From 8628fc8664d49dde740eeed1a3d09437657f5a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Wed, 13 Nov 2024 22:08:24 +0100 Subject: [PATCH] MDL-83711 quiz: Quiz navigation profile pic not linking in secure mode --- .../classes/output/navigation_panel_base.php | 5 ++++- mod/quiz/tests/behat/attempt_basic.feature | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mod/quiz/classes/output/navigation_panel_base.php b/mod/quiz/classes/output/navigation_panel_base.php index c4350612d5b..b4a56a32571 100644 --- a/mod/quiz/classes/output/navigation_panel_base.php +++ b/mod/quiz/classes/output/navigation_panel_base.php @@ -171,13 +171,16 @@ abstract class navigation_panel_base { * @return user_picture|null */ public function user_picture() { - global $DB; + global $DB, $PAGE; if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_NONE) { return null; } $user = $DB->get_record('user', ['id' => $this->attemptobj->get_userid()]); $userpicture = new user_picture($user); $userpicture->courseid = $this->attemptobj->get_courseid(); + if ($PAGE->pagelayout === 'secure') { + $userpicture->link = false; + } if ($this->attemptobj->get_quiz()->showuserpicture == QUIZ_SHOWIMAGE_LARGE) { $userpicture->size = true; } diff --git a/mod/quiz/tests/behat/attempt_basic.feature b/mod/quiz/tests/behat/attempt_basic.feature index 04ebd106617..466fa63cb2d 100644 --- a/mod/quiz/tests/behat/attempt_basic.feature +++ b/mod/quiz/tests/behat/attempt_basic.feature @@ -234,3 +234,25 @@ Feature: Attempt a quiz And I press "Continue your attempt" Then I should see "First question" And I should not see "First question version 2" + + @javascript + Scenario: User image in the quiz navigation in normal mode. + Given I am on the "Quiz 1" "quiz activity editing" page logged in as "admin" + And I expand all fieldsets + And I set the field "Show the user's picture" to "Large image" + And I press "Save and return to course" + And I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + And I press "Attempt quiz" + Then "Student One" "link" should exist in the "Quiz navigation" "block" + + @javascript + Scenario: User image in the quiz navigation in secure layout. + Given I am on the "Quiz 1" "quiz activity editing" page logged in as "admin" + And I expand all fieldsets + And I set the field "Show the user's picture" to "Large image" + And I set the field "Browser security" to "Full screen pop-up with some JavaScript security" + And I press "Save and return to course" + And I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + And I press "Attempt quiz" + And I switch to a second window + Then "Student One" "link" should not exist in the "Quiz navigation" "block"