forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrader.html.ep
More file actions
267 lines (267 loc) · 10.3 KB
/
grader.html.ep
File metadata and controls
267 lines (267 loc) · 10.3 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
% use WeBWorK::Utils qw(wwRound points_stepsize round_nearest_stepsize);
%
% if (!stash->{jsInserted}) {
% stash->{jsInserted} = 1;
% content_for js => begin
<%= javascript getAssetURL($ce, 'js/ProblemGrader/singleproblemgrader.js'), defer => undef =%>
% end
% }
%
<div class="problem-grader d-none" id="problem-grader-<%= $grader->{problem_id} %>"
data-grader-title="<%= maketext('Problem Grader') %>">
<div class="problem-grader-table">
% my $currentScore = 0;
% my $rawCurrentScore = 0;
%
% # Subscores for each answer in the problem.
% if (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1) {
% # Determine the scores and weights for each part of the problem.
% my $total = 0;
% my (@scores, @weights);
% for my $ans_id (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} }) {
% push(@scores, $grader->{pg}{answers}{$ans_id}{score} * 100);
% push(@weights, $grader->{pg}{answers}{$ans_id}{weight} // 1);
% $total += $weights[-1];
% }
%
% # Normalize the weights
% @weights = map { $_ / $total } @weights;
%
% for my $part (0 .. $#scores) {
% $rawCurrentScore += $scores[$part] * $weights[$part];
% $scores[$part] = wwRound(0, $scores[$part]);
<div class="row align-items-center mb-2">
<%= label_for "score_problem$grader->{problem_id}_$grader->{pg}{flags}{ANSWER_ENTRY_ORDER}[$part]",
class => 'col-fixed col-form-label',
begin =%>
<%= maketext('Answer [_1] Score (%):', $part + 1) =%>
<%= link_to '#',
class => 'help-popup',
data => {
bs_content => maketext(
'The initial value is the answer sub score for the answer '
. 'that is currently shown. If this is modified, it will be used to compute '
. 'the total problem score below. This score is not saved, and will reset to '
. 'the score for the shown answer if the page is reloaded.'
),
bs_placement => 'top',
bs_toggle => 'popover'
},
begin =%>
<i class="icon fas fa-question-circle" aria-hidden="true"></i>
<span class="visually-hidden"><%= maketext('Answer Score Help') =%></span>
<% end =%>
<% end =%>
<div class="col-sm">
% param('answer-part-score', $scores[$part]);
<%= number_field 'answer-part-score' => '',
class => 'answer-part-score form-control form-control-sm d-inline',
id =>
"score_problem$grader->{problem_id}_$grader->{pg}{flags}{ANSWER_ENTRY_ORDER}[$part]",
data => {
problem_id => $grader->{problem_id},
answer_labels =>
'["' . join('","', @{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} }) . '"]',
weight => $weights[$part]
},
min => 0,
max => 100,
autocomplete => 'off' =%>
<%== maketext('<b>Weight:</b> [_1]%', wwRound(2, $weights[$part] * 100)) =%>
</div>
</div>
% }
% $currentScore = wwRound(0, $rawCurrentScore);
% } elsif (@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} }) {
% $rawCurrentScore = $grader->{pg}{answers}{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER}[0] }{score} * 100;
% $currentScore = wwRound(0, $rawCurrentScore);
<%= hidden_field 'answer-part-score' => $currentScore, class => 'answer-part-score',
data => { problem_id => $grader->{problem_id}, weight => 1 } =%>
% }
%
% # Total point value. Show only if configured to.
% unless ($ce->{problemGraderScore} eq 'Percent') {
% my $stepSize = points_stepsize($grader->{problem_value});
% my $recordedPoints =
% round_nearest_stepsize($grader->{recorded_score} * $grader->{problem_value}, $stepSize);
% my $currentPoints =
% round_nearest_stepsize($rawCurrentScore / 100 * $grader->{problem_value}, $stepSize);
% param('grader-problem-points', $recordedPoints);
<div class="row align-items-center mb-2">
<%= label_for "score_problem$grader->{problem_id}_points",
class => 'col-fixed col-form-label',
begin =%>
<%= maketext('Point Value (0 - [_1]):', $grader->{problem_value}) %>
<%= link_to '#',
class => 'help-popup',
data => {
bs_content => tag(
'p',
class => 'mb-0',
maketext(
'The initial value is the currently saved score as a point value computed '
. 'using the percent score. This point value is used to compute the percent '
. 'score (rounded to a whole percent) that can be saved.'
)
)
. (
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1 ? tag(
'p',
class => 'mt-2 mb-0',
maketext(
'This can computed from the answer sub scores above using the weights '
. 'shown if they are modified. Alternatively, enter the point score you '
. 'want saved here (the above sub scores will be ignored).'
)
) : ''
)
. (
$currentPoints != $recordedPoints ? tag(
'p',
class => 'mt-2 mb-0',
maketext(
'Click the "Use points from last check" button to set the point value '
. 'to the points from the answers that were entered when answers were '
. 'last checked.'
)
) : ''
),
bs_placement => 'top',
bs_toggle => 'popover',
bs_html => 'true'
},
begin =%>
<i class="fas fa-question-circle" aria-hidden="true"></i>
<span class="visually-hidden"><%= maketext('Point Value Help') %></span>
<% end =%>
<% end =%>
<div class="col-sm">
<%= number_field 'grader-problem-points' => '',
min => 0,
max => $grader->{problem_value},
step => $stepSize,
autocomplete => 'off',
id => "score_problem$grader->{problem_id}_points",
class => "problem-points form-control form-control-sm d-inline",
data => { problem_id => $grader->{problem_id} } =%>
% if ($recordedPoints != $currentPoints) {
<button class="recompute-grade btn btn-sm btn-secondary" type="button"
data-problem-id="<%= $grader->{problem_id} %>">
<%= maketext('Use points from last check: [_1]', $currentPoints) =%>
</button>
% }
</div>
</div>
% }
%
% # Total problem score. (Hidden if configured to only show point values.)
% if ($ce->{problemGraderScore} eq 'Point') {
<%= hidden_field 'grader-problem-score' => wwRound(0, $grader->{recorded_score} * 100),
id => "score_problem$grader->{problem_id}",
data => { problem_id => $grader->{problem_id} } =%>
% } else {
<div class="row align-items-center mb-2">
% my $recordedScore = wwRound(0, $grader->{recorded_score} * 100);
<%= label_for "score_problem$grader->{problem_id}", class => 'col-fixed col-form-label', begin =%>
<%= maketext('Problem Score (%):') %>
<%= link_to '#',
class => 'help-popup',
data => {
bs_content => tag(
'p',
class => 'mb-0',
maketext('The initial value is the currently saved score for this student.')
)
. (
@{ $grader->{pg}{flags}{ANSWER_ENTRY_ORDER} } > 1 ? tag(
'p',
class => 'mt-2 mb-0',
maketext(
'This is the only part of the score that is actually saved. '
. 'This is computed from the answer sub scores above using the weights '
. 'shown if they are modified. Alternatively, enter the score you want '
. 'saved here (the above sub scores will be ignored).'
)
) : ''
)
. (
$currentScore != $recordedScore ? tag(
'p',
class => 'mt-2 mb-0',
maketext(
'Click the "Use score from last check" button to set the problem score '
. 'to the score from the answers that were entered when answers were '
. 'last checked.'
)
) : ''
),
bs_placement => 'top',
bs_toggle => 'popover',
bs_html => 'true'
},
begin =%>
<i class="fas fa-question-circle" aria-hidden="true"></i>
<span class="visually-hidden"><%= maketext('Problem Score Help') %></span>
<% end =%>
<% end =%>
<div class="col-sm">
% param('grader-problem-score', $recordedScore);
<%= number_field 'grader-problem-score' => '',
min => 0,
max => 100,
autocomplete => "off",
id => "score_problem$grader->{problem_id}",
class => "problem-score form-control form-control-sm d-inline",
data => { problem_id => $grader->{problem_id} } =%>
% if ($recordedScore != $currentScore) {
<button class="recompute-grade btn btn-sm btn-secondary" type="button"
data-problem-id="<%= $grader->{problem_id} %>">
<%= maketext('Use score from last check: [_1]%', $currentScore) =%>
</button>
% }
</div>
</div>
% }
%
% # Instructor comment
% if ($grader->{past_answer_id}) {
<div class="row">
<%= label_for "comment_problem$grader->{problem_id}" => maketext('Comment:'),
class => 'col-fixed col-form-label' =%>
<div class="col-sm">
% param('grader-instructor-comment', $grader->{comment_string});
<%= text_area 'grader-instructor-comment' => '',
id => "comment_problem$grader->{problem_id}",
class => 'grader-problem-comment form-control d-inline latexentryfield',
data => { problem_id => $grader->{problem_id} },
rows => 3 =%>
<%= hidden_field "MaThQuIlL_comment_problem$grader->{problem_id}" => '',
id => "MaThQuIlL_comment_problem$grader->{problem_id}" =%>
</div>
</div>
% }
%
% # Save button
<div class="row align-items-center">
<div class="col-fixed mt-2">
<button class="save-grade btn btn-sm btn-secondary" type="button"
id="<%= "save_grade_problem$grader->{problem_id}" %>"
data-course-id="<%= $grader->{course_id} %>"
data-student-id="<%= $grader->{student_id} %>"
data-set-id="<%= $grader->{set_id} %>"
data-version-id="<%= $grader->{version_id} %>"
data-problem-id="<%= $grader->{problem_id} %>"
data-past-answer-id="<%= $grader->{past_answer_id} %>"
data-save-sub-status="<%= $grader->{save_sub_status} %>">
<%= maketext('Save') =%>
</button>
</div>
<div class="col-sm mt-2">
<div id="<%= "grader_messages_problem$grader->{problem_id}" %>" class="problem-grader-message"></div>
</div>
</div>
</div>
</div>