MDL-83711 quiz: Quiz navigation profile pic not linking in secure mode

This commit is contained in:
Luca Bösch 2024-11-13 22:08:24 +01:00
parent 7da8af1006
commit 8628fc8664
2 changed files with 26 additions and 1 deletions

View File

@ -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;
}

View File

@ -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"