Skip to content

Commit

Permalink
Disable start new test button instead of hiding it.
Browse files Browse the repository at this point in the history
When acting as another user, disable the "Start New Test" button
instead of hiding it if user doesn't have permission to start a
test as a different user.  Include a tooltip that states why the
button is disabled.
  • Loading branch information
somiaj committed Nov 13, 2024
1 parent be8f218 commit 1143916
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/WeBWorK/ContentGenerator/ProblemSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async sub initialize ($c) {
my $eUserID = $c->param('effectiveUser');

# Don't show "Start New Test" button when acting as another user, unless user has permissions to do so.
$c->{hide_start_new_test} = $userID ne $eUserID
$c->{disable_start_new_test} = $userID ne $eUserID
&& !($authz->hasPermissions($userID, 'record_answers_when_acting_as_student')
|| $authz->hasPermissions($userID, 'create_new_set_version_when_acting_as_student'));

Expand Down
19 changes: 13 additions & 6 deletions templates/ContentGenerator/ProblemSet/version_list.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,20 @@
<div class="alert alert-warning"><%= maketext('This test requires a proctor password to start.') %></div>
% }
%
% # Hide "Start New Test" button when acting as another use who doesn't have permissions to start test.
% unless ($c->{hide_start_new_test}) {
<div class="mb-3">
<%= link_to maketext('Start New Test') => $c->systemLink(url_for($routeName, setID => $set->set_id)),
class => 'btn btn-primary' =%>
</div>
<div class="mb-3">
% # Disable "Start New Test" button when acting as another user who doesn't have permissions to start tests.
% if ($c->{disable_start_new_test}) {
<span class="d-inline-block set-id-tooltip" tabindex="0" data-bs-toggle="tooltip" data-bs-placement="top"
data-bs-title="<%=maketext(
'You are acting as another user and do not have permission to start a new test for other users.'
) %>">
<button class="btn btn-primary" type="button" disabled><%= maketext('Start New Test') %></button>
</span>
% } else {
<%= link_to maketext('Start New Test') => $c->systemLink(url_for($routeName, setID => $set->set_id)),
class => "btn btn-primary" =%>
% }
</div>
% } else {
% # Message about if/when next version will be available.
% my $msg = maketext('No more tests available.');
Expand Down

0 comments on commit 1143916

Please sign in to comment.