From 6a7aebb6d48d847e98911259bd44342586c750a8 Mon Sep 17 00:00:00 2001 From: akshaya Date: Thu, 26 Jul 2018 17:07:30 +0530 Subject: [PATCH 01/15] Issue #21 feat: Question Template : Preview of the answer display layout (horizontal and vertical) is unclear --- assets/Grid.png | Bin 0 -> 718 bytes assets/Horizontal.png | Bin 0 -> 661 bytes assets/Vertical.png | Bin 0 -> 691 bytes editor/question-ctrl.js | 11 +++++++++++ editor/question.html | 27 +++++++++++++++++++-------- editor/style.css | 23 ++++++++++++++++++++++- 6 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 assets/Grid.png create mode 100644 assets/Horizontal.png create mode 100644 assets/Vertical.png diff --git a/assets/Grid.png b/assets/Grid.png new file mode 100644 index 0000000000000000000000000000000000000000..12cfe2dc9c3a58808489f4bf0442a904a27e8c5d GIT binary patch literal 718 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8khhn#^NA%Cx&(BWL`2bFm-skIEGX( zzP)XmCmbkpwD7!&RAj)#3yKd#zL=Q2QT+1efaz|BMc?>dXhtyk&f3zZs5mR78 zfQZSDQZe(L@3o$bi2Psa_WkjVUoSIfZEQdKuj>25*PpxJcYhDx-!^&v^}|=PV!jJk zSe(7yFMmc{y-SH0w`i_IA6kH@_X&uc#=@U~$>-3xkKyRWM!-i+q@3QUiUc$?;=4a`4 z#&<%Q%nTr9Kl}A(pM4hjJ$O>%*Q&oyH~iiIT(<7|DO>d&i&V}q=sXAwV_c`fY0SV~ zF*US7+v^a|0j9WA(Fa|V445}Ggh#RxRCZXunq|)^Ej07?On&{~@9%RPjOA|4dEoF! zm*LGLIzM1ZBmMAiHF zWpmEYc1$n#7u`E^``dN>>}|e#f4+Y6DDnNjrRD$r%qzRMY~|VPJ#}gu?v-6WyY*dN z`r`7MqAj(Pjow{-eCq4*HPL?~RhRD*ezAVp&4bsT*G*Ozzw^H1)wNBT+j2kUE?n1j zxtnEE?qS<FIVZ|V3(Z`X{zUT!*!~+YZ2HCDf%n6N;I~cGl zdQdLNbX?HzAfM|+#tjDwT^OuIT-p6i#2$QbNoG6~AN@>B@J}xTPr(L<0$X8xlnl=q z;ogJ-*+77wld!zs+;onPoS>akn3j;NXe6b_AHt7(8A5T-G@yGywntjSk!Z literal 0 HcmV?d00001 diff --git a/assets/Vertical.png b/assets/Vertical.png new file mode 100644 index 0000000000000000000000000000000000000000..ec76bfbe50262431837383526d0d63c70551a9cc GIT binary patch literal 691 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8khhn#^NA%Cx&(BWL`2bFy(r>IEGX( zzP-IMD-GjV^RoX!IEGD<{b=%s~9XU zY0hAbX^;rTYh2g1`|s^t*=Iau*>TWv|3k9_&Wr9aHWb$#&TVLS*~!fC{7>6$2L8?> zc7}65dABpl2|eXwnDbdWkJ(1$lq`eAbMrfF6&_Qp84Awj@8JC~L8F}E!JPXAzh9hB zFW-Il@x!u$gxz=R{?*sq{`F;lakFZoSA*|{Rjd(0%UEu(td43RN#M!vgK801izqaO zu*Gi?-`xa^&w4@em}QnVduIYuA%mx@pUXO@geCxXmMyXX literal 0 HcmV?d00001 diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 174e30c..abadb30 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -20,6 +20,13 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.questionData = {'questionMaxScore': 1}; $scope.questionData.isShuffleOption = false; $scope.questionData.isPartialScore = true; + $scope.templateIcons = []; + _.each($scope.templatesType, function(template, key){ + $scope.templateIcons.push({ + "icon": ecEditor.resolvePluginResource(instance.manifest.id, instance.manifest.ver, 'assets/'+template+'.png'), + "name": template + }); + }); $scope.questionData.templateType = $scope.templatesType[0]; $scope.questionMetaData = {}; @@ -362,6 +369,10 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) pluginInstance.renderForm(questionData1.data); $scope.$safeApply(); }; + $scope.changeLayout = function(templateType){ + $scope.questionData.templateType = templateType; + $scope.showPreview(); + } $scope.extractHTML = function(htmlElement) { var divElement= document.createElement('div'); divElement.innerHTML= htmlElement; diff --git a/editor/question.html b/editor/question.html index 0da1e12..3d27cf7 100644 --- a/editor/question.html +++ b/editor/question.html @@ -81,14 +81,25 @@

Preview

Configuration

- - -
+ + +
+
+ Select layout * +
+ +
+
+
+ +
+
+
+
+
Shuffle Option
.row{ + padding: 0; +} + +.ui.grid.template-layout>.row>.column{ + padding: 1rem; +} + +.select-template{ + cursor: pointer; } \ No newline at end of file From 8ab40a022a744f923c9cd15eeb6f7909c8eef16a Mon Sep 17 00:00:00 2001 From: swati2093 Date: Wed, 1 Aug 2018 11:40:00 +0530 Subject: [PATCH 02/15] Issue #14 feat: question edit flow changes --- editor/question-ctrl.js | 98 +++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index fa7986b..9b7a3a8 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -153,14 +153,16 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) } else { var metaFormScope = $('#question-meta-form #content-meta-form').scope(); metaFormScope.isSubmit = false; - $scope.questionData.questionTitle = metaFormScope.contentMeta.name; - $scope.questionData.qcMedium = metaFormScope.contentMeta.medium; - $scope.questionData.qcLevel = metaFormScope.contentMeta.qlevel; - $scope.questionData.questionDesc = metaFormScope.contentMeta.description; - $scope.questionData.questionMaxScore = metaFormScope.contentMeta.max_score; - $scope.questionData.qcGrade = metaFormScope.contentMeta.gradeLevel; - $scope.questionData.concepts = metaFormScope.contentMeta.concepts; - $scope.questionData.topic = metaFormScope.contentMeta.topic; + for (var key in metaFormScope.contentMeta) { + if (metaFormScope.contentMeta.hasOwnProperty(key)) { + if (key == 'name') { + $scope.questionData['title'] = metaFormScope.contentMeta['name']; + } else { + $scope.questionData[key] = metaFormScope.contentMeta[key]; + } + } + } + $scope.questionMetadataScreen = false; } } @@ -168,27 +170,27 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.questionMetadataScreen = true; //comment because in edit question the question and question title are not if ($scope.category == 'FTB') { - $scope.questionData.questionTitle = _.isUndefined($scope.questionData.questionTitle) ? $scope.questionCreationFormData.question.text.replace(/\[\[.*?\]\]/g, '____') : $scope.questionData.questionTitle; - } else { - $scope.questionData.questionTitle = _.isUndefined($scope.questionData.questionTitle) ? $scope.questionCreationFormData.question.text : $scope.questionData.questionTitle; - } - $scope.questionData.questionTitle = $scope.extractHTML($scope.questionData.questionTitle); - $scope.questionMetaData.name = $scope.questionData.questionTitle; - $scope.questionMetaData.medium = $scope.questionData.qcMedium; - $scope.questionMetaData.level = $scope.questionData.qcLevel; - $scope.questionMetaData.description = $scope.questionData.questionDesc; - $scope.questionMetaData.max_score = $scope.questionData.questionMaxScore; - $scope.questionMetaData.gradeLevel = $scope.questionData.qcGrade; - $scope.questionMetaData.concepts = $scope.questionData.concepts; - $scope.questionMetaData.topic = $scope.questionData.topic; - $scope.questionMetaData.subject = $scope.questionData.subject; - $scope.questionMetaData.board = $scope.questionData.board; - if ($scope.questionMetaData.concepts) { - $scope.questionMetaData.conceptData = "(" + $scope.questionData.concepts.length + ") concepts selected"; - } - if ($scope.questionMetaData.topic) { - $scope.questionMetaData.topicData = "(" + $scope.questionData.topic.length + ") topics selected"; - } + $scope.questionData.title = _.isUndefined($scope.questionData.title) ? $scope.questionCreationFormData.question.text.replace(/\[\[.*?\]\]/g, '____') : $scope.questionData.title; + } else { + $scope.questionData.title = _.isUndefined($scope.questionData.title) ? $scope.questionCreationFormData.question.text : $scope.questionData.title; + } + $scope.questionData.title = $scope.extractHTML($scope.questionData.title); + + + for (var key in $scope.questionData) { + if ($scope.questionData.hasOwnProperty(key)) { + if (key == 'title') { + $scope.questionMetaData['name'] = $scope.questionData['title']; + } + $scope.questionMetaData[key] = $scope.questionData[key]; + } + } + if ($scope.questionMetaData.concepts) { + $scope.questionMetaData.conceptData = "(" + $scope.questionData.concepts.length + ") concepts selected"; + } + if ($scope.questionMetaData.topic) { + $scope.questionMetaData.topicData = "(" + $scope.questionData.topic.length + ") topics selected"; + } ecEditor.dispatchEvent('org.ekstep.editcontentmeta:showpopup', { action: 'question-meta-save', subType: 'questions', @@ -199,7 +201,8 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) metadata: $scope.questionMetaData }); } - $scope.sendMetaData = function () { + $scope.sendMetaData = function (newQuestionCreate) { + $scope.isNewQuestion = newQuestionCreate; var formElement = $("#questionMetaDataTemplate").find("#content-meta-form"); var frmScope = formElement.scope(); ecEditor.dispatchEvent("metadata:form:onsuccess", {target: '#questionMetaDataTemplate', form: frmScope.metaForm}); @@ -231,15 +234,6 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) questionFormData.data = data; var metadata = { "code": "NA", - "name": $scope.questionMetaData.name, - "title": $scope.questionMetaData.name, - "medium": $scope.questionMetaData.medium, - "max_score": $scope.questionData.questionMaxScore, - "gradeLevel": $scope.questionMetaData.gradeLevel, - "subject": $scope.questionMetaData.subject, - "board": $scope.questionMetaData.board, - "qlevel": $scope.questionMetaData.level, - "question": $scope.questionCreationFormData.question.text, "isShuffleOption" : $scope.questionData.isShuffleOption, "body": JSON.stringify(questionFormData), "itemType": "UNIT", @@ -251,9 +245,20 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) "type": $scope.category.toLowerCase(), // backward compatibility "template": "NA", // backward compatibility "template_id": "NA", // backward compatibility - "topic": $scope.questionMetaData.topic, "framework": ecEditor.getContext('framework') }; + for (var key in $scope.questionMetaData) { + if ($scope.questionMetaData.hasOwnProperty(key)) { + if (key == 'title') { + metadata['name'] = $scope.questionMetaData['title']; + } + if(key == 'level'){ + metadata['qlevel'] = $scope.questionMetaData['level']; + }else{ + metadata[key] = $scope.questionMetaData[key]; + } + } + } var dynamicOptions = [{"answer": true, "value": {"type": "text", "asset": "1"}}]; var mtfoptions = [{ "value": { @@ -299,9 +304,16 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) ecEditor.getService('assessment').saveQuestionV3(assessmentId, data, function (err, resp) { if (!err) { var qMetadata = $scope.qFormData.request.assessment_item.metadata; - qMetadata.identifier = resp.data.result.node_id; - ecEditor.dispatchEvent($scope._constants.questionbankPlugin + ':saveQuestion', qMetadata); - $scope.closeThisDialog(); + qMetadata.identifier = resp.data.result.node_id; + if ($scope.isNewQuestion) { + $scope.templatesScreen = true; + $scope.questionMetadataScreen = false; + delete $scope.questionData.title; + $scope.$safeApply(); + } else { + ecEditor.dispatchEvent($scope._constants.questionbankPlugin + ':saveQuestion', qMetadata); + $scope.closeThisDialog(); + } } else { ecEditor.dispatchEvent("org.ekstep.toaster:error", { title: 'Failed to save question...', From a4b4dc6032ab365397032edf482f9d3d6f196c0f Mon Sep 17 00:00:00 2001 From: akshaya Date: Wed, 1 Aug 2018 15:26:24 +0530 Subject: [PATCH 03/15] Issue #21 fix: PR changes --- editor/question.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/editor/question.html b/editor/question.html index 3d27cf7..214678e 100644 --- a/editor/question.html +++ b/editor/question.html @@ -87,10 +87,6 @@

Configuration

Select layout *
-
From 712d27e5584008db33da49ab2399263b7e1d5229 Mon Sep 17 00:00:00 2001 From: swati2093 Date: Wed, 1 Aug 2018 16:40:39 +0530 Subject: [PATCH 04/15] Issue #14 feat: question edit flow changes --- editor/question.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/editor/question.html b/editor/question.html index 0da1e12..31a59c2 100644 --- a/editor/question.html +++ b/editor/question.html @@ -121,16 +121,20 @@

Configuration

ng-click="back();generateTelemetry({type: 'TOUCH', id: 'button', target: {id: 'question-back', ver: '', type: 'button'}})"> Back +
+
-
From d6b4fb05c501cbfaba610d5cf868e00f2b2c7817 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2018 16:05:56 +0530 Subject: [PATCH 05/15] Issue #21 fix: MCQ layout icons are not displaying --- editor/question-ctrl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 5b67c07..b711e6a 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -22,8 +22,9 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.questionData.isPartialScore = true; $scope.templateIcons = []; _.each($scope.templatesType, function(template, key){ + var templateIconName = template.toLowerCase(); $scope.templateIcons.push({ - "icon": ecEditor.resolvePluginResource(instance.manifest.id, instance.manifest.ver, 'assets/'+template+'.png'), + "icon": ecEditor.resolvePluginResource(instance.manifest.id, instance.manifest.ver, 'assets/'+templateIconName+'.png'), "name": template }); }); @@ -130,7 +131,6 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) questions.push(qObj); data[$scope._constants.questionsetPlugin][$scope._constants.questionPlugin] = questions; confData = {"contentBody": {}, "parentElement": true, "element": "#iframeArea"}; - document.getElementById("iframeArea").contentDocument.location.reload(true); var pluginInstances = ecEditor.getPluginInstances(); var previewInstance = _.find(pluginInstances, function (pi) { return pi.manifest.id === $scope._constants.previewPlugin From ce6f95d56deac0a410484cbb04ddf57d2119aa86 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2018 16:08:41 +0530 Subject: [PATCH 06/15] Issue #21 fix: MCQ layout icons deleted --- assets/Grid.png | Bin 718 -> 0 bytes assets/Horizontal.png | Bin 661 -> 0 bytes assets/Vertical.png | Bin 691 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 assets/Grid.png delete mode 100644 assets/Horizontal.png delete mode 100644 assets/Vertical.png diff --git a/assets/Grid.png b/assets/Grid.png deleted file mode 100644 index 12cfe2dc9c3a58808489f4bf0442a904a27e8c5d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 718 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8khhn#^NA%Cx&(BWL`2bFm-skIEGX( zzP)XmCmbkpwD7!&RAj)#3yKd#zL=Q2QT+1efaz|BMc?>dXhtyk&f3zZs5mR78 zfQZSDQZe(L@3o$bi2Psa_WkjVUoSIfZEQdKuj>25*PpxJcYhDx-!^&v^}|=PV!jJk zSe(7yFMmc{y-SH0w`i_IA6kH@_X&uc#=@U~$>-3xkKyRWM!-i+q@3QUiUc$?;=4a`4 z#&<%Q%nTr9Kl}A(pM4hjJ$O>%*Q&oyH~iiIT(<7|DO>d&i&V}q=sXAwV_c`fY0SV~ zF*US7+v^a|0j9WA(Fa|V445}Ggh#RxRCZXunq|)^Ej07?On&{~@9%RPjOA|4dEoF! zm*LGLIzM1ZBmMAiHF zWpmEYc1$n#7u`E^``dN>>}|e#f4+Y6DDnNjrRD$r%qzRMY~|VPJ#}gu?v-6WyY*dN z`r`7MqAj(Pjow{-eCq4*HPL?~RhRD*ezAVp&4bsT*G*Ozzw^H1)wNBT+j2kUE?n1j zxtnEE?qS<FIVZ|V3(Z`X{zUT!*!~+YZ2HCDf%n6N;I~cGl zdQdLNbX?HzAfM|+#tjDwT^OuIT-p6i#2$QbNoG6~AN@>B@J}xTPr(L<0$X8xlnl=q z;ogJ-*+77wld!zs+;onPoS>akn3j;NXe6b_AHt7(8A5T-G@yGywntjSk!Z diff --git a/assets/Vertical.png b/assets/Vertical.png deleted file mode 100644 index ec76bfbe50262431837383526d0d63c70551a9cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 691 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8khhn#^NA%Cx&(BWL`2bFy(r>IEGX( zzP-IMD-GjV^RoX!IEGD<{b=%s~9XU zY0hAbX^;rTYh2g1`|s^t*=Iau*>TWv|3k9_&Wr9aHWb$#&TVLS*~!fC{7>6$2L8?> zc7}65dABpl2|eXwnDbdWkJ(1$lq`eAbMrfF6&_Qp84Awj@8JC~L8F}E!JPXAzh9hB zFW-Il@x!u$gxz=R{?*sq{`F;lakFZoSA*|{Rjd(0%UEu(td43RN#M!vgK801izqaO zu*Gi?-`xa^&w4@em}QnVduIYuA%mx@pUXO@geCxXmMyXX From 0906af4d6f04d00cddca02d00dcd88f2f4338fe1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 6 Aug 2018 16:10:20 +0530 Subject: [PATCH 07/15] Issue #21 fix: MCQ layout icons added --- assets/grid.png | Bin 0 -> 718 bytes assets/horizontal.png | Bin 0 -> 661 bytes assets/vertical.png | Bin 0 -> 691 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/grid.png create mode 100644 assets/horizontal.png create mode 100644 assets/vertical.png diff --git a/assets/grid.png b/assets/grid.png new file mode 100644 index 0000000000000000000000000000000000000000..12cfe2dc9c3a58808489f4bf0442a904a27e8c5d GIT binary patch literal 718 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8khhn#^NA%Cx&(BWL`2bFm-skIEGX( zzP)XmCmbkpwD7!&RAj)#3yKd#zL=Q2QT+1efaz|BMc?>dXhtyk&f3zZs5mR78 zfQZSDQZe(L@3o$bi2Psa_WkjVUoSIfZEQdKuj>25*PpxJcYhDx-!^&v^}|=PV!jJk zSe(7yFMmc{y-SH0w`i_IA6kH@_X&uc#=@U~$>-3xkKyRWM!-i+q@3QUiUc$?;=4a`4 z#&<%Q%nTr9Kl}A(pM4hjJ$O>%*Q&oyH~iiIT(<7|DO>d&i&V}q=sXAwV_c`fY0SV~ zF*US7+v^a|0j9WA(Fa|V445}Ggh#RxRCZXunq|)^Ej07?On&{~@9%RPjOA|4dEoF! zm*LGLIzM1ZBmMAiHF zWpmEYc1$n#7u`E^``dN>>}|e#f4+Y6DDnNjrRD$r%qzRMY~|VPJ#}gu?v-6WyY*dN z`r`7MqAj(Pjow{-eCq4*HPL?~RhRD*ezAVp&4bsT*G*Ozzw^H1)wNBT+j2kUE?n1j zxtnEE?qS<FIVZ|V3(Z`X{zUT!*!~+YZ2HCDf%n6N;I~cGl zdQdLNbX?HzAfM|+#tjDwT^OuIT-p6i#2$QbNoG6~AN@>B@J}xTPr(L<0$X8xlnl=q z;ogJ-*+77wld!zs+;onPoS>akn3j;NXe6b_AHt7(8A5T-G@yGywntjSk!Z literal 0 HcmV?d00001 diff --git a/assets/vertical.png b/assets/vertical.png new file mode 100644 index 0000000000000000000000000000000000000000..ec76bfbe50262431837383526d0d63c70551a9cc GIT binary patch literal 691 zcmeAS@N?(olHy`uVBq!ia0vp^5g^RL1|$oo8khhn#^NA%Cx&(BWL`2bFy(r>IEGX( zzP-IMD-GjV^RoX!IEGD<{b=%s~9XU zY0hAbX^;rTYh2g1`|s^t*=Iau*>TWv|3k9_&Wr9aHWb$#&TVLS*~!fC{7>6$2L8?> zc7}65dABpl2|eXwnDbdWkJ(1$lq`eAbMrfF6&_Qp84Awj@8JC~L8F}E!JPXAzh9hB zFW-Il@x!u$gxz=R{?*sq{`F;lakFZoSA*|{Rjd(0%UEu(td43RN#M!vgK801izqaO zu*Gi?-`xa^&w4@em}QnVduIYuA%mx@pUXO@geCxXmMyXX literal 0 HcmV?d00001 From b3223f89c5d220abe2808a19255aeb1818ad7411 Mon Sep 17 00:00:00 2001 From: Jagadish Pujari Date: Mon, 6 Aug 2018 16:20:53 +0530 Subject: [PATCH 08/15] Issue #30 fix: Instead of making EvnetBus - editor:form:success undefined checking based hasEventListener --- editor/question-ctrl.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 5b67c07..8cb9d35 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -42,8 +42,12 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) } else { $scope.showTemplates(); } - EventBus.listeners['editor:form:success'] = undefined; - ecEditor.addEventListener('editor:form:success', $scope.saveMetaData); + + //Listener 'editor:form:success' making scope specific and if already added to EventBus dont add if not added add to EventBus + $scope.IsEventListened = EventBus.hasEventListener('editor:form:success', $scope.saveMetaData, $scope) + if(!$scope.IsEventListened){ + ecEditor.addEventListener('editor:form:success', $scope.saveMetaData); + } } $scope.showTemplates = function() { $scope.templatesScreen = true; From 429a20e3f2564556f3a38d624e478255b28d9828 Mon Sep 17 00:00:00 2001 From: Jagadish Pujari Date: Mon, 6 Aug 2018 19:46:30 +0530 Subject: [PATCH 09/15] Issue #30 fix: metadata form name fixed --- editor/question-ctrl.js | 182 ++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 89 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 8cb9d35..96f2216 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -15,7 +15,9 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) previewPlugin: 'org.ekstep.questionset.preview', questionPlugin: 'org.ekstep.question', questionsetPlugin: 'org.ekstep.questionset', - questionbankPlugin: 'org.ekstep.questionbank' + questionbankPlugin: 'org.ekstep.questionbank', + formElementId: '#questionMetaDataTemplate', + metadataFormName: 'questionMetaDataTemplate' }; $scope.questionData = {'questionMaxScore': 1}; $scope.questionData.isShuffleOption = false; @@ -214,102 +216,104 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) } $scope.sendMetaData = function (newQuestionCreate) { $scope.isNewQuestion = newQuestionCreate; - var formElement = $("#questionMetaDataTemplate").find("#content-meta-form"); + var formElement = $($scope._constants.formElementId).find("#content-meta-form"); var frmScope = formElement.scope(); - ecEditor.dispatchEvent("metadata:form:onsuccess", {target: '#questionMetaDataTemplate', form: frmScope.metaForm}); + ecEditor.dispatchEvent("metadata:form:onsuccess", {target: $scope._constants.formElementId, form: frmScope.metaForm}); }; $scope.saveMetaData = function (event, object) { - if(object.isValid){ - var metaDataObject = object.formData.metaData; - for (var property in object.formData.metaData) { - if (metaDataObject[property]) { - $scope.questionMetaData[property] = metaDataObject[property]; + if(object.formData.name.toLowerCase() == $scope._constants.metadataFormName.toLowerCase()){ + if(object.isValid){ + var metaDataObject = object.formData.metaData; + for (var property in object.formData.metaData) { + if (metaDataObject[property]) { + $scope.questionMetaData[property] = metaDataObject[property]; + } } - } - var questionFormData = {}; - var data = {}; // TODO: You have to get this from Q.Unit plugin(getData()) - data.plugin = $scope.selectedTemplatePluginData.plugin; - data.data = $scope.questionCreationFormData; - var outRelations = []; - _.each($scope.questionMetaData.concepts, function(concept){ - outRelations.push({ - "endNodeId": concept.identifier, - "relationType": "associatedTo" - }) - }); - var metadataObj = $scope.questionMetaData; - metadataObj.category = $scope.category; - // TODO: questionCount should be sent from unit template controllers. Currently it is hardcoded to 1. - data.config = { "metadata": metadataObj, "max_time": 0, "max_score": $scope.questionData.questionMaxScore, "partial_scoring": $scope.questionData.isPartialScore, "layout": $scope.questionData.templateType, "isShuffleOption" : $scope.questionData.isShuffleOption, "questionCount": 1}; - data.media = $scope.questionCreationFormData.media; - questionFormData.data = data; - var metadata = { - "code": "NA", - "isShuffleOption" : $scope.questionData.isShuffleOption, - "body": JSON.stringify(questionFormData), - "itemType": "UNIT", - "version": 2, - "category": $scope.category, - "description": $scope.questionMetaData.description, - "createdBy": window.context.user.id, - "channel": ecEditor.getContext('channel'), - "type": $scope.category.toLowerCase(), // backward compatibility - "template": "NA", // backward compatibility - "template_id": "NA", // backward compatibility - "framework": ecEditor.getContext('framework') - }; - for (var key in $scope.questionMetaData) { - if ($scope.questionMetaData.hasOwnProperty(key)) { - if (key == 'title') { - metadata['name'] = $scope.questionMetaData['title']; - } - if(key == 'level'){ - metadata['qlevel'] = $scope.questionMetaData['level']; - }else{ - metadata[key] = $scope.questionMetaData[key]; + var questionFormData = {}; + var data = {}; // TODO: You have to get this from Q.Unit plugin(getData()) + data.plugin = $scope.selectedTemplatePluginData.plugin; + data.data = $scope.questionCreationFormData; + var outRelations = []; + _.each($scope.questionMetaData.concepts, function(concept){ + outRelations.push({ + "endNodeId": concept.identifier, + "relationType": "associatedTo" + }) + }); + var metadataObj = $scope.questionMetaData; + metadataObj.category = $scope.category; + // TODO: questionCount should be sent from unit template controllers. Currently it is hardcoded to 1. + data.config = { "metadata": metadataObj, "max_time": 0, "max_score": $scope.questionData.questionMaxScore, "partial_scoring": $scope.questionData.isPartialScore, "layout": $scope.questionData.templateType, "isShuffleOption" : $scope.questionData.isShuffleOption, "questionCount": 1}; + data.media = $scope.questionCreationFormData.media; + questionFormData.data = data; + var metadata = { + "code": "NA", + "isShuffleOption" : $scope.questionData.isShuffleOption, + "body": JSON.stringify(questionFormData), + "itemType": "UNIT", + "version": 2, + "category": $scope.category, + "description": $scope.questionMetaData.description, + "createdBy": window.context.user.id, + "channel": ecEditor.getContext('channel'), + "type": $scope.category.toLowerCase(), // backward compatibility + "template": "NA", // backward compatibility + "template_id": "NA", // backward compatibility + "framework": ecEditor.getContext('framework') + }; + for (var key in $scope.questionMetaData) { + if ($scope.questionMetaData.hasOwnProperty(key)) { + if (key == 'title') { + metadata['name'] = $scope.questionMetaData['title']; + } + if(key == 'level'){ + metadata['qlevel'] = $scope.questionMetaData['level']; + }else{ + metadata[key] = $scope.questionMetaData[key]; + } } } + var dynamicOptions = [{"answer": true, "value": {"type": "text", "asset": "1"}}]; + var mtfoptions = [{ + "value": { + "type": "mixed", + "text": "इक", + "image": "", + "count": "", + "audio": "", + "resvalue": "इक", + "resindex": 0 + }, + "index": 0 + }]; + switch ($scope.category) { + case 'MCQ': + metadata.options = dynamicOptions; + break; + case 'FTB': + metadata.answer = dynamicOptions; + break; + case 'MTF': + metadata.lhs_options = mtfoptions; + metadata.rhs_options = mtfoptions; + break; + default: + metadata.options = dynamicOptions; + break; } - var dynamicOptions = [{"answer": true, "value": {"type": "text", "asset": "1"}}]; - var mtfoptions = [{ - "value": { - "type": "mixed", - "text": "इक", - "image": "", - "count": "", - "audio": "", - "resvalue": "इक", - "resindex": 0 - }, - "index": 0 - }]; - switch ($scope.category) { - case 'MCQ': - metadata.options = dynamicOptions; - break; - case 'FTB': - metadata.answer = dynamicOptions; - break; - case 'MTF': - metadata.lhs_options = mtfoptions; - metadata.rhs_options = mtfoptions; - break; - default: - metadata.options = dynamicOptions; - break; - } - $scope.qFormData = { - "request": { - "assessment_item": { - "objectType": "AssessmentItem", - "metadata": metadata, - "outRelations": outRelations + $scope.qFormData = { + "request": { + "assessment_item": { + "objectType": "AssessmentItem", + "metadata": metadata, + "outRelations": outRelations + } } - } - }; - /*Save data and get response and dispatch event with response to questionbank plugin*/ - $scope.saveQuestion($scope.assessmentId, $scope.qFormData); - } + }; + /*Save data and get response and dispatch event with response to questionbank plugin*/ + $scope.saveQuestion($scope.assessmentId, $scope.qFormData); + } + } }; $scope.saveQuestion = function (assessmentId, data) { ecEditor.getService('assessment').saveQuestionV3(assessmentId, data, function (err, resp) { From 740e4cbb57b50d673403d288bf4f3f3f47050859 Mon Sep 17 00:00:00 2001 From: Jagadish Pujari Date: Mon, 6 Aug 2018 20:01:20 +0530 Subject: [PATCH 10/15] Issue #30 fix: Listner code reverted --- editor/question-ctrl.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 96f2216..892c55d 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -45,11 +45,8 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.showTemplates(); } - //Listener 'editor:form:success' making scope specific and if already added to EventBus dont add if not added add to EventBus - $scope.IsEventListened = EventBus.hasEventListener('editor:form:success', $scope.saveMetaData, $scope) - if(!$scope.IsEventListened){ - ecEditor.addEventListener('editor:form:success', $scope.saveMetaData); - } + EventBus.listeners['editor:form:success'] = undefined; + ecEditor.addEventListener('editor:form:success', $scope.saveMetaData); } $scope.showTemplates = function() { $scope.templatesScreen = true; From b906583effb67bcbceaddd55adeb72bf9e41c284 Mon Sep 17 00:00:00 2001 From: Jagadish Pujari Date: Mon, 6 Aug 2018 20:50:52 +0530 Subject: [PATCH 11/15] Issue #30 fix: Form target fixed --- editor/question-ctrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 892c55d..9ad7287 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -218,7 +218,7 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) ecEditor.dispatchEvent("metadata:form:onsuccess", {target: $scope._constants.formElementId, form: frmScope.metaForm}); }; $scope.saveMetaData = function (event, object) { - if(object.formData.name.toLowerCase() == $scope._constants.metadataFormName.toLowerCase()){ + if(object.formData.target.tempalteName.toLowerCase() == $scope._constants.metadataFormName.toLowerCase()){ if(object.isValid){ var metaDataObject = object.formData.metaData; for (var property in object.formData.metaData) { From 18ab9961def679bf6c809ae1bd79f7a2dfa753c3 Mon Sep 17 00:00:00 2001 From: vinukumar-vs Date: Tue, 7 Aug 2018 20:13:33 +0530 Subject: [PATCH 12/15] Issue #30 fix: Metadata save response checking for target undefined check --- editor/question-ctrl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 9ad7287..089398b 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -218,7 +218,7 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) ecEditor.dispatchEvent("metadata:form:onsuccess", {target: $scope._constants.formElementId, form: frmScope.metaForm}); }; $scope.saveMetaData = function (event, object) { - if(object.formData.target.tempalteName.toLowerCase() == $scope._constants.metadataFormName.toLowerCase()){ + if(object.formData.target && object.formData.target.tempalteName && (object.formData.target.tempalteName.toLowerCase() == $scope._constants.metadataFormName.toLowerCase())){ if(object.isValid){ var metaDataObject = object.formData.metaData; for (var property in object.formData.metaData) { @@ -426,4 +426,4 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.init(); }]); -//# sourceURL=questionCtrl.js \ No newline at end of file +//# sourceURL=questionCtrl.js From 0c5048a39faa698f9e752c6e85567f790a4fbb43 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Aug 2018 15:43:27 +0530 Subject: [PATCH 13/15] Issue #30 issue: Question bank filter field changes --- editor/question-ctrl.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 01db5f3..7222ccd 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -342,14 +342,14 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.assessmentId = questionData.identifier; $scope.questionData = questionData1; $scope.questionCreationFormData = questionData1.data.data; - $scope.questionData.qcMedium = questionData1.data.config.metadata.medium; + $scope.questionData.medium = questionData1.data.config.metadata.medium; $scope.questionData.questionTitle = questionData.title; - $scope.questionData.qcLevel = questionData.qlevel; + $scope.questionData.level = questionData.qlevel; $scope.questionData.subject = questionData1.data.config.metadata.subject; $scope.questionData.board = questionData1.data.config.metadata.board; $scope.questionData.templateType = questionData1.data.config.layout; $scope.questionData.isPartialScore = questionData1.data.config.partial_scoring; - $scope.questionData.qcGrade = questionData1.data.config.metadata.gradeLevel; + $scope.questionData.gradeLevel = questionData1.data.config.metadata.gradeLevel; $scope.questionData.isShuffleOption = questionData1.data.config.isShuffleOption; $scope.category = questionData.category; if (questionData1.data.config.metadata.concepts) { @@ -363,7 +363,7 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.selectedConceptsData = questionData1.data.config.metadata.concepts; $scope.selectedTopicsData = questionData.topic; $scope.questionData.questionDesc = questionData1.data.config.metadata.description; - $scope.questionData.questionMaxScore = questionData1.data.config.metadata.max_score; + $scope.questionData.max_score = questionData1.data.config.metadata.max_score; $scope.conceptsCheck = true; $scope.topicsCheck = true; var pluginID = questionData1.data.plugin.id; From 3d141d19cc54108ede4e22fc77ea9f0b79c19d40 Mon Sep 17 00:00:00 2001 From: Jagadish Pujari Date: Thu, 9 Aug 2018 18:53:04 +0530 Subject: [PATCH 14/15] Issue #35 fix: Load preview edit-copy question --- editor/question-ctrl.js | 4 ++++ editor/question.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index 7222ccd..cf48f0c 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -42,6 +42,10 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) }); if (!ecEditor._.isEmpty(questionData)) { $scope.showQuestionForm(questionData); + //Check dom is ready then only play preview + angular.element(document).ready(function () { + $scope.setPreviewData(); + }); } else { $scope.showTemplates(); } diff --git a/editor/question.html b/editor/question.html index 0334e1a..c18e51f 100644 --- a/editor/question.html +++ b/editor/question.html @@ -72,7 +72,7 @@

Preview

- +
From 2e90e7d256953877bf11a90a15900351d44f4a4f Mon Sep 17 00:00:00 2001 From: Jagadish Pujari Date: Fri, 10 Aug 2018 11:09:53 +0530 Subject: [PATCH 15/15] Issue #35 fix: timeout in preview load --- editor/question-ctrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/question-ctrl.js b/editor/question-ctrl.js index cf48f0c..1ddc1fa 100644 --- a/editor/question-ctrl.js +++ b/editor/question-ctrl.js @@ -44,7 +44,7 @@ angular.module('org.ekstep.question', ['org.ekstep.metadataform']) $scope.showQuestionForm(questionData); //Check dom is ready then only play preview angular.element(document).ready(function () { - $scope.setPreviewData(); + setTimeout(function(){ $scope.setPreviewData(); }, 0); }); } else { $scope.showTemplates();