<commit_before><% content_for :head do %>
  <%= javascript_include_tag 'jquery-ui-timepicker-addon' %>
  <%= stylesheet_link_tag 'common/jquery-ui', 'common/jquery-ui-timepicker-addon' %>
  <%= javascript_include_tag 'PeriodDeltaChain/PeriodDeltaChain' %>
  <%= javascript_include_tag 'moment-with-langs.min', 'localize_date' %>
  <%= javascript_include_tag 'help_system' %>

  <%= render partial: 'boot',
             formats: [:js],
             handlers: [:erb] %>
<% end %>

<%= render 'shared/flash_message' %>

<%= render partial: 'shared/navigation_warning',
           formats: [:js],
           handlers: [:erb] %>

<%= form_for @assignment do |f| %>

  <%= render partial: 'shared/error_explanation',
             locals: { model: @assignment } %>

  <%# The locale format string used for localising the date/time %>
  <%= raw(f.text_field nil,
                       id: 'format',
                       class: 'hidden',
                       value: t('date.formats.js_date_time'),
                       disabled: true) %>

  <%# Assignment properties %>
  <fieldset>
    <legend>
      <span><%= t('assignment.properties') %></span>
    </legend>

    <div class='help assignment_properties_help'>
      <p class='help-message-box assignment_properties_help'>
        <%= t('assignment.help.assignment_form.properties').html_safe %>
      </p>
    </div>

    <div>
      <%= raw(f.label :short_identifier,
                      t('assignment.short_identifier').html_safe ) %>
      <%= raw(f.text_field :short_identifier,
                           id: 'assignment_short_identifier',
                           onchange: 'set_onbeforeunload(true);',
                           size: 35,
                           maxlength: 30,
                           required: true) %>      
    </div>

    <div>
      <%= raw(f.label :description,
                      t('assignment.name').html_safe ) %>
      <%= raw(f.text_field :description,
                           onchange: 'set_onbeforeunload(true);',
                           size: 35,
                           required: true) %>
    </div>

    <div>
      <%= raw(f.label :message ) %>
      <%= raw(f.text_area :message,
                          cols: 65,
                          rows: 8,
                          onchange: 'set_onbeforeunload(true);') %>
    </div>

    <div>
      <%= raw(f.label :repository_folder,
                      t(:repository_folder).html_safe) %>
      /
      <%= raw(f.text_field :repository_folder,
                           onchange: 'set_onbeforeunload(true);',
                           size: 34,
                           required: true) %>
    </div>

    <% if !@sections.empty? %>
      <div id='section_due_dates_type_form_right' class='information'>
        <%= t('assignment.section_due_date_option') %>
      </div>

      <div id='section_due_dates_type_form'>
        <%= raw(f.label :section_due_dates_type, t('section.due_dates_type') ) %>
        <%= raw(f.check_box :section_due_dates_type,
                            checked: @assignment.section_due_dates_type,
                            onclick: 'set_onbeforeunload(true);') %>
      </div>

      <div id='section_due_dates_information'
           style='<%= 'display: none' unless @assignment.section_due_dates_type %>'>
        <p class='information'>
          <%= raw t('assignment.section_due_dates_info') %>
        </p>
        <div class='section_due_date_form'>
          <% @index = 1 %>
          <%= f.fields_for :section_due_dates,
                           @section_due_dates do |due_date_f| %>
            <p>
              <%= label 'section', t('section.legend') %> <%= Section.find(due_date_f.object.section_id).name %>
              <br>
              <%= due_date_f.text_field :section_id, class: 'hidden' %>
              <br>
              <%= due_date_f.label :due_date, t('due_date') %>
              <%= raw(due_date_f.text_field :due_date,
                                            id: "actual_section_due_date_#{@index}",
                                            class: 'hidden actual_section_due_date') %>
              <%= text_field_tag "section_due_date_#{@index}",
                                 nil,
                                 { onchange: 'set_onbeforeunload(true);',
                                   size: 30,
                                   class: 'section_due_date' } %>
            </p>
            <% @index += 1 %>
          <% end %>
        </div>
      </div>
    <% end %>

    <div>
      <%= raw(f.label :due_date,
                      t('assignment.due_date').html_safe) %>
      <%= raw(f.text_field :due_date,
                           id: 'actual_assignment_due_date',
                           class: 'hidden') %>
      <%= text_field_tag 'assignment_due_date',
                         nil,
                         { onchange: 'set_onbeforeunload(true);',
                           size: 35,
                           required: true } %>
    </div>

    <div>
      <%= raw(f.check_box :allow_web_submits,
                          checked: @assignment.allow_web_submits,
                          onclick: 'set_onbeforeunload(true);') %>
      <%= raw(f.label :allow_web_submits,
                      t('assignment.allow_web_submits')) %>
    </div>

    <div>
      <%= raw(f.check_box :display_grader_names_to_students,
                          checked: @assignment.display_grader_names_to_students,
                          onclick: 'set_onbeforeunload(true);') %>
      <%= raw(f.label :display_grader_names_to_students,
                      t('assignment.display_grader_names_to_students')) %>
    </div>

    <div>
      <%= raw(f.check_box :is_hidden,
                          checked: @assignment.is_hidden,
                          onclick: 'set_onbeforeunload(true);') %>
      <%= f.label :is_hidden, t('assignment.is_hidden') %>
    </div>
  </fieldset>

  <%# Marking scheme %>
  <fieldset>
    <legend>
      <span><%= t('assignment.marking_scheme.title') %></span>
    </legend>

    <div id='marking_scheme_notice' class='warning' style='display:none'>
      <%= t('assignment.notice.change_marking_scheme_type')%>
    </div>

    <div class='help assignment_marking_scheme_help'>
      <p class='help-message-box assignment_marking_scheme_help'>
        <%= t('assignment.help.assignment_form.marking_scheme') %>
      </p>
    </div>

    <% Assignment::MARKING_SCHEME_TYPE.each do |key, value| %>
      <p>
        <%= raw(f.radio_button :marking_scheme_type,
                               Assignment::MARKING_SCHEME_TYPE[key],
                               checked: @assignment.marking_scheme_type == Assignment::MARKING_SCHEME_TYPE[key],
                               onchange: "set_onbeforeunload(true);
                                             notice_marking_scheme_changed(#{@assignment.id.nil?},
                                               '#{Assignment::MARKING_SCHEME_TYPE[key]}',
                                               '#{@assignment.marking_scheme_type}')") %>

        <%= raw(f.label('marking_scheme_type_' + Assignment::MARKING_SCHEME_TYPE[key],
                        t("assignment.marking_scheme.#{value}"),
                        class: 'radio_label')) %>
      </p>
    <% end %>
  </fieldset>

  <%# Required files %>
  <fieldset>
    <legend>
      <span><%= t('assignment.required_files') %></span>
    </legend>

    <div class='help assignment_required_files_help'>
      <p class='help-message-box assignment_required_files_help'>
        <%= t('assignment.help.assignment_form.required_files') %>
      </p>
    </div>

    <h4><%= t('assignment.required_files_by_student') %></h4>
    <% @show_checkbox_required_files = true %>
    <div id='assignment_files'>
      <%= f.fields_for :assignment_files do |assignment_file_form| %>
        <%= render partial: 'assignment_file',
                   locals: { assignment_file: assignment_file_form.object,
                             form: f } %>
      <% end %>
    </div>
     <p id='assignment_file_add_link'>
        <%= add_assignment_file_link t('assignment.add_required_file'), f %>
     </p>
     <br>
     <% if @show_checkbox_required_files %>
	   <%= f.check_box :only_required_files,
	                   checked: @assignment.only_required_files,
	                   onclick: 'set_onbeforeunload(true);' 
	   %>
	   <%= f.label :only_required_files,
	                 t('required_file_warning'),
	                 { id: "assignment_only_required_files_label" }
	   %>
	 <% else %>
	   <%= f.check_box :only_required_files,
	                   { checked: @assignment.only_required_files,
	                     id: "assignment_only_required_files_edit",
	                     onclick: 'set_onbeforeunload(true);' }
	   %>
	   <%= f.label :only_required_files,
	                 t('required_file_warning'),
	                 { id: "assignment_only_required_files_edit_label" }
	   %>
	 <% end %>
  </fieldset>

  <%# Assignment types %>
  <fieldset>
    <legend>
      <span><%= t('assignment.group.properties') %></span>
    </legend>

    <div class='help assignment_assignment_type_help'>
      <p class='help-message-box assignment_assignment_type_help'>
        <%= t('assignment.help.assignment_form.assignment_type').html_safe %>
      </p>
    </div>

    <p id='persist_groups_assignment_style'
       style='<%= 'display: none' unless @assignments.size > 0 && @assignment.id.nil? %>'>
      <%= check_box_tag 'persist_groups',
                        '0',
                        false,
                        id: 'persist_groups',
                        onclick: 'set_onbeforeunload(true);' %>
      <%= label_tag 'persist_groups',
                    t('assignment.group.persist_group_from'),
                    class: 'checkbox_label' %>
      <select id='persist_groups_assignment'
              name='persist_groups_assignment'
              data-path='<%= update_group_properties_on_persist_assignments_path %>'
              disabled>
        <% @assignments.each do |assignment| %>
          <option value='<%= assignment.id %>'>
            <%= assignment.short_identifier %>
          </option>
        <% end %>
      </select>
    </p>
    <p id='is_group_assignment_style'>
      <%= raw(check_box_tag 'is_group_assignment',
                            true,
                            false,
                            id: 'is_group_assignment',
                            onchange: 'set_onbeforeunload(true);') %>
      <%= raw(label_tag 'is_group_assignment',
                        t('assignment.group.work_in_groups'),
                        class: 'checkbox_label') %>
    </p>
    <fieldset class='group_properties disable' style='display: none' disabled>
      <legend>
        <span><%= t('assignment.group.properties') %></span>
      </legend>

      <div id='group_properties'>
        <p id='student_form_groups_style'>
          <%= raw(f.check_box :student_form_groups,
                              id: 'student_form_groups',
                              onchange: 'set_onbeforeunload(true);') %>
          <%= raw(label_tag 'student_form_groups',
                             t('assignment.group.students_allowed_form_groups'),
                             class: 'checkbox_label') %>
        </p>

        <p id='group_limit_style'>
          <%= raw(f.label :group_min,
                          t('assignment.group.limit_min').html_safe,
                          class: 'inline_label') %>
          <%= raw(f.number_field :group_min,
                                 max: 999,
                                 onchange: 'set_onbeforeunload(true);',
                                 disabled: true,
                                 min: 1) %>
          <%= raw(f.label :group_max,
                          t('assignment.group.limit_max'),
                          class: 'inline_label') %>
          <%= raw(f.number_field :group_max,
                                 max: 999,
                                 onchange: 'set_onbeforeunload(true);',
                                 disabled: true,
                                 min: 1) %>
        </p>

        <p id='group_name_autogenerated_style'>
          <%= raw(f.check_box :group_name_autogenerated, {}, 'true', 'false') %>
          <%= raw(f.label :group_name_autogenerated,
                          t('assignment.group.name_autogenerated'),
                          class: 'checkbox_label',
                          onchange: 'set_onbeforeunload(true);') %>

        </p>
      </div>
    </fieldset>
  </fieldset>

  <%# Submission rules %>
  <fieldset>
    <legend>
      <span><%= t('assignment.submission_rules') %></span>
    </legend>

    <div class='help assignment_submission_rules_help'>
      <p class='help-message-box assignment_submission_rules_help'>
        <%= t('assignment.help.assignment_form.submission_rules') %>
      </p>
    </div>

    <%= f.fields_for :submission_rule do |rule| %>
      <h5><%= t('assignment.submission.penalty_rules').html_safe %></h5>

      <p>
        <%= rule.radio_button :type,
                              'NoLateSubmissionRule',
                              checked: true,
                              onchange: 'change_submission_rule();',
                              id: 'no_late_submission_rule' %>
        <%= label_tag 'no_late_submission_rule',
                      t('submission_rules.no_late_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>

      <p>
        <%= rule.radio_button :type,
                              'GracePeriodSubmissionRule',
                              onchange: 'change_submission_rule(); ',
                              id: 'grace_period_submission_rule' %>
        <%= label_tag 'grace_period_submission_rule',
                      t('submission_rules.grace_period_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>
      <div id='grace_periods'>
        <% if rule.object.type.to_s == 'GracePeriodSubmissionRule' %>
          <%= rule.fields_for :periods do |period_form| %>
            <%
              # The below conditional is meant to filter out periods that do not match
              # the currently selected submission rule. This only happens when we fail to
              # save a new submission rule.
              if rule.object.type.to_s == rule.object.class.to_s or period_form.object.id.nil? %>
              <%= render partial: 'grace_period',
                         locals: { grace_period: period_form.object,
                                   pf: rule } %>
            <% end %>
          <% end %>
        <% end %>
      </div>
      <div class='sub_rule_link'>
        <span class='grace_periods_link'>
          <%= add_grace_period_link(t('submission_rules.grace_period_submission_rule.add_grace_period'),
                                    rule,
                                    'grace_period_link') %>
        </span>
      </div>

      <p>
        <%= rule.radio_button :type,
                              'PenaltyDecayPeriodSubmissionRule',
                              onchange: 'change_submission_rule();',
                              id: 'penalty_decay_period_submission_rule' %>
        <%= label_tag 'penalty_decay_period_submission_rule',
                      t('submission_rules.penalty_decay_period_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>
      <div id='penalty_decay_periods'>
        <% if rule.object.type.to_s == 'PenaltyDecayPeriodSubmissionRule' %>
          <%= rule.fields_for :periods do |period_form| %>
            <%
              # The below conditional is meant to filter out periods that do not match
              # the currently selected submission rule. This only happens when we fail to
              # save a new submission rule.
              if rule.object.type.to_s == rule.object.class.to_s or period_form.object.id.nil? %>
              <%= render partial: 'penalty_decay_period',
                         locals: { penalty_decay_period: period_form.object,
                                   pf: rule } %>
            <% end %>
          <% end %>
        <% end %>
      </div>
      <div class='sub_rule_link'>
        <span class='penalty_decay_period_link'>
          <%= add_penalty_decay_period_link(t('submission_rules.penalty_decay_period_submission_rule.add_penalty_decay'),
                                            rule,
                                            'penalty_decay_period_link') %>
        </span>
      </div>

      <p>
        <%= rule.radio_button :type,
                              'PenaltyPeriodSubmissionRule',
                              onchange: 'change_submission_rule();',
                              id: 'penalty_period_submission_rule' %>
        <%= label_tag 'penalty_period_submission_rule',
                      t('submission_rules.penalty_period_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>
      <div id='penalty_periods'>
        <% if rule.object.type.to_s == 'PenaltyPeriodSubmissionRule' %>
          <%= rule.fields_for :periods do |period_form| %>
            <%
              # The below conditional is meant to filter out periods that do not match
              # the currently selected submission rule. This only happens when we fail to
              # save a new submission rule.
              if rule.object.type.to_s == rule.object.class.to_s or period_form.object.id.nil? %>
              <%= render partial: 'penalty_period',
                         locals: { penalty_period: period_form.object,
                                   pf: rule } %>
            <% end %>
          <% end %>
        <% end %>
      </div>
      <div class='sub_rule_link'>
        <span class='penalty_periods_link'>
          <%= add_penalty_period_link(t('submission_rules.penalty_period_submission_rule.add_penalty_period'),
                                      rule,
                                      'penalty_period_link') %>
        </span>
      </div>
    <%- end -%>
  </fieldset>

  <%# Remark request rules %>
  <fieldset>
    <legend>
      <span><%= t('assignment.remark.rules')%></span>
    </legend>

    <div class='help assignment_remark_request_rules_help'>
      <p class='help-message-box assignment_remark_request_rules_help'>
        <%= t('assignment.help.assignment_form.remark_request_rules') %>
      </p>
    </div>

    <p id='allow_remark_requests'>
      <%= raw(f.check_box(:allow_remarks,
                          id: 'allow_remarks',
                          onchange: 'set_onbeforeunload(true);')) %>
      <%= raw(f.label('allow_remarks',
                      t('assignment.remark.allow'),
                      class: 'checkbox_label',
                      for: 'allow_remarks')) %>
    </p>

    <div id='remark_properties'
         style="<%= 'display:none' unless @assignment.allow_remarks %>"
         class="<%= 'disable' unless @assignment.allow_remarks %>">
      <div>
        <%= raw(f.label('remark_due_date',
                        t('assignment.remark.due_date'),
                        class: 'inline_label')) %>
        <%= raw(f.text_field :remark_due_date,
                             id: 'actual_remark_due_date',
                             class: 'hidden') %>
        <%= text_field_tag 'assignment_remark_due_date',
                           nil,
                           { onchange: 'set_onbeforeunload(true);',
                             size: 35 } %>
      </div>

      <div>
        <%= raw(f.label('remark_message',
                        t('assignment.remark.message'),
                        class: 'textbox_label')) %>
        <%= raw(f.text_area :remark_message,
                            rows: 8,
                            cols: 65,
                            onchange: 'set_onbeforeunload(true);') %>
      </div>
    </div>
  </fieldset>

  <%= f.submit t(:submit),
               data: { disable_with: t('working') },
               onclick: 'set_onbeforeunload(false);' %>
<% end %>
<commit_msg>Added the onkeyup for the short identifier.<commit_after><% content_for :head do %>
  <%= javascript_include_tag 'jquery-ui-timepicker-addon' %>
  <%= stylesheet_link_tag 'common/jquery-ui', 'common/jquery-ui-timepicker-addon' %>
  <%= javascript_include_tag 'PeriodDeltaChain/PeriodDeltaChain' %>
  <%= javascript_include_tag 'moment-with-langs.min', 'localize_date' %>
  <%= javascript_include_tag 'help_system' %>

  <%= render partial: 'boot',
             formats: [:js],
             handlers: [:erb] %>
<% end %>

<%= render 'shared/flash_message' %>

<%= render partial: 'shared/navigation_warning',
           formats: [:js],
           handlers: [:erb] %>

<%= form_for @assignment do |f| %>

  <%= render partial: 'shared/error_explanation',
             locals: { model: @assignment } %>

  <%# The locale format string used for localising the date/time %>
  <%= raw(f.text_field nil,
                       id: 'format',
                       class: 'hidden',
                       value: t('date.formats.js_date_time'),
                       disabled: true) %>

  <%# Assignment properties %>
  <fieldset>
    <legend>
      <span><%= t('assignment.properties') %></span>
    </legend>

    <div class='help assignment_properties_help'>
      <p class='help-message-box assignment_properties_help'>
        <%= t('assignment.help.assignment_form.properties').html_safe %>
      </p>
    </div>

    <div>
      <%= raw(f.label :short_identifier,
                      t('assignment.short_identifier').html_safe ) %>
      <%= raw(f.text_field :short_identifier,
                           id: 'assignment_short_identifier',
                           onchange: 'set_onbeforeunload(true);',
						   onKeyUp: "document.getElementById('assignment_repository_folder').value=this.value",
                           size: 35,
                           maxlength: 30,
                           required: true) %>      
    </div>

    <div>
      <%= raw(f.label :description,
                      t('assignment.name').html_safe ) %>
      <%= raw(f.text_field :description,
                           onchange: 'set_onbeforeunload(true);',
                           size: 35,
                           required: true) %>
    </div>

    <div>
      <%= raw(f.label :message ) %>
      <%= raw(f.text_area :message,
                          cols: 65,
                          rows: 8,
                          onchange: 'set_onbeforeunload(true);') %>
    </div>

    <div>
      <%= raw(f.label :repository_folder,
                      t(:repository_folder).html_safe) %>
      /
      <%= raw(f.text_field :repository_folder,
                           onchange: 'set_onbeforeunload(true);',
                           size: 34,
                           required: true) %>
    </div>

    <% if !@sections.empty? %>
      <div id='section_due_dates_type_form_right' class='information'>
        <%= t('assignment.section_due_date_option') %>
      </div>

      <div id='section_due_dates_type_form'>
        <%= raw(f.label :section_due_dates_type, t('section.due_dates_type') ) %>
        <%= raw(f.check_box :section_due_dates_type,
                            checked: @assignment.section_due_dates_type,
                            onclick: 'set_onbeforeunload(true);') %>
      </div>

      <div id='section_due_dates_information'
           style='<%= 'display: none' unless @assignment.section_due_dates_type %>'>
        <p class='information'>
          <%= raw t('assignment.section_due_dates_info') %>
        </p>
        <div class='section_due_date_form'>
          <% @index = 1 %>
          <%= f.fields_for :section_due_dates,
                           @section_due_dates do |due_date_f| %>
            <p>
              <%= label 'section', t('section.legend') %> <%= Section.find(due_date_f.object.section_id).name %>
              <br>
              <%= due_date_f.text_field :section_id, class: 'hidden' %>
              <br>
              <%= due_date_f.label :due_date, t('due_date') %>
              <%= raw(due_date_f.text_field :due_date,
                                            id: "actual_section_due_date_#{@index}",
                                            class: 'hidden actual_section_due_date') %>
              <%= text_field_tag "section_due_date_#{@index}",
                                 nil,
                                 { onchange: 'set_onbeforeunload(true);',
                                   size: 30,
                                   class: 'section_due_date' } %>
            </p>
            <% @index += 1 %>
          <% end %>
        </div>
      </div>
    <% end %>

    <div>
      <%= raw(f.label :due_date,
                      t('assignment.due_date').html_safe) %>
      <%= raw(f.text_field :due_date,
                           id: 'actual_assignment_due_date',
                           class: 'hidden') %>
      <%= text_field_tag 'assignment_due_date',
                         nil,
                         { onchange: 'set_onbeforeunload(true);',
                           size: 35,
                           required: true } %>
    </div>

    <div>
      <%= raw(f.check_box :allow_web_submits,
                          checked: @assignment.allow_web_submits,
                          onclick: 'set_onbeforeunload(true);') %>
      <%= raw(f.label :allow_web_submits,
                      t('assignment.allow_web_submits')) %>
    </div>

    <div>
      <%= raw(f.check_box :display_grader_names_to_students,
                          checked: @assignment.display_grader_names_to_students,
                          onclick: 'set_onbeforeunload(true);') %>
      <%= raw(f.label :display_grader_names_to_students,
                      t('assignment.display_grader_names_to_students')) %>
    </div>

    <div>
      <%= raw(f.check_box :is_hidden,
                          checked: @assignment.is_hidden,
                          onclick: 'set_onbeforeunload(true);') %>
      <%= f.label :is_hidden, t('assignment.is_hidden') %>
    </div>
  </fieldset>

  <%# Marking scheme %>
  <fieldset>
    <legend>
      <span><%= t('assignment.marking_scheme.title') %></span>
    </legend>

    <div id='marking_scheme_notice' class='warning' style='display:none'>
      <%= t('assignment.notice.change_marking_scheme_type')%>
    </div>

    <div class='help assignment_marking_scheme_help'>
      <p class='help-message-box assignment_marking_scheme_help'>
        <%= t('assignment.help.assignment_form.marking_scheme') %>
      </p>
    </div>

    <% Assignment::MARKING_SCHEME_TYPE.each do |key, value| %>
      <p>
        <%= raw(f.radio_button :marking_scheme_type,
                               Assignment::MARKING_SCHEME_TYPE[key],
                               checked: @assignment.marking_scheme_type == Assignment::MARKING_SCHEME_TYPE[key],
                               onchange: "set_onbeforeunload(true);
                                             notice_marking_scheme_changed(#{@assignment.id.nil?},
                                               '#{Assignment::MARKING_SCHEME_TYPE[key]}',
                                               '#{@assignment.marking_scheme_type}')") %>

        <%= raw(f.label('marking_scheme_type_' + Assignment::MARKING_SCHEME_TYPE[key],
                        t("assignment.marking_scheme.#{value}"),
                        class: 'radio_label')) %>
      </p>
    <% end %>
  </fieldset>

  <%# Required files %>
  <fieldset>
    <legend>
      <span><%= t('assignment.required_files') %></span>
    </legend>

    <div class='help assignment_required_files_help'>
      <p class='help-message-box assignment_required_files_help'>
        <%= t('assignment.help.assignment_form.required_files') %>
      </p>
    </div>

    <h4><%= t('assignment.required_files_by_student') %></h4>
    <% @show_checkbox_required_files = true %>
    <div id='assignment_files'>
      <%= f.fields_for :assignment_files do |assignment_file_form| %>
        <%= render partial: 'assignment_file',
                   locals: { assignment_file: assignment_file_form.object,
                             form: f } %>
      <% end %>
    </div>
     <p id='assignment_file_add_link'>
        <%= add_assignment_file_link t('assignment.add_required_file'), f %>
     </p>
     <br>
     <% if @show_checkbox_required_files %>
	   <%= f.check_box :only_required_files,
	                   checked: @assignment.only_required_files,
	                   onclick: 'set_onbeforeunload(true);' 
	   %>
	   <%= f.label :only_required_files,
	                 t('required_file_warning'),
	                 { id: "assignment_only_required_files_label" }
	   %>
	 <% else %>
	   <%= f.check_box :only_required_files,
	                   { checked: @assignment.only_required_files,
	                     id: "assignment_only_required_files_edit",
	                     onclick: 'set_onbeforeunload(true);' }
	   %>
	   <%= f.label :only_required_files,
	                 t('required_file_warning'),
	                 { id: "assignment_only_required_files_edit_label" }
	   %>
	 <% end %>
  </fieldset>

  <%# Assignment types %>
  <fieldset>
    <legend>
      <span><%= t('assignment.group.properties') %></span>
    </legend>

    <div class='help assignment_assignment_type_help'>
      <p class='help-message-box assignment_assignment_type_help'>
        <%= t('assignment.help.assignment_form.assignment_type').html_safe %>
      </p>
    </div>

    <p id='persist_groups_assignment_style'
       style='<%= 'display: none' unless @assignments.size > 0 && @assignment.id.nil? %>'>
      <%= check_box_tag 'persist_groups',
                        '0',
                        false,
                        id: 'persist_groups',
                        onclick: 'set_onbeforeunload(true);' %>
      <%= label_tag 'persist_groups',
                    t('assignment.group.persist_group_from'),
                    class: 'checkbox_label' %>
      <select id='persist_groups_assignment'
              name='persist_groups_assignment'
              data-path='<%= update_group_properties_on_persist_assignments_path %>'
              disabled>
        <% @assignments.each do |assignment| %>
          <option value='<%= assignment.id %>'>
            <%= assignment.short_identifier %>
          </option>
        <% end %>
      </select>
    </p>
    <p id='is_group_assignment_style'>
      <%= raw(check_box_tag 'is_group_assignment',
                            true,
                            false,
                            id: 'is_group_assignment',
                            onchange: 'set_onbeforeunload(true);') %>
      <%= raw(label_tag 'is_group_assignment',
                        t('assignment.group.work_in_groups'),
                        class: 'checkbox_label') %>
    </p>
    <fieldset class='group_properties disable' style='display: none' disabled>
      <legend>
        <span><%= t('assignment.group.properties') %></span>
      </legend>

      <div id='group_properties'>
        <p id='student_form_groups_style'>
          <%= raw(f.check_box :student_form_groups,
                              id: 'student_form_groups',
                              onchange: 'set_onbeforeunload(true);') %>
          <%= raw(label_tag 'student_form_groups',
                             t('assignment.group.students_allowed_form_groups'),
                             class: 'checkbox_label') %>
        </p>

        <p id='group_limit_style'>
          <%= raw(f.label :group_min,
                          t('assignment.group.limit_min').html_safe,
                          class: 'inline_label') %>
          <%= raw(f.number_field :group_min,
                                 max: 999,
                                 onchange: 'set_onbeforeunload(true);',
                                 disabled: true,
                                 min: 1) %>
          <%= raw(f.label :group_max,
                          t('assignment.group.limit_max'),
                          class: 'inline_label') %>
          <%= raw(f.number_field :group_max,
                                 max: 999,
                                 onchange: 'set_onbeforeunload(true);',
                                 disabled: true,
                                 min: 1) %>
        </p>

        <p id='group_name_autogenerated_style'>
          <%= raw(f.check_box :group_name_autogenerated, {}, 'true', 'false') %>
          <%= raw(f.label :group_name_autogenerated,
                          t('assignment.group.name_autogenerated'),
                          class: 'checkbox_label',
                          onchange: 'set_onbeforeunload(true);') %>

        </p>
      </div>
    </fieldset>
  </fieldset>

  <%# Submission rules %>
  <fieldset>
    <legend>
      <span><%= t('assignment.submission_rules') %></span>
    </legend>

    <div class='help assignment_submission_rules_help'>
      <p class='help-message-box assignment_submission_rules_help'>
        <%= t('assignment.help.assignment_form.submission_rules') %>
      </p>
    </div>

    <%= f.fields_for :submission_rule do |rule| %>
      <h5><%= t('assignment.submission.penalty_rules').html_safe %></h5>

      <p>
        <%= rule.radio_button :type,
                              'NoLateSubmissionRule',
                              checked: true,
                              onchange: 'change_submission_rule();',
                              id: 'no_late_submission_rule' %>
        <%= label_tag 'no_late_submission_rule',
                      t('submission_rules.no_late_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>

      <p>
        <%= rule.radio_button :type,
                              'GracePeriodSubmissionRule',
                              onchange: 'change_submission_rule(); ',
                              id: 'grace_period_submission_rule' %>
        <%= label_tag 'grace_period_submission_rule',
                      t('submission_rules.grace_period_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>
      <div id='grace_periods'>
        <% if rule.object.type.to_s == 'GracePeriodSubmissionRule' %>
          <%= rule.fields_for :periods do |period_form| %>
            <%
              # The below conditional is meant to filter out periods that do not match
              # the currently selected submission rule. This only happens when we fail to
              # save a new submission rule.
              if rule.object.type.to_s == rule.object.class.to_s or period_form.object.id.nil? %>
              <%= render partial: 'grace_period',
                         locals: { grace_period: period_form.object,
                                   pf: rule } %>
            <% end %>
          <% end %>
        <% end %>
      </div>
      <div class='sub_rule_link'>
        <span class='grace_periods_link'>
          <%= add_grace_period_link(t('submission_rules.grace_period_submission_rule.add_grace_period'),
                                    rule,
                                    'grace_period_link') %>
        </span>
      </div>

      <p>
        <%= rule.radio_button :type,
                              'PenaltyDecayPeriodSubmissionRule',
                              onchange: 'change_submission_rule();',
                              id: 'penalty_decay_period_submission_rule' %>
        <%= label_tag 'penalty_decay_period_submission_rule',
                      t('submission_rules.penalty_decay_period_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>
      <div id='penalty_decay_periods'>
        <% if rule.object.type.to_s == 'PenaltyDecayPeriodSubmissionRule' %>
          <%= rule.fields_for :periods do |period_form| %>
            <%
              # The below conditional is meant to filter out periods that do not match
              # the currently selected submission rule. This only happens when we fail to
              # save a new submission rule.
              if rule.object.type.to_s == rule.object.class.to_s or period_form.object.id.nil? %>
              <%= render partial: 'penalty_decay_period',
                         locals: { penalty_decay_period: period_form.object,
                                   pf: rule } %>
            <% end %>
          <% end %>
        <% end %>
      </div>
      <div class='sub_rule_link'>
        <span class='penalty_decay_period_link'>
          <%= add_penalty_decay_period_link(t('submission_rules.penalty_decay_period_submission_rule.add_penalty_decay'),
                                            rule,
                                            'penalty_decay_period_link') %>
        </span>
      </div>

      <p>
        <%= rule.radio_button :type,
                              'PenaltyPeriodSubmissionRule',
                              onchange: 'change_submission_rule();',
                              id: 'penalty_period_submission_rule' %>
        <%= label_tag 'penalty_period_submission_rule',
                      t('submission_rules.penalty_period_submission_rule.form_description'),
                      class: 'radio_label' %>
      </p>
      <div id='penalty_periods'>
        <% if rule.object.type.to_s == 'PenaltyPeriodSubmissionRule' %>
          <%= rule.fields_for :periods do |period_form| %>
            <%
              # The below conditional is meant to filter out periods that do not match
              # the currently selected submission rule. This only happens when we fail to
              # save a new submission rule.
              if rule.object.type.to_s == rule.object.class.to_s or period_form.object.id.nil? %>
              <%= render partial: 'penalty_period',
                         locals: { penalty_period: period_form.object,
                                   pf: rule } %>
            <% end %>
          <% end %>
        <% end %>
      </div>
      <div class='sub_rule_link'>
        <span class='penalty_periods_link'>
          <%= add_penalty_period_link(t('submission_rules.penalty_period_submission_rule.add_penalty_period'),
                                      rule,
                                      'penalty_period_link') %>
        </span>
      </div>
    <%- end -%>
  </fieldset>

  <%# Remark request rules %>
  <fieldset>
    <legend>
      <span><%= t('assignment.remark.rules')%></span>
    </legend>

    <div class='help assignment_remark_request_rules_help'>
      <p class='help-message-box assignment_remark_request_rules_help'>
        <%= t('assignment.help.assignment_form.remark_request_rules') %>
      </p>
    </div>

    <p id='allow_remark_requests'>
      <%= raw(f.check_box(:allow_remarks,
                          id: 'allow_remarks',
                          onchange: 'set_onbeforeunload(true);')) %>
      <%= raw(f.label('allow_remarks',
                      t('assignment.remark.allow'),
                      class: 'checkbox_label',
                      for: 'allow_remarks')) %>
    </p>

    <div id='remark_properties'
         style="<%= 'display:none' unless @assignment.allow_remarks %>"
         class="<%= 'disable' unless @assignment.allow_remarks %>">
      <div>
        <%= raw(f.label('remark_due_date',
                        t('assignment.remark.due_date'),
                        class: 'inline_label')) %>
        <%= raw(f.text_field :remark_due_date,
                             id: 'actual_remark_due_date',
                             class: 'hidden') %>
        <%= text_field_tag 'assignment_remark_due_date',
                           nil,
                           { onchange: 'set_onbeforeunload(true);',
                             size: 35 } %>
      </div>

      <div>
        <%= raw(f.label('remark_message',
                        t('assignment.remark.message'),
                        class: 'textbox_label')) %>
        <%= raw(f.text_area :remark_message,
                            rows: 8,
                            cols: 65,
                            onchange: 'set_onbeforeunload(true);') %>
      </div>
    </div>
  </fieldset>

  <%= f.submit t(:submit),
               data: { disable_with: t('working') },
               onclick: 'set_onbeforeunload(false);' %>
<% end %>

{'fraction_non_alphanumeric': 0.12881029890500148, 'fraction_numerical': 0.0017756732761171944, 'mean_word_length': 1.6279325988334414, 'pattern_counts': {'":': 0, '<': 619, '<?xml version=': 0, '>': 621, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 84, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6421340', 'n_tokens_mistral': 12435, 'n_tokens_neox': 11480, 'n_words': 1804}