forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblemGrader.html.ep
More file actions
286 lines (286 loc) · 11.9 KB
/
ProblemGrader.html.ep
File metadata and controls
286 lines (286 loc) · 11.9 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
% use WeBWorK::Utils qw(wwRound getAssetURL points_stepsize round_nearest_stepsize);
% require WeBWorK::PG;
%
% content_for js => begin
<%= javascript getAssetURL($ce, 'js/SelectAll/selectall.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'js/RenderProblem/renderproblem.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'js/ProblemGrader/problemgrader.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'node_modules/iframe-resizer/js/iframeResizer.min.js') =%>
<%= javascript getAssetURL($ce, 'js/Essay/essay.js'), defer => undef =%>
% if ($ce->{pg}{specialPGEnvironmentVars}{entryAssist} eq 'MathQuill') {
<%= javascript getAssetURL($ce, 'node_modules/@openwebwork/mathquill/dist/mathquill.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'js/MathQuill/mqeditor.js'), defer => undef =%>
% } elsif ($ce->{pg}{specialPGEnvironmentVars}{entryAssist} eq 'MathView') {
<%= javascript getAssetURL($ce, "js/MathView/$ce->{pg}{options}{mathViewLocale}"), defer => undef =%>
<%= javascript getAssetURL($ce, 'js/MathView/mathview.js'), defer => undef =%>
% }
% end
%
% content_for css => begin
<%= stylesheet getAssetURL($ce, 'js/Problem/problem.css') =%>
% if ($ce->{pg}{specialPGEnvironmentVars}{entryAssist} eq 'MathQuill') {
<%= stylesheet getAssetURL($ce, 'node_modules/@openwebwork/mathquill/dist/mathquill.css') =%>
<%= stylesheet getAssetURL($ce, 'js/MathQuill/mqeditor.css') =%>
% } elsif ($ce->{pg}{specialPGEnvironmentVars}{entryAssist} eq 'MathView') {
<%= stylesheet getAssetURL($ce, 'js/MathView/mathview.css') =%>
% }
% end
%
% unless ($authz->hasPermissions(param('user'), 'access_instructor_tools')) {
<div class="alert alert-danger p-1 mb-0">
<%= maketext('You are not authorized to access instructor tools.') =%>
</div>
% last;
% }
%
% unless ($authz->hasPermissions(param('user'), 'problem_grader')) {
<div class="alert alert-danger p-1 mb-0"><%= maketext('You are not authorized to grade assignments.') %></div>
% last;
% }
%
% unless ($set && $problem) {
<div class="alert alert-danger p-1 mb-0"><%= maketext('This set or problem is not valid.') =%></div>
% last;
% }
%
% unless (@$users) {
<div class="alert alert-danger p-1 mb-0">
% if ($set->assignment_type =~ /gateway/) {
<%= maketext('There are no completed versions of this test.') =%>
% } else {
<%= maketext('This set is not assigned to any students.') =%>
% }
</div>
% last;
% }
%
<div class="rpc_render_area_container my-3 p-2 border rounded">
<div id="problem_render_area" class="rpc_render_area"></div>
<div class="col-12 flex-wrap">
<div class="input-group d-inline-flex flex-nowrap w-auto py-1 me-sm-3">
<%= label_for selected_student => maketext('Showing problem for:'), class => 'input-group-text' =%>
<%= select_field student_selector => [
map {
my $user = $_;
map { [
($user->{displayName}
. (
ref($_->{problem}) =~ /::ProblemVersion/
? maketext(' (version [_1])', $_->{problem}->version_id)
: ''
)
) => $user->user_id,
data => {
source_file => $_->{problem}->source_file || $problem->source_file,
problem_seed => $_->{problem}->problem_seed,
last_answer => $_->{problem}->last_answer,
ref($_->{problem}) =~ /::ProblemVersion/
? (
version_id => $_->{problem}->version_id,
answer_prefix => sprintf('Q%04d_', $_->{problem}->problem_id)
)
: (),
}
] } @{ $user->{data} }
} @$users
],
id => 'student_selector', class => 'form-select' =%>
</div>
<div class="input-group d-inline-flex flex-nowrap w-auto py-1">
<%= label_for problem_displaymode => maketext('Display Mode:'), class => 'input-group-text' =%>
<%= select_field 'problem_displaymode' => [
grep { exists WeBWorK::PG::DISPLAY_MODES()->{$_} } @{ $ce->{pg}{displayModes} }
],
id => 'problem_displaymode', class => 'form-select' =%>
</div>
</div>
</div>
%
<%= form_for current_route, method => 'POST', id => 'problem-grader-form', name => 'problem-grader-form', begin =%>
<%= hidden_field hidden_course_id => $courseID =%>
<%= hidden_field hidden_set_id => $set->set_id =%>
<%= hidden_field hidden_problem_id => $problem->problem_id =%>
<%= hidden_field hidden_language => $ce->{language} =%>
<div class="table-responsive">
% my $problemNeedsGrading = 0;
<table class="table table-sm table-bordered caption-top">
<thead>
<tr>
% if ($haveSections) {
<th><%= maketext('Section') %></th>
% }
<th>
<div><%= maketext('Name') %></div>
% if ($set->assignment_type =~ /gateway/) {
<div><%= maketext('Version') %></div>
% }
</th>
<th><%= maketext('Latest Answers') %></th>
<th id="mark-all-correct-header" class="text-center">
<%= label_for 'select-all' => maketext('Mark Correct') =%>
<br>
<%= check_box 'select-all' => 'on', id => 'select-all', class => 'select-all form-check-input',
data => { select_group => 'mark_correct' } =%>
</th>
% unless ($ce->{problemGraderScore} eq 'Point') {
<th id="score-header"><%= maketext('Score (%)') %></th>
% }
% unless ($ce->{problemGraderScore} eq 'Percent') {
<th id="point-header"><%= maketext('Points (0 - [_1])', $problem->value) %></th>
% }
<th id="comment-header"><%= maketext('Comment') %></th>
</tr>
</thead>
<tbody>
% my $stepSize = points_stepsize($problem->value);
% for my $user (@$users) {
% my $userID = $user->user_id;
%
% for (@{ $user->{data} }) {
% next unless defined $_->{problem};
% my $versionID = ref($_->{problem}) =~ /::ProblemVersion/ ? $_->{problem}->version_id : 0;
% my @answerTypes = split(',', $_->{problem}->flags =~ s/:needs_grading$//r);
% my $problemLink;
% if ($versionID) {
% $problemLink = $c->systemLink(
% url_for('gateway_quiz', setID => "$setID,v$versionID"),
% params => { effectiveUser => $userID, currentPage => $_->{pageNumber} }
% )->fragment("prob$_->{problemNumber}");
% } else {
% $problemLink = $c->systemLink(
% url_for('problem_detail'),
% params => { effectiveUser => $userID }
% )->fragment('problem_body');
% }
<tr>
% if ($haveSections) {
<td class="text-center restricted-width-col"><%= $user->section %></td>
% }
% $problemNeedsGrading = 1 if $_->{problem}->flags =~ /:needs_grading$/;
<td class="<%= $_->{problem}->flags =~ /:needs_grading$/ ? 'needs-grading' : ''%>">
<%= link_to $problemLink, target => 'WW_View', begin =%>
<div class="<%= $ce->status_abbrev_to_name($user->status) || '' %>">
<%= $user->{displayName} =%>
</div>
% if ($versionID) {
<div><%= maketext('(version [_1])', $versionID) =%></div>
% }
<% end =%>
</td>
<td class="problem-answers"
data-source-file="<%= $_->{problem}->source_file || $problem->source_file %>">
% if (defined $_->{past_answer} ) {
% my @scores = split(//, $_->{past_answer}->scores);
% my @answers = split(/\t/, $_->{past_answer}->answer_string);
%
% for (my $i = 0; $i <= $#answers; $i++) {
<div class="<%= join(
' ',
'past-answer',
# Color the answer if it is not an essay answer.
$answerTypes[$i] && $answerTypes[$i] eq 'essay'
? ()
: $scores[$i] ? 'correct' : 'incorrect'
) %>">
% if ($answerTypes[$i] && $answerTypes[$i] eq 'essay') {
% # If the answer is an essay answer then display it line by line.
% my @lines = split /\n/, $answers[$i];
% for (0 .. $#lines - 1) {
<%= $lines[$_] =%><br>
% }
<%= $lines[-1] =%>
% } elsif ($answerTypes[$i] && $answerTypes[$i] eq 'Value (Formula)') {
% # If its a formula then mark it as tex for MathJax.
`<%= $answers[$i] %>`
% } else {
% # If it isn't an essay or a formula then show it as text.
% my @parts = split("⍮", $answers[$i]);
% for (0 .. $#parts - 1) {
<%= $parts[$_] =%>⍮\
% }
<%= $parts[-1] =%>
% }
</div>
% }
% } else {
<%= 'There are no answers for this student.' =%>
% }
</td>
<td class="text-center restricted-width-col">
% param("$userID.$versionID.mark_correct", undef);
<%= check_box "$userID.$versionID.mark_correct" => '1',
class => 'mark_correct form-check-input',
'aria-labelledby' => 'mark-all-correct-header' =%>
</td>
% unless ($ce->{problemGraderScore} eq 'Point') {
<td class="restricted-width-col">
% param("$userID.$versionID.score", undef);
<%= number_field "$userID.$versionID.score" => wwRound(0, $_->{problem}->status * 100),
id => "$userID.$versionID.score",
class => 'problem-score form-control form-control-sm restricted-width-col',
style => 'width:6.5rem;', min => 0, max => 100, step => 1,
autocomplete => 'off', 'aria-labelledby' => 'score-header' =%>
</td>
% }
% unless ($ce->{problemGraderScore} eq 'Percent') {
% my $problemValue = ($_->{problem}->value ne '' ? $_->{problem} : $problem)->value;
% my $useUserValue = $problemValue != $problem->value;
% my $thisStepSize = $useUserValue ? points_stepsize($problemValue) : $stepSize;
<td class="restricted-width-col">
% if ($ce->{problemGraderScore} eq 'Point') {
% param("$userID.$versionID.score", wwRound(0, $_->{problem}->status * 100));
<%= hidden_field "$userID.$versionID.score" => 0,
id => "$userID.$versionID.score" %>
% }
% param("$userID.$versionID.points", undef);
<%= number_field "$userID.$versionID.points" => round_nearest_stepsize(
$_->{problem}->status * $problemValue, $thisStepSize),
id => "$userID.$versionID.points",
class => 'problem-points form-control form-control-sm restricted-width-col',
style => 'width:6.5rem;',
min => 0,
max => $problemValue,
step => $thisStepSize,
autocomplete => 'off',
'aria-labelledby' => $useUserValue
? "point-label-$userID.$versionID"
: 'point-header' =%>
% if ($useUserValue) {
<div id="point-label-<%= "$userID.$versionID" =%>" class="fw-bold">
<%= maketext('Points (0 - [_1])', $problemValue) =%>
</div>
% }
</td>
% }
<td class="grader-comment-column">
% if (defined $_->{past_answer}) {
<%= text_area "$userID.$versionID.comment" => $_->{past_answer}->comment_string,
id => "${userID}_${versionID}_comment",
rows => 3, class => 'form-control latexentryfield',
'aria-labelledby' => 'comment-header' =%>
<%= hidden_field "MaThQuIlL_${userID}_${versionID}_comment" => '',
id => "MaThQuIlL_${userID}_${versionID}_comment",
data => { eqn_editor_btn_after => 'true' } =%>
% }
</td>
</tr>
% }
% }
</tbody>
</table>
% if ($problemNeedsGrading) {
<div class='problem-grader-legend-key mb-3'>
<span class='needs-grading fw-bold p-2'><%= maketext('Name') %></span>
\( = \)
<%= maketext('Problem has an essay answer that needs to be graded.') =%>
</div>
% }
<div id="alt-source-key" class='problem-grader-legend-key mb-3 d-none'>
<span class='alt-source p-2'><%= maketext('Latest Answers') %></span>
\( = \)
<%= maketext('Problem has a different source file than the currently rendered problem.') =%>
</div>
</div>
<%= $c->hidden_authen_fields =%>
<%= submit_button maketext('Save'), name => 'assignGrades', class => 'btn btn-primary mb-2' =%>
<% end =%>