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

Commit a56ff37

Browse files
committed
Minor pct correct grading cleanups
Signed-off-by: Brad Miller <bonelake@mac.com>
1 parent 15d05c8 commit a56ff37

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

runestone/mchoice/js/mchoice.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*==========================================
1+
p; /*==========================================
22
======== Master mchoice.js =========
33
============================================
44
=== This file contains the JS for the ===
@@ -453,10 +453,8 @@ export default class MultipleChoice extends RunestoneBase {
453453
this.correct = numCorrect === numNeeded && numNeeded === numGiven;
454454
if (numGiven === numNeeded) {
455455
this.percent = numCorrect / numNeeded;
456-
} else if (numGiven < numNeeded) {
457-
this.percent = (numCorrect - (numNeeded - numGiven)) / numNeeded;
458456
} else {
459-
this.percent = (numCorrect - (numGiven - numNeeded)) / numNeeded;
457+
this.percent = numCorrect / Math.max(numGiven, numNeeded);
460458
}
461459
}
462460

runestone/parsons/js/parsons.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ class LineBasedGrader {
8888
var answerLines = problem.answerLines();
8989
var i;
9090
var state;
91-
this.percentLines = answerLines.length / solutionLines.length;
91+
this.percentLines =
92+
Math.min(answerLines.length, solutionLines.length) /
93+
Math.max(answerLines.length, solutionLines.length);
9294
if (answerLines.length < solutionLines.length) {
9395
state = "incorrectTooShort";
9496
this.correctLength = false;
@@ -1466,7 +1468,8 @@ export default class Parsons extends RunestoneBase {
14661468
// Increment Parsons area height based on number of lines of text in the current Parsons block - Vincent Qiu (September 2020)
14671469
var singleHeight = 40;
14681470
var additionalHeight = 20;
1469-
areaHeight += Math.ceil( // For future more accurate height display, this calculation should also be conditionally based on fontFamily
1471+
areaHeight += Math.ceil(
1472+
// For future more accurate height display, this calculation should also be conditionally based on fontFamily
14701473
singleHeight +
14711474
(linesItem[linesIndex].children.length - 1) *
14721475
additionalHeight +

0 commit comments

Comments
 (0)