Module: Agilix::Buzz::Commands::Enrollment
- Included in:
- Api
- Defined in:
- lib/agilix/buzz/commands/enrollment.rb
Instance Method Summary collapse
-
#create_enrollments(items = [], disallowduplicates: false, disallowsamestatusduplicates: false) ⇒ Object
ISSUE: API format is very inconsistent on this one, requires both query string modification & body modification api.create_enrollments [57026, entityid: 57025].
-
#delete_enrollments(items = {}) ⇒ Object
ISSUE: Inconsistent from other delete apis.
- #enrollment_status ⇒ Object
- #enrollment_status_lookup_value(int) ⇒ Object
-
#get_enrollment3(options = {}) ⇒ Object
(also: #get_enrollment)
api.get_enrollment enrollmentid: 60997.
-
#get_enrollment_activity(options = {}) ⇒ Object
api.get_enrollment_activity enrollmentid: 60997.
-
#get_enrollment_gradebook2(options = {}) ⇒ Object
(also: #get_enrollment_gradebook)
api.get_enrollment_gradebook enrollmentid: 60997.
-
#get_enrollment_group_list(options = {}) ⇒ Object
api.get_enrollment_group_list enrollmentid: 60997.
-
#get_enrollment_metrics_report(options = {}) ⇒ Object
api.get_enrollment_metrics_report entityid: 50725, report: “Student” api.get_enrollment_metrics_report entityid: 50725, report: “Enrollment”.
-
#list_enrollments(options = {}) ⇒ Object
api.list_enrollments domainid: 50725.
-
#list_enrollments_by_teacher(options = {}) ⇒ Object
api.list_enrollments_by_teacher teacheruserid: 50726 api.list_enrollments_by_teacher.
-
#list_entity_enrollments(options = {}) ⇒ Object
api.list_entity_enrollments entityid: 60982.
-
#list_user_enrollments(options = {}) ⇒ Object
api.list_user_enrollments userid: 57181.
-
#put_self_assessment(options = {}) ⇒ Object
ISSUE: this should be a post, not a get api.put_self_assessment enrollmentid: 60997, understanding: 200, effort: 220, interest: 100.
-
#restore_enrollment(options = {}) ⇒ Object
api.restore_enrollment enrollmentid: 60997.
-
#update_enrollments(items) ⇒ Object
api.update_enrollments [60997, status: 7].
Instance Method Details
#create_enrollments(items = [], disallowduplicates: false, disallowsamestatusduplicates: false) ⇒ Object
ISSUE: API format is very inconsistent on this one, requires both query string modification & body modification api.create_enrollments [57026, entityid: 57025]
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 27 def create_enrollments(items = [], disallowduplicates: false, disallowsamestatusduplicates: false ) = items.map do |item| item[:status] ||= 1 argument_cleaner(required_params: %i( userid entityid status ), optional_params: %i( roleid flags domainid startdate enddate reference schema data ), options: item ) end if [disallowduplicates, disallowsamestatusduplicates].compact.any? query_params = {} query_params[:disallowduplicates] = disallowduplicates query_params[:disallowsamestatusduplicates] = disallowsamestatusduplicates end authenticated_bulk_post cmd: "createenrollments", root_node: 'enrollment', query_params: query_params, body: end |
#delete_enrollments(items = {}) ⇒ Object
ISSUE: Inconsistent from other delete apis. many are singular, not plural api.delete_enrollments [ { enrollmentid: 60997 }]
42 43 44 45 46 47 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 42 def delete_enrollments(items = {}) = items.map do |item| argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( ), options: item ) end authenticated_bulk_post cmd: "deleteenrollments", root_node: 'enrollment', body: end |
#enrollment_status ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 6 def enrollment_status { active: 1, withdrawn: 4, withdrawn_failed: 5, transferred: 6, completed: 7, completed_no_credit: 8, suspended: 9, inactive: 10 } end |
#enrollment_status_lookup_value(int) ⇒ Object
19 20 21 22 23 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 19 def enrollment_status_lookup_value(int) int = int.to_i raise ArgumentError.new("Not a valid enrollment status code") unless enrollment_status.values.include?(int) enrollment_status.find {|k,v| v == int}.first end |
#get_enrollment3(options = {}) ⇒ Object Also known as: get_enrollment
api.get_enrollment enrollmentid: 60997
50 51 52 53 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 50 def get_enrollment3( = {}) = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( select ), options: ) authenticated_get cmd: "getenrollment3", ** end |
#get_enrollment_activity(options = {}) ⇒ Object
api.get_enrollment_activity enrollmentid: 60997
57 58 59 60 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 57 def get_enrollment_activity( = {}) = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( last mergeoverlap ), options: ) authenticated_get cmd: "getenrollmentactivity", ** end |
#get_enrollment_gradebook2(options = {}) ⇒ Object Also known as: get_enrollment_gradebook
api.get_enrollment_gradebook enrollmentid: 60997
63 64 65 66 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 63 def get_enrollment_gradebook2( = {}) = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( forcerequireditems gradingschemeid gradingscheme itemid scorm zerounscored ), options: ) authenticated_get cmd: "getenrollmentgradebook2", ** end |
#get_enrollment_group_list(options = {}) ⇒ Object
api.get_enrollment_group_list enrollmentid: 60997
70 71 72 73 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 70 def get_enrollment_group_list( = {}) = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( setid ), options: ) authenticated_get cmd: "getenrollmentgrouplist", ** end |
#get_enrollment_metrics_report(options = {}) ⇒ Object
api.get_enrollment_metrics_report entityid: 50725, report: “Student” api.get_enrollment_metrics_report entityid: 50725, report: “Enrollment”
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 77 def get_enrollment_metrics_report( = {}) raise ArgumentError.new("report can only be Student or Enrollment") unless ['Student', 'Enrollment'].include?([:report]) default_select = %w( user.id user.firstname user.lastname user.username user.reference) student_select = %w( coursecount latecount failedcount paceyellows pacereds performanceyellows performancereds) enrollment_select = %w(enrollment.id course.title course.id course.reference score achieved possible failing seconds completable completed gradable completedgradable graded percentcomplete late failed recentlyfailed pacelight pacereason performancelight performancereason lastduedatemissed calculateddate ) if [:report] == "Student" [:select] ||= (default_select + student_select).flatten.join(",") elsif [:report] == "Enrollment" [:select] ||= (default_select + enrollment_select).flatten.join(",") end = argument_cleaner(required_params: %i( entityid report select ), optional_params: %i( filename format ), options: ) authenticated_get cmd: "getenrollmentmetricsreport", ** end |
#list_enrollments(options = {}) ⇒ Object
api.list_enrollments domainid: 50725
92 93 94 95 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 92 def list_enrollments( = {}) = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select query userdomainid userquery usertext coursedomainid coursequery coursetext ), options: ) authenticated_get cmd: "listenrollments", ** end |
#list_enrollments_by_teacher(options = {}) ⇒ Object
api.list_enrollments_by_teacher teacheruserid: 50726 api.list_enrollments_by_teacher
99 100 101 102 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 99 def list_enrollments_by_teacher( = {}) = argument_cleaner(required_params: %i( ), optional_params: %i( teacheruserid teacherallstatus teacherdaysactivepastend privileges allstatus daysactivepastend userid select ), options: ) authenticated_get cmd: "listenrollmentsbyteacher", ** end |
#list_entity_enrollments(options = {}) ⇒ Object
api.list_entity_enrollments entityid: 60982
105 106 107 108 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 105 def list_entity_enrollments( = {}) = argument_cleaner(required_params: %i( entityid ), optional_params: %i( privileges allstatus daysactivepastend userid select ), options: ) authenticated_get cmd: "listentityenrollments", ** end |
#list_user_enrollments(options = {}) ⇒ Object
api.list_user_enrollments userid: 57181
111 112 113 114 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 111 def list_user_enrollments( = {}) = argument_cleaner(required_params: %i( userid ), optional_params: %i( allstatus entityid privileges daysactivepastend query select ), options: ) authenticated_get cmd: "listuserenrollments", ** end |
#put_self_assessment(options = {}) ⇒ Object
ISSUE: this should be a post, not a get api.put_self_assessment enrollmentid: 60997, understanding: 200, effort: 220, interest: 100
118 119 120 121 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 118 def put_self_assessment( = {}) = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( understanding interest effort ), options: ) authenticated_get cmd: "putselfassessment", ** end |
#restore_enrollment(options = {}) ⇒ Object
api.restore_enrollment enrollmentid: 60997
124 125 126 127 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 124 def restore_enrollment( = {}) = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( ), options: ) authenticated_get cmd: "restoreenrollment", ** end |
#update_enrollments(items) ⇒ Object
api.update_enrollments [60997, status: 7]
130 131 132 133 134 135 |
# File 'lib/agilix/buzz/commands/enrollment.rb', line 130 def update_enrollments(items) = items.map do |item| argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( userid entityid domainid roleid flags status startdate enddate reference schema data ), options: item) end authenticated_bulk_post cmd: "updateenrollments", root_node: 'enrollment', body: end |