Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit a933b8d

Browse files
committed
Fix: BookServer was returning different results for timed
* The counts were incorrect * Skipped was always == the array length * No feedback shown even if feedback should be shown * clean up some components where feedback was not right.
1 parent 05b8a92 commit a933b8d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

runestone/clickableArea/js/timedclickable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import ClickableArea from "./clickable.js";
55
export default class TimedClickableArea extends ClickableArea {
66
constructor(opts) {
77
super(opts);
8-
this.restoreAnswers({});
8+
if (! this.assessmentTaken){
9+
this.restoreAnswers({}); // This takes the place of reinitializeListeners -- but might be better to implement that method for consistency.
10+
}
911
this.renderTimedIcon(this.containerDiv);
1012
this.hideButtons();
1113
}

runestone/timed/js/timed.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ export default class Timed extends RunestoneBase {
649649
let componentKind = $(tmpChild).data("component");
650650
this.renderedQuestionArray[this.currentQuestionIndex] = {
651651
question: window.component_factory[componentKind](opts),
652+
state: opts.state,
652653
};
653654
}
654655
} else if (opts.state === "broken_exam") {
@@ -658,6 +659,7 @@ export default class Timed extends RunestoneBase {
658659
currentQuestion =
659660
this.renderedQuestionArray[this.currentQuestionIndex].question;
660661
if (opts.state === "forreview") {
662+
await currentQuestion.component_ready_promise;
661663
await currentQuestion.checkCurrentAnswer();
662664
currentQuestion.renderFeedback();
663665
currentQuestion.disableInteraction();
@@ -1156,7 +1158,7 @@ export default class Timed extends RunestoneBase {
11561158
parseInt(data.correct),
11571159
parseInt(data.incorrect),
11581160
parseInt(data.skipped),
1159-
parseInt(data.timeTaken),
1161+
parseInt(data.time_taken),
11601162
data.reset,
11611163
];
11621164
this.setLocalStorage(tmpArr);
@@ -1173,6 +1175,11 @@ export default class Timed extends RunestoneBase {
11731175
this.incorrect = tmpArr[1];
11741176
this.skipped = tmpArr[2];
11751177
this.timeTaken = tmpArr[3];
1178+
} else if (tmpArr.length == 5) {
1179+
this.score = tmpArr[0];
1180+
this.incorrect = tmpArr[1];
1181+
this.skipped = tmpArr[2];
1182+
this.timeTaken = tmpArr[3];
11761183
} else if (tmpArr.length == 7) {
11771184
// Loaded Completed Exam
11781185
this.score = tmpArr[0];
@@ -1224,14 +1231,14 @@ export default class Timed extends RunestoneBase {
12241231
scoreString = `Num Correct: ${this.score}. Questions: ${this.correctStr}<br>Num Wrong: ${this.incorrect}. Questions: ${this.incorrectStr}<br>Num Skipped: ${this.skipped}. Questions: ${this.skippedStr}<br>`;
12251232
numQuestions = this.score + this.incorrect + this.skipped;
12261233
percentCorrect = (this.score / numQuestions) * 100;
1227-
scoreString += "Percent Correct: " + percentCorrect + "%";
1234+
scoreString += "Percent Correct: " + percentCorrect.toFixed(2) + "%";
12281235
$(this.scoreDiv).html(scoreString);
12291236
this.scoreDiv.style.display = "block";
12301237
} else {
12311238
scoreString = `Num Correct: ${this.score}<br>Num Wrong: ${this.incorrect}<br>Num Skipped: ${this.skipped}<br>`;
12321239
numQuestions = this.score + this.incorrect + this.skipped;
12331240
percentCorrect = (this.score / numQuestions) * 100;
1234-
scoreString += "Percent Correct: " + percentCorrect + "%";
1241+
scoreString += "Percent Correct: " + percentCorrect.toFixed(2) + "%";
12351242
$(this.scoreDiv).html(scoreString);
12361243
this.scoreDiv.style.display = "block";
12371244
}

0 commit comments

Comments
 (0)