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 24, 2024
1 parent 7dc5de9 commit 0fd85ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 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
17 changes: 12 additions & 5 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">
<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>
% }
% }
</div>
% } else {
% # Message about if/when next version will be available.
% my $msg = maketext('No more tests available.');
Expand Down

0 comments on commit 0fd85ba

Please sign in to comment.