Skip to content

Commit 4e0670f

Browse files
author
Martin Krulis
committed
Fixing SIS extensions to support SIS courses events which are not scheduled (do not have day, time, or room filled).
1 parent 0b12cf6 commit 4e0670f

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

app/V1Module/presenters/SisPresenter.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,16 @@ public function actionCreateGroup($courseId) {
333333
$group = new Group($remoteCourse->getCourseId(), $parentGroup->getInstance(), $user, $parentGroup);
334334

335335
foreach (["en", "cs"] as $language) {
336-
$timeInfo = $this->dayToString($remoteCourse->getDayOfWeek(), $language) . ", " . $remoteCourse->getTime();
337-
if ($remoteCourse->isFortnightly()) {
338-
$timeInfo .= ', ' . $this->oddWeeksToString($remoteCourse->getOddWeeks(), $language);
336+
// Assemble new group name from course data....
337+
if ($remoteCourse->getDayOfWeek() !== null && $remoteCourse->getTime() !== null) {
338+
$timeInfo = $this->dayToString($remoteCourse->getDayOfWeek(), $language) . ", " . $remoteCourse->getTime();
339+
if ($remoteCourse->isFortnightly()) {
340+
$timeInfo .= ', ' . $this->oddWeeksToString($remoteCourse->getOddWeeks(), $language);
341+
}
342+
$caption = sprintf("%s (%s)", $remoteCourse->getCaption($language), $timeInfo);
343+
} else {
344+
$caption = $remoteCourse->getCaption($language);
339345
}
340-
$caption = sprintf("%s (%s)", $remoteCourse->getCaption($language), $timeInfo);
341346

342347
$localization = new LocalizedGroup($language, $caption, $remoteCourse->getAnnotation($language));
343348
$group->addLocalizedText($localization);

app/helpers/SisHelper/SisCourseRecord.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ public static function fromArray($sisUserId, $data) {
5353
$result->affiliation = $data["affiliation"];
5454
$result->year = $data["year"];
5555
$result->term = $data["semester"];
56-
$result->dayOfWeek = intval($data["day_of_week"]) - 1;
57-
$minutes = intval($data["time"]);
58-
$result->time = (new DateTime())
59-
->setTime(floor($minutes / 60), $minutes % 60)
60-
->format("H:i");
56+
$result->dayOfWeek = $data["day_of_week"] !== null ? intval($data["day_of_week"]) - 1 : null;
57+
if ($data["time"] !== null) {
58+
$minutes = intval($data["time"]);
59+
$result->time = (new DateTime())
60+
->setTime(floor($minutes / 60), $minutes % 60)
61+
->format("H:i");
62+
} else {
63+
$result->time = null;
64+
}
6165
$result->fortnightly = $data["fortnight"];
6266
$result->oddWeeks = $data["firstweek"] == 1;
6367
$result->type = array_key_exists($data["type"], static::$typeMap) ? static::$typeMap[$data["type"]] : "unknown";

0 commit comments

Comments
 (0)