AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', '$timeout', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", "AIAConstants", "LoginConstants", "$parse", "ModuleService", "$interval",
function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService, AIAConstants, LoginConstants, $parse, ModuleService, $interval) {
$scope.$sce = $sce;
$scope.ObjectAttribute=function(windowviewid)
{
var windata={
'multiwinid': windowviewid,
'LabExerciseModulesList': [],
'LabExerciseData': [],
'moduleName': '',
'currentViewTitle': '',
'parentSlugName': '',
'keywords': '',
'SavedLabExercise': [],
'quiznumber': 1,
'initialQuestioNo': 1,
'TextDropId': '',
'draggableAttribute': '',
'droppableAttribute': '',
'UserAttempt': [],
'labExeIdentifier': '',
'activityTitle': '',
'TotalNumberofQuiz': 0,
'LabExerciseUserData': [],
'isResetClicked': false,
'isResultVisible': false,
'usersCorrectQuestData': [],
'MaxScore': 0,
'Score': 0,
'DragItems': '',
'isReviewBtnSelected': false,
'LastQuestion': 0,
'commaSeperatedUserAnswers': '',
'userloginid': 0,
'correctResonseKeyValue': [],
'correctResponseForSavingDatabase':'',
'y': 0,
'x': 0,
'width': 0,
'height': 0,
'minimised': false,
'maximised': true,
'minmaxAutoEvent':true,
'isLabExChanged':false
};
return windata;
}
$scope.initializeLEWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) {
if (isOpenWithExistsModule || openPanelNo == 0) {
if ($rootScope.LEWindowData != undefined) {
$rootScope.LEWindowData.length = 0;
}
else {
$rootScope.LEWindowData = [];
}
$rootScope.LEWindowData.push($scope.ObjectAttribute(windowviewid));
}
else {
var isNewWindow = true;
for (var k = 0; k < $rootScope.LEWindowData.length; k++) {
if ($rootScope.LEWindowData[k].multiwinid == windowviewid) {
isNewWindow = false;
break;
}
}
if (isNewWindow) {
$rootScope.LEWindowData.push($scope.ObjectAttribute(windowviewid));
}
}
}
$scope.GetLEwindowStoreData = function (windowviewid, keyname) {
for (var x = 0 ; x < $rootScope.LEWindowData.length; x++) {
if ($rootScope.LEWindowData[x].multiwinid == windowviewid) {
return $rootScope.LEWindowData[x][keyname];
}
}
}
$scope.SetLEwindowStoreData = function (windowviewid, keyname, value) {
for (var x = 0 ; x < $rootScope.LEWindowData.length; x++) {
if ($rootScope.LEWindowData[x].multiwinid == windowviewid) {
$rootScope.LEWindowData[x][keyname] = value;
}
}
}
// access from home controller
$rootScope.SetLabwindowData=function(windowviewid,keyname,data) {
for(var x=0 ;x < $rootScope.LEWindowData.length;x++){
if($rootScope.LEWindowData[x].multiwinid==windowviewid)
{
$rootScope.LEWindowData[x][keyname]=data;
}
}
}
$scope.DisableLabUI = function (windowviewid) {
var modulePanel = $("#labImagePanel_"+windowviewid).find(" .jsPanel-content");
if(modulePanel.length>0)
{
modulePanel[0].style.pointerEvents="none";
modulePanel[0].style.opacity="0.7";
}
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
// CB module disable all
$('#HomeContainerDiv').css('pointer-events', 'none');
$('#HomeContainerDiv').css('opacity', '0.7');
}
$scope.EnableLabUI = function (windowviewid) {
var modulePanel = $("#labImagePanel_"+windowviewid).find(" .jsPanel-content");
if(modulePanel.length>0)
{
modulePanel[0].style.pointerEvents="auto";
modulePanel[0].style.opacity="1";
}
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
// CB module enable all
$('#HomeContainerDiv').css('pointer-events', 'auto');
$('#HomeContainerDiv').css('opacity', '1');
}
$scope.loadAIModuleById = function (moduleId) {
$rootScope.isCallFromOtherModule = undefined;
$rootScope.MULTI_VIEW_ID += 1;
// store exist module in module service
var ExistData = ModuleService.getModuleData("LAB_EXERCISE");
if (ExistData != undefined && ExistData.length > 0) {
// clear all module data before open new module in cb
ModuleService.ClearWinDataByModule(ExistData.mType);
}
var newWindowData = {
"mType": 'LAB_EXERCISE',
};
ModuleService.setModuleData(newWindowData, 0);
// close/remove prev panel when in minimised mode
if($rootScope.LEWindowData!=undefined)
{
if($rootScope.LEWindowData.length>0)
{
for(var x=0 ;x < $rootScope.LEWindowData.length;x++){
var winid=$rootScope.LEWindowData[x].multiwinid;
if ($('#labImagePanel_' + winid).html() != undefined) {
$('#labImagePanel_' + winid).remove();
}
}
$rootScope.LEWindowData=[];
}
}
$scope.initializeLEWindowData($rootScope.MULTI_VIEW_ID, true, undefined);
$scope.DisableLabUI($rootScope.MULTI_VIEW_ID);
//get current path
var currentURL = $location.path();
var selectedModuleName = '';
//set module title
angular.forEach($rootScope.userModules, function (value, key) {
if (value.slug === currentURL.replace('/', '')) {
selectedModuleName = value.name;
}
$rootScope.currentActiveModuleTitle = selectedModuleName;
})
$scope.SetLEwindowStoreData($rootScope.MULTI_VIEW_ID, 'moduleName', selectedModuleName);
$scope.getLabExerciseModules($rootScope.MULTI_VIEW_ID);
$scope.scroll();
//$document.find('div#divoptions div.thumbnail').draggable();
};
$scope.scroll = function () {
// $window.scrollTo(0, 0);
$("html,body").scrollTop(0);
}
// $rootScope.currentActiveModuleTitle = pages[8].Name;
//to get all lab exercise modules from json files
$scope.getLabExerciseModules = function (windowviewid) {
$scope.LabExerciseModulesList = null;
var labExerciseModulePath = '~/../content/data/json/le/labexercise.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
$scope.LabExerciseModulesList = result;
$scope.SetLEwindowStoreData(windowviewid, 'LabExerciseModulesList', result);
$scope.EnableLabUI(windowviewid);
},
function (error) {
$scope.EnableLabUI(windowviewid);
console.log(error.statusText)
}
)
}
$scope.getLabExerciseTitle = function (excercise) {
var windowviewid = $rootScope.MULTI_VIEW_ID;
if (excercise != null) {
// open module bu openresource
var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource');
if (isopenResourceRequest == "true") {
//set default module data
var LEopenData = {
"id": excercise.Slug,
"mType": 'LAB_EXERCISE',
"windowTitle": excercise.Topic,
"size": { height: 600, width: 900 },
"position": { x: 1, y: 30 }
};
window.parent.AIAModuleOpenResourceInfo(LEopenData);
}
else {
// $rootScope.menuLabExer = 1;//used in home controller
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', 1);
$scope.SetLEwindowStoreData(windowviewid, 'currentViewTitle', excercise.Topic);
$scope.SetLEwindowStoreData(windowviewid, 'keywords', excercise.Slug);
$scope.SetLEwindowStoreData(windowviewid, 'LabExerciseUserData', []);
$location.url("/lab-exercise-view");
}
}
}
$rootScope.InitializeLabExerciseMain = function () {
if ($rootScope.isCallFromOtherModule) {
$scope.LEModuleData = ModuleService.getModuleData("LAB_EXERCISE");
if($scope.LEModuleData.length<1) return;
$scope.DisableLabUI();
$scope.readyToLoad = true;
$rootScope.LEWindowLoadComplete = false;
$scope.wincount = 1;
var winlen = $scope.LEModuleData.length;
var timeint = null;
timeint = $interval(function () {
if ($scope.readyToLoad == true) {
var windata = $scope.LEModuleData[$scope.wincount - 1];
$scope.InitializeLabExercise(windata);
}
$scope.readyToLoad = false;
if ($scope.wincount < winlen && $rootScope.LEWindowLoadComplete == true) {
$scope.wincount = $scope.wincount + 1;
$rootScope.LEWindowLoadComplete = false;
$scope.readyToLoad = true;
}
if ($scope.wincount == winlen && $rootScope.LEWindowLoadComplete == true) {
$scope.stopInterval();
$scope.$emit("LoadModuleComplete", "LAB_EXERCISE");
}
}, 100);
$scope.stopInterval = function () {
if (angular.isDefined(timeint)) {
$interval.cancel(timeint);
timeint = undefined;
}
};
}
else {
$scope.DisableLabUI();
$scope.InitializeLabExercise(null);
}
}
$scope.InitializeLabExercise = function (leModuleData) {
if ($rootScope.isCallFromOtherModule == true) {
$scope.leOpenInOtherModules = leModuleData;
$rootScope.MULTI_VIEW_ID += 1;
var windowviewid = $rootScope.MULTI_VIEW_ID;
$scope.initializeLEWindowData(windowviewid, false, $scope.leOpenInOtherModules.currentWindowId);
var moduleName = $scope.leOpenInOtherModules.mType;
$scope.SetLEwindowStoreData(windowviewid, 'moduleName', moduleName);
if($scope.leOpenInOtherModules.lastQuize!=undefined)
{
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', $scope.leOpenInOtherModules.lastQuize);
}
else
{
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', 1);
}
$scope.SetLEwindowStoreData(windowviewid, 'currentViewTitle', $scope.leOpenInOtherModules.anatomyTitle);
var keywords = $scope.leOpenInOtherModules.id;
$scope.SetLEwindowStoreData(windowviewid, 'keywords', keywords);
var isMaximize = $scope.leOpenInOtherModules.maximised!=undefined?$scope.leOpenInOtherModules.maximised:false;
var isMinimize = $scope.leOpenInOtherModules.minimised!=undefined?$scope.leOpenInOtherModules.minimised:false;
;
$scope.SetLEwindowStoreData(windowviewid, 'maximised', isMaximize);
$scope.SetLEwindowStoreData(windowviewid, 'minimised', isMinimize);
$scope.SetLEwindowStoreData(windowviewid, 'LabExerciseUserData', []);
if($location.url()== "/curriculum-builder-detail") {
$scope.SetLEwindowStoreData(windowviewid,'parentSlugName',($location.url()).replace('/', ''));
}
else
{
$scope.SetLEwindowStoreData(windowviewid,'parentSlugName','lab-exercises');
}
$scope.loadLabExecise(windowviewid, keywords);
}
else {
$scope.SetLEwindowStoreData($rootScope.MULTI_VIEW_ID, 'parentSlugName', 'lab-exercises');
var keywords = $scope.GetLEwindowStoreData($rootScope.MULTI_VIEW_ID, 'keywords');
$scope.loadLabExecise($rootScope.MULTI_VIEW_ID, keywords);
}
}
$scope.loadLabExecise = function (windowviewid, keywords) {
var Identifier = (keywords).split('dat_')[1];
$scope.SetLEwindowStoreData(windowviewid, 'labExeIdentifier', Identifier);
$scope.jsPanelID = 'labImagePanel' + '_' + windowviewid;
var currentViewTitle = $scope.GetLEwindowStoreData(windowviewid, 'currentViewTitle');
if ($rootScope.isCallFromOtherModule) {
// open JS panel for curriculum with define cornonate in CB jason
$scope.jsPanelWidth = $scope.leOpenInOtherModules.size.width;//1000;
$scope.jsPanelHeight = $scope.leOpenInOtherModules.size.height;
if ($scope.leOpenInOtherModules.size.height < 450)
$scope.jsPanelHeight = 450;
$scope.jsPanelLeft = $scope.leOpenInOtherModules.position.x;
if ($scope.leOpenInOtherModules.position.x <= 1)
$scope.jsPanelLeft = 0;
$scope.jsPanelTop = $scope.leOpenInOtherModules.position.y;
if ($scope.leOpenInOtherModules.position.y < 30)
$scope.jsPanelTop = 30;
if($location.url()!= "/curriculum-builder-detail") {
$scope.jsPanelLeft = 1;
$scope.jsPanelTop = 85;
}
}
else {
$scope.jsPanelWidth = $(window).outerWidth() - 10;
$scope.jsPanelHeight = $(window).outerHeight() - 110;
$scope.jsPanelLeft = 1;
$scope.jsPanelTop = 55;
}
$scope.jsPanelLab = $.jsPanel({
id: $scope.jsPanelID,
selector: '.labBodyView',
theme: 'success',
currentController: 'LabExercController',
parentSlug: $scope.GetLEwindowStoreData(windowviewid, 'parentSlugName'),
ajax: {
url: 'app/views/LabExerc/lab-exercises-detail.html'
},
title: currentViewTitle,
position: {
top: $scope.jsPanelTop,
left: $scope.jsPanelLeft,
},
size: {
width: $scope.jsPanelWidth,
height: $scope.jsPanelHeight
},
onminimized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetLEwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetLEwindowStoreData(windowviewid, 'minimised',true);
$scope.SetLEwindowStoreData(windowviewid, 'maximised',false);
},
onmaximized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetLEwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetLEwindowStoreData(windowviewid, 'maximised',true);
$scope.SetLEwindowStoreData(windowviewid, 'minimised',false);
var canvasDIvHeight = $('#labImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#panelbodyDiv_' + windowviewid).css("height",canvasDIvHeight-100);
$('#resultbodyDiv_' + windowviewid).css("height",canvasDIvHeight-90);
$rootScope.resetMenuOptionOnClick(pnlName);
},
onnormalized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetLEwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetLEwindowStoreData(windowviewid, 'minimised',false);
$scope.SetLEwindowStoreData(windowviewid, 'maximised',false);
var canvasDIvHeight = $('#labImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#panelbodyDiv_' + windowviewid).css("height",canvasDIvHeight-100);
$('#resultbodyDiv_' + windowviewid).css("height",canvasDIvHeight-90);
$rootScope.resetMenuOptionOnClick(pnlName);
},
resizable: {
minWidth: 600,
minHeight: 500,
stop: function (event, ui) {
var pnlName=event.currentTarget.id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var canvasDIvHeight = $('#labImagePanel_' + windowviewid+ " .jsPanel-content").height();
$scope.SetLEwindowStoreData(windowviewid, 'width', ui.size.width);
$scope.SetLEwindowStoreData(windowviewid, 'height', canvasDIvHeight);
$scope.SetLEwindowStoreData(windowviewid, 'y', ui.position.top);
$scope.SetLEwindowStoreData(windowviewid, 'x', ui.position.left);
$rootScope.UnsaveCurriculum = true;
$('#panelbodyDiv_' + windowviewid).css("height",canvasDIvHeight-100);
$('#resultbodyDiv_' + windowviewid).css("height",canvasDIvHeight-90);
$rootScope.resetMenuOptionOnClick(pnlName);
}
},
draggable: {
stop: function( event, ui ) {
var pnlName=event.currentTarget.id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
$scope.SetLEwindowStoreData(windowviewid, 'y', ui.position.top);
$scope.SetLEwindowStoreData(windowviewid, 'x', ui.position.left);
$rootScope.UnsaveCurriculum = true;
$rootScope.resetMenuOptionOnClick(pnlName);
}
},
});
var userloginid = JSON.parse(localStorage.getItem('loggedInUserDetails')).Id;
$scope.SetLEwindowStoreData(windowviewid, 'userloginid', userloginid);
$timeout(function () {
var isMaximize = $scope.GetLEwindowStoreData(windowviewid, 'maximised');
var isMinimize = $scope.GetLEwindowStoreData(windowviewid, 'minimised');
if (isMaximize) {
$scope.jsPanelLab.maximize();
}
else if (isMinimize) {
$scope.jsPanelLab.minimize();
}
else {
$scope.jsPanelLab.normalize();
}
$rootScope.AllPanelObject(windowviewid,$scope.jsPanelLab);
$("#labImagePanel_"+windowviewid).css('overflow','hidden');
// set false after initial call of min,max or normal
$scope.SetLEwindowStoreData(windowviewid, 'minmaxAutoEvent', false);
$scope.SetLEwindowStoreData(windowviewid, 'y', $scope.jsPanelTop);
$scope.SetLEwindowStoreData(windowviewid, 'x', $scope.jsPanelLeft)
$scope.SetLEwindowStoreData(windowviewid, 'width', $scope.jsPanelWidth);
$scope.SetLEwindowStoreData(windowviewid, 'height', $scope.jsPanelHeight);
$scope.setControlsIDs(windowviewid);
var timeintval = null;
timeintval = $interval(function () {
$scope.labViewID = "LabView_" + windowviewid;
var labViewElement = angular.element(document.getElementById($scope.labViewID));
if (document.getElementById($scope.labViewID) != null)
{
var panelBody = document.getElementById("panelbodyDiv_" + windowviewid);
var len = panelBody!=null?(panelBody.id).split("_").length:0;
if (len>1) {
$scope.stopLabIntervalLoader();
$compile(labViewElement.contents())($scope);
$scope.createScopeVariable(windowviewid);
//wait until DOM element load of Lab
$scope.PanelActivity();
$scope.JsPanelclick(windowviewid);
var canvasDIvHeight = $('#labImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#panelbodyDiv_' + windowviewid).css("height",canvasDIvHeight-100);
$('#resultbodyDiv_' + windowviewid).css("height",canvasDIvHeight-90);
$scope.LoadLabExercise(windowviewid,userloginid,Identifier);
}
else
{
$scope.setControlsIDs(windowviewid);
console.log("waiting for loading content");
}
}
else
{
$scope.setControlsIDs(windowviewid);
console.log("waiting for loading view scope");
}
},100);
$scope.stopLabIntervalLoader = function () {
if (angular.isDefined(timeintval)) {
$interval.cancel(timeintval);
timeintval = undefined;
}
};
}, 100);
}
$scope.LoadLabExercise = function (windowviewid,userloginid,Identifier) {
var labExerciseInfo = {
userId: userloginid,
identifier: Identifier,
};
LabExerciseService.GetLabExercise(labExerciseInfo)
.then(
function (labResult) {
if (labResult != undefined && labResult.lastQuestion > 0 && labResult != AIAConstants.SAVED_LAB_EXERCISE_NOT_FOUND) {
$scope.SetLEwindowStoreData(windowviewid, 'SavedLabExercise', labResult);
$('#quizNo_' + windowviewid).text(labResult.lastQuestion);
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', labResult.lastQuestion);
// $scope.initialQuestioNo = labResult.lastQuestion;
$scope.SetLEwindowStoreData(windowviewid, 'initialQuestioNo', labResult.lastQuestion);
$scope.GetQuizByTopic(windowviewid);
}
else {
$scope.GetQuizByTopic(windowviewid);
}
$scope.DisableLabUI(windowviewid);
},
function (error) {
console.log('error in getting save ddata');
$scope.DisableLabUI(windowviewid);
})
}
$scope.JsPanelclick = function (windowviewid) {
//reset option list manager and annotation
//call when module loaded
$rootScope.resetMenuOption();
//remove pre event
// $("#labImagePanel_" + windowviewid).off("click");
$("#labImagePanel_" + windowviewid).on('click', function (event) {
var pnlName = event.currentTarget.id;
$rootScope.resetMenuOptionOnClick(pnlName);
});
}
$scope.createScopeVariable = function (windowviewid) {
// create dynamic scope variable to store and load data.
var dynamicLabExerciseModules = 'LabExerciseModules' + windowviewid;
var model1 = $parse(dynamicLabExerciseModules);
model1.assign($scope, null);
var dynamicDragList = 'DraggedList' + windowviewid;
var model2 = $parse(dynamicDragList);
model2.assign($scope, []);
var dynamicImagePath = 'ImagePath' + windowviewid;
var model3 = $parse(dynamicImagePath);
model3.assign($scope, '');
var dynamicVisible = 'IsVisible' + windowviewid;
var model4 = $parse(dynamicVisible);
model4.assign($scope, false);
}
$scope.setControlsIDs = function (windowviewid) {
$("#LabView").attr("id", "LabView_" + windowviewid);
$("#exerciseName").attr("id", "exerciseName_" + windowviewid);
$("#activityTitle").attr("id", "activityTitle_" + windowviewid);
$("#Title").attr("id", "Title_" + windowviewid);
$("#quizNo").attr("id", "quizNo_" + windowviewid);
$("#totalquiz").attr("id", "totalquiz_" + windowviewid);
$("#btnBackward").attr("id", "btnBackward_" + windowviewid);
$("#btnForward").attr("id", "btnForward_" + windowviewid);
$("#btnBackwardIcon").attr("id", "btnBackwardIcon_" + windowviewid);
$("#btnForwardIcon").attr("id", "btnForwardIcon_" + windowviewid);
$("#saveBtn").attr("id", "saveBtn_" + windowviewid);
$("#reviewBtn").attr("id", "reviewBtn_" + windowviewid);
$("#resetBtn").attr("id", "resetBtn_" + windowviewid);
$("#quizSubmitBtn").attr("id", "quizSubmitBtn_" + windowviewid);
$("#reportBtn").attr("id", "reportBtn_" + windowviewid);
$("#reporttitle").attr("id", "reporttitle_" + windowviewid);
$("#tdTotalQuiz").attr("id", "tdTotalQuiz_" + windowviewid);
$("#tdCorrectAnswer").attr("id", "tdCorrectAnswer_" + windowviewid);
$("#tdinCorrectAnswer").attr("id", "tdinCorrectAnswer_" + windowviewid);
$("#scoreResult").attr("id", "scoreResult_" + windowviewid);
$("#submitResultHtml").attr("id", "submitResultHtml_" + windowviewid);
$("#questionHtml").attr("id", "questionHtml_" + windowviewid);
$("#resultLabData").attr("id", "resultLabData_" + windowviewid);
$("#questionStatus").attr("id", "questionStatus_" + windowviewid);
$("#btnSendMail").attr("id", "btnSendMail_" + windowviewid);
$("#btnReportClose").attr("id", "btnReportClose_" + windowviewid);
$("#panelbodyDiv").attr("id", "panelbodyDiv_" + windowviewid);
$("#resultbodyDiv").attr("id", "resultbodyDiv_" + windowviewid);
$("#LabExPageHeading").attr("id", "LabExPageHeading_" + windowviewid);
$("#minlab").attr("id", "minlab_" + windowviewid);
$("#minlabicon").attr("id", "minlabicon_" + windowviewid);
$("#LabExMinimizedId").attr("id", "LabExMinimizedId_" + windowviewid);
$("#maxlab").attr("id", "maxlab_" + windowviewid);
$("#maxlabicon").attr("id", "maxlabicon_" + windowviewid);
$("#minclose").attr("id", "minclose_" + windowviewid);
$("#mincloseicon").attr("id", "mincloseicon_" + windowviewid);
$("#maxclose").attr("id", "maxclose_" + windowviewid);
$("#maxcloseicon").attr("id", "maxcloseicon_" + windowviewid);
$("#alertPopUp").attr("id", "alertPopUp_" + windowviewid);
$("#messageBody").attr("id", "messageBody_" + windowviewid);
$("#labmodalclose").attr("id", "labmodalclose_" + windowviewid);
$("#labexmodalbackground").attr("id", "labExModalbackground_" + windowviewid);
$("#labExModalID").attr("id", "labExModalID_" + windowviewid);
$("#LabExerciseForm").attr("id", "LabExerciseForm_" + windowviewid);
$("#closeEmailmodel").attr("id", "closeEmailmodel_" + windowviewid);
$("#emailTo").attr("id", "emailTo_" + windowviewid);
$("#userName").attr("id", "userName_" + windowviewid);
$("#userEmailID").attr("id", "userEmailID_" + windowviewid);
$("#chkCopy").attr("id", "chkCopy_" + windowviewid);
$("#emailComment").attr("id", "emailComment_" + windowviewid);
$("#labExEmailSentModalID").attr("id", "labExEmailSentModalID_" + windowviewid);
$("#sendNotification").attr("id", "sendNotification_" + windowviewid);
if ($rootScope.isCallFromOtherModule) {
$('#btnSendMail_' + windowviewid).css('visibility', 'hidden');
}
}
$scope.PanelActivity = function () {
$(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function (event) {
var panelid = $(event.target).parent().parent().parent().parent().attr('id');
$scope.RemoveJSPanel(panelid);
});
}
$scope.RemoveJSPanel = function (panelid)
{
var len = (panelid).split("_").length;
var windowviewid = (panelid).split("_")[len - 1];
// remove old stored data after close panel
for (var index = 0 ; index < $rootScope.LEWindowData.length; index++) {
if ($rootScope.LEWindowData[index].multiwinid == windowviewid) {
if (index != -1) {
// remove module which one is loaded
$rootScope.LEWindowData.splice(index, 1);
if ($('#' + panelid).html() != undefined) {
$('#' + panelid).remove();
}
// $rootScope.resetjsPanelTop();
}
}
}
}
$scope.GetQuizByTopic = function (windowviewid) {
$scope.DisableLabUI(windowviewid);
$('.jsPanel-content').css('font-size', '14px');
var keywords = $scope.GetLEwindowStoreData(windowviewid, 'keywords');
var LabExerciseName = $scope.GetLEwindowStoreData(windowviewid, 'currentViewTitle');
$('#exerciseName_' + windowviewid).text(LabExerciseName);
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
var TotalNumberofQuiz = $scope.GetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz');
$('#quizNo_' + windowviewid).text(quiznumber);
$('#totalquiz_' + windowviewid).text(TotalNumberofQuiz);
if (quiznumber == 1) {
$("#btnBackward_" + windowviewid).css('pointer-events', 'none');
}
else if (quiznumber == TotalNumberofQuiz) {
$("#btnForward_" + windowviewid).css('pointer-events', 'none');
}
else {
$("#btnBackward_" + windowviewid).css('pointer-events', 'auto');
$("#btnForward_" + windowviewid).css('pointer-events', 'auto');
}
var labExerciseModulePath = '~/../content/data/json/le/' + keywords + '.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
$scope.SetLEwindowStoreData(windowviewid, 'LabExerciseData', result);
var Identifier = (keywords).split('dat_')[1];
$scope.SetLEwindowStoreData(windowviewid, 'labExeIdentifier', Identifier);
$('#panelbodyDiv_' + windowviewid).empty();
var dynamicLabExerciseModules = 'LabExerciseModules' + windowviewid;
var dynamicDragList = 'DraggedList' + windowviewid;
var dynamicImagePath = 'ImagePath' + windowviewid;
var dynamicVisible = 'IsVisible' + windowviewid;
var $e1 = $('
'
+ ''
+ '
'
+ '
'
+ '
'
+ '
![]()
'
+ '
{{optionbox.Answervalue}}
'
+ '
{{ans.Value}}
'
+ '
'
+ '
{{option.OptionTitle}}
'
+ '
').appendTo('#panelbodyDiv_' + windowviewid);
$compile($e1)($scope);
var LabExerciseUserData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseUserData');
var SavedLabExercise = $scope.GetLEwindowStoreData(windowviewid, 'SavedLabExercise');
$.each(result.LabExercise, function (index, value) {
var LabExerciseName = result.LabExercise[index].Topic;
$('#exerciseName_' + windowviewid).text(LabExerciseName);
$scope.SetLEwindowStoreData(windowviewid, 'currentViewTitle', LabExerciseName);
if (result.LabExercise[index].Slug == keywords) {
var TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions;
$scope.SetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz', TotalNumberofQuiz);
$('#totalquiz_' + windowviewid).text(TotalNumberofQuiz);
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == quiznumber) {
var MaxScore = result.LabExercise[index].Questions[index1].Options.length;
$scope.SetLEwindowStoreData(windowviewid, 'MaxScore', MaxScore);
if (result.LabExercise[index].Questions[index1].ImagePath == "") {
$("#imgblock_" + windowviewid).css("display", "none");
$scope[dynamicVisible] = false;
//$scope.IsVisible = false;
$("#textblock_" + windowviewid).css("display", "block");
$scope[dynamicLabExerciseModules] = result.LabExercise[index].Questions[index1];
$scope.deliberatelyTrustDangerousSnippet = function (html) {
return $sce.trustAsHtml(html);
};
var activityTitle = result.LabExercise[index].Questions[index1].activityTitle;
$scope.SetLEwindowStoreData(windowviewid, 'activityTitle', activityTitle);
var Title = result.LabExercise[index].Questions[index1].Title;
$('#activityTitle_' + windowviewid).text(activityTitle);
$('#Title_' + windowviewid).text(Title);
}
else {
$("#imgblock_" + windowviewid).css("display", "block");
$scope[dynamicVisible] = true;
//$scope.IsVisible = true;
$("#textblock_" + windowviewid).css("display", "none");
$scope[dynamicLabExerciseModules] = result.LabExercise[index].Questions[index1];
var activityTitle = result.LabExercise[index].Questions[index1].activityTitle;
$scope.SetLEwindowStoreData(windowviewid, 'activityTitle', activityTitle);
var Title = result.LabExercise[index].Questions[index1].Title;
$('#activityTitle_' + windowviewid).text(activityTitle);
$('#Title_' + windowviewid).text(Title);
$scope[dynamicImagePath] = keywords + "/" + result.LabExercise[index].Questions[index1].ImagePath;
}
if ($("#textblock_" + windowviewid).css("display") == "block") {
$("#imgdiv_" + windowviewid).css("position", "static");
$("#imgdiv_" + windowviewid).find("div").each(function () {
var answerDiv = $(this).attr("id").split("-");
if (answerDiv[0] == "blockans") {
var concatID = answerDiv[0] + "-" + answerDiv[1];
$("#" + concatID).css("width", "auto");
}
});
}
else {
$("#imgdiv_" + windowviewid).css("position", "relative");
}
$scope.ShowHideDiv("bottom", windowviewid);
}
});
$timeout(function () {
if ((SavedLabExercise !=undefined && SavedLabExercise.lastQuestion > 0) || (LabExerciseUserData != undefined && LabExerciseUserData.length > 0)) {
var isResetClicked = $scope.GetLEwindowStoreData(windowviewid, 'isResetClicked');
if (isResetClicked != true) {
$scope.ShowSavedLabExercise(windowviewid);
}
else {
$scope.SetLEwindowStoreData(windowviewid, 'isResetClicked', false);
}
}
$scope.EnableLabUI(windowviewid);
if ($rootScope.isCallFromOtherModule) {
$rootScope.LEWindowLoadComplete = true;
}
}, 100);
}
});
},
function (error) {
console.log(error.statusText)
}
)
}
$scope.nextQuiz = function ($event) {
$rootScope.UnsaveCurriculum = true;
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$scope.SetLEwindowStoreData(windowviewid, 'isLabExChanged', true);
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
$('#quizNo_' + windowviewid).text(quiznumber);
$scope.SetLEwindowStoreData(windowviewid, 'TextDropId', '');
var TotalNumberofQuiz = $scope.GetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz');
$('#totalquiz_' + windowviewid).text(TotalNumberofQuiz);
if (quiznumber != TotalNumberofQuiz) {
$scope.CreateLabExerciseDataToSave(windowviewid, quiznumber);
}
if (quiznumber == TotalNumberofQuiz)
return;
else {
quiznumber++;
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', quiznumber);
$('#quizNo_' + windowviewid).text(quiznumber);
}
if (quiznumber == TotalNumberofQuiz) {
var isReviewBtnSelected = $scope.GetLEwindowStoreData(windowviewid, 'isReviewBtnSelected');
if (isReviewBtnSelected == true) {
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
}
else {
$("#quizSubmitBtn_" + windowviewid).css("display", "block");
}
}
else {
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
}
$scope.resetQuiz(windowviewid);
$scope.ShowHideDiv("", windowviewid);
}
$scope.prevQuiz = function ($event) {
$rootScope.UnsaveCurriculum = true;
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$scope.SetLEwindowStoreData(windowviewid, 'isLabExChanged', true);
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
var TotalNumberofQuiz = $scope.GetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz');
$('#totalquiz_' + windowviewid).text(TotalNumberofQuiz);
$('#quizNo_' + windowviewid).text(quiznumber);
if (quiznumber != 1) {
$scope.CreateLabExerciseDataToSave(windowviewid, quiznumber);
}
$scope.SetLEwindowStoreData(windowviewid, 'TextDropId', '');
if (quiznumber == 1)
return;
else {
quiznumber--;
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', quiznumber);
$('#quizNo_' + windowviewid).text(quiznumber);
}
if (quiznumber == TotalNumberofQuiz) {
var isReviewBtnSelected = $scope.GetLEwindowStoreData(windowviewid, 'isReviewBtnSelected');
if (isReviewBtnSelected == true) {
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
}
else {
$("#quizSubmitBtn_" + windowviewid).css("display", "block");
}
}
else {
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
}
$scope.resetQuiz(windowviewid);
$scope.ShowHideDiv("", windowviewid);
}
$scope.SubmitAttempt = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
var LabExerciseData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseData');
$scope.CreateLabExerciseDataToSave(windowviewid, quiznumber);
$("#submitResultHtml_" + windowviewid).css("display", "block");
$("#questionHtml_" + windowviewid).css("display", "none");
var LabExerciseName = $scope.GetLEwindowStoreData(windowviewid, 'currentViewTitle');
$('#reporttitle_' + windowviewid).text(LabExerciseName);
var TotalNumberofQuiz = $scope.GetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz');
$('#tdTotalQuiz_' + windowviewid).text(TotalNumberofQuiz);
$("#resultLabData_" + windowviewid).empty();
var sortedQuestionHtml = '';
var usersCorrectQuestData = $scope.GetLEwindowStoreData(windowviewid, 'usersCorrectQuestData');
var SavedLabExercise = $scope.GetLEwindowStoreData(windowviewid, 'SavedLabExercise');
if (SavedLabExercise != undefined && SavedLabExercise.labExercise.length > 0) {
for (var j = 0; j <= SavedLabExercise.labExercise.length - 1; j++) {
var boolValueEx = false;
for (var i = 0; i <= usersCorrectQuestData.length - 1; i++) {
if (SavedLabExercise.labExercise[j].QuestionNo == usersCorrectQuestData[i].QuestionNo) {
boolValueEx = true;
break;
}
}
if (boolValueEx == false) {
if (SavedLabExercise.labExercise[j].MaxScore == SavedLabExercise.labExercise[j].Score) {
usersCorrectQuestData.push({
CorrectAnswers: SavedLabExercise.labExercise[j].CorrectAnswers,
DragItems: SavedLabExercise.labExercise[j].DragItems,
CorrectStatus: "Correct",
MaxScore: SavedLabExercise.labExercise[j].MaxScore,
QuestionNo: SavedLabExercise.labExercise[j].QuestionNo,
Score: SavedLabExercise.labExercise[j].Score,
UserAnswer: SavedLabExercise.labExercise[j].UserAnswers
})
}
else {
usersCorrectQuestData.push({
CorrectAnswers: SavedLabExercise.labExercise[j].CorrectAnswers,
DragItems: SavedLabExercise.labExercise[j].DragItems,
CorrectStatus: "Incorrect",
MaxScore: SavedLabExercise.labExercise[j].MaxScore,
QuestionNo: SavedLabExercise.labExercise[j].QuestionNo,
Score: SavedLabExercise.labExercise[j].Score,
UserAnswer: SavedLabExercise.labExercise[j].UserAnswers
})
}
}
}
}
for (var j = TotalNumberofQuiz; j >= 1; j--) {
for (var i = 0; i <= usersCorrectQuestData.length - 1; i++) {
if (j == usersCorrectQuestData[i].QuestionNo) {
if (usersCorrectQuestData[i].CorrectStatus == "Correct") {
var labExerciseHtml = $("#resultLabData_" + windowviewid).append("" + usersCorrectQuestData[i].QuestionNo + " | " + usersCorrectQuestData[i].title + " | " + usersCorrectQuestData[i].CorrectStatus + " | |
");
$compile(labExerciseHtml)($scope);
}
else {
var labExerciseHtml = $("#resultLabData_" + windowviewid).append("" + usersCorrectQuestData[i].QuestionNo + " | " + usersCorrectQuestData[i].title + " | " + usersCorrectQuestData[i].CorrectStatus + " | |
");
$compile(labExerciseHtml)($scope);
}
var isValueExist = true;
break;
}
else {
var isValueExist = false;
}
}
if (isValueExist == false) {
var labExerciseHtml_1 = $("#resultLabData_" + windowviewid).prepend("" + j + " | | Incorrect | |
");
$compile(labExerciseHtml_1)($scope);
}
}
for (var j = 1; j <= TotalNumberofQuiz; j++) {
$("#resultLabData_" + windowviewid + " tr td:nth-child(1)").each(function () {
if (j == $(this).text()) {
$q = $(this).parent();
if ($q.find("td:nth-child(3)").text() == "Correct") {
sortedQuestionHtml += '' + $q.find("td:nth-child(1)").text() + ' | ' + $q.find("td:nth-child(2)").text() + ' | ' + $q.find("td:nth-child(3)").text() + ' | |
';
}
else {
sortedQuestionHtml += '' + $q.find("td:nth-child(1)").text() + ' | ' + $q.find("td:nth-child(2)").text() + ' | ' + $q.find("td:nth-child(3)").text() + ' | |
';
}
}
});
}
$scope.SetLEwindowStoreData(windowviewid, 'usersCorrectQuestData', usersCorrectQuestData);
$("#resultLabData_" + windowviewid).empty();
var sortedCompileHtml = $("#resultLabData_" + windowviewid).append(sortedQuestionHtml);
$compile(sortedCompileHtml)($scope);
var inCorrectAnswer = 0;
var CorrectAnswer = 0;
var scoreResult = 0;
$("#resultLabData_" + windowviewid + " tr td:nth-child(3)").each(function () {
if ($(this).text() == "Incorrect") {
inCorrectAnswer = inCorrectAnswer + 1;
}
else {
CorrectAnswer = CorrectAnswer + 1;
}
});
$('#tdCorrectAnswer_' + windowviewid).text(CorrectAnswer);
$('#tdinCorrectAnswer_' + windowviewid).text(inCorrectAnswer);
scoreResult = Math.round((parseInt(CorrectAnswer) / parseInt(TotalNumberofQuiz)) * 100);
$('#scoreResult_' + windowviewid).text(scoreResult);
$("#resultLabData_" + windowviewid + " tr td:nth-child(2)").each(function (key, value) {
if ($(this).text().length == 1 || $(this).text() == "undefined") {
var a = parseInt($(this).prev().text()) - 1;
$(this).text(LabExerciseData.LabExercise[0].Questions[a].activityTitle);
}
});
}
$scope.ReportGen = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$("#submitResultHtml_" + windowviewid).css("display", "block");
$("#questionHtml_" + windowviewid).css("display", "none");
var LabExerciseName = $scope.GetLEwindowStoreData(windowviewid, 'currentViewTitle');
$('#reporttitle_' + windowviewid).text(LabExerciseName);
}
$scope.handleDragStart = function (e) {
this.style.opacity = '0.4';
if ($.browser.msie) {
localStorage.setItem("text", this.innerHTML);
}
else {
e.dataTransfer.setData('text/plain', this.innerHTML);
}
var dragableId = $(this).attr("Id");
var id = $(this).attr("id");
var droppedID = dragableId.split("-")[0];
var textBoxName = (dragableId.split("-")[1]);
var windowviewid = (dragableId.split("-")[1]).split("_")[1];
$scope.SetLEwindowStoreData(windowviewid, 'TextDropId', dragableId);
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
if (droppedID != 'block') {
var draggableAttribute = $("#" + dragableId).attr("draggedattr");
$scope.SetLEwindowStoreData(windowviewid, 'draggableAttribute', draggableAttribute);
}
else {
$scope.SetLEwindowStoreData(windowviewid, 'draggableAttribute', '');
// $scope.draggableAttribute = '';
}
if ($("#textblock_" + windowviewid).css("display") == "block") {
// when no image path on question
var droppableAttribute = $("#blockbox-" + textBoxName).attr("dropdattr");
$scope.SetLEwindowStoreData(windowviewid, 'droppableAttribute', droppableAttribute);
}
var LabExerciseData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseData');
//if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer
if (dragableId.indexOf('T') != -1) {
var optionText = document.getElementById(dragableId).innerHTML;
var currentQuizData = new jinqJs()
.from(LabExerciseData.LabExercise[0].Questions)
.where('Number == ' + quiznumber)
.select();
var optionData = new jinqJs()
.from(currentQuizData[0].Options)
.where('OptionTitle == ' + optionText)
.select();
var option = optionData[0].OptionNumber;
}
};
$scope.handleDragEnd = function (e) {
this.style.opacity = '1.0';
};
$scope.handleDrop = function (e) {
e.preventDefault();
e.stopPropagation();
var id = $(this).attr("id");
if (id.match("divoptions")) {
var droppedID = id.split("-")[0];
var BlockBoxName = (id.split("-")[1]);//get undefined
var windowviewid = (id.split("_")[1]);
}
else {
var droppedID = id.split("-")[0];
var BlockBoxName = (id.split("-")[1]);
var windowviewid = (id.split("-")[1]).split("_")[1];
}
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
var dragableId = $scope.GetLEwindowStoreData(windowviewid, 'TextDropId');
var dragOptionId = (dragableId.split("-")[0]);
var dragOptionName = (dragableId.split("-")[1]);
var draggableAttribute = $scope.GetLEwindowStoreData(windowviewid, 'draggableAttribute');
var droppableAttribute = $scope.GetLEwindowStoreData(windowviewid, 'droppableAttribute');
var x = $("#imgdrop_" + windowviewid).offset();
var keywords = $scope.GetLEwindowStoreData(windowviewid, 'keywords');
if ($.browser.msie) {
var dataText = localStorage.getItem("text");
localStorage.setItem("text", '');
}
else {
var dataText = e.dataTransfer.getData('text/plain');
}
// dynamic scope name used in repeat collection
var dynamicDragList = 'DraggedList' + windowviewid;
if (id == "divoptions_" + windowviewid) {
dragtext = $('#' + dragableId).html();
var labExerciseModulePath = '~/../content/data/json/le/' + keywords + '.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
$.each(result.LabExercise, function (index, value) {
if (result.LabExercise[index].Slug == keywords) {
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == quiznumber) {
var Options = result.LabExercise[index].Questions[index1].Options;
$.each(Options, function (inx, value2) {
if (Options[inx].OptionTitle == dragtext) {
if ($scope[dynamicDragList] != null) {
var UserAttemptQption = [];
UserAttemptQption = $scope.GetLEwindowStoreData(windowviewid, 'UserAttempt');
$.each($scope[dynamicDragList], function (inx1, value3) {
UserAttemptQption.push({ "BlankBoxName": BlockBoxName, "OptionName": dragOptionName });
var DraggedAttr = $scope[dynamicDragList][inx1].DraggedAttr;
console.log("drag box id:" + DraggedAttr);
if (DraggedAttr == draggableAttribute) {
$rootScope.UnsaveCurriculum = true;
$scope.SetLEwindowStoreData(windowviewid, 'isLabExChanged', true);
$scope[dynamicDragList].splice(inx1, 1);
$('#' + draggableAttribute).css({ "display": "block", "color": "#000000!important" });
$('#blockans-' + dragOptionName).css("background-color", "transparent !important");
if ($("#textblock_" + windowviewid).css("display") == "block") {
$('#blockbox-' + dragOptionName).removeAttr("dropdattr");
}
return false;
}
});
}
}
});
}
});
}
});
},
function (error) {
console.log(error.statusText)
}
)
}
else {
if ($("#textblock_" + windowviewid).css("display") == "block") {
if ($("#" + id).attr("dropdattr") == undefined) {
$(this).each(function (key, value) {
if (droppedID == 'blockbox') {
var labExerciseModulePath = '~/../content/data/json/le/' + keywords + '.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
$.each(result.LabExercise, function (index, value) {
if (result.LabExercise[index].Slug == keywords) {
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == quiznumber) {
var Options = result.LabExercise[index].Questions[index1].OptionBox;
$.each(Options, function (inx, value2) {
if (Options[inx].BoxName == BlockBoxName.split("_")[0]) {
$rootScope.UnsaveCurriculum = true;
$scope.SetLEwindowStoreData(windowviewid, 'isLabExChanged', true);
if ($scope[dynamicDragList] != null) {
for (var i = 0; i <= $scope[dynamicDragList].length - 1; i++) {
if ($scope[dynamicDragList][i].Value == undefined) {
i = 0;
continue;
}
if ($scope[dynamicDragList][i].DraggedAttr == draggableAttribute) {
$scope[dynamicDragList].splice(i, 1);
}
}
}
var UserAttemptQption = [];
UserAttemptQption = $scope.GetLEwindowStoreData(windowviewid, 'UserAttempt');
UserAttemptQption.push({ "BlankBoxName": BlockBoxName, "OptionName": dragOptionName });
if (dragOptionId == 'block') {
$scope[dynamicDragList].push({ "DraggedAttr": dragableId, "blockID": dragableId, "id": BlockBoxName, "optionName": BlockBoxName, "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord });
}
else {
$scope[dynamicDragList].push({ "DraggedAttr": draggableAttribute, "blockID": dragableId, "id": BlockBoxName, "optionName": BlockBoxName, "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord });
}
$('#' + dragableId).css("display", "none");
$('#blockans-' + Options[inx].OptionNumber + '_' + windowviewid).css("background-color", "transparent !important");
if (dragOptionId == 'block') {
$timeout(function () {
$('#blockans-' + BlockBoxName).attr("draggedAttr", dragableId);
}, 350);
}
else {
$timeout(function () {
$('#blockans-' + BlockBoxName).attr("draggedAttr", draggableAttribute);
}, 350);
}
$('#blockbox-' + BlockBoxName).attr("dropdAttr", 'blockans-' + BlockBoxName);
if (droppableAttribute != '' && droppableAttribute != undefined) {
$('#blockbox-' + droppableAttribute.split('-')[1]).removeAttr("dropdattr");
}
// console.log($scope[dynamicDragList]);
// $scope.a = $scope.dragableId;
}
});
}
});
}
});
},
function (error) {
console.log(error.statusText)
}
)
}
});
}
}
else {
$(this).each(function (key, value) {
if (droppedID == 'blockbox') {
var labExerciseModulePath = '~/../content/data/json/le/' + keywords + '.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
$.each(result.LabExercise, function (index, value) {
if (result.LabExercise[index].Slug == keywords) {
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == quiznumber) {
var Options = result.LabExercise[index].Questions[index1].OptionBox;
$.each(Options, function (inx, value2) {
if (Options[inx].BoxName == BlockBoxName.split("_")[0]) {
$rootScope.UnsaveCurriculum = true;
$scope.SetLEwindowStoreData(windowviewid, 'isLabExChanged', true);
if ($scope[dynamicDragList] != null) {
for (var i = 0; i <= $scope[dynamicDragList].length - 1; i++) {
if ($scope[dynamicDragList][i].Value == undefined) {
i = 0;
continue;
}
if ($scope[dynamicDragList][i].DraggedAttr == draggableAttribute) {
$scope[dynamicDragList].splice(i, 1);
}
}
}
var UserAttemptQption = [];
UserAttemptQption = $scope.GetLEwindowStoreData(windowviewid, 'UserAttempt');
UserAttemptQption.push({ "BlankBoxName": BlockBoxName, "OptionName": dragOptionName });
if (dragOptionId == 'block') {
$scope[dynamicDragList].push({ "DraggedAttr": dragableId, "blockID": dragableId, "id": BlockBoxName, "optionName": BlockBoxName, "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord });
}
else {
$scope[dynamicDragList].push({ "DraggedAttr": draggableAttribute, "blockID": dragableId, "id": BlockBoxName, "optionName": BlockBoxName, "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord });
}
$('#' + dragableId).css("display", "none");
$('#blockans-' + Options[inx].OptionNumber + '_' + windowviewid).css("background-color", "transparent !important");
if (dragOptionId == 'block') {
$timeout(function () {
$('#blockans-' + BlockBoxName).attr("draggedAttr", dragableId);
}, 350);
}
else {
$timeout(function () {
$('#blockans-' + BlockBoxName).attr("draggedAttr", draggableAttribute);
}, 350);
}
$('#blockbox-' + BlockBoxName).attr("dropdAttr", 'blockans-' + BlockBoxName);
console.log($scope[dynamicDragList]);
// $scope.a = $scope.dragableId;
}
});
}
});
}
});
},
function (error) {
console.log(error.statusText)
}
)
}
});
}
}
$scope.$apply();
$timeout(function () {
if ($("#textblock_" + windowviewid).css("display") == "block") {
$("#imgdiv_" + windowviewid).css("position", "static");
$("#imgdiv_" + windowviewid).find("div").each(function () {
var answerDiv = $(this).attr("id").split("-");
if (answerDiv[0] == "blockans") {
var concatID = answerDiv[0] + "-" + answerDiv[1];
$("#" + concatID).css("width", "auto");
}
});
}
else {
$("#imgdiv_" + windowviewid).css("position", "relative");
}
}, 350);
};
$scope.minLabExPanel = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
if ($('#questionHtml_' + windowviewid).css('display') === 'block') {
$("#questionHtml_" + windowviewid).css("display", "none");
$scope.SetLEwindowStoreData(windowviewid, 'isResultVisible', false);
}
else {
$("#submitResultHtml_" + windowviewid).css("display", "none");
$scope.SetLEwindowStoreData(windowviewid, 'isResultVisible', true);
}
$("#LabExPageHeading_" + windowviewid).css("display", "none");
$("#LabExMinimizedId_" + windowviewid).css("display", "block");
}
$scope.maxLabExPanel = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
var isResultVisible = $scope.GetLEwindowStoreData(windowviewid, 'isResultVisible');
if (isResultVisible == true) {
$("#submitResultHtml_" + windowviewid).css("display", "block");
}
else {
$("#questionHtml_" + windowviewid).css("display", "block");
}
$("#LabExPageHeading_" + windowviewid).css("display", "block");
$("#LabExMinimizedId_" + windowviewid).css("display", "none");
}
$scope.handleDragOver = function (e) {
e.preventDefault(); // Necessary. Allows us to drop.
e.dataTransfer.dropEffect = 'move'; // See the section on the DataTransfer object.
//return false;
};
$scope.OnResetClick = function ($event) {
$rootScope.UnsaveCurriculum = true;
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$scope.SetLEwindowStoreData(windowviewid, 'isResetClicked', true);
$scope.resetQuiz(windowviewid);
}
$scope.resetQuiz = function (windowviewid) {
// dynamic scope name used in repeat collection
var dynamicDragList = 'DraggedList' + windowviewid;
$scope[dynamicDragList] = [];
$scope.SetLEwindowStoreData(windowviewid, 'UserAttempt', []);
$scope.SetLEwindowStoreData(windowviewid, 'isLabExChanged', true);
$scope.GetQuizByTopic(windowviewid);
};
$scope.ReviewAttempt = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
var keywords = $scope.GetLEwindowStoreData(windowviewid, 'keywords');
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
var labExerciseModulePath = '~/../content/data/json/le/' + keywords + '.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
$.each(result.LabExercise, function (index, value) {
if (result.LabExercise[index].Slug == keywords) {
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == quiznumber) {
var correctResponse = result.LabExercise[index].Questions[index1].correctResponse;
var Options = result.LabExercise[index].Questions[index1].Options;
$.each(correctResponse, function (inx, value2) {
if (correctResponse[inx].Answer.indexOf('|') != -1) {
var multipleanswer = correctResponse[inx].Answer.split('|');
option = multipleanswer[0];
}
else
option = correctResponse[inx].Answer;
var options = new jinqJs()
.from(Options)
.where('OptionNumber == ' + option)
.select();
var optionText = options[0].OptionTitle;
var OptionName = "";
$.each(Options, function (inx1, value3) {
if (optionText == $('#blockans-' + correctResponse[inx].OptionBox + '_' + windowviewid).text()) {
OptionName = option;
}
});
if (option == OptionName) {
blReviewAttempt = true;
}
else {
blReviewAttempt = false;
$('#blockans-' + correctResponse[inx].OptionBox + '_' + windowviewid).css("background", "#ff4e00");
}
});
}
});
}
});
},
function (error) {
console.log(error.statusText)
}
)
};
$scope.ShowHideDiv = function (status, windowviewid) {
if (status == "bottom") {
$("#divright").css("display", "none");
$("#divleft").css("display", "none");
$("#divoptions_" + windowviewid).css("display", "block");
}
else {
$("#divright").css("display", "block");
$("#divleft").css("display", "block");
$("#divoptions_" + windowviewid).css("display", "none");
}
};
// save also from curriculum while slide change,export and save cb
$rootScope.SaveAnswer = function ($event,windowviewid) {
if(windowviewid==undefined)
{
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$rootScope.UnsaveCurriculum = true;
}
$scope.DisableLabUI(windowviewid);
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
$scope.CreateLabExerciseDataToSave(windowviewid, quiznumber);
var ExeciseIdentifier = $scope.GetLEwindowStoreData(windowviewid, 'labExeIdentifier');
var TotalNumberofQuiz = $scope.GetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz');
var LabExerciseUserData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseUserData');
var LastQuestion = $scope.GetLEwindowStoreData(windowviewid, 'LastQuestion');
var userloginid = $scope.GetLEwindowStoreData(windowviewid, 'userloginid');
//remore panelid
for(i=0;i 0) {
angular.forEach(LabExerciseUserData, function (value, key) {
if (value.QuestionNo == LabExerciseAttemptedData.QuestionNo) {
}
else {
lbData.push(value);
}
})
LabExerciseUserData = [];
lbData.push(LabExerciseAttemptedData);
angular.forEach(lbData, function (value1, key1) {
LabExerciseUserData.push(value1);
})
}
else
LabExerciseUserData.push(LabExerciseAttemptedData);
$scope.SetLEwindowStoreData(windowviewid, 'usersCorrectQuestData', []);
var usersCorrectQuestData = [];
if (LabExerciseUserData.length > 0) {
for (var i = 0; i <= LabExerciseUserData.length - 1; i++) {
if (LabExerciseUserData[i].MaxScore == LabExerciseUserData[i].Score) {
usersCorrectQuestData.push({
MaxScore: LabExerciseUserData[i].MaxScore,
UserAnswer: LabExerciseUserData[i].UserAnswer,
QuestionNo: LabExerciseUserData[i].QuestionNo,
CorrectAnswer: JSON.stringify(LabExerciseUserData[i].CorrectAnswer),
DragItems: LabExerciseUserData[i].DragItems,
Score: LabExerciseUserData[i].Score,
title: LabExerciseUserData[i].title,
CorrectStatus: 'Correct'
});
}
else {
usersCorrectQuestData.push({
MaxScore: LabExerciseUserData[i].MaxScore,
UserAnswer: LabExerciseUserData[i].UserAnswer,
QuestionNo: LabExerciseUserData[i].QuestionNo,
CorrectAnswer: JSON.stringify(LabExerciseUserData[i].CorrectAnswer),
DragItems: LabExerciseUserData[i].DragItems,
Score: LabExerciseUserData[i].Score,
title: LabExerciseUserData[i].title,
CorrectStatus: 'Incorrect'
});
}
}
}
else {
if (MaxScore == Score) {
usersCorrectQuestData.push({
MaxScore: MaxScore,
UserAnswer: commaSeperatedUserAnswers,
QuestionNo: quiznumber,
CorrectAnswer: JSON.stringify(correctResponseForSavingDatabase),
DragItems: DragItems,
Score: Score,
title: activityTitle,
CorrectStatus: 'Correct'
});
}
else {
usersCorrectQuestData.push({
MaxScore: MaxScore,
UserAnswer: commaSeperatedUserAnswers,
QuestionNo: quiznumber,
CorrectAnswer: JSON.stringify(correctResponseForSavingDatabase),
DragItems: DragItems,
Score: Score,
title: activityTitle,
CorrectStatus: 'Incorrect'
});
}
}
$scope.SetLEwindowStoreData(windowviewid, 'usersCorrectQuestData', usersCorrectQuestData);
$scope.SetLEwindowStoreData(windowviewid, 'LabExerciseUserData', LabExerciseUserData);
}
$scope.reviewAttemptAnswer = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
quiznumber = ($event.target.id).split("_")[len - 2];
$scope.SetLEwindowStoreData(windowviewid, 'quiznumber', quiznumber);
$('#quizNo_' + windowviewid).text(quiznumber);
// $scope.isReviewBtnSelected = true;
$scope.SetLEwindowStoreData(windowviewid, 'isReviewBtnSelected', true);
$("#reviewBtn_" + windowviewid).css("display", "none");
$("#resetBtn_" + windowviewid).css("display", "none");
$("#saveBtn_" + windowviewid).css("display", "none");
$("#submitResultHtml_" + windowviewid).css("display", "none");
$("#questionHtml_" + windowviewid).css("display", "block");
$("#reportBtn_" + windowviewid).css("display", "block");
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
$scope.SetLEwindowStoreData(windowviewid, 'TextDropId', '');
$scope.resetQuiz(windowviewid);
}
$scope.CloseReport = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$scope.SetLEwindowStoreData(windowviewid, 'isReviewBtnSelected', false);
$("#reviewBtn_" + windowviewid).css("display", "block");
$("#resetBtn_" + windowviewid).css("display", "block");
$("#saveBtn_" + windowviewid).css("display", "block");
$("#submitResultHtml_" + windowviewid).css("display", "none");
$("#questionHtml_" + windowviewid).css("display", "block");
$("#reportBtn_" + windowviewid).css("display", "none");
$("#quizSubmitBtn_" + windowviewid).css("display", "block");
}
$scope.getUserAnswers = function (windowviewid) {
var userAnswers = [];
var blockBoxes = $("div[id*='blockbox']");
var blockBoxesNew = [];
for (var i = 0; i < blockBoxes.length; i++) {
var len = (blockBoxes[i].id).split("_").length;
var selectedWinId = (blockBoxes[i].id).split("_")[len - 1];
if (windowviewid == selectedWinId) {
blockBoxesNew.push(blockBoxes[i]);
}
}
var blockBoxesInTextBlock = $("#textblock_" + windowviewid).children();
var blockBoxLength = blockBoxesNew.length - blockBoxesInTextBlock.length;
var blockAnswers = $("div[id*='blockans']");
var blockAnswersNew = [];
for (var i = 0; i < blockAnswers.length; i++) {
var len = (blockAnswers[i].id).split("_").length;
var selectedWinId = (blockAnswers[i].id).split("_")[len - 1];
if (windowviewid == selectedWinId) {
blockAnswersNew.push(blockAnswers[i]);
}
}
for (var i = 0; i < blockAnswersNew.length; i++) {
var id = ((blockAnswersNew[i].id).split('-')[1]).split('_')[0];
userAnswers[id.replace('T', '')] = blockAnswersNew[i].innerHTML;
}
$scope.SetLEwindowStoreData(windowviewid, 'commaSeperatedUserAnswers', '');
var commaSeperatedUserAnswers = '';
for (var i = 1; i <= blockBoxLength; i++) {
var userAns = userAnswers[i];
if (userAns != undefined) {
commaSeperatedUserAnswers += userAns + ',';
}
else {
commaSeperatedUserAnswers += '' + ',';
}
}
//remove last comma
commaSeperatedUserAnswers = commaSeperatedUserAnswers.replace(/,$/, '');
$scope.SetLEwindowStoreData(windowviewid, 'commaSeperatedUserAnswers', commaSeperatedUserAnswers);
}
$scope.getCorrectResponse = function (windowviewid, quiznumber) {
var LabExerciseData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseData');
var correctResponse = '';
var correctResponseForSavingDatabase = '';
var cr = new jinqJs()
.from(LabExerciseData.LabExercise[0].Questions)
.where('Number == ' + quiznumber)
.select();
for (var i = 0; i < cr[0].correctResponse.length; i++) {
var blankBox = cr[0].correctResponse[i].OptionBox;
var option;
if (cr[0].correctResponse[i].Answer.indexOf('|') != -1) {
var multipleanswer = cr[0].correctResponse[i].Answer.split('|');
option = multipleanswer[0];
}
else
option = cr[0].correctResponse[i].Answer;
var options = new jinqJs()
.from(cr[0].Options)
.where('OptionNumber == ' + option)
.select();
var optionText = options[0].OptionTitle;
correctResponse += blankBox + ' ' + cr[0].correctResponse[i].Answer + ',';
correctResponseForSavingDatabase += parseInt(blankBox.replace('T', '')) - 1 + ':' + optionText + ',';
}
correctResponse = correctResponse.replace(/,$/, '');
var correctResonseKeyValue = correctResponse.split(',');
$scope.SetLEwindowStoreData(windowviewid, 'correctResonseKeyValue', correctResonseKeyValue);
correctResponseForSavingDatabase = correctResponseForSavingDatabase.replace(/,$/, '');
$scope.SetLEwindowStoreData(windowviewid, 'correctResponseForSavingDatabase', correctResponseForSavingDatabase);
}
$scope.getDragItems = function (windowviewid) {
var OptionBoxes = $("div[id*='block-']");
var DragItems = '';
for (var i = 0; i < OptionBoxes.length; i++) {
var len = (OptionBoxes[i].id).split("_").length;
var selectedWinId = (OptionBoxes[i].id).split("_")[len - 1];
if (windowviewid == selectedWinId)
{
DragItems += OptionBoxes[i].id.replace('block-', '') + ',' + OptionBoxes[i].innerHTML + ';';
}
}
DragItems = DragItems.replace(/;$/, '');
$scope.SetLEwindowStoreData(windowviewid, 'DragItems', DragItems);
}
$scope.getScore = function (windowviewid) {
var UserAttemptQption = [];
UserAttemptQption = $scope.GetLEwindowStoreData(windowviewid, 'UserAttempt');
$scope.SetLEwindowStoreData(windowviewid, 'Score', 0);
var scorecount = 0;
var correctResonseKeyValue = $scope.GetLEwindowStoreData(windowviewid, 'correctResonseKeyValue');
angular.forEach(UserAttemptQption, function (value, key) {
var userOptedAnswer = value.BlankBoxName.split('_')[0] + ' ' + value.OptionName.split('_')[0];
for (var i = 0; i < correctResonseKeyValue.length; i++) {
if (correctResonseKeyValue[i].indexOf('|') != -1) {
var splitedOption = correctResonseKeyValue[i].split(' ');
var multipleanswer = splitedOption[1].split('|');
var opt1 = splitedOption[0] + ' ' + multipleanswer[0]; correctResonseKeyValue
var opt2 = splitedOption[0] + ' ' + multipleanswer[1];
if (userOptedAnswer == opt1 || userOptedAnswer == opt2) {
scorecount += 1;
}
}
else {
if (userOptedAnswer == correctResonseKeyValue[i]) {
scorecount += 1;
}
}
}
});
$scope.SetLEwindowStoreData(windowviewid, 'Score', scorecount);
}
$scope.ShowSavedLabExercise = function (windowviewid) {
//from database
var quiznumber = $scope.GetLEwindowStoreData(windowviewid, 'quiznumber');
var lastQuestion = quiznumber;
var lastQuestionDetails;
var lastQuestionAnswers;
var blockIds = [];
var TotalNumberofQuiz = $scope.GetLEwindowStoreData(windowviewid, 'TotalNumberofQuiz');
var LabExerciseData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseData');
var LabExerciseUserData = $scope.GetLEwindowStoreData(windowviewid, 'LabExerciseUserData');
var SavedLabExercise = $scope.GetLEwindowStoreData(windowviewid, 'SavedLabExercise');
// dynamic scope name used in repeat collection
var dynamicDragList = 'DraggedList' + windowviewid;
//if user opted this question, it will have entry in LabExerciseUserData
if (LabExerciseUserData != undefined) {
var thisQuestiondataInLabExerciseUserData = new jinqJs()
.from(LabExerciseUserData)
.where('QuestionNo == ' + quiznumber)
.select();
}
//if this exists in LabExerciseUserData, show the new opted else show from database
var isFromDB = false;
if (thisQuestiondataInLabExerciseUserData != undefined && thisQuestiondataInLabExerciseUserData.length > 0) {
lastQuestionDetails = thisQuestiondataInLabExerciseUserData;
if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0)
lastQuestionAnswers = lastQuestionDetails[0].UserAnswer.split(',');
}
else {
if (SavedLabExercise !=undefined && SavedLabExercise.lastQuestion > 0) {
isFromDB = true;
lastQuestionDetails = new jinqJs()
.from(SavedLabExercise.labExercise)
.where('QuestionNo == ' + lastQuestion)
.select();
if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0)
lastQuestionAnswers = lastQuestionDetails[0].UserAnswers.split(',');
}
}
if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0) {
var QustionAnsKeyValue = [];
for (var i = 0; i < lastQuestionAnswers.length; i++) {
var num = i + 1;
QustionAnsKeyValue.push({ blockbox: 'T' + num, text: lastQuestionAnswers[i] });
if (isFromDB) {
if (lastQuestionAnswers[i] != "") {
var blocks = $("div[id*='block-']");
for (var j = 0; j < blocks.length; j++) {
var len = (blocks[j].id).split("_").length;
var selectedWinId = (blocks[j].id).split("_")[len - 1];
if (windowviewid == selectedWinId) {
if ((blocks[j].innerHTML).toString() == lastQuestionAnswers[i]) {
if ($('#' + blocks[j].id).css('display').toLowerCase() == 'block') {
$('#' + blocks[j].id).css("display", "none");
break;
}
};
}
}
}
}
}
if (lastQuestionDetails != undefined && lastQuestionDetails.length > 0 && !isFromDB) {
var dragList = lastQuestionDetails[0].DragList;
var blocks = $("div[id*='block-']");
angular.forEach(dragList, function (v, k) {
for (var j = 0; j < blocks.length; j++) {
var len = (blocks[j].id).split("_").length;
var selectedWinId = (blocks[j].id).split("_")[len - 1];
if (windowviewid == selectedWinId) {
if ((blocks[j].innerHTML).toString() == v.Value) {
if ($('#' + blocks[j].id).css('display').toLowerCase() == 'block') {
$('#' + blocks[j].id).css("display", "none");
break;
}
};
}
}
})
}
var labQuestionData = new jinqJs()
.from(LabExerciseData.LabExercise[0].Questions)
.where('Number == ' + lastQuestion)
.select();
if (QustionAnsKeyValue != undefined) {
angular.forEach(QustionAnsKeyValue, function (value, key) {
var questionOptionBox = new jinqJs()
.from(labQuestionData[0].OptionBox)
.where('BoxName == ' + value.blockbox)
.select();
if (value.text != "") {
var OptionList = new jinqJs()
.from(labQuestionData[0].Options)
.where('OptionTitle == ' + value.text)
.select();
var blockId = 'block-' + OptionList[0].OptionNumber;
if (OptionList != undefined && OptionList.length > 1 && blockIds.indexOf(blockId) != -1) {
blockId = 'block-' + OptionList[1].OptionNumber;
}
blockIds.push(blockId);
$scope[dynamicDragList].push({ "DraggedAttr": blockId + '_' + windowviewid, "blockID": blockId + '_' + windowviewid, "id": value.blockbox + '_' + windowviewid, "optionName": value.blockbox + '_' + windowviewid, "Value": value.text, "topcoord": questionOptionBox[0].topcoord, "leftcoord": questionOptionBox[0].leftcoord });
$timeout(function () {
if ($("#textblock_" + windowviewid).css("display") == "block") {
$("#imgdiv_" + windowviewid).css("position", "static");
$("#imgdiv_" + windowviewid).find("div").each(function () {
var answerDiv = $(this).attr("id").split("-");
if (answerDiv[0] == "blockans") {
var concatID = answerDiv[0] + "-" + answerDiv[1];
$("#" + concatID).css("width", "auto");
}
});
for (var i = 0; i <= $scope[dynamicDragList].length - 1; i++) {
$('#blockbox-' + $scope[dynamicDragList][i].optionName).attr("dropdattr", "blockans-" + $scope[dynamicDragList][i].optionName + "")
}
}
else {
$("#imgdiv_" + windowviewid).css("position", "relative");
}
$scope.EnableLabUI(windowviewid);
}, 500);
}
})
}
}
if (lastQuestion == TotalNumberofQuiz) {
var isReviewBtnSelected = $scope.GetLEwindowStoreData(windowviewid, 'isReviewBtnSelected');
if (isReviewBtnSelected == true) {
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
}
else {
$("#quizSubmitBtn_" + windowviewid).css("display", "block");
}
}
else {
$("#quizSubmitBtn_" + windowviewid).css("display", "none");
}
$scope.EnableLabUI(windowviewid);
}
$scope.SendLabEXMailToUser = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
var reportCopyStatus = $("#chkCopy_" + windowviewid).prop("checked");// document.getElementById("#chkCopy_" + windowviewid).checked ;
var receiverEmails = $("#emailTo_" + windowviewid).val();
var senderEmails = receiverEmails.split(",");
var isSenderEmailValid = false;
var isReceiverEmailValid = false;
var isUserNameValid = false;
for (var i = 0; i <= senderEmails.length - 1; i++) {
var sEmail = $.trim(senderEmails[i]);
if (sEmail.length == 0) {
isSenderEmailValid = false;
$("#alertPopUp_" + windowviewid).css("display", "block");
$("#messageBody_" + windowviewid).text("Email Address is empty");
return false;
}
if ($scope.validateEmail(sEmail, windowviewid)) {
isSenderEmailValid = true;
}
else {
isSenderEmailValid = false;
$("#alertPopUp_" + windowviewid).css("display", "block");
$("#messageBody_" + windowviewid).text("Email Address is not valid");
return false;
}
}
var userName = $("#userName_" + windowviewid).val();
if (userName.length == 0 || userName == 'undefined' || userName == ' ') {
$("#alertPopUp_" + windowviewid).css("display", "block");
$("#messageBody_" + windowviewid).text("Please enter your name");
isUserNameValid = false;
return false;
}
var filterName = /^([a-zA-Z]+\s?)*$/;
if (filterName.test(userName)) {
isUserNameValid = true;
}
else
{
$("#alertPopUp_" + windowviewid).css("display", "block");
$("#messageBody_" + windowviewid).text("Your Name is not valid");
isUserNameValid = false;
return false;
}
var yourEmail = $("#userEmailID_" + windowviewid).val();
var rEmail = yourEmail;
if ($.trim(rEmail).length == 0)
{
isReceiverEmailValid = false;
$("#alertPopUp_" + windowviewid).css("display", "block");
$("#messageBody_" + windowviewid).text("Your Email Address is empty");
return false;
}
if ($scope.validateEmail(rEmail))
{
isReceiverEmailValid = true;
}
else
{
isReceiverEmailValid = false;
$("#alertPopUp_" + windowviewid).css("display", "block");
$("#messageBody_" + windowviewid).text("Your Email Address is not valid");
return false;
}
// email validation code ends
if (isSenderEmailValid == true && isReceiverEmailValid == true && isUserNameValid == true) {
var reportHtml = '';
reportHtml += 'Question | Activity Title | Status | ';
$("#resultLabData_" + windowviewid + " tr").each(function () {
reportHtml += '';
$(this).children("td").each(function () {
if ($(this).text() == " Review") {
}
else {
reportHtml += '' + $(this).text() + ' | ';
}
});
reportHtml += '
';
});
reportHtml += '
';
if ($("#emailComment_" + windowviewid).val() == undefined || $("#emailComment_" + windowviewid).val() == "") {
var reportImage = "Name: " + userName + "
" + $("#submitResultHtml_" + windowviewid + " .panel-heading .row div:nth-child(1)").text() + " | Performance Report | " + $("#submitResultHtml_" + windowviewid + " .panel-heading .row div:nth-child(3)").text() + " |
Total Question | Correct Answers | Incorrect Answers | " + $("#questionStatus_" + windowviewid + " tbody tr td:nth-child(1)").text() + " | " + $("#questionStatus_" + windowviewid + " tbody tr td:nth-child(2)").text() + " | " + $("#questionStatus_" + windowviewid + " tbody tr td:nth-child(3)").text() + " |
" + reportHtml + "";
}
else {
var reportImage = "Name: " + userName + "
" + $("#emailComment_" + windowviewid).val() + "
" + $("#submitResultHtml_" + windowviewid + " .panel-heading .row div:nth-child(1)").text() + " | Performance Report | " + $("#submitResultHtml_" + windowviewid + " .panel-heading .row div:nth-child(3)").text() + " |
Total Question | Correct Answers | Incorrect Answers | " + $("#questionStatus_" + windowviewid + " tbody tr td:nth-child(1)").text() + " | " + $("#questionStatus_" + windowviewid + " tbody tr td:nth-child(2)").text() + " | " + $("#questionStatus_" + windowviewid + " tbody tr td:nth-child(3)").text() + " |
" + reportHtml + "";
}
var reportTitleName = "Lab Exercise Report for " + $("#submitResultHtml_" + windowviewid + " .panel-heading .row div:nth-child(1)").text();
var User = {
"Name": userName,
"EmailAdd": yourEmail,
"reportImage": reportImage,
"reportTitle": reportTitleName,
"ReportCheck": reportCopyStatus,
"EmailTo": receiverEmails,
};
LabExerciseService.LabExerciseReport(User).then(
function (result) {
if (result == "True") {
$rootScope.closeLabExEmailModel("", windowviewid);
document.getElementById('labExEmailSentModalID_' + windowviewid).style.display = "block";
document.getElementById('labExModalbackground_' + windowviewid).style.display = "block";
}
else {
$rootScope.closeLabExEmailModel("", windowviewid);
var message = LoginConstants.MAIL_NOT_SENT
$('#errorMessage').text(message);
$("#messageModal").modal('show');
$('#messageModal').css('z-index', '12000001');
}
console.log(result);
},
function (error) {
var message = LoginConstants.MAIL_NOT_SENT
$('#errorMessage').text(message);
$("#messageModal").modal('show');
$('#messageModal').css('z-index', '12000001');
console.log(error.statusText);
}
)
}
}
$scope.labExModalClose = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
$("#alertPopUp_" + windowviewid).css("display", "none");
}
$scope.validateEmail = function (sEmail) {
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(sEmail)) {
return true;
}
else {
return false;
}
}
$rootScope.closeLabExEmailModel = function ($event, windowviewid) {
if (windowviewid == undefined) {
var len = ($event.currentTarget.id).split("_").length;
var windowviewid = ($event.currentTarget.id).split("_")[len - 1];
}
document.getElementById("LabExerciseForm_" + windowviewid).reset();
$scope.LabExForm.$setPristine();
$scope.LabExForm.$setUntouched();
document.body.style.overflow = "scroll";
document.getElementById('labExModalbackground_' + windowviewid).style.display = "none";
document.getElementById('labExModalID_' + windowviewid).style.display = "none";
// $scope.reportCopyStatus = false;
$("#chkCopy_" + windowviewid).prop('checked', false);
}
$rootScope.sendMail = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
window.scrollTo(0, 0);
document.body.style.overflow = "hidden";
$("#chkCopy_" + windowviewid).prop('checked', false);
document.getElementById('labExModalbackground_' + windowviewid).style.display = "block";
document.getElementById('labExModalID_' + windowviewid).style.display = "block";
}
$rootScope.emailNotification = function ($event) {
var len = ($event.target.id).split("_").length;
var windowviewid = ($event.target.id).split("_")[len - 1];
document.getElementById('labExEmailSentModalID_' + windowviewid).style.display = "none";
document.getElementById('labExModalbackground_' + windowviewid).style.display = "none";
}
}]
);
AIA.directive('draggable', function () {
return {
link: function ($scope, element, attrs) {
element[0].addEventListener('dragstart', $scope.handleDragStart, false);
element[0].addEventListener('dragend', $scope.handleDragEnd, false);
}
}
});
AIA.directive('droppable', function () {
return {
link: function ($scope, element, attrs) {
element[0].addEventListener('drop', $scope.handleDrop, false);
element[0].addEventListener('dragover', $scope.handleDragOver, false);
}
}
});
AIA.directive('imageonload', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.bind('load', function (e) {
var len = (e.target.id).split("_").length;
var windowviewid = (e.target.id).split("_")[len - 1];
$('#imgdiv_' + windowviewid).css('width', this.naturalWidth + "px");
});
element.bind('error', function () {
});
}
};
});