comprodls-sdk 2.90.3-development → 2.91.0-thor
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.
- package/README.md +1 -137
- package/dist/comprodls-sdk.js +2917 -6291
- package/dist/comprodls-sdk.min.js +1 -1
- package/lib/comprodls.js +39 -57
- package/lib/config/index.js +172 -198
- package/lib/helpers/index.js +3 -2
- package/lib/helpers/lib/api/converter.js +1 -2
- package/lib/helpers/lib/api/index.js +19 -94
- package/lib/helpers/lib/errors.js +75 -80
- package/lib/helpers/lib/requestLayer.js +154 -0
- package/lib/helpers/lib/validator.js +65 -52
- package/lib/open_access/index.js +48 -53
- package/lib/services/analytics/index.js +286 -1014
- package/lib/services/attempts/index.js +38 -88
- package/lib/services/auth/index.js +324 -806
- package/lib/services/authextn/index.js +85 -247
- package/lib/services/datasyncmanager/index.js +10 -45
- package/lib/services/drive/index.js +20 -83
- package/lib/services/integrations/index.js +51 -126
- package/lib/services/invitations/index.js +20 -61
- package/lib/services/product/index.js +82 -85
- package/lib/services/pub/index.js +167 -235
- package/lib/services/pushX/index.js +195 -142
- package/lib/services/pushX/pubnubClientWrapper.js +399 -172
- package/lib/services/rules/index.js +14 -67
- package/lib/services/spaces/index.js +106 -289
- package/lib/services/spacesextn/index.js +44 -20
- package/lib/services/superuser/index.js +21 -36
- package/lib/services/taxonomy/index.js +27 -57
- package/lib/services/workflows/index.js +38 -97
- package/lib/services/xapi/index.js +7 -168
- package/lib/token/index.js +73 -67
- package/lib/token/validations.js +45 -48
- package/package.json +2 -3
- package/lib/helpers/lib/api/validations.js +0 -73
- package/lib/helpers/lib/utils.js +0 -24
- package/lib/services/activity/activity.js +0 -209
- package/lib/services/activity/attempt.js +0 -431
- package/lib/services/activity/index.js +0 -28
- package/lib/services/auth/classProduct.js +0 -37
- package/lib/services/collab/index.js +0 -468
- package/test.js +0 -38
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
* Functions for calling Analytics API.
|
|
24
24
|
************************************************************/
|
|
25
25
|
|
|
26
|
-
/*********************************
|
|
27
|
-
* Setting Up Module Entry Point
|
|
28
|
-
**********************************/
|
|
29
|
-
|
|
30
26
|
var q = require('q');
|
|
31
27
|
var request = require('superagent');
|
|
32
28
|
var Agent = require('agentkeepalive');
|
|
@@ -41,17 +37,11 @@ var keepaliveAgent = new Agent({
|
|
|
41
37
|
freeSocketTimeout: 30000
|
|
42
38
|
});
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
* Public Function definitions
|
|
46
|
-
**********************************/
|
|
40
|
+
//Analytics Adaptor Constructor
|
|
47
41
|
function analytics() {
|
|
48
42
|
return {
|
|
49
|
-
archiveUserAnalytics: archiveUserAnalytics.bind(this),
|
|
50
|
-
getArchivedUserAnalytics: getArchivedUserAnalytics.bind(this),
|
|
51
|
-
|
|
52
43
|
getOrgAnalyticsStat: getOrgAnalyticsStat.bind(this),
|
|
53
44
|
|
|
54
|
-
getClassAnalytics: getClassAnalytics.bind(this),
|
|
55
45
|
getClassProductRecentPendingSubmissions: getClassProductRecentPendingSubmissions.bind(this),
|
|
56
46
|
getClassRecordUserAggregations: getClassRecordUserAggregations.bind(this),
|
|
57
47
|
getClassRecord: getClassRecord.bind(this),
|
|
@@ -63,22 +53,10 @@ function analytics() {
|
|
|
63
53
|
getGroupsWithEvaluatedOnce: getGroupsWithEvaluatedOnce.bind(this),
|
|
64
54
|
|
|
65
55
|
getUserProductAnalytics: getUserProductAnalytics.bind(this),
|
|
66
|
-
getUserProductAnalyticById: getUserProductAnalyticById.bind(this),
|
|
67
56
|
getExternalDataForUserAnalyticItem: getExternalDataForUserAnalyticItem.bind(this),
|
|
68
|
-
searchUserProductAnalytics: searchUserProductAnalytics.bind(this),
|
|
69
57
|
getUserClassRecentSubmissions: getUserClassRecentSubmissions.bind(this),
|
|
70
58
|
getStudentsWithEvaluatedOnce: getStudentsWithEvaluatedOnce.bind(this),
|
|
71
59
|
|
|
72
|
-
// user-state api
|
|
73
|
-
getAppState: getAppState.bind(this),
|
|
74
|
-
updateAppState: updateAppState.bind(this),
|
|
75
|
-
deleteAppState: deleteAppState.bind(this),
|
|
76
|
-
|
|
77
|
-
getUserProductAllState: getUserProductAllState.bind(this),
|
|
78
|
-
updateUserProductMultiState: updateUserProductMultiState.bind(this),
|
|
79
|
-
|
|
80
|
-
getQuestionProgressByLearningObjective: getQuestionProgressByLearningObjective.bind(this),
|
|
81
|
-
|
|
82
60
|
//AssignedPaths Related APIs
|
|
83
61
|
getAllAssignedPathsOfClass: getAllAssignedPathsOfClass.bind(this),
|
|
84
62
|
getMyAssignedPathsOfClass: getMyAssignedPathsOfClass.bind(this),
|
|
@@ -99,119 +77,109 @@ function analytics() {
|
|
|
99
77
|
};
|
|
100
78
|
}
|
|
101
79
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
80
|
+
/*********************************
|
|
81
|
+
* Public Function definitions
|
|
82
|
+
**********************************/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Wiki Link for SDK params
|
|
86
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getorganalyticsstatparams
|
|
87
|
+
*/
|
|
110
88
|
function getOrgAnalyticsStat(options) {
|
|
111
|
-
|
|
89
|
+
var self = this;
|
|
112
90
|
|
|
113
91
|
//Initializing promise
|
|
114
92
|
var dfd = q.defer();
|
|
115
93
|
//Validations
|
|
116
94
|
var err = {};
|
|
117
|
-
|
|
95
|
+
if(options && options.type) {
|
|
118
96
|
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
119
|
-
|
|
97
|
+
if(err) { dfd.reject(err); }
|
|
120
98
|
else {
|
|
121
99
|
err = {};
|
|
122
100
|
var allowedAnalyticsDataType = ['users', 'classes'];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
101
|
+
if(allowedAnalyticsDataType.indexOf(options.type) > -1) {
|
|
102
|
+
//Passed all validations, Construct API url
|
|
103
|
+
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
126
104
|
self.config.ANALYTICS_API_URLS.getOrgAnalyticsStat;
|
|
127
|
-
|
|
105
|
+
url = helpers.api.constructAPIUrl(url, {
|
|
128
106
|
orgId: self.orgId, type: options.type
|
|
129
107
|
});
|
|
130
108
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
109
|
+
var params = {};
|
|
110
|
+
if(options) {
|
|
111
|
+
if(options.range) { params.range = options.range; }
|
|
112
|
+
if(options.start) { params.start = options.start; }
|
|
113
|
+
if(options.end) { params.end = options.end; }
|
|
114
|
+
if(options.role) { params.role = options.role; }
|
|
115
|
+
if(options.shadow) { params.shadow = options.shadow; }
|
|
116
|
+
}
|
|
139
117
|
|
|
140
|
-
|
|
141
|
-
|
|
118
|
+
//Setup request with URL and Params
|
|
119
|
+
var requestAPI = request.get(url).query(params);
|
|
142
120
|
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
//Setup token in Authorization header
|
|
122
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
145
123
|
|
|
146
124
|
// setting up traceid
|
|
147
125
|
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
148
126
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
127
|
+
//Call Product Timespent Api
|
|
128
|
+
requestAPI.end(function(err, response) {
|
|
129
|
+
if(err) {
|
|
130
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
131
|
+
dfd.reject(err);
|
|
132
|
+
}
|
|
155
133
|
else { dfd.resolve(response.body); }
|
|
156
134
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
135
|
+
} else {
|
|
136
|
+
err.message = err.description = 'Type: ' + options.type + ' is not supported';
|
|
137
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
138
|
+
dfd.reject(err);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
err.message = err.description = 'type not found in request options';
|
|
143
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
144
|
+
dfd.reject(err);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return dfd.promise;
|
|
170
148
|
}
|
|
171
149
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// classid: 'string', // OPTIONAL
|
|
177
|
-
// itemcode: 'string', // OPTIONAL (only for 'type=items') item-code of the required item
|
|
178
|
-
// metrics: boolean // OPTIONAL (only for 'type=items') true/false - aggregations on the
|
|
179
|
-
// item(s), default - true
|
|
180
|
-
// history: boolean // If history is true - submission is array else submission is object
|
|
181
|
-
// expiredView: boolean // If expiredView is true - items from class record matrix will be returned.
|
|
182
|
-
// externalData: boolean // OPTIONAL(default is 'false' - only works with itemcode) whether to return external
|
|
183
|
-
//secondary evaluation data or not.
|
|
184
|
-
// group: boolean // If group is true - then it will return group data from P1.
|
|
185
|
-
//}
|
|
150
|
+
/**
|
|
151
|
+
* Wiki Link for SDK params
|
|
152
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserproductanalyticsparams
|
|
153
|
+
*/
|
|
186
154
|
function getUserProductAnalytics(options) {
|
|
187
|
-
|
|
155
|
+
var self = this;
|
|
188
156
|
|
|
189
157
|
//Initializing promise
|
|
190
158
|
var dfd = q.defer();
|
|
191
159
|
//Validations
|
|
192
160
|
var err = {};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
161
|
+
if(options && options.type && options.userid && options.productcode) {
|
|
162
|
+
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
163
|
+
if(err) { dfd.reject(err); }
|
|
196
164
|
else {
|
|
197
165
|
var supportedType = ['items', 'summary'];
|
|
198
166
|
//Passed all validations, Construct API url
|
|
199
|
-
|
|
167
|
+
var url = self.config.DEFAULT_HOSTS['ANALYTICS'];
|
|
200
168
|
|
|
201
169
|
if(supportedType.indexOf(options.type) > -1) {
|
|
202
170
|
switch(options.type) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
171
|
+
case 'items':
|
|
172
|
+
url += self.config.ANALYTICS_API_URLS.getAnalyticProductItems;
|
|
173
|
+
break;
|
|
174
|
+
case 'summary':
|
|
175
|
+
url += self.config.ANALYTICS_API_URLS.getAnalyticProductSummary;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
179
|
+
|
|
180
|
+
var params = { userid: options.userid, productcode: options.productcode };
|
|
181
|
+
|
|
182
|
+
if(options.classid) { params.classid = options.classid; }
|
|
215
183
|
if(options.itemcode) { params.itemcode = options.itemcode; }
|
|
216
184
|
if(options.metrics) { params.metrics = options.metrics; }
|
|
217
185
|
if(options.history) { params.history = options.history; }
|
|
@@ -219,98 +187,43 @@ function getUserProductAnalytics(options) {
|
|
|
219
187
|
if(options.externalData) { params.externalData = options.externalData; }
|
|
220
188
|
if(options.expiredView && options.type === 'items') { params.expiredView = options.expiredView; }
|
|
221
189
|
|
|
222
|
-
|
|
223
|
-
|
|
190
|
+
//Setup request with URL and Params
|
|
191
|
+
var requestAPI = request.get(url).query(params);
|
|
224
192
|
|
|
225
|
-
|
|
226
|
-
|
|
193
|
+
//Setup token in Authorization header
|
|
194
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
227
195
|
|
|
228
196
|
// setting up traceid
|
|
229
197
|
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
230
198
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
199
|
+
//Call Product Timespent Api
|
|
200
|
+
requestAPI.end(function(err, response) {
|
|
201
|
+
if(err) {
|
|
202
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
203
|
+
dfd.reject(err);
|
|
204
|
+
}
|
|
237
205
|
else { dfd.resolve(response.body); }
|
|
238
206
|
});
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
207
|
+
} else {
|
|
208
|
+
err.message = err.description = options.type + " is not a valid value of option 'type'";
|
|
209
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
210
|
+
dfd.reject(err);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
err.message = err.description = "Required parameter 'type' or 'userid' or " +
|
|
247
215
|
"'productcode' not found in request options";
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return dfd.promise;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
//options = {
|
|
256
|
-
// userprogressid: 'string' // userprogressid
|
|
257
|
-
//}
|
|
258
|
-
function getUserProductAnalyticById(options) {
|
|
259
|
-
var self = this;
|
|
260
|
-
|
|
261
|
-
//Initializing promise
|
|
262
|
-
var dfd = q.defer();
|
|
263
|
-
//Validations
|
|
264
|
-
var err = {};
|
|
265
|
-
if(options && options.userprogressid) {
|
|
266
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
267
|
-
if(err) { dfd.reject(err); }
|
|
268
|
-
else {
|
|
269
|
-
//Passed all validations, Construct API url
|
|
270
|
-
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
271
|
-
self.config.ANALYTICS_API_URLS.getAnalyticProductById;
|
|
272
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
273
|
-
orgId: self.orgId, userProgressId: options.userprogressid
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
//Setup request with URL and Params
|
|
277
|
-
var requestAPI = request.get(url);
|
|
278
|
-
|
|
279
|
-
//Setup token in Authorization header
|
|
280
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
281
|
-
|
|
282
|
-
// setting up traceid
|
|
283
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
216
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
217
|
+
dfd.reject(err);
|
|
218
|
+
}
|
|
284
219
|
|
|
285
|
-
|
|
286
|
-
requestAPI.end(function(err, response) {
|
|
287
|
-
if(err) {
|
|
288
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
289
|
-
dfd.reject(err);
|
|
290
|
-
}
|
|
291
|
-
else { dfd.resolve(response.body); }
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
} else {
|
|
295
|
-
err.message = err.description = "Required parameter 'userprogressid' not " +
|
|
296
|
-
"found in request options";
|
|
297
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
298
|
-
dfd.reject(err);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return dfd.promise;
|
|
220
|
+
return dfd.promise;
|
|
302
221
|
}
|
|
303
222
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
// (any one field from 'submission_order' OR 'ext_link_id' is mandatory)
|
|
309
|
-
// submission_order: number, // optional
|
|
310
|
-
// ext_link_id: <ext_link_id>, // optional
|
|
311
|
-
// part: number, // mandatory
|
|
312
|
-
// classid: <classid>, // optional
|
|
313
|
-
//}
|
|
223
|
+
/**
|
|
224
|
+
* Wiki Link for SDK params
|
|
225
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getexternaldataforuseranalyticitemparams
|
|
226
|
+
*/
|
|
314
227
|
function getExternalDataForUserAnalyticItem(options) {
|
|
315
228
|
var self = this;
|
|
316
229
|
var dfd = q.defer();
|
|
@@ -318,11 +231,11 @@ function getExternalDataForUserAnalyticItem(options) {
|
|
|
318
231
|
var err = {};
|
|
319
232
|
if(options && options.ext_user_id && options.productcode && options.itemcode &&
|
|
320
233
|
(options.submission_order || options.ext_link_id) && options.part) {
|
|
321
|
-
|
|
322
|
-
|
|
234
|
+
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
235
|
+
if(err) { dfd.reject(err); }
|
|
323
236
|
else {
|
|
324
237
|
// Passed all validations, Construct API url
|
|
325
|
-
|
|
238
|
+
var url = self.config.DEFAULT_HOSTS.ANALYTICS +
|
|
326
239
|
self.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;
|
|
327
240
|
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
328
241
|
|
|
@@ -355,127 +268,18 @@ function getExternalDataForUserAnalyticItem(options) {
|
|
|
355
268
|
else { dfd.resolve(response.body); }
|
|
356
269
|
});
|
|
357
270
|
}
|
|
358
|
-
|
|
359
|
-
|
|
271
|
+
} else {
|
|
272
|
+
err.message = err.description = "Required parameters 'ext_user_id' or 'productcode' or 'itemcode'" +
|
|
360
273
|
" or (either 'submission_order' OR 'ext_link_id') or 'part'are not found in request options";
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return dfd.promise;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
//options = {
|
|
368
|
-
// userid: <userid>
|
|
369
|
-
// productid: <productid>,
|
|
370
|
-
// classid: <classid>, // OPTIONAL
|
|
371
|
-
//}
|
|
372
|
-
function archiveUserAnalytics(options) {
|
|
373
|
-
var self = this, err = {};
|
|
374
|
-
//Initializing promise
|
|
375
|
-
var dfd = q.defer();
|
|
376
|
-
if(options && options.userid && options.productid) {
|
|
377
|
-
//Validations
|
|
378
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
379
|
-
if(err) { dfd.reject(err); }
|
|
380
|
-
else {
|
|
381
|
-
var params = {};
|
|
382
|
-
//Passed all validations, Construct API url
|
|
383
|
-
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
384
|
-
self.config.ANALYTICS_API_URLS.archiveUserAnalytics;
|
|
385
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
386
|
-
|
|
387
|
-
if(options.userid) { params.userid = options.userid; }
|
|
388
|
-
if(options.productid) { params.productid = options.productid; }
|
|
389
|
-
if(options.classid) { params.classid = options.classid; }
|
|
390
|
-
|
|
391
|
-
//Setup request with URL and Params
|
|
392
|
-
var requestAPI = request.post(url).query(params)
|
|
393
|
-
.set('Content-Type', 'application/json');
|
|
394
|
-
|
|
395
|
-
//Setup token in Authorization header
|
|
396
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
397
|
-
|
|
398
|
-
// setting up traceid
|
|
399
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
400
|
-
|
|
401
|
-
requestAPI.end(function(err, response) {
|
|
402
|
-
if(err) {
|
|
403
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
404
|
-
dfd.reject(err);
|
|
405
|
-
}
|
|
406
|
-
else { dfd.resolve(response.body); }
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
} else {
|
|
410
|
-
err.message = err.description = 'Mandatory parameter [userid, productid] ' +
|
|
411
|
-
'not found in request options';
|
|
412
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
413
|
-
dfd.reject(err);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return dfd.promise;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
//options = {
|
|
420
|
-
// userid: <userid>, // OPTIONAL
|
|
421
|
-
// productid: <productid>, // OPTIONAL
|
|
422
|
-
// classid: <classid>, // OPTIONAL
|
|
423
|
-
// lookup: 'string', // Search query (',' separated key value pairs), e.g. key1:val1,key2:val2,key3:val3
|
|
424
|
-
// cursor: '', // cursor to next set of documents
|
|
425
|
-
// limit: '' // limit of documents per function call
|
|
426
|
-
//}
|
|
427
|
-
function searchUserProductAnalytics(options) {
|
|
428
|
-
var self = this, err = {};
|
|
429
|
-
//Initializing promise
|
|
430
|
-
var dfd = q.defer();
|
|
431
|
-
|
|
432
|
-
//Validations
|
|
433
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
434
|
-
if(err) { dfd.reject(err); }
|
|
435
|
-
else {
|
|
436
|
-
var params = {};
|
|
437
|
-
//Passed all validations, Construct API url
|
|
438
|
-
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
439
|
-
self.config.ANALYTICS_API_URLS.searchUserProductAnalytics;
|
|
440
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
441
|
-
|
|
442
|
-
if(options.userid) { params.userid = options.userid; }
|
|
443
|
-
if(options.productid) { params.productid = options.productid; }
|
|
444
|
-
if(options.classid) { params.classid = options.classid; }
|
|
445
|
-
if(options.lookup) { params.lookup = options.lookup; }
|
|
446
|
-
if(options.cursor) { params.cursor = options.cursor; }
|
|
447
|
-
if(options.limit) { params.limit = options.limit; }
|
|
448
|
-
|
|
449
|
-
//Setup request with URL and Params
|
|
450
|
-
var requestAPI = request.get(url).query(params);
|
|
451
|
-
|
|
452
|
-
//Setup token in Authorization header
|
|
453
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
454
|
-
|
|
455
|
-
// setting up traceid
|
|
456
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
457
|
-
|
|
458
|
-
requestAPI.end(function(err, response) {
|
|
459
|
-
if(err) {
|
|
460
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
461
|
-
dfd.reject(err);
|
|
462
|
-
}
|
|
463
|
-
else { dfd.resolve(response.body); }
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
|
|
274
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
275
|
+
dfd.reject(err);
|
|
276
|
+
}
|
|
467
277
|
return dfd.promise;
|
|
468
278
|
}
|
|
469
279
|
|
|
470
280
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* userid: string,
|
|
474
|
-
* classid: string,
|
|
475
|
-
* productcode: string,
|
|
476
|
-
* gradingStatus: string, // optional, type of submissions required.
|
|
477
|
-
* Possible values: ['not-started', 'submitted', 'evaluated']
|
|
478
|
-
* }
|
|
281
|
+
* Wiki Link for SDK params
|
|
282
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserclassrecentsubmissionsparams
|
|
479
283
|
*/
|
|
480
284
|
function getUserClassRecentSubmissions(options) {
|
|
481
285
|
var self = this;
|
|
@@ -528,332 +332,57 @@ function getUserClassRecentSubmissions(options) {
|
|
|
528
332
|
return dfd.promise;
|
|
529
333
|
}
|
|
530
334
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Wiki Link for SDK params
|
|
337
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getstudentswithevaluatedonceparams
|
|
338
|
+
*/
|
|
535
339
|
function getStudentsWithEvaluatedOnce(options) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
var dfd = q.defer();
|
|
539
|
-
if(options && options.classid && options.productcode) {
|
|
540
|
-
//Validations
|
|
541
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
542
|
-
if(err) { dfd.reject(err); }
|
|
543
|
-
else {
|
|
544
|
-
// Passed all validations, Construct API url
|
|
545
|
-
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
546
|
-
self.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;
|
|
547
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
548
|
-
|
|
549
|
-
// Setup params
|
|
550
|
-
var params = {
|
|
551
|
-
classid: options.classid,
|
|
552
|
-
productcode: options.productcode
|
|
553
|
-
};
|
|
554
|
-
// Setup request with URL and Params
|
|
555
|
-
var requestAPI = request.get(url).query(params);
|
|
556
|
-
// Setup token in Authorization header
|
|
557
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
558
|
-
|
|
559
|
-
// setting up traceid
|
|
560
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
561
|
-
|
|
562
|
-
requestAPI.end(function(error, response) {
|
|
563
|
-
if(error) {
|
|
564
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
565
|
-
dfd.reject(err);
|
|
566
|
-
}
|
|
567
|
-
else { dfd.resolve(response.body); }
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
} else {
|
|
571
|
-
err.message = err.description = 'Required parameter classid or ' +
|
|
572
|
-
'productcode not found in request options.';
|
|
573
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
574
|
-
dfd.reject(err);
|
|
575
|
-
}
|
|
576
|
-
return dfd.promise;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
/*options = {
|
|
581
|
-
userid: <userid>, productcode: <productcode>,
|
|
582
|
-
classid: <classid>, // OPTIONAL
|
|
583
|
-
itemcode: <itemcode> // OPTIONAL
|
|
584
|
-
key: <string> // OPTIONAL
|
|
585
|
-
}*/
|
|
586
|
-
function getAppState(options) {
|
|
587
|
-
var self = this;
|
|
588
|
-
var dfd = q.defer();
|
|
589
|
-
// Validations
|
|
590
|
-
var err = {};
|
|
591
|
-
if(options && options.userid && options.productcode) {
|
|
592
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
593
|
-
if(err) { dfd.reject(err); }
|
|
594
|
-
else {
|
|
595
|
-
// Passed all validations, Construct API url
|
|
596
|
-
var url = self.config.DEFAULT_HOSTS.ANALYTICS +
|
|
597
|
-
self.config.ANALYTICS_API_URLS.appState;
|
|
598
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
599
|
-
|
|
600
|
-
var params = { userid: options.userid, productcode: options.productcode };
|
|
601
|
-
if(options.classid) { params.classid = options.classid; }
|
|
602
|
-
if(options.itemcode) { params.itemcode = options.itemcode; }
|
|
603
|
-
if(options.key) { params.key = options.key; }
|
|
604
|
-
|
|
605
|
-
// Setup request with URL and Params
|
|
606
|
-
var requestAPI = request.get(url).query(params);
|
|
607
|
-
|
|
608
|
-
// Setup token in Authorization header
|
|
609
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
610
|
-
|
|
611
|
-
// setting up traceid
|
|
612
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
613
|
-
|
|
614
|
-
// Call Product Timespent Api
|
|
615
|
-
requestAPI.end(function(err, response) {
|
|
616
|
-
if(err) {
|
|
617
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
618
|
-
dfd.reject(err);
|
|
619
|
-
}
|
|
620
|
-
else { dfd.resolve(response.body); }
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
} else {
|
|
624
|
-
err.message = err.description = "Required parameters 'userid' or " +
|
|
625
|
-
"'productcode' are not found in request options";
|
|
626
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
627
|
-
dfd.reject(err);
|
|
628
|
-
}
|
|
629
|
-
return dfd.promise;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
/*options = {
|
|
633
|
-
userid: <userid>,
|
|
634
|
-
productcode: <productcode>,
|
|
635
|
-
classid: <classid>, // OPTIONAL
|
|
636
|
-
itemcode: <itemcode> // OPTIONAL
|
|
637
|
-
appdata: <object>,
|
|
638
|
-
}*/
|
|
639
|
-
function updateAppState(options) {
|
|
640
|
-
var self = this;
|
|
641
|
-
var dfd = q.defer();
|
|
642
|
-
// Validations
|
|
643
|
-
var err = {};
|
|
644
|
-
if(options && options.userid && options.productcode && options.appdata) {
|
|
645
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
646
|
-
if(err) { dfd.reject(err); }
|
|
647
|
-
else {
|
|
648
|
-
// Passed all validations, Construct API url
|
|
649
|
-
var url = self.config.DEFAULT_HOSTS.ANALYTICS +
|
|
650
|
-
self.config.ANALYTICS_API_URLS.appState;
|
|
651
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
652
|
-
|
|
653
|
-
var params = { userid: options.userid, productcode: options.productcode };
|
|
654
|
-
if(options.classid) { params.classid = options.classid; }
|
|
655
|
-
if(options.itemcode) { params.itemcode = options.itemcode; }
|
|
656
|
-
|
|
657
|
-
// Setup request with URL and Params
|
|
658
|
-
var requestAPI = request.put(url).query(params)
|
|
659
|
-
.set('Content-Type', 'application/json')
|
|
660
|
-
.set('Accept', 'application/json')
|
|
661
|
-
.send(options.appdata);
|
|
662
|
-
|
|
663
|
-
// Setup token in Authorization header
|
|
664
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
665
|
-
|
|
666
|
-
// setting up traceid
|
|
667
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
668
|
-
|
|
669
|
-
// Call Product Timespent Api
|
|
670
|
-
requestAPI.end(function(err, response) {
|
|
671
|
-
if(err) {
|
|
672
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
673
|
-
dfd.reject(err);
|
|
674
|
-
}
|
|
675
|
-
else { dfd.resolve(response.body); }
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
} else {
|
|
679
|
-
err.message = err.description = "Required parameters 'userid' or 'appdata'" +
|
|
680
|
-
" or 'productcode' are not found in request options";
|
|
681
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
682
|
-
dfd.reject(err);
|
|
683
|
-
}
|
|
684
|
-
return dfd.promise;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
/*options = {
|
|
688
|
-
userid: <userid>, productcode: <productcode>,
|
|
689
|
-
classid: <classid>, // OPTIONAL
|
|
690
|
-
itemcode: <itemcode> // OPTIONAL
|
|
691
|
-
key: <string> // OPTIONAL
|
|
692
|
-
}*/
|
|
693
|
-
function deleteAppState(options) {
|
|
694
|
-
var self = this;
|
|
695
|
-
var dfd = q.defer();
|
|
696
|
-
// Validations
|
|
697
|
-
var err = {};
|
|
698
|
-
if(options && options.userid && options.productcode) {
|
|
699
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
700
|
-
if(err) { dfd.reject(err); }
|
|
701
|
-
else {
|
|
702
|
-
// Passed all validations, Construct API url
|
|
703
|
-
var url = self.config.DEFAULT_HOSTS.ANALYTICS +
|
|
704
|
-
self.config.ANALYTICS_API_URLS.appState;
|
|
705
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
706
|
-
|
|
707
|
-
var params = { userid: options.userid, productcode: options.productcode };
|
|
708
|
-
if(options.classid) { params.classid = options.classid; }
|
|
709
|
-
if(options.itemcode) { params.itemcode = options.itemcode; }
|
|
710
|
-
if(options.key) { params.key = options.key; }
|
|
711
|
-
|
|
712
|
-
// Setup request with URL and Params
|
|
713
|
-
var requestAPI = request.delete(url).query(params);
|
|
714
|
-
|
|
715
|
-
// Setup token in Authorization header
|
|
716
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
717
|
-
|
|
718
|
-
// setting up traceid
|
|
719
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
720
|
-
|
|
721
|
-
// Call Product Timespent Api
|
|
722
|
-
requestAPI.end(function(err, response) {
|
|
723
|
-
if(err) {
|
|
724
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
725
|
-
dfd.reject(err);
|
|
726
|
-
}
|
|
727
|
-
else { dfd.resolve(response.body); }
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
} else {
|
|
731
|
-
err.message = err.description = "Required parameters 'userid' or " +
|
|
732
|
-
"'productcode' are not found in request options";
|
|
733
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
734
|
-
dfd.reject(err);
|
|
735
|
-
}
|
|
736
|
-
return dfd.promise;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
/** This function is used to get state of single item if itemcode is given, otherwise if the
|
|
740
|
-
item code is not given then it will return state of all items and product state.
|
|
741
|
-
options = {
|
|
742
|
-
userid: <userid>,
|
|
743
|
-
productcode: <productcode>,
|
|
744
|
-
classid: <classid>, // OPTIONAL
|
|
745
|
-
itemcode: <itemcode> // OPTIONAL
|
|
746
|
-
model: <string> // OPTIONAL
|
|
747
|
-
key: <string> // OPTIONAL
|
|
748
|
-
}
|
|
749
|
-
*/
|
|
750
|
-
function getUserProductAllState(options) {
|
|
751
|
-
var self = this;
|
|
340
|
+
var self = this, err = {};
|
|
341
|
+
//Initializing promise
|
|
752
342
|
var dfd = q.defer();
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if(options && options.userid && options.productcode) {
|
|
343
|
+
if(options && options.classid && options.productcode) {
|
|
344
|
+
//Validations
|
|
756
345
|
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
757
346
|
if(err) { dfd.reject(err); }
|
|
758
347
|
else {
|
|
759
|
-
|
|
760
|
-
var url = self.config.DEFAULT_HOSTS
|
|
348
|
+
// Passed all validations, Construct API url
|
|
349
|
+
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
350
|
+
self.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;
|
|
761
351
|
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
762
352
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
353
|
+
// Setup params
|
|
354
|
+
var params = {
|
|
355
|
+
classid: options.classid,
|
|
356
|
+
productcode: options.productcode
|
|
357
|
+
};
|
|
769
358
|
// Setup request with URL and Params
|
|
770
359
|
var requestAPI = request.get(url).query(params);
|
|
771
|
-
|
|
772
360
|
// Setup token in Authorization header
|
|
773
361
|
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
774
362
|
|
|
775
363
|
// setting up traceid
|
|
776
364
|
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
777
365
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
366
|
+
requestAPI.end(function(error, response) {
|
|
367
|
+
if(error) {
|
|
368
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
782
369
|
dfd.reject(err);
|
|
783
370
|
}
|
|
784
371
|
else { dfd.resolve(response.body); }
|
|
785
372
|
});
|
|
786
373
|
}
|
|
787
374
|
} else {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
return dfd.promise;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
/*options = {
|
|
797
|
-
userid: <userid>,
|
|
798
|
-
productcode: <productcode>,
|
|
799
|
-
classid: <classid>, // OPTIONAL
|
|
800
|
-
data: <object>,
|
|
801
|
-
}*/
|
|
802
|
-
function updateUserProductMultiState(options) {
|
|
803
|
-
var self = this;
|
|
804
|
-
var dfd = q.defer();
|
|
805
|
-
// Validations
|
|
806
|
-
var err = {};
|
|
807
|
-
if(options && options.userid && options.productcode && options.data) {
|
|
808
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
809
|
-
if(err) { dfd.reject(err); }
|
|
810
|
-
else {
|
|
811
|
-
// Passed all validations, Construct API url
|
|
812
|
-
var url = self.config.DEFAULT_HOSTS.ANALYTICS +
|
|
813
|
-
self.config.ANALYTICS_API_URLS.updateUserProductMultiState;
|
|
814
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
815
|
-
|
|
816
|
-
var params = { userid: options.userid, productcode: options.productcode };
|
|
817
|
-
if(options.classid) { params.classid = options.classid; }
|
|
818
|
-
|
|
819
|
-
// Setup request with URL and Params
|
|
820
|
-
var requestAPI = request.put(url).query(params)
|
|
821
|
-
.set('Content-Type', 'application/json')
|
|
822
|
-
.set('Accept', 'application/json')
|
|
823
|
-
.send(options.data);
|
|
824
|
-
|
|
825
|
-
// Setup token in Authorization header
|
|
826
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
827
|
-
|
|
828
|
-
// setting up traceid
|
|
829
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
830
|
-
|
|
831
|
-
// Call Product Timespent Api
|
|
832
|
-
requestAPI.end(function(err, response) {
|
|
833
|
-
if(err) {
|
|
834
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
835
|
-
dfd.reject(err);
|
|
836
|
-
}
|
|
837
|
-
else { dfd.resolve(response); }
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
} else {
|
|
841
|
-
err.message = err.description = "Required parameters 'userid' or 'data'" +
|
|
842
|
-
" or 'productcode' are not found in request options";
|
|
843
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
844
|
-
dfd.reject(err);
|
|
375
|
+
err.message = err.description = 'Required parameter classid or ' +
|
|
376
|
+
'productcode not found in request options.';
|
|
377
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
378
|
+
dfd.reject(err);
|
|
845
379
|
}
|
|
846
380
|
return dfd.promise;
|
|
847
381
|
}
|
|
848
382
|
|
|
849
383
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
* classid: string,
|
|
853
|
-
* productcode: string,
|
|
854
|
-
* details: boolean, // optional, if details of submissions is also required.
|
|
855
|
-
* limit: number // optional, number of submissions to be fetched at once (default & max is 100)
|
|
856
|
-
* }
|
|
384
|
+
* Wiki Link for SDK params
|
|
385
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassproductrecentpendingsubmissionsparams
|
|
857
386
|
*/
|
|
858
387
|
function getClassProductRecentPendingSubmissions(options) {
|
|
859
388
|
var self = this;
|
|
@@ -906,12 +435,9 @@ function getClassProductRecentPendingSubmissions(options) {
|
|
|
906
435
|
return dfd.promise;
|
|
907
436
|
}
|
|
908
437
|
|
|
909
|
-
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
* userids: 'string', // comma separated userids as a single string e.g. '<userid1>,<userid2>..'(optional)
|
|
913
|
-
* includeContext: 'boolean' // includse context or heirarchy (optional)
|
|
914
|
-
*}
|
|
438
|
+
/**
|
|
439
|
+
* Wiki Link for SDK params
|
|
440
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecordparams
|
|
915
441
|
*/
|
|
916
442
|
function getClassRecord(options) {
|
|
917
443
|
var self = this;
|
|
@@ -954,18 +480,16 @@ function getClassRecord(options) {
|
|
|
954
480
|
}
|
|
955
481
|
} else {
|
|
956
482
|
err.message = err.description = 'Required parameter classid or ' +
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
483
|
+
'productcode not found in request options.';
|
|
484
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
485
|
+
dfd.reject(err);
|
|
960
486
|
}
|
|
961
487
|
return dfd.promise;
|
|
962
488
|
}
|
|
963
489
|
|
|
964
|
-
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
* item-code: 'string' // item-code of item(optional)
|
|
968
|
-
*}
|
|
490
|
+
/**
|
|
491
|
+
* Wiki Link for SDK params
|
|
492
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecorditemaggregationsparams
|
|
969
493
|
*/
|
|
970
494
|
function getClassRecordItemAggregations(options) {
|
|
971
495
|
var self = this;
|
|
@@ -987,7 +511,7 @@ function getClassRecordItemAggregations(options) {
|
|
|
987
511
|
classid: options.classid,
|
|
988
512
|
productcode: options.productcode,
|
|
989
513
|
'item-code': options['item-code']
|
|
990
|
-
}
|
|
514
|
+
};
|
|
991
515
|
|
|
992
516
|
// Setup Request with url and params
|
|
993
517
|
var requestAPI = request.get(url).query(queryParams);
|
|
@@ -1003,26 +527,22 @@ function getClassRecordItemAggregations(options) {
|
|
|
1003
527
|
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1004
528
|
dfd.reject(err);
|
|
1005
529
|
} else {
|
|
1006
|
-
dfd.resolve(response.body)
|
|
530
|
+
dfd.resolve(response.body);
|
|
1007
531
|
}
|
|
1008
532
|
});
|
|
1009
533
|
}
|
|
1010
534
|
} else {
|
|
1011
535
|
err.message = err.description = 'Required parameter classid or ' +
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
536
|
+
'productcode not found in request options.';
|
|
537
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
538
|
+
dfd.reject(err);
|
|
1015
539
|
}
|
|
1016
540
|
return dfd.promise;
|
|
1017
541
|
}
|
|
1018
542
|
|
|
1019
|
-
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1022
|
-
* 'item-code': 'string', // itemcode of item(optional)
|
|
1023
|
-
* groupid: 'string', // groupid of a group(optional)
|
|
1024
|
-
* id: 'string' // id of showcase record item(optional)
|
|
1025
|
-
*}
|
|
543
|
+
/**
|
|
544
|
+
* Wiki Link for SDK params
|
|
545
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getshowcaserecordofaclassparams
|
|
1026
546
|
*/
|
|
1027
547
|
function getShowcaseRecordOfAClass(options) {
|
|
1028
548
|
var self = this;
|
|
@@ -1069,20 +589,15 @@ function getShowcaseRecordOfAClass(options) {
|
|
|
1069
589
|
}
|
|
1070
590
|
} else {
|
|
1071
591
|
err.message = err.description = 'Required parameter classid not found in request options.';
|
|
1072
|
-
|
|
1073
|
-
|
|
592
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
593
|
+
dfd.reject(err);
|
|
1074
594
|
}
|
|
1075
595
|
return dfd.promise;
|
|
1076
596
|
}
|
|
1077
597
|
|
|
1078
598
|
/**
|
|
1079
|
-
*
|
|
1080
|
-
*
|
|
1081
|
-
* productcode: 'string', // mandatory, product code
|
|
1082
|
-
* groupid: 'string', // mandatory, group id
|
|
1083
|
-
* itemcode: 'string', // optional, item code of the group LO whose GR is required
|
|
1084
|
-
* history: boolean // optional, if true give all the submissions else give only the latest submission
|
|
1085
|
-
* }
|
|
599
|
+
* Wiki Link for SDK params
|
|
600
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getgrouprecordparams
|
|
1086
601
|
*/
|
|
1087
602
|
function getGroupRecord(options) {
|
|
1088
603
|
var self = this;
|
|
@@ -1104,7 +619,7 @@ function getGroupRecord(options) {
|
|
|
1104
619
|
classid: options.classid,
|
|
1105
620
|
productcode: options.productcode,
|
|
1106
621
|
groupid: options.groupid
|
|
1107
|
-
}
|
|
622
|
+
};
|
|
1108
623
|
|
|
1109
624
|
if(options.itemcode) { queryParams.itemcode = options.itemcode; }
|
|
1110
625
|
if(options.history) { queryParams.history = options.history; }
|
|
@@ -1123,27 +638,22 @@ function getGroupRecord(options) {
|
|
|
1123
638
|
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1124
639
|
dfd.reject(err);
|
|
1125
640
|
} else {
|
|
1126
|
-
dfd.resolve(response.body)
|
|
641
|
+
dfd.resolve(response.body);
|
|
1127
642
|
}
|
|
1128
643
|
});
|
|
1129
644
|
}
|
|
1130
645
|
} else {
|
|
1131
646
|
err.message = err.description = 'Required parameter classid or ' +
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
647
|
+
'productcode or groupid not found in request options.';
|
|
648
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
649
|
+
dfd.reject(err);
|
|
1135
650
|
}
|
|
1136
651
|
return dfd.promise;
|
|
1137
652
|
}
|
|
1138
653
|
|
|
1139
654
|
/**
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1142
|
-
* classid: string,
|
|
1143
|
-
* productcode: string,
|
|
1144
|
-
* details: boolean, // optional, if details of submissions is also required.
|
|
1145
|
-
* limit: number // optional, number of submissions to be fetched at once (default & max is 100)
|
|
1146
|
-
* }
|
|
655
|
+
* Wiki Link for SDK params
|
|
656
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassgroupsrecentpendingsubmissionsparams
|
|
1147
657
|
*/
|
|
1148
658
|
function getClassGroupsRecentPendingSubmissions(options) {
|
|
1149
659
|
var self = this;
|
|
@@ -1197,305 +707,106 @@ function getClassGroupsRecentPendingSubmissions(options) {
|
|
|
1197
707
|
}
|
|
1198
708
|
|
|
1199
709
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
*}
|
|
1204
|
-
*/
|
|
710
|
+
* Wiki Link for SDK params
|
|
711
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getgroupswithevaluatedonceparams
|
|
712
|
+
*/
|
|
1205
713
|
function getGroupsWithEvaluatedOnce(options) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
// Setup params
|
|
1220
|
-
var params = {
|
|
1221
|
-
classid: options.classid,
|
|
1222
|
-
productcode: options.productcode
|
|
1223
|
-
};
|
|
1224
|
-
// Setup request with URL and Params
|
|
1225
|
-
var requestAPI = request.get(url).query(params);
|
|
1226
|
-
// Setup token in Authorization header
|
|
1227
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1228
|
-
|
|
1229
|
-
// setting up traceid
|
|
1230
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1231
|
-
|
|
1232
|
-
requestAPI.end(function(error, response) {
|
|
1233
|
-
if(error) {
|
|
1234
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
1235
|
-
dfd.reject(err);
|
|
1236
|
-
}
|
|
1237
|
-
else { dfd.resolve(response.body); }
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
} else {
|
|
1241
|
-
err.message = err.description = 'Required parameter classid or ' +
|
|
1242
|
-
'productcode not found in request options.';
|
|
1243
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1244
|
-
dfd.reject(err);
|
|
1245
|
-
}
|
|
1246
|
-
return dfd.promise;
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
//options = {
|
|
1250
|
-
// classid: 'string',
|
|
1251
|
-
// productcode: 'string',
|
|
1252
|
-
// userid: 'string' //optional
|
|
1253
|
-
//}
|
|
714
|
+
var self = this, err = {};
|
|
715
|
+
//Initializing promise
|
|
716
|
+
var dfd = q.defer();
|
|
717
|
+
if(options && options.classid && options.productcode) {
|
|
718
|
+
//Validations
|
|
719
|
+
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
720
|
+
if(err) { dfd.reject(err); }
|
|
721
|
+
else {
|
|
722
|
+
// Passed all validations, Construct API url
|
|
723
|
+
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
724
|
+
self.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;
|
|
725
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
1254
726
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
// Passed all validations, Construct API url
|
|
1265
|
-
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
1266
|
-
self.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;
|
|
1267
|
-
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
1268
|
-
|
|
1269
|
-
// Setup params
|
|
1270
|
-
var params = {
|
|
1271
|
-
classid: options.classid,
|
|
1272
|
-
productcode: options.productcode,
|
|
1273
|
-
userid: options.userid
|
|
1274
|
-
};
|
|
1275
|
-
// Setup request with URL and Params
|
|
1276
|
-
var requestAPI = request.get(url).query(params);
|
|
1277
|
-
// Setup token in Authorization header
|
|
1278
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
727
|
+
// Setup params
|
|
728
|
+
var params = {
|
|
729
|
+
classid: options.classid,
|
|
730
|
+
productcode: options.productcode
|
|
731
|
+
};
|
|
732
|
+
// Setup request with URL and Params
|
|
733
|
+
var requestAPI = request.get(url).query(params);
|
|
734
|
+
// Setup token in Authorization header
|
|
735
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1279
736
|
|
|
1280
737
|
// setting up traceid
|
|
1281
738
|
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1282
739
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
740
|
+
requestAPI.end(function(error, response) {
|
|
741
|
+
if(error) {
|
|
742
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
743
|
+
dfd.reject(err);
|
|
744
|
+
}
|
|
745
|
+
else { dfd.resolve(response.body); }
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
} else {
|
|
749
|
+
err.message = err.description = 'Required parameter classid or ' +
|
|
750
|
+
'productcode not found in request options.';
|
|
751
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
752
|
+
dfd.reject(err);
|
|
753
|
+
}
|
|
754
|
+
return dfd.promise;
|
|
1298
755
|
}
|
|
1299
756
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
// end: '' // time(ms) - end interval // OPTIONAL
|
|
1307
|
-
// interval: '' The interval at which counters are displayed. Possible values are five_minutes, half_hour, hour, six_day, day, week, and month. Default interval is day. // Only for type - timeseries // OPTIONAL
|
|
1308
|
-
//}
|
|
1309
|
-
function getClassAnalytics(options) {
|
|
1310
|
-
var self = this;
|
|
1311
|
-
|
|
757
|
+
/**
|
|
758
|
+
* Wiki Link for SDK params
|
|
759
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclassrecorduseraggregationsparams
|
|
760
|
+
*/
|
|
761
|
+
function getClassRecordUserAggregations(options) {
|
|
762
|
+
var self = this, err = {};
|
|
1312
763
|
//Initializing promise
|
|
1313
764
|
var dfd = q.defer();
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
if(options && options.type && options.analyticsDataType && options.classid) {
|
|
765
|
+
if(options && options.classid && options.productcode) {
|
|
766
|
+
//Validations
|
|
1317
767
|
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1318
|
-
|
|
1319
|
-
else {
|
|
1320
|
-
err = {};
|
|
1321
|
-
if((!options.range && !options.interval) ||
|
|
1322
|
-
(options.range && options.type === 'stat') ||
|
|
1323
|
-
(options.interval && options.type === 'timeseries'))
|
|
1324
|
-
{
|
|
1325
|
-
var allowedAnalyticsDataType = ['enrolments', 'logins'];
|
|
1326
|
-
if(allowedAnalyticsDataType.indexOf(options.analyticsDataType) > -1) {
|
|
1327
|
-
//Passed all validations, Construct API url
|
|
1328
|
-
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
1329
|
-
self.config.ANALYTICS_API_URLS.getClassAnalytics;
|
|
1330
|
-
url = helpers.api.constructAPIUrl(url, {
|
|
1331
|
-
orgId: self.orgId, type: options.type,
|
|
1332
|
-
analyticsDataType: options.analyticsDataType
|
|
1333
|
-
});
|
|
1334
|
-
|
|
1335
|
-
var params = { classid: options.classid };
|
|
1336
|
-
if(options) {
|
|
1337
|
-
if(options.range) { params.range = options.range; }
|
|
1338
|
-
if(options.start) { params.start = options.start; }
|
|
1339
|
-
if(options.end) { params.end = options.end; }
|
|
1340
|
-
if(options.interval) { params.interval = options.interval; }
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
//Setup request with URL and Params
|
|
1344
|
-
var requestAPI = request.get(url).query(params);
|
|
1345
|
-
|
|
1346
|
-
//Setup token in Authorization header
|
|
1347
|
-
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1348
|
-
|
|
1349
|
-
// setting up traceid
|
|
1350
|
-
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1351
|
-
|
|
1352
|
-
//Call Product Timespent Api
|
|
1353
|
-
requestAPI.end(function(err, response) {
|
|
1354
|
-
if(err) {
|
|
1355
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
|
|
1356
|
-
dfd.reject(err);
|
|
1357
|
-
}
|
|
1358
|
-
else { dfd.resolve(response.body); }
|
|
1359
|
-
});
|
|
1360
|
-
} else {
|
|
1361
|
-
err.message = err.description = 'analyticsDataType: ' +
|
|
1362
|
-
options.analyticsDataType + ' is not supported';
|
|
1363
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1364
|
-
dfd.reject(err);
|
|
1365
|
-
}
|
|
1366
|
-
} else {
|
|
1367
|
-
err.message = err.description = 'Range should be defined for type - ' +
|
|
1368
|
-
'"stat" and Interval should be defined for type - "timeseries"';
|
|
1369
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1370
|
-
dfd.reject(err);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
} else {
|
|
1374
|
-
err.message = err.description = 'Required options ["type", "analyticsDataType",' +
|
|
1375
|
-
' "classid"] not found in request options';
|
|
1376
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1377
|
-
dfd.reject(err);
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
return dfd.promise;
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
//options = {
|
|
1384
|
-
// useranalyticid: <userid>,
|
|
1385
|
-
// cursor: '', // OPTIONAL cursor to next set of documents
|
|
1386
|
-
// limit: '' // OPTIONAL limit of documents per function call (Default is 5)
|
|
1387
|
-
//}
|
|
1388
|
-
function getArchivedUserAnalytics(options) {
|
|
1389
|
-
var self = this;
|
|
1390
|
-
|
|
1391
|
-
//Initializing promise
|
|
1392
|
-
var dfd = q.defer();
|
|
1393
|
-
//Validations
|
|
1394
|
-
var err = {};
|
|
1395
|
-
if(options && options.useranalyticid) {
|
|
1396
|
-
err = helpers.validations.isAuthenticated(self.orgId, self.token);
|
|
1397
|
-
if(err) { dfd.reject(err); }
|
|
768
|
+
if(err) { dfd.reject(err); }
|
|
1398
769
|
else {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
var params = { useranalyticid: options.useranalyticid };
|
|
1404
|
-
if(options) {
|
|
1405
|
-
if(options.cursor) { params.cursor = options.cursor; }
|
|
1406
|
-
if(options.limit) { params.limit = options.limit; }
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
//Setup request with URL and Params
|
|
1410
|
-
var requestAPI = request.get(url).query(params);
|
|
770
|
+
// Passed all validations, Construct API url
|
|
771
|
+
var url = self.config.DEFAULT_HOSTS['ANALYTICS'] +
|
|
772
|
+
self.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;
|
|
773
|
+
url = helpers.api.constructAPIUrl(url, { orgId: self.orgId });
|
|
1411
774
|
|
|
1412
|
-
|
|
1413
|
-
|
|
775
|
+
// Setup params
|
|
776
|
+
var params = {
|
|
777
|
+
classid: options.classid,
|
|
778
|
+
productcode: options.productcode,
|
|
779
|
+
userid: options.userid
|
|
780
|
+
};
|
|
781
|
+
// Setup request with URL and Params
|
|
782
|
+
var requestAPI = request.get(url).query(params);
|
|
783
|
+
// Setup token in Authorization header
|
|
784
|
+
requestAPI = helpers.api.setupAPIToken(requestAPI, self.token);
|
|
1414
785
|
|
|
1415
786
|
// setting up traceid
|
|
1416
787
|
if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
|
|
1417
788
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
dfd.reject(err);
|
|
1423
|
-
}
|
|
1424
|
-
else { dfd.resolve(response.body); }
|
|
1425
|
-
});
|
|
1426
|
-
}
|
|
1427
|
-
} else {
|
|
1428
|
-
err.message = err.description = "Mandatory field 'useranalyticid' not found" +
|
|
1429
|
-
" in request options";
|
|
1430
|
-
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1431
|
-
dfd.reject(err);
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
return dfd.promise;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
/*********************************************************
|
|
1438
|
-
* This function converts the data from questions format to
|
|
1439
|
-
* Learning Objective Format.
|
|
1440
|
-
*********************************************************/
|
|
1441
|
-
function getQuestionProgressByLearningObjective(questionsArray) {
|
|
1442
|
-
var learningObjectiveFormat = {};
|
|
1443
|
-
for(var i = 0; i < questionsArray.length; i++) {
|
|
1444
|
-
var questionLearningObjectives = questionsArray[i]['learning-objectives'];
|
|
1445
|
-
for(var j = 0; j < questionLearningObjectives.length; j++) {
|
|
1446
|
-
var analytics;
|
|
1447
|
-
var correct;
|
|
1448
|
-
var questionDataMap;
|
|
1449
|
-
if(!learningObjectiveFormat[questionLearningObjectives[j]]) {
|
|
1450
|
-
correct = 0;
|
|
1451
|
-
analytics = questionsArray[i].__analytics;
|
|
1452
|
-
if(analytics.statusEvaluation === 'correct') {
|
|
1453
|
-
correct++;
|
|
1454
|
-
}
|
|
1455
|
-
var questionsMap = {
|
|
1456
|
-
'status': {
|
|
1457
|
-
'correct': correct,
|
|
1458
|
-
'total': 1
|
|
1459
|
-
},
|
|
1460
|
-
'questions': []
|
|
1461
|
-
};
|
|
1462
|
-
questionDataMap = {
|
|
1463
|
-
'question-code': questionsArray[i].questionCode,
|
|
1464
|
-
'analytics': analytics
|
|
1465
|
-
};
|
|
1466
|
-
questionsMap.questions.push(questionDataMap);
|
|
1467
|
-
learningObjectiveFormat[questionLearningObjectives[j]] = questionsMap;
|
|
1468
|
-
}
|
|
1469
|
-
else {
|
|
1470
|
-
var savedQuestionsMap = learningObjectiveFormat[questionLearningObjectives[j]];
|
|
1471
|
-
analytics = questionsArray[i].__analytics;
|
|
1472
|
-
if(analytics.statusEvaluation === 'correct') {
|
|
1473
|
-
correct = savedQuestionsMap.status.correct;
|
|
1474
|
-
savedQuestionsMap.status.correct = correct + 1;
|
|
1475
|
-
}
|
|
1476
|
-
var total = savedQuestionsMap.status.total;
|
|
1477
|
-
savedQuestionsMap.status.total = total + 1;
|
|
1478
|
-
questionDataMap = {
|
|
1479
|
-
'question-code': questionsArray[i].questionCode,
|
|
1480
|
-
'analytics': analytics
|
|
1481
|
-
};
|
|
1482
|
-
savedQuestionsMap.questions.push(questionDataMap);
|
|
1483
|
-
learningObjectiveFormat[questionLearningObjectives[j]] = savedQuestionsMap;
|
|
1484
|
-
}
|
|
789
|
+
requestAPI.end(function(error, response) {
|
|
790
|
+
if(error) {
|
|
791
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, error);
|
|
792
|
+
dfd.reject(err);
|
|
1485
793
|
}
|
|
794
|
+
else { dfd.resolve(response.body); }
|
|
795
|
+
});
|
|
1486
796
|
}
|
|
1487
|
-
|
|
797
|
+
} else {
|
|
798
|
+
err.message = err.description = 'Required parameter classid or ' +
|
|
799
|
+
'productcode not found in request options.';
|
|
800
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
801
|
+
dfd.reject(err);
|
|
802
|
+
}
|
|
803
|
+
return dfd.promise;
|
|
1488
804
|
}
|
|
1489
805
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
"status_expired": <boolean>,
|
|
1495
|
-
"limit": integer, // Number of entities to be fetched
|
|
1496
|
-
"cursor": "string" // cursor to get next set of assignments
|
|
1497
|
-
};
|
|
1498
|
-
*/
|
|
806
|
+
/**
|
|
807
|
+
* Wiki Link for SDK params
|
|
808
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getallassignedpathsofclassparams
|
|
809
|
+
*/
|
|
1499
810
|
function getAllAssignedPathsOfClass(options) {
|
|
1500
811
|
var self = this;
|
|
1501
812
|
// Initializing promise
|
|
@@ -1547,13 +858,10 @@ function getAllAssignedPathsOfClass(options) {
|
|
|
1547
858
|
return dfd.promise;
|
|
1548
859
|
}
|
|
1549
860
|
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
"productcode" : "string" //required
|
|
1555
|
-
};
|
|
1556
|
-
*/
|
|
861
|
+
/**
|
|
862
|
+
* Wiki Link for SDK params
|
|
863
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getassignedpathanalyticsparams
|
|
864
|
+
*/
|
|
1557
865
|
function getAssignedPathAnalytics(options) {
|
|
1558
866
|
var self = this;
|
|
1559
867
|
// Initializing promise
|
|
@@ -1599,17 +907,10 @@ function getAssignedPathAnalytics(options) {
|
|
|
1599
907
|
return dfd.promise;
|
|
1600
908
|
}
|
|
1601
909
|
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
"status_not_started": <boolean>,
|
|
1607
|
-
"status_expired": <boolean>,
|
|
1608
|
-
"progress" : "true/false",
|
|
1609
|
-
"expiredView" : "true/false",
|
|
1610
|
-
"group" : "true/false"
|
|
1611
|
-
};
|
|
1612
|
-
*/
|
|
910
|
+
/**
|
|
911
|
+
* Wiki Link for SDK params
|
|
912
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getmyassignedpathsofclassparams
|
|
913
|
+
*/
|
|
1613
914
|
function getMyAssignedPathsOfClass(options) {
|
|
1614
915
|
var self = this;
|
|
1615
916
|
// Initializing promise
|
|
@@ -1659,17 +960,10 @@ function getMyAssignedPathsOfClass(options) {
|
|
|
1659
960
|
return dfd.promise;
|
|
1660
961
|
}
|
|
1661
962
|
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
"status_not_started": <boolean>,
|
|
1667
|
-
"status_expired": <boolean>,
|
|
1668
|
-
"progress" : "true/false",
|
|
1669
|
-
"expiredView" : "true/false",
|
|
1670
|
-
"group" : "true/false"
|
|
1671
|
-
};
|
|
1672
|
-
*/
|
|
963
|
+
/**
|
|
964
|
+
* Wiki Link for SDK params
|
|
965
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getuserassignedpathsofclassparams
|
|
966
|
+
*/
|
|
1673
967
|
function getUserAssignedPathsOfClass(options) {
|
|
1674
968
|
var self = this;
|
|
1675
969
|
// Initializing promise
|
|
@@ -1720,15 +1014,10 @@ function getUserAssignedPathsOfClass(options) {
|
|
|
1720
1014
|
return dfd.promise;
|
|
1721
1015
|
}
|
|
1722
1016
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
"ext_assignedpathid": "string",
|
|
1728
|
-
"progress" : "true/false",
|
|
1729
|
-
"group" : "true/false"
|
|
1730
|
-
};
|
|
1731
|
-
*/
|
|
1017
|
+
/**
|
|
1018
|
+
* Wiki Link for SDK params
|
|
1019
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getmyparticularassignedpathofclassparams
|
|
1020
|
+
*/
|
|
1732
1021
|
function getMyParticularAssignedPathOfClass(options) {
|
|
1733
1022
|
var self = this;
|
|
1734
1023
|
// Initializing promise
|
|
@@ -1779,12 +1068,10 @@ function getMyParticularAssignedPathOfClass(options) {
|
|
|
1779
1068
|
return dfd.promise;
|
|
1780
1069
|
}
|
|
1781
1070
|
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
};
|
|
1787
|
-
*/
|
|
1071
|
+
/**
|
|
1072
|
+
* Wiki Link for SDK params
|
|
1073
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getparticularassignedpathofclassparams
|
|
1074
|
+
*/
|
|
1788
1075
|
function getParticularAssignedPathOfClass(options) {
|
|
1789
1076
|
var self = this;
|
|
1790
1077
|
// Initializing promise
|
|
@@ -1833,12 +1120,10 @@ function getParticularAssignedPathOfClass(options) {
|
|
|
1833
1120
|
return dfd.promise;
|
|
1834
1121
|
}
|
|
1835
1122
|
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
}
|
|
1841
|
-
*/
|
|
1123
|
+
/**
|
|
1124
|
+
* Wiki Link for SDK params
|
|
1125
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#gettimeseriesanalyticsparams
|
|
1126
|
+
*/
|
|
1842
1127
|
function getTimeseriesAnalytics(options) {
|
|
1843
1128
|
var self = this;
|
|
1844
1129
|
var dfd = q.defer();
|
|
@@ -1878,14 +1163,10 @@ function getTimeseriesAnalytics(options) {
|
|
|
1878
1163
|
return dfd.promise;
|
|
1879
1164
|
}
|
|
1880
1165
|
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
query: 'string', //mandatory
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
*/
|
|
1166
|
+
/**
|
|
1167
|
+
* Wiki Link for SDK params
|
|
1168
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#postprogresstimeseriesparams
|
|
1169
|
+
*/
|
|
1889
1170
|
function postProgressTimeseries(options) {
|
|
1890
1171
|
var self = this;
|
|
1891
1172
|
var dfd = q.defer();
|
|
@@ -1897,9 +1178,9 @@ function postProgressTimeseries(options) {
|
|
|
1897
1178
|
|
|
1898
1179
|
//Setup request with URL and Params
|
|
1899
1180
|
var requestAPI = request.post(url).send(options.body);
|
|
1900
|
-
|
|
1901
|
-
if(options.cursor) {
|
|
1902
|
-
var params = { cursor: options.cursor }
|
|
1181
|
+
|
|
1182
|
+
if(options.cursor) {
|
|
1183
|
+
var params = { cursor: options.cursor };
|
|
1903
1184
|
requestAPI.query(params);
|
|
1904
1185
|
};
|
|
1905
1186
|
|
|
@@ -1924,13 +1205,11 @@ function postProgressTimeseries(options) {
|
|
|
1924
1205
|
return dfd.promise;
|
|
1925
1206
|
}
|
|
1926
1207
|
|
|
1927
|
-
|
|
1928
|
-
*
|
|
1929
|
-
*
|
|
1930
|
-
* custom_component_code: 'string', // class custom component code(optional)
|
|
1931
|
-
*}
|
|
1208
|
+
/**
|
|
1209
|
+
* Wiki Link for SDK params
|
|
1210
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclasscustomcomponentrecordparams
|
|
1932
1211
|
*/
|
|
1933
|
-
|
|
1212
|
+
function getClassCustomComponentRecord(options) {
|
|
1934
1213
|
var self = this;
|
|
1935
1214
|
|
|
1936
1215
|
//Initializing DFD
|
|
@@ -1975,21 +1254,17 @@ function postProgressTimeseries(options) {
|
|
|
1975
1254
|
}
|
|
1976
1255
|
} else {
|
|
1977
1256
|
err.message = err.description = 'Required parameter classid not found in request options.';
|
|
1978
|
-
|
|
1979
|
-
|
|
1257
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1258
|
+
dfd.reject(err);
|
|
1980
1259
|
}
|
|
1981
1260
|
return dfd.promise;
|
|
1982
1261
|
}
|
|
1983
1262
|
|
|
1984
|
-
|
|
1985
|
-
*
|
|
1986
|
-
*
|
|
1987
|
-
* custom_component_code: 'string', // class custom component code(mandatory)
|
|
1988
|
-
* userid: 'string', // user uuid(mandatory)
|
|
1989
|
-
* item_code: 'string' // item-code of an item(mandatory)
|
|
1990
|
-
*}
|
|
1263
|
+
/**
|
|
1264
|
+
* Wiki Link for SDK params
|
|
1265
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getclasscustomcomponentusersubmissionparams
|
|
1991
1266
|
*/
|
|
1992
|
-
|
|
1267
|
+
function getClassCustomComponentUserSubmission(options) {
|
|
1993
1268
|
var self = this;
|
|
1994
1269
|
|
|
1995
1270
|
//Initializing DFD
|
|
@@ -2035,20 +1310,17 @@ function postProgressTimeseries(options) {
|
|
|
2035
1310
|
} else {
|
|
2036
1311
|
err.message = err.description = 'Required parameter classid or ' +
|
|
2037
1312
|
'custom-component-code or ' + 'userid or ' + 'item-code not found in request options.';
|
|
2038
|
-
|
|
2039
|
-
|
|
1313
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1314
|
+
dfd.reject(err);
|
|
2040
1315
|
}
|
|
2041
1316
|
return dfd.promise;
|
|
2042
1317
|
}
|
|
2043
1318
|
|
|
2044
|
-
|
|
2045
|
-
*
|
|
2046
|
-
*
|
|
2047
|
-
* classid: 'string', // class uuid(mandatory)
|
|
2048
|
-
* userid: 'string' // user uuid (optional)
|
|
2049
|
-
*}
|
|
1319
|
+
/**
|
|
1320
|
+
* Wiki Link for SDK params
|
|
1321
|
+
* https://github.com/comprodls/comprodls-sdk-js/wiki/06_ANALYTICS-Adapter#getcrossproductaggregationparams
|
|
2050
1322
|
*/
|
|
2051
|
-
|
|
1323
|
+
function getCrossProductAggregation(options) {
|
|
2052
1324
|
var self = this;
|
|
2053
1325
|
|
|
2054
1326
|
//Initializing DFD
|
|
@@ -2066,7 +1338,7 @@ function postProgressTimeseries(options) {
|
|
|
2066
1338
|
// Setup Query Params
|
|
2067
1339
|
var queryParams = { classid: options.classid };
|
|
2068
1340
|
|
|
2069
|
-
if(options.userid) { queryParams.userid = options.userid }
|
|
1341
|
+
if(options.userid) { queryParams.userid = options.userid; }
|
|
2070
1342
|
|
|
2071
1343
|
// Setup Request with url and params
|
|
2072
1344
|
var requestAPI = request.get(url).query(queryParams);
|
|
@@ -2086,8 +1358,8 @@ function postProgressTimeseries(options) {
|
|
|
2086
1358
|
}
|
|
2087
1359
|
} else {
|
|
2088
1360
|
err.message = err.description = 'Required parameter classid not found in request options.';
|
|
2089
|
-
|
|
2090
|
-
|
|
1361
|
+
err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
|
|
1362
|
+
dfd.reject(err);
|
|
2091
1363
|
}
|
|
2092
1364
|
return dfd.promise;
|
|
2093
1365
|
}
|