class Stellar::Gradebook::AssignmentList
Collection of assignments in a course's Gradebook
module.
Attributes
Generic Stellar
client used to make requests.
The course's
Public Class Methods
Creates a list of Gradebook
assignments for a class.
@param [Stellar::Gradebook] gradebook client scoped to a course's Gradebook
# File lib/stellar/gradebook.rb, line 55 def initialize(gradebook) @gradebook = gradebook @client = gradebook.client @url = gradebook.navigation['Assignments'] reload! end
Public Instance Methods
Creates a new assignment in the Gradebook
.
@param [String] long_name the assignment's full name @param [String] short_name a shorter name? @param [Numeric] max_score maximum score that a student can receive @param [Time] due_on date when the pset is due @param [Numeric] weight score weight in total score for the course @return [Stellar::Gradebook::AssignmentList] self, for easy call chaining
# File lib/stellar/gradebook.rb, line 103 def add(long_name, short_name, max_points, due_on = Time.now, weight = nil) add_page = @client.get @gradebook.navigation['Add Assignment'] add_form = add_page.form_with :action => /new/i add_form.field_with(:name => /title/i).value = long_name add_form.field_with(:name => /short/i).value = short_name add_form.field_with(:name => /points/i).value = max_points.to_s add_form.field_with(:name => /short/i).value = due_on.strftime('%m.%d.%Y') if weight add_form.field_with(:name => /weight/i).value = weight.to_s end add_form.submit add_form.button_with(:class => /active/) reload! end
All assignments in this course's Gradebook
module. @return [Array<Stellar::Gradebook::Assignment>] list of assignments posted
by this course
# File lib/stellar/gradebook.rb, line 66 def all @assignments end
An assignment in the course's homework module. @param [String] name the name of the desired assignment @return [Stellar::Homework] an assignment with the given name, or nil if no
such assignment exists
# File lib/stellar/gradebook.rb, line 74 def named(name) @assignments.find { |a| a.name == name } end
Reloads the contents of this assignment list.
@return [Stellar::Gradebook::AssignmentList] self, for easy call chaining
# File lib/stellar/gradebook.rb, line 81 def reload! assignment_page = @client.get_nokogiri @url @assignments = assignment_page.css('.gradeTable tbody tr').map { |tr| begin Stellar::Gradebook::Assignment.new tr, self rescue ArgumentError nil end }.reject(&:nil?) self end