From cb13bba9b688dee18e06dc8b0afb5ef3f9e594f2 Mon Sep 17 00:00:00 2001 From: Nexterday Date: Tue, 5 Dec 2023 15:20:03 +0100 Subject: [PATCH] MDL-74836 theme: Display activity header on secure layouts --- .../secure_layout_activity_heading.feature | 38 +++++++++++++++++++ theme/boost/layout/secure.php | 6 +++ theme/boost/templates/secure.mustache | 3 ++ theme/classic/layout/secure.php | 6 +++ theme/classic/templates/secure.mustache | 3 ++ 5 files changed, 56 insertions(+) create mode 100644 mod/quiz/accessrule/seb/tests/behat/secure_layout_activity_heading.feature diff --git a/mod/quiz/accessrule/seb/tests/behat/secure_layout_activity_heading.feature b/mod/quiz/accessrule/seb/tests/behat/secure_layout_activity_heading.feature new file mode 100644 index 00000000000..9c1f1b57e7e --- /dev/null +++ b/mod/quiz/accessrule/seb/tests/behat/secure_layout_activity_heading.feature @@ -0,0 +1,38 @@ +@mod_quiz @quizaccess @quizaccess_seb +Feature: View the activity header when Safe Exam Browser is required + In order to correctly identify the quiz when Safe Exam Browser is required + As a student + I need to be able to see the quiz information in the activity header + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Sam1 | Student1 | student1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | TF1 | TF question | + And the following "activity" exists: + | activity | quiz | + | course | C1 | + | idnumber | 00001 | + | name | Test quiz name | + | intro | Test quiz description | + | seb_requiresafeexambrowser | 1 | + | grade | 10 | + And quiz "Test quiz name" contains the following questions: + | question | page | + | TF1 | 1 | + + Scenario: Quiz description is displayed when Safe Exam Browser is required + When I am on the "Test quiz name" "quiz activity" page logged in as student1 + Then I should see "Launch Safe Exam Browser" + And I should see "Test quiz description" diff --git a/theme/boost/layout/secure.php b/theme/boost/layout/secure.php index 74fe3f9543a..6b329213c6f 100644 --- a/theme/boost/layout/secure.php +++ b/theme/boost/layout/secure.php @@ -36,5 +36,11 @@ $templatecontext = [ 'hasblocks' => $hasblocks ]; +if (empty($PAGE->layout_options['noactivityheader'])) { + $header = $PAGE->activityheader; + $renderer = $PAGE->get_renderer('core'); + $templatecontext['headercontent'] = $header->export_for_template($renderer); +} + echo $OUTPUT->render_from_template('theme_boost/secure', $templatecontext); diff --git a/theme/boost/templates/secure.mustache b/theme/boost/templates/secure.mustache index 32d92b5340d..e5334304a3c 100644 --- a/theme/boost/templates/secure.mustache +++ b/theme/boost/templates/secure.mustache @@ -63,6 +63,9 @@
{{{ output.course_content_header }}} + {{#headercontent}} + {{> core/activity_header }} + {{/headercontent}} {{{ output.main_content }}} {{{ output.course_content_footer }}} diff --git a/theme/classic/layout/secure.php b/theme/classic/layout/secure.php index e51b3f28ffa..560be423960 100644 --- a/theme/classic/layout/secure.php +++ b/theme/classic/layout/secure.php @@ -42,5 +42,11 @@ $templatecontext = [ 'bodyattributes' => $bodyattributes ]; +if (empty($PAGE->layout_options['noactivityheader'])) { + $header = $PAGE->activityheader; + $renderer = $PAGE->get_renderer('core'); + $templatecontext['headercontent'] = $header->export_for_template($renderer); +} + echo $OUTPUT->render_from_template('theme_classic/secure', $templatecontext); diff --git a/theme/classic/templates/secure.mustache b/theme/classic/templates/secure.mustache index b237592f39b..37b539dd0f2 100644 --- a/theme/classic/templates/secure.mustache +++ b/theme/classic/templates/secure.mustache @@ -75,6 +75,9 @@
{{{ output.course_content_header }}} + {{#headercontent}} + {{> core/activity_header }} + {{/headercontent}} {{{ output.main_content }}} {{{ output.course_content_footer }}}