Class: Stellar::Gradebook::Assignment
- Inherits:
-
Object
- Object
- Stellar::Gradebook::Assignment
- Defined in:
- lib/stellar/gradebook.rb
Overview
One assignment in the Gradebook tab.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Generic Stellar client used to make requests.
-
#deleted ⇒ Object
(also: #deleted?)
readonly
True if the homework was deleted.
-
#gradebook ⇒ Object
readonly
The gradebook that this assignment is in.
-
#name ⇒ Object
readonly
Assignment name.
-
#url ⇒ Object
readonly
URL of the assignment’s main page.
Instance Method Summary collapse
-
#delete! ⇒ Object
Deletes this assignment from the Gradebook.
-
#initialize(tr, gradebook) ⇒ Assignment
constructor
Creates a submission from a <tr> element in the Gradebook assignments page.
Constructor Details
#initialize(tr, gradebook) ⇒ Assignment
Creates a submission from a <tr> element in the Gradebook assignments page.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/stellar/gradebook.rb', line 144 def initialize(tr, gradebook) @gradebook = gradebook @client = gradebook.client link = tr.css('a[href*=".html"]').find { |link| link.css('img').empty? } raise ArgumentError, 'Invalid assignment-listing <tr>' unless link @name = link.inner_text @url = URI.join tr.document.url, link['href'] page = client.get_nokogiri @url summary_table = page.css('.gradeTable').find do |table| /summary/i =~ table.css('caption').inner_text end raise ArgumentError, 'Invalid assignment-listing <tr>' unless summary_table edit_link = summary_table.css('tbody tr a[href*="edit"]').first raise ArgumentError, 'Invalid assignment-listing <tr>' unless edit_link @edit_url = URI.join @url.to_s, edit_link['href'] @deleted = false end |
Instance Attribute Details
#client ⇒ Object (readonly)
Generic Stellar client used to make requests.
136 137 138 |
# File 'lib/stellar/gradebook.rb', line 136 def client @client end |
#deleted ⇒ Object (readonly) Also known as: deleted?
True if the homework was deleted.
128 129 130 |
# File 'lib/stellar/gradebook.rb', line 128 def deleted @deleted end |
#gradebook ⇒ Object (readonly)
The gradebook that this assignment is in.
133 134 135 |
# File 'lib/stellar/gradebook.rb', line 133 def gradebook @gradebook end |
#name ⇒ Object (readonly)
Assignment name.
122 123 124 |
# File 'lib/stellar/gradebook.rb', line 122 def name @name end |
#url ⇒ Object (readonly)
URL of the assignment’s main page.
125 126 127 |
# File 'lib/stellar/gradebook.rb', line 125 def url @url end |
Instance Method Details
#delete! ⇒ Object
Deletes this assignment from the Gradebook.
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/stellar/gradebook.rb', line 167 def delete! return if @deleted edit_page = @client.get @edit_url edit_form = edit_page.form_with :action => /edit/i confirm_page = edit_form.submit edit_form.(:name => /del/i) @deleted = true self end |