From e1c181b3f91b52e643855b4fa87f365c3224771d Mon Sep 17 00:00:00 2001 From: Sachin Date: Mon, 13 Aug 2018 23:21:43 +0530 Subject: [PATCH] Issue #13 fix: validation text audio fix --- editor/controllers/mcq-controller.js | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/editor/controllers/mcq-controller.js b/editor/controllers/mcq-controller.js index 9629aa8..631e5a2 100644 --- a/editor/controllers/mcq-controller.js +++ b/editor/controllers/mcq-controller.js @@ -122,22 +122,13 @@ angular.module('mcqApp', ['org.ekstep.question']) div.innerHTML = html; return div.textContent || div.innerText; }; - $scope.formValidation = function () { - var opSel = false; - var valid = false; - var opData; - var optionElems = ecEditor.jQuery('.option-text'); - optionElems.each(function (i, op) { - var index = op.id.split('options_')[1]; - ecEditor.jQuery('option-box').removeClass('has-errorCard'); - opData={ + $scope.isFormValid=function(index){ + var opData={ "text":$scope.getTextFromHTML($scope.mcqFormData.options[index].text), "image":$scope.getTextFromHTML($scope.mcqFormData.options[index].image), "audio":$scope.getTextFromHTML($scope.mcqFormData.options[index].audio) } - if(index && CKEDITOR.instances[op.id]) { - $scope.mcqFormData.options[index].text = CKEDITOR.instances[op.id].getData(); - if(opData.text.length != 0 || opData.image.length != 0 || opData.audio.length != 0) { + if(opData.text.length != 0 || opData.image.length != 0 || opData.audio.length != 0) { ecEditor.jQuery('#option-box-' + index).removeClass('has-errorCard'); $scope.mcqForm.$valid = true; }else{ @@ -145,9 +136,20 @@ angular.module('mcqApp', ['org.ekstep.question']) $scope.mcqForm.$valid = false; return false; } + } + $scope.formValidation = function () { + var opSel = false; + var valid = false; + var opData; + var optionElems = ecEditor.jQuery('.option-text'); + optionElems.each(function (i, op) { + var index = op.id.split('options_')[1]; + ecEditor.jQuery('option-box').removeClass('has-errorCard'); + if(index && CKEDITOR.instances[op.id]) { + $scope.mcqFormData.options[index].text = CKEDITOR.instances[op.id].getData(); + $scope.isFormValid(index); } else{ - ecEditor.jQuery('#option-box-' + index).addClass('has-errorCard'); - $scope.mcqForm.$valid = false; + $scope.isFormValid(index); } }); var formValid = $scope.mcqForm.$valid && $scope.mcqFormData.options.length > 1;