education/classroom

View on GitHub
app/views/assignments/_assignment_form_options.html.erb

Summary

Maintainability
Test Coverage
<% view = FormView.new(subject: @assignment, organization: @organization) %>
<% if view.errors_for?(:base) %>
  <dd class="error mb-1 text-red text-bold f4"><%= view.error_message_for(:base) %></dd>
<% end %>
<dl class="<%= view.form_class_for(:title) %> mt-0">
  <dt><%= f.label :title %></dt>
  <dd><%= f.text_field :title, class: 'textfield form-control input-block', autocomplete: :off, oninput: 'removeErrorBox(el);' %></dd>
  <%= render('shared/form_error', errors: view.error_message_for(:title)) if view.errors_for?(:title) %>
</dl>

<dl class="<%= view.form_class_for(:slug) %>">
  <dt><%= f.label :slug %></dt>
  <dd><%= f.text_field :slug, class: 'textfield form-control input-block', autocomplete: :off, oninput: 'removeErrorBox(this);' %></dd>
  <%= render('shared/form_error', errors: view.error_message_for(:slug)) if view.errors_for?(:slug) %>
  <p class="f6 text-gray my-2"><%= t('assignment_form.slug_note') %></p>
</dl>

<dl class="<%= view.form_class_for(:public_repo) %> my-4">
  <div class="form-checkbox">
    <label>
      <%= f.radio_button :visibility, "public", checked: view.public_is_checked? %>
      <div class="d-flex">
        <div>
          <%= octicon 'repo', height: 32, class: "text-gray mr-2" %>
        </div>
        <div>
          Public
          <span class="d-block f6 text-gray text-normal mt-1">Submit assignments using public repositories. All submissions will be visible to the world.</span>
        </div>
      </div>
    </label>
  </div>

  <div class="form-checkbox">
    <label>
      <%= f.radio_button :visibility, "private", checked: !view.public_is_checked?, disabled: !view.private_repos_available? %>
      <div class="d-flex">
        <div>
          <%= octicon 'lock', height: 32, class: "text-orange mr-2" %>
        </div>
        <div>
          Private
          <span class="d-block f6 text-gray text-normal mt-1">
            <p<%= " style=color: #6A737D" unless view.private_repos_available? %>">
              Submit assignments using private repositories. Submissions will only be visible to the submitter and organization owners. Editing this after assignments are created will not retroactively change their visibility.
            </p>
            <% unless view.private_repos_available? %>
              <strong>
                <p>Private repositories aren't available for this organization. However, current faculty may be eligible for free, unlimited private repositories.</p>
                <p><%= link_to "Apply for free private repositories", "https://education.github.com/discount_requests/new" %></p>
              </strong>
            <% end %>
          </span>
        </div>
      </div>
    </label>
  </div>

  <%= render('shared/form_error', errors: view.error_message_for(:public_repo)) if view.errors_for?(:public_repo) %>
</dl>

<div class="Box my-4">
  <div class="Box-header">
    <h3 class="Box-title">Optional</h3>
  </div>
  <div class="Box-body">
    <% unless GitHubClassroom.enterprise? %>
      <dl class="form-group mt-0 <%= view.form_class_for(:starter_code_repository) %>">
        <dt><label>Add starter code</label></dt>
        <dd>
          <%= f.text_field :starter_code_repository,
            class: "textfield js-autocomplete-textfield form-control input-contrast input-block",
            name: "repo_name",
            type: "text",
            value: @assignment.starter_code_repository.try(:full_name),
            placeholder: @assignment.starter_code_repository.try(:full_name) ||
                'Find a GitHub repository…',
            autocomplete: "off",
            oninput: "importOptions(this.value);removeErrorBox(this);",
            data: { "autocomplete-search-endpoint": "github_repos" }
          %>
        </dd>

        <dd class="dd-autocomplete-suggestions"><%= render_autocomplete_suggestions_container %></dd>
        <input class="js-autocomplete-resource-id" type="hidden" name="repo_id" />

        <%= render('shared/form_error', errors: view.error_message_for(:starter_code_repository)) if view.errors_for?(:starter_code_repository) %>

        <div id="import-options" style=<%= "display:none;" if not @assignment.starter_code? %>>
          <div class="form-checkbox">
            <label><%= f.radio_button :template_repos_enabled, true, checked: (true if @assignment.new_record? || @assignment.template_repos_enabled?) %> Import starter code using a template repository</label>
            <span class="Label border border-green text-gray-dark">Beta</span>
            <span class="note">Starter code repository should be a <%= link_to "template repository", "https://help.github.com/en/articles/creating-a-template-repository", target: "_blank" %>. Increases student repository creation and code import speed dramatically.</span>
          </div>

          <div class="form-checkbox">
            <label><%= f.radio_button :template_repos_enabled, false %> Import starter code using source importer</label>
            <span class="note">Slower than template repository method, but the repository doesn't need to be a template.</span>
          </div>
        </div>
      </dl>
    <% end %>

    <hr class="pt-3"/>

    <dl class="<%= view.form_class_for(:deadline) %>">
      <dt><label>Deadline</label></dt>
      <dd><%= f.text_field :deadline, class: 'jquery-datetimepicker form-control input-block', value: DeadlineFormatHelper.convert(f.object.deadline), autocomplete: :off %></dd>
      <%= render('shared/form_error', errors: view.error_message_for(:deadline)) if view.errors_for?(:deadline) %>
      <dd class="col-md-10 text-small text-gray my-2">After the deadline, GitHub Classroom will save the latest commit from each repository as a submission. Submission commits are viewable on the assignment page.</dd>
    </dl>

    <hr class="pt-2"/>

    <dl class="form-group">
      <h4 class="h5">Enable assignment invitation link</h4>
      <div class="form-checkbox">
        <label>
          <%= f.check_box :invitations_enabled %>
           Allow students to accept the assignment
        </label>
        <p class="text-small text-normal text-gray mt-1">
          While enabled, anyone with access to the link will be able to accept and access this assignment
        </p>
      </div>
    </dl>

    <hr class="pt-2"/>

    <dl class="form-group">
      <h4 class="h5">Student admin access</h4>
      <div class="form-checkbox">
        <label>
          <%= f.check_box :students_are_repo_admins %>
          Grant students admin access to their repository
        </label>
        <p class="text-small text-gray text-normal mt-1">Editing this after assignments are created will not retroactively change their permissions.</p>
      </div>
    </dl>

  </div>
</div>