Module: Agilix::Buzz::Commands::Enrollment

Included in:
Api
Defined in:
lib/agilix/buzz/commands/enrollment.rb

Instance Method Summary collapse

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 )
  options = 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: options
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 = {})
  options = 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: options
end

#enrollment_statusObject



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

Raises:

  • (ArgumentError)


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(options = {})
  options = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( select ), options: options )
  authenticated_get cmd: "getenrollment3", **options
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(options = {})
  options = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( last mergeoverlap ), options: options )
  authenticated_get cmd: "getenrollmentactivity", **options
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(options = {})
  options = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( forcerequireditems gradingschemeid gradingscheme itemid scorm zerounscored ), options: options )
  authenticated_get cmd: "getenrollmentgradebook2", **options
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(options = {})
  options = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( setid ), options: options )
  authenticated_get cmd: "getenrollmentgrouplist", **options
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”

Raises:

  • (ArgumentError)


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(options = {})
  raise ArgumentError.new("report can only be Student or Enrollment") unless ['Student', 'Enrollment'].include?(options[: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 options[:report] == "Student"
    options[:select] ||= (default_select + student_select).flatten.join(",")
  elsif options[:report] == "Enrollment"
    options[:select] ||= (default_select + enrollment_select).flatten.join(",")
  end
  options = argument_cleaner(required_params: %i( entityid report select  ), optional_params: %i( filename format ), options: options )
  authenticated_get cmd: "getenrollmentmetricsreport", **options
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(options = {})
  options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select query userdomainid userquery usertext coursedomainid coursequery coursetext ), options: options )
  authenticated_get cmd: "listenrollments", **options
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(options = {})
  options = argument_cleaner(required_params: %i(  ), optional_params: %i( teacheruserid teacherallstatus teacherdaysactivepastend privileges allstatus daysactivepastend userid select ), options: options )
  authenticated_get cmd: "listenrollmentsbyteacher", **options
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(options = {})
  options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( privileges allstatus daysactivepastend userid select ), options: options )
  authenticated_get cmd: "listentityenrollments", **options
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(options = {})
  options = argument_cleaner(required_params: %i( userid ), optional_params: %i( allstatus entityid privileges daysactivepastend query select ), options: options )
  authenticated_get cmd: "listuserenrollments", **options
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(options = {})
  options = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( understanding interest effort ), options: options )
  authenticated_get cmd: "putselfassessment", **options
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(options = {})
  options = argument_cleaner(required_params: %i( enrollmentid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "restoreenrollment", **options
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)
  options = 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: options
end