diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..638fe5f03 --- /dev/null +++ b/.flake8 @@ -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 diff --git a/runestone/clickableArea/js/clickable.js b/runestone/clickableArea/js/clickable.js index f51867301..61c5bef7c 100644 --- a/runestone/clickableArea/js/clickable.js +++ b/runestone/clickableArea/js/clickable.js @@ -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" }); } diff --git a/runestone/dragndrop/js/dragndrop.js b/runestone/dragndrop/js/dragndrop.js index ad4173087..eeab6fe42 100644 --- a/runestone/dragndrop/js/dragndrop.js +++ b/runestone/dragndrop/js/dragndrop.js @@ -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" }); } diff --git a/runestone/fitb/js/fitb.js b/runestone/fitb/js/fitb.js index b146d2396..02c251627 100644 --- a/runestone/fitb/js/fitb.js +++ b/runestone/fitb/js/fitb.js @@ -321,6 +321,8 @@ export default class FITB extends RunestoneBase { } } } + this.percent = + this.isCorrectArray.filter(Boolean).length / this.blankArray.length; } renderFeedback() { diff --git a/runestone/mchoice/js/mchoice.js b/runestone/mchoice/js/mchoice.js index d8073fb73..890491d05 100644 --- a/runestone/mchoice/js/mchoice.js +++ b/runestone/mchoice/js/mchoice.js @@ -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() { @@ -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; } } diff --git a/runestone/parsons/js/parsons.js b/runestone/parsons/js/parsons.js index aa6f4db68..b7d4a640a 100644 --- a/runestone/parsons/js/parsons.js +++ b/runestone/parsons/js/parsons.js @@ -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; } } } @@ -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");