From b5544584886dacb0a1f99d7a06d171ec9cbf3552 Mon Sep 17 00:00:00 2001 From: Noah Paessel Date: Thu, 19 Apr 2012 11:46:42 -0400 Subject: [PATCH] Set tolerance of response criterion. --- .../numeric-sequence-no-visual-prompts.json | 15 +++++++++------ .../numeric-sequence-range-visual-prompts.json | 15 +++++++++------ .../point-circle-visual-prompt.json | 10 ++++++---- .../input/numeric-sequence-no-visual-prompts.json | 1 + lib/author/sequences.js | 6 ++++-- src/author/sequences.coffee | 11 ++++++++--- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/example-data/expected-ouput/numeric-sequence-no-visual-prompts.json b/example-data/expected-ouput/numeric-sequence-no-visual-prompts.json index cb248c0..a6a0be5 100644 --- a/example-data/expected-ouput/numeric-sequence-no-visual-prompts.json +++ b/example-data/expected-ouput/numeric-sequence-no-visual-prompts.json @@ -49,12 +49,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 600 + 600, + 0.03 ], "step": "/shared/numeric-sequence/page/1-introduction/step/5" } @@ -80,12 +81,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 600 + 600, + 0.03 ], "step": "/shared/numeric-sequence/page/1-introduction/step/5" } @@ -111,12 +113,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 600 + 600, + 0.03 ], "step": "/shared/numeric-sequence/page/1-introduction/step/5" } diff --git a/example-data/expected-ouput/numeric-sequence-range-visual-prompts.json b/example-data/expected-ouput/numeric-sequence-range-visual-prompts.json index 7f08bd9..d2fc3c2 100644 --- a/example-data/expected-ouput/numeric-sequence-range-visual-prompts.json +++ b/example-data/expected-ouput/numeric-sequence-range-visual-prompts.json @@ -72,12 +72,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 600 + 600, + 0.01 ], "step": "/shared/numeric-sequence/page/1-introduction/step/5" } @@ -123,12 +124,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 600 + 600, + 0.01 ], "step": "/shared/numeric-sequence/page/1-introduction/step/5" } @@ -175,12 +177,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 600 + 600, + 0.01 ], "step": "/shared/numeric-sequence/page/1-introduction/step/5" } diff --git a/example-data/expected-ouput/point-circle-visual-prompt.json b/example-data/expected-ouput/point-circle-visual-prompt.json index f27fc13..a98353a 100644 --- a/example-data/expected-ouput/point-circle-visual-prompt.json +++ b/example-data/expected-ouput/point-circle-visual-prompt.json @@ -266,12 +266,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 4 + 4, + 0.01 ], "step": "/shared/point-circles/page/2-numeric/step/4" } @@ -311,12 +312,13 @@ "responseBranches": [ { "criterion": [ - "=", + "withinAbsTolerance", [ "responseField", 1 ], - 4 + 4, + 0.01 ], "step": "/shared/point-circles/page/2-numeric/step/4" } diff --git a/example-data/input/numeric-sequence-no-visual-prompts.json b/example-data/input/numeric-sequence-no-visual-prompts.json index 3437917..5aa1906 100644 --- a/example-data/input/numeric-sequence-no-visual-prompts.json +++ b/example-data/input/numeric-sequence-no-visual-prompts.json @@ -13,6 +13,7 @@ "text": "

What is the x-coordinate at the 3-time unit mark?

" }, "correctAnswer": 600.0, + "tolerance": 0.03, "giveUp": { "text": "

Take a closer look, it's 600 units of distance.

" }, diff --git a/lib/author/sequences.js b/lib/author/sequences.js index 1f58a77..69fa6c1 100644 --- a/lib/author/sequences.js +++ b/lib/author/sequences.js @@ -398,12 +398,14 @@ __extends(NumericSequence, _super); function NumericSequence(_arg) { - this.correctAnswer = _arg.correctAnswer; + var _ref; + this.correctAnswer = _arg.correctAnswer, this.tolerance = _arg.tolerance; + this.tolerance = (_ref = this.tolerance) != null ? _ref : 0.01; NumericSequence.__super__.constructor.apply(this, arguments); } NumericSequence.prototype.getCriterion = function() { - return ["=", ["responseField", 1], this.correctAnswer]; + return ["withinAbsTolerance", ["responseField", 1], this.correctAnswer, this.tolerance]; }; NumericSequence.prototype.appendSteps = function(runtimePage) { diff --git a/src/author/sequences.coffee b/src/author/sequences.coffee index fe54b3e..62d0bc6 100644 --- a/src/author/sequences.coffee +++ b/src/author/sequences.coffee @@ -78,16 +78,18 @@ Sequence.classFor['ConstructedResponseSequence'] = class ConstructedResponseSequ Sequence.classFor['MultipleChoiceWithCustomHintsSequence'] = class MultipleChoiceWithCustomHintsSequence - constructor: ({@initialPrompt, @choices, @correctAnswerIndex, @hints, @confirmCorrect, @page}) -> + constructor: ({@initialPrompt, @choices, @correctAnswerIndex, @hints, @confirmCorrect, @page}) -> [@initialPrompt, @confirmCorrect] = [@initialPrompt, @confirmCorrect].map asObject # FIXME? Underscore would be handy here. indexed = [] indexed[hint.choiceIndex] = hint for hint in @hints + @orderedHints = (hint for hint in indexed when hint?) getCriterionForChoice: (choiceIndex) -> ["=", ["responseField", 1], 1 + choiceIndex] + appendSteps: (runtimePage) -> runtimeActivity = runtimePage.activity @@ -242,11 +244,14 @@ Sequence.classFor['PickAPointSequence'] = class PickAPointSequence extends Corre Sequence.classFor['NumericSequence'] = class NumericSequence extends CorrectableSequenceWithFeedback - constructor: ({@correctAnswer}) -> + constructor: ({@correctAnswer, @tolerance}) -> + @tolerance = @tolerance ? 0.01 super arguments... + getCriterion: -> - ["=",["responseField", 1], @correctAnswer] + ["withinAbsTolerance",["responseField", 1], @correctAnswer, @tolerance] + appendSteps: (runtimePage) -> runtimeActivity = runtimePage.activity