Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Set tolerance of response criterion.
Browse files Browse the repository at this point in the history
  • Loading branch information
knowuh committed Apr 19, 2012
1 parent cc95697 commit b554458
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
Expand Up @@ -49,12 +49,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
600 600,
0.03
], ],
"step": "/shared/numeric-sequence/page/1-introduction/step/5" "step": "/shared/numeric-sequence/page/1-introduction/step/5"
} }
Expand All @@ -80,12 +81,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
600 600,
0.03
], ],
"step": "/shared/numeric-sequence/page/1-introduction/step/5" "step": "/shared/numeric-sequence/page/1-introduction/step/5"
} }
Expand All @@ -111,12 +113,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
600 600,
0.03
], ],
"step": "/shared/numeric-sequence/page/1-introduction/step/5" "step": "/shared/numeric-sequence/page/1-introduction/step/5"
} }
Expand Down
Expand Up @@ -72,12 +72,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
600 600,
0.01
], ],
"step": "/shared/numeric-sequence/page/1-introduction/step/5" "step": "/shared/numeric-sequence/page/1-introduction/step/5"
} }
Expand Down Expand Up @@ -123,12 +124,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
600 600,
0.01
], ],
"step": "/shared/numeric-sequence/page/1-introduction/step/5" "step": "/shared/numeric-sequence/page/1-introduction/step/5"
} }
Expand Down Expand Up @@ -175,12 +177,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
600 600,
0.01
], ],
"step": "/shared/numeric-sequence/page/1-introduction/step/5" "step": "/shared/numeric-sequence/page/1-introduction/step/5"
} }
Expand Down
10 changes: 6 additions & 4 deletions example-data/expected-ouput/point-circle-visual-prompt.json
Expand Up @@ -266,12 +266,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
4 4,
0.01
], ],
"step": "/shared/point-circles/page/2-numeric/step/4" "step": "/shared/point-circles/page/2-numeric/step/4"
} }
Expand Down Expand Up @@ -311,12 +312,13 @@
"responseBranches": [ "responseBranches": [
{ {
"criterion": [ "criterion": [
"=", "withinAbsTolerance",
[ [
"responseField", "responseField",
1 1
], ],
4 4,
0.01
], ],
"step": "/shared/point-circles/page/2-numeric/step/4" "step": "/shared/point-circles/page/2-numeric/step/4"
} }
Expand Down
1 change: 1 addition & 0 deletions example-data/input/numeric-sequence-no-visual-prompts.json
Expand Up @@ -13,6 +13,7 @@
"text": "<p>What is the x-coordinate at the 3-time unit mark?</p>" "text": "<p>What is the x-coordinate at the 3-time unit mark?</p>"
}, },
"correctAnswer": 600.0, "correctAnswer": 600.0,
"tolerance": 0.03,
"giveUp": { "giveUp": {
"text": "<p>Take a closer look, it's 600 units of distance.</p>" "text": "<p>Take a closer look, it's 600 units of distance.</p>"
}, },
Expand Down
6 changes: 4 additions & 2 deletions lib/author/sequences.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/author/sequences.coffee
Expand Up @@ -78,16 +78,18 @@ Sequence.classFor['ConstructedResponseSequence'] = class ConstructedResponseSequ


Sequence.classFor['MultipleChoiceWithCustomHintsSequence'] = class MultipleChoiceWithCustomHintsSequence 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 [@initialPrompt, @confirmCorrect] = [@initialPrompt, @confirmCorrect].map asObject


# FIXME? Underscore would be handy here. # FIXME? Underscore would be handy here.
indexed = [] indexed = []
indexed[hint.choiceIndex] = hint for hint in @hints indexed[hint.choiceIndex] = hint for hint in @hints

@orderedHints = (hint for hint in indexed when hint?) @orderedHints = (hint for hint in indexed when hint?)


getCriterionForChoice: (choiceIndex) -> getCriterionForChoice: (choiceIndex) ->
["=", ["responseField", 1], 1 + choiceIndex] ["=", ["responseField", 1], 1 + choiceIndex]



appendSteps: (runtimePage) -> appendSteps: (runtimePage) ->
runtimeActivity = runtimePage.activity runtimeActivity = runtimePage.activity
Expand Down Expand Up @@ -242,11 +244,14 @@ Sequence.classFor['PickAPointSequence'] = class PickAPointSequence extends Corre


Sequence.classFor['NumericSequence'] = class NumericSequence extends CorrectableSequenceWithFeedback Sequence.classFor['NumericSequence'] = class NumericSequence extends CorrectableSequenceWithFeedback


constructor: ({@correctAnswer}) -> constructor: ({@correctAnswer, @tolerance}) ->
@tolerance = @tolerance ? 0.01
super arguments... super arguments...



getCriterion: -> getCriterion: ->
["=",["responseField", 1], @correctAnswer] ["withinAbsTolerance",["responseField", 1], @correctAnswer, @tolerance]



appendSteps: (runtimePage) -> appendSteps: (runtimePage) ->
runtimeActivity = runtimePage.activity runtimeActivity = runtimePage.activity
Expand Down

0 comments on commit b554458

Please sign in to comment.