Skip to content

Commit

Permalink
MDL-80946 quizaccess_seb: Remove invalidkeys text if not using SEB.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kotlyar committed Aug 21, 2024
1 parent 6cd5507 commit 4bb0465
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mod/quiz/accessrule/seb/rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,11 @@ private function get_reason_text(string $identifier): string {
*/
private function get_invalid_key_error_message(): string {
// Return error message with download link and links to get the seb config.
return get_string('invalidkeys', 'quizaccess_seb')
. $this->display_buttons($this->get_action_buttons());
if ($this->accessmanager->is_using_seb()) {
return get_string('invalidkeys', 'quizaccess_seb')
. $this->display_buttons($this->get_action_buttons());
}
return $this->display_buttons($this->get_action_buttons());
}

/**
Expand Down
4 changes: 4 additions & 0 deletions mod/quiz/accessrule/seb/tests/rule_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public function test_access_prevented_if_config_key_invalid(): void {

// Set up dummy request.
$FULLME = 'https://example.com/moodle/mod/quiz/attempt.php?attemptid=123&page=4';
$_SERVER['HTTP_USER_AGENT'] = 'SEB';
$_SERVER['HTTP_X_SAFEEXAMBROWSER_CONFIGKEYHASH'] = 'Broken config key';

$user = $this->getDataGenerator()->create_user();
Expand All @@ -397,6 +398,7 @@ public function test_access_prevented_if_config_key_invalid_uploaded_config(): v

// Set up dummy request.
$FULLME = 'https://example.com/moodle/mod/quiz/attempt.php?attemptid=123&page=4';
$_SERVER['HTTP_USER_AGENT'] = 'SEB';
$_SERVER['HTTP_X_SAFEEXAMBROWSER_CONFIGKEYHASH'] = 'Broken config key';

$user = $this->getDataGenerator()->create_user();
Expand All @@ -422,6 +424,7 @@ public function test_access_prevented_if_config_key_invalid_uploaded_template():

// Set up dummy request.
$FULLME = 'https://example.com/moodle/mod/quiz/attempt.php?attemptid=123&page=4';
$_SERVER['HTTP_USER_AGENT'] = 'SEB';
$_SERVER['HTTP_X_SAFEEXAMBROWSER_CONFIGKEYHASH'] = 'Broken config key';

$user = $this->getDataGenerator()->create_user();
Expand Down Expand Up @@ -677,6 +680,7 @@ public function test_access_prevented_if_browser_exam_keys_are_invalid_use_uploa
// Set up dummy request.
$FULLME = 'https://example.com/moodle/mod/quiz/attempt.php?attemptid=123&page=4';
$expectedhash = hash('sha256', $FULLME . $quizsettings->get_config_key());
$_SERVER['HTTP_USER_AGENT'] = 'SEB';
$_SERVER['HTTP_X_SAFEEXAMBROWSER_CONFIGKEYHASH'] = $expectedhash;

// Set up broken browser key.
Expand Down

0 comments on commit 4bb0465

Please sign in to comment.