Skip to content

Commit

Permalink
remove date and time display on course page for no fixed time meetings
Browse files Browse the repository at this point in the history
  • Loading branch information
karenliulll committed Oct 6, 2023
1 parent 910bcd8 commit 48f3254
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
37 changes: 21 additions & 16 deletions classes/dates.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,32 @@ class dates extends activity_dates {
protected function get_dates(): array {
$starttime = $this->cm->customdata['start_time'] ?? null;
$duration = $this->cm->customdata['duration'] ?? null;
$recurring = $this->cm->customdata['recurring'] ?? null;
$recurrencetype = $this->cm->customdata['recurrence_type'] ?? null;
$now = time();
$dates = [];

if ($starttime) {
if ($duration && $starttime + $duration < $now) {
// Meeting has ended.
$dataid = 'end_date_time';
$labelid = 'activitydate:ended';
$meetimgtimestamp = $starttime + $duration;
} else {
// Meeting hasn't started / in progress, or without fixed time (doesn't have an end date or time).
$dataid = 'start_time';
$labelid = $starttime > $now ? 'activitydate:starts' : 'activitydate:started';
$meetimgtimestamp = $starttime;
}
// For meeting with no fixed time, no time info needed on course page.
if (!($recurring == 1 && $recurrencetype == 0)) {
if ($duration && $starttime + $duration < $now) {
// Meeting has ended.
$dataid = 'end_date_time';
$labelid = 'activitydate:ended';
$meetimgtimestamp = $starttime + $duration;
} else {
// Meeting hasn't started / in progress, or without fixed time (doesn't have an end date or time).
$dataid = 'start_time';
$labelid = $starttime > $now ? 'activitydate:starts' : 'activitydate:started';
$meetimgtimestamp = $starttime;
}

$dates[] = [
'dataid' => $dataid,
'label' => get_string($labelid, 'mod_zoom'),
'timestamp' => $meetimgtimestamp,
];
$dates[] = [
'dataid' => $dataid,
'label' => get_string($labelid, 'mod_zoom'),
'timestamp' => $meetimgtimestamp,
];
}
}

return $dates;
Expand Down
7 changes: 6 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ function zoom_get_coursemodule_info($coursemodule) {
global $DB;

$dbparams = ['id' => $coursemodule->instance];
$fields = 'id, intro, introformat, start_time, duration';
$fields = 'id, intro, introformat, start_time, recurring, recurrence_type, duration';
if (!$zoom = $DB->get_record('zoom', $dbparams, $fields)) {
return false;
}
Expand All @@ -1313,6 +1313,11 @@ function zoom_get_coursemodule_info($coursemodule) {
$result->customdata['duration'] = $zoom->duration;
}

// Skip the if condition for recurring and recurrence_type, the values of NULL and 0 are needed in other functions.
$result->customdata['recurring'] = $zoom->recurring;

$result->customdata['recurrence_type'] = $zoom->recurrence_type;

return $result;
}

Expand Down

0 comments on commit 48f3254

Please sign in to comment.