d2l_sdk 0.1.10 → 0.1.11
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/.codeclimate.yml +28 -0
- data/.fasterer.yml +28 -0
- data/.rubocop.yml +67 -0
- data/.vscode/settings.json +9 -0
- data/Gemfile +3 -2
- data/README.md +341 -63
- data/d2l_sdk.gemspec +1 -0
- data/lib/d2l_sdk/auth.rb +1 -1
- data/lib/d2l_sdk/calendar.rb +11 -12
- data/lib/d2l_sdk/config.rb +29 -29
- data/lib/d2l_sdk/config_variables.rb +27 -39
- data/lib/d2l_sdk/course.rb +53 -47
- data/lib/d2l_sdk/course_content.rb +60 -54
- data/lib/d2l_sdk/course_template.rb +19 -14
- data/lib/d2l_sdk/datahub.rb +28 -28
- data/lib/d2l_sdk/demographics.rb +23 -8
- data/lib/d2l_sdk/discussions.rb +361 -56
- data/lib/d2l_sdk/dropbox.rb +208 -16
- data/lib/d2l_sdk/enroll.rb +9 -9
- data/lib/d2l_sdk/grades.rb +7 -7
- data/lib/d2l_sdk/group.rb +42 -42
- data/lib/d2l_sdk/logging.rb +2 -2
- data/lib/d2l_sdk/lti.rb +243 -11
- data/lib/d2l_sdk/news.rb +2 -2
- data/lib/d2l_sdk/org_unit.rb +20 -18
- data/lib/d2l_sdk/requests.rb +105 -69
- data/lib/d2l_sdk/section.rb +13 -12
- data/lib/d2l_sdk/semester.rb +6 -5
- data/lib/d2l_sdk/setup_versions.rb +7 -7
- data/lib/d2l_sdk/user.rb +48 -58
- data/lib/d2l_sdk/version.rb +1 -1
- metadata +6 -5
- data/change_lastname.rb +0 -65
- data/lol.txt +0 -1
- data/test.rb +0 -19
data/lib/d2l_sdk/dropbox.rb
CHANGED
@@ -27,21 +27,101 @@ def get_dropbox_file_attachment(org_unit_id, folder_id, file_id)
|
|
27
27
|
_get(path)
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
def check_dropbox_folder_update_data_validity(dropbox_folder_update_data)
|
31
|
+
schema = {
|
32
|
+
'type' => 'object',
|
33
|
+
'required' => %w(CategoryId Name CustomInstructions Availability
|
34
|
+
GroupTypeId DueDate DisplayInCalendar NotificationEmail),
|
35
|
+
'properties' =>
|
36
|
+
{
|
37
|
+
'CategoryId' => { 'type' => %w(integer null) },
|
38
|
+
'Name' => { 'type' => 'string' },
|
39
|
+
'CustomInstructions' =>
|
40
|
+
{
|
41
|
+
'type' => 'object',
|
42
|
+
'properties' =>
|
43
|
+
{
|
44
|
+
'Content' => { 'type' => 'string' },
|
45
|
+
'Type' => { 'type' => 'string' } # either 'Text' or 'HTML'
|
46
|
+
}
|
47
|
+
},
|
48
|
+
'Availability' =>
|
49
|
+
{
|
50
|
+
'type' => %w(object null),
|
51
|
+
'properties' =>
|
52
|
+
{
|
53
|
+
'StartDate' => { 'type' => 'string' },
|
54
|
+
'EndDate' => { 'type' => 'string' }
|
55
|
+
}
|
56
|
+
},
|
57
|
+
'GroupTypeId' => { 'type' => %w(integer null) },
|
58
|
+
'DueDate' => { 'type' => %w(string null) },
|
59
|
+
'DisplayInCalendar' => { 'type' => 'boolean' },
|
60
|
+
'NotificationEmail' => { 'type' => %w(string null) }
|
61
|
+
}
|
62
|
+
}
|
63
|
+
JSON::Validator.validate!(schema, dropbox_folder_update_data, validate_schema: true)
|
64
|
+
end
|
65
|
+
|
66
|
+
# REVIEW: Create a new dropbox folder in an org unit.
|
31
67
|
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/
|
32
|
-
|
68
|
+
def create_dropbox_folder(org_unit_id, dropbox_folder_update_data)
|
69
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/"
|
70
|
+
payload = {
|
71
|
+
"CategoryId" => nil, # or a number
|
72
|
+
"Name" => "string",
|
73
|
+
"CustomInstructions" => {
|
74
|
+
"Content" => "string",
|
75
|
+
"Text" => "Text|HTML"
|
76
|
+
},
|
77
|
+
"Availability" => {
|
78
|
+
"StartDate" => "string or nil", # or nil
|
79
|
+
"EndDate" => "string or nil" # or nil
|
80
|
+
},
|
81
|
+
"GroupTypeId" => nil, # or a number
|
82
|
+
"DueDate" => nil,
|
83
|
+
"DisplayInCalendar" => false,
|
84
|
+
"NotificationEmail" => nil # or a string --- Added in LE v1.21
|
85
|
+
}.merge!(dropbox_folder_update_data)
|
86
|
+
check_dropbox_folder_update_data_validity(payload)
|
87
|
+
_post(path, payload)
|
88
|
+
# RETURNS: DropboxFolder JSON block
|
89
|
+
end
|
90
|
+
|
91
|
+
# REVIEW: Update a particular dropbox folder in an org unit.
|
33
92
|
# => PUT /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}
|
93
|
+
def update_dropbox_folder(org_unit_id, dropbox_folder_update_data)
|
94
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}"
|
95
|
+
payload = {
|
96
|
+
"CategoryId" => nil, # or a number
|
97
|
+
"Name" => "string",
|
98
|
+
"CustomInstructions" => {
|
99
|
+
"Content" => "string",
|
100
|
+
"Text" => "Text|HTML"
|
101
|
+
},
|
102
|
+
"Availability" => {
|
103
|
+
"StartDate" => "string or nil", # or nil
|
104
|
+
"EndDate" => "string or nil" # or nil
|
105
|
+
},
|
106
|
+
"GroupTypeId" => nil, # or a number
|
107
|
+
"DueDate" => nil,
|
108
|
+
"DisplayInCalendar" => false,
|
109
|
+
"NotificationEmail" => nil # or a string --- Added in LE v1.21
|
110
|
+
}.merge!(dropbox_folder_update_data)
|
111
|
+
check_dropbox_folder_update_data_validity(payload)
|
112
|
+
_put(path, payload)
|
113
|
+
# RETURNS: DropboxFolder JSON block
|
114
|
+
end
|
34
115
|
|
35
116
|
# REVIEW: Retrieve a list of org units for which the current user context has an
|
36
117
|
# assessment role on their dropbox folders (can see submissions and provide feedback).
|
37
118
|
# => GET /d2l/api/le/#{$le_ver}/dropbox/orgUnits/feedback/
|
38
119
|
def get_current_user_assessable_folders(type = nil)
|
39
120
|
path = "/d2l/api/le/#{$le_ver}/dropbox/orgUnits/feedback/"
|
40
|
-
path += "?type=#{type}" if type
|
121
|
+
path += "?type=#{type}" if type.zero? || type == 1
|
41
122
|
_get(path)
|
42
123
|
end
|
43
124
|
|
44
|
-
|
45
125
|
##################
|
46
126
|
## SUBMISSIONS: ##
|
47
127
|
##################
|
@@ -63,38 +143,114 @@ end
|
|
63
143
|
|
64
144
|
# TODO: Post a new group submission to a particular dropbox folder.
|
65
145
|
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/submissions/group/(groupId)
|
146
|
+
# INPUT: multipart/mixed body should contain a JSON part encoding the submission’s descriptive comments
|
147
|
+
# in RichText, followed by the submission file’s data.
|
148
|
+
def post_new_group_submission; end
|
149
|
+
|
66
150
|
# TODO: Post a new submission for the current user context to a particular dropbox folder.
|
67
151
|
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/submissions/mysubmissions/
|
68
|
-
#
|
152
|
+
# INPUT: multipart/mixed body should contain a JSON part encoding the submission’s descriptive comments
|
153
|
+
# in RichText, followed by the submission file’s data.
|
154
|
+
def post_current_user_new_submission; end
|
155
|
+
|
156
|
+
# REVIEW: Mark a submitted file as read.
|
69
157
|
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/submissions/#{submission_id}/files/#{file_id}/markAsRead
|
158
|
+
# INPUT: "Provide an empty post body."
|
159
|
+
def mark_file_as_read(org_unit_id, folder_id, submission_id)
|
160
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/submissions/#{submission_id}/files/#{file_id}/markAsRead"
|
161
|
+
_post(path, {})
|
162
|
+
end
|
70
163
|
|
71
164
|
##################
|
72
165
|
## FEEDBACK: #####
|
73
166
|
##################
|
74
167
|
|
75
|
-
#
|
76
|
-
# => DELETE /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/
|
168
|
+
# REVIEW: Remove a particular file attachment from an entity’s feedback entry within a specified dropbox folder.
|
169
|
+
# => DELETE /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}/attachments/#{file_id}
|
170
|
+
def remove_feedback_entry_file_attachment(org_unit_id, folder_id, entity_type, entity_id, file_id)
|
171
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}/attachments/#{file_id}"
|
172
|
+
_delete(path)
|
173
|
+
end
|
77
174
|
|
78
175
|
# REVIEW: Retrieve the feedback entry from a dropbox folder for the provided entity.
|
79
|
-
# => GET /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}
|
176
|
+
# => GET /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}
|
80
177
|
def get_dropbox_folder_entity_feedback_entry(org_unit_id, folder_id, entity_id)
|
81
|
-
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}
|
178
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}"
|
82
179
|
_get(path)
|
83
180
|
end
|
84
181
|
|
85
182
|
# REVIEW: Retrieve a feedback entry’s file attachment from a dropbox folder for the provided entity.
|
86
|
-
# => GET /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/
|
183
|
+
# => GET /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}/attachments/#{file_id}
|
87
184
|
def get_feedback_entry_file_attachment(org_unit_id, folder_id, entity_id, file_id)
|
88
|
-
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/
|
185
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}/attachments/#{file_id}"
|
89
186
|
_get(path)
|
90
187
|
end
|
91
188
|
|
92
189
|
# TODO: Post feedback (without attachment) for a particular submission in a specific dropbox folder.
|
93
|
-
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}
|
190
|
+
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}
|
191
|
+
# INPUT: Dropbox.DropboxFeedback
|
192
|
+
def post_feedback_without_attachment(org_unit_id, folder_id, entity_id, entity_type, dropbox_feedback)
|
193
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}"
|
194
|
+
payload = {
|
195
|
+
"Score" => 1,
|
196
|
+
"Feedback" =>
|
197
|
+
{
|
198
|
+
"Text" => "String",
|
199
|
+
"Html" => "String"
|
200
|
+
},
|
201
|
+
"RubricAssessments" =>
|
202
|
+
[
|
203
|
+
{
|
204
|
+
"RubricId" => 0,
|
205
|
+
"OverallScore" => nil, # or null
|
206
|
+
"OverallFeedback" =>
|
207
|
+
{ # RICHTEXT
|
208
|
+
"Text" => "String",
|
209
|
+
"Html" => "String"
|
210
|
+
},
|
211
|
+
"OverallLevel" =>
|
212
|
+
{ # or null
|
213
|
+
"LevelId" => 0,
|
214
|
+
"Feedback" =>
|
215
|
+
{ # RICHTEXT
|
216
|
+
"Text" => "String",
|
217
|
+
"Html" => "String"
|
218
|
+
}
|
219
|
+
},
|
220
|
+
"OverallScoreOverridden" => false,
|
221
|
+
"OverallFeedbackOverridden" => false,
|
222
|
+
"CriteriaOutcome" =>
|
223
|
+
[ # Array of CriterionOutcome hashes
|
224
|
+
{ # Example CriterionOutcome hash. Set for merging as
|
225
|
+
# it is assumed -at least- one is required.
|
226
|
+
"CriterionId" => 0,
|
227
|
+
"LevelId" => nil, # or a D2LID::Integer
|
228
|
+
"Score" => nil, # or a decimal
|
229
|
+
"ScoreIsOverridden" => false,
|
230
|
+
"Feedback" =>
|
231
|
+
{ # RICHTEXT
|
232
|
+
"Text" => "String",
|
233
|
+
"Html" => "String"
|
234
|
+
},
|
235
|
+
"FeedbackIsOverridden" => false
|
236
|
+
},
|
237
|
+
# more CriterionOutcome hashes here! :D
|
238
|
+
]
|
239
|
+
}
|
240
|
+
],
|
241
|
+
"IsGraded" => false
|
242
|
+
}.merge!(dropbox_feedback)
|
243
|
+
# TODO: Create a schema to validate this payload against... :/
|
244
|
+
_post(path, payload)
|
245
|
+
end
|
246
|
+
|
94
247
|
# TODO: Attach an uploaded file to a particular entity’s feedback entry in a specific dropbox folder.
|
95
|
-
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/
|
248
|
+
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}/attach
|
249
|
+
def attach_file_to_feedback_entry; end
|
250
|
+
|
96
251
|
# TODO: Initiate a resumable file upload request for a particular entity’s feedback for a specific dropbox folder.
|
97
|
-
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/
|
252
|
+
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/folders/#{folder_id}/feedback/#{entity_type}/#{entity_id}/upload
|
253
|
+
def initiate_feedback_entry_file_upload; end
|
98
254
|
|
99
255
|
##########################
|
100
256
|
## FOLDER CATEGORIES: ####
|
@@ -114,7 +270,43 @@ def get_dropbox_folder_category_info(org_unit_id, category_id)
|
|
114
270
|
_get(path)
|
115
271
|
end
|
116
272
|
|
117
|
-
#
|
273
|
+
# REVIEW: Create a new dropbox folder category for the provided org unit.
|
118
274
|
# => POST /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/categories/
|
119
|
-
#
|
275
|
+
# INPUT: DropboxCategory JSON data block
|
276
|
+
# RETURNS: a single DropboxCategory block.
|
277
|
+
# NOTE: Few enough required values in the JSON data block,
|
278
|
+
# so they can simply be passed as arguments and checked
|
279
|
+
# for conformity by themselves.
|
280
|
+
def create_dropbox_folder_category(org_unit_id, dropbox_category_id, dropbox_category_name)
|
281
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/categories/"
|
282
|
+
# Check that the values conform to the JSON schema.
|
283
|
+
if !dropbox_category_id.is_a? Numeric
|
284
|
+
raise ArgumentError, "Argument 'dropbox_category_id' with value #{dropbox_category_id} is not an integer value."
|
285
|
+
elsif !dropbox_category_name.is_a? String
|
286
|
+
raise ArgumentError, "Argument 'dropbox_category_name' with value #{dropbox_category_name} is not a String value."
|
287
|
+
end
|
288
|
+
payload = {
|
289
|
+
'Id' => dropbox_category_id,
|
290
|
+
'Name' => dropbox_category_name
|
291
|
+
}
|
292
|
+
_post(path, payload)
|
293
|
+
end
|
294
|
+
|
295
|
+
# REVIEW: Update the information for a specific dropbox folder category.
|
120
296
|
# => PUT /d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/categories/#{category_id}
|
297
|
+
# INPUT: DropboxCategory JSON data block.
|
298
|
+
# RETURNS: a single DropboxCategory block.
|
299
|
+
def update_dropbox_folder_category(org_unit_id, category_id, dropbox_category_id, dropbox_category_name)
|
300
|
+
path = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/dropbox/categories/#{category_id}"
|
301
|
+
# Check that the values conform to the JSON schema.
|
302
|
+
if !dropbox_category_id.is_a? Numeric
|
303
|
+
raise ArgumentError, "Argument 'dropbox_category_id' with value #{dropbox_category_id} is not an integer value."
|
304
|
+
elsif !dropbox_category_name.is_a? String
|
305
|
+
raise ArgumentError, "Argument 'dropbox_category_name' with value #{dropbox_category_name} is not a String value."
|
306
|
+
end
|
307
|
+
payload = {
|
308
|
+
'Id' => dropbox_category_id,
|
309
|
+
'Name' => dropbox_category_name
|
310
|
+
}
|
311
|
+
_put(path, payload)
|
312
|
+
end
|
data/lib/d2l_sdk/enroll.rb
CHANGED
@@ -43,10 +43,10 @@ def get_all_enrollments_of_current_user(bookmark = '', sort_by = '', is_active =
|
|
43
43
|
path = "/d2l/api/lp/#{$lp_ver}/enrollments/myenrollments/"
|
44
44
|
path += "?bookmark=#{bookmark}" if bookmark != ''
|
45
45
|
path += "?sortBy=#{sort_by}" if sort_by != ''
|
46
|
-
path += "?isActive=#{is_active}"
|
46
|
+
path += "?isActive=#{is_active}" unless is_active.nil?
|
47
47
|
path += "?startDateTime=#{start_date_time}" if start_date_time != ''
|
48
48
|
path += "?endDateTime=#{end_date_time}" if end_date_time != ''
|
49
|
-
path += "?canAccess=#{can_access}"
|
49
|
+
path += "?canAccess=#{can_access}" unless can_access.nil?
|
50
50
|
_get(path)
|
51
51
|
# Returns: paged result set containing the resulting MyOrgUnitInfo data blocks
|
52
52
|
end
|
@@ -112,7 +112,7 @@ def check_create_enrollment_data_validity(enrollment_data)
|
|
112
112
|
'properties' => {
|
113
113
|
'OrgUnitId' => { 'type' => 'integer' },
|
114
114
|
'UserId' => { 'type' => 'integer' },
|
115
|
-
'RoleId' => { 'type' => 'integer' }
|
115
|
+
'RoleId' => { 'type' => 'integer' }
|
116
116
|
}
|
117
117
|
}
|
118
118
|
JSON::Validator.validate!(schema, enrollment_data, validate_schema: true)
|
@@ -120,10 +120,11 @@ end
|
|
120
120
|
|
121
121
|
# Create a new enrollment for a user.
|
122
122
|
def create_user_enrollment(course_enrollment_data)
|
123
|
-
payload = {
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
payload = {
|
124
|
+
'OrgUnitId' => '', # String
|
125
|
+
'UserId' => '', # String
|
126
|
+
'RoleId' => '', # String
|
127
|
+
}.merge!(course_enrollment_data)
|
127
128
|
# ap payload
|
128
129
|
# requires: CreateEnrollmentData JSON block
|
129
130
|
path = "/d2l/api/lp/#{$lp_ver}/enrollments/"
|
@@ -132,7 +133,6 @@ def create_user_enrollment(course_enrollment_data)
|
|
132
133
|
# Returns: EnrollmentData JSON block for the newly enrolled user.
|
133
134
|
end
|
134
135
|
|
135
|
-
|
136
136
|
########################
|
137
137
|
# PINNING:##############
|
138
138
|
########################
|
@@ -170,7 +170,7 @@ end
|
|
170
170
|
# Input: auditee_id (D2LID as single JSON number) - Auditee to be removed
|
171
171
|
def remove_auditee(auditor_id, auditee_id)
|
172
172
|
path = "/d2l/api/le/#{$le_ver}/auditing/auditors/#{auditor_id}/auditees/"
|
173
|
-
_delete(path, true, {AuditeeId: auditee_id})
|
173
|
+
_delete(path, true, { AuditeeId: auditee_id })
|
174
174
|
end
|
175
175
|
|
176
176
|
# REVIEW: Retrieve information for an auditee.
|
data/lib/d2l_sdk/grades.rb
CHANGED
@@ -164,13 +164,13 @@ def create_org_unit_grade_object(org_unit_id, grade_object, type)
|
|
164
164
|
end
|
165
165
|
|
166
166
|
# TODO: Update a specific grade object.
|
167
|
-
def update_org_unit_grade_object(org_unit_id, grade_object)
|
167
|
+
# def update_org_unit_grade_object(org_unit_id, grade_object)
|
168
168
|
# NOTE: if new name, it must be Unique
|
169
169
|
# NOTE: must be grade object of type numeric, passfail, selectbox, or text
|
170
170
|
# PUT /d2l/api/le/(version)/(orgUnitId)/grades/(gradeObjectId)
|
171
171
|
# Return: This action returns a GradeObject JSON block for the grade object
|
172
172
|
# that the service just updated.
|
173
|
-
end
|
173
|
+
# end
|
174
174
|
|
175
175
|
########################
|
176
176
|
# GRADE CATEGORIES:#####
|
@@ -208,9 +208,9 @@ def create_org_unit_grade_category(org_unit_id, grade_category_data)
|
|
208
208
|
payload =
|
209
209
|
{
|
210
210
|
'Name' => '', # <string>,
|
211
|
-
'ShortName'=> '', # <string>,
|
212
|
-
'CanExceedMax'=> false, # <boolean>,
|
213
|
-
'ExcludeFromFinalGrade'=> false, # <boolean>,
|
211
|
+
'ShortName' => '', # <string>,
|
212
|
+
'CanExceedMax' => false, # <boolean>,
|
213
|
+
'ExcludeFromFinalGrade' => false, # <boolean>,
|
214
214
|
'StartDate' => nil, # <string:UTCDateTime>|null,
|
215
215
|
'EndDate' => nil, # <string:UTCDateTime>|null,
|
216
216
|
'Weight' => nil, # <number:decimal>|null,
|
@@ -357,7 +357,7 @@ def get_org_unit_completion_records(org_unit_id, user_id = 0, start_expiry = '',
|
|
357
357
|
# parameter (or the first segment if the parameter is empty or missing).
|
358
358
|
end
|
359
359
|
|
360
|
-
#
|
360
|
+
# TODO: Retrieve all the course completion records for a user.
|
361
361
|
# RETURNS: This action returns a paged result set containing the resulting
|
362
362
|
# CourseCompletion data blocks for the segment following your bookmark
|
363
363
|
# parameter (or the first segment if the parameter is empty or missing).
|
@@ -483,7 +483,7 @@ end
|
|
483
483
|
# a conflict will be added to the result set and that grade will not
|
484
484
|
# be exempted or unexempted.
|
485
485
|
# RETURNS: a JSON array of BulkGradeObjectExemptionConflict blocks.
|
486
|
-
def bulk_grade_exemption_update(org_unit_id, user_id,
|
486
|
+
def bulk_grade_exemption_update(org_unit_id, user_id, bulk_grade_exemption_update_block)
|
487
487
|
# Grade.BulkGradeObjectExemptionUpdate JSON data block example:
|
488
488
|
# {"ExemptedIds" => [0,1,2,3], # D2LIDs
|
489
489
|
# "UnexemptedIds" => [0,1,2,3], # D2LIDs
|
data/lib/d2l_sdk/group.rb
CHANGED
@@ -12,7 +12,7 @@ end
|
|
12
12
|
|
13
13
|
# Delete a particular group from an org unit.
|
14
14
|
def delete_group(org_unit_id, group_category_id, group_id)
|
15
|
-
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/groupcategories/#{group_category_id}/groups
|
15
|
+
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/groupcategories/#{group_category_id}/groups/#{group_id}"
|
16
16
|
_delete(path)
|
17
17
|
end
|
18
18
|
|
@@ -53,19 +53,19 @@ def validate_create_group_category_data(group_category_data)
|
|
53
53
|
schema = {
|
54
54
|
'type' => 'object',
|
55
55
|
'required' => %w(Name Description EnrollmentStyle
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
EnrollmentQuality AutoEnroll RandomizeEnrollments
|
57
|
+
NumberOfGroups MaxUsersPerGroup AllocateAfterExpiry
|
58
|
+
SelfEnrollmentExpiryDate GroupPrefix),
|
59
59
|
'properties' => {
|
60
60
|
'Name' => { 'type' => 'string' },
|
61
61
|
'Description' =>
|
62
62
|
{
|
63
63
|
'type' => 'object',
|
64
|
-
'properties'=>{
|
64
|
+
'properties' => {
|
65
65
|
"Content" => "string",
|
66
|
-
"Type" => "string" #"Text|HTML"
|
66
|
+
"Type" => "string" # "Text|HTML"
|
67
67
|
}
|
68
|
-
}, #RichTextInput
|
68
|
+
}, # RichTextInput
|
69
69
|
# if set to SingleUserMemberSpecificGroup, values set for NumberOfGroups
|
70
70
|
# and MaxUsersPerGroup are IGNORED
|
71
71
|
# ----------------------------------
|
@@ -77,16 +77,16 @@ def validate_create_group_category_data(group_category_data)
|
|
77
77
|
# 4 = SelfEnrollmentNumberOfGroups
|
78
78
|
# 5 = PeoplePerNumberOfGroupsSelfEnrollment
|
79
79
|
# ----------------------------------
|
80
|
-
'EnrollmentStyle' => { 'type' => 'integer' }, #num GRPENROLL_T
|
80
|
+
'EnrollmentStyle' => { 'type' => 'integer' }, # num GRPENROLL_T
|
81
81
|
# if non-nil, values for NumberOfGroups and MaxUsersPerGroup are IGNORED
|
82
82
|
'EnrollmentQuantity' => { 'type' => %w(integer null) },
|
83
|
-
'AutoEnroll' => { 'type' => 'boolean'},
|
83
|
+
'AutoEnroll' => { 'type' => 'boolean' },
|
84
84
|
'RandomizeEnrollments' => { 'type' => 'boolean' },
|
85
|
-
'NumberOfGroups' => { 'type' => %w(integer null) }, #nil, 0, 1, 3, 5
|
86
|
-
'MaxUsersPerGroup' => { 'type' => %w(integer null) }, #1, 3, 5
|
85
|
+
'NumberOfGroups' => { 'type' => %w(integer null) }, # nil, 0, 1, 3, 5
|
86
|
+
'MaxUsersPerGroup' => { 'type' => %w(integer null) }, # 1, 3, 5
|
87
87
|
# if MaxUsersPerGroup has a value, then set this to true.
|
88
88
|
'AllocateAfterExpiry' => { 'type' => 'boolean' },
|
89
|
-
'SelfEnrollmentExpiryDate' => { 'type' => %w(string null) }, #UTCDATETIME
|
89
|
+
'SelfEnrollmentExpiryDate' => { 'type' => %w(string null) }, # UTCDATETIME
|
90
90
|
# Prepends group prefix to GroupName and GroupCode
|
91
91
|
'GroupPrefix' => { 'type' => %w(string null) }
|
92
92
|
}
|
@@ -99,18 +99,19 @@ end
|
|
99
99
|
#### requirements of values
|
100
100
|
# Create a new group category for an org unit.
|
101
101
|
def create_org_unit_group_category(org_unit_id, group_category_data)
|
102
|
-
payload = {
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
102
|
+
payload = {
|
103
|
+
'Name' => '', # String
|
104
|
+
'Description' => {}, # RichTextInput
|
105
|
+
'EnrollmentStyle' => 0, # number : group_enroll
|
106
|
+
'EnrollmentQuantity' => nil, # number | null
|
107
|
+
'AutoEnroll' => false, # bool
|
108
|
+
'RandomizeEnrollments' => false, # bool
|
109
|
+
'NumberOfGroups' => nil, # number | nil
|
110
|
+
'MaxUsersPerGroup' => nil, # number | nil
|
111
|
+
'AllocateAfterExpiry' => false, # bool
|
112
|
+
'SelfEnrollmentExpiryDate' => nil, # string: UTCDateTime | nil
|
113
|
+
'GroupPrefix' => nil, # String | nil
|
114
|
+
}.merge!(group_category_data)
|
114
115
|
# Requires: JSON block of GroupCategoryData
|
115
116
|
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/groupcategories/"
|
116
117
|
_post(path, payload)
|
@@ -125,14 +126,14 @@ def validate_group_data(group_data)
|
|
125
126
|
'properties' =>
|
126
127
|
{
|
127
128
|
'Name' => { 'type' => 'string' },
|
128
|
-
"Code" => {'type' => 'string'},
|
129
|
+
"Code" => { 'type' => 'string' },
|
129
130
|
'Description' =>
|
130
131
|
{
|
131
132
|
'type' => 'object',
|
132
|
-
'properties'=>
|
133
|
+
'properties' =>
|
133
134
|
{
|
134
135
|
"Content" => "string",
|
135
|
-
"Type" => "string" #"Text|HTML"
|
136
|
+
"Type" => "string" # "Text|HTML"
|
136
137
|
}
|
137
138
|
}
|
138
139
|
}
|
@@ -175,7 +176,7 @@ def validate_group_enrollment_data(group_enrollment_data)
|
|
175
176
|
'properties' => {
|
176
177
|
'UserId' => { 'type' => 'integer' }
|
177
178
|
}
|
178
|
-
}
|
179
|
+
}.merge!(group_enrollment_data)
|
179
180
|
JSON::Validator.validate!(schema, course_data, validate_schema: true)
|
180
181
|
end
|
181
182
|
|
@@ -196,15 +197,14 @@ def validate_update_group_category_data(group_category_data)
|
|
196
197
|
'required' => %w(Name Description AutoEnroll RandomizeEnrollments),
|
197
198
|
'properties' => {
|
198
199
|
'Name' => { 'type' => 'string' },
|
199
|
-
'Description' =>
|
200
|
-
{
|
200
|
+
'Description' => {
|
201
201
|
'type' => 'object',
|
202
|
-
'properties'=>{
|
202
|
+
'properties' => {
|
203
203
|
"Content" => "string",
|
204
|
-
"Type" => "string" #"Text|HTML"
|
204
|
+
"Type" => "string" # "Text|HTML"
|
205
205
|
}
|
206
206
|
},
|
207
|
-
'AutoEnroll' => { 'type' => 'boolean'},
|
207
|
+
'AutoEnroll' => { 'type' => 'boolean' },
|
208
208
|
'RandomizeEnrollments' => { 'type' => 'boolean' }
|
209
209
|
}
|
210
210
|
}
|
@@ -213,21 +213,21 @@ end
|
|
213
213
|
|
214
214
|
# update a particular group category for an org unit
|
215
215
|
def update_org_unit_group_category(org_unit_id, group_category_id, group_category_data)
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
216
|
+
payload = {
|
217
|
+
'Name' => '', # String
|
218
|
+
'Description' => {}, # RichTextInput
|
219
|
+
'AutoEnroll' => false, # bool
|
220
|
+
'RandomizeEnrollments' => false, # bool
|
221
|
+
}.merge!(group_category_data)
|
222
222
|
# Requires: JSON block of GroupCategoryData
|
223
223
|
validate_update_group_category_data(payload)
|
224
|
-
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/groupcategories/#{
|
224
|
+
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/groupcategories/#{group_category_id}"
|
225
225
|
_put(path, payload)
|
226
226
|
# Returns a GroupCategoryData JSON block, in the Fetch form, of updated grp. cat.
|
227
227
|
end
|
228
228
|
|
229
|
-
def
|
229
|
+
def group_category_locker_set_up?(org_unit_id, group_category_id)
|
230
230
|
path = "/d2l/api/lp/#{$lp_ver}/#{org_unit_id}/groupcategories/#{group_category_id}/locker"
|
231
231
|
_get(path)["HasLocker"]
|
232
|
-
#returns true if the group cat. locker has been setup already
|
232
|
+
# returns true if the group cat. locker has been setup already
|
233
233
|
end
|