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

Commit 1c65d5b

Browse files
committed
prevent loading ans from localstorage when grading
1 parent 9643156 commit 1c65d5b

5 files changed

Lines changed: 45 additions & 24 deletions

File tree

runestone/clickableArea/js/clickable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ ClickableArea.prototype.restoreAnswers = function (data) {
156156

157157

158158
ClickableArea.prototype.checkLocalStorage = function () {
159+
if (this.graderactive) {
160+
return;
161+
}
159162
// Gets previous answer data from local storage if it exists
160163
this.hasStoredAnswers = false;
161164
var len = localStorage.length;

runestone/dragndrop/js/dragndrop.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ DragNDrop.prototype.restoreAnswers = function (data) {
380380
};
381381

382382
DragNDrop.prototype.checkLocalStorage = function () {
383+
384+
if (this.graderactive) {
385+
return;
386+
}
387+
383388
this.hasStoredDropzones = false;
384389
var len = localStorage.length;
385390
if (len > 0) {

runestone/fitb/js/fitb.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ FITB.prototype.restoreAnswers = function (data) {
159159

160160
FITB.prototype.checkLocalStorage = function () {
161161
// Loads previous answers from local storage if they exist
162+
if (this.graderactive) {
163+
return;
164+
}
165+
162166
var len = localStorage.length;
163167
if (len > 0) {
164168
var ex = localStorage.getItem(this.localStorageKey());

runestone/parsons/js/parsons.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ ParsonsBlock.prototype.consumeBlock = function(block) {
363363
for (var i = 0; i < block.labels.length; i++) {
364364
this.addLabel(block.labels[i][0], this.lines.length - block.lines.length + block.labels[i][1]);
365365
}
366-
366+
367367
this.problem.blocks = newBlocks;
368368
this.problem.state = undefined;
369369
this.problem.updateView();
@@ -391,7 +391,7 @@ ParsonsBlock.prototype.addIndent = function() {
391391
ParsonsBlock.prototype.addLabel = function(label, line) {
392392
var div = document.createElement("div");
393393
$(div).addClass("block-label");
394-
394+
395395
if(this.problem.options.numbered == "right") {
396396
$(div).addClass("right-label");
397397
}
@@ -404,7 +404,7 @@ ParsonsBlock.prototype.addLabel = function(label, line) {
404404
if(this.labels.length != 0) {
405405
$(div).css("margin-top", (line - this.labels[this.labels.length - 1][1] - 1) * this.lines[line].view.offsetHeight);
406406
}
407-
407+
408408
this.labels.push([label, line]);
409409
}
410410

@@ -1133,7 +1133,7 @@ Parsons.prototype.initializeOptions = function() {
11331133

11341134
var numbered = $(this.origElem).data('numbered');
11351135
options["numbered"] = numbered;
1136-
1136+
11371137
if (maxdist !== undefined) {
11381138
options["maxdist"] = maxdist;
11391139
}
@@ -1302,7 +1302,7 @@ Parsons.prototype.initializeLines = function(text) {
13021302
for (var i = 0; i < textBlocks.length; i++) {
13031303
var textBlock = textBlocks[i];
13041304

1305-
// Figure out options based on the #option
1305+
// Figure out options based on the #option
13061306
// Remove the options from the code
13071307
// only options are #paired or #distractor
13081308
var options = {};
@@ -1435,7 +1435,7 @@ Parsons.prototype.initializeAreas = function(sourceBlocks, answerBlocks, options
14351435
addition = 2.1;
14361436
areaHeight += (item.outerHeight(true)+height_add*addition);
14371437
areaWidth = Math.max(areaWidth, item.outerWidth(true));
1438-
1438+
14391439
};
14401440
}
14411441
for (i = 0; i < blocks.length; i++) {
@@ -1460,7 +1460,7 @@ Parsons.prototype.initializeAreas = function(sourceBlocks, answerBlocks, options
14601460
} else {
14611461
$(this.answerArea).addClass("answer");
14621462
}
1463-
1463+
14641464
// Initialize paired distractor decoration
14651465
var bins = [];
14661466
var bin = [];
@@ -1505,7 +1505,7 @@ Parsons.prototype.initializeAreas = function(sourceBlocks, answerBlocks, options
15051505
var pairedDiv = document.createElement("div");
15061506
$(pairedDiv).addClass("paired");
15071507
$(pairedDiv).html("<span id= 'st' style = 'vertical-align: middle; font-weight: bold'>or{</span>");
1508-
1508+
15091509
pairedDivs.push(pairedDiv);
15101510
this.sourceArea.appendChild(pairedDiv);
15111511
}
@@ -1518,7 +1518,7 @@ Parsons.prototype.initializeAreas = function(sourceBlocks, answerBlocks, options
15181518
if(this.options.numbered != undefined) {
15191519
this.addBlockLabels(sourceBlocks.concat(answerBlocks));
15201520
}
1521-
1521+
15221522
// Update the view
15231523
this.state = undefined; // needs to be here for loading from storage
15241524
this.updateView();
@@ -1629,6 +1629,11 @@ Parsons.prototype.restoreAnswers = function(serverData) {
16291629

16301630
// RunestoneBase: Load what is in local storage
16311631
Parsons.prototype.checkLocalStorage = function () {
1632+
1633+
if (this.graderactive) {
1634+
return;
1635+
}
1636+
16321637
this.loadData(this.localData());
16331638
};
16341639

@@ -1806,13 +1811,13 @@ Parsons.prototype.adaptBlocks = function(input) {
18061811
blocks.push(block);
18071812
}
18081813
}
1809-
1814+
18101815
this.recentAttempts = localStorage.getItem(this.adaptiveId + "recentAttempts");
18111816
if(this.recentAttempts == undefined || this.recentAttempts == "NaN") {
18121817
this.recentAttempts = 3;
18131818
}
18141819

1815-
var lastestAttemptCount = this.recentAttempts;
1820+
var lastestAttemptCount = this.recentAttempts;
18161821
var nBlocks = blocks.length;
18171822
var nBlocksToCombine = 0;
18181823
var nDistractors = distractors.length;
@@ -1837,7 +1842,7 @@ Parsons.prototype.adaptBlocks = function(input) {
18371842
// Remove all of distractors
18381843
nToRemove = nDistractors;
18391844
this.pairDistractors = true;
1840-
}
1845+
}
18411846
/*
18421847
else if(lastestAttemptCount < 12) { //10-11
18431848
// Remove all distractors and give indentation
@@ -2040,7 +2045,7 @@ Parsons.prototype.blocksFromSource = function() {
20402045
//move pairs together
20412046
//Go through array looking for ditractor and its pair
20422047
for(i = 1; i < originalBlocks.length; i++) {
2043-
if(originalBlocks[i].lines[0].paired && $.inArray(originalBlocks[i], blocks) >= 0) {
2048+
if(originalBlocks[i].lines[0].paired && $.inArray(originalBlocks[i], blocks) >= 0) {
20442049
var j = i;
20452050
while($.inArray(originalBlocks[j - 1], blocks) < 0) { // find the paired distractor or solution block it will be next to
20462051
j--;
@@ -2051,7 +2056,7 @@ Parsons.prototype.blocksFromSource = function() {
20512056
blocks.splice(indexTo, 0, originalBlocks[i]);
20522057
}
20532058
}
2054-
}
2059+
}
20552060
return blocks;
20562061
};
20572062

@@ -2226,8 +2231,8 @@ Parsons.prototype.checkMe = function() {
22262231
this.recentAttempts = this.checkCount;
22272232
this.checkCount = 0;
22282233
localStorage.setItem(this.adaptiveId + "recentAttempts", this.recentAttempts);
2229-
}
2230-
localStorage.setItem(this.adaptiveId + this.divid + "Count", this.checkCount);
2234+
}
2235+
localStorage.setItem(this.adaptiveId + this.divid + "Count", this.checkCount);
22312236

22322237
this.logAnswer(grade);
22332238
this.setLocalStorage();
@@ -2298,9 +2303,9 @@ Parsons.prototype.initializeAdaptive = function() {
22982303
}
22992304
this.checkCount = count;
23002305

2301-
2306+
23022307
this.recentAttempts = localStorage.getItem(this.adaptiveId + "recentAttempts");
2303-
2308+
23042309
if(this.recentAttempts == undefined || this.recentAttempts == "NaN") {
23052310
this.recentAttempts = 3;
23062311
}
@@ -2732,7 +2737,7 @@ Parsons.prototype.helpMe = function() {
27322737
// this.helpCount = Math.max(this.helpCount, -1); // min 1 attempt before more help
27332738
//this.helpButton.disabled = true;
27342739
//}
2735-
2740+
27362741
// if less than 3 attempts
27372742
if (this.numDistinct < 3)
27382743
{
@@ -2986,10 +2991,10 @@ Parsons.prototype.updateView = function() {
29862991
if (matching.length == 0) {
29872992
$(div).hide();
29882993
} else {
2989-
$(div).show();
2994+
$(div).show();
2995+
29902996

29912997

2992-
29932998
var height = -5;
29942999
height += parseInt($(matching[matching.length - 1].view).css("top"));
29953000
height -= parseInt($(matching[0].view).css("top"));
@@ -3127,7 +3132,7 @@ Parsons.prototype.addBlockLabels = function(blocks) {
31273132
}
31283133
}
31293134
for (var i = 0; i < blocks.length; i++) {
3130-
3135+
31313136
var currentBin = blocks[i].pairedBin();
31323137
if(currentBin == -1 || currentBin != bin) {
31333138
bin = currentBin;
@@ -3141,7 +3146,7 @@ Parsons.prototype.addBlockLabels = function(blocks) {
31413146
blocks[i].addLabel(label, 0);
31423147
binChildren++;
31433148
}
3144-
3149+
31453150
if(blocksNotInBins + this.pairedBins.length >= 10) {
31463151
this.areaWidth += 5;
31473152
$(this.sourceArea).css({
@@ -3150,7 +3155,7 @@ Parsons.prototype.addBlockLabels = function(blocks) {
31503155
$(this.answerArea).css({
31513156
'width' : $(this.answerArea).width() + 5,
31523157
});
3153-
}
3158+
}
31543159
}
31553160

31563161
// Put all the blocks back into the source area, reshuffling as necessary

runestone/shortanswer/js/shortanswer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ ShortAnswer.prototype.setLocalStorage = function(data) {
150150
ShortAnswer.prototype.checkLocalStorage = function () {
151151
// Repopulates the short answer text
152152
// which was stored into local storage.
153+
if (this.graderactive) {
154+
return;
155+
}
156+
153157
var len = localStorage.length;
154158
if (len > 0) {
155159
var ex = localStorage.getItem(this.localStorageKey());

0 commit comments

Comments
 (0)