Skip to content

Commit

Permalink
Issue #SB-22361 fix: user is allowed to play the content by clicking …
Browse files Browse the repository at this point in the history
…on next and prev button on content player even though the attempt is exceeded
  • Loading branch information
gouravmore committed Jan 13, 2021
1 parent a4e4f41 commit 42c5ac6
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public boolean execute(final String action, JSONArray args, CallbackContext call
} else if(action.equals("getRelevantContent")) {
String request = args.getString(0);
contentService.getRelevantContent(request, new GenieServicesResponse(callbackContext));
} else if(action.equals("checkMaxLimit")) {
String request = args.getString(0);
contentService.checkMaxLimit(request, new GenieServicesResponse(callbackContext));
} else if(action.equals("getRelatedContent")) {
JSONObject contentExtras = null;
if(!args.getString(0).equals("null")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ genieservice.prototype.getRelevantContent = function(req) {
return this.handleAction("getRelevantContent", [req]);
}

// get max litmit content of particular content
genieservice.prototype.checkMaxLimit = function(req) {
return this.handleAction("checkMaxLimit", [req]);
}

genieservice.prototype.getLearnerAssessment = function(uid, id, contentExtras) {
return this.handleAction("getLearnerAssessment", [uid, id, contentExtras]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,49 +184,75 @@ endPage.controller("endPageController", function($scope, $rootScope, $state,$ele

var contentToPlay = (contentType === 'previous') ? $scope.previousContent[contentId] : $scope.nextContent[contentId];
var contentMetadata = {};
if (contentToPlay.content && contentToPlay.content.trackableParentInfo){
var trackableParentInfo = contentToPlay.content.trackableParentInfo;
window.postMessage(JSON.stringify({
event: 'renderer:navigate',
data: {
identifier: trackableParentInfo.identifier,
hierarchyInfo: trackableParentInfo.hierarchyInfo,
trackable: 'Yes'
}
}));
return;
}else if (contentToPlay.content){
contentMetadata = contentToPlay.content.contentData;
_.extend(contentMetadata, _.pick(contentToPlay.content, "hierarchyInfo", "isAvailableLocally", "basePath", "rollup"));
contentMetadata.basepath = contentMetadata.basePath;
$rootScope.content = window.content = content = contentMetadata;
}

if(content.mimeType === "video/x-youtube"){
contentToPlay.content.isAvailableLocally = false;
}
$scope.checkMaxLimit(contentToPlay, function(isMaxLimitReached){
if (isMaxLimitReached) {
window.postMessage({
event: 'renderer:maxLimitExceeded',
data: {
}
})
return;
}
if (contentToPlay.content && contentToPlay.content.trackableParentInfo){
var trackableParentInfo = contentToPlay.content.trackableParentInfo;
window.postMessage(JSON.stringify({
event: 'renderer:navigate',
data: {
identifier: trackableParentInfo.identifier,
hierarchyInfo: trackableParentInfo.hierarchyInfo,
trackable: 'Yes'
}
}));
return;
}else if (contentToPlay.content){
contentMetadata = contentToPlay.content.contentData;
_.extend(contentMetadata, _.pick(contentToPlay.content, "hierarchyInfo", "isAvailableLocally", "basePath", "rollup"));
contentMetadata.basepath = contentMetadata.basePath;
$rootScope.content = window.content = content = contentMetadata;
}

if(content.mimeType === "video/x-youtube"){
contentToPlay.content.isAvailableLocally = false;
}

if (contentToPlay.content.isAvailableLocally) {
EkstepRendererAPI.hideEndPage();
var object = {
'config': GlobalContext.config,
'data': undefined,
'metadata': contentMetadata
}
GlobalContext.config = mergeJSON(AppConfig, contentMetadata);
window.globalConfig = GlobalContext.config;
if (contentToPlay.content.isAvailableLocally) {
EkstepRendererAPI.hideEndPage();
var object = {
'config': GlobalContext.config,
'data': undefined,
'metadata': contentMetadata
}
GlobalContext.config = mergeJSON(AppConfig, contentMetadata);
window.globalConfig = GlobalContext.config;

org.ekstep.contentrenderer.initializePreview(object)
EkstepRendererAPI.dispatchEvent('renderer:player:show');
} else {
if(contentMetadata.identifier && window.parent.hasOwnProperty('onContentNotFound')) {
window.parent.onContentNotFound(contentMetadata.identifier, contentMetadata.hierarchyInfo);
org.ekstep.contentrenderer.initializePreview(object)
EkstepRendererAPI.dispatchEvent('renderer:player:show');
} else {
console.warn('Content not Available');
if(contentMetadata.identifier && window.parent.hasOwnProperty('onContentNotFound')) {
window.parent.onContentNotFound(contentMetadata.identifier, contentMetadata.hierarchyInfo);
} else {
console.warn('Content not Available');
}
}
}
});
};

$scope.checkMaxLimit = function(contentToPlay, callback) {
var contentMetadata = contentToPlay.content.contentData
if (contentToPlay.content && contentToPlay.content.primaryCategory.toLowerCase() === 'course assessment'){
org.ekstep.service.content.checkMaxLimit(contentMetadata).then(function(response){
if(response){
callback(response);
} else{
console.log('Error has occurred');
callback(false);
}
});
}else{
callback(false);
}
}

$scope.initEndpage = function() {

$rootScope.content = $scope.playerMetadata = content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if (!window.genieservice) {
return window.parent.handleAction('getAllUserProfile', [profileRequest]);
};

var checkMaxLimit = function checkMaxLimit(request) {
return window.parent.handleAction('checkMaxLimit', [request]);
};

var setUser = function setUser(userId) {
return window.parent.handleAction('setUser', [userId]);
};
Expand Down Expand Up @@ -60,6 +64,7 @@ if (!window.genieservice) {
return {
getCurrentUser: getCurrentUser,
getAllUserProfile: getAllUserProfile,
checkMaxLimit: checkMaxLimit,
setUser: setUser,
getContent: getContent,
getRelevantContent: getRelevantContent,
Expand Down
17 changes: 17 additions & 0 deletions player/public/services/interfaceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ org.ekstep.service.content = new (org.ekstep.service.mainService.extend({
})
})
},
checkMaxLimit: function (request) {
return new Promise(function (resolve, reject) {
org.ekstep.service.renderer.checkMaxLimit(request)
.then(function (contents) {
if (contents) {
resolve(contents)
} else {
// eslint-disable-next-line
reject("Contents is not available.")
}
})
.catch(function (err) {
console.error(AppErrors.contetnPathFetch, err)
reject(err)
})
})
},
cacheTelemetryEvents: function (event) {
if (event.eid.toLowerCase() === this.constant.ASSESS.toLowerCase()) {
var eventObj = _.clone(event)
Expand Down
6 changes: 6 additions & 0 deletions player/public/services/localservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ org.ekstep.service.local = new (org.ekstep.service.mainService.extend({
var response = JSON.parse("{\"next\":{\"content\":{\"basePath\":\"fixture-stories/video-renderer\",\"contentData\":{\"appIcon\":\"do_2123999168105512961495/beee6757847b84a1e41ce827ae02ccc7_1477485749628.jpeg\",\"artifactUrl\":\"fixture-stories/video-renderer/cat.mp4\",\"audience\":[\"Learner\"],\"board\":\"CBSE\",\"channel\":\"b00bc992ef25f1a9a8d63291e20efc8d\",\"contentDisposition\":\"inline\",\"contentEncoding\":\"identity\",\"contentType\":\"Resource\",\"createdBy\":\"0b174e4f-eff1-44e9-b15e-415787470456\",\"createdOn\":\"2017-12-19T05:35:20.038+0000\",\"owner\":\"bodhi1 user\",\"description\":\"Video\",\"downloadUrl\":\"do_2123999168105512961495/dummy.mp4\",\"gradeLevel\":[\"Class 1\"],\"identifier\":\"org.ekstep.videorenderer\",\"language\":[\"English\"],\"lastPublishedOn\":\"2018-05-31T12:15:39.161+0000\",\"mimeType\":\"video/webm\",\"name\":\"Water Conservation\",\"osId\":\"org.ekstep.quiz.app\",\"pkgVersion\":\"5.0\",\"publisher\":\"EkStep\",\"resourceType\":\"Read\",\"size\":\"64271.0\",\"status\":\"Live\",\"subject\":\"English\",\"versionKey\":\"1527768938990\"},\"contentType\":\"resource\",\"hierarchyInfo\":[{\"contentType\":\"textbook\",\"identifier\":\"do_2125251490189148161635\"},{\"contentType\":\"textbookunit\",\"identifier\":\"do_2125251493823201281636\"},{\"contentType\":\"collection\",\"identifier\":\"do_2123999194039664641503\"}],\"identifier\":\"org.ekstep.videorenderer\",\"isAvailableLocally\":false,\"isUpdateAvailable\":false,\"lastUpdatedTime\":1531915165000,\"mimeType\":\"video/webm\",\"referenceCount\":1,\"sizeOnDevice\":101206}},\"prev\":{\"content\":{\"basePath\":\"fixture-stories/shapes\",\"contentData\":{\"appIcon\":\"do_2123999198485053441504/b5c2ff92ab5512754a24b7ed0a09e97f_1478082514640.jpeg\",\"audience\":[\"Learner\"],\"board\":\"CBSE\",\"channel\":\"b00bc992ef25f1a9a8d63291e20efc8d\",\"contentDisposition\":\"inline\",\"contentEncoding\":\"identity\",\"contentType\":\"Resource\",\"createdBy\":\"0b174e4f-eff1-44e9-b15e-415787470456\",\"createdOn\":\"2017-12-19T05:41:30.882+0000\",\"owner\":\"Vinu Kumar V S\",\"description\":\"Different Shapes\",\"downloadUrl\":\"do_2123999198485053441504/dummy.mp4\",\"gradeLevel\":[\"Class 1\"],\"identifier\":\"org.ekstep.shapes\",\"language\":[\"English\"],\"lastPublishedOn\":\"2018-05-31T12:15:40.732+0000\",\"mimeType\":\"application/vnd.ekstep.ecml-archive\",\"name\":\"Directions\",\"osId\":\"org.ekstep.quiz.app\",\"pkgVersion\":\"4.0\",\"resourceType\":\"Read\",\"size\":\"38058.0\",\"status\":\"Live\",\"subject\":\"Hindi\",\"variants\":{\"spine\":{\"ecarUrl\":\"https://ekstep-public-qa.s3-ap-south-1.amazonaws.com/ecar_files/do_2123999198485053441504/elevator-pitch-bi-hana_1527768940895_do_2123999198485053441504_4.0_spine.ecar\",\"size\":24190}},\"versionKey\":\"1527768940387\"},\"contentType\":\"resource\",\"hierarchyInfo\":[{\"contentType\":\"textbook\",\"identifier\":\"do_2125251490189148161635\"},{\"contentType\":\"textbookunit\",\"identifier\":\"do_2125251493823201281636\"},{\"contentType\":\"collection\",\"identifier\":\"do_2123999194039664641503\"}],\"identifier\":\"org.ekstep.shapes\",\"isAvailableLocally\":true,\"isUpdateAvailable\":false,\"lastUpdatedTime\":1531914190000,\"mimeType\":\"application/vnd.ekstep.ecml-archive\",\"referenceCount\":1,\"sizeOnDevice\":9371}}}")
resolve(response)
})
},
// Get max limit of particular content
checkMaxLimit: function (request) {
return new Promise(function (resolve, reject) {
resolve(false)
})
}
}))()
org.ekstep.service.renderer = org.ekstep.service.local
6 changes: 6 additions & 0 deletions player/public/services/webservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ org.ekstep.service.web = new (org.ekstep.service.mainService.extend({
})
},

checkMaxLimit: function () {
return new Promise(function (resolve, reject) {
resolve(false)
})
},

setUser: function (uid) {
return new Promise(function (resolve, reject) {
resolve(true)
Expand Down

0 comments on commit 42c5ac6

Please sign in to comment.