comprodls-sdk 2.45.0 → 2.46.0

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.
@@ -312,7 +312,8 @@ exports.ATTEMPTS_API_URLS = {
312
312
  getUserAttemptStatsForActivity: '/org/{orgId}/user/{userId}/activities/{activityId}/attempts/stats',
313
313
  getUserAttemptForActivity: '/org/{orgId}/user/{userId}/activities/{activityId}/attempts/{attemptId}',
314
314
  getUserFirstAttemptForActivity: '/org/{orgId}/user/{userId}/activities/{activityId}/attempts/first',
315
- getUserLastAttemptForActivity: '/org/{orgId}/user/{userId}/activities/{activityId}/attempts/last'
315
+ getUserLastAttemptForActivity: '/org/{orgId}/user/{userId}/activities/{activityId}/attempts/last',
316
+ getUserActivityMeta: '/org/{orgId}/user/{userId}/activities/{activityId}/meta'
316
317
  };
317
318
 
318
319
  exports.PUB_API_URLS = {
@@ -46,7 +46,8 @@ function attempts() {
46
46
  getUserAttemptForActivity: getUserAttemptForActivity.bind(this),
47
47
  getUserFirstAttemptForActivity: getUserFirstAttemptForActivity.bind(this),
48
48
  getUserLastAttemptForActivity: getUserLastAttemptForActivity.bind(this),
49
- updateUserAttemptForActivity: updateUserAttemptForActivity.bind(this)
49
+ updateUserAttemptForActivity: updateUserAttemptForActivity.bind(this),
50
+ getUserActivityMeta: getUserActivityMeta.bind(this)
50
51
  };
51
52
  }
52
53
 
@@ -390,3 +391,49 @@ function updateUserAttemptForActivity(options) {
390
391
  }
391
392
  return dfd.promise;
392
393
  }
394
+
395
+ /*
396
+ options = {
397
+ userid: 'string', //mandatory
398
+ activityid: 'string', //mandatory
399
+ classid: 'string', //mandatory with assignmentid
400
+ assignmentid: 'string'
401
+ }
402
+ */
403
+ function getUserActivityMeta(options) {
404
+ var self = this;
405
+ var dfd = q.defer();
406
+ var err;
407
+
408
+ if(options && options.userid && options.activityid) {
409
+ //Passed all validations, Construct API url
410
+ var url = self.config.DEFAULT_HOSTS.ATTEMPTS + self.config.ATTEMPTS_API_URLS.getUserActivityMeta;
411
+ url = helpers.api.constructAPIUrl(url, { orgId: self.orgId, userId: options.userid, activityId: options.activityid });
412
+
413
+ // Contruct parameters
414
+ var params = {};
415
+ if(options.classid) { params.classid = options.classid; }
416
+ if(options.assignmentid) { params.assignmentid = options.assignmentid; }
417
+
418
+ //Setup request with URL and Params
419
+ var requestAPI = request.get(url).query(params);
420
+
421
+ if(self.traceid) { requestAPI.set('X-Amzn-Trace-Id', self.traceid); }
422
+
423
+ requestAPI.end(function (err, response) {
424
+ if (err) {
425
+ err = new DLSError(helpers.errors.ERROR_TYPES.API_ERROR, err);
426
+ dfd.reject(err);
427
+ }
428
+ else { dfd.resolve(response.body); }
429
+ });
430
+ }
431
+ else {
432
+ err = {};
433
+ err.message = err.description = 'Mandatory params - userid or activityid ' +
434
+ 'not found in request options.';
435
+ err = new DLSError(helpers.errors.ERROR_TYPES.SDK_ERROR, err);
436
+ dfd.reject(err);
437
+ }
438
+ return dfd.promise;
439
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "comprodls-sdk",
3
3
  "description": "comproDLS SDK for JavaScript",
4
- "version": "2.45.0",
4
+ "version": "2.46.0",
5
5
  "author": {
6
6
  "name": "Compro Technologies Private Limited",
7
7
  "url": "http://www.comprotechnologies.com/"
package/test.js ADDED
@@ -0,0 +1,84 @@
1
+ var orgId = 'aberystwyth-thor';
2
+ var ComproDLS = require('../comprodls-sdk-js/lib/comprodls.js').init('thor', 'asgard', {orgId});
3
+
4
+ var accountId = 'cup1';
5
+ var tokenObj = {
6
+ "access_token" : "a8e3b7d2-2d41-4777-9233-df282467c95c",
7
+ //"access_token" : "YWMtb2nasMuyEemJvL3ph9UnmAAAAW0KQNb1ziRGuAkJ_n6LweFX9KOhYaSQeKg~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //student //YWMtw4m3tmsMEem5x6kSLL2ajAAAAWqQ3dJz4CkidQEwcm1LDszgrThOUuDLCkA~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e
8
+ // "access_token" : "YWMtQAfQGHfCEemdBmGZgYqIcgAAAWrkJ96wsnysSc8M5ilW1ZI1jOeLo226vn8~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //admin
9
+ "expires_in" : 604800,
10
+ "refresh_token": "c002d2710236789e3f36d0b8670a07b684f44b4a43e9c4a322260c11390d37826a889053c876df0dc3ae49f4701cc27bdc42d77b62ec3735eaaf9ea35cc433f208aeb1d7003eddf38ec9ab418e40caa2fefb9fda6454a3b98daf9d911db4a4e8ca285a2dfbb395b7"
11
+ };
12
+
13
+
14
+ var self = this;
15
+ var Adapter = ComproDLS.Xapi(orgId);
16
+ // console.log(Adapter);
17
+
18
+ var Options = {
19
+ "actor": {
20
+ "uuid": "a8e3b7d2-2d41-4777-9233-df282467c95c"
21
+ },
22
+ "product": {
23
+ "code": "nitish_shubham"
24
+ },
25
+ "entity": {
26
+ "timestamp": 1680160044000,
27
+ "verb": "submitted",
28
+ "item-code": "1528361176072/1529662897466/1529664397950",
29
+ "timespent": 5000,
30
+ "result": {
31
+ "response": {
32
+ "text": "desi boyzz testing"
33
+ },
34
+ "score": {
35
+ "min": 0,
36
+ "max": 100,
37
+ "raw": 85
38
+ }
39
+ }
40
+ },
41
+ "classid": "1df11d0d-ff69-4abf-9dd4-ac1262d6f8fc"
42
+ };
43
+
44
+ // ComproDLS.authWithToken(orgId, tokenObj, {})
45
+ // .then(function (response) {
46
+ // for (let i = 0; i < 100; i++) {
47
+ // Adapter.postStatement(Options)
48
+ // .then(function (res) {
49
+ // console.log("^^^^^^^^^^^^^", res);
50
+ // })
51
+ // .catch(function (err) {
52
+ // console.log("ERR CATCG", err);
53
+ // })
54
+ // }
55
+ // })
56
+ // .catch(function (err) {
57
+ // console.log("ERR CATCG", err);
58
+ // })
59
+
60
+
61
+ function sendStatement(){
62
+ Adapter.postStatement(Options)
63
+ .then(function (res) {
64
+ console.log("^^^^^^^^^^^^^", res);
65
+ // setTimeout(function(){
66
+ // sendStatement();
67
+ // }, 1000)
68
+ setTimeout(function(){ sendStatement()}, 0);
69
+ })
70
+ .catch(function (err) {
71
+ console.log("ERR CATCG", err);
72
+ sendStatement();
73
+ })
74
+ }
75
+
76
+ ComproDLS.authWithToken(orgId, tokenObj, {})
77
+ .then(function (response) {
78
+ // for(var i = 0; i < 10; i++) {
79
+ sendStatement();
80
+ // }
81
+ })
82
+ .catch(function (err) {
83
+ console.log("ERR CATCG", err);
84
+ });
package/test1.js ADDED
@@ -0,0 +1,52 @@
1
+ var orgId = 'aberystwyth-thor';
2
+ var ComproDLS = require('../comprodls-sdk-js/lib/comprodls.js').init('thor', 'asgard', {orgId});
3
+
4
+ var accountId = 'cup1';
5
+ var tokenObj = {
6
+ "access_token" : "rishav_admin_aberystwyth-thor",
7
+ // "access_token" : "a8e3b7d2-2d41-4777-9233-df282467c95c",
8
+ //"access_token" : "YWMtb2nasMuyEemJvL3ph9UnmAAAAW0KQNb1ziRGuAkJ_n6LweFX9KOhYaSQeKg~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //student //YWMtw4m3tmsMEem5x6kSLL2ajAAAAWqQ3dJz4CkidQEwcm1LDszgrThOUuDLCkA~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e
9
+ // "access_token" : "YWMtQAfQGHfCEemdBmGZgYqIcgAAAWrkJ96wsnysSc8M5ilW1ZI1jOeLo226vn8~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //admin
10
+ "expires_in" : 604800,
11
+ "refresh_token": "c002d2710236789e3f36d0b8670a07b684f44b4a43e9c4a322260c11390d37826a889053c876df0dc3ae49f4701cc27bdc42d77b62ec3735eaaf9ea35cc433f208aeb1d7003eddf38ec9ab418e40caa2fefb9fda6454a3b98daf9d911db4a4e8ca285a2dfbb395b7"
12
+ };
13
+
14
+
15
+ var self = this;
16
+ var Adapter = ComproDLS.Analytics(accountId);
17
+
18
+ var Options = {
19
+ // classid: '1df11d0d-ff69-4abf-9dd4-ac1262d6f8fc',
20
+ productcode: 'nitish_shubham',
21
+ userid: 'a8e3b7d2-2d41-4777-9233-df282467c95c',
22
+ // userid: '1de8c08d-ab2a-4066-89e8-6f28e92f0605',
23
+ type: 'items'
24
+ // assignedPathId:"78965a6d-771d-4b04-9ed8-1c8aee72d930",
25
+ // details: true
26
+ };
27
+
28
+ function getUP(){
29
+ Adapter.getUserProductAnalytics(Options)
30
+ .then(function (res) {
31
+ console.log("^^^^^^^^^^^^^", res);
32
+ getUP();
33
+ })
34
+ .catch(function (err) {
35
+ if(err.code == 404){
36
+ console.log(err);
37
+ } else {
38
+ console.log(err);
39
+ }
40
+ getUP();
41
+ })
42
+ }
43
+
44
+ ComproDLS.authWithToken(orgId, tokenObj, {})
45
+ .then(function (response) {
46
+ for(var i = 0; i < 6; i++) {
47
+ getUP();
48
+ }
49
+ })
50
+ .catch(function (err) {
51
+ console.log("ERR CATCG", err);
52
+ });
package/test3.js ADDED
@@ -0,0 +1,42 @@
1
+ var orgid = 'aberystwyth-thor';
2
+ var ComproDLS = require('../comprodls-sdk-js/lib/comprodls.js').init('thor', 'asgard', {orgid});
3
+
4
+ // var accountId = 'cup1';
5
+ var tokenObj = {
6
+ "access_token" : "a8e3b7d2-2d41-4777-9233-df282467c95c",
7
+ //"access_token" : "YWMtb2nasMuyEemJvL3ph9UnmAAAAW0KQNb1ziRGuAkJ_n6LweFX9KOhYaSQeKg~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //student //YWMtw4m3tmsMEem5x6kSLL2ajAAAAWqQ3dJz4CkidQEwcm1LDszgrThOUuDLCkA~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e
8
+ //"access_token" : "YWMtQAfQGHfCEemdBmGZgYqIcgAAAWrkJ96wsnysSc8M5ilW1ZI1jOeLo226vn8~~5d5cf9be-cb5d-11e6-a329-0e34ffe5d91e", //admin
9
+ "expires_in" : 604800,
10
+ "refresh_token": "c002d2710236789e3f36d0b8670a07b684f44b4a43e9c4a322260c11390d37826a889053c876df0dc3ae49f4701cc27bdc42d77b62ec3735eaaf9ea35cc433f208aeb1d7003eddf38ec9ab418e40caa2fefb9fda6454a3b98daf9d911db4a4e8ca285a2dfbb395b7"
11
+ };
12
+
13
+
14
+ var self = this;
15
+ var Adapter = ComproDLS.Attempts();
16
+
17
+ var Options = {
18
+ userid: 'nitishtc1',
19
+ activityid: 'nitish_shubham___1528361176072/1529662897466/1533280874199'
20
+ // classid: '564da84e-abeb-417b-bcc1-03f8434e85c8',
21
+ // itemcode: 'itemcode1',
22
+ // model: 'model.modelcode1',
23
+ // key: 'key1'
24
+ };
25
+ console.log('1');
26
+ // ComproDLS.authWithToken(orgId, tokenObj, {})
27
+ // .then(function (response) {
28
+ console.log('2');
29
+ Adapter.getUserActivityMeta(Options)
30
+ .then(function (res) {
31
+ console.log('3');
32
+ console.log("^^^^^^^^^^^^^", res);
33
+ })
34
+ .catch(function (err) {
35
+ console.log('4');
36
+ console.log("ERR CATCG", err);
37
+ })
38
+
39
+ // })
40
+ // .catch(function (err) {
41
+ // console.log("ERR CATCG", err);
42
+ // })