@@ -2,9 +2,11 @@ _ = require 'underscore'
2
2
React = require ' react'
3
3
katex = require ' katex'
4
4
{TaskStepActions , TaskStepStore } = require ' ../../flux/task-step'
5
+ {TaskActions } = require ' ../../flux/task'
5
6
ArbitraryHtmlAndMath = require ' ../html'
6
7
StepMixin = require ' ./step-mixin'
7
8
Question = require ' ../question'
9
+ BS = require ' react-bootstrap'
8
10
9
11
10
12
ExerciseFreeResponse = React .createClass
@@ -98,13 +100,32 @@ ExerciseReview = React.createClass
98
100
onContinue : ->
99
101
@props .onNextStep ()
100
102
103
+ tryAnother : ->
104
+ task_id = TaskStepStore .getTaskId (@ getId ())
105
+ TaskStepActions .loadRecovery (@ getId ())
106
+ TaskActions .load (task_id)
107
+
108
+ canTryAnother : ->
109
+ step = TaskStepStore .get (@ getId ())
110
+ return step .has_recovery and step .correct_answer_id isnt step .answer_id
111
+
112
+ renderFooterButtons : ->
113
+ isDisabledClass = ' disabled' unless @ isContinueEnabled ()
114
+ continueButton = <BS.Button bsStyle = " primary" className = {isDisabledClass} onClick = {@onContinue }>Continue</BS.Button >
115
+ tryAnotherButton = <BS.Button bsStyle = " primary" onClick = {@tryAnother }>Try Another</BS.Button > if @ canTryAnother ()
116
+ <span >
117
+ {tryAnotherButton}
118
+ {continueButton}
119
+ </span >
120
+
101
121
102
122
module .exports = React .createClass
103
123
displayName : ' Exercise'
104
124
105
125
render : ->
106
126
{id } = @props
107
- {content , free_response , is_completed } = TaskStepStore .get (id)
127
+ step = TaskStepStore .get (id)
128
+ {id , content , free_response , is_completed } = step
108
129
# TODO: Assumes 1 question.
109
130
question = content .questions [0 ]
110
131
0 commit comments