| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 | 2×
2×
2×
2×
2×
2×
2×
2×
25×
106×
106×
106×
368×
368×
368×
368×
368×
368×
368×
4×
364×
368×
368×
368×
368×
364×
368×
21×
368×
| var Exercise, React, StepFooter, StepPanel, TaskStepActions, TaskStepStore, TaskStore, ref;
React = require('react');
ref = require('../../flux/task-step'), TaskStepActions = ref.TaskStepActions, TaskStepStore = ref.TaskStepStore;
TaskStore = require('../../flux/task').TaskStore;
StepPanel = require('../../helpers/policies').StepPanel;
Exercise = require('openstax-react-components').Exercise;
StepFooter = require('./step-footer');
module.exports = React.createClass({
displayName: 'ExerciseShell',
propTypes: {
id: React.PropTypes.string.isRequired,
taskId: React.PropTypes.string.isRequired
},
updateFreeResponse: function(freeResponse) {
return TaskStepActions.updateTempFreeResponse(this.props.id, freeResponse);
},
canOnlyContinue: function() {
var id;
id = this.props.id;
return _.chain(StepPanel.getRemainingActions(id)).difference(['clickContinue']).isEmpty().value();
},
render: function() {
var controlText, getCurrentPanel, getReadingForStep, id, ref1, step, stepIndex, task, taskId, waitingText;
ref1 = this.props, id = ref1.id, taskId = ref1.taskId;
step = TaskStepStore.get(id);
task = TaskStore.get(taskId);
stepIndex = TaskStore.getStepIndex(taskId, id);
waitingText = (function() {
switch (false) {
case !TaskStepStore.isLoading(id):
return "Loading…";
case !TaskStepStore.isSaving(id):
return "Saving…";
default:
return null;
}
})();
getReadingForStep = function(id, taskId) {
return TaskStore.getReadingForTaskId(taskId, id);
};
getCurrentPanel = function(id) {
var currentPanel;
if (!TaskStepStore.isSaving(id)) {
return currentPanel = StepPanel.getPanel(id);
}
};
if (task.type === 'reading' && this.canOnlyContinue()) {
controlText = 'Continue';
}
return React.createElement("div", {
"className": 'exercise-wrapper',
"data-step-number": stepIndex + 1
}, React.createElement(Exercise, React.__spread({}, this.props, {
"freeResponseValue": step.temp_free_response,
"controlText": controlText,
"step": step,
"footer": React.createElement(StepFooter, null),
"waitingText": waitingText,
"canTryAnother": TaskStepStore.canTryAnother(id, task),
"isRecovering": TaskStepStore.isRecovering(id),
"disabled": TaskStepStore.isSaving(id),
"canReview": StepPanel.canReview(id),
"isContinueEnabled": StepPanel.canContinue(id),
"getCurrentPanel": getCurrentPanel,
"getReadingForStep": getReadingForStep,
"setFreeResponseAnswer": TaskStepActions.setFreeResponseAnswer,
"onFreeResponseChange": this.updateFreeResponse,
"freeResponseValue": TaskStepStore.getTempFreeResponse(id),
"setAnswerId": TaskStepActions.setAnswerId
})));
}
});
|