Merge branch 'MDL-57254-master' of git://github.com/jleyva/moodle

This commit is contained in:
David Monllao
2017-03-20 06:48:43 +01:00
2 changed files with 13 additions and 0 deletions
+6
View File
@@ -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 {
+7
View File
@@ -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);