From 11439165c45042b7306d4c69e7570accc6dd8c14 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Tue, 12 Nov 2024 22:36:52 -0700 Subject: [PATCH] Disable start new test button instead of hiding it. 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. --- lib/WeBWorK/ContentGenerator/ProblemSet.pm | 2 +- .../ProblemSet/version_list.html.ep | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/WeBWorK/ContentGenerator/ProblemSet.pm b/lib/WeBWorK/ContentGenerator/ProblemSet.pm index 5f025e357c..c77ce3ef77 100644 --- a/lib/WeBWorK/ContentGenerator/ProblemSet.pm +++ b/lib/WeBWorK/ContentGenerator/ProblemSet.pm @@ -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')); diff --git a/templates/ContentGenerator/ProblemSet/version_list.html.ep b/templates/ContentGenerator/ProblemSet/version_list.html.ep index 7c91f5ebf3..1bcebd81d5 100644 --- a/templates/ContentGenerator/ProblemSet/version_list.html.ep +++ b/templates/ContentGenerator/ProblemSet/version_list.html.ep @@ -126,13 +126,20 @@
<%= maketext('This test requires a proctor password to start.') %>
% } % - % # Hide "Start New Test" button when acting as another use who doesn't have permissions to start test. - % unless ($c->{hide_start_new_test}) { -
- <%= link_to maketext('Start New Test') => $c->systemLink(url_for($routeName, setID => $set->set_id)), - class => 'btn btn-primary' =%> -
+
+ % # Disable "Start New Test" button when acting as another user who doesn't have permissions to start tests. + % if ($c->{disable_start_new_test}) { + + + + % } else { + <%= link_to maketext('Start New Test') => $c->systemLink(url_for($routeName, setID => $set->set_id)), + class => "btn btn-primary" =%> % } +
% } else { % # Message about if/when next version will be available. % my $msg = maketext('No more tests available.');