Skip to content

Commit

Permalink
MDL-71163 quizaccess_openclosedate: remove duplicate date info
Browse files Browse the repository at this point in the history
The quiz module now showa the quiz open and close dates at the top of
the page. So there is no need for the quizaccess_openclosedate plugin to
display these dates in the middle of the page.
  • Loading branch information
rezaies committed Apr 30, 2021
1 parent 1da9d7a commit e25be6b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 47 deletions.
1 change: 1 addition & 0 deletions mod/quiz/accessrule/openclosedate/lang/en/deprecated.txt
@@ -0,0 +1 @@
quiznotavailable,quizaccess_openclosedate
Expand Up @@ -30,4 +30,7 @@
$string['notavailable'] = 'This quiz is not currently available';
$string['pluginname'] = 'Open and close date access rule';
$string['privacy:metadata'] = 'The Open and close date quiz access rule plugin does not store any personal data.';

// Deprecated since Moodle 3.11.
$string['quiznotavailable'] = 'The quiz will not be available until {$a}';

24 changes: 0 additions & 24 deletions mod/quiz/accessrule/openclosedate/rule.php
Expand Up @@ -42,30 +42,6 @@ public static function make(quiz $quizobj, $timenow, $canignoretimelimits) {
return new self($quizobj, $timenow);
}

public function description() {
$result = array();
if ($this->timenow < $this->quiz->timeopen) {
$result[] = get_string('quiznotavailable', 'quizaccess_openclosedate',
userdate($this->quiz->timeopen));
if ($this->quiz->timeclose) {
$result[] = get_string('quizcloseson', 'quiz', userdate($this->quiz->timeclose));
}

} else if ($this->quiz->timeclose && $this->timenow > $this->quiz->timeclose) {
$result[] = get_string('quizclosed', 'quiz', userdate($this->quiz->timeclose));

} else {
if ($this->quiz->timeopen) {
$result[] = get_string('quizopenedon', 'quiz', userdate($this->quiz->timeopen));
}
if ($this->quiz->timeclose) {
$result[] = get_string('quizcloseson', 'quiz', userdate($this->quiz->timeclose));
}
}

return $result;
}

public function prevent_access() {
$message = get_string('notavailable', 'quizaccess_openclosedate');

Expand Down
21 changes: 0 additions & 21 deletions mod/quiz/accessrule/openclosedate/tests/rule_test.php
Expand Up @@ -50,7 +50,6 @@ public function test_no_dates() {
$attempt->preview = 0;

$rule = new quizaccess_openclosedate($quizobj, 10000);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
Expand All @@ -59,7 +58,6 @@ public function test_no_dates() {
$this->assertFalse($rule->time_left_display($attempt, 0));

$rule = new quizaccess_openclosedate($quizobj, 0);
$this->assertEmpty($rule->description());
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
Expand All @@ -79,8 +77,6 @@ public function test_start_date() {
$attempt->preview = 0;

$rule = new quizaccess_openclosedate($quizobj, 9999);
$this->assertEquals($rule->description(),
array(get_string('quiznotavailable', 'quizaccess_openclosedate', userdate(10000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
Expand All @@ -89,8 +85,6 @@ public function test_start_date() {
$this->assertFalse($rule->time_left_display($attempt, 0));

$rule = new quizaccess_openclosedate($quizobj, 10000);
$this->assertEquals($rule->description(),
array(get_string('quizopenedon', 'quiz', userdate(10000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
Expand All @@ -110,8 +104,6 @@ public function test_close_date() {
$attempt->preview = 0;

$rule = new quizaccess_openclosedate($quizobj, 20000);
$this->assertEquals($rule->description(),
array(get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));
Expand All @@ -123,8 +115,6 @@ public function test_close_date() {
$this->assertEquals($rule->time_left_display($attempt, 20100), -100);

$rule = new quizaccess_openclosedate($quizobj, 20001);
$this->assertEquals($rule->description(),
array(get_string('quizclosed', 'quiz', userdate(20000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
Expand All @@ -148,33 +138,22 @@ public function test_both_dates() {
$attempt->preview = 0;

$rule = new quizaccess_openclosedate($quizobj, 9999);
$this->assertEquals($rule->description(),
array(get_string('quiznotavailable', 'quizaccess_openclosedate', userdate(10000)),
get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));

$rule = new quizaccess_openclosedate($quizobj, 10000);
$this->assertEquals($rule->description(),
array(get_string('quizopenedon', 'quiz', userdate(10000)),
get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));

$rule = new quizaccess_openclosedate($quizobj, 20000);
$this->assertEquals($rule->description(),
array(get_string('quizopenedon', 'quiz', userdate(10000)),
get_string('quizcloseson', 'quiz', userdate(20000))));
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
$this->assertFalse($rule->is_finished(0, $attempt));

$rule = new quizaccess_openclosedate($quizobj, 20001);
$this->assertEquals($rule->description(),
array(get_string('quizclosed', 'quiz', userdate(20000))));
$this->assertEquals($rule->prevent_access(),
get_string('notavailable', 'quizaccess_openclosedate'));
$this->assertFalse($rule->prevent_new_attempt(0, $attempt));
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/tests/external_test.php
Expand Up @@ -1670,8 +1670,8 @@ public function test_get_quiz_access_information() {
$result = mod_quiz_external::get_quiz_access_information($quiz->id);
$result = external_api::clean_returnvalue(mod_quiz_external::get_quiz_access_information_returns(), $result);

// Access limited by time and password.
$this->assertCount(3, $result['accessrules']);
// Access is limited by time and password, but only the password limit has a description.
$this->assertCount(1, $result['accessrules']);
// Two rule names, password and open/close date.
$this->assertCount(2, $result['activerulenames']);
$this->assertCount(1, $result['preventaccessreasons']);
Expand Down

0 comments on commit e25be6b

Please sign in to comment.