Skip to content

Commit

Permalink
Add Percent attribute to all gradables
Browse files Browse the repository at this point in the history
  • Loading branch information
runestonetest committed Nov 11, 2020
1 parent c3dda23 commit 57d474f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[flake8]
max-line-length=88
ignore=F821,
W503,
E203, # space before :
E501,
E265,
E266, # too many #
E711,
E712 # web2py needs to compare to == True or == False for queries

builtins=settings,
request,
response,
db,
auth,
redirect,
XML,
URL,
T,
HTTP,
cache,
gluon,
verifyInstructorStatus
1 change: 1 addition & 0 deletions runestone/clickableArea/js/clickable.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ export default class ClickableArea extends RunestoneBase {
$(this.incorrectArray[i]).removeClass("clickable-incorrect");
}
}
this.percent = this.correctNum / (this.correctNum + this.incorrectNum);
this.setLocalStorage({ correct: this.correct ? "T" : "F" });
}

Expand Down
1 change: 1 addition & 0 deletions runestone/dragndrop/js/dragndrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ export default class DragNDrop extends RunestoneBase {
}
}
this.correctNum = this.dragNum - this.incorrectNum - this.unansweredNum;
this.percent = this.correctNum / this.dragPairArray.length;
this.setLocalStorage({ correct: this.correct ? "T" : "F" });
}

Expand Down
2 changes: 2 additions & 0 deletions runestone/fitb/js/fitb.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ export default class FITB extends RunestoneBase {
}
}
}
this.percent =
this.isCorrectArray.filter(Boolean).length / this.blankArray.length;
}

renderFeedback() {
Expand Down
9 changes: 9 additions & 0 deletions runestone/mchoice/js/mchoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ export default class MultipleChoice extends RunestoneBase {
var numNeeded = this.correctList.length;
this.answer = this.givenArray.join(",");
this.correct = numCorrect === numNeeded && numNeeded === numGiven;
if (numGiven === numNeeded) {
this.percent = numCorrect / numNeeded;
} else if (numGiven < numNeeded) {
this.percent = (numCorrect - (numNeeded - numGiven)) / numNeeded;
} else {
this.percent = (numCorrect - numGiven - numNeeded) / numNeeded;
}
}

logMCMAsubmission() {
Expand Down Expand Up @@ -507,9 +514,11 @@ export default class MultipleChoice extends RunestoneBase {
scoreMCMFSubmission() {
if (this.givenArray[0] == this.correctIndexList[0]) {
this.correct = true;
this.percent = 1.0;
} else if (this.givenArray[0] != null) {
// if given is null then the question wasn"t answered and should be counted as skipped
this.correct = false;
this.percent = 0.0;
}
}

Expand Down
9 changes: 8 additions & 1 deletion runestone/parsons/js/parsons.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ class LineBasedGrader {
} else {
// Determine whether the code is in the correct order
var isCorrectOrder = false;
this.correctLength = false;
if (answerLines.length == solutionLines.length) {
this.correctLength = true;
isCorrectOrder = true;
this.correctLines = 0;
this.solutionLength = solutionLines.length;
for (i = 0; i < solutionLines.length; i++) {
if (answerLines[i].text !== solutionLines[i].text) {
isCorrectOrder = false;
} else {
this.correctLines += 1;
}
}
}
Expand All @@ -124,7 +130,8 @@ class LineBasedGrader {
indentLeft.push(answerLines[i]);
}
}
if (indentLeft.length + indentRight.length == 0) {
this.incorrectIndents = indentLeft.length + indentRight.length;
if (this.incorrectIndents == 0) {
// Perfect
state = "correct";
answerArea.addClass("correct");
Expand Down

0 comments on commit 57d474f

Please sign in to comment.