-
-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathGatewayQuiz.html.ep
More file actions
789 lines (789 loc) · 30.2 KB
/
GatewayQuiz.html.ep
File metadata and controls
789 lines (789 loc) · 30.2 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
% use WeBWorK::Utils qw(wwRound getAssetURL);
% use WeBWorK::Utils::DateTime qw(before after);
% use WeBWorK::Utils::LanguageAndDirection qw(get_problem_lang_and_dir);
% use WeBWorK::HTML::SingleProblemGrader;
% use WeBWorK::AchievementEvaluator qw(checkForAchievements);
%
% content_for css => begin
<%= stylesheet getAssetURL($ce, 'js/Achievements/achievements.css') =%>
<%= stylesheet getAssetURL($ce, 'js/GatewayQuiz/gateway.css') =%>
% # Output css for jquery-ui for problems to use.
<%= stylesheet getAssetURL($ce, 'node_modules/jquery-ui-dist/jquery-ui.min.css') =%>
%
% # Add CSS files requested by problems via ADD_CSS_FILE() in the PG file
% # or via a setting of $ce->{pg}{specialPGEnvironmentVars}{extra_css_files}
% # which can be set in course.conf (the value should be an anonomous array).
% my @cssFiles;
% if (ref($ce->{pg}{specialPGEnvironmentVars}{extra_css_files}) eq 'ARRAY') {
% push(@cssFiles, { file => $_, external => 0 }) for @{ $ce->{pg}{specialPGEnvironmentVars}{extra_css_files} };
% }
% for my $pg (@$pg_results) {
% next unless ref($pg);
% if (ref($pg->{flags}{extra_css_files}) eq 'ARRAY') {
% push @cssFiles, @{ $pg->{flags}{extra_css_files} };
% }
% }
% my %cssFilesAdded; # Used to avoid duplicates
% for (@cssFiles) {
% next if $cssFilesAdded{ $_->{file} };
% $cssFilesAdded{ $_->{file} } = 1;
% if ($_->{external}) {
<%= stylesheet $_->{file} =%>
% } else {
<%= stylesheet getAssetURL($ce, $_->{file}) =%>
% }
% }
% end
%
% content_for js => begin
<%= javascript getAssetURL($ce, 'js/GatewayQuiz/gateway.js'), defer => undef =%>
%
% # Output javascript for jquery-ui for problems to use.
<%= javascript getAssetURL($ce, 'node_modules/jquery-ui-dist/jquery-ui.min.js') =%>
%
% # Add JS files requested by problems via ADD_JS_FILE() in the PG file.
% my %jsFiles;
% for my $pg (@$pg_results) {
% next unless ref($pg);
% if (ref($pg->{flags}{extra_js_files}) eq 'ARRAY') {
% for (@{ $pg->{flags}{extra_js_files} }) {
% next if $jsFiles{ $_->{file} };
% $jsFiles{ $_->{file} } = 1;
%
% my %attributes = ref($_->{attributes}) eq 'HASH' ? %{ $_->{attributes} } : ();
% if ($_->{external}) {
<%= javascript $_->{file}, %attributes =%>
% } else {
<%= javascript getAssetURL($ce, $_->{file}), %attributes =%>
% }
% }
% }
% }
% end
%
% my $userID = param('user');
% my $effectiveUserID = param('effectiveUser');
%
% # If the set is invalid, then show that information and exit.
% if ($c->{invalidSet}) {
<div class="alert alert-danger mb-2">
<div class="mb-2">
<%= maketext('The selected test ([_1]) is not a valid test for [_2].', $setID, $effectiveUserID) =%>
</div>
<div><%= $c->{invalidSet} %></div>
</div>
% last;
% }
% # If user tried to create a test version for another user without correct permissions, show message and exit.
% if ($c->{actingCreationError}) {
<div class="alert alert-danger mb-2">
<%= maketext(
'You are acting as user [_1] and do not have the permission to create a new test version when acting '
. 'as another user.',
$effectiveUserID
) =%>
</div>
% last;
% }
% # Get confirmation before creating new test version or working on an open test for another user.
% if (stash->{actingConfirmation}) {
<div class="alert alert-danger mb-2">
<div class="mb-2"><%= stash->{actingConfirmation} =%></div>
<div>
<%= link_to stash->{actingConfirmationButton} => $c->systemLink(
url_for,
params => { effectiveUser => $effectiveUserID, user => $userID, submit_for_student_ok => 1 }
),
class => 'btn btn-primary'
=%>
<%= link_to maketext('Cancel') => $c->systemLink(
url_for('problem_list', setID => $setID =~ s/,v\d+$//r),
params => { effectiveUser => $effectiveUserID, user => $userID }
),
class => 'btn btn-primary'
=%>
</div>
</div>
%
% last;
% }
%
% my $setID = $c->{set}->set_id;
% my $setVersionID = $c->{set}->version_id;
% my $numProbPerPage = $c->{set}->problems_per_page;
%
% if ($c->{will}{recordAnswers}) {
% my $divClass = 'alert-success';
% my $recdMsg = '';
% for (@{ $c->{scoreRecordedMessage} }) {
% if ($_ ne 'recorded') {
% $recdMsg = $_;
% $divClass = 'alert-danger';
% last;
% }
% }
%
<div class="<%= "alert $divClass mb-3 p-1" %>">
% # A handy noun for when referring to a test.
% my $testNoun = ($c->{set}->attempts_per_version || 0) > 1 ? maketext('submission') : maketext('test');
% my $testNounNum =
% (($c->{set}->attempts_per_version || 0) > 1)
% ? maketext('submission (version [_1])', $setVersionID)
% : maketext('version ([_1])', $setVersionID);
%
% if ($recdMsg) {
% # There was an error when saving the results
<strong><%= maketext('Your score on this [_1] was NOT recorded.', $testNounNum) %> <%= $recdMsg %></strong>
<br>
% } else {
% # No error. Output recorded message.
<strong><%= maketext('Your score on this [_1] WAS recorded.', $testNounNum) %></strong>
<br>
% # Show the score if that is allowed.
% if ($c->{can}{showScore}) {
<strong>
<%= maketext('Your score on this [_1] is [_2]/[_3].',
$testNoun, $c->{attemptScore}, $c->{totalPossible}) =%>
</strong>
% } else {
% if ($c->{set}->hide_score eq 'BeforeAnswerDate') {
<%= maketext('(Your score on this [_1] is not available until [_2].)',
$testNoun, $c->formatDateTime($c->{set}->answer_date, $ce->{studentDateDisplayFormat})) =%>
% } else {
<%= maketext('(Your score on this [_1] is not available.)', $testNoun) =%>
% }
% }
% # Print a message when submitting the score to an LMS.
% if ($c->{ltiGradePassbackMessage}) {
<br>
<%= $c->{ltiGradePassbackMessage} =%>
% }
% }
</div>
%
% # Finally, if there is another recorded message, output that too.
% if (
% $c->{set}->attempts_per_version > 1
% && $c->{attemptNumber} > 0
% && $c->{recordedScore} != $c->{attemptScore}
% && $c->{can}{showScore}
% )
% {
<div class="alert alert-warning p-1">
<%== maketext(
'Your recorded score for this version is [_1]/[_2] ([_3]%).',
'<span id="test-recorded-score">' . wwRound(2, $c->{recordedScore}) . '</span>',
'<span id="test-total-possible">' . $c->{totalPossible} . '</span>',
'<span id="test-recorded-percent">'
. wwRound(0, 100 * $c->{recordedScore} / $c->{totalPossible})
. '</span>'
) =%>
</div>
% }
% } elsif ($c->{will}{checkAnswers}) {
% if ($c->{can}{showScore}) {
<div class="alert alert-warning p-1">
<strong>
<%= maketext('Your score on this (checked, not recorded) submission is [_1]/[_2].',
$c->{attemptScore}, $c->{totalPossible}) =%>
</strong>
<br>
<%== maketext(
'Your recorded score for this version is [_1]/[_2] ([_3]%).',
'<span id="test-recorded-score">' . wwRound(2, $c->{recordedScore}) . '</span>',
'<span id="test-total-possible">' . $c->{totalPossible} . '</span>',
'<span id="test-recorded-percent">'
. wwRound(0, 100 * $c->{recordedScore} / $c->{totalPossible})
. '</span>'
) =%>
</div>
% }
% }
%
% # Display the reduced scoring message if reduced scoring is enabled and the set is in the reduced scoring period.
% if ($ce->{pg}{ansEvalDefaults}{enableReducedScoring}
% && $c->{set}->enable_reduced_scoring
% && after($c->{set}->reduced_scoring_date, $submitTime)
% && before($c->{set}->due_date, $submitTime)
% && ($c->{can}{recordAnswersNextTime} || $c->{submitAnswers}))
% {
<div class="alert alert-warning p-1">
<strong>
% my $text = maketext('You are in the Reduced Scoring Period. All work counts for [_1]% of the original.',
% $ce->{pg}{ansEvalDefaults}{reducedScoringValue} * 100);
<%== maketext('Note: [_1]', tag('i', $text)) =%>
</strong>
</div>
% }
%
% # Remaining output of test headers.
% # Display timer or information about elapsed time, output link, and information about any recorded score if not
% # submitAnswers or checkAnswers.
% if ($c->{can}{recordAnswersNextTime} && before($c->{set}->due_date + $ce->{gatewayGracePeriod}, $submitTime)) {
% my $timeLeft = $c->{set}->due_date - int($submitTime); # This is in seconds
%
% # Print the timer if there is less than 24 hours left.
% if ($timeLeft < 86400) {
<%= tag('div',
id => 'gwTimer',
class => 'alert alert-warning p-1',
data => {
server_time => int($submitTime),
server_due_time => $c->{set}->due_date,
session_timeout => $ce->{sessionTimeout},
course_id => $ce->{courseName},
grace_period => $ce->{gatewayGracePeriod},
alert_title => maketext('Test Time Notification'),
alert_three => maketext(
'You have less than 90 seconds left to complete this assignment. You should finish it soon!'),
alert_two => ('<div>' . maketext('You have less than 45 seconds left!') . '</div>')
. (
($c->{set}->attempts_per_version > 1 && $c->{attemptNumber} > 0) ? ''
: '<div>' . maketext('Press "Grade Test" soon!') . '</div>'
),
alert_one => ('<div>' . maketext('You are out of time!') . '</div>')
. (
($c->{set}->attempts_per_version > 1 && $c->{attemptNumber} > 0) ? ''
: '<div>' . maketext('Press "Grade Test" now!') . '</div>'
),
$userID ne $effectiveUserID ? (acting => 1) : ()
},
# '00:00:00' is a placeholder that is replaced by the actual time remaining via javascript.
maketext('Remaining time: [_1]', '00:00:00')
) =%>
% }
%
% if ($timeLeft < 60 && $timeLeft > 0 && !$c->{can}{gradeUnsubmittedTest}
% && !$authz->hasPermissions($userID, 'record_answers_when_acting_as_student')) {
<div class="alert alert-danger d-inline-block mb-2 p-1">
<strong><%= maketext('You have less than 1 minute to complete this test.') %></strong>
</div>
% } elsif ($timeLeft <= 0 && !$c->{can}{gradeUnsubmittedTest} &&
% !$authz->hasPermissions($userID, 'record_answers_when_acting_as_student')) {
<div class="alert alert-danger d-inline-block mb-2 p-1">
<strong>
<%= maketext('You are out of time!')
. (
$c->{set}->attempts_per_version > 1
&& $c->{attemptNumber} > 0 ? '' : ' ' . maketext('Press "Grade Test" now!')
) =%>
</strong>
</div>
% }
% # If there are multiple attempts per version, then indicate the number remaining. If a multiple attempt
% # multi-page test has been submitted, then show the score on the previous submission.
% if ($c->{set}->attempts_per_version > 1) {
<div class="alert alert-info p-1">
<em><%= maketext('You have [_1] attempt(s) remaining on this test.', $c->{numAttemptsLeft}) %></em>
</div>
% if ($c->{numAttemptsLeft} < $c->{set}->attempts_per_version
% && $numPages > 1
% && $c->{can}{showScore})
% {
<div id="gwScoreSummary">
<strong><%= maketext('Score summary for last submission:') %></strong>
<table>
<tr>
<th class="text-start"><%= maketext('Prob') %></th>
<td></td>
<th><%= maketext('Status') %></th>
<td></td>
<th><%= maketext('Result') %></th>
</tr>
% for (0 .. $#{ $c->{probStatus} }) {
<tr>
<td><%= $_ + 1 %></td>
<td></td>
<td><%= int(100 * $c->{probStatus}[ $probOrder->[$_] ] + 0.5) . '%' %></td>
<td></td>
<td>
<%= $c->{probStatus}[ $probOrder->[$_] ] == 1
? maketext('Correct')
: maketext('Incorrect') %>
</td>
</tr>
% }
</table>
</div>
% }
% }
% } else {
% if (!$c->{checkAnswers} && !$c->{submitAnswers} && $c->{can}{showScore}) {
<div class="alert alert-warning p-1">
<strong>
<%== maketext(
'Your recorded score on this test (version [_1]) is [_2]/[_3] ([_4]%).',
$setVersionID,
'<span id="test-recorded-score">' . wwRound(2, $c->{recordedScore}) . '</span>',
'<span id="test-total-possible">' . $c->{totalPossible} . '</span>',
'<span id="test-recorded-percent">'
. wwRound(0, 100 * $c->{recordedScore} / $c->{totalPossible})
. '</span>'
)
. (
$c->{exceededAllowedTime} && $c->{recordedScore} == 0
? ' ' . maketext('You exceeded the allowed time.')
: ''
) =%>
</strong>
<br>
</div>
% }
%
% if ($c->{set}->version_last_attempt_time) {
<div class="alert alert-warning p-1">
<%= maketext('Time taken on test: [_1] min ([_2] min allowed).',
$c->{elapsedTime}, sprintf('%.0f', 10 * ($c->{set}->due_date - $c->{set}->open_date) / 6) / 100) %>
<br>
<%= maketext('Test completed on [_1].', $c->{completedTime}) %>
</div>
% } elsif ($c->{exceededAllowedTime} && $c->{recordedScore} != 0) {
<div class="alert alert-warning p-1">
<%= maketext('(This test is overtime because it was not submitted in the allowed time.)') %>
</div>
% }
%
% if ($c->{can}{showWork} && $setID ne 'Undefined_Set') {
<div class="row">
<div class="col-md-10 mb-1">
<div class="alert alert-info p-1 mb-0">
<%= maketext('The test (which is version [_1]) may no longer be submitted for a grade.',
$setVersionID)
. ($c->{can}{showScore} ? (' ' . maketext('You may still check your answers.')) : '') %>
</div>
</div>
% # Display a print test link if the user is allowed to see work.
<div class="col-md-2 text-end mb-1">
<%= link_to maketext('Print Test') =>
$c->systemLink(url_for('hardcopy_preselect_set', setID => "$setID,v$setVersionID")),
class => 'btn btn-info' =%>
</div>
</div>
% }
% }
%
% my $action = url_for;
%
% # This is a hack to get a URL that will not require a proctor login if a proctored test has been submitted for the
% # last time. The assignment type has already been reset in this case, so use that to decide if we should give a path
% # to an unproctored test.
% $action =~ s/proctored_test_mode/test_mode/ if $c->{set}->assignment_type eq 'gateway';
%
% # Make sure that if this is a set, then the 'action' in the form points to the same set.
% $action =~ s/(test_mode\/$setID)\/?$/$1,v$setVersionID\//;
%
% if (!$c->{can}{recordAnswersNextTime} && !$c->{can}{showWork}) {
% # Problems cannot be shown.
<div class="gwProblem">
% if ($c->{set}->hide_work eq 'BeforeAnswerDate') {
<strong>
<%= maketext('Completed results for this assignment are not available until [_1].',
$c->formatDateTime($c->{set}->answer_date, $ce->{studentDateDisplayFormat})) %>
</strong>
% } else {
<strong><%= maketext('Completed results for this assignment are not available.') %></strong>
% }
</div>
% } else {
% # Problems can be shown, so output the main form and the problems.
% my $startTime = param('startTime') || time;
%
% if ($haveProblemWarnings) {
<div class="row g-0">
<div class="col-12 alert alert-danger">
<%== maketext('<strong>Warning</strong>: There may be something wrong with a problem in this test. '
. 'Please inform your instructor including the warning messages below the problem.') =%>
</div>
</div>
% }
%
<%= form_for $action, name => 'gwquiz', method => 'POST', class => 'problem-main-form mt-0', begin =%>
<%= $c->hidden_authen_fields =%>
<%= hidden_field courseID => $ce->{courseName} =%>
%
% # Hacks to use a javascript link to trigger previews and jump to subsequent pages of a multipage test.
<%= hidden_field pageChangeHack => '' =%>
<%= hidden_field startTime => $startTime =%>
% if ($numProbPerPage && $numPages > 1) {
<%= hidden_field newPage => '' =%>
<%= hidden_field currentPage => $pageNumber =%>
% }
% # Keep track that a user has confirmed it is okay to submit for a student.
% if (param('submit_for_student_ok')) {
<%= hidden_field submit_for_student_ok => 1 =%>
% }
%
% # Set up links between problems and, for multi-page tests, pages.
% for my $i (0 .. $#$pg_results) {
% my $pn = $i + 1;
% content_for 'gw-navigation-problem-row' => begin
<td class="problem">
% if ($i >= $startProb && $i <= $endProb) {
<%= link_to $pn => '#', class => 'problem-jump-link', data => { problem_number => $pn } =%>
% } else {
<%= $pn =%>
% }
</td>
% end
% content_for 'gw-navigation-score-row' => begin
<td class="score" data-problem-id="<%= $problems->[ $probOrder->[$i] ]->problem_id %>"
data-problem-value="<%= $problems->[ $probOrder->[$i] ]->value %>">
% if ($c->{probStatus}[ $probOrder->[$i] ] == 1) {
💯
% } else {
<%= wwRound(0, 100 * $c->{probStatus}[ $probOrder->[$i] ]) =%>
% }
</td>
% end
% }
% content_for 'gw-navigation-cols' => begin
<colgroup><col class="header"></colgroup>
% end
% if ($numProbPerPage && $numPages > 1) {
% content_for 'gw-navigation-cols' => begin
% for my $pageNum (1 .. $numPages) {
<colgroup class="page">
% for (1 .. $numProbPerPage) {
% last if $_ * $pageNum > @$problem_numbers;
<col class="problem">
% }
</colgroup>
% }
% end
% for my $i (1 .. $numPages) {
% content_for 'gw-navigation-pages' => begin
<td colspan="<%= $i == $numPages && (@$problem_numbers % $numProbPerPage)
? (@$problem_numbers % $numProbPerPage)
: $numProbPerPage %>"
class="<%= $i == $pageNumber ? 'page active' : 'page' %>">
% if ($i == $pageNumber) {
<%= $i =%>
% } else {
<%= link_to $i => '#', class => 'page-change-link', data => { page_number => $i } =%>
% }
</td>
% end
% }
% content_for 'gw-navigation-table-rows' => begin
% if ($numProbPerPage == 1) {
<tr>
<th scope="row"><%= maketext('Move to Problem:') %></th>
<%= content 'gw-navigation-pages' =%>
</tr>
% } else {
<tr>
<th scope="row" class="text-nowrap"><%= maketext('Move to Page:') %></th>
<%= content 'gw-navigation-pages' =%>
</tr>
<tr>
<th class="text-nowrap"><%= maketext('Jump to Problem:') %></th>
<%= content 'gw-navigation-problem-row' =%>
</tr>
% }
% end
% content_for 'gw-previous-next-buttons' => begin
<div class="submit-buttons-container mb-3">
% my $prevText = $numProbPerPage == 1 ? maketext('Previous Problem') : maketext('Previous Page');
% if ($pageNumber > 1) {
<%= link_to $prevText => '#',
class => 'btn btn-primary page-change-link', data => { page_number => $pageNumber - 1 } =%>
% } else {
<a class="btn btn-primary disabled" role="button" aria-disabled="true"><%= $prevText =%></a>
% }
% my $nextText = $numProbPerPage == 1 ? maketext('Next Problem') : maketext('Next Page');
% if ($pageNumber < $numPages) {
<%= link_to $nextText => '#',
class => 'btn btn-primary page-change-link', data => { page_number => $pageNumber + 1 } =%>
% } else {
<a class="btn btn-primary disabled" role="button" aria-disabled="true"><%= $nextText =%></a>
% }
</div>
% end
% } else {
% content_for 'gw-navigation-cols' => begin
<colgroup class="page"><% for (0 .. $#$pg_results) { =%><col class="problem"><% } =%></colgroup>
% end
% content_for 'gw-navigation-table-rows' => begin
<tr>
<th class="text-nowrap"><%= maketext('Jump to Problem:') %></th>
<%= content 'gw-navigation-problem-row' =%>
</tr>
% end
% }
% if ($c->{can}{showProblemScores} && $c->{set}->version_last_attempt_time) {
% content_for 'gw-navigation-table-rows' => begin
<tr><th><%= maketext('% Score:') %></th><%= content 'gw-navigation-score-row' =%></tr>
% end
% }
% my $jumpLinks = begin
<div class="table-responsive">
<table class="gwNavigation" role="navigation" aria-label="problem navigation">
<%= content 'gw-navigation-cols' =%>
<%= content 'gw-navigation-table-rows' =%>
</table>
</div>
<%= content 'gw-previous-next-buttons' =%>
% end
<%= $jumpLinks->() =%>
%
% # Print out problems and attempt results, as appropriate.
% for my $i (0 .. $#$pg_results) {
% my $pg = $pg_results->[ $probOrder->[$i] ];
%
% if ($i >= $startProb && $i <= $endProb) {
% my $recordMessage = '';
% my $resultsTable = '';
%
% if ($c->{submitAnswers}) {
% if ($c->{scoreRecordedMessage}[ $probOrder->[$i] ] ne 'recorded') {
% $recordMessage = tag('div', class => 'alert alert-danger d-inline-block mb-2 p-1',
% maketext('ANSWERS NOT RECORDED -- [_1]', $c->{scoreRecordedMessage}[ $probOrder->[$i] ])
% );
% }
% $resultsTable = $c->attemptResults($pg);
% } elsif (param('showCorrectAnswers') && $c->{will}{showCorrectAnswers}) {
% $recordMessage = tag('div', class => 'alert alert-danger d-inline-block mb-2 p-1',
% maketext('CORRECT ANSWERS SHOWN ONLY -- ANSWERS NOT RECORDED')
% );
% } elsif ($c->{will}{checkAnswers}) {
% $recordMessage = tag('div', class => 'alert alert-danger d-inline-block mb-2 p-1',
% maketext('ANSWERS ONLY CHECKED -- ANSWERS NOT RECORDED')
% );
%
% $resultsTable = $c->attemptResults($pg);
% } elsif ($c->{previewAnswers}) {
% $recordMessage = tag('div', class => 'alert alert-danger d-inline-block mb-2 p-1',
% maketext('PREVIEW ONLY -- ANSWERS NOT RECORDED')
% );
% }
%
<div class="gwProblem">
% # Show the jump to anchor.
<div id="<%= "prob$i" %>" tabindex="-1"><%= $recordMessage %></div>
% # Output the problem header.
<h2 class="gw-problem-number"><%= maketext('Problem [_1].', $i + 1) %></h2>
<span class="problem-sub-header">
% if ($c->{can}{showTemplateIds}) {
<%= '('
. maketext('Template ID: [_1]', $problems->[ $probOrder->[$i] ]->problem_id) . ')' %>
% }
% my $problemValue = $problems->[ $probOrder->[$i] ]->value;
% if (defined $problemValue) {
% my $points = $problemValue == 1 ? maketext('point') : maketext('points');
<%= "($problemValue $points)" %>
% }
%
% # This uses the permission level and user id of the user assigned to the set.
% if ( $authz->hasPermissions($effectiveUserID, 'print_path_to_problem') )
% {
<%= $problems->[ $probOrder->[$i] ]->source_file %>
% }
</span>
%
% my $instructor_comment = $c->get_instructor_comment($problems->[ $probOrder->[$i] ]);
% if ($instructor_comment) {
<div id="answerComment" class="answerComments">
<b><%= maketext('Instructor Comment:') %></b>
<br>
<%= $instructor_comment %>
</div>
% }
%
% # If there were translation errors, then show those instead of the problem.
% if ($pg->{flags}{error_flag}) {
% stash->{briefErrorOutput} = 1;
<%= include 'ContentGenerator/Base/error_output',
error => $pg->{errors},
details => $pg->{body_text} =%>
%
% delete stash->{briefErrorOutput};
% } else {
<div class="problem-content text-dark col-lg-10" <%== get_problem_lang_and_dir(
$pg->{flags}, $ce->{perProblemLangAndDirSettingMode}, $ce->{language}
) %> data-bs-theme="light">
<%== $pg->{body_text} =%>
</div>
% }
% if ($pg->{result}{msg}) {
<div class="mb-2"><b><%== maketext('Note: [_1]', tag('i', $pg->{result}{msg})) %></b></div>
% }
%
% if ($pg->{flags}{solutionExists} && $authz->hasPermissions($userID, 'always_show_solution')) {
<p>
<b><%= maketext('Note') %>:</b>
<i>
<%= maketext('The solution shown is an instructor preview and '
. 'will only be shown to students when answers are available.'
) =%>
</i>
</p>
% }
%
% if (
% (
% $authz->hasPermissions($userID, 'show_correct_answers_before_answer_date')
% || $authz->hasPermissions($userID, 'view_hidden_work')
% )
% && !$c->can_showCorrectAnswersForAll($c->{set}, $c->{problem}, $c->{tmplSet})
% )
% {
<p>
<b><%= maketext('Note') %>:</b>
<i>
<%= maketext('The correct answers shown in feedback are instructor previews and '
. 'will only be shown to students when answers are available.') =%>
</i>
</p>
% }
%
<div class="text-end mb-2">
<%= link_to maketext('preview answers') => '#',
class => 'gateway-preview-btn btn btn-secondary',
($numProbPerPage && $numPages > 1) ? (data => { page_number => $pageNumber }) : () =%>
</div>
%
% if ($resultsTable) {
<%= $resultsTable =%>
% }
%
% # Initialize the problem graders for the problem.
% if ($c->{will}{showProblemGrader} && !$pg->{flags}{error_flag}) {
<%= WeBWorK::HTML::SingleProblemGrader->new($c, $pg, $problems->[ $probOrder->[$i] ], $c->{set})
->insertGrader =%>
% }
% # Show warnings for the problem if there are any.
<%= include 'ContentGenerator/Base/problem_warning_and_debug_output',
warnings => $pg->{warnings},
warning_messages => ref $pg->{warning_messages} eq 'ARRAY' ? $pg->{warning_messages} : [],
debug_messages => ref $pg->{debug_messages} eq 'ARRAY' ? $pg->{debug_messages} : [] =%>
</div>
% # Store the problem status for continued attempts recording.
<%= hidden_field 'probstatus' . $problems->[ $probOrder->[$i] ]{problem_id}
=> $c->{probStatus}[ $probOrder->[$i] ] =%>
%
<div class="gwDivider"></div>
% } else {
% # Print out hidden fields with the current last answers.
% my $curr_prefix = 'Q' . sprintf('%04d', $problem_numbers->[ $probOrder->[$i] ]) . '_';
% for my $curr_field (grep {/^(?!previous).*$curr_prefix/} keys %{ $c->{formFields} }) {
% if (ref($c->{formFields}{$curr_field}) eq 'ARRAY') {
% for (@{ $c->{formFields}{$curr_field} }) {
<%= hidden_field $curr_field => $_ =%>
% }
% } else {
<%= hidden_field $curr_field => $c->{formFields}{$curr_field} // '' =%>
% }
% }
% # Store the problem status for continued attempts recording.
<%= hidden_field 'probstatus' . $problems->[ $probOrder->[$i] ]{problem_id}
=> $c->{probStatus}[ $probOrder->[$i] ] %>
% }
%
% # If the user can check answers and a problem_data form parameter for
% # this problem has been set then add a hidden input with that data.
% if (
% $c->{can}{checkAnswers}
% && defined $c->param('problem_data_' . $problems->[ $probOrder->[$i] ]{problem_id})
% ) {
<%= hidden_field 'problem_data_' . $problems->[ $probOrder->[$i] ]{problem_id}
=> param('problem_data_' . $problems->[ $probOrder->[$i] ]{problem_id}) =%>
% }
% }
%
<%= $jumpLinks->() =%>
<div class="gwDivider"></div>
%
<div class="submit-buttons-container col-12 mb-2">
<%= submit_button maketext('Preview Test'), name => 'previewAnswers', class => 'btn btn-primary mb-1' =%>
% if ($c->{can}{checkAnswersNextTime}
% && (!$c->{can}{recordAnswersNextTime} || $c->{can}{showProblemGrader})) {
<%= submit_button maketext('Check Test'), name => 'checkAnswers', class => 'btn btn-primary mb-1' =%>
% }
% if ($c->{can}{recordAnswersNextTime}) {
<%= tag('input',
type => 'submit',
name => 'submitAnswers',
value => $effectiveUserID ne $userID
? maketext('Grade Test for [_1]', $effectiveUserID) : maketext('Grade Test'),
class => 'btn btn-primary mb-1',
$c->{set}->attempts_per_version
? (
data => {
confirm_dialog_title => maketext('Do you want to grade this test?'),
confirm_btn_text => maketext('Yes'),
cancel_btn_text => maketext('No'),
confirm_dialog_message => $c->{numAttemptsLeft} > 1
? maketext(
'You have [_1] submissions remaining for this test. If you say yes, then you will '
. 'have [quant,_2,submission] remaining. Once all submissions have been used, your '
. 'answers will be final and you will not be able to continue to work this test '
. 'version.',
$c->{numAttemptsLeft},
$c->{numAttemptsLeft} - 1
)
: $c->{set}->attempts_per_version > 1 ? maketext(
'This is your last submission. If you say yes, then your answers will be final, '
. 'and you will not be able to continue to work this test version.'
)
: maketext(
'This is your only submission. If you say yes, then your answers will be final, '
. 'and you will not be able to continue to work this test version.'
),
# This is always a plural form. JavaScript replaces %d with the
# number of unanswered questions which will be greater than one.
unanswered_questions_message =>
maketext('There are [_1] problems with unanswered questions.', '%d'),
unanswered_question_message => maketext('There is a problem with unanswered questions.'),
return_to_test_message => maketext(
'Are you sure you want to grade the test? '
. 'Select "No" if you would like to return to the test to enter more answers.'
)
}
)
: ()
) =%>
% }
</div>
% if ($numProbPerPage && $numPages > 1 && $c->{can}{recordAnswersNextTime}) {
<p><em><%= maketext('Note: grading the test grades all problems, not just those on this page.') %></em></p>
% }
%
% if ($c->{can}{showCorrectAnswers}) {
<div class="submit-buttons-container col-12 my-2">
<%= submit_button maketext('Show Correct Answers'), name => 'showCorrectAnswers',
class => 'btn btn-primary mb-1' =%>
</div>
% }
%
% if (defined param('sourceFilePath')) {
<%= hidden_field sourceFilePath => param('sourceFilePath') =%>
% }
% if (defined param('problemSeed')) {
<%= hidden_field problemSeed => param('problemSeed') =%>
% }
% # Make sure the student nav filter setting is preserved when the problem form is submitted.
% if (param('studentNavFilter')) {
<%= hidden_field studentNavFilter => param('studentNavFilter') =%>
% }
<% end =%>
% }
%
% # Add a show answers option if appropriate.
% if ($authz->hasPermissions($userID, 'view_answers')) {
<%= form_for 'answer_log', method => 'POST', target => 'WW_Info', begin =%>
<%= $c->hidden_authen_fields('pastans-') =%>
<%= hidden_field courseID => $ce->{courseName} =%>
<%= hidden_field selected_sets => "$setID,v$setVersionID" =%>
<%= hidden_field selected_users => $effectiveUserID =%>
% for ($startProb + 1 .. $endProb + 1) {
<%= hidden_field selected_problems => $_ =%>
% }
<%= submit_button maketext('Show Past Answers'), name => 'action', class => 'btn btn-primary' =%>
<% end =%>
% }
%
% # If achievements enabled, check to see if there are new ones and output them. Use the first
% # problem to seed the data. However, all of the problems will be provided to the achievement evaluator.
% if ($ce->{achievementsEnabled} && $c->{will}{recordAnswers} && $c->{submitAnswers} && $setID ne 'Undefined_Set') {
<%= checkForAchievements($problems->[0], $c, setVersion => $setVersionID) =%>
% }