diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
index bd8e590..93b8d4d 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
@@ -1,6 +1,6 @@
///
-AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce',"$compile","$location",
-function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location) {
+AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService",
+function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService) {
$scope.$sce = $sce;
$scope.LabExerciseName;
$scope.LabExerciseQuiz = null;
@@ -10,13 +10,14 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$scope.Title = "";
$scope.Imagepath = "";
$scope.DraggedList = [];
+ $scope.UserAttempt = [];
+ $scope.UserAnswersForAllQuestions = [];
+ $scope.LabExerciseUserData = [];
+ $scope.LabExercise = [];
$scope.dragableId = "";
+ $scope.UserAttempt = [];
$scope.blReviewAttempt = false;
$scope.$on('$viewContentLoaded', function (event) {
-
- if ($rootScope.refreshcheck == null) {
- $location.path('/');
- }
// code that will be executed ...
// every time this view is loaded
@@ -31,7 +32,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$rootScope.currentActiveModuleTitle = selectedModuleName;
})
- $scope.showTabButton = false;
+ $scope.showme = false;
$rootScope.currentActiveModuleTitle = pages[8].name;
$scope.getLabExerciseModules();
@@ -47,7 +48,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
});
- // $scope.showTabButton = false;
+ // $scope.showme = false;
$scope.IsVisible = function () {
// $scope.scroll();
@@ -85,6 +86,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
if (title != null) {
$scope.LabExerciseQuiz = title;
$scope.LabExerciseName = title.Topic;
+ $scope.LabExerciseUserData = [];
$location.url("/lab-exercises-detail?labexercise=" + (title.Slug || ""));
}
@@ -92,19 +94,17 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$scope.GetQuizByTopic = function () {
-
- if ($rootScope.refreshcheck == null) {
- $location.path('/');
- }
var keywords = $location.search();
$scope.LabExerciseName = keywords.labexercise;
$scope.LabExerciseModules = null;
$scope.LabExerciseBoxes = null;
+
+
var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json';
DataService.getAnotherJson(labExerciseModulePath).then(
function (result) {
- //debugger;
+ $scope.LabExData = result;
// alert(JSON.stringify(result.LabExercise));
$.each(result.LabExercise, function (index, value) {
$scope.LabExerciseName = result.LabExercise[index].Topic;
@@ -113,23 +113,28 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$scope.TotalNumberofQuiz = result.LabExercise[index].NumberofQuestions;
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) {
+ $scope.MaxScore = result.LabExercise[index].Questions[index1].Options.length;
if (result.LabExercise[index].Questions[index1].ImagePath == "") {
$("#imgblock").css("display", "none");
+ //$("#imgblock").remove();
$scope.IsVisible = false;
$("#textblock").css("display", "block");
$scope.LabExerciseModules = result.LabExercise[index].Questions[index1];
$scope.deliberatelyTrustDangerousSnippet = function (html) {
- //var htmltag= $compile(html)($scope);
- return $sce.trustAsHtml(html);
+ //var htmltag= $compile(html)($scope);
+ return $sce.trustAsHtml(html);
};
$scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle;
$scope.Title = result.LabExercise[index].Questions[index1].Title;
+
}
else {
$("#imgblock").css("display", "block");
$scope.IsVisible = true;
$("#textblock").css("display", "none");
+ // $("#textblock").remove();
$scope.LabExerciseModules = result.LabExercise[index].Questions[index1];
+ console.log($scope.LabExerciseModules);
$scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle;
$scope.Title = result.LabExercise[index].Questions[index1].Title;
$scope.Imagepath = keywords.labexercise + "/" + result.LabExercise[index].Questions[index1].ImagePath;
@@ -137,7 +142,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$scope.ShowHideDiv(result.LabExercise[index].Questions[index1].Options[0].textalign);
}
});
- //$scope.quiznumber++;
+ //$scope.quiznumber++;0
}
@@ -149,32 +154,126 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
}
)
}
-
+ $scope.isReviewBtnSelected = false;
$scope.nextQuiz = function () {
+
+ //need to save all questions till the current question number when user clicks on save
+ //if ($scope.dragableId!="") {
+ // $scope.UserAnswersForAllQuestions.push({'QuestionNo':$scope.quiznumber,'UserAnswer':$scope.UserAttempt})
+
+ //}
+ //else {
+ // //need to anattampted question means user ahs not dragged, dropped options so save blank
+ // $scope.UserAnswersForAllQuestions.push({ 'QuestionNo': $scope.quiznumber, 'UserAnswer': "" })
+ //}
+ if ($scope.quiznumber != $scope.TotalNumberofQuiz)
+ {
+ $scope.CreateLabExerciseDataToSave();
+ }
+
+ //{
+ // $scope.selectedQuestionNo = $scope.quiznumber + 1;
+ // $scope.CreateLabExerciseDataToSave();
+ //}
+
+
+ $scope.dragableId = "";
if ($scope.quiznumber == $scope.TotalNumberofQuiz)
return;
else
- $scope.quiznumber++;
+ $scope.quiznumber++;
+
+
+ if ($scope.quiznumber == $scope.TotalNumberofQuiz) {
+ if ($scope.isReviewBtnSelected == true) {
+ $("#quizSubmitBtn").css("display", "none");
+ }
+ else {
+ $("#quizSubmitBtn").css("display", "block");
+ }
+
+ }
+ else
+ {
+ $("#quizSubmitBtn").css("display", "none");
+ }
+
$scope.resetQuiz();
$scope.ShowHideDiv();
+
+
}
$scope.prevQuiz = function () {
- if ($scope.quiznumber == 1)
- return;
- else
- $scope.quiznumber--;
+ if ($scope.quiznumber != 1) {
+ // $scope.quizQuesNo = $scope.quizQuesNo - 1;
+ // $scope.selectedQuestionNo = $scope.quizQuesNo;
+ $scope.CreateLabExerciseDataToSave();
+ }
+ $scope.dragableId = "";
+ $scope.UserAttempt = [];
+ if ($scope.quiznumber == 1)
+ return;
+ else
+ $scope.quiznumber--;
+
+ if ($scope.quiznumber == $scope.TotalNumberofQuiz) {
+ if ($scope.isReviewBtnSelected == true) {
+ $("#quizSubmitBtn").css("display", "none");
+ }
+ else {
+ $("#quizSubmitBtn").css("display", "block");
+ }
+ }
+ else {
+ $("#quizSubmitBtn").css("display", "none");
+ }
+ $scope.resetQuiz();
+ $scope.ShowHideDiv();
+ }
- $scope.resetQuiz();
- $scope.ShowHideDiv();
+
+ $scope.SubmitAttempt = function () {
+ $scope.CreateLabExerciseDataToSave();
+
+ $("#submitResultHtml").css("display", "block");
+ $("#questionHtml").css("display", "none");
+ console.log($scope.usersCorrectQuestData);
+ $("#resultLabData").empty();
+ for (var i = 0; i <= $scope.usersCorrectQuestData.length - 1; i++) {
+ var labExerciseHtml = $("#resultLabData").append("
" + $scope.usersCorrectQuestData[i].QuestionNo + " | " + $scope.usersCorrectQuestData[i].title + " | " + $scope.usersCorrectQuestData[i].CorrectStatus + " | |
");
+ $compile(labExerciseHtml)($scope);
+ }
}
+
+ $scope.ReportGen = function () {
+ $("#submitResultHtml").css("display", "block");
+ $("#questionHtml").css("display", "none");
+ }
+
+
$scope.handleDragStart = function (e) {
- this.style.opacity = '0.8';
+ this.style.opacity = '0.4';
e.dataTransfer.setData('text/plain', this.innerHTML);
$scope.dragableId = $(this).attr("Id");
+ //if user drag already selected answer from one blankbox to another than it gets id of blank box so need to get answer
+ if ($scope.dragableId.indexOf('T') != -1) {
+ var optionText = document.getElementById($scope.dragableId).innerHTML;
+ var currentQuizData = new jinqJs()
+ .from($scope.LabExData.LabExercise[0].Questions)
+ .where('Number == ' + $scope.quiznumber)
+ .select();
+ var optionData = new jinqJs()
+ .from(currentQuizData[0].Options)
+ .where('OptionTitle == ' + optionText)
+ .select();
+ var option = optionData[0].OptionNumber;
+ $scope.dragableId = optionText + '-' + option;
+ }
+
};
$scope.handleDragEnd = function (e) {
@@ -188,7 +287,10 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
//alert(x.left + "," + $("#droppable").clientWidth + "," + x.top);
var id = $(this).attr("id");
+
var keywords = $location.search();
+ $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1];
+
var dataText = e.dataTransfer.getData('text/plain');
if (id == "divoptions" || id == "divleft" || id == "divright") {
var item = $('#' + $scope.dragableId).html();
@@ -202,11 +304,15 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$.each(result.LabExercise[index].Questions, function (index1, value1) {
if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) {
var Options = result.LabExercise[index].Questions[index1].Options;
+
+
$.each(Options, function (inx, value2) {
if (Options[inx].OptionTitle == item) {
if ($scope.DraggedList != null) {
$.each($scope.DraggedList, function (inx1, value3) {
-
+ $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] });
+ //var balnkBox=id.split('-')[1];
+ //$scope.UserAttempt.push({balnkBox :+ $scope.dragableId.split('-')[1] });
if ($scope.DraggedList[inx1].Value == item) {
$scope.DraggedList.splice(inx1, 1);
$('#block-' + Options[inx].OptionNumber).css("display", "block");
@@ -248,7 +354,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
}
});
}
-
+ //var balnkBox = id.split('-')[1];
+ //$scope.UserAttempt.push({ balnkBox: +$scope.dragableId.split('-')[1] });
+ $scope.UserAttempt.push({ "BlankBoxName": id.split('-')[1], "OptionName": $scope.dragableId.split('-')[1] });
$scope.DraggedList.push({ "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord });
//$('#' + $scope.dragableId).remove();
$('#' + $scope.dragableId).css("display", "none");
@@ -274,6 +382,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
//{
// $("#divoptions").html("
")
//}
+ //alert(JSON.stringify($scope.UserAttempt));
};
$scope.handleDragOver = function (e) {
@@ -284,6 +393,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
$scope.resetQuiz = function () {
$scope.DraggedList = [];
+ $scope.UserAttempt = [];
$scope.GetQuizByTopic();
};
@@ -342,7 +452,211 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location
}
};
-
+
+ $scope.SaveAnswer = function () {
+ $scope.CreateLabExerciseDataToSave();
+
+
+ //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData)
+ $scope.labExerciseAttempt = [];
+ $scope.labExerciseAttempt.push({ 'LabExerciseUserData': $scope.LabExerciseUserData, 'userId': $scope.userId, 'labExerciseIdentifier': $scope.labExerciseIdentifier, 'LastQuestion': $scope.LastQuestion, 'TotalQuestions': $scope.TotalQuestions });
+ LabExerciseService.saveLabExerciseAttempt($scope.labExerciseAttempt)
+ .then(
+ function (result) {
+ alert("Successfully updated");
+ },
+ function (error) {
+ console.log(' Error in authentication = ' + error.statusText);
+ alert("Error");
+ });
+ };
+
+ $scope.usersCorrectQuestData = [];
+ $scope.CreateLabExerciseDataToSave = function () {
+
+ $scope.LabExerciseAttemptedData = [];
+ $scope.lb = [];
+ //get user answers
+ $scope.getUserAnswers();
+
+
+ //get correct response
+ $scope.getCorrectResponse();
+
+ // $scope.correctResponseForSavingDatabaseArray = $scope.correctResponseForSavingDatabase.split(',');
+
+ //get dragItems
+ $scope.getDragItems();
+
+ //get score
+ $scope.getScore();
+
+ $scope.userId = JSON.parse(localStorage.getItem('loggedInUserDetails')).Id;
+ $scope.labExerciseIdentifier = $scope.labExercideIdentifier;
+ $scope.LastQuestion = $scope.quiznumber;
+ $scope.TotalQuestions = $scope.TotalNumberofQuiz;
+
+ $scope.LabExerciseAttemptedData = {
+
+ MaxScore: $scope.MaxScore,
+ UserAnswer: $scope.commaSeperatedUserAnswers,
+ QuestionNo: $scope.quiznumber,
+ CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase),
+ DragItems: $scope.DragItems,
+ Score: $scope.Score,
+ title: $scope.activityTitle,
+ }
+
+
+ if($scope.LabExerciseAttemptedData.MaxScore == $scope.LabExerciseAttemptedData.Score)
+ {
+ $scope.usersCorrectQuestData.push({
+ MaxScore: $scope.MaxScore,
+ UserAnswer: $scope.commaSeperatedUserAnswers,
+ QuestionNo: $scope.quiznumber,
+ CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase),
+ DragItems: $scope.DragItems,
+ Score: $scope.Score,
+ title: $scope.activityTitle,
+ CorrectStatus : 'Correct'
+ });
+ }
+ else
+ {
+ $scope.usersCorrectQuestData.push({
+ MaxScore: $scope.MaxScore,
+ UserAnswer: $scope.commaSeperatedUserAnswers,
+ QuestionNo: $scope.quiznumber,
+ CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase),
+ DragItems: $scope.DragItems,
+ Score: $scope.Score,
+ title: $scope.activityTitle,
+ CorrectStatus: 'Incorrect'
+ });
+ }
+
+ var thisQuestiondataInLabExerciseUserData = new jinqJs()
+ .from($scope.LabExerciseUserData)
+ .where('QuestionNo == ' + $scope.LabExerciseAttemptedData.QuestionNo)
+ .select();
+ if (thisQuestiondataInLabExerciseUserData.length > 0) {
+
+ angular.forEach($scope.LabExerciseUserData, function (value, key) {
+ if (value.QuestionNo == $scope.LabExerciseAttemptedData.QuestionNo) {
+
+ }
+ else {
+ $scope.lb.push(value);
+ }
+ })
+ $scope.LabExerciseUserData = [];
+
+ $scope.lb.push($scope.LabExerciseAttemptedData);
+ angular.forEach($scope.lb, function (value1, key1) {
+ $scope.LabExerciseUserData.push(value1);
+ })
+ }
+ else
+ $scope.LabExerciseUserData.push($scope.LabExerciseAttemptedData);
+ }
+
+ $scope.reviewAttemptAnswer = function () {
+ $scope.isReviewBtnSelected = true;
+ $("#reviewBtn").css("display", "none");
+ $("#resetBtn").css("display", "none");
+ $("#saveBtn").css("display", "none");
+ $("#submitResultHtml").css("display", "none");
+ $("#questionHtml").css("display", "block");
+ $("#reportBtn").css("display", "block");
+ $scope.quiznumber = 1;
+ $scope.nextQuiz();
+ }
+
+
+
+ $scope.getUserAnswers = function () {
+ var userAnswers = [];
+ var blockBoxes = $("div[id*='blockbox']");
+ var blockBoxesInTextBlock = $("#textblock").children();
+
+ var blockBoxLength = blockBoxes.length - blockBoxesInTextBlock.length;
+ var blockAnswers = $("div[id*='blockans']");
+ for (var i = 0; i < blockAnswers.length; i++) {
+
+ var id = (blockAnswers[i].id).split('-')[1];
+ userAnswers[id.replace('T', '')] = blockAnswers[i].innerHTML;
+ }
+
+ $scope.commaSeperatedUserAnswers = '';
+ for (var i = 1; i <= blockBoxLength; i++) {
+
+ var userAns = userAnswers[i];
+ if (userAns != undefined) {
+ $scope.commaSeperatedUserAnswers += userAns + ',';
+ }
+ else {
+ $scope.commaSeperatedUserAnswers += '' + ',';
+ }
+ }
+ //remove last comma
+ $scope.commaSeperatedUserAnswers = $scope.commaSeperatedUserAnswers.replace(/,$/, '');
+ }
+
+ $scope.getCorrectResponse = function () {
+ $scope.correctResponse = '';
+ $scope.correctResponseForSavingDatabase = '';
+ var cr = new jinqJs()
+ .from($scope.LabExData.LabExercise[0].Questions)
+ .where('Number == ' + $scope.quiznumber)
+ .select();
+ for (var i = 0; i < cr[0].correctResponse.length; i++) {
+ var blankBox = cr[0].correctResponse[i].OptionBox;
+ var option = cr[0].correctResponse[i].Answer;
+
+ var options = new jinqJs()
+ .from(cr[0].Options)
+ .where('OptionNumber == ' + option)
+ .select();
+
+ //var optionText = options[0].OptionTitle;
+ // $scope.correctResponse += blankBox + ' ' + option + ',';
+ // $scope.correctResponseForSavingDatabase += parseInt(blankBox.replace('T', '')) - 1 + ':' + optionText + ',';
+ }
+
+ $scope.correctResponse = $scope.correctResponse.replace(/,$/, '');
+ $scope.correctResonseKeyValue = $scope.correctResponse.split(',');
+
+ $scope.correctResponseForSavingDatabase = $scope.correctResponseForSavingDatabase.replace(/,$/, '');
+ }
+
+
+ $scope.getDragItems = function () {
+ var OptionBoxes = $("div[id*='block-']");
+ $scope.DragItems = '';
+ for (var i = 0; i < OptionBoxes.length; i++) {
+ $scope.DragItems += OptionBoxes[i].id.replace('block-', '') + ',' + OptionBoxes[i].innerHTML + ';';
+ }
+ $scope.DragItems = $scope.DragItems.replace(/;$/, '');
+
+ }
+
+ $scope.getScore = function () {
+
+ var abc = $scope.UserAttempt;
+ $scope.Score = 0;
+ angular.forEach($scope.UserAttempt, function (value, key) {
+
+ var userOptedAnswer = value.BlankBoxName + ' ' + value.OptionName;
+ for (var i = 0; i < $scope.correctResonseKeyValue.length; i++) {
+ if (userOptedAnswer == $scope.correctResonseKeyValue[i]) {
+ $scope.Score += 1;
+ }
+
+ }
+
+
+ })
+ }
}]
);
diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
index 5457003..74fe122 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
+++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
@@ -17,11 +17,11 @@
-
+
{{activityTitle}}
{{Title}}
-
Question {{quiznumber}} of {{TotalNumberofQuiz}}
+
Question {{quiznumber}} of {{TotalNumberofQuiz}}
@@ -64,9 +64,11 @@
-
-
-
+
+
+
+
+
@@ -77,6 +79,65 @@
+
+
+
+
+
+
Cardiovascula System
+
Performace Report
+
Score: 0%
+
+
+
+
+
+
+
+
+ Total Question |
+ Correct Answers |
+ Incorrect Answers |
+
+
+
+
+ 18 |
+ 0 |
+ 18 |
+
+
+
+
+
+
+
+
+
+ Question |
+ Activity Title |
+ Status |
+ Action |
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index.html
index 52a42f2..24e7252 100644
--- a/400-SOURCECODE/AIAHTML5.Web/index.html
+++ b/400-SOURCECODE/AIAHTML5.Web/index.html
@@ -1447,7 +1447,7 @@
-
+