Skip to content

Commit dec4f96

Browse files
committed
gulp commit
1 parent 12cfc8a commit dec4f96

File tree

2 files changed

+154
-154
lines changed

2 files changed

+154
-154
lines changed

public/scripts/all.js

Lines changed: 105 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,111 @@ angular.module('myApp', ['ui.router', 'ui.ace', 'ngWebworker'])
4040

4141
}]) // end config
4242

43+
angular.module('myApp')
44+
45+
.controller('assessmentController', ["$scope", "assessmentService", "workerService", function($scope, assessmentService, workerService) {
46+
47+
assessmentService.getAssessment().then(function(response) {
48+
var list = [];
49+
_.each(response, function(item) {
50+
for (var i = 0; i < item.questions.length; i++) {
51+
list.push(item.questions[i]);
52+
}
53+
})
54+
// console.log(list);
55+
$scope.questions = list;
56+
});
57+
58+
$scope.eval = function(q, userCode) {
59+
60+
61+
let qId = q._id;
62+
let answer = q.answer;
63+
64+
workerService.worker(qId, answer, userCode).then(function(result) {
65+
assessmentService.ticker(result);
66+
})
67+
68+
}
69+
70+
$scope.submitAssessment = (length) => {
71+
assessmentService.submitAssessment(length);
72+
}
73+
74+
$scope.doSomeStuff = function(q) {
75+
q.disabled = true;
76+
}
77+
78+
79+
}]);
80+
81+
angular.module('myApp')
82+
83+
.service('assessmentService', ["$q", "$http", function($q, $http) {
84+
85+
86+
87+
this.getAssessment = () => {
88+
return $http({
89+
method: 'GET',
90+
url: '/api/assessment/js'
91+
}).then((response) => {
92+
93+
return response.data;
94+
})
95+
}
96+
97+
var tick = 0;
98+
this.ticker = (result) => {
99+
if (result === true) {
100+
tick += 1;
101+
}else {
102+
return 0;
103+
}
104+
console.log("tick count", tick);
105+
}
106+
107+
this.submitAssessment = (length) => {
108+
var totalScore = (tick / length) * 100;
109+
totalScore = totalScore.toString();
110+
console.log(totalScore);
111+
return $http({
112+
method: 'PUT',
113+
url: '/api/users',
114+
data: {
115+
progress: {
116+
jsAssessment: totalScore
117+
}
118+
}
119+
}).success(function(resp) {
120+
console.log(resp);
121+
})
122+
}
123+
124+
}])
125+
126+
angular.module('myApp').service('workerService', ["Webworker", function(Webworker) {
127+
128+
this.worker = (qId, answer, userCode) => {
129+
130+
function isSame(userCode, answer) {
131+
if (userCode === answer) {
132+
return true;
133+
} else {
134+
return false;
135+
}
136+
}
137+
138+
var myWorker = Webworker.create(isSame, {
139+
isSame: true,
140+
onReturn: function(data) {return data;}
141+
});
142+
143+
var result = myWorker.run(userCode, answer);
144+
return result;
145+
}
146+
}])
147+
43148
angular.module('myApp')
44149

45150
.directive('bars', function () {
@@ -418,111 +523,6 @@ angular.module('myApp')
418523

419524
angular.module('myApp')
420525

421-
.controller('assessmentController', ["$scope", "assessmentService", "workerService", function($scope, assessmentService, workerService) {
422-
423-
assessmentService.getAssessment().then(function(response) {
424-
var list = [];
425-
_.each(response, function(item) {
426-
for (var i = 0; i < item.questions.length; i++) {
427-
list.push(item.questions[i]);
428-
}
429-
})
430-
// console.log(list);
431-
$scope.questions = list;
432-
});
433-
434-
$scope.eval = function(q, userCode) {
435-
436-
437-
let qId = q._id;
438-
let answer = q.answer;
439-
440-
workerService.worker(qId, answer, userCode).then(function(result) {
441-
assessmentService.ticker(result);
442-
})
443-
444-
}
445-
446-
$scope.submitAssessment = (length) => {
447-
assessmentService.submitAssessment(length);
448-
}
449-
450-
$scope.doSomeStuff = function(q) {
451-
q.disabled = true;
452-
}
453-
454-
455-
}]);
456-
457-
angular.module('myApp')
458-
459-
.service('assessmentService', ["$q", "$http", function($q, $http) {
460-
461-
462-
463-
this.getAssessment = () => {
464-
return $http({
465-
method: 'GET',
466-
url: '/api/assessment/js'
467-
}).then((response) => {
468-
469-
return response.data;
470-
})
471-
}
472-
473-
var tick = 0;
474-
this.ticker = (result) => {
475-
if (result === true) {
476-
tick += 1;
477-
}else {
478-
return 0;
479-
}
480-
console.log("tick count", tick);
481-
}
482-
483-
this.submitAssessment = (length) => {
484-
var totalScore = (tick / length) * 100;
485-
totalScore = totalScore.toString();
486-
console.log(totalScore);
487-
return $http({
488-
method: 'PUT',
489-
url: '/api/users',
490-
data: {
491-
progress: {
492-
jsAssessment: totalScore
493-
}
494-
}
495-
}).success(function(resp) {
496-
console.log(resp);
497-
})
498-
}
499-
500-
}])
501-
502-
angular.module('myApp').service('workerService', ["Webworker", function(Webworker) {
503-
504-
this.worker = (qId, answer, userCode) => {
505-
506-
function isSame(userCode, answer) {
507-
if (userCode === answer) {
508-
return true;
509-
} else {
510-
return false;
511-
}
512-
}
513-
514-
var myWorker = Webworker.create(isSame, {
515-
isSame: true,
516-
onReturn: function(data) {return data;}
517-
});
518-
519-
var result = myWorker.run(userCode, answer);
520-
return result;
521-
}
522-
}])
523-
524-
angular.module('myApp')
525-
526526
.controller('lessonTestsController', ["$scope", function($scope) {
527527

528528

public/styles/styles.css

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,54 @@ a {
1111
text-decoration: none;
1212
color: white; }
1313

14+
#assessment-view .code-input-wrapper {
15+
display: flex;
16+
justify-content: center;
17+
margin: 10px 0 10px 0; }
18+
19+
#assessment-view .ace_editor {
20+
height: 200px; }
21+
22+
#assessment-view .assessment-eval {
23+
color: #fff;
24+
margin: 1em; }
25+
26+
#assessment-view button {
27+
background: #406BB2;
28+
padding: 10px 16px;
29+
width: auto;
30+
font-weight: 600;
31+
text-transform: uppercase;
32+
font-size: 14px;
33+
color: #fff;
34+
line-height: 16px;
35+
letter-spacing: 0.5px;
36+
border-radius: 2px;
37+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.1);
38+
border: 0;
39+
outline: 0;
40+
transition: all 0.25s; }
41+
42+
#assessment-view button:hover {
43+
background: #8FB9FF;
44+
box-shadow: 0 4px 7px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.1); }
45+
46+
#assessment-view button:disabled {
47+
visibility: hidden; }
48+
49+
#assessment-view #submit-assessment {
50+
float: right;
51+
margin: 4em; }
52+
53+
#assessment-view .stuff {
54+
color: #406BB2;
55+
width: 90vw;
56+
margin: 1em; }
57+
58+
#assessment-view input {
59+
width: 100vw;
60+
height: 20vh; }
61+
1462
#dashboard-wrapper {
1563
width: 100vw;
1664
height: 91vh;
@@ -111,55 +159,6 @@ a {
111159
#unit-subview #js-graph-div rect:hover {
112160
fill: #8FB9FF; }
113161

114-
#assessment-view .code-input-wrapper {
115-
display: flex;
116-
justify-content: center;
117-
margin: 10px 0 10px 0; }
118-
119-
#assessment-view .ace_editor {
120-
height: 200px; }
121-
122-
#assessment-view .assessment-eval {
123-
color: #fff;
124-
margin: 1em; }
125-
126-
#assessment-view button {
127-
background: #406BB2;
128-
padding: 10px 16px;
129-
width: auto;
130-
font-weight: 600;
131-
text-transform: uppercase;
132-
font-size: 14px;
133-
color: #fff;
134-
line-height: 16px;
135-
letter-spacing: 0.5px;
136-
border-radius: 2px;
137-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.1);
138-
border: 0;
139-
outline: 0;
140-
transition: all 0.25s; }
141-
142-
#assessment-view button:hover {
143-
background: #8FB9FF;
144-
box-shadow: 0 4px 7px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.1); }
145-
146-
#assessment-view button:disabled {
147-
visibility: hidden; }
148-
149-
#assessment-view #submit-assessment {
150-
float: right;
151-
margin: 4em; }
152-
153-
#assessment-view .stuff {
154-
color: #406BB2;
155-
width: 90vw;
156-
margin: 1em; }
157-
158-
#assessment-view input {
159-
width: 100vw;
160-
height: 20vh; }
161-
162-
163162
#home-wrapper {
164163
font-family: 'Lato';
165164
position: absolute;
@@ -199,6 +198,7 @@ button:hover {
199198
background: #8FB9FF;
200199
box-shadow: 0 4px 7px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.1); }
201200

201+
202202
.lessonTests {
203203
position: relative;
204204
left: 50%;

0 commit comments

Comments
 (0)