Method: Stellar::Gradebook::Student#update_grades

Defined in:
lib/stellar/gradebook.rb

#update_grades(new_grades) ⇒ Stellar::Gradebook::Student

Changes some of the student’s grades.

Parameters:

  • new_grades (Hash)

    maps assignment names to the desired scores

Returns:



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/stellar/gradebook.rb', line 322

def update_grades(new_grades)
  reload! unless @input_names
  
  page = @client.get @url
  grade_form = page.form_with :action => /detail/i
  new_grades.each do |assignment_name, new_grade|
    unless input_name = @input_names[assignment_name]
      raise ArgumentError, "Invalid assignment #{assignment_name}"
    end
    grade_form.field_with(:name => input_name).value = new_grade.to_s
  end
  grade_form.submit grade_form.button_with(:class => /save/)
  
  reload!
end