Class: Stellar::Gradebook::AssignmentList
- Inherits:
-
Object
- Object
- Stellar::Gradebook::AssignmentList
- Defined in:
- lib/stellar/gradebook.rb
Overview
Collection of assignments in a course’s Gradebook module.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Generic Stellar client used to make requests.
-
#gradebook ⇒ Object
readonly
The course’s.
Instance Method Summary collapse
-
#add(long_name, short_name, max_points, due_on = Time.now, weight = nil) ⇒ Stellar::Gradebook::AssignmentList
Creates a new assignment in the Gradebook.
-
#all ⇒ Array<Stellar::Gradebook::Assignment>
All assignments in this course’s Gradebook module.
-
#initialize(gradebook) ⇒ AssignmentList
constructor
Creates a list of Gradebook assignments for a class.
-
#named(name) ⇒ Stellar::Homework
An assignment in the course’s homework module.
-
#reload! ⇒ Stellar::Gradebook::AssignmentList
Reloads the contents of this assignment list.
Constructor Details
#initialize(gradebook) ⇒ AssignmentList
Creates a list of Gradebook assignments for a class.
55 56 57 58 59 60 61 |
# File 'lib/stellar/gradebook.rb', line 55 def initialize(gradebook) @gradebook = gradebook @client = gradebook.client @url = gradebook.['Assignments'] reload! end |
Instance Attribute Details
#client ⇒ Object (readonly)
Generic Stellar client used to make requests.
50 51 52 |
# File 'lib/stellar/gradebook.rb', line 50 def client @client end |
#gradebook ⇒ Object (readonly)
The course’s
47 48 49 |
# File 'lib/stellar/gradebook.rb', line 47 def gradebook @gradebook end |
Instance Method Details
#add(long_name, short_name, max_points, due_on = Time.now, weight = nil) ⇒ Stellar::Gradebook::AssignmentList
Creates a new assignment in the Gradebook.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# 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.['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.(:class => /active/) reload! end |
#all ⇒ Array<Stellar::Gradebook::Assignment>
All assignments in this course’s Gradebook module.
66 67 68 |
# File 'lib/stellar/gradebook.rb', line 66 def all @assignments end |
#named(name) ⇒ Stellar::Homework
An assignment in the course’s homework module.
74 75 76 |
# File 'lib/stellar/gradebook.rb', line 74 def named(name) @assignments.find { |a| a.name == name } end |
#reload! ⇒ Stellar::Gradebook::AssignmentList
Reloads the contents of this assignment list.
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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 |