projects
/
qomet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
allow <code class=...>, temporary MathJax fix, try to fix pre-filled inputs bug
[qomet.git]
/
public
/
javascripts
/
assessment.js
diff --git
a/public/javascripts/assessment.js
b/public/javascripts/assessment.js
index
5fe24cd
..
91e34fc
100644
(file)
--- a/
public/javascripts/assessment.js
+++ b/
public/javascripts/assessment.js
@@
-15,6
+15,15
@@
function checkWindowSize()
return window.innerWidth >= screen.width-3 && window.innerHeight >= screen.height-3;
};
return window.innerWidth >= screen.width-3 && window.innerHeight >= screen.height-3;
};
+function libsRefresh()
+{
+ // Run Prism + MathJax on questions text
+ $("#statements").find("code[class^=language-]").each( (i,elem) => {
+ Prism.highlightElement(elem);
+ });
+ MathJax.Hub.Queue(["Typeset",MathJax.Hub,"statements"]);
+}
+
new Vue({
el: "#assessment",
data: {
new Vue({
el: "#assessment",
data: {
@@
-183,6
+192,9
@@
new Vue({
document.location.href= "/fullscreen";
}, false);
},
document.location.href= "/fullscreen";
}, false);
},
+ updated: function() {
+ libsRefresh(); //TODO: shouldn't be required: "MathJax" strings on start and assign them to assessment.questions. ...
+ },
methods: {
inputId: function(i,j) {
return "q" + i + "_" + "input" + j;
methods: {
inputId: function(i,j) {
return "q" + i + "_" + "input" + j;
@@
-193,14
+205,15
@@
new Vue({
},
// stage 2
sendAnswer: function(realIndex) {
},
// stage 2
sendAnswer: function(realIndex) {
- console.log(realIndex);
- if (assessment.index == assessment.questions.length - 1)
- this.$emit("gameover");
- else
- assessment.index++;
- this.$forceUpdate(); //TODO: shouldn't be required
+ let gotoNext = () => {
+ if (assessment.index == assessment.questions.length - 1)
+ this.$emit("gameover");
+ else
+ assessment.index++;
+ this.$forceUpdate(); //TODO: shouldn't be required
+ };
if (assessment.mode == "open")
if (assessment.mode == "open")
- return; //only local
+ return
gotoNext()
; //only local
let answerData = {
aid: assessment._id,
answer: JSON.stringify({
let answerData = {
aid: assessment._id,
answer: JSON.stringify({
@@
-220,6
+233,8
@@
new Vue({
success: ret => {
if (!!ret.errmsg)
return this.$emit("warning", ret.errmsg);
success: ret => {
if (!!ret.errmsg)
return this.$emit("warning", ret.errmsg);
+ else
+ gotoNext();
//socket.emit(message.newAnswer, answer);
},
});
//socket.emit(message.newAnswer, answer);
},
});
@@
-278,7
+293,8
@@
new Vue({
$("#leftButton, #rightButton").hide();
if (assessment.time > 0)
{
$("#leftButton, #rightButton").hide();
if (assessment.time > 0)
{
- this.remainingTime = assessment.time * 60 - (!!paper ? paper.startTime/1000 : 0);
+ const deltaTime = !!paper ? Date.now() - paper.startTime : 0;
+ this.remainingTime = assessment.time * 60 - Math.round(deltaTime / 1000);
this.runTimer();
}
// Initialize structured answer(s) based on questions type and nesting (TODO: more general)
this.runTimer();
}
// Initialize structured answer(s) based on questions type and nesting (TODO: more general)
@@
-296,18
+312,12
@@
new Vue({
{
// Resuming
let indices = paper.inputs.map( input => { return input.index; });
{
// Resuming
let indices = paper.inputs.map( input => { return input.index; });
- let remainingIndices = _.difference(
_.range(assessment.questions.length), indices
);
+ let remainingIndices = _.difference(
_.range(assessment.questions.length).map(String), indices
);
assessment.indices = indices.concat( _.shuffle(remainingIndices) );
}
assessment.index = !!paper ? paper.inputs.length : 0;
assessment.indices = indices.concat( _.shuffle(remainingIndices) );
}
assessment.index = !!paper ? paper.inputs.length : 0;
+ Vue.nextTick(libsRefresh);
this.stage = 2;
this.stage = 2;
- Vue.nextTick( () => {
- // Run Prism + MathJax on questions text
- $("#statements").find("code[class^=language-]").each( (i,elem) => {
- Prism.highlightElement(elem);
- });
- MathJax.Hub.Queue(["Typeset",MathJax.Hub,"statements"]);
- });
};
if (assessment.mode == "open")
return initializeStage2();
};
if (assessment.mode == "open")
return initializeStage2();