Merge branch 'MDL-57254-master' of git://github.com/jleyva/moodle
This commit is contained in:
@@ -1027,6 +1027,12 @@ function choice_can_view_results($choice, $current = null, $choiceopen = null) {
|
||||
|
||||
if (is_null($choiceopen)) {
|
||||
$timenow = time();
|
||||
|
||||
if ($choice->timeopen != 0 && $timenow < $choice->timeopen) {
|
||||
// If the choice is not available, we can't see the results.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($choice->timeclose != 0 && $timenow > $choice->timeclose) {
|
||||
$choiceopen = false;
|
||||
} else {
|
||||
|
||||
@@ -102,7 +102,14 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
|
||||
$canview = choice_can_view_results($choice);
|
||||
$this->assertTrue($canview);
|
||||
|
||||
// Add a time restriction (choice not open yet).
|
||||
$choice->timeopen = time() + YEARSECS;
|
||||
$DB->update_record('choice', $choice);
|
||||
$canview = choice_can_view_results($choice);
|
||||
$this->assertFalse($canview);
|
||||
|
||||
// Show results after closing.
|
||||
$choice->timeopen = 0;
|
||||
$choice->showresults = CHOICE_SHOWRESULTS_AFTER_CLOSE;
|
||||
$DB->update_record('choice', $choice);
|
||||
$canview = choice_can_view_results($choice);
|
||||
|
||||
Reference in New Issue
Block a user