From 4e2908eea9a882c5f44d596efb4226be61e0c4c0 Mon Sep 17 00:00:00 2001 From: nikita Date: Tue, 20 Feb 2018 18:22:49 +0530 Subject: [PATCH] added back-end code fro lab execrice save --- 400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj | 1 + 400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs | 13 +++++++++++++ 400-SOURCECODE/AIAHTML5.API/Models/LabExercise.cs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js | 20 ++++++++++++-------- 6 files changed, 347 insertions(+), 79 deletions(-) create mode 100644 400-SOURCECODE/AIAHTML5.API/Models/LabExercise.cs diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index 759758a..f26de4f 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -130,6 +130,7 @@ Global.asax + diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs index d6a697a..1132e7f 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs @@ -1,38 +1,140 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; +using log4net; +using AIAHTML5.API.Constants; +using AIAHTML5.API.Models; +using System.Collections; +using System.Data.SqlClient; namespace AIAHTML5.API.Controllers { public class LabExerciseController : ApiController { - // GET api/ + // GET api/authenticate public IEnumerable Get() { return new string[] { "value1", "value2" }; } - // GET api//5 + // GET api/authenticate/5 public string Get(int id) { return "value"; } - // POST api/ - public void Post([FromBody]JObject labExerciseUserAttemptData) + // POST api/authenticate + public HttpResponseMessage Post([FromBody]JArray labExerciseUserAttemptData) { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("inside insertLabExerciseAttempt Post LabExerciseController"); + + try + { + LabExercise le = new LabExercise(); + le.labExercise = new List(); + + foreach (var item in labExerciseUserAttemptData.Children()) + { + var itemProperties = item.Children(); + //you could do a foreach or a linq here depending on what you need to do exactly with the value + var userId = itemProperties.FirstOrDefault(x => x.Name == "userId"); + le.userId = Convert.ToInt32(userId.Value); ////This is a JValue type + + var labExerciseIdentifier = itemProperties.FirstOrDefault(x => x.Name == "labExerciseIdentifier"); + le.labExerciseIdentifier = labExerciseIdentifier.Value.ToString(); ////This is a JValue type + + var lastQuestion = itemProperties.FirstOrDefault(x => x.Name == "LastQuestion"); + le.lastQuestion = Convert.ToInt32(lastQuestion.Value); ////This is a JValue type + + var totalQuestions = itemProperties.FirstOrDefault(x => x.Name == "TotalQuestions"); + le.totalQuestions = Convert.ToInt32(totalQuestions.Value); ////This is a JValue type + + var LabExerciseUserData = itemProperties.FirstOrDefault(x => x.Name == "LabExerciseUserData"); + foreach (var labQuiz in LabExerciseUserData.Children()) + { + var labQuizProperties = labQuiz.Children(); + foreach (var lb in labQuizProperties) + { + var itemProperties1 = lb.Children(); + + LabEcerciseDetails labExDetails = new LabEcerciseDetails(); + + var MaxScore = itemProperties1.FirstOrDefault(x => x.Name == "MaxScore"); + labExDetails.MaxScore = Convert.ToInt32(MaxScore.Value); + + var UserAnswer = itemProperties1.FirstOrDefault(x => x.Name == "UserAnswer"); + labExDetails.UserAnswer = UserAnswer.Value.ToString(); + + var QuestionNo = itemProperties1.FirstOrDefault(x => x.Name == "QuestionNo"); + labExDetails.QuestionNo = Convert.ToInt32(QuestionNo.Value); + + var CorrectAnswer = itemProperties1.FirstOrDefault(x => x.Name == "CorrectAnswer"); + labExDetails.CorrectAnswer = CorrectAnswer.Value.ToString(); + + var DragItems = itemProperties1.FirstOrDefault(x => x.Name == "DragItems"); + labExDetails.DragItems = DragItems.Value.ToString(); + + var Score = itemProperties1.FirstOrDefault(x => x.Name == "Score"); + labExDetails.Score = Convert.ToInt32(Score.Value); + + + + le.labExercise.Add(labExDetails); + + } + } + } + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("insertyed") }; + + } + catch (SqlException e) + { + + //logger.Fatal("SqlException occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); + + //ArrayList supportMailList = UserUtility.GetSupportMailList(); + //string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; + //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; + //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); + + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; + } + catch (Exception e) + { + + //logger.Fatal("Exception occured for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); + + //ArrayList supportMailList = UserUtility.GetSupportMailList(); + //string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; + //string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; + //UserUtility.SendEmail(credentials, supportMailList, "", mailSubject, mailBody); + + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; + + } + + + } - // PUT api//5 + + + + + + + // PUT api/authenticate/5 public void Put(int id, [FromBody]string value) { } - // DELETE api//5 + // DELETE api/authenticate/5 public void Delete(int id) { } diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index 1522532..1781a40 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -861,5 +861,18 @@ namespace AIAHTML5.API.Models return result; } + + internal int InsertLabExerciseData(int userId, string labExerciseIdentifier, int lastQusetion, int totalQuestions, List<> labExDetails ) + { + return 1; + + } + + + internal int InsertLabExerciseDetails(int userId, string labExerciseIdentifier, int lastQusetion, int totalQuestions, List<> labExDetails ) + { + return 1; + + } } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/LabExercise.cs b/400-SOURCECODE/AIAHTML5.API/Models/LabExercise.cs new file mode 100644 index 0000000..5c62687 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Models/LabExercise.cs @@ -0,0 +1,46 @@ +using log4net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace AIAHTML5.API.Models +{ + public class LabExercise + { + + public int userId { get; set; } + public string labExerciseIdentifier { get; set; } + public int lastQuestion { get; set; } + public int totalQuestions { get; set; } + public List labExercise; + + + internal static int insertLabExerciseAttempt(int userId, string labExerciseIdentifier, int LastQuestion, int TotalQuestions, List labExercise) + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("inside insertLabExerciseAttempt for UserId =" + userId + ",labExerciseIdentifier= " + labExerciseIdentifier + ",LastQuestion= " + LastQuestion+ "TotalQuestions =" + TotalQuestions); + + + int result = 0; + + DBModel objModel = new DBModel(); + + result = objModel.InsertLoginDetails(userId); + + return result; + } + + } + + public class LabEcerciseDetails + { + + public int MaxScore { get; set; } + public string UserAnswer { get; set; } + public int QuestionNo { get; set; } + public string CorrectAnswer { get; set; } + public string DragItems { get; set; } + public int Score { get; set; } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index e38facd..ecfb0dd 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -10,10 +10,12 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.Title = ""; $scope.Imagepath = ""; $scope.DraggedList = []; - $scope.AnswerList = []; + $scope.UserAttempt = []; $scope.UserAnswersForAllQuestions = []; + $scope.LabExerciseUserData = []; $scope.LabExercise = []; $scope.dragableId = ""; + $scope.UserAttempt = []; $scope.blReviewAttempt = false; $scope.$on('$viewContentLoaded', function (event) { // code that will be executed ... @@ -84,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 || "")); } @@ -95,6 +98,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.LabExerciseName = keywords.labexercise; $scope.LabExerciseModules = null; $scope.LabExerciseBoxes = null; + //alert($scope.LabExerciseName) var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json'; @@ -109,6 +113,7 @@ 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(); @@ -150,14 +155,16 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $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.AnswerList}) + //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': "" }) + //} + $scope.CreateLabExerciseDataToSave(); - } - else { - //need to anattampted question means user ahs not dragged, dropped options so save blank - $scope.UserAnswersForAllQuestions.push({ 'QuestionNo': $scope.quiznumber, 'UserAnswer': "" }) - } $scope.dragableId = ""; if ($scope.quiznumber == $scope.TotalNumberofQuiz) return; @@ -168,7 +175,11 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location } $scope.prevQuiz = function () { + + $scope.CreateLabExerciseDataToSave(); + $scope.dragableId = ""; + $scope.UserAttempt = []; if ($scope.quiznumber == 1) return; else @@ -184,6 +195,21 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location 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) { @@ -214,15 +240,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; - $scope.maxScore = Options.length; + $.each(Options, function (inx, value2) { if (Options[inx].OptionTitle == item) { if ($scope.DraggedList != null) { $.each($scope.DraggedList, function (inx1, value3) { - // $scope.AnswerList.push({ "optionName": id.split('-')[1], "AnswerName": $scope.dragableId.split('-')[1] }); - 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] }); + //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"); @@ -264,8 +290,9 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location } }); } - - $scope.AnswerList.push({ "optionName": id.split('-')[1], "AnswerName": $scope.dragableId.split('-')[1] }); + //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"); @@ -291,7 +318,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location //{ // $("#divoptions").html("



") //} - //alert(JSON.stringify($scope.AnswerList)); + //alert(JSON.stringify($scope.UserAttempt)); }; $scope.handleDragOver = function (e) { @@ -302,6 +329,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location $scope.resetQuiz = function () { $scope.DraggedList = []; + $scope.UserAttempt = []; $scope.GetQuizByTopic(); }; @@ -362,8 +390,84 @@ 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.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 + } + + 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.getUserAnswers = function () { var userAnswers = []; var blockBoxes = $("div[id*='blockbox']"); var blockBoxesInTextBlock = $("#textblock").children(); @@ -373,80 +477,78 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location for (var i = 0; i < blockAnswers.length; i++) { var id = (blockAnswers[i].id).split('-')[1]; - userAnswers[id.replace('T','')] = blockAnswers[i].innerHTML; + userAnswers[id.replace('T', '')] = blockAnswers[i].innerHTML; } - var commaSeperatedUserAnswers = ''; - for (var i = 1; i <=blockBoxLength; i++) { - - var userAns = userAnswers[i]; - if(userAns!=undefined){ - commaSeperatedUserAnswers +=userAns + ','; - } - else{ - commaSeperatedUserAnswers +=''+','; - } + $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 - commaSeperatedUserAnswers = commaSeperatedUserAnswers.replace(/,$/, ''); - + $scope.commaSeperatedUserAnswers = $scope.commaSeperatedUserAnswers.replace(/,$/, ''); + } - //get correct response - $scope.correctResponse =''; - $scope.correctResponseForSavingDatabase =''; - var cr = new jinqJs() + $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 options = cr[0].correctResponse[i].Answer; - $scope.correctResponse += blankBox + ' ' + options + ','; - $scope.correctResponseForSavingDatabase += parseInt(blankBox.replace('T',''))-1 + ':' + options + ','; + 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.correctResponseForSavingDatabaseArray = $scope.correctResponseForSavingDatabase.split(','); + } - //get dragItems + + $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 = DragItems.replace(/;$/, ''); + $scope.DragItems = $scope.DragItems.replace(/;$/, ''); + } - //get score + $scope.getScore = function () { - $scope.LabExerciseAttemptedData = { - userId: localStorage.getItem('loggedInUserDetails').id, - //Attemptnumber: 1, - labExerciseIdentifier: $scope.labExercideIdentifier, - LastQuestion: $scope.quiznumber, - TotalQuestions: $scope.TotalNumberofQuiz, - MaxScore: $scope.maxScore, - UserAnswer: commaSeperatedUserAnswers, - QuestionNo: $scope.quiznumber, - CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), - DragItems: $scope.DragItems, - Score: 1 - } - var abc = $scope.AnswerList; - //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) - LabExerciseService.saveLabExerciseAttempt($scope.LabExerciseAttemptedData) - .then( - function (result) { - alert("Successfully updated"); - }, - function (error) { - console.log(' Error in authentication = ' + error.statusText); - alert("Error"); - }); - }; + 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/services/LabExerciseService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js index 1e5f2cf..518d2e7 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js @@ -1,13 +1,17 @@ -AIA.factory('LabExerciseService', function ($http, $q) { +AIA.factory('LabExerciseService', function ($http, $q,$rootScope) { return { - saveLabExerciseAttempt: function (username, labExercieObj) { + saveLabExerciseAttempt: function (labExercieObj) { var deferred = $q.defer(); - - $http.post('/API/api/Authenticate', JSON.stringify(userInfo), { - headers: { - 'Content-Type': 'application/json' - } - }) + $http.post('/API/api/LabExercise', JSON.stringify(labExercieObj), { + headers: { + 'Content-Type': 'application/json' + } + }) + //$http.post('/API/api/LabExercise', JSON.stringify(labExercieObj, userId, labExerciseIdentifier, LastQuestion, TotalQuestions), { + // headers: { + // 'Content-Type': 'application/json' + // } + //}) .success(function (data, status, headers, config) { console.log('success') deferred.resolve(data); -- libgit2 0.21.4