diff --git a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm index 6a007a388b..c1c9df3904 100644 --- a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -609,8 +609,7 @@ async sub pre_header_initialize ($c) { || $authz->hasPermissions($userID, 'create_new_set_version_when_acting_as_student')) ) { - - $c->{invalidSet} = $c->maketext( + $c->{actingConformation} = $c->maketext( 'You are acting as user [_1]. If you continue, you will create a new version of ' . 'this test for that user, which will count against their allowed maximum ' . 'number of versions for the current time interval. In general, this is not ' @@ -618,16 +617,15 @@ async sub pre_header_initialize ($c) { . 'the "Create New Test Version" button below. Alternatively, click "Cancel".', $effectiveUserID ); - $c->{invalidVersionCreation} = 1; - $c->{confirmSubmitForStudent} = 1; + $c->{actingConformationCreate} = 1; + return; } elsif ($effectiveUserID ne $userID) { - $c->{invalidSet} = $c->maketext( + $c->{actingCreationError} = $c->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 ); - $c->{invalidVersionCreation} = 1; } elsif (($maxAttemptsPerVersion == 0 || $currentNumAttempts < $maxAttemptsPerVersion) && $c->submitTime < $set->due_date() + $ce->{gatewayGracePeriod}) @@ -665,7 +663,7 @@ async sub pre_header_initialize ($c) { # student which is dangerous for open test versions. Give a warning unless the user # has already confirmed they understand the risk. if ($effectiveUserID ne $userID && !$c->param('submit_for_student_ok')) { - $c->{invalidSet} = $c->maketext( + $c->{actingConformation} = $c->maketext( 'You are trying to view an open test version for [_1] and have the permission to submit ' . 'answers for that user. This is dangerous, as your answers can overwrite the ' . q/student's answers as you move between test pages, preview, or check answers. / @@ -675,7 +673,7 @@ async sub pre_header_initialize ($c) { . 'before viewing open test versions.', $effectiveUserID ); - $c->{confirmSubmitForStudent} = 1; + return; } } } @@ -694,8 +692,8 @@ async sub pre_header_initialize ($c) { else { delete $c->authen->session->{proctor_authorization_granted}; } } - # If the set or problem is invalid, then delete any proctor session keys and return. - if ($c->{invalidSet}) { + # If the set is invalid, then delete any proctor session keys and return. + if ($c->{invalidSet} || $c->{actingCreationError}) { if (defined $c->{assignment_type} && $c->{assignment_type} eq 'proctored_gateway') { delete $c->authen->session->{proctor_authorization_granted}; } @@ -1368,7 +1366,7 @@ sub path ($c, $args) { $args, 'WeBWorK' => $navigation_allowed ? $c->url_for('root') : '', $courseName => $navigation_allowed ? $c->url_for('set_list') : '', - $setID eq 'Undefined_Set' || $c->{invalidSet} + $setID eq 'Undefined_Set' || $c->{invalidSet} || $c->{actingCreationError} || $c->{actingConformation} ? ($setID => '') : ( $c->{set}->set_id => $c->url_for('problem_list', setID => $c->{set}->set_id), @@ -1382,7 +1380,7 @@ sub nav ($c, $args) { my $userID = $c->param('user'); my $effectiveUserID = $c->param('effectiveUser'); - return '' if $c->{invalidSet}; + return '' if $c->{invalidSet} || $c->{actingCreationError} || $c->{actingConformation}; # Set up and display a student navigation for those that have permission to act as a student. if ($c->authz->hasPermissions($userID, 'become_student') && $effectiveUserID ne $userID) { diff --git a/templates/ContentGenerator/GatewayQuiz.html.ep b/templates/ContentGenerator/GatewayQuiz.html.ep index fcaaaf38f2..7b251f1f24 100644 --- a/templates/ContentGenerator/GatewayQuiz.html.ep +++ b/templates/ContentGenerator/GatewayQuiz.html.ep @@ -65,42 +65,46 @@ % my $userID = param('user'); % my $effectiveUserID = param('effectiveUser'); % -% # If the set or problem is invalid, then show that information and exit. +% # If the set is invalid, then show that information and exit. % if ($c->{invalidSet}) {
- % if (!$c->{confirmSubmitForStudent} || $c->{invalidVersionCreation}) { -
- % if ($c->{invalidVersionCreation}) { - <%= maketext( - 'The selected test ([_1]) is not a valid test for [_2] (acted as by [_3]).', - $setID, $effectiveUserID, $userID - ) =%> - % } else { - <%= maketext( - 'The selected test ([_1]) is not a valid test for [_2].', - $setID, $effectiveUserID - ) =%> - % } -
- % } +
+ <%= maketext('The selected test ([_1]) is not a valid test for [_2].', $setID, $effectiveUserID) =%> +
<%= $c->{invalidSet} %>
- % if ($c->{confirmSubmitForStudent}) { -
- <%= link_to $c->{invalidVersionCreation} - ? maketext('Create New Test Version') : maketext('View Test Version') => $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' - =%> -
- % } +
+ % last; +% } +% # If user tried to create a test version for another user without correct permissions, show message and exit. +% if ($c->{actingCreationError}) { +
+ <%= 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 + ) =%> +
+ % last; +% } +% # Get confirmation before creating new test version or working on an open test for another user. +% if ($c->{actingConformation}) { +
+
<%= $c->{actingConformation} =%>
+
+ <%= link_to $c->{actingConformationCreate} + ? maketext('Create New Test Version') : maketext('View Test Version') => $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' + =%> +
% % last;