Class: MoodleRb::Grades
- Inherits:
-
Object
- Object
- MoodleRb::Grades
- Includes:
- HTTParty, Utility
- Defined in:
- lib/moodle_rb/grades.rb
Instance Attribute Summary collapse
-
#query_options ⇒ Object
readonly
Returns the value of attribute query_options.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #by_assignment(assignment_id) ⇒ Object
- #by_course(course_id, *user_ids) ⇒ Object
-
#initialize(token, url, query_options) ⇒ Grades
constructor
A new instance of Grades.
Methods included from Utility
#api_array, #check_for_errors, #key_value_query_format, #query_hash
Constructor Details
#initialize(token, url, query_options) ⇒ Grades
Returns a new instance of Grades.
8 9 10 11 12 |
# File 'lib/moodle_rb/grades.rb', line 8 def initialize(token, url, ) @token = token @query_options = self.class.base_uri url end |
Instance Attribute Details
#query_options ⇒ Object (readonly)
Returns the value of attribute query_options.
6 7 8 |
# File 'lib/moodle_rb/grades.rb', line 6 def @query_options end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/moodle_rb/grades.rb', line 6 def token @token end |
Instance Method Details
#by_assignment(assignment_id) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/moodle_rb/grades.rb', line 14 def by_assignment(assignment_id) response = self.class.post( '/webservice/rest/server.php', { :query => query_hash('mod_assign_get_grades', token), :body => { :assignmentids => api_array(assignment_id) } }.merge() ) check_for_errors(response) response.parsed_response['assignments'] end |
#by_course(course_id, *user_ids) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/moodle_rb/grades.rb', line 28 def by_course(course_id, *user_ids) response = self.class.post( '/webservice/rest/server.php', { :query => query_hash('core_grades_get_grades', token), :body => { :courseid => course_id, :userids => api_array(user_ids) } }.merge() ) check_for_errors(response) response.parsed_response['items'] end |