Skip to content

Commit

Permalink
MDL-58578 mod_quiz: Correctly provide group override priorities
Browse files Browse the repository at this point in the history
Previously the override priorities were being provided
back to front.
  • Loading branch information
cameorn1730 committed Apr 27, 2017
1 parent 756a132 commit 7eae70e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions mod/quiz/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1352,17 +1352,17 @@ function quiz_get_group_override_priorities($quizid) {
}
}

// Sort open times in descending manner. The earlier open time gets higher priority.
rsort($grouptimeopen);
// Sort open times in ascending manner. The earlier open time gets higher priority.
sort($grouptimeopen);
// Set priorities.
$opengrouppriorities = [];
$openpriority = 1;
foreach ($grouptimeopen as $timeopen) {
$opengrouppriorities[$timeopen] = $openpriority++;
}

// Sort close times in ascending manner. The later close time gets higher priority.
sort($grouptimeclose);
// Sort close times in descending manner. The later close time gets higher priority.
rsort($grouptimeclose);
// Set priorities.
$closegrouppriorities = [];
$closepriority = 1;
Expand Down
8 changes: 4 additions & 4 deletions mod/quiz/tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ public function test_quiz_get_group_override_priorities() {

$openpriorities = $priorities['open'];
// Override 2's time open has higher priority since it is sooner than override 1's.
$this->assertEquals(1, $openpriorities[$override1->timeopen]);
$this->assertEquals(2, $openpriorities[$override2->timeopen]);
$this->assertEquals(2, $openpriorities[$override1->timeopen]);
$this->assertEquals(1, $openpriorities[$override2->timeopen]);

$closepriorities = $priorities['close'];
// Override 1's time close has higher priority since it is later than override 2's.
$this->assertEquals(2, $closepriorities[$override1->timeclose]);
$this->assertEquals(1, $closepriorities[$override2->timeclose]);
$this->assertEquals(1, $closepriorities[$override1->timeclose]);
$this->assertEquals(2, $closepriorities[$override2->timeclose]);
}

public function test_quiz_core_calendar_provide_event_action_open() {
Expand Down

0 comments on commit 7eae70e

Please sign in to comment.