From c13b829c00faedc1df799374cf9aa8834dcf1bad Mon Sep 17 00:00:00 2001 From: Mahmoud Kassaei Date: Fri, 29 Jan 2021 19:28:32 +0000 Subject: [PATCH] MDL-70719 quiz overrides: only show Actions column header if needed --- mod/quiz/overrides.php | 15 +++++++++------ mod/quiz/tests/behat/quiz_user_override.feature | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mod/quiz/overrides.php b/mod/quiz/overrides.php index fafcb4fa308..8d312839907 100644 --- a/mod/quiz/overrides.php +++ b/mod/quiz/overrides.php @@ -147,17 +147,20 @@ if ($groupmode) { // Initialise table. $table = new html_table(); +$table->head = $headers; $table->colclasses = $colclasses; +$table->headspan = array_fill(0, count($headers), 1); + +$table->head[] = get_string('overrides', 'quiz'); $table->colclasses[] = 'colsetting'; $table->colclasses[] = 'colvalue'; -$table->colclasses[] = 'colaction'; -$table->headspan = array_fill(0, count($headers), 1); $table->headspan[] = 2; -$table->headspan[] = 1; -$table->head = $headers; -$table->head[] = get_string('overrides', 'quiz'); -$table->head[] = get_string('action'); +if ($canedit) { + $table->head[] = get_string('action'); + $table->colclasses[] = 'colaction'; + $table->headspan[] = 1; +} $userurl = new moodle_url('/user/view.php', []); $groupurl = new moodle_url('/group/overview.php', ['id' => $cm->course]); diff --git a/mod/quiz/tests/behat/quiz_user_override.feature b/mod/quiz/tests/behat/quiz_user_override.feature index db450d3bf46..ae6327ddfb7 100644 --- a/mod/quiz/tests/behat/quiz_user_override.feature +++ b/mod/quiz/tests/behat/quiz_user_override.feature @@ -44,6 +44,7 @@ Feature: Quiz user override And I set the following fields to these values: | timeclose[year] | 2030 | And I press "Save" + And I should see "Action" And I should see "Tuesday, 1 January 2030, 8:00" in the "Student One" "table_row" And I should see "student1@example.com" in the "Student One" "table_row" @@ -64,6 +65,7 @@ Feature: Quiz user override | Attempts allowed | 1 | And I press "Save" Then I should see "This override is inactive" + And I should see "Action" And "Edit" "icon" should exist in the "Student One" "table_row" And "copy" "icon" should exist in the "Student One" "table_row" And "Delete" "icon" should exist in the "Student One" "table_row" @@ -82,6 +84,7 @@ Feature: Quiz user override | Override user | Student One | | Attempts allowed | 1 | And I press "Save" + And I should see "Action" And I should not see "student1@example.com" And "Edit" "icon" should exist in the "Student One" "table_row" And "copy" "icon" should exist in the "Student One" "table_row" @@ -139,6 +142,7 @@ Feature: Quiz user override Then "Student One" "table_row" should exist And "Student Two" "table_row" should exist And "Add user override" "button" should not exist + And I should not see "Action" And "Edit" "link" should not exist in the "Student One" "table_row" And "Copy" "link" should not exist in the "Student One" "table_row" And "Delete" "link" should not exist in the "Student One" "table_row"