Commit 75263b72e1623600d56e435e6d41c76fccb55b83
1 parent
b64d9472
prepared object for save . need to get score and move code in functions.
Showing
8 changed files
with
245 additions
and
33 deletions
400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj
@@ -60,17 +60,17 @@ | @@ -60,17 +60,17 @@ | ||
60 | <HintPath>..\packages\MongoDB.Driver.Core.2.5.0\lib\net45\MongoDB.Driver.Core.dll</HintPath> | 60 | <HintPath>..\packages\MongoDB.Driver.Core.2.5.0\lib\net45\MongoDB.Driver.Core.dll</HintPath> |
61 | <Private>True</Private> | 61 | <Private>True</Private> |
62 | </Reference> | 62 | </Reference> |
63 | - <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
64 | - <SpecificVersion>False</SpecificVersion> | ||
65 | - <HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath> | 63 | + <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
64 | + <HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
65 | + <Private>True</Private> | ||
66 | </Reference> | 66 | </Reference> |
67 | <Reference Include="System.Buffers, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | 67 | <Reference Include="System.Buffers, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
68 | <HintPath>..\packages\System.Buffers.4.3.0\lib\netstandard1.1\System.Buffers.dll</HintPath> | 68 | <HintPath>..\packages\System.Buffers.4.3.0\lib\netstandard1.1\System.Buffers.dll</HintPath> |
69 | <Private>True</Private> | 69 | <Private>True</Private> |
70 | </Reference> | 70 | </Reference> |
71 | <Reference Include="System.Net.Http" /> | 71 | <Reference Include="System.Net.Http" /> |
72 | - <Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
73 | - <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath> | 72 | + <Reference Include="System.Net.Http.Formatting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
73 | + <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.0.0\lib\net45\System.Net.Http.Formatting.dll</HintPath> | ||
74 | <Private>True</Private> | 74 | <Private>True</Private> |
75 | </Reference> | 75 | </Reference> |
76 | <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | 76 | <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
@@ -86,12 +86,12 @@ | @@ -86,12 +86,12 @@ | ||
86 | <Reference Include="System.Core" /> | 86 | <Reference Include="System.Core" /> |
87 | <Reference Include="System.Data.DataSetExtensions" /> | 87 | <Reference Include="System.Data.DataSetExtensions" /> |
88 | <Reference Include="System.Web.Extensions" /> | 88 | <Reference Include="System.Web.Extensions" /> |
89 | - <Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
90 | - <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath> | 89 | + <Reference Include="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
90 | + <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.0.0\lib\net45\System.Web.Http.dll</HintPath> | ||
91 | <Private>True</Private> | 91 | <Private>True</Private> |
92 | </Reference> | 92 | </Reference> |
93 | - <Reference Include="System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
94 | - <HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath> | 93 | + <Reference Include="System.Web.Http.WebHost, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
94 | + <HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.0.0\lib\net45\System.Web.Http.WebHost.dll</HintPath> | ||
95 | <Private>True</Private> | 95 | <Private>True</Private> |
96 | </Reference> | 96 | </Reference> |
97 | <Reference Include="System.Xml.Linq" /> | 97 | <Reference Include="System.Xml.Linq" /> |
@@ -121,6 +121,7 @@ | @@ -121,6 +121,7 @@ | ||
121 | <Compile Include="Controllers\AdminAccessController.cs" /> | 121 | <Compile Include="Controllers\AdminAccessController.cs" /> |
122 | <Compile Include="Controllers\AuthenticateController.cs" /> | 122 | <Compile Include="Controllers\AuthenticateController.cs" /> |
123 | <Compile Include="Controllers\ForgotUserController.cs" /> | 123 | <Compile Include="Controllers\ForgotUserController.cs" /> |
124 | + <Compile Include="Controllers\LabExerciseController.cs" /> | ||
124 | <Compile Include="Controllers\LicenseTermConditionController.cs" /> | 125 | <Compile Include="Controllers\LicenseTermConditionController.cs" /> |
125 | <Compile Include="Controllers\PixelLocationsController.cs" /> | 126 | <Compile Include="Controllers\PixelLocationsController.cs" /> |
126 | <Compile Include="Controllers\ResetPasswordController.cs" /> | 127 | <Compile Include="Controllers\ResetPasswordController.cs" /> |
400-SOURCECODE/AIAHTML5.API/Controllers/LabExerciseController.cs
0 → 100644
1 | +using Newtonsoft.Json.Linq; | ||
2 | +using System; | ||
3 | +using System.Collections.Generic; | ||
4 | +using System.Linq; | ||
5 | +using System.Net; | ||
6 | +using System.Net.Http; | ||
7 | +using System.Web.Http; | ||
8 | + | ||
9 | +namespace AIAHTML5.API.Controllers | ||
10 | +{ | ||
11 | + public class LabExerciseController : ApiController | ||
12 | + { | ||
13 | + // GET api/<controller> | ||
14 | + public IEnumerable<string> Get() | ||
15 | + { | ||
16 | + return new string[] { "value1", "value2" }; | ||
17 | + } | ||
18 | + | ||
19 | + // GET api/<controller>/5 | ||
20 | + public string Get(int id) | ||
21 | + { | ||
22 | + return "value"; | ||
23 | + } | ||
24 | + | ||
25 | + // POST api/<controller> | ||
26 | + public void Post([FromBody]JObject labExerciseUserAttemptData) | ||
27 | + { | ||
28 | + } | ||
29 | + | ||
30 | + // PUT api/<controller>/5 | ||
31 | + public void Put(int id, [FromBody]string value) | ||
32 | + { | ||
33 | + } | ||
34 | + | ||
35 | + // DELETE api/<controller>/5 | ||
36 | + public void Delete(int id) | ||
37 | + { | ||
38 | + } | ||
39 | + } | ||
40 | +} | ||
0 | \ No newline at end of file | 41 | \ No newline at end of file |
400-SOURCECODE/AIAHTML5.API/Controllers/LabExercises.cs
0 → 100644
1 | +using System; | ||
2 | +using System.Collections.Generic; | ||
3 | +using System.Linq; | ||
4 | +using System.Web; | ||
5 | +using System; | ||
6 | +using System.Threading.Tasks; | ||
7 | +using MongoDB.Bson; | ||
8 | +using MongoDB.Driver; | ||
9 | +using AIAHTML5.API.Properties; | ||
10 | +using MongoDB.Driver.Builders; | ||
11 | + | ||
12 | +namespace AIAHTML5.API.Models | ||
13 | +{ | ||
14 | + public class LabExercises | ||
15 | + { | ||
16 | + public int Attemptnumber { get; set; } | ||
17 | + public string labExerciseCode { get; set; } | ||
18 | + public string Answer { get; set; } | ||
19 | + public int Question { get; set; } | ||
20 | + public int Score { get; set; } | ||
21 | + | ||
22 | + | ||
23 | + public void UpdateUserLabExercise(Users objUser) | ||
24 | + { | ||
25 | + var client = new MongoClient(); | ||
26 | + var db = client.GetDatabase(Settings.Default.database); | ||
27 | + | ||
28 | + var collection = db.GetCollection<BsonDocument>("Users"); | ||
29 | + | ||
30 | + collection.UpdateOne( | ||
31 | + Builders<BsonDocument>.Filter.Eq("loginId", objUser.loginId), | ||
32 | + Builders<BsonDocument>.Update.Set("LabExerciseAttempt", objUser.labExerciseAttempt)); | ||
33 | + | ||
34 | + | ||
35 | + } | ||
36 | + } | ||
37 | +} | ||
0 | \ No newline at end of file | 38 | \ No newline at end of file |
400-SOURCECODE/AIAHTML5.API/packages.config
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <packages> | 2 | <packages> |
3 | <package id="DnsClient" version="1.0.7" targetFramework="net45" /> | 3 | <package id="DnsClient" version="1.0.7" targetFramework="net45" /> |
4 | + <package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" /> | ||
5 | + <package id="Microsoft.AspNet.WebApi.Client" version="5.0.0" targetFramework="net45" /> | ||
6 | + <package id="Microsoft.AspNet.WebApi.Core" version="5.0.0" targetFramework="net45" /> | ||
7 | + <package id="Microsoft.AspNet.WebApi.WebHost" version="5.0.0" targetFramework="net45" /> | ||
4 | <package id="MongoDB.Bson" version="2.5.0" targetFramework="net45" /> | 8 | <package id="MongoDB.Bson" version="2.5.0" targetFramework="net45" /> |
5 | <package id="MongoDB.Driver" version="2.5.0" targetFramework="net45" /> | 9 | <package id="MongoDB.Driver" version="2.5.0" targetFramework="net45" /> |
6 | <package id="MongoDB.Driver.Core" version="2.5.0" targetFramework="net45" /> | 10 | <package id="MongoDB.Driver.Core" version="2.5.0" targetFramework="net45" /> |
11 | + <package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" /> | ||
7 | <package id="System.Buffers" version="4.3.0" targetFramework="net45" /> | 12 | <package id="System.Buffers" version="4.3.0" targetFramework="net45" /> |
8 | <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net45" /> | 13 | <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.0.0" targetFramework="net45" /> |
9 | </packages> | 14 | </packages> |
10 | \ No newline at end of file | 15 | \ No newline at end of file |
400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js
1 | /// <reference path="../../content/data/json/le/LabExercise.js" /> | 1 | /// <reference path="../../content/data/json/le/LabExercise.js" /> |
2 | -AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce',"$compile","$location", | ||
3 | -function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location) { | 2 | +AIA.controller("LabExercController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$location", "LabExerciseService", |
3 | +function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $location, LabExerciseService) { | ||
4 | $scope.$sce = $sce; | 4 | $scope.$sce = $sce; |
5 | $scope.LabExerciseName; | 5 | $scope.LabExerciseName; |
6 | $scope.LabExerciseQuiz = null; | 6 | $scope.LabExerciseQuiz = null; |
@@ -10,13 +10,12 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -10,13 +10,12 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
10 | $scope.Title = ""; | 10 | $scope.Title = ""; |
11 | $scope.Imagepath = ""; | 11 | $scope.Imagepath = ""; |
12 | $scope.DraggedList = []; | 12 | $scope.DraggedList = []; |
13 | + $scope.AnswerList = []; | ||
14 | + $scope.UserAnswersForAllQuestions = []; | ||
15 | + $scope.LabExercise = []; | ||
13 | $scope.dragableId = ""; | 16 | $scope.dragableId = ""; |
14 | $scope.blReviewAttempt = false; | 17 | $scope.blReviewAttempt = false; |
15 | $scope.$on('$viewContentLoaded', function (event) { | 18 | $scope.$on('$viewContentLoaded', function (event) { |
16 | - | ||
17 | - if ($rootScope.refreshcheck == null) { | ||
18 | - $location.path('/'); | ||
19 | - } | ||
20 | // code that will be executed ... | 19 | // code that will be executed ... |
21 | // every time this view is loaded | 20 | // every time this view is loaded |
22 | 21 | ||
@@ -31,7 +30,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -31,7 +30,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
31 | $rootScope.currentActiveModuleTitle = selectedModuleName; | 30 | $rootScope.currentActiveModuleTitle = selectedModuleName; |
32 | }) | 31 | }) |
33 | 32 | ||
34 | - $scope.showTabButton = false; | 33 | + $scope.showme = false; |
35 | $rootScope.currentActiveModuleTitle = pages[8].name; | 34 | $rootScope.currentActiveModuleTitle = pages[8].name; |
36 | $scope.getLabExerciseModules(); | 35 | $scope.getLabExerciseModules(); |
37 | 36 | ||
@@ -47,7 +46,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -47,7 +46,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
47 | 46 | ||
48 | }); | 47 | }); |
49 | 48 | ||
50 | - // $scope.showTabButton = false; | 49 | + // $scope.showme = false; |
51 | $scope.IsVisible = function () { | 50 | $scope.IsVisible = function () { |
52 | // $scope.scroll(); | 51 | // $scope.scroll(); |
53 | 52 | ||
@@ -92,19 +91,16 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -92,19 +91,16 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
92 | 91 | ||
93 | 92 | ||
94 | $scope.GetQuizByTopic = function () { | 93 | $scope.GetQuizByTopic = function () { |
95 | - | ||
96 | - if ($rootScope.refreshcheck == null) { | ||
97 | - $location.path('/'); | ||
98 | - } | ||
99 | var keywords = $location.search(); | 94 | var keywords = $location.search(); |
100 | $scope.LabExerciseName = keywords.labexercise; | 95 | $scope.LabExerciseName = keywords.labexercise; |
101 | $scope.LabExerciseModules = null; | 96 | $scope.LabExerciseModules = null; |
102 | $scope.LabExerciseBoxes = null; | 97 | $scope.LabExerciseBoxes = null; |
98 | + //alert($scope.LabExerciseName) | ||
103 | var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json'; | 99 | var labExerciseModulePath = '~/../content/data/json/le/' + $scope.LabExerciseName + '.json'; |
104 | 100 | ||
105 | DataService.getAnotherJson(labExerciseModulePath).then( | 101 | DataService.getAnotherJson(labExerciseModulePath).then( |
106 | function (result) { | 102 | function (result) { |
107 | - //debugger; | 103 | + $scope.LabExData = result; |
108 | // alert(JSON.stringify(result.LabExercise)); | 104 | // alert(JSON.stringify(result.LabExercise)); |
109 | $.each(result.LabExercise, function (index, value) { | 105 | $.each(result.LabExercise, function (index, value) { |
110 | $scope.LabExerciseName = result.LabExercise[index].Topic; | 106 | $scope.LabExerciseName = result.LabExercise[index].Topic; |
@@ -115,12 +111,13 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -115,12 +111,13 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
115 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | 111 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { |
116 | if (result.LabExercise[index].Questions[index1].ImagePath == "") { | 112 | if (result.LabExercise[index].Questions[index1].ImagePath == "") { |
117 | $("#imgblock").css("display", "none"); | 113 | $("#imgblock").css("display", "none"); |
114 | + //$("#imgblock").remove(); | ||
118 | $scope.IsVisible = false; | 115 | $scope.IsVisible = false; |
119 | $("#textblock").css("display", "block"); | 116 | $("#textblock").css("display", "block"); |
120 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | 117 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; |
121 | $scope.deliberatelyTrustDangerousSnippet = function (html) { | 118 | $scope.deliberatelyTrustDangerousSnippet = function (html) { |
122 | - //var htmltag= $compile(html)($scope); | ||
123 | - return $sce.trustAsHtml(html); | 119 | + //var htmltag= $compile(html)($scope); |
120 | + return $sce.trustAsHtml(html); | ||
124 | }; | 121 | }; |
125 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | 122 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; |
126 | $scope.Title = result.LabExercise[index].Questions[index1].Title; | 123 | $scope.Title = result.LabExercise[index].Questions[index1].Title; |
@@ -129,6 +126,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -129,6 +126,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
129 | $("#imgblock").css("display", "block"); | 126 | $("#imgblock").css("display", "block"); |
130 | $scope.IsVisible = true; | 127 | $scope.IsVisible = true; |
131 | $("#textblock").css("display", "none"); | 128 | $("#textblock").css("display", "none"); |
129 | + // $("#textblock").remove(); | ||
132 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; | 130 | $scope.LabExerciseModules = result.LabExercise[index].Questions[index1]; |
133 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; | 131 | $scope.activityTitle = result.LabExercise[index].Questions[index1].activityTitle; |
134 | $scope.Title = result.LabExercise[index].Questions[index1].Title; | 132 | $scope.Title = result.LabExercise[index].Questions[index1].Title; |
@@ -151,6 +149,16 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -151,6 +149,16 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
151 | } | 149 | } |
152 | 150 | ||
153 | $scope.nextQuiz = function () { | 151 | $scope.nextQuiz = function () { |
152 | + //need to save all questions till the current question number when user clicks on save | ||
153 | + if ($scope.dragableId!="") { | ||
154 | + $scope.UserAnswersForAllQuestions.push({'QuestionNo':$scope.quiznumber,'UserAnswer':$scope.AnswerList}) | ||
155 | + | ||
156 | + } | ||
157 | + else { | ||
158 | + //need to anattampted question means user ahs not dragged, dropped options so save blank | ||
159 | + $scope.UserAnswersForAllQuestions.push({ 'QuestionNo': $scope.quiznumber, 'UserAnswer': "" }) | ||
160 | + } | ||
161 | + $scope.dragableId = ""; | ||
154 | if ($scope.quiznumber == $scope.TotalNumberofQuiz) | 162 | if ($scope.quiznumber == $scope.TotalNumberofQuiz) |
155 | return; | 163 | return; |
156 | else | 164 | else |
@@ -160,6 +168,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -160,6 +168,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
160 | } | 168 | } |
161 | 169 | ||
162 | $scope.prevQuiz = function () { | 170 | $scope.prevQuiz = function () { |
171 | + $scope.dragableId = ""; | ||
163 | if ($scope.quiznumber == 1) | 172 | if ($scope.quiznumber == 1) |
164 | return; | 173 | return; |
165 | else | 174 | else |
@@ -188,7 +197,10 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -188,7 +197,10 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
188 | //alert(x.left + "," + $("#droppable").clientWidth + "," + x.top); | 197 | //alert(x.left + "," + $("#droppable").clientWidth + "," + x.top); |
189 | 198 | ||
190 | var id = $(this).attr("id"); | 199 | var id = $(this).attr("id"); |
200 | + | ||
191 | var keywords = $location.search(); | 201 | var keywords = $location.search(); |
202 | + $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; | ||
203 | + | ||
192 | var dataText = e.dataTransfer.getData('text/plain'); | 204 | var dataText = e.dataTransfer.getData('text/plain'); |
193 | if (id == "divoptions" || id == "divleft" || id == "divright") { | 205 | if (id == "divoptions" || id == "divleft" || id == "divright") { |
194 | var item = $('#' + $scope.dragableId).html(); | 206 | var item = $('#' + $scope.dragableId).html(); |
@@ -196,17 +208,21 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -196,17 +208,21 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
196 | var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; | 208 | var labExerciseModulePath = '~/../content/data/json/le/' + keywords.labexercise + '.json'; |
197 | DataService.getAnotherJson(labExerciseModulePath).then( | 209 | DataService.getAnotherJson(labExerciseModulePath).then( |
198 | function (result) { | 210 | function (result) { |
199 | - | 211 | + |
200 | $.each(result.LabExercise, function (index, value) { | 212 | $.each(result.LabExercise, function (index, value) { |
201 | if (result.LabExercise[index].Slug == keywords.labexercise) { | 213 | if (result.LabExercise[index].Slug == keywords.labexercise) { |
202 | $.each(result.LabExercise[index].Questions, function (index1, value1) { | 214 | $.each(result.LabExercise[index].Questions, function (index1, value1) { |
203 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { | 215 | if (result.LabExercise[index].Questions[index1].Number == $scope.quiznumber) { |
204 | var Options = result.LabExercise[index].Questions[index1].Options; | 216 | var Options = result.LabExercise[index].Questions[index1].Options; |
217 | + $scope.maxScore = Options.length; | ||
218 | + | ||
205 | $.each(Options, function (inx, value2) { | 219 | $.each(Options, function (inx, value2) { |
206 | if (Options[inx].OptionTitle == item) { | 220 | if (Options[inx].OptionTitle == item) { |
207 | if ($scope.DraggedList != null) { | 221 | if ($scope.DraggedList != null) { |
208 | $.each($scope.DraggedList, function (inx1, value3) { | 222 | $.each($scope.DraggedList, function (inx1, value3) { |
209 | - | 223 | + // $scope.AnswerList.push({ "optionName": id.split('-')[1], "AnswerName": $scope.dragableId.split('-')[1] }); |
224 | + var balnkBox=id.split('-')[1]; | ||
225 | + $scope.UserAttempt.push({balnkBox :+ $scope.dragableId.split('-')[1] }); | ||
210 | if ($scope.DraggedList[inx1].Value == item) { | 226 | if ($scope.DraggedList[inx1].Value == item) { |
211 | $scope.DraggedList.splice(inx1, 1); | 227 | $scope.DraggedList.splice(inx1, 1); |
212 | $('#block-' + Options[inx].OptionNumber).css("display", "block"); | 228 | $('#block-' + Options[inx].OptionNumber).css("display", "block"); |
@@ -249,6 +265,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -249,6 +265,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
249 | }); | 265 | }); |
250 | } | 266 | } |
251 | 267 | ||
268 | + $scope.AnswerList.push({ "optionName": id.split('-')[1], "AnswerName": $scope.dragableId.split('-')[1] }); | ||
252 | $scope.DraggedList.push({ "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); | 269 | $scope.DraggedList.push({ "id": id.split('-')[1], "optionName": id.split('-')[1], "Value": dataText, "topcoord": Options[inx].topcoord, "leftcoord": Options[inx].leftcoord }); |
253 | //$('#' + $scope.dragableId).remove(); | 270 | //$('#' + $scope.dragableId).remove(); |
254 | $('#' + $scope.dragableId).css("display", "none"); | 271 | $('#' + $scope.dragableId).css("display", "none"); |
@@ -274,6 +291,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -274,6 +291,7 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
274 | //{ | 291 | //{ |
275 | // $("#divoptions").html("<br><br><br><br>") | 292 | // $("#divoptions").html("<br><br><br><br>") |
276 | //} | 293 | //} |
294 | + //alert(JSON.stringify($scope.AnswerList)); | ||
277 | }; | 295 | }; |
278 | 296 | ||
279 | $scope.handleDragOver = function (e) { | 297 | $scope.handleDragOver = function (e) { |
@@ -342,7 +360,93 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | @@ -342,7 +360,93 @@ function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location | ||
342 | } | 360 | } |
343 | 361 | ||
344 | }; | 362 | }; |
345 | - | 363 | + |
364 | + $scope.SaveAnswer = function () { | ||
365 | + | ||
366 | + //get user answers | ||
367 | + var userAnswers = []; | ||
368 | + var blockBoxes = $("div[id*='blockbox']"); | ||
369 | + var blockBoxesInTextBlock = $("#textblock").children(); | ||
370 | + | ||
371 | + var blockBoxLength = blockBoxes.length - blockBoxesInTextBlock.length; | ||
372 | + var blockAnswers = $("div[id*='blockans']"); | ||
373 | + for (var i = 0; i < blockAnswers.length; i++) { | ||
374 | + | ||
375 | + var id = (blockAnswers[i].id).split('-')[1]; | ||
376 | + userAnswers[id.replace('T','')] = blockAnswers[i].innerHTML; | ||
377 | + } | ||
378 | + | ||
379 | + var commaSeperatedUserAnswers = ''; | ||
380 | + for (var i = 1; i <=blockBoxLength; i++) { | ||
381 | + | ||
382 | + var userAns = userAnswers[i]; | ||
383 | + if(userAns!=undefined){ | ||
384 | + commaSeperatedUserAnswers +=userAns + ','; | ||
385 | + } | ||
386 | + else{ | ||
387 | + commaSeperatedUserAnswers +=''+','; | ||
388 | + } | ||
389 | + } | ||
390 | + //remove last comma | ||
391 | + commaSeperatedUserAnswers = commaSeperatedUserAnswers.replace(/,$/, ''); | ||
392 | + | ||
393 | + | ||
394 | + //get correct response | ||
395 | + $scope.correctResponse =''; | ||
396 | + $scope.correctResponseForSavingDatabase =''; | ||
397 | + var cr = new jinqJs() | ||
398 | + .from($scope.LabExData.LabExercise[0].Questions) | ||
399 | + .where('Number == ' + $scope.quiznumber) | ||
400 | + .select(); | ||
401 | + for (var i = 0; i < cr[0].correctResponse.length; i++) { | ||
402 | + var blankBox = cr[0].correctResponse[i].OptionBox; | ||
403 | + var options = cr[0].correctResponse[i].Answer; | ||
404 | + $scope.correctResponse += blankBox + ' ' + options + ','; | ||
405 | + $scope.correctResponseForSavingDatabase += parseInt(blankBox.replace('T',''))-1 + ':' + options + ','; | ||
406 | + } | ||
407 | + | ||
408 | + $scope.correctResponse = $scope.correctResponse.replace(/,$/, ''); | ||
409 | + $scope.correctResonseKeyValue = $scope.correctResponse.split(','); | ||
410 | + | ||
411 | + $scope.correctResponseForSavingDatabase = $scope.correctResponseForSavingDatabase.replace(/,$/, ''); | ||
412 | + // $scope.correctResponseForSavingDatabaseArray = $scope.correctResponseForSavingDatabase.split(','); | ||
413 | + | ||
414 | + //get dragItems | ||
415 | + var OptionBoxes = $("div[id*='block-']"); | ||
416 | + $scope.DragItems = ''; | ||
417 | + for (var i = 0; i < OptionBoxes.length; i++) { | ||
418 | + $scope.DragItems += OptionBoxes[i].id.replace('block-', '') + ',' + OptionBoxes[i].innerHTML + ';'; | ||
419 | + } | ||
420 | + $scope.DragItems = DragItems.replace(/;$/, ''); | ||
421 | + | ||
422 | + | ||
423 | + //get score | ||
424 | + | ||
425 | + $scope.LabExerciseAttemptedData = { | ||
426 | + userId: localStorage.getItem('loggedInUserDetails').id, | ||
427 | + //Attemptnumber: 1, | ||
428 | + labExerciseIdentifier: $scope.labExercideIdentifier, | ||
429 | + LastQuestion: $scope.quiznumber, | ||
430 | + TotalQuestions: $scope.TotalNumberofQuiz, | ||
431 | + MaxScore: $scope.maxScore, | ||
432 | + UserAnswer: commaSeperatedUserAnswers, | ||
433 | + QuestionNo: $scope.quiznumber, | ||
434 | + CorrectAnswer: JSON.stringify($scope.correctResponseForSavingDatabase), | ||
435 | + DragItems: $scope.DragItems, | ||
436 | + Score: 1 | ||
437 | + } | ||
438 | + var abc = $scope.AnswerList; | ||
439 | + //LabExerciseService.saveLabExerciseAttempt("superadmin", $scope.LabExerciseAttemptedData) | ||
440 | + LabExerciseService.saveLabExerciseAttempt($scope.LabExerciseAttemptedData) | ||
441 | + .then( | ||
442 | + function (result) { | ||
443 | + alert("Successfully updated"); | ||
444 | + }, | ||
445 | + function (error) { | ||
446 | + console.log(' Error in authentication = ' + error.statusText); | ||
447 | + alert("Error"); | ||
448 | + }); | ||
449 | + }; | ||
346 | }] | 450 | }] |
347 | 451 | ||
348 | ); | 452 | ); |
400-SOURCECODE/AIAHTML5.Web/app/services/LabExerciseService.js
0 → 100644
1 | +AIA.factory('LabExerciseService', function ($http, $q) { | ||
2 | + return { | ||
3 | + saveLabExerciseAttempt: function (username, labExercieObj) { | ||
4 | + var deferred = $q.defer(); | ||
5 | + | ||
6 | + $http.post('/API/api/Authenticate', JSON.stringify(userInfo), { | ||
7 | + headers: { | ||
8 | + 'Content-Type': 'application/json' | ||
9 | + } | ||
10 | + }) | ||
11 | + .success(function (data, status, headers, config) { | ||
12 | + console.log('success') | ||
13 | + deferred.resolve(data); | ||
14 | + }).error(function (data, status, headers, config) { | ||
15 | + console.log('error') | ||
16 | + deferred.reject(data); | ||
17 | + $rootScope.isVisibleLogin = true; | ||
18 | + $rootScope.errorMessage = data; | ||
19 | + $("#messageModal").modal('show'); | ||
20 | + | ||
21 | + }); | ||
22 | + return deferred.promise; | ||
23 | + }, | ||
24 | + } | ||
25 | +}) | ||
0 | \ No newline at end of file | 26 | \ No newline at end of file |
400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | </div> | 26 | </div> |
27 | <div class="panel-body" style="padding:2px;overflow:scroll"> | 27 | <div class="panel-body" style="padding:2px;overflow:scroll"> |
28 | <div id="textblock" style="margin:20px;"> | 28 | <div id="textblock" style="margin:20px;"> |
29 | - <div style="margin:14px;" ng-repeat="optionbox in LabExerciseModules.OptionBox" droppable="true" class="droppable ui-droppable options" id="blockbox-{{optionbox.BoxName}}"> | 29 | + <div style="margin: 20px;" ng-repeat="optionbox in LabExerciseModules.OptionBox" droppable="true" class="droppable ui-droppable options" id="blockbox-{{optionbox.BoxName}}"> |
30 | <div ng-bind-html="deliberatelyTrustDangerousSnippet(optionbox.QuizText)"></div> | 30 | <div ng-bind-html="deliberatelyTrustDangerousSnippet(optionbox.QuizText)"></div> |
31 | </div> | 31 | </div> |
32 | <!--<ul> | 32 | <!--<ul> |
@@ -38,16 +38,16 @@ | @@ -38,16 +38,16 @@ | ||
38 | <div draggable="true" ng-repeat="option in LabExerciseModules.Options | filter:{'textalign':'left'}" ng-style="{'width': '150px', 'height':'40px','font-size':'8px;','valign':'middle','text-align':'center', 'vertical-align:middle','background-color': '#808080','margin':'10px !important','float':'{{option.textalign}}'} " style="margin-bottom: 10px !important; width: 180px;" class="thumbnail caption col-sm-2 col-lg-3 ui-draggable marginR5 " id="block-{{option.OptionNumber}}">{{option.OptionTitle}}</div> | 38 | <div draggable="true" ng-repeat="option in LabExerciseModules.Options | filter:{'textalign':'left'}" ng-style="{'width': '150px', 'height':'40px','font-size':'8px;','valign':'middle','text-align':'center', 'vertical-align:middle','background-color': '#808080','margin':'10px !important','float':'{{option.textalign}}'} " style="margin-bottom: 10px !important; width: 180px;" class="thumbnail caption col-sm-2 col-lg-3 ui-draggable marginR5 " id="block-{{option.OptionNumber}}">{{option.OptionTitle}}</div> |
39 | </div> | 39 | </div> |
40 | <div class="col-sm-9"> | 40 | <div class="col-sm-9"> |
41 | - <div style="position: relative; margin-left: 70px;" id="imgdiv"> | 41 | + <div style="position: relative; margin-left: 85px;" id="imgdiv"> |
42 | <div id="imgblock"> | 42 | <div id="imgblock"> |
43 | - <img id="droppable" ng-src="content/images/LE/{{Imagepath}}" alt="" ng-click="onClick()" imageonload /> | 43 | + <img id="droppable" ng-src="content/images/LE/{{Imagepath}}" alt="" ng-click="onClick()" imageonload /> |
44 | </div> | 44 | </div> |
45 | 45 | ||
46 | <div ng-show="IsVisible" ng-repeat="optionbox in LabExerciseModules.OptionBox" droppable="true" class="droppable ui-droppable options" id="blockbox-{{optionbox.BoxName}}" ng-style="{'top':{{optionbox.topcoord}}, 'left':{{optionbox.leftcoord}},'position': 'absolute', 'width': '155px', 'height':'30px', 'border':'0px solid #333', 'background': '#E8E8E8' }">{{optionbox.Answervalue}}</div> | 46 | <div ng-show="IsVisible" ng-repeat="optionbox in LabExerciseModules.OptionBox" droppable="true" class="droppable ui-droppable options" id="blockbox-{{optionbox.BoxName}}" ng-style="{'top':{{optionbox.topcoord}}, 'left':{{optionbox.leftcoord}},'position': 'absolute', 'width': '155px', 'height':'30px', 'border':'0px solid #333', 'background': '#E8E8E8' }">{{optionbox.Answervalue}}</div> |
47 | <div draggable="true" ng-repeat="ans in DraggedList" droppable="true" class="droppable ui-droppable answerdroppable" id="blockans-{{ans.id}}" ng-style="{'top':{{ans.topcoord}}, 'left':{{ans.leftcoord}},'position': 'absolute', 'width': '158px', 'height':'30px', 'border':'0px solid #333', 'background': 'transparent','font-size': '12px','border-color':'#FF0000','padding-top':'5px'}">{{ans.Value}}</div> | 47 | <div draggable="true" ng-repeat="ans in DraggedList" droppable="true" class="droppable ui-droppable answerdroppable" id="blockans-{{ans.id}}" ng-style="{'top':{{ans.topcoord}}, 'left':{{ans.leftcoord}},'position': 'absolute', 'width': '158px', 'height':'30px', 'border':'0px solid #333', 'background': 'transparent','font-size': '12px','border-color':'#FF0000','padding-top':'5px'}">{{ans.Value}}</div> |
48 | </div> | 48 | </div> |
49 | 49 | ||
50 | - <div class="col-sm-12" style="margin-left: 200px; margin-top: 10px; height:80px;" id="divoptions" droppable="true" > | 50 | + <div class="col-sm-12" style="margin-left: 215px; margin-top: 10px; height:80px;" id="divoptions" droppable="true"> |
51 | <!--<div class="col-sm-3 col-lg-3 ui-draggable" >--> | 51 | <!--<div class="col-sm-3 col-lg-3 ui-draggable" >--> |
52 | <div draggable="true" ng-repeat="option in LabExerciseModules.Options | filter:{'textalign':'bottom'}" ng-style="{'width': '150px', 'height':'40px','font-size':'8px;','valign':'middle','text-align':'center', 'vertical-align:middle','background-color': '#808080','margin':'5px !important','float':'{{option.textalign}}'} " style="margin-bottom: 5px !important; width: 180px;" class="thumbnail caption col-sm-2 col-lg-3 ui-draggable marginR5 " id="block-{{option.OptionNumber}}">{{option.OptionTitle}}</div> | 52 | <div draggable="true" ng-repeat="option in LabExerciseModules.Options | filter:{'textalign':'bottom'}" ng-style="{'width': '150px', 'height':'40px','font-size':'8px;','valign':'middle','text-align':'center', 'vertical-align:middle','background-color': '#808080','margin':'5px !important','float':'{{option.textalign}}'} " style="margin-bottom: 5px !important; width: 180px;" class="thumbnail caption col-sm-2 col-lg-3 ui-draggable marginR5 " id="block-{{option.OptionNumber}}">{{option.OptionTitle}}</div> |
53 | <!--</div>--> | 53 | <!--</div>--> |
@@ -64,7 +64,7 @@ | @@ -64,7 +64,7 @@ | ||
64 | </div> | 64 | </div> |
65 | <div class="pull-right"> | 65 | <div class="pull-right"> |
66 | <div class="btn-group pull-left marginR5"> | 66 | <div class="btn-group pull-left marginR5"> |
67 | - <button class="btn btn-sm btn-primary">Save</button> | 67 | + <button class="btn btn-sm btn-primary" ng-click="SaveAnswer()">Save</button> |
68 | <button class="btn btn-sm btn-primary" ng-click="ReviewAttempt()">Review Your Attempt</button> | 68 | <button class="btn btn-sm btn-primary" ng-click="ReviewAttempt()">Review Your Attempt</button> |
69 | <button class="btn btn-sm btn-primary" ng-click="resetQuiz()">Reset</button> | 69 | <button class="btn btn-sm btn-primary" ng-click="resetQuiz()">Reset</button> |
70 | </div> | 70 | </div> |
400-SOURCECODE/AIAHTML5.Web/index.html
@@ -1435,7 +1435,7 @@ | @@ -1435,7 +1435,7 @@ | ||
1435 | <script src="app/services/TermService.js"></script> | 1435 | <script src="app/services/TermService.js"></script> |
1436 | <script src="libs/jquery/jquery_plugin/jqueryui.js"></script> | 1436 | <script src="libs/jquery/jquery_plugin/jqueryui.js"></script> |
1437 | <script src="libs/jquery/jquery_plugin/slider-pips/jquery-ui-slider-pips.js"></script> | 1437 | <script src="libs/jquery/jquery_plugin/slider-pips/jquery-ui-slider-pips.js"></script> |
1438 | - | 1438 | + <script src="../app/services/LabExerciseService.js"></script> |
1439 | <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script> | 1439 | <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script> |
1440 | 1440 | ||
1441 | <script src="libs/jquery/jquery_plugin/color-picker/jquery.minicolors.min.js"></script> | 1441 | <script src="libs/jquery/jquery_plugin/color-picker/jquery.minicolors.min.js"></script> |