<h1>Editing assignment</h1>

<!-- CHECK IF THE ASSIGNMENT HAS BEEN GRADED, AND IF IT HAS, DISALLOW
     CHANGE OF ITS DESIGNATION OF GROUP/INDIVIDUAL-->
<% @a=Igrade.exists?( :assignment_id => @assignment.id )%>
<% @b=Ggrade.exists?( :assignment_id => @assignment.id )%>

<% form_for(@assignment) do |f| %>
  <%= f.error_messages %>

  <p>
  <!-- ORDERING CANNOT CHANGE ONCE CREATED, IF ASSIGNMENT NOT GRADED 
       YET IT CAN BE DELETED, AND RE-CREATED WITH DIFFERENT ORDERING-->	
    <%= f.label :ordering %><br />
    <%= f.text_field :ordering, :disabled => "disabled" %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_field :description %>
  </p>
  <p>
    <%= f.label :due_date %><br />
    <%= f.date_select :due_date %>
  </p>
  <p>
    <%= f.label :groupf, "Check if group (cannot change if graded)" %><br />

  <% if !@a && !@b %>
       <%= f.check_box :groupf %>
  <% else %>
       <%= f.check_box :groupf, :disabled => "disabled" %>
  <% end %>

  </p>
  <p>
    <%= f.submit 'Update' %>
  </p>
<% end %>

<%= link_to 'Show', @assignment %> |
<%= link_to 'Back', assignments_path %>