mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-75058-master' of https://github.com/jleyva/moodle
This commit is contained in:
commit
f9af45eff5
@ -478,6 +478,9 @@ class core_course_external extends external_api {
|
||||
array(
|
||||
'label' => new external_value(PARAM_TEXT, 'date label'),
|
||||
'timestamp' => new external_value(PARAM_INT, 'date timestamp'),
|
||||
'relativeto' => new external_value(PARAM_INT, 'relative date timestamp',
|
||||
VALUE_OPTIONAL),
|
||||
'dataid' => new external_value(PARAM_NOTAGS, 'cm data id', VALUE_OPTIONAL),
|
||||
)
|
||||
),
|
||||
VALUE_DEFAULT,
|
||||
|
@ -1655,6 +1655,59 @@ class externallib_test extends externallib_advanced_testcase {
|
||||
$this->assertEquals(-1, $sections[5]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get course contents dates.
|
||||
*/
|
||||
public function test_get_course_contents_dates() {
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$this->setAdminUser();
|
||||
set_config('enablecourserelativedates', 1);
|
||||
|
||||
// Course with just main section.
|
||||
$timenow = time();
|
||||
$course = self::getDataGenerator()->create_course(
|
||||
['numsections' => 0, 'relativedatesmode' => true, 'startdate' => $timenow - DAYSECS]);
|
||||
|
||||
$teacher = self::getDataGenerator()->create_user();
|
||||
self::getDataGenerator()->enrol_user($teacher->id, $course->id, 'editingteacher');
|
||||
|
||||
$this->setUser($teacher);
|
||||
|
||||
// Create resource (empty dates).
|
||||
$resource = self::getDataGenerator()->create_module('resource', ['course' => $course->id]);
|
||||
// Create activities with dates.
|
||||
$resource = self::getDataGenerator()->create_module('forum', ['course' => $course->id, 'duedate' => $timenow]);
|
||||
$resource = self::getDataGenerator()->create_module('choice',
|
||||
['course' => $course->id, 'timeopen' => $timenow, 'timeclose' => $timenow + DAYSECS]);
|
||||
$resource = self::getDataGenerator()->create_module('assign',
|
||||
['course' => $course->id, 'allowsubmissionsfromdate' => $timenow]);
|
||||
|
||||
$result = core_course_external::get_course_contents($course->id);
|
||||
$result = external_api::clean_returnvalue(core_course_external::get_course_contents_returns(), $result);
|
||||
|
||||
foreach ($result[0]['modules'] as $module) {
|
||||
if ($module['modname'] == 'resource') {
|
||||
$this->assertEmpty($module['dates']);
|
||||
} else if ($module['modname'] == 'forum') {
|
||||
$this->assertCount(1, $module['dates']);
|
||||
$this->assertEquals('duedate', $module['dates'][0]['dataid']);
|
||||
$this->assertEquals($timenow, $module['dates'][0]['timestamp']);
|
||||
} else if ($module['modname'] == 'choice') {
|
||||
$this->assertCount(2, $module['dates']);
|
||||
$this->assertEquals('timeopen', $module['dates'][0]['dataid']);
|
||||
$this->assertEquals($timenow, $module['dates'][0]['timestamp']);
|
||||
$this->assertEquals('timeclose', $module['dates'][1]['dataid']);
|
||||
$this->assertEquals($timenow + DAYSECS, $module['dates'][1]['timestamp']);
|
||||
} else if ($module['modname'] == 'assign') {
|
||||
$this->assertCount(1, $module['dates']);
|
||||
$this->assertEquals('allowsubmissionsfromdate', $module['dates'][0]['dataid']);
|
||||
$this->assertEquals($timenow, $module['dates'][0]['timestamp']);
|
||||
$this->assertEquals($course->startdate, $module['dates'][0]['relativeto']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test duplicate_course
|
||||
*/
|
||||
|
@ -72,6 +72,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:submissionsopen' : 'activitydate:submissionsopened';
|
||||
$date = [
|
||||
'dataid' => 'allowsubmissionsfromdate',
|
||||
'label' => get_string($openlabelid, 'mod_assign'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -83,6 +84,7 @@ class dates extends activity_dates {
|
||||
|
||||
if ($timedue) {
|
||||
$date = [
|
||||
'dataid' => 'duedate',
|
||||
'label' => get_string('activitydate:submissionsdue', 'mod_assign'),
|
||||
'timestamp' => (int) $timedue,
|
||||
];
|
||||
|
@ -56,48 +56,62 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, null, null, null, null, [
|
||||
['label' => get_string('activitydate:submissionsopen', 'mod_assign'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:submissionsopen', 'mod_assign'), 'timestamp' => $after,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, null, null, null, null, [
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $after,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, null, null, null, null, [
|
||||
['label' => get_string('activitydate:submissionsopen', 'mod_assign'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:submissionsopen', 'mod_assign'), 'timestamp' => $after,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, null, null, null, null, [
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $before],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $before,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $after,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, null, null, null, null, [
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $before],
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $before,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'with user override' => [
|
||||
$before, $after, $earlier, $later, null, null, [
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'with group override' => [
|
||||
$before, $after, null, null, $earlier, $later, [
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'with both user and group overrides' => [
|
||||
$before, $after, $earlier, $later, $earlier - DAYSECS, $later + DAYSECS, [
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:submissionsopened', 'mod_assign'), 'timestamp' => $earlier,
|
||||
'dataid' => 'allowsubmissionsfromdate'],
|
||||
['label' => get_string('activitydate:submissionsdue', 'mod_assign'), 'timestamp' => $later,
|
||||
'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -46,6 +46,7 @@ class dates extends activity_dates {
|
||||
if (!empty($chat->schedule) && $chattime > $now) {
|
||||
return [
|
||||
[
|
||||
'dataid' => 'chattime',
|
||||
'label' => get_string('nextchattime', 'mod_chat'),
|
||||
'timestamp' => (int) $chattime
|
||||
]
|
||||
|
@ -62,7 +62,8 @@ class dates_test extends advanced_testcase {
|
||||
$future, CHAT_SCHEDULE_SINGLE, [
|
||||
[
|
||||
'label' => $label,
|
||||
'timestamp' => $future
|
||||
'timestamp' => $future,
|
||||
'dataid' => 'chattime',
|
||||
],
|
||||
]
|
||||
],
|
||||
@ -70,7 +71,8 @@ class dates_test extends advanced_testcase {
|
||||
$future, CHAT_SCHEDULE_WEEKLY, [
|
||||
[
|
||||
'label' => $label,
|
||||
'timestamp' => $future
|
||||
'timestamp' => $future,
|
||||
'dataid' => 'chattime',
|
||||
]
|
||||
]
|
||||
],
|
||||
@ -78,7 +80,8 @@ class dates_test extends advanced_testcase {
|
||||
$future, CHAT_SCHEDULE_DAILY, [
|
||||
[
|
||||
'label' => $label,
|
||||
'timestamp' => $future
|
||||
'timestamp' => $future,
|
||||
'dataid' => 'chattime',
|
||||
]
|
||||
]
|
||||
],
|
||||
@ -86,7 +89,8 @@ class dates_test extends advanced_testcase {
|
||||
$past, CHAT_SCHEDULE_DAILY, [
|
||||
[
|
||||
'label' => $label,
|
||||
'timestamp' => $dailynextchattime
|
||||
'timestamp' => $dailynextchattime,
|
||||
'dataid' => 'chattime',
|
||||
],
|
||||
]
|
||||
],
|
||||
@ -94,7 +98,8 @@ class dates_test extends advanced_testcase {
|
||||
$past, CHAT_SCHEDULE_WEEKLY, [
|
||||
[
|
||||
'label' => $label,
|
||||
'timestamp' => $weeklynextchattime
|
||||
'timestamp' => $weeklynextchattime,
|
||||
'dataid' => 'chattime',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
@ -50,6 +50,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeopen',
|
||||
'label' => get_string($openlabelid, 'course'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -58,6 +59,7 @@ class dates extends activity_dates {
|
||||
if ($timeclose) {
|
||||
$closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeclose',
|
||||
'label' => get_string($closelabelid, 'course'),
|
||||
'timestamp' => (int) $timeclose,
|
||||
];
|
||||
|
@ -56,30 +56,30 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, [
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $later],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closes:', 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, [
|
||||
['label' => 'Opened:', 'timestamp' => $before],
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Opened:', 'timestamp' => $before, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, [
|
||||
['label' => 'Opened:', 'timestamp' => $earlier],
|
||||
['label' => 'Closed:', 'timestamp' => $before],
|
||||
['label' => 'Opened:', 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closed:', 'timestamp' => $before, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -50,6 +50,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeavailablefrom',
|
||||
'label' => get_string($openlabelid, 'course'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -58,6 +59,7 @@ class dates extends activity_dates {
|
||||
if ($timeclose) {
|
||||
$closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeavailableto',
|
||||
'label' => get_string($closelabelid, 'course'),
|
||||
'timestamp' => (int) $timeclose,
|
||||
];
|
||||
|
@ -56,30 +56,30 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeavailablefrom'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, [
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeavailableto'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $later],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeavailablefrom'],
|
||||
['label' => 'Closes:', 'timestamp' => $later, 'dataid' => 'timeavailableto'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, [
|
||||
['label' => 'Opened:', 'timestamp' => $before],
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Opened:', 'timestamp' => $before, 'dataid' => 'timeavailablefrom'],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeavailableto'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, [
|
||||
['label' => 'Opened:', 'timestamp' => $earlier],
|
||||
['label' => 'Closed:', 'timestamp' => $before],
|
||||
['label' => 'Opened:', 'timestamp' => $earlier, 'dataid' => 'timeavailablefrom'],
|
||||
['label' => 'Closed:', 'timestamp' => $before, 'dataid' => 'timeavailableto'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -50,6 +50,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeopen',
|
||||
'label' => get_string($openlabelid, 'course'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -58,6 +59,7 @@ class dates extends activity_dates {
|
||||
if ($timeclose) {
|
||||
$closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeclose',
|
||||
'label' => get_string($closelabelid, 'course'),
|
||||
'timestamp' => (int) $timeclose,
|
||||
];
|
||||
|
@ -56,30 +56,30 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, [
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $later],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closes:', 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, [
|
||||
['label' => 'Opened:', 'timestamp' => $before],
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Opened:', 'timestamp' => $before, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, [
|
||||
['label' => 'Opened:', 'timestamp' => $earlier],
|
||||
['label' => 'Closed:', 'timestamp' => $before],
|
||||
['label' => 'Opened:', 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closed:', 'timestamp' => $before, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -47,6 +47,7 @@ class dates extends activity_dates {
|
||||
|
||||
if ($duedate) {
|
||||
$dates[] = [
|
||||
'dataid' => 'duedate',
|
||||
'label' => get_string('activitydate:due', 'mod_forum'),
|
||||
'timestamp' => (int) $duedate,
|
||||
];
|
||||
|
@ -54,12 +54,12 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'future due date' => [
|
||||
$after, [
|
||||
['label' => 'Due:', 'timestamp' => $after],
|
||||
['label' => 'Due:', 'timestamp' => $after, 'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
'due date is past' => [
|
||||
$before, [
|
||||
['label' => 'Due:', 'timestamp' => $before],
|
||||
['label' => 'Due:', 'timestamp' => $before, 'dataid' => 'duedate'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -50,6 +50,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
|
||||
$dates[] = [
|
||||
'dataid' => 'available',
|
||||
'label' => get_string($openlabelid, 'course'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -58,6 +59,7 @@ class dates extends activity_dates {
|
||||
if ($timeclose) {
|
||||
$closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
|
||||
$dates[] = [
|
||||
'dataid' => 'deadline',
|
||||
'label' => get_string($closelabelid, 'course'),
|
||||
'timestamp' => (int) $timeclose,
|
||||
];
|
||||
|
@ -56,48 +56,48 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after, 'dataid' => 'available'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, null, null, null, null, [
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after, 'dataid' => 'available'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $before],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $before, 'dataid' => 'available'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closed', 'course'), 'timestamp' => $before],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'available'],
|
||||
['label' => get_string('activitydate:closed', 'course'), 'timestamp' => $before, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
'with user override' => [
|
||||
$before, $after, $earlier, $later, null, null, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'available'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
'with group override' => [
|
||||
$before, $after, null, null, $earlier, $later, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'available'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
'with both user and group overrides' => [
|
||||
$before, $after, $earlier, $later, $earlier - DAYSECS, $later + DAYSECS, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'available'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'deadline'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -50,6 +50,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeopen',
|
||||
'label' => get_string($openlabelid, 'core_course'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -58,6 +59,7 @@ class dates extends activity_dates {
|
||||
if ($timeclose) {
|
||||
$closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeclose',
|
||||
'label' => get_string($closelabelid, 'core_course'),
|
||||
'timestamp' => (int) $timeclose,
|
||||
];
|
||||
|
@ -56,48 +56,48 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, null, null, null, null, [
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opens', 'course'), 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $before],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $before, 'dataid' => 'timeopen'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, null, null, null, null, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closed', 'course'), 'timestamp' => $before],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => get_string('activitydate:closed', 'course'), 'timestamp' => $before, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with user override' => [
|
||||
$before, $after, $earlier, $later, null, null, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with group override' => [
|
||||
$before, $after, null, null, $earlier, $later, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with both user and group overrides' => [
|
||||
$before, $after, $earlier, $later, $earlier - DAYSECS, $later + DAYSECS, [
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later],
|
||||
['label' => get_string('activitydate:opened', 'course'), 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => get_string('activitydate:closes', 'course'), 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -50,6 +50,7 @@ class dates extends activity_dates {
|
||||
if ($timeopen) {
|
||||
$openlabelid = $timeopen > $now ? 'activitydate:opens' : 'activitydate:opened';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeopen',
|
||||
'label' => get_string($openlabelid, 'core_course'),
|
||||
'timestamp' => (int) $timeopen,
|
||||
];
|
||||
@ -58,6 +59,7 @@ class dates extends activity_dates {
|
||||
if ($timeclose) {
|
||||
$closelabelid = $timeclose > $now ? 'activitydate:closes' : 'activitydate:closed';
|
||||
$dates[] = [
|
||||
'dataid' => 'timeclose',
|
||||
'label' => get_string($closelabelid, 'core_course'),
|
||||
'timestamp' => (int) $timeclose,
|
||||
];
|
||||
|
@ -56,30 +56,30 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with opening time' => [
|
||||
$after, null, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
]
|
||||
],
|
||||
'only with closing time' => [
|
||||
null, $after, [
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'with both times' => [
|
||||
$after, $later, [
|
||||
['label' => 'Opens:', 'timestamp' => $after],
|
||||
['label' => 'Closes:', 'timestamp' => $later],
|
||||
['label' => 'Opens:', 'timestamp' => $after, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closes:', 'timestamp' => $later, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'between the dates' => [
|
||||
$before, $after, [
|
||||
['label' => 'Opened:', 'timestamp' => $before],
|
||||
['label' => 'Closes:', 'timestamp' => $after],
|
||||
['label' => 'Opened:', 'timestamp' => $before, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closes:', 'timestamp' => $after, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
'dates are past' => [
|
||||
$earlier, $before, [
|
||||
['label' => 'Opened:', 'timestamp' => $earlier],
|
||||
['label' => 'Closed:', 'timestamp' => $before],
|
||||
['label' => 'Opened:', 'timestamp' => $earlier, 'dataid' => 'timeopen'],
|
||||
['label' => 'Closed:', 'timestamp' => $before, 'dataid' => 'timeclose'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
@ -53,6 +53,7 @@ class dates extends activity_dates {
|
||||
if ($submissionstart) {
|
||||
$openlabelid = $submissionstart > $now ? 'activitydate:submissionsopen' : 'activitydate:submissionsopened';
|
||||
$dates[] = [
|
||||
'dataid' => 'submissionstart',
|
||||
'label' => get_string($openlabelid, 'mod_workshop'),
|
||||
'timestamp' => (int) $submissionstart,
|
||||
];
|
||||
@ -61,6 +62,7 @@ class dates extends activity_dates {
|
||||
if ($submissionend) {
|
||||
$closelabelid = $submissionend > $now ? 'activitydate:submissionsclose' : 'activitydate:submissionsclosed';
|
||||
$dates[] = [
|
||||
'dataid' => 'submissionend',
|
||||
'label' => get_string($closelabelid, 'mod_workshop'),
|
||||
'timestamp' => (int) $submissionend,
|
||||
];
|
||||
@ -69,6 +71,7 @@ class dates extends activity_dates {
|
||||
if ($assessmentstart) {
|
||||
$openlabelid = $assessmentstart > $now ? 'activitydate:assessmentsopen' : 'activitydate:assessmentsopened';
|
||||
$dates[] = [
|
||||
'dataid' => 'assessmentstart',
|
||||
'label' => get_string($openlabelid, 'mod_workshop'),
|
||||
'timestamp' => (int) $assessmentstart,
|
||||
];
|
||||
@ -77,6 +80,7 @@ class dates extends activity_dates {
|
||||
if ($assessmentend) {
|
||||
$closelabelid = $assessmentend > $now ? 'activitydate:assessmentsclose' : 'activitydate:assessmentsclosed';
|
||||
$dates[] = [
|
||||
'dataid' => 'assessmentend',
|
||||
'label' => get_string($closelabelid, 'mod_workshop'),
|
||||
'timestamp' => (int) $assessmentend,
|
||||
];
|
||||
|
@ -58,46 +58,46 @@ class dates_test extends advanced_testcase {
|
||||
],
|
||||
'only with start time for submissions' => [
|
||||
$after, null, null, null, [
|
||||
['label' => 'Submissions open:', 'timestamp' => $after],
|
||||
['label' => 'Submissions open:', 'timestamp' => $after, 'dataid' => 'submissionstart'],
|
||||
]
|
||||
],
|
||||
'only with end time for submissions' => [
|
||||
null, $after, null, null, [
|
||||
['label' => 'Submissions close:', 'timestamp' => $after],
|
||||
['label' => 'Submissions close:', 'timestamp' => $after, 'dataid' => 'submissionend'],
|
||||
]
|
||||
],
|
||||
'only with start time for assessments' => [
|
||||
null, null, $after, null, [
|
||||
['label' => 'Assessments open:', 'timestamp' => $after],
|
||||
['label' => 'Assessments open:', 'timestamp' => $after, 'dataid' => 'assessmentstart'],
|
||||
]
|
||||
],
|
||||
'only with end time for assessments' => [
|
||||
null, null, null, $after, [
|
||||
['label' => 'Assessments close:', 'timestamp' => $after],
|
||||
['label' => 'Assessments close:', 'timestamp' => $after, 'dataid' => 'assessmentend'],
|
||||
]
|
||||
],
|
||||
'all times in future' => [
|
||||
$after, $later, $latest, $latest + DAYSECS, [
|
||||
['label' => 'Submissions open:', 'timestamp' => $after],
|
||||
['label' => 'Submissions close:', 'timestamp' => $later],
|
||||
['label' => 'Assessments open:', 'timestamp' => $latest],
|
||||
['label' => 'Assessments close:', 'timestamp' => $latest + DAYSECS],
|
||||
['label' => 'Submissions open:', 'timestamp' => $after, 'dataid' => 'submissionstart'],
|
||||
['label' => 'Submissions close:', 'timestamp' => $later, 'dataid' => 'submissionend'],
|
||||
['label' => 'Assessments open:', 'timestamp' => $latest, 'dataid' => 'assessmentstart'],
|
||||
['label' => 'Assessments close:', 'timestamp' => $latest + DAYSECS, 'dataid' => 'assessmentend'],
|
||||
]
|
||||
],
|
||||
'all times in the past' => [
|
||||
$earliest - DAYSECS, $earliest, $earlier, $before, [
|
||||
['label' => 'Submissions opened:', 'timestamp' => $earliest - DAYSECS],
|
||||
['label' => 'Submissions closed:', 'timestamp' => $earliest],
|
||||
['label' => 'Assessments opened:', 'timestamp' => $earlier],
|
||||
['label' => 'Assessments closed:', 'timestamp' => $before],
|
||||
['label' => 'Submissions opened:', 'timestamp' => $earliest - DAYSECS, 'dataid' => 'submissionstart'],
|
||||
['label' => 'Submissions closed:', 'timestamp' => $earliest, 'dataid' => 'submissionend'],
|
||||
['label' => 'Assessments opened:', 'timestamp' => $earlier, 'dataid' => 'assessmentstart'],
|
||||
['label' => 'Assessments closed:', 'timestamp' => $before, 'dataid' => 'assessmentend'],
|
||||
]
|
||||
],
|
||||
'between submission and assessment' => [
|
||||
$earlier, $before, $after, $later, [
|
||||
['label' => 'Submissions opened:', 'timestamp' => $earlier],
|
||||
['label' => 'Submissions closed:', 'timestamp' => $before],
|
||||
['label' => 'Assessments open:', 'timestamp' => $after],
|
||||
['label' => 'Assessments close:', 'timestamp' => $later],
|
||||
['label' => 'Submissions opened:', 'timestamp' => $earlier, 'dataid' => 'submissionstart'],
|
||||
['label' => 'Submissions closed:', 'timestamp' => $before, 'dataid' => 'submissionend'],
|
||||
['label' => 'Assessments open:', 'timestamp' => $after, 'dataid' => 'assessmentstart'],
|
||||
['label' => 'Assessments close:', 'timestamp' => $later, 'dataid' => 'assessmentend'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user