d2l_sdk 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
 
2
- ###################
3
- ### CONTENT ACTIONS
4
- ###################
2
+ ########################
3
+ ### CONTENT ACTIONS#####
4
+ ########################
5
5
 
6
6
  # Delete a specific module from an org unit.
7
7
  def delete_module(org_unit_id, module_id) # DELETE
@@ -51,7 +51,7 @@ def get_topic_file(org_unit_id, topic_id, stream = false) # GET
51
51
  _get(query_string)
52
52
  end
53
53
 
54
- # Add a child +module+ or +topic+ to a specific module’s structure.
54
+ # TODO Add a child +module+ or +topic+ to a specific module’s structure.
55
55
  # Can be used in multiple ways. D2L categorizes it into 3 different ways:
56
56
  # --Module: add child module to parent module
57
57
  # --Link Topic: add child topic to parent module structure consisting of a LINK
@@ -68,7 +68,6 @@ end
68
68
  # Returns (if successful) a JSON data block containing properties of the newly created object
69
69
  def add_child_to_module(org_unit_id, module_id) # POST
70
70
  query_string = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}/structure/"
71
- # TODO
72
71
  end
73
72
 
74
73
  def check_content_module_validity(content_module)
@@ -200,9 +199,9 @@ def update_topic(org_unit_id, topic_id, content_topic) # GET
200
199
  _put(query_string, payload)
201
200
  end
202
201
 
203
- ####################
204
- ### CONTENT OVERVIEW
205
- ####################
202
+ #########################
203
+ ### CONTENT OVERVIEW#####
204
+ #########################
206
205
 
207
206
  # Retrieve the overview for a course offering.
208
207
  def get_course_overview(org_unit_id) # GET
@@ -219,9 +218,9 @@ def get_course_overview_file_attachment(org_unit_id) # GET
219
218
  # Returns: a file stream containing the course offering’s overview attachment.
220
219
  end
221
220
 
222
- ########
223
- ### ISBN
224
- ########
221
+ ##############
222
+ ### ISBN #####
223
+ ##############
225
224
 
226
225
  # Remove the association between an ISBN and org unit.
227
226
  def delete_isbn_association(org_unit_id, isbn) # DELETE
@@ -279,9 +278,137 @@ def create_isbn_org_unit_association(org_unit_id, isbn_association_data) # GET
279
278
  # the association between an org unit and an ISBN.
280
279
  end
281
280
 
282
- ####################
283
- ### SCHEDULED ITEMS
284
- ####################
281
+ #########################
282
+ ### SCHEDULED ITEMS######
283
+ #########################
284
+
285
+ # REVIEW: Retrieve the calling user’s scheduled items.
286
+ def get_user_overdue_items(org_unit_ids_CSV, completion = nil,
287
+ start_date_time = '', end_date_time = '') # GET
288
+ query_string = "/d2l/api/le/#{$le_ver}/content/myItems/?"
289
+ query_string += "orgUnitIdsCSV=#{org_unit_ids_CSV}&"
290
+ query_string += "completion=#{completion}&" unless completion.nil?
291
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
292
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
293
+ _get(query_string)
294
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
295
+ end
296
+
297
+ # REVIEW: Retrieve the calling user’s scheduled items still due.
298
+ def get_current_user_still_due_items(org_unit_ids_CSV, completion = nil,
299
+ start_date_time = '', end_date_time = '')
300
+ query_string = "/d2l/api/le/#{$le_ver}/content/myItems/due/?"
301
+ query_string += "orgUnitIdsCSV=#{org_unit_ids_CSV}&"
302
+ query_string += "completion=#{completion}&" unless completion.nil?
303
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
304
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
305
+ _get(query_string)
306
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
307
+ end
308
+
309
+ # REVIEW: Retrieve the quantities of the calling user’s scheduled items, organized by org unit.
310
+ # GET /d2l/api/le/(version)/content/myItems/itemCounts/
311
+ def get_current_user_organized_scheduled_items(org_unit_ids_CSV,
312
+ completion = nil,
313
+ start_date_time = '',
314
+ end_date_time = '')
315
+ query_string = "/d2l/api/le/#{$le_ver}/content/myItems/itemCounts/?"
316
+ query_string += "orgUnitIdsCSV=#{org_unit_ids_CSV}&"
317
+ query_string += "completion=#{completion}&" unless completion.nil?
318
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
319
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
320
+ _get(query_string)
321
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
322
+ end
323
+
324
+ # REVIEW: Retrieve the quantities of the calling user’s scheduled items still due.
325
+ # GET /d2l/api/le/(version)/content/myItems/due/itemCounts/
326
+ def get_current_user_scheduled_item_count(org_unit_ids_CSV, completion = nil,
327
+ start_date_time = '', end_date_time = '') # GET
328
+ query_string = "/d2l/api/le/#{$le_ver}/content/myItems/due/itemCounts/?"
329
+ query_string += "orgUnitIdsCSV=#{org_unit_ids_CSV}&"
330
+ query_string += "completion=#{completion}&" unless completion.nil?
331
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
332
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
333
+ _get(query_string)
334
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
335
+ end
336
+
337
+ # REVIEW: Retrieve the calling user’s completed scheduled items.
338
+ # GET /d2l/api/le/(version)/content/myItems/completions/
339
+ def get_current_user_completed_scheduled_items(org_unit_ids_CSV,
340
+ completion_from_date_time = '',
341
+ completed_to_date_time = '')
342
+ query_string = "/d2l/api/le/#{$le_ver}/content/myItems/completions/?"
343
+ query_string += "orgUnitIdsCSV=#{org_unit_ids_CSV}&"
344
+ query_string += "completedFromDateTime=#{completion_from_date_time}&" unless completion_from_date_time == ''
345
+ query_string += "completedToDateTime=#{completed_to_date_time}&" unless completed_to_date_time == ''
346
+ _get(query_string)
347
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
348
+ end
349
+
350
+ # REVIEW: Retrieve the calling user’s completed scheduled items that have a due date.
351
+ # GET /d2l/api/le/(version)/content/myItems/completions/due/
352
+ def get_current_user_completed_scheduled_items_with_due_date(org_unit_ids_CSV,
353
+ completion_from_date_time = '',
354
+ completed_to_date_time = '')
355
+ query_string = "/d2l/api/le/#{$le_ver}/content/myItems/completions/due/?"
356
+ query_string += "orgUnitIdsCSV=#{org_unit_ids_CSV}&"
357
+ query_string += "completedFromDateTime=#{completion_from_date_time}&" unless completion_from_date_time == ''
358
+ query_string += "completedToDateTime=#{completed_to_date_time}&" unless completed_to_date_time == ''
359
+ _get(query_string)
360
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
361
+ end
362
+
363
+ # REVIEW: Retrieve the calling user’s scheduled items for a particular org unit.
364
+ # GET /d2l/api/le/(version)/(orgUnitId)/content/myItems/
365
+ def get_current_user_scheduled_items_by_org_unit(org_unit_id, completion = nil,
366
+ start_date_time = '',
367
+ end_date_time = '')
368
+ query_string = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/myItems/?"
369
+ query_string += "completion=#{completion}&" unless completion.nil?
370
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
371
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
372
+ _get(query_string)
373
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
374
+ end
375
+
376
+ # REVIEW: Retrieve the calling user’s scheduled items still due for a particular org unit.
377
+ # GET /d2l/api/le/(version)/(orgUnitId)/content/myItems/due/
378
+ def get_current_user_org_unit_scheduled_item_count(org_unit_id, completion = nil,
379
+ start_date_time = '',
380
+ end_date_time = '') # GET
381
+ query_string = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/myItems/due/?"
382
+ query_string += "completion=#{completion}&" unless completion.nil?
383
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
384
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
385
+ _get(query_string)
386
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
387
+ end
388
+
389
+ # REVIEW: Retrieve the quantity of the calling user’s scheduled items for provided org unit.
390
+ # GET /d2l/api/le/(version)/(orgUnitId)/content/myItems/itemCount
391
+ def get_user_overdue_items(org_unit_id, completion = nil, start_date_time = '',
392
+ end_date_time = '') # GET
393
+ query_string = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/myItems/itemCount?"
394
+ query_string += "completion=#{completion}&" unless completion.nil?
395
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
396
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
397
+ _get(query_string)
398
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
399
+ end
400
+
401
+ # REVIEW: Retrieve quantity of the calling user’s scheduled items still due for a particular org unit.
402
+ # GET /d2l/api/le/(version)/(orgUnitId)/content/myItems/due/itemCount
403
+ def get_user_overdue_items(org_unit_id, completion = nil, start_date_time = '',
404
+ end_date_time = '') # GET
405
+ query_string = "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/myItems/due/itemCount?"
406
+ query_string += "completion=#{completion}&" unless completion.nil?
407
+ query_string += "startDateTime=#{start_date_time}&" unless start_date_time == ''
408
+ query_string += "endDateTime=#{end_date_time}&" unless end_date_time == ''
409
+ _get(query_string)
410
+ # Returns: An ObjectListPage JSON block containing a list of ScheduledItem blocks
411
+ end
285
412
 
286
413
  # Retrieve the overdue items for a particular user in a particular org unit.
287
414
  # +org_unit_ids_CSV+ is a CSV of D2LIDs or rather Org unit IDs (optional)
@@ -308,9 +435,9 @@ def get_current_user_overdue_items(org_unit_ids_CSV = nil) # GET
308
435
  # Returns: An ObjectListPage JSON block containing a list of OverdueItem.
309
436
  end
310
437
 
311
- #####################
312
- ### TABLE OF CONTENTS
313
- #####################
438
+ #########################
439
+ ### TABLE OF CONTENTS####
440
+ #########################
314
441
 
315
442
  # Retrieve a list of topics that have been bookmarked.
316
443
  def get_bookmarked_topics(org_unit_id) # GET
@@ -348,15 +475,13 @@ def get_current_user_progress(org_unit_id, level) # GET
348
475
  # a list of ContentAggregateCompletion items.
349
476
  end
350
477
 
351
- # Retrieve the user progress items in an org unit, for specific users or content topics.
352
- # NOTE: UNSTABLE
478
+
479
+ # TODO: --UNSTABLE-- Retrieve the user progress items in an org unit, for specific users or content topics.
353
480
  # _get "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/userprogress/"
354
481
 
355
- # Retrieve one user’s progress within an org unit for a particular content topic.
356
- # NOTE: UNSTABLE
482
+ # TODO: --UNSTABLE-- Retrieve one user’s progress within an org unit for a particular content topic.
357
483
  # _get "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/userprogress/#{topic_id}"
358
484
 
359
- # Update a user progress item.
360
- # NOTE: UNSTABLE
485
+ # TODO: --UNSTABLE-- Update a user progress item.
361
486
  # _post "/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/userprogress/"
362
487
  # payload: UserProgressData
@@ -4,6 +4,40 @@ require 'json-schema'
4
4
  # COURSE TEMPLATES:#####
5
5
  ########################
6
6
 
7
+ # Simply, a course template can be deleted by refencing it using its Identifier
8
+ # as an argument for this method. The argument is then used to refernce the obj
9
+ # by a path and then the path is passed in for a delete http method.
10
+ # /d2l/api/lp/(version)/coursetemplates/(orgUnitId) [DELETE]
11
+ def delete_course_template(org_unit_id)
12
+ path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}"
13
+ _delete(path)
14
+ puts '[+] Course template data deleted successfully'.green
15
+ end
16
+
17
+ # Retrieves a course template based upon an explicitly defined course template
18
+ # org_unit_id or Identifier. This is done by using the identifier as a component
19
+ # of the path, and then performing a GET http method that is then returned.
20
+ #
21
+ # returns: JSON course template data
22
+ # /d2l/api/lp/(version)/coursetemplates/(orgUnitId) [GET]
23
+ def get_course_template(org_unit_id)
24
+ path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}"
25
+ _get(path)
26
+ # return: JSON course template data
27
+ end
28
+
29
+ # Moreso a helper method, but this really just returns the schema of the
30
+ # course templates. This is predefined in the routing table, and retrieved via
31
+ # a GET http method.
32
+ #
33
+ # returns: JSON of course templates schema
34
+ # /d2l/api/lp/(version)/coursetemplates/schema [GET]
35
+ def get_course_templates_schema
36
+ path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/schema"
37
+ _get(path)
38
+ # This action returns a JSON array of SchemaElement blocks.
39
+ end
40
+
7
41
  # Checks if the created course template data conforms to the valence api for the
8
42
  # course template JSON object. If it does conform, then nothing happens and it
9
43
  # simply returns true. If it does not conform, then the JSON validator raises
@@ -51,18 +85,51 @@ def create_course_template(course_template_data)
51
85
  # returns: CourseTemplate JSON block containing the new data.
52
86
  end
53
87
 
54
- # Retrieves a course template based upon an explicitly defined course template
55
- # org_unit_id or Identifier. This is done by using the identifier as a component
56
- # of the path, and then performing a GET http method that is then returned.
57
- #
58
- # returns: JSON course template data
59
- # /d2l/api/lp/(version)/coursetemplates/(orgUnitId) [GET]
60
- def get_course_template(org_unit_id)
61
- path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}"
62
- _get(path)
63
- # return: JSON course template data
88
+ # Checks if the updated course template data conforms to the valence api for the
89
+ # course template JSON object. If it does conform, then nothing happens and it
90
+ # simply returns true. If it does not conform, then the JSON validator raises
91
+ # an exception.
92
+ def check_course_template_updated_data_validity(course_template_data)
93
+ schema = {
94
+ 'type' => 'object',
95
+ 'required' => %w(Name Code),
96
+ 'properties' => {
97
+ 'Name' => { 'type' => 'string' },
98
+ 'Code' => { 'type' => 'string' }
99
+ }
100
+ }
101
+ JSON::Validator.validate!(schema, course_template_data, validate_schema: true)
102
+ end
103
+
104
+ # This is the primary method utilized to update course templates. As only the
105
+ # Name and the Code can be changed in an update, they are pre-defined to
106
+ # conform to the required update data. The update is then performed via a
107
+ # PUT http method that is executed using a path referencing the course template.
108
+ # /d2l/api/lp/(version)/coursetemplates/(orgUnitId) [PUT]
109
+ def update_course_template(org_unit_id, new_data)
110
+ # Define a valid, empty payload and merge! with the new data.
111
+ payload = { 'Name' => '', # String
112
+ 'Code' => 'off_SEMESTERCODE_STARNUM', # String
113
+ }.merge!(new_data)
114
+ puts "Updating course template #{org_unit_id}"
115
+ check_course_template_updated_data_validity(payload)
116
+ # ap payload
117
+ # requires: CourseTemplateInfo JSON block
118
+ # Define a path referencing the courses path
119
+ path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/" + org_unit_id.to_s
120
+ _put(path, payload)
121
+ puts '[+] Course template update completed successfully'.green
64
122
  end
65
123
 
124
+ ################################################################################################
125
+ ################################################################################################
126
+
127
+ ###########################
128
+ # Additional Functions:####
129
+ ###########################
130
+
131
+
132
+
66
133
  # Instead of explicitly retrieving a single course template, this method uses
67
134
  # the routing table to retrieve all of the organizations descendants with the
68
135
  # outTypeId of 2. What this means is that it is literally retrieving any and all
@@ -102,64 +169,6 @@ def get_course_template_by_name(org_unit_name)
102
169
  # return: JSON array of matching course template data objects
103
170
  end
104
171
 
105
- # Moreso a helper method, but this really just returns the schema of the
106
- # course templates. This is predefined in the routing table, and retrieved via
107
- # a GET http method.
108
- #
109
- # returns: JSON of course templates schema
110
- # /d2l/api/lp/(version)/coursetemplates/schema [GET]
111
- def get_course_templates_schema
112
- path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/schema"
113
- _get(path)
114
- # This action returns a JSON array of SchemaElement blocks.
115
- end
116
-
117
- # Checks if the updated course template data conforms to the valence api for the
118
- # course template JSON object. If it does conform, then nothing happens and it
119
- # simply returns true. If it does not conform, then the JSON validator raises
120
- # an exception.
121
- def check_course_template_updated_data_validity(course_template_data)
122
- schema = {
123
- 'type' => 'object',
124
- 'required' => %w(Name Code),
125
- 'properties' => {
126
- 'Name' => { 'type' => 'string' },
127
- 'Code' => { 'type' => 'string' }
128
- }
129
- }
130
- JSON::Validator.validate!(schema, course_template_data, validate_schema: true)
131
- end
132
-
133
- # This is the primary method utilized to update course templates. As only the
134
- # Name and the Code can be changed in an update, they are pre-defined to
135
- # conform to the required update data. The update is then performed via a
136
- # PUT http method that is executed using a path referencing the course template.
137
- # /d2l/api/lp/(version)/coursetemplates/(orgUnitId) [PUT]
138
- def update_course_template(org_unit_id, new_data)
139
- # Define a valid, empty payload and merge! with the new data.
140
- payload = { 'Name' => '', # String
141
- 'Code' => 'off_SEMESTERCODE_STARNUM', # String
142
- }.merge!(new_data)
143
- puts "Updating course template #{org_unit_id}"
144
- check_course_template_updated_data_validity(payload)
145
- # ap payload
146
- # requires: CourseTemplateInfo JSON block
147
- # Define a path referencing the courses path
148
- path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/" + org_unit_id.to_s
149
- _put(path, payload)
150
- puts '[+] Course template update completed successfully'.green
151
- end
152
-
153
- # Simply, a course template can be deleted by refencing it using its Identifier
154
- # as an argument for this method. The argument is then used to refernce the obj
155
- # by a path and then the path is passed in for a delete http method.
156
- # /d2l/api/lp/(version)/coursetemplates/(orgUnitId) [DELETE]
157
- def delete_course_template(org_unit_id)
158
- path = "/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}"
159
- _delete(path)
160
- puts '[+] Course template data deleted successfully'.green
161
- end
162
-
163
172
  # As a more streamlined approach to deleting many course templates conforming to
164
173
  # a particular naming style, this function performs deletions based on a string.
165
174
  # Using the name argument, +get_course_template_by_name+ is called in order to
@@ -174,6 +183,6 @@ def delete_all_course_templates_with_name(name)
174
183
  end
175
184
  end
176
185
 
177
- # TO DO:
186
+ # TODO: Delete course templates by using regular expressions to filter them.
178
187
  def delete_course_templates_by_regex(regex)
179
188
  end
@@ -2,11 +2,9 @@ require_relative 'requests'
2
2
  require 'json-schema'
3
3
 
4
4
  ########################
5
- # DEMOGRPAHICS:#########
5
+ # ACTIONS:##############
6
6
  ########################
7
7
 
8
- ###### Actions
9
-
10
8
  # Delete one or more of a particular user's associated demographics entries.
11
9
  # if no entries specified, it DELETES ALL.
12
10
  # entry_ids are added as additional variables
@@ -17,45 +15,69 @@ def delete_user_demographics(user_id, entry_ids = '')
17
15
  _delete(path)
18
16
  end
19
17
 
18
+ # Retrieve all the demographics entries for all users enrolled in an OU
20
19
  # optional params: fieldIds, roleIds, and userIds are CSV formatted Strings
21
20
  # search and bookmark are Strings
22
- # retrieve all the demographics entries for all users enrolled in an OU
23
21
  def get_all_demographics_by_org_unit(org_unit_id, field_ids = '', role_ids = '',
24
22
  user_ids = '', search = '', bookmark = '')
25
23
  path = "/d2l/api/lp/#{$lp_ver}/demographics/orgUnits/#{org_unit_id}/users/"
26
- path += "?fieldIds=" + field_ids if field_ids != ''
27
- path += "?roleIds=" + role_ids if role_ids != ''
28
- path += "?userIds=" + user_ids if user_ids != ''
29
- path += "?search=" + search if search != ''
30
- path += "?bookmark=" + bookmark if bookmark != ''
24
+ path += "?"
25
+ path += "fieldIds=#{field_ids}&" if field_ids != ''
26
+ path += "roleIds=#{role_ids}&" if role_ids != ''
27
+ path += "userIds=#{user_ids}&" if user_ids != ''
28
+ path += "search=#{search}&" if search != ''
29
+ path += "bookmark=#{bookmark}&" if bookmark != ''
31
30
  _get(path)
32
31
  # returns paged result set of DemographicsUserEntryData JSON blocks
33
32
  end
34
33
 
35
- # retrieve all the demographics entries for a specific user within an OU
34
+ # Retrieve all the demographics entries for a specific user within an OU
36
35
  def get_all_demographics_by_org_unit_by_user(org_unit_id, user_id, field_ids = '')
37
36
  path = "/d2l/api/lp/#{$lp_ver}/demographics/orgUnits/#{org_unit_id}/users/(#{user_id})"
38
- path += "#{field_ids}" if field_ids != ''
37
+ path += "?fieldIds=#{field_ids}" if field_ids != ''
39
38
  _get(path)
40
39
  # returns DemographicsUserEntryData JSON block
41
40
  end
42
41
 
43
- # retrieve all demographics entries for all users with specified filters
42
+ # Retrieve all demographics entries for all users with specified filters
44
43
  def get_all_demographics(field_ids = '', role_ids = '', user_ids = '',
45
44
  search = '', bookmark = '')
46
45
  path = "/d2l/api/lp/#{$lp_ver}/demographics/users/"
47
- path += "#{field_ids}" if field_ids != ''
48
- path += "#{role_ids}" if role_ids != ''
49
- path += "#{user_ids}" if user_ids != ''
50
- path += "#{search}" if search != ''
51
- path += "#{bookmark}" if bookmark != ''
46
+ path += "?"
47
+ path += "fieldIds=#{field_ids}&" if field_ids != ''
48
+ path += "roleIds=#{role_ids}&" if role_ids != ''
49
+ path += "userIds=#{user_ids}&" if user_ids != ''
50
+ path += "search=#{search}&" if search != ''
51
+ path += "bookmark=#{bookmark}" if bookmark != ''
52
52
  _get(path)
53
53
  # returns paged result set of DemographicsUserEntryData JSON blocks
54
54
  end
55
55
 
56
+ # Retrieve all the demographics entries for a single user.
57
+ def get_user_demographics(user_id, field_ids = '', bookmark = '')
58
+ path = "/d2l/api/lp/#{$lp_ver}/demographics/users/#{user_id}"
59
+ path += "?"
60
+ path += "fieldIds=#{field_ids}&" if field_ids != ''
61
+ path += "bookmark=#{bookmark}" if bookmark != ''
62
+ end
63
+
64
+ # TODO: Update the demographics entries for a single user.
65
+ # Return: a DemographicsUserEntryData JSON block containing the user’s updated entries.
66
+ def update_user_demographics(user_id, demographics_entry_data)
67
+ # PUT /d2l/api/lp/(version)/demographics/users/(userId)
68
+ end
56
69
 
57
- ###### FIELDS
58
- # retrieve list of all demographics fields
70
+ ########################
71
+ ## FIELDS:##############
72
+ ########################
73
+
74
+ # REVIEW: Delete a single demographic field, provided it has no associated entries.
75
+ def delete_demographics_field(field_id)
76
+ path = "/d2l/api/lp/#{$lp_ver}/demographics/fields/#{field_id}"
77
+ _delete(path)
78
+ end
79
+
80
+ # Retrieve list of all demographics fields
59
81
  def get_all_demographic_fields(bookmark = '')
60
82
  path = "/d2l/api/lp/#{$lp_ver}/demographics/fields/"
61
83
  path += "#{bookmark}" if bookmark != ''
@@ -63,16 +85,34 @@ def get_all_demographic_fields(bookmark = '')
63
85
  # returns paged result set of DemographicsField JSON blocks
64
86
  end
65
87
 
66
- # retrieve a single demographic field
88
+ # Retrieve a single demographic field
67
89
  def get_demographic_field(field_id)
68
90
  path = "/d2l/api/lp/#{$lp_ver}/demographics/fields/#{field_id}"
69
91
  _get(path)
70
92
  # returns fetch form of DemographicsField JSON block
71
93
  end
72
94
 
73
- ###### DATA TYPES
95
+ # TODO: Create new demographic field
96
+ # Input: DemographicsField (Demographics.Demographicsfield)
97
+ # RETURNS: fetch form of a DemographicsField JSON block
98
+ def create_demographic_field(demographics_field)
99
+ # POST /d2l/api/lp/(version)/demographics/fields/
100
+ # RETURNS: fetch form of a DemographicsField JSON block
101
+ end
102
+
103
+ # TODO: Update demographic field
104
+ # Input: DemographicsField (Demographics.Demographicsfield)
105
+ # RETURNS: fetch form of a DemographicsField JSON block
106
+ def create_demographic_field(field_id, demographics_field)
107
+ # PUT /d2l/api/lp/(version)/demographics/fields/(fieldId)
108
+ # RETURNS: fetch form of a DemographicsField JSON block
109
+ end
110
+
111
+ ########################
112
+ ## DATA TYPES:##########
113
+ ########################
74
114
 
75
- # retrieve the list of all demographics data types
115
+ # Retrieve the list of all demographics data types
76
116
  # uses DataTypeId's as a paging control value
77
117
  def get_all_demographic_types(bookmark = '')
78
118
  path = "/d2l/api/lp/#{$lp_ver}/demographics/dataTypes/"