d2l_sdk 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/d2l_sdk.rb +16 -14
- data/lib/d2l_sdk/auth.rb +1 -1
- data/lib/d2l_sdk/config_variables.rb +81 -5
- data/lib/d2l_sdk/course.rb +184 -136
- data/lib/d2l_sdk/course_content.rb +148 -23
- data/lib/d2l_sdk/course_template.rb +78 -69
- data/lib/d2l_sdk/demographics.rb +62 -22
- data/lib/d2l_sdk/enroll.rb +159 -84
- data/lib/d2l_sdk/grades.rb +352 -0
- data/lib/d2l_sdk/group.rb +1 -0
- data/lib/d2l_sdk/news.rb +97 -0
- data/lib/d2l_sdk/org_unit.rb +205 -167
- data/lib/d2l_sdk/requests.rb +3 -14
- data/lib/d2l_sdk/section.rb +77 -52
- data/lib/d2l_sdk/semester.rb +3 -0
- data/lib/d2l_sdk/setup_versions.rb +14 -0
- data/lib/d2l_sdk/user.rb +334 -68
- data/lib/d2l_sdk/version.rb +1 -1
- metadata +4 -2
data/lib/d2l_sdk/enroll.rb
CHANGED
@@ -1,9 +1,109 @@
|
|
1
1
|
require_relative 'requests'
|
2
2
|
require 'json-schema'
|
3
|
+
|
3
4
|
########################
|
4
5
|
# Enrollments:##########
|
5
6
|
########################
|
6
7
|
|
8
|
+
# Delete a user’s enrollment in a provided org unit.
|
9
|
+
def delete_user_enrollment(user_id, org_unit_id)
|
10
|
+
path = "/d2l/api/lp/#{$lp_ver}/users/#{user_id}/orgUnits/#{org_unit_id}"
|
11
|
+
_delete(path)
|
12
|
+
# Returns: EnrollmentData JSON block showing the enrollment status
|
13
|
+
# just before this action deleted the enrollment of the user
|
14
|
+
end
|
15
|
+
|
16
|
+
# Delete a user’s enrollment in a provided org unit.
|
17
|
+
def delete_user_enrollment_alternative(user_id, org_unit_id)
|
18
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/orgUnits/#{org_unit_id}/users/#{user_id}"
|
19
|
+
_delete(path)
|
20
|
+
# Returns: EnrollmentData JSON block showing the enrollment status
|
21
|
+
# just before this action deleted the enrollment of the user
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieve the enrolled users in the classlist for an org unit
|
25
|
+
def get_enrolled_users_in_classlist(org_unit_id)
|
26
|
+
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/classlist/"
|
27
|
+
_get(path)
|
28
|
+
# Returns: JSON array of ClasslistUser data blocks.
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieve the list of all enrollments for the current user
|
32
|
+
# Optional params:
|
33
|
+
# --orgUnitTypeId: CSV of D2LIDs
|
34
|
+
# --bookmark: String
|
35
|
+
# --sortBy: string
|
36
|
+
# --isActive: bool
|
37
|
+
# --startDateTime: UTCDateTime
|
38
|
+
# --endDateTime: UTCDateTime
|
39
|
+
# --canAccess: bool
|
40
|
+
def get_all_enrollments_of_current_user(bookmark = '', sort_by = '', is_active = nil,
|
41
|
+
start_date_time = '', end_date_time = '',
|
42
|
+
can_access = nil)
|
43
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/myenrollments/"
|
44
|
+
path += "?bookmark=#{bookmark}" if bookmark != ''
|
45
|
+
path += "?sortBy=#{sort_by}" if sort_by != ''
|
46
|
+
path += "?isActive=#{is_active}" if is_active != nil
|
47
|
+
path += "?startDateTime=#{start_date_time}" if start_date_time != ''
|
48
|
+
path += "?endDateTime=#{end_date_time}" if end_date_time != ''
|
49
|
+
path += "?canAccess=#{can_access}" if can_access != nil
|
50
|
+
_get(path)
|
51
|
+
# Returns: paged result set containing the resulting MyOrgUnitInfo data blocks
|
52
|
+
end
|
53
|
+
|
54
|
+
# Retrieve the enrollment details for the current user in the provided org unit.
|
55
|
+
def get_enrollments_details_of_current_user(org_unit_id)
|
56
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/myenrollments/#{org_unit_id}/"
|
57
|
+
_get(path)
|
58
|
+
# Returns: MyOrgUnitInfo JSON block.
|
59
|
+
end
|
60
|
+
|
61
|
+
# Retrieve the collection of users enrolled in the identified org unit.
|
62
|
+
# Optional params:
|
63
|
+
# --roleId: D2LID
|
64
|
+
# --bookmark: String
|
65
|
+
def get_org_unit_enrollments(org_unit_id, role_id = 0, bookmark = '')
|
66
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/orgUnits/#{org_unit_id}/users/"
|
67
|
+
path += "?roleId=#{role_id}" if role_id != 0
|
68
|
+
path += "?bookmark=#{bookmark}" if bookmark != ''
|
69
|
+
_get(path)
|
70
|
+
# Returns: paged result set containing the resulting OrgUnitUser data blocks
|
71
|
+
end
|
72
|
+
|
73
|
+
# Retrieve enrollment details for a user in the provided org unit.
|
74
|
+
# Note:
|
75
|
+
# Same as +get_user_enrollment_data_by_org_unit+
|
76
|
+
# This call is equivalent to the route that fetches by specifying the user first,
|
77
|
+
# and then the org unit.
|
78
|
+
def get_org_unit_enrollment_data_by_user(org_unit_id, user_id)
|
79
|
+
path = "/d2l/api/lp/#{$lp_ver}/orgUnits/#{org_unit_id}/users/#{user_id}"
|
80
|
+
_get(path)
|
81
|
+
# Returns: EnrollmentData JSON block.
|
82
|
+
end
|
83
|
+
|
84
|
+
# Retrieve a list of all enrollments for the provided user.
|
85
|
+
# Optional params:
|
86
|
+
# --orgUnitTypeId (CSV of D2LIDs)
|
87
|
+
# --roleId: D2LIDs
|
88
|
+
# --bookmark: string
|
89
|
+
def get_all_enrollments_of_user(user_id, org_unit_type_id = 0, role_id = 0,
|
90
|
+
bookmark = '')
|
91
|
+
path = "/d2l/api/lp/1.3/enrollments/users/#{user_id}/orgUnits/"
|
92
|
+
path += "?orgUnitTypeId=#{org_unit_type_id}" if org_unit_type_id != 0
|
93
|
+
path += "?roleId=#{role_id}" if role_id != 0
|
94
|
+
path += "?bookmark=#{bookmark}" if bookmark != ''
|
95
|
+
_get(path)
|
96
|
+
# Returns: paged result set w/ the resulting UserOrgUnit data blocks
|
97
|
+
end
|
98
|
+
|
99
|
+
# Retrieve enrollment details in an org unit for the provided user.
|
100
|
+
# Same as +get_org_unit_enrollment_data_by_user+
|
101
|
+
def get_user_enrollment_data_by_org_unit(user_id, org_unit_id)
|
102
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/users/#{user_id}/orgUnits/#{org_unit_id}"
|
103
|
+
_get(path)
|
104
|
+
# Returns: EnrollmentData JSON block.
|
105
|
+
end
|
106
|
+
|
7
107
|
# Check the validity of the CreateEnrollmentData that is passed as a payload
|
8
108
|
def check_create_enrollment_data_validity(enrollment_data)
|
9
109
|
schema = {
|
@@ -32,102 +132,77 @@ def create_user_enrollment(course_enrollment_data)
|
|
32
132
|
# Returns: EnrollmentData JSON block for the newly enrolled user.
|
33
133
|
end
|
34
134
|
|
35
|
-
# Retrieve enrollment details in an org unit for the provided user.
|
36
|
-
# Same as +get_org_unit_enrollment_data_by_user+
|
37
|
-
def get_user_enrollment_data_by_org_unit(user_id, org_unit_id)
|
38
|
-
path = "/d2l/api/lp/#{$lp_ver}/enrollments/users/#{user_id}/orgUnits/#{org_unit_id}"
|
39
|
-
_get(path)
|
40
|
-
# Returns: EnrollmentData JSON block.
|
41
|
-
end
|
42
135
|
|
43
|
-
|
44
|
-
#
|
45
|
-
|
46
|
-
# --roleId: D2LIDs
|
47
|
-
# --bookmark: string
|
48
|
-
def get_all_enrollments_of_user(user_id, org_unit_type_id = 0, role_id = 0,
|
49
|
-
bookmark = '')
|
50
|
-
path = "/d2l/api/lp/1.3/enrollments/users/#{user_id}/orgUnits/"
|
51
|
-
path += "?orgUnitTypeId=#{org_unit_type_id}" if org_unit_type_id != 0
|
52
|
-
path += "?roleId=#{role_id}" if role_id != 0
|
53
|
-
path += "?bookmark=#{bookmark}" if bookmark != ''
|
54
|
-
_get(path)
|
55
|
-
# Returns: paged result set w/ the resulting UserOrgUnit data blocks
|
56
|
-
end
|
136
|
+
########################
|
137
|
+
# PINNING:##############
|
138
|
+
########################
|
57
139
|
|
58
|
-
#
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
def get_org_unit_enrollment_data_by_user(org_unit_id, user_id)
|
64
|
-
path = "/d2l/api/lp/#{$lp_ver}/orgUnits/#{org_unit_id}/users/#{user_id}"
|
65
|
-
_get(path)
|
66
|
-
# Returns: EnrollmentData JSON block.
|
140
|
+
# REVIEW: Remove the pin from the provided org unit.
|
141
|
+
def delete_current_user_org_unit_pin(org_unit_id)
|
142
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/myenrollments/#{org_unit_id}/pin"
|
143
|
+
_delete(path)
|
144
|
+
# RETURNS: nil
|
67
145
|
end
|
68
146
|
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
path = "/d2l/api/lp/#{$lp_ver}/enrollments/orgUnits/#{org_unit_id}/users/"
|
75
|
-
path += "?roleId=#{role_id}" if role_id != 0
|
76
|
-
path += "?bookmark=#{bookmark}" if bookmark != ''
|
77
|
-
_get(path)
|
78
|
-
# Returns: paged result set containing the resulting OrgUnitUser data blocks
|
147
|
+
# REVIEW: Pin an org unit to the top of the list of a user’s enrollments.
|
148
|
+
def pin_org_unit_for_current_context(org_unit_id)
|
149
|
+
path = "/d2l/api/lp/#{$lp_ver}/enrollments/myenrollments/#{org_unit_id}/pin"
|
150
|
+
_post(path, {})
|
151
|
+
# RETURNS: MyOrgUnitInfo JSON block.
|
79
152
|
end
|
80
153
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
# Returns: MyOrgUnitInfo JSON block.
|
86
|
-
end
|
154
|
+
########################
|
155
|
+
# GROUPS:###############
|
156
|
+
########################
|
157
|
+
# NOTE: Groups functions now in "group.rb"
|
87
158
|
|
88
|
-
|
89
|
-
#
|
90
|
-
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
#
|
95
|
-
|
96
|
-
#
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
path += "?isActive=#{is_active}" if is_active != nil
|
104
|
-
path += "?startDateTime=#{start_date_time}" if start_date_time != ''
|
105
|
-
path += "?endDateTime=#{end_date_time}" if end_date_time != ''
|
106
|
-
path += "?canAccess=#{can_access}" if can_access != nil
|
107
|
-
_get(path)
|
108
|
-
# Returns: paged result set containing the resulting MyOrgUnitInfo data blocks
|
159
|
+
########################
|
160
|
+
# SECTIONS:#############
|
161
|
+
########################
|
162
|
+
# NOTE: Sections functions now in "section.rb"
|
163
|
+
|
164
|
+
########################
|
165
|
+
# AUDITORS:#############
|
166
|
+
########################
|
167
|
+
# NOTE: auditor_id's and auditee_id's are just user_id's.
|
168
|
+
|
169
|
+
# REVIEW: Remove an auditee from the list of users that an auditor is auditing.
|
170
|
+
# Input: auditee_id (D2LID as single JSON number) - Auditee to be removed
|
171
|
+
def remove_auditee(auditor_id, auditee_id)
|
172
|
+
path = "/d2l/api/le/#{$le_ver}/auditing/auditors/#{auditor_id}/auditees/"
|
173
|
+
_delete(path, true, {AuditeeId: auditee_id})
|
109
174
|
end
|
110
175
|
|
111
|
-
# Retrieve
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
176
|
+
# REVIEW: Retrieve information for an auditee.
|
177
|
+
# RETURNS: a AuditedUser JSON block.
|
178
|
+
def get_auditee(auditee_id)
|
179
|
+
path = "/d2l/api/le/#{$le_ver}/auditing/auditees/#{auditee_id}"
|
180
|
+
_get(path)
|
181
|
+
# RETURNS: a AuditedUser JSON block.
|
116
182
|
end
|
117
183
|
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
184
|
+
# REVIEW: Retrieve information for an auditor.
|
185
|
+
# RETURNS: a Auditor JSON block.
|
186
|
+
def get_auditor(auditor_id)
|
187
|
+
path = "/d2l/api/le/#{$le_ver}/auditing/auditors/#{auditor_id}"
|
188
|
+
_get(path)
|
189
|
+
# RETURNS: a Auditor JSON block
|
124
190
|
end
|
125
191
|
|
192
|
+
# REVIEW: Retrieve the list of users an auditor is auditing.
|
193
|
+
# RETURNS: a JSON array of Auditee blocks.
|
194
|
+
def get_auditor_auditees(auditor_id)
|
195
|
+
path = "/d2l/api/le/#{$le_ver}/auditing/auditors/#{auditor_id}/auditees/"
|
196
|
+
_get(path)
|
197
|
+
# RETURNS: a JSON array of Auditee blocks.
|
198
|
+
end
|
126
199
|
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
200
|
+
# REVIEW: Add a user to the list of those an auditor is auditing.
|
201
|
+
# INPUT:
|
202
|
+
# JSON Param - auditee_id (D2LID as single JSON number) - Auditee to be added
|
203
|
+
# RETURNS: nil?
|
204
|
+
def add_auditor_auditee(auditor_id, auditee_id)
|
205
|
+
path = "/d2l/api/le/#{$le_ver}/auditing/auditors/#{auditor_id}/auditees/"
|
206
|
+
_post(path, auditee_id)
|
207
|
+
# RETURNS: nil?
|
133
208
|
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
require_relative 'requests'
|
2
|
+
require 'json-schema'
|
3
|
+
########################
|
4
|
+
# GRADES:###############
|
5
|
+
########################
|
6
|
+
|
7
|
+
# REVIEW: Delete a specific grade object for a particular org unit.
|
8
|
+
# Return: nil
|
9
|
+
def delete_org_unit_grade_object(org_unit_id, grade_object_id)
|
10
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}"
|
11
|
+
_delete(path)
|
12
|
+
end
|
13
|
+
|
14
|
+
# REVIEW: Retrieve all the current grade objects for a particular org unit.
|
15
|
+
# Return: This action returns a JSON array of GradeObject blocks.
|
16
|
+
def get_org_unit_grades(org_unit_id)
|
17
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/"
|
18
|
+
_get(path)
|
19
|
+
# RETURN: This action returns a JSON array of GradeObject blocks.
|
20
|
+
end
|
21
|
+
|
22
|
+
# REVIEW: Retrieve a specific grade object for a particular org unit.
|
23
|
+
# Return: This action returns a GradeObject JSON block.
|
24
|
+
def get_org_unit_grade_object(org_unit_id, grade_object_id)
|
25
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}"
|
26
|
+
_get(path)
|
27
|
+
# RETURN: This action returns a GradeObject JSON block.
|
28
|
+
end
|
29
|
+
|
30
|
+
# TODO: Create a new grade object for a particular org unit.
|
31
|
+
# Return: This action returns a GradeObject JSON block for the grade object
|
32
|
+
# that the service just created, so you can quickly retrieve the grade object ID
|
33
|
+
def create_org_unit_grade_object(org_unit_id, grade_object)
|
34
|
+
# POST /d2l/api/le/(version)/(orgUnitId)/grades/
|
35
|
+
# NOTE: must be grade object of type numeric, passfail, selectbox, or text
|
36
|
+
# NOTE: the name must be unique!
|
37
|
+
# Return: This action returns a GradeObject JSON block for the grade object
|
38
|
+
# that the service just created, so you can quickly retrieve the grade object
|
39
|
+
# ID
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: Update a specific grade object.
|
43
|
+
def update_org_unit_grade_object(org_unit_id, grade_object)
|
44
|
+
# NOTE: if new name, it must be Unique
|
45
|
+
# NOTE: must be grade object of type numeric, passfail, selectbox, or text
|
46
|
+
# PUT /d2l/api/le/(version)/(orgUnitId)/grades/(gradeObjectId)
|
47
|
+
# Return: This action returns a GradeObject JSON block for the grade object
|
48
|
+
# that the service just updated.
|
49
|
+
end
|
50
|
+
|
51
|
+
########################
|
52
|
+
# GRADE CATEGORIES:#####
|
53
|
+
########################
|
54
|
+
|
55
|
+
# REVIEW: Delete a specific grade category for a provided org unit.
|
56
|
+
def delete_org_unit_grade_category(org_unit_id, category_id)
|
57
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/categories/#{category_id}"
|
58
|
+
_delete(path)
|
59
|
+
end
|
60
|
+
|
61
|
+
# REVIEW: Retrieve a list of all grade categories for a provided org unit.
|
62
|
+
# Return: This action retrieves a JSON array of GradeObjectCategory blocks.
|
63
|
+
def get_org_unit_grade_categories(org_unit_id)
|
64
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/categories/"
|
65
|
+
_get(path)
|
66
|
+
# Return: This action retrieves a JSON array of GradeObjectCategory blocks.
|
67
|
+
end
|
68
|
+
|
69
|
+
# REVIEW: Retrieve a specific grade category for a provided org unit.
|
70
|
+
# Return: This action retrieves a GradeObjectCategory JSON block.
|
71
|
+
def get_org_unit_grade_category(org_unit_id, category_id)
|
72
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/categories/#{category_id}"
|
73
|
+
_get(path)
|
74
|
+
# Return: This action retrieves a GradeObjectCategory JSON block.
|
75
|
+
end
|
76
|
+
|
77
|
+
# TODO: Create a new grade category for a provided org unit.
|
78
|
+
# Return. This action returns the newly created grade object category in a
|
79
|
+
# GradeObjectCategory JSON block, so that you can quickly gather its grade
|
80
|
+
# category ID.
|
81
|
+
def create_org_unit_grade_category(org_unit_id, grade_category_data)
|
82
|
+
# POST /d2l/api/le/(version)/(orgUnitId)/grades/
|
83
|
+
# Return. This action returns the newly created grade object category in a
|
84
|
+
# GradeObjectCategory JSON block, so that you can quickly gather its grade
|
85
|
+
# category ID.
|
86
|
+
end
|
87
|
+
|
88
|
+
########################
|
89
|
+
# GRADE SCHEMES:########
|
90
|
+
########################
|
91
|
+
|
92
|
+
# REVIEW: Retrieve all the grade schemes for a provided org unit.
|
93
|
+
# Return: This action returns a JSON array of GradeScheme blocks.
|
94
|
+
def get_org_unit_grade_schemes(org_unit_id)
|
95
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/schemes/"
|
96
|
+
_get(path)
|
97
|
+
# Return: This action returns a JSON array of GradeScheme blocks.
|
98
|
+
end
|
99
|
+
|
100
|
+
# REVIEW: Retrieve a particular grade scheme.
|
101
|
+
# Return: This action returns a GradeScheme JSON block.
|
102
|
+
def get_org_unit_grade_scheme(org_unit_id, grade_scheme_id)
|
103
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/schemes/#{grade_scheme_id}"
|
104
|
+
_get(path)
|
105
|
+
# Return: This action returns a GradeScheme JSON block.
|
106
|
+
end
|
107
|
+
|
108
|
+
########################
|
109
|
+
# GRADE VALUES:#########
|
110
|
+
########################
|
111
|
+
|
112
|
+
# REVIEW: Retrieve the final grade value for the current user context.
|
113
|
+
# Return: This action returns a GradeValue JSON block containing the final
|
114
|
+
# calculated grade value for the current user context.
|
115
|
+
def get_current_user_final_grade(org_unit_id)
|
116
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/final/values/myGradeValue"
|
117
|
+
_get(path)
|
118
|
+
# Return: This action returns a GradeValue JSON block containing the final
|
119
|
+
# calculated grade value for the current user context.
|
120
|
+
end
|
121
|
+
|
122
|
+
# TODO: Retrieve a list of final grade values for the current user
|
123
|
+
# context across a number of org units.
|
124
|
+
# -INPUT: Input. When calling this action, you must provide a list of org unit
|
125
|
+
# IDs that amount to some or all of the calling user’s active enrollments.
|
126
|
+
# -RETURN: This action returns an ObjectListPage JSON block containing a list of
|
127
|
+
# final calculated grade values sorted by the OrgUnitIds that match the provided
|
128
|
+
# query parameter filters.
|
129
|
+
def get_current_user_final_grades(org_unit_ids_csv)
|
130
|
+
# RETURN: This action returns an ObjectListPage JSON block containing a list
|
131
|
+
# of final calculated grade values sorted by the OrgUnitIds that match the
|
132
|
+
# provided query parameter filters.
|
133
|
+
end
|
134
|
+
|
135
|
+
# REVIEW: Retrieve the final grade value for a particular user.
|
136
|
+
# INPUT: grade_type is an optional parameter. Forces grade to be returned as a certain
|
137
|
+
# grade type, such as calculated or adjusted.
|
138
|
+
# Return: This action returns a GradeValue JSON block containing the final
|
139
|
+
# calculated grade value for the provided user.
|
140
|
+
def get_user_final_grade(org_unit_id, user_id, grade_type = '')
|
141
|
+
path = "/d2l/api/le/#{le_ver}/#{org_unit_id}/grades/final/values/#{user_id}"
|
142
|
+
path += "?gradeType=#{grade_type}" if grade_type != ''
|
143
|
+
_get(path)
|
144
|
+
# Return: This action returns a GradeValue JSON block containing the final
|
145
|
+
# calculated grade value for the provided user.
|
146
|
+
end
|
147
|
+
|
148
|
+
# REVIEW: Retrieve each user’s grade value for a particular grade object.
|
149
|
+
# INPUT: sort = string, page_size = number, is_graded = boolean, search_text = string
|
150
|
+
# RETURN: This action returns an ObjectListPage JSON block containing a list
|
151
|
+
# of user grade values for your provided grade object.
|
152
|
+
def get_all_grade_object_grades(org_unit_id, grade_object_id, sort = '',
|
153
|
+
page_size = 0, is_graded = nil, search_text = '')
|
154
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/values/"
|
155
|
+
path += "?"
|
156
|
+
path += "sort=#{sort}&" if sort != ''
|
157
|
+
path += "pageSize=#{page_size}&" if page_size != 0
|
158
|
+
path += "isGraded=#{is_graded}&" if is_graded != nil
|
159
|
+
path += "searchText=#{search_text}" if search_text != ''
|
160
|
+
_get(path)
|
161
|
+
# RETURN: This action returns an ObjectListPage JSON block containing a list
|
162
|
+
# of user grade values for your provided grade object.
|
163
|
+
end
|
164
|
+
|
165
|
+
# REVIEW: Retrieve a specific grade value for the current user context assigned
|
166
|
+
# in a particular org unit.
|
167
|
+
# RETURN: This action returns a GradeValue JSON block.
|
168
|
+
def get_user_grade_object_grade(org_unit_id, grade_object_id, user_id)
|
169
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/values/#{user_id}"
|
170
|
+
_get(path)
|
171
|
+
# RETURN: This action returns a GradeValue JSON block.
|
172
|
+
end
|
173
|
+
|
174
|
+
# REVIEW: Retrieve all the grade objects for the current user context assigned
|
175
|
+
# in a particular org unit.
|
176
|
+
def get_current_user_org_unit_grades(org_unit_id)
|
177
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/values/myGradeValues/"
|
178
|
+
_get(path)
|
179
|
+
# RETURN: This action returns a JSON array of GradeValue blocks.
|
180
|
+
end
|
181
|
+
|
182
|
+
# REVIEW: Retrieve all the grade objects for a particular user assigned in an org unit.
|
183
|
+
def get_user_org_unit_grades(org_unit_id, user_id)
|
184
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/values/#{user_id}/"
|
185
|
+
_get(path)
|
186
|
+
# RETURN: This action returns a JSON array of GradeValue blocks.
|
187
|
+
end
|
188
|
+
|
189
|
+
########################
|
190
|
+
# GRADE VALUES:#########
|
191
|
+
########################
|
192
|
+
|
193
|
+
# REVIEW: Delete a course completion.
|
194
|
+
# RETURNS: nil
|
195
|
+
def delete_course_completion(org_unit_id, completion_id)
|
196
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/courseCompletion/#{completion_id}"
|
197
|
+
_delete(path)
|
198
|
+
end
|
199
|
+
|
200
|
+
# REVIEW: Retrieve all the course completion records for an org unit.
|
201
|
+
# RETURNS: This action returns a paged result set containing the resulting
|
202
|
+
# CourseCompletion data blocks for the segment following your bookmark
|
203
|
+
# parameter (or the first segment if the parameter is empty or missing).
|
204
|
+
def get_org_unit_completion_records(org_unit_id, user_id = 0, start_expiry = '',
|
205
|
+
end_expiry = '', bookmark = '')
|
206
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/courseCompletion/"
|
207
|
+
path += "?"
|
208
|
+
path += "userId=#{user_id}&" if user_id != 0
|
209
|
+
path += "startExpiry=#{start_expiry}&" if startExpiry != ''
|
210
|
+
path += "endExpiry=#{end_expiry}&" if endExpiry != ''
|
211
|
+
path += "bookmark=#{bookmark}" if bookmark != ''
|
212
|
+
_get(path)
|
213
|
+
# RETURNS: This action returns a paged result set containing the resulting
|
214
|
+
# CourseCompletion data blocks for the segment following your bookmark
|
215
|
+
# parameter (or the first segment if the parameter is empty or missing).
|
216
|
+
end
|
217
|
+
|
218
|
+
# REVIEW: Retrieve all the course completion records for a user.
|
219
|
+
# RETURNS: This action returns a paged result set containing the resulting
|
220
|
+
# CourseCompletion data blocks for the segment following your bookmark
|
221
|
+
# parameter (or the first segment if the parameter is empty or missing).
|
222
|
+
def get_user_completion_records(user_id, start_expiry = '', end_expiry = '',
|
223
|
+
bookmark = '')
|
224
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/courseCompletion/"
|
225
|
+
path += "?"
|
226
|
+
path += "startExpiry=#{start_expiry}&" if startExpiry != ''
|
227
|
+
path += "endExpiry=#{end_expiry}&" if endExpiry != ''
|
228
|
+
path += "bookmark=#{bookmark}" if bookmark != ''
|
229
|
+
_get(path)
|
230
|
+
# RETURNS: This action returns a paged result set containing the resulting
|
231
|
+
# CourseCompletion data blocks for the segment following your bookmark
|
232
|
+
# parameter (or the first segment if the parameter is empty or missing).
|
233
|
+
end
|
234
|
+
|
235
|
+
# TODO: Create a new course completion for an org unit.
|
236
|
+
# RETURNS: a CourseCompletion JSON block with the newly created course completion record.
|
237
|
+
def create_course_completion(org_unit_id, course_completion_data)
|
238
|
+
#CourseCompletionCreationData JSON data block example:
|
239
|
+
# {"UserId" => 0,
|
240
|
+
# "CompletedDate" => "UTCDateTime",
|
241
|
+
# "ExpiryDate" => "UTCDateTime" || nil}
|
242
|
+
# POST /d2l/api/le/(version)/(orgUnitId)/grades/courseCompletion/
|
243
|
+
end
|
244
|
+
|
245
|
+
# TODO: Update an existing course completion.
|
246
|
+
# RETURNS: a CourseCompletion JSON block with the newly created course completion record.
|
247
|
+
def update_course_completion(org_unit_id, completion_id, course_completion_data)
|
248
|
+
# CourseCompletionUpdateData JSON data block example:
|
249
|
+
# {"CompletedDate" => "UTCDateTime",
|
250
|
+
# "ExpiryDate" => "UTCDateTime" || nil}
|
251
|
+
# PUT /d2l/api/le/(version)/(orgUnitId)/grades/courseCompletion/(completionId)
|
252
|
+
end
|
253
|
+
|
254
|
+
########################
|
255
|
+
# GRADE STATISTICS:#####
|
256
|
+
########################
|
257
|
+
|
258
|
+
# REVIEW: Get statistics for a specified grade item.
|
259
|
+
# RETURNS: a GradeStatisticsInfo JSON block.
|
260
|
+
def get_grade_item_statistics(org_unit_id, grade_object_id)
|
261
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/statistics"
|
262
|
+
_get(path)
|
263
|
+
# RETURNS: a GradeStatisticsInfo JSON block.
|
264
|
+
end
|
265
|
+
|
266
|
+
########################
|
267
|
+
# GRADE SETUP:##########
|
268
|
+
########################
|
269
|
+
|
270
|
+
# REVIEW: Retrieve the grades configuration for the org unit.
|
271
|
+
# RETURNS: a GradeSetupInfo JSON block.
|
272
|
+
def get_org_unit_grade_config(org_unit_id)
|
273
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/setup/"
|
274
|
+
_get(path)
|
275
|
+
# RETURNS: a GradeSetupInfo JSON block.
|
276
|
+
end
|
277
|
+
|
278
|
+
# TODO: Update the grades configuration for the org unit.
|
279
|
+
# INPUT: a GradeSetupInfo JSON block. (grade_setup_info)
|
280
|
+
# RETURNS: a GradeSetupInfo JSON block.
|
281
|
+
def update_org_unit_grade_config(org_unit_id, grade_setup_info)
|
282
|
+
# Grade.GradeSetupInfo JSON data block example:
|
283
|
+
# {"GradingSystem" => "Points", # Other types: "Weighted", "Formula"
|
284
|
+
# "IsNullGradeZero" => false,
|
285
|
+
# "DefaultGradeSchemeId" => 0}
|
286
|
+
# PUT /d2l/api/le/(version)/(orgUnitId)/grades/setup/
|
287
|
+
# RETURNS: a GradeSetupInfo JSON block.
|
288
|
+
end
|
289
|
+
|
290
|
+
########################
|
291
|
+
# GRADE EXEMPTIONS:#####
|
292
|
+
########################
|
293
|
+
|
294
|
+
# REVIEW: Retrieve all the exempt users for a provided grade.
|
295
|
+
# RETURNS: a JSON array of User blocks.
|
296
|
+
def get_grade_exempt_users(org_unit_id, grade_object_id)
|
297
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/exemptions/"
|
298
|
+
_get(path)
|
299
|
+
# RETURNS: a JSON array of User blocks.
|
300
|
+
end
|
301
|
+
|
302
|
+
# REVIEW: Determine if a user is exempt from a grade.
|
303
|
+
# RETURNS: a User JSON block.
|
304
|
+
def get_is_user_exempt(org_unit_id, grade_object_id, user_id)
|
305
|
+
path = "GET /d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/exemptions/#{user_id}"
|
306
|
+
_get(path)
|
307
|
+
# RETURNS: a User JSON block.
|
308
|
+
end
|
309
|
+
|
310
|
+
# REVIEW: Exempt a user from a grade.
|
311
|
+
# RETURNS: a User JSON block.
|
312
|
+
def exempt_user_from_grade(org_unit_id, grade_object_id, user_id)
|
313
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/exemptions/#{user_id}"
|
314
|
+
_post(path, {})
|
315
|
+
# RETURNS: a User JSON block.
|
316
|
+
end
|
317
|
+
|
318
|
+
# REVIEW: Remove a user’s exemption from a grade.
|
319
|
+
# RETURNS: nil
|
320
|
+
def remove_user_grade_exemption(org_unit_id, grade_object_id, user_id)
|
321
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/#{grade_object_id}/exemptions/#{user_id}"
|
322
|
+
_delete(path)
|
323
|
+
# RETURNS: nil
|
324
|
+
end
|
325
|
+
|
326
|
+
#############################
|
327
|
+
# BULK GRADE EXEMPTIONS:#####
|
328
|
+
#############################
|
329
|
+
|
330
|
+
# REVIEW: Retrieve all the grade objects for a provided user in a provided org unit with exemption status included.
|
331
|
+
# RETURNS: BulkGradeObjectExemptionResult JSON block.
|
332
|
+
def get_user_grade_exemptions(org_unit_id, user_id)
|
333
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/grades/exemptions/#{user_id}"
|
334
|
+
_get(path)
|
335
|
+
# RETURNS: BulkGradeObjectExemptionResult JSON block.
|
336
|
+
end
|
337
|
+
|
338
|
+
# TODO: Attempt to exempt or unexempt a set of grades for a user.
|
339
|
+
# INPUT: a BulkGradeObjectExemptionUpdate.
|
340
|
+
# NOTE: If a grade has been changed since the provided ExemptionAccessDate,
|
341
|
+
# a conflict will be added to the result set and that grade will not
|
342
|
+
# be exempted or unexempted.
|
343
|
+
# RETURNS: a JSON array of BulkGradeObjectExemptionConflict blocks.
|
344
|
+
def bulk_grade_exemption_update(org_unit_id, user_id, bulk_grade_exmption_update_block)
|
345
|
+
# Grade.BulkGradeObjectExemptionUpdate JSON data block example:
|
346
|
+
# {"ExemptedIds" => [0,1,2,3], # D2LIDs
|
347
|
+
# "UnexemptedIds" => [0,1,2,3], # D2LIDs
|
348
|
+
# "ExemptionAccessDate" => 'UTCDateTime'}
|
349
|
+
|
350
|
+
# POST /d2l/api/le/(version)/(orgUnitId)/grades/exemptions/(userId)
|
351
|
+
# RETURNS: a JSON array of BulkGradeObjectExemptionConflict blocks.
|
352
|
+
end
|