Class: XQueueSubmission
- Inherits:
-
Object
- Object
- XQueueSubmission
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/xqueue_ruby/xqueue_submission.rb
Defined Under Namespace
Classes: InvalidSubmissionError
Constant Summary collapse
- DEFAULTS =
{correct: false, score: 0, message: '', errors: ''}
Instance Attribute Summary collapse
-
#correct ⇒ Object
String: textual feedback from autograder.
-
#files ⇒ Object
XQueue-server-supplied nonce that will be needed to post back a grade for this submission.
-
#message ⇒ Object
Numeric: score reported by autograder.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#score ⇒ Object
one-way hash of edX student ID.
-
#secret ⇒ Object
readonly
The
XQueue
from which this assignment was retrieved (and to which the grade should be posted back). -
#student_id ⇒ Object
readonly
When student submitted assignment via edX (a Time object).
-
#submission_time ⇒ Object
readonly
Returns the value of attribute submission_time.
Class Method Summary collapse
Instance Method Summary collapse
- #expand_files ⇒ Object
-
#initialize(hash) ⇒ XQueueSubmission
constructor
A new instance of XQueueSubmission.
- #post_back ⇒ Object
Constructor Details
#initialize(hash) ⇒ XQueueSubmission
Returns a new instance of XQueueSubmission.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 31 def initialize(hash) begin fields_hash = DEFAULTS.merge(hash) fields_hash.each {|key, value| instance_variable_set("@#{key}", value)} rescue NoMethodError => e if e. == "undefined method `[]' for nil:NilClass" raise InvalidSubmissionError, "Missing element(s) in JSON: #{hash}" end raise StandardError 'yoloswag' end end |
Instance Attribute Details
#correct ⇒ Object
String: textual feedback from autograder
23 24 25 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 23 def correct @correct end |
#files ⇒ Object
XQueue-server-supplied nonce that will be needed to post back a grade for this submission
14 15 16 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 14 def files @files end |
#message ⇒ Object
Numeric: score reported by autograder
21 22 23 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 21 def @message end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
10 11 12 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 10 def queue @queue end |
#score ⇒ Object
one-way hash of edX student ID
19 20 21 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 19 def score @score end |
#secret ⇒ Object (readonly)
The XQueue
from which this assignment was retrieved (and to which the grade should be posted back)
12 13 14 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 12 def secret @secret end |
#student_id ⇒ Object (readonly)
When student submitted assignment via edX (a Time object)
17 18 19 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 17 def student_id @student_id end |
#submission_time ⇒ Object (readonly)
Returns the value of attribute submission_time.
15 16 17 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 15 def submission_time @submission_time end |
Class Method Details
.parse_JSON(xqueue, json_response) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 47 def self.parse_JSON(xqueue, json_response) parsed = JSON.parse(json_response) header, files, body = parsed['xqueue_header'], parsed['xqueue_files'], parsed['xqueue_body'] grader_payload = body['grader_payload'] anonymous_student_id, submission_time = body['student_info']['anonymous_student_id'], Time.parse(body['student_info']['submission_time']) XQueueSubmission.new({queue: xqueue, secret: header, files: files, student_id: anonymous_student_id, submission_time: submission_time }) end |
Instance Method Details
#expand_files ⇒ Object
55 56 57 58 59 60 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 55 def # @files = @files.map each do # do something # end # self end |
#post_back ⇒ Object
43 44 45 |
# File 'lib/xqueue_ruby/xqueue_submission.rb', line 43 def post_back() @queue.put_result(@secret, @score, @correct, @message) end |