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

Commit fe58d84

Browse files
committed
New: disable scratch AC during exam
1 parent 59c9e4c commit fe58d84

File tree

4 files changed

+49
-42
lines changed

4 files changed

+49
-42
lines changed

runestone/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .dragndrop import DragNDrop
1414
from .fitb import FillInTheBlank
1515
from .groupsub import GroupSubmission
16-
from .hparsons import HParsonsNode
16+
from .hparsons import HParsonsDirective
1717
from .khanex import Khanex
1818
from .selectquestion import SelectQuestion
1919
from .matrixeq import MatrixEq
@@ -247,7 +247,7 @@ def build(options):
247247
"disqus": DisqusDirective,
248248
"dragndrop": DragNDrop,
249249
"groupsub": GroupSubmission,
250-
"hparsons": HParsonsNode,
250+
"hparsons": HParsonsDirective,
251251
"parsonsprob": ParsonsProblem,
252252
"poll": Poll,
253253
"quizly": Quizly,

runestone/activecode/js/acfactory.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export default class ACFactory {
150150
});
151151
}
152152
static toggleScratchActivecode() {
153+
if (!eBookConfig.enableScratchAC) return;
153154
var divid = "ac_modal_" + eBookConfig.scratchDiv;
154155
var div = $("#" + divid);
155156
$(`#${eBookConfig.scratchDiv}`).removeClass("ac_section");

runestone/common/project_template/_templates/plugin_layouts/sphinx_bootstrap/layout.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@
235235
eBookConfig = {};
236236
{% if dynamic_pages == 'True' %}
237237
{% raw %}
238-
eBookConfig.useRunestoneServices = true;
238+
eBookConfig.useRunestoneServices = {{ use_services }};
239239
eBookConfig.host = '';
240240
eBookConfig.app = eBookConfig.host + '/runestone';
241241
eBookConfig.course = '{{ course_name }}';
@@ -273,6 +273,7 @@
273273
eBookConfig.proxyuri_runs = '{{proxy_uri_runs}}';
274274
eBookConfig.proxyuri_files = '{{proxy_uri_files}}';
275275
eBookConfig.enable_chatcodes = {{enable_chatcodes}} ? {{ enable_chatcodes }} : false;
276+
eBookConfig.enableScratchAC = true;
276277

277278
</script>
278279

runestone/timed/js/timed.js

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class Timed extends RunestoneBase {
6363
if ($(this.origElem).is("[data-no-pause]")) {
6464
this.nopause = true;
6565
}
66-
66+
eBookConfig.enableScratchAC = false;
6767
this.running = 0;
6868
this.paused = 0;
6969
this.done = 0;
@@ -275,14 +275,14 @@ export default class Timed extends RunestoneBase {
275275
this.flagContainer = document.createElement("li");
276276
this.flagButton = document.createElement("button");
277277
$(this.flagButton).addClass("flagBtn");
278-
this.flagButton.innerHTML = "Flag Question"; // name on button
278+
this.flagButton.innerHTML = "Flag Question"; // name on button
279279
$(this.flagButton).attr("aria-labelledby", "Flag");
280280
$(this.flagButton).attr("tabindex", "5");
281281
$(this.flagButton).attr("role", "button");
282282
$(this.flagButton).attr("id", "flag");
283283
$(this.flagButton).css("cursor", "pointer");
284-
this.flagContainer.appendChild(this.flagButton); // adding button to container
285-
this.flaggingPlace.appendChild(this.flagContainer); // adding container to flaggingPlace
284+
this.flagContainer.appendChild(this.flagButton); // adding button to container
285+
this.flaggingPlace.appendChild(this.flagContainer); // adding container to flaggingPlace
286286
// making "Next" button
287287
this.rightContainer = document.createElement("li");
288288
this.rightNavButton = document.createElement("button");
@@ -296,7 +296,7 @@ export default class Timed extends RunestoneBase {
296296
this.pagNavList.appendChild(this.rightContainer);
297297
this.ensureButtonSafety();
298298
this.navDiv.appendChild(this.pagNavList);
299-
this.flagDiv.appendChild(this.flaggingPlace); // adds flaggingPlace to the flagDiv
299+
this.flagDiv.appendChild(this.flaggingPlace); // adds flaggingPlace to the flagDiv
300300
this.break = document.createElement("br");
301301
this.navDiv.appendChild(this.break);
302302
// render the question number jump buttons
@@ -319,7 +319,7 @@ export default class Timed extends RunestoneBase {
319319
this.qNumList.appendChild(this.qNumWrapperList);
320320
this.navDiv.appendChild(this.qNumList);
321321
this.navBtnListeners();
322-
this.flagBtnListener(); // listens for click on flag button
322+
this.flagBtnListener(); // listens for click on flag button
323323
$(this.flagButton).hide();
324324
}
325325

@@ -365,12 +365,14 @@ export default class Timed extends RunestoneBase {
365365
await this.navigateAway();
366366
}
367367
var target = $(event.target).text();
368-
if (target.match(/Next/)) { // checks given text to match "Next"
368+
if (target.match(/Next/)) {
369+
// checks given text to match "Next"
369370
if ($(this.rightContainer).hasClass("disabled")) {
370371
return;
371372
}
372373
this.currentQuestionIndex++;
373-
} else if (target.match(/Prev/)) { // checks given text to match "Prev"
374+
} else if (target.match(/Prev/)) {
375+
// checks given text to match "Prev"
374376
if ($(this.leftContainer).hasClass("disabled")) {
375377
return;
376378
}
@@ -392,26 +394,31 @@ export default class Timed extends RunestoneBase {
392394
$(
393395
"ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
394396
).addClass("active");
395-
if ($("ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
396-
).hasClass("flagcolor")) { // checking for class
397-
this.flagButton.innerHTML = "Unflag Question"; // changes text on button
398-
}
399-
else {
400-
this.flagButton.innerHTML = "Flag Question"; // changes text on button
397+
if (
398+
$(
399+
"ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
400+
).hasClass("flagcolor")
401+
) {
402+
// checking for class
403+
this.flagButton.innerHTML = "Unflag Question"; // changes text on button
404+
} else {
405+
this.flagButton.innerHTML = "Flag Question"; // changes text on button
401406
}
402407
}
403408

404409
async handleFlag(event) {
405410
// called when flag button is clicked
406-
var target = $(event.target).text()
411+
var target = $(event.target).text();
407412
if (target.match(/Flag Question/)) {
408-
$("ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
409-
).addClass("flagcolor"); // class will change color of question block
413+
$(
414+
"ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
415+
).addClass("flagcolor"); // class will change color of question block
410416
this.flagButton.innerHTML = "Unflag Question";
411417
} else {
412-
$("ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
413-
).removeClass("flagcolor"); // will restore current color of question block
414-
this.flagButton.innerHTML = "Flag Question"; // also sets name back
418+
$(
419+
"ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
420+
).removeClass("flagcolor"); // will restore current color of question block
421+
this.flagButton.innerHTML = "Flag Question"; // also sets name back
415422
}
416423
}
417424

@@ -441,11 +448,13 @@ export default class Timed extends RunestoneBase {
441448
$(
442449
"ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")"
443450
).addClass("active");
444-
if ($("ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")" // checking for flagcolor class
445-
).hasClass("flagcolor")) {
451+
if (
452+
$(
453+
"ul#pageNums > ul > li:eq(" + this.currentQuestionIndex + ")" // checking for flagcolor class
454+
).hasClass("flagcolor")
455+
) {
446456
this.flagButton.innerHTML = "Unflag Question";
447-
}
448-
else {
457+
} else {
449458
this.flagButton.innerHTML = "Flag Question";
450459
}
451460
await this.renderTimedQuestion();
@@ -473,7 +482,7 @@ export default class Timed extends RunestoneBase {
473482
flagBtnListener() {
474483
this.flaggingPlace.addEventListener(
475484
"click",
476-
this.handleFlag.bind(this), // calls this to take action
485+
this.handleFlag.bind(this), // calls this to take action
477486
false
478487
);
479488
}
@@ -583,9 +592,8 @@ export default class Timed extends RunestoneBase {
583592
currentIndex -= 1;
584593
// And swap it with the current element.
585594
temporaryValue = this.renderedQuestionArray[currentIndex];
586-
this.renderedQuestionArray[
587-
currentIndex
588-
] = this.renderedQuestionArray[randomIndex];
595+
this.renderedQuestionArray[currentIndex] =
596+
this.renderedQuestionArray[randomIndex];
589597
this.renderedQuestionArray[randomIndex] = temporaryValue;
590598
}
591599
}
@@ -629,9 +637,8 @@ export default class Timed extends RunestoneBase {
629637
}
630638
} catch (e) {
631639
opts.state = "broken_exam";
632-
this.renderedQuestionArray[
633-
this.currentQuestionIndex
634-
] = opts;
640+
this.renderedQuestionArray[this.currentQuestionIndex] =
641+
opts;
635642
console.log(
636643
`Error initializing question: Details ${e}`
637644
);
@@ -647,8 +654,8 @@ export default class Timed extends RunestoneBase {
647654
return;
648655
}
649656

650-
currentQuestion = this.renderedQuestionArray[this.currentQuestionIndex]
651-
.question;
657+
currentQuestion =
658+
this.renderedQuestionArray[this.currentQuestionIndex].question;
652659
if (opts.state === "forreview") {
653660
await currentQuestion.checkCurrentAnswer();
654661
currentQuestion.renderFeedback();
@@ -948,9 +955,8 @@ export default class Timed extends RunestoneBase {
948955
// send the final version of the question the student is on when they press the
949956
// finish exam button.
950957

951-
var currentQuestion = this.renderedQuestionArray[
952-
this.currentQuestionIndex
953-
].question;
958+
var currentQuestion =
959+
this.renderedQuestionArray[this.currentQuestionIndex].question;
954960
await currentQuestion.checkCurrentAnswer();
955961
await currentQuestion.logCurrentAnswer();
956962
currentQuestion.renderFeedback();
@@ -1000,9 +1006,8 @@ export default class Timed extends RunestoneBase {
10001006
this.incorrectStr = "";
10011007
// Gets the score of each problem
10021008
for (var i = 0; i < this.renderedQuestionArray.length; i++) {
1003-
var correct = this.renderedQuestionArray[
1004-
i
1005-
].question.checkCorrectTimed();
1009+
var correct =
1010+
this.renderedQuestionArray[i].question.checkCorrectTimed();
10061011
if (correct == "T") {
10071012
this.score++;
10081013
this.correctStr = this.correctStr + (i + 1) + ", ";

0 commit comments

Comments
 (0)