comprodls-sdk 2.11.7 → 2.12.1

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.
Files changed (48) hide show
  1. package/.eslintrc +28 -28
  2. package/.npmignore +5 -0
  3. package/README.md +371 -371
  4. package/dist/comprodls-sdk.js +11493 -11301
  5. package/dist/comprodls-sdk.min.js +18 -18
  6. package/grunt/publish.js +148 -148
  7. package/lib/comprodls.js +146 -146
  8. package/lib/config/index.js +337 -336
  9. package/lib/helpers/index.js +29 -29
  10. package/lib/helpers/lib/api/converter.js +119 -119
  11. package/lib/helpers/lib/api/index.js +120 -120
  12. package/lib/helpers/lib/api/validations.js +72 -72
  13. package/lib/helpers/lib/errors.js +129 -129
  14. package/lib/helpers/lib/utils.js +23 -23
  15. package/lib/helpers/lib/validator.js +100 -100
  16. package/lib/open_access/index.js +121 -121
  17. package/lib/services/activity/activity.js +209 -209
  18. package/lib/services/activity/attempt.js +431 -431
  19. package/lib/services/activity/index.js +28 -28
  20. package/lib/services/analytics/index.js +1555 -1555
  21. package/lib/services/attempts/index.js +342 -342
  22. package/lib/services/auth/classProduct.js +37 -37
  23. package/lib/services/auth/index.js +2541 -2535
  24. package/lib/services/collab/index.js +468 -468
  25. package/lib/services/drive/index.js +144 -144
  26. package/lib/services/integrations/index.js +279 -116
  27. package/lib/services/invitations/index.js +313 -313
  28. package/lib/services/lrs/index.js +459 -459
  29. package/lib/services/product/index.js +267 -267
  30. package/lib/services/pub/index.js +407 -407
  31. package/lib/services/push/index.js +187 -187
  32. package/lib/services/push/pubnubClientWrapper.js +557 -557
  33. package/lib/services/push/sessionStorage.js +64 -64
  34. package/lib/services/pushX/index.js +190 -190
  35. package/lib/services/pushX/pubnubClientWrapper.js +211 -211
  36. package/lib/services/sisevents/index.js +113 -113
  37. package/lib/services/spaces/index.js +976 -929
  38. package/lib/services/superuser/index.js +175 -175
  39. package/lib/services/workflows/index.js +464 -464
  40. package/lib/services/xapi/index.js +232 -232
  41. package/lib/token/index.js +114 -114
  42. package/lib/token/validations.js +88 -88
  43. package/package-lock.json +5095 -0
  44. package/package.json +1 -1
  45. package/test.js +50 -50
  46. package/.vscode/launch.json +0 -23
  47. package/npm-debug.log.189866131 +0 -0
  48. package/npm-debug.log.712840116 +0 -26
@@ -1,342 +1,342 @@
1
- /*************************************************************************
2
- *
3
- * COMPRO CONFIDENTIAL
4
- * __________________
5
- *
6
- * [2015] - [2020] Compro Technologies Private Limited
7
- * All Rights Reserved.
8
- *
9
- * NOTICE: All information contained herein is, and remains
10
- * the property of Compro Technologies Private Limited. The
11
- * intellectual and technical concepts contained herein are
12
- * proprietary to Compro Technologies Private Limited and may
13
- * be covered by U.S. and Foreign Patents, patents in process,
14
- * and are protected by trade secret or copyright law.
15
- *
16
- * Dissemination of this information or reproduction of this material
17
- * is strictly forbidden unless prior written permission is obtained
18
- * from Compro Technologies Pvt. Ltd..
19
- ***************************************************************************/
20
-
21
- /***********************************************************
22
- * comproDLS SDK attempts Adaptor
23
- * Functions for calling attempts.
24
- ************************************************************/
25
-
26
- /*********************************
27
- * Setting Up Module Entry Point
28
- **********************************/
29
-
30
- var q = require('q');
31
- var request = require('superagent');
32
-
33
- var helpers = require('../../helpers');
34
- var DLSError = helpers.errors.DLSError;
35
-
36
- module.exports = attempts;
37
-
38
- /*********************************
39
- * Public Function definitions
40
- **********************************/
41
- function attempts() {
42
- return {
43
- getUserAllAttemptsForActivity: getUserAllAttemptsForActivity.bind(this),
44
- createUserAttemptForActivity: createUserAttemptForActivity.bind(this),
45
- getUserAttemptStatsForActivity: getUserAttemptStatsForActivity.bind(this),
46
- getUserAttemptForActivity: getUserAttemptForActivity.bind(this),
47
- getUserFirstAttemptForActivity: getUserFirstAttemptForActivity.bind(this),
48
- getUserLastAttemptForActivity: getUserLastAttemptForActivity.bind(this)
49
- };
50
- }
51
-
52
- /*
53
- options = {
54
- userid: 'string', //mandatory
55
- activityid: 'string', //mandatory
56
- allorgs: boolean, //default = false
57
- classid: 'string',
58
- assignmentid: 'string',
59
- productcode: 'string',
60
- cursor: 'string',
61
- limit: 'integer',
62
- sortOrder: 'string' //'asc' or 'desc'
63
- }
64
- */
65
- function getUserAllAttemptsForActivity(options) {
66
- var self = this;
67
- var dfd = q.defer();
68
- var err;
69
-
70
- if(options && options.userid && options.activityid) {
71
- //Passed all validations, Construct API url
72
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
73
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
74
-
75
- // Contruct parameters
76
- var params = {};
77
- if(options.allorgs) { params.allorgs = options.allorgs; }
78
- if(options.classid) { params.classid = options.classid; }
79
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
80
- if(options.productcode) { params.productcode = options.productcode; }
81
- if(options.cursor) { params.cursor = options.cursor; }
82
- if(options.limit) { params.limit = options.limit; }
83
- if(options.sortOrder) { params.sortOrder = options.sortOrder; }
84
-
85
- //Setup request with URL and Params
86
- var requestAPI = request.get(url).query(params);
87
-
88
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
89
-
90
- requestAPI.end(function (err, response) {
91
- if (err) {
92
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
93
- dfd.reject(err);
94
- }
95
- else { dfd.resolve(response.body); }
96
- });
97
- }
98
- else {
99
- err = {};
100
- err.message = err.description = 'Mandatory params - userid or activityid ' +
101
- 'not found in request options.';
102
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
103
- dfd.reject(err);
104
- }
105
- return dfd.promise;
106
- }
107
-
108
- /*
109
- options = {
110
- userid: 'string', //mandatory
111
- activityid: 'string', //mandatory
112
- "body": {
113
- "classid": "string",
114
- "assignmentid": "string",
115
- "itemcode":"string",
116
- "productcode": "string",
117
- "max_allowed":"string"
118
- }
119
- }
120
- */
121
- function createUserAttemptForActivity(options) {
122
- var self = this;
123
- var dfd = q.defer();
124
- var err;
125
-
126
- if(options && options.userid && options.activityid && options.body) {
127
- //Passed all validations, Construct API url
128
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
129
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
130
-
131
- //Setup request with URL and Body
132
- var requestAPI = request.post(url).send(options.body);
133
-
134
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
135
-
136
- requestAPI.end(function (err, response) {
137
- if (err) {
138
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
139
- dfd.reject(err);
140
- }
141
- else { dfd.resolve(response.body); }
142
- });
143
- }
144
- else {
145
- err = {};
146
- err.message = err.description = 'Mandatory params - userid or activityid or body ' +
147
- 'not found in request options.';
148
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
149
- dfd.reject(err);
150
- }
151
- return dfd.promise;
152
- }
153
-
154
- /*
155
- options = {
156
- userid: 'string', //mandatory
157
- activityid: 'string', //mandatory
158
- classid: 'string', //mandatory with assignmentid
159
- assignmentid: 'string',
160
- allorgs: boolean // default = false
161
- }
162
- */
163
- function getUserAttemptStatsForActivity(options) {
164
- var self = this;
165
- var dfd = q.defer();
166
- var err;
167
-
168
- if(options && options.userid && options.activityid) {
169
- //Passed all validations, Construct API url
170
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;
171
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
172
-
173
- // Contruct parameters
174
- var params = {};
175
- if(options.allorgs) { params.allorgs = options.allorgs; }
176
- if(options.classid) { params.classid = options.classid; }
177
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
178
-
179
- //Setup request with URL and Params
180
- var requestAPI = request.get(url).query(params);
181
-
182
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
183
-
184
- requestAPI.end(function (err, response) {
185
- if (err) {
186
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
187
- dfd.reject(err);
188
- }
189
- else { dfd.resolve(response.body); }
190
- });
191
- }
192
- else {
193
- err = {};
194
- err.message = err.description = 'Mandatory params - userid or activityid ' +
195
- 'not found in request options.';
196
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
197
- dfd.reject(err);
198
- }
199
- return dfd.promise;
200
- }
201
-
202
- /*
203
- options = {
204
- userid: 'string', //mandatory
205
- activityid: 'string', //mandatory
206
- attemptid: 'string', //mandatory
207
- details: boolean
208
- }
209
- */
210
- function getUserAttemptForActivity(options) {
211
- var self = this;
212
- var dfd = q.defer();
213
- var err;
214
-
215
- if(options && options.userid && options.activityid && options.attemptid) {
216
- //Passed all validations, Construct API url
217
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;
218
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid,
219
- attemptId: options.attemptid });
220
-
221
- // Contruct parameters
222
- var params = {};
223
- if(options.details) { params.details = options.details; }
224
-
225
- //Setup request with URL and Params
226
- var requestAPI = request.get(url).query(params);
227
-
228
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
229
-
230
- requestAPI.end(function (err, response) {
231
- if (err) {
232
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
233
- dfd.reject(err);
234
- }
235
- else { dfd.resolve(response.body); }
236
- });
237
- }
238
- else {
239
- err = {};
240
- err.message = err.description = 'Mandatory params - userid or activityid or attemptid ' +
241
- 'not found in request options.';
242
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
243
- dfd.reject(err);
244
- }
245
- return dfd.promise;
246
- }
247
-
248
- /*
249
- options = {
250
- userid: 'string', //mandatory
251
- activityid: 'string', //mandatory
252
- classid: 'string' //mandatory with assignmentid
253
- assignmentid: 'string'
254
- details: boolean
255
- }
256
- */
257
- function getUserFirstAttemptForActivity(options) {
258
- var self = this;
259
- var dfd = q.defer();
260
- var err;
261
-
262
- if(options && options.userid && options.activityid) {
263
- //Passed all validations, Construct API url
264
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;
265
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
266
-
267
- // Contruct parameters
268
- var params = {};
269
- if(options.details) { params.details = options.details; }
270
- if(options.classid) { params.classid = options.classid; }
271
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
272
-
273
- //Setup request with URL and Params
274
- var requestAPI = request.get(url).query(params);
275
-
276
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
277
-
278
- requestAPI.end(function (err, response) {
279
- if (err) {
280
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
281
- dfd.reject(err);
282
- }
283
- else { dfd.resolve(response.body); }
284
- });
285
- }
286
- else {
287
- err = {};
288
- err.message = err.description = 'Mandatory params - userid or activityid ' +
289
- 'not found in request options.';
290
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
291
- dfd.reject(err);
292
- }
293
- return dfd.promise;
294
- }
295
-
296
- /*
297
- options = {
298
- userid: 'string', //mandatory
299
- activityid: 'string', //mandatory
300
- classid: 'string'//mandatory with assignmentid
301
- assignmentid: 'string'
302
- details: boolean
303
- }
304
- */
305
- function getUserLastAttemptForActivity(options) {
306
- var self = this;
307
- var dfd = q.defer();
308
- var err;
309
-
310
- if(options && options.userid && options.activityid) {
311
- //Passed all validations, Construct API url
312
- var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;
313
- url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
314
-
315
- // Contruct parameters
316
- var params = {};
317
- if(options.details) { params.details = options.details; }
318
- if(options.classid) { params.classid = options.classid; }
319
- if(options.assignmentid) { params.assignmentid = options.assignmentid; }
320
-
321
- //Setup request with URL and Params
322
- var requestAPI = request.get(url).query(params);
323
- console.log(url, params, requestAPI);
324
- if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
325
-
326
- requestAPI.end(function (err, response) {
327
- if (err) {
328
- err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
329
- dfd.reject(err);
330
- }
331
- else { dfd.resolve(response.body); }
332
- });
333
- }
334
- else {
335
- err = {};
336
- err.message = err.description = 'Mandatory params - userid or activityid ' +
337
- 'not found in request options.';
338
- err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
339
- dfd.reject(err);
340
- }
341
- return dfd.promise;
342
- }
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ /***********************************************************
22
+ * comproDLS SDK attempts Adaptor
23
+ * Functions for calling attempts.
24
+ ************************************************************/
25
+
26
+ /*********************************
27
+ * Setting Up Module Entry Point
28
+ **********************************/
29
+
30
+ var q = require('q');
31
+ var request = require('superagent');
32
+
33
+ var helpers = require('../../helpers');
34
+ var DLSError = helpers.errors.DLSError;
35
+
36
+ module.exports = attempts;
37
+
38
+ /*********************************
39
+ * Public Function definitions
40
+ **********************************/
41
+ function attempts() {
42
+ return {
43
+ getUserAllAttemptsForActivity: getUserAllAttemptsForActivity.bind(this),
44
+ createUserAttemptForActivity: createUserAttemptForActivity.bind(this),
45
+ getUserAttemptStatsForActivity: getUserAttemptStatsForActivity.bind(this),
46
+ getUserAttemptForActivity: getUserAttemptForActivity.bind(this),
47
+ getUserFirstAttemptForActivity: getUserFirstAttemptForActivity.bind(this),
48
+ getUserLastAttemptForActivity: getUserLastAttemptForActivity.bind(this)
49
+ };
50
+ }
51
+
52
+ /*
53
+ options = {
54
+ userid: 'string', //mandatory
55
+ activityid: 'string', //mandatory
56
+ allorgs: boolean, //default = false
57
+ classid: 'string',
58
+ assignmentid: 'string',
59
+ productcode: 'string',
60
+ cursor: 'string',
61
+ limit: 'integer',
62
+ sortOrder: 'string' //'asc' or 'desc'
63
+ }
64
+ */
65
+ function getUserAllAttemptsForActivity(options) {
66
+ var self = this;
67
+ var dfd = q.defer();
68
+ var err;
69
+
70
+ if(options && options.userid && options.activityid) {
71
+ //Passed all validations, Construct API url
72
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
73
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
74
+
75
+ // Contruct parameters
76
+ var params = {};
77
+ if(options.allorgs) { params.allorgs = options.allorgs; }
78
+ if(options.classid) { params.classid = options.classid; }
79
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
80
+ if(options.productcode) { params.productcode = options.productcode; }
81
+ if(options.cursor) { params.cursor = options.cursor; }
82
+ if(options.limit) { params.limit = options.limit; }
83
+ if(options.sortOrder) { params.sortOrder = options.sortOrder; }
84
+
85
+ //Setup request with URL and Params
86
+ var requestAPI = request.get(url).query(params);
87
+
88
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
89
+
90
+ requestAPI.end(function (err, response) {
91
+ if (err) {
92
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
93
+ dfd.reject(err);
94
+ }
95
+ else { dfd.resolve(response.body); }
96
+ });
97
+ }
98
+ else {
99
+ err = {};
100
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
101
+ 'not found in request options.';
102
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
103
+ dfd.reject(err);
104
+ }
105
+ return dfd.promise;
106
+ }
107
+
108
+ /*
109
+ options = {
110
+ userid: 'string', //mandatory
111
+ activityid: 'string', //mandatory
112
+ "body": {
113
+ "classid": "string",
114
+ "assignmentid": "string",
115
+ "itemcode":"string",
116
+ "productcode": "string",
117
+ "max_allowed":"string"
118
+ }
119
+ }
120
+ */
121
+ function createUserAttemptForActivity(options) {
122
+ var self = this;
123
+ var dfd = q.defer();
124
+ var err;
125
+
126
+ if(options && options.userid && options.activityid && options.body) {
127
+ //Passed all validations, Construct API url
128
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.userAttempts;
129
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
130
+
131
+ //Setup request with URL and Body
132
+ var requestAPI = request.post(url).send(options.body);
133
+
134
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
135
+
136
+ requestAPI.end(function (err, response) {
137
+ if (err) {
138
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
139
+ dfd.reject(err);
140
+ }
141
+ else { dfd.resolve(response.body); }
142
+ });
143
+ }
144
+ else {
145
+ err = {};
146
+ err.message = err.description = 'Mandatory params - userid or activityid or body ' +
147
+ 'not found in request options.';
148
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
149
+ dfd.reject(err);
150
+ }
151
+ return dfd.promise;
152
+ }
153
+
154
+ /*
155
+ options = {
156
+ userid: 'string', //mandatory
157
+ activityid: 'string', //mandatory
158
+ classid: 'string', //mandatory with assignmentid
159
+ assignmentid: 'string',
160
+ allorgs: boolean // default = false
161
+ }
162
+ */
163
+ function getUserAttemptStatsForActivity(options) {
164
+ var self = this;
165
+ var dfd = q.defer();
166
+ var err;
167
+
168
+ if(options && options.userid && options.activityid) {
169
+ //Passed all validations, Construct API url
170
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;
171
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
172
+
173
+ // Contruct parameters
174
+ var params = {};
175
+ if(options.allorgs) { params.allorgs = options.allorgs; }
176
+ if(options.classid) { params.classid = options.classid; }
177
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
178
+
179
+ //Setup request with URL and Params
180
+ var requestAPI = request.get(url).query(params);
181
+
182
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
183
+
184
+ requestAPI.end(function (err, response) {
185
+ if (err) {
186
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
187
+ dfd.reject(err);
188
+ }
189
+ else { dfd.resolve(response.body); }
190
+ });
191
+ }
192
+ else {
193
+ err = {};
194
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
195
+ 'not found in request options.';
196
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
197
+ dfd.reject(err);
198
+ }
199
+ return dfd.promise;
200
+ }
201
+
202
+ /*
203
+ options = {
204
+ userid: 'string', //mandatory
205
+ activityid: 'string', //mandatory
206
+ attemptid: 'string', //mandatory
207
+ details: boolean
208
+ }
209
+ */
210
+ function getUserAttemptForActivity(options) {
211
+ var self = this;
212
+ var dfd = q.defer();
213
+ var err;
214
+
215
+ if(options && options.userid && options.activityid && options.attemptid) {
216
+ //Passed all validations, Construct API url
217
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;
218
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid,
219
+ attemptId: options.attemptid });
220
+
221
+ // Contruct parameters
222
+ var params = {};
223
+ if(options.details) { params.details = options.details; }
224
+
225
+ //Setup request with URL and Params
226
+ var requestAPI = request.get(url).query(params);
227
+
228
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
229
+
230
+ requestAPI.end(function (err, response) {
231
+ if (err) {
232
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
233
+ dfd.reject(err);
234
+ }
235
+ else { dfd.resolve(response.body); }
236
+ });
237
+ }
238
+ else {
239
+ err = {};
240
+ err.message = err.description = 'Mandatory params - userid or activityid or attemptid ' +
241
+ 'not found in request options.';
242
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
243
+ dfd.reject(err);
244
+ }
245
+ return dfd.promise;
246
+ }
247
+
248
+ /*
249
+ options = {
250
+ userid: 'string', //mandatory
251
+ activityid: 'string', //mandatory
252
+ classid: 'string' //mandatory with assignmentid
253
+ assignmentid: 'string'
254
+ details: boolean
255
+ }
256
+ */
257
+ function getUserFirstAttemptForActivity(options) {
258
+ var self = this;
259
+ var dfd = q.defer();
260
+ var err;
261
+
262
+ if(options && options.userid && options.activityid) {
263
+ //Passed all validations, Construct API url
264
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;
265
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
266
+
267
+ // Contruct parameters
268
+ var params = {};
269
+ if(options.details) { params.details = options.details; }
270
+ if(options.classid) { params.classid = options.classid; }
271
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
272
+
273
+ //Setup request with URL and Params
274
+ var requestAPI = request.get(url).query(params);
275
+
276
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
277
+
278
+ requestAPI.end(function (err, response) {
279
+ if (err) {
280
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
281
+ dfd.reject(err);
282
+ }
283
+ else { dfd.resolve(response.body); }
284
+ });
285
+ }
286
+ else {
287
+ err = {};
288
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
289
+ 'not found in request options.';
290
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
291
+ dfd.reject(err);
292
+ }
293
+ return dfd.promise;
294
+ }
295
+
296
+ /*
297
+ options = {
298
+ userid: 'string', //mandatory
299
+ activityid: 'string', //mandatory
300
+ classid: 'string'//mandatory with assignmentid
301
+ assignmentid: 'string'
302
+ details: boolean
303
+ }
304
+ */
305
+ function getUserLastAttemptForActivity(options) {
306
+ var self = this;
307
+ var dfd = q.defer();
308
+ var err;
309
+
310
+ if(options && options.userid && options.activityid) {
311
+ //Passed all validations, Construct API url
312
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;
313
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
314
+
315
+ // Contruct parameters
316
+ var params = {};
317
+ if(options.details) { params.details = options.details; }
318
+ if(options.classid) { params.classid = options.classid; }
319
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
320
+
321
+ //Setup request with URL and Params
322
+ var requestAPI = request.get(url).query(params);
323
+ console.log(url, params, requestAPI);
324
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
325
+
326
+ requestAPI.end(function (err, response) {
327
+ if (err) {
328
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
329
+ dfd.reject(err);
330
+ }
331
+ else { dfd.resolve(response.body); }
332
+ });
333
+ }
334
+ else {
335
+ err = {};
336
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
337
+ 'not found in request options.';
338
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
339
+ dfd.reject(err);
340
+ }
341
+ return dfd.promise;
342
+ }