| 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 | 2×
2×
2×
2×
2×
2×
2×
2×
| var ArbitraryHtmlAndMath, BS, CardBody, ExerciseStore, FreeResponse, Question, React, TaskTeacherReviewExercise, _, ref;
React = require('react');
_ = require('underscore');
BS = require('react-bootstrap');
ref = require('openstax-react-components'), ArbitraryHtmlAndMath = ref.ArbitraryHtmlAndMath, Question = ref.Question, CardBody = ref.CardBody, FreeResponse = ref.FreeResponse;
ExerciseStore = require('../../flux/exercise').ExerciseStore;
TaskTeacherReviewExercise = React.createClass({
displayName: 'TaskTeacherReviewExercise',
propTypes: {
content: React.PropTypes.object.isRequired,
answers: React.PropTypes.array.isRequired,
answered_count: React.PropTypes.number.isRequired
},
getInitialState: function() {
return {
showAnswers: false
};
},
onChangeAnswerAttempt: function(answer) {
return console.log('You cannot change an answer on a problem you\'ve reviewed.', 'TODO: show warning in ui.');
},
toggleAnswers: function() {
var showAnswers;
showAnswers = this.state.showAnswers;
return this.setState({
showAnswers: !showAnswers
});
},
getQuestion: function() {
var content;
content = this.props.content;
return content.questions[0];
},
renderNoFreeResponse: function() {
var freeResponsesClasses, header;
freeResponsesClasses = 'teacher-review-answers has-no-answers';
header = React.createElement("i", null, "No student text responses");
return React.createElement(BS.Panel, {
"header": header,
"className": freeResponsesClasses
});
},
renderFreeResponse: function() {
var answers, freeResponses, freeResponsesClasses, question, showAnswers, toggleAnswersText;
answers = this.props.answers;
showAnswers = this.state.showAnswers;
question = this.getQuestion();
toggleAnswersText = "View student text responses (" + answers.length + ")";
if (showAnswers) {
toggleAnswersText = 'Hide student text responses';
}
freeResponsesClasses = 'teacher-review-answers';
if (showAnswers) {
freeResponsesClasses += ' active';
}
freeResponses = _.map(answers, function(answer, index) {
var freeResponseKey;
freeResponseKey = "free-response-" + question.id + "-" + index;
return React.createElement(FreeResponse, React.__spread({}, answer, {
"key": freeResponseKey
}));
});
return React.createElement(BS.Accordion, {
"onSelect": this.toggleAnswers
}, React.createElement(BS.Panel, {
"header": toggleAnswersText,
"eventKey": question.id,
"className": freeResponsesClasses
}, freeResponses));
},
render: function() {
var answered_count, answers, question, ref1, studentResponses;
ref1 = this.props, answers = ref1.answers, answered_count = ref1.answered_count;
question = this.getQuestion();
if (ExerciseStore.hasQuestionWithFormat('free-response', {
content: this.props.content
})) {
studentResponses = answers.length ? this.renderFreeResponse() : this.renderNoFreeResponse();
}
return React.createElement(CardBody, {
"className": 'task-step openstax-exercise',
"pinned": false
}, React.createElement(Question, {
"model": question,
"answered_count": answered_count,
"type": 'teacher-review',
"exercise_uid": this.props.content.uid,
"onChangeAttempt": this.onChangeAnswerAttempt
}, studentResponses));
}
});
module.exports = TaskTeacherReviewExercise;
|