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 c74a623
Show file tree
Hide file tree
Showing 2 changed files with 17 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
22 changes: 16 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,23 @@
<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>
% # Disable "Start New Test" button when acting as another use who doesn't have permissions to start test.
% my $disabled = '';
% my $disabled_tooltip = '';
% if ($c->{disable_start_new_test}) {
% $disabled = ' disabled';
% $disabled_tooltip = ' class="d-inline-block" tabindex="0" data-bs-toggle="tooltip" '
% . 'data-bs-placement="top" title="'
% . maketext(
% 'You are acting as another user and do not have permission to start a new test for other users.')
% . '"';
% }
<div class="mb-3">
<span<%== $disabled_tooltip =%>>
<%= link_to maketext('Start New Test') => $c->systemLink(url_for($routeName, setID => $set->set_id)),
class => "btn btn-primary$disabled" =%>
</span>
</div>
% } else {
% # Message about if/when next version will be available.
% my $msg = maketext('No more tests available.');
Expand Down

0 comments on commit c74a623

Please sign in to comment.