class Stellar::Gradebook::Assignment
One assignment in the Gradebook
tab.
Attributes
client[R]
Generic Stellar
client used to make requests.
deleted[R]
True if the homework was deleted.
deleted?[R]
True if the homework was deleted.
gradebook[R]
The gradebook that this assignment is in.
name[R]
Assignment
name.
url[R]
URL of the assignment's main page.
Public Class Methods
new(tr, gradebook)
click to toggle source
Creates a submission from a <tr> element in the Gradebook
assignments page.
@param [Nokogiri::XML::Element] tr a <tr> element in the Gradebook
assignments page describing this assignment
@param [Stellar::Gradebook] gradebook Stellar
client scoped to the
course gradebook containing this assignment
# 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
Public Instance Methods
delete!()
click to toggle source
Deletes this assignment from the Gradebook
.
# 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.button_with(:name => /del/i) @deleted = true self end