From 980aeed02af1c69302c3f4b433be6b815659d48c Mon Sep 17 00:00:00 2001 From: James Gurung Date: Wed, 17 Feb 2021 17:30:24 +0000 Subject: [PATCH] Minor fixes. --- README.md | 8 ++++---- src/CalendarGenerator.cs | 4 ++-- src/InputReader.cs | 2 +- src/Settings.cs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e79584e..ba91ffa 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This is a cross-platform command line tool for bulk generating student and teach This file is required to configure: * Daily **`timings`**, which can be customised for specific `days` and/or `yearGroups` -* Year group **`absences`** (e.g. for study leave or staggered start days) +* Year group **`absences`** (e.g. for study leave or a staggered start of term) * Period **`overrides`** (e.g. whole-school tutorials or early finishes) * Lesson **`renames`** @@ -46,7 +46,7 @@ This file is required to configure: ], "overrides": [ - { "date": "2021-09-02", "period": "1", "yearGroups": [8, 9, 10, 12], "title": "" } + { "date": "2021-09-02", "period": "1", "yearGroups": [8, 9, 10, 12], "title": "" }, { "date": "2021-12-17", "period": "4", "title": "Whole school assembly" }, { "date": "2021-12-17", "period": "5", "title": "" } ], @@ -116,7 +116,7 @@ To create this file in SIMS: #### google-key.json -If you are using the `--google` flag to directly upload timetables to Google Calendar, your domain administrator will need to create a free service account key: +If you are using the `--google` flag to directly sync timetables to Google Calendar, your domain administrator will need to create a free service account key: 1. [Create a new project](https://console.cloud.google.com/projectcreate) on the Google Cloud Platform console. 1. [Enable the Google Calendar API.](https://console.cloud.google.com/apis/library/calendar-json.googleapis.com) Depending on the size of your school, you may also need to apply for a raised quota. The tool may use up to 1000 API requests per user when it is first run. @@ -134,7 +134,7 @@ If you are using the `--google` flag to directly upload timetables to Google Cal #### microsoft-key.json -This file is required if you are using the `--microsoft` flag to directly upload timetables to Microsoft 365. +This file is required if you are using the `--microsoft` flag to directly sync timetables to Microsoft 365. ``` { diff --git a/src/CalendarGenerator.cs b/src/CalendarGenerator.cs index 5d9631b..7ed6ab2 100644 --- a/src/CalendarGenerator.cs +++ b/src/CalendarGenerator.cs @@ -26,7 +26,7 @@ public IList Generate(Person person) var period = periodTimings.Key; myLessons.TryGetValue($"{dayCode}:{period}", out var lesson); - var yearGroup = person.YearGroup ?? lesson?.YearGroup ?? default; + var yearGroup = person.YearGroup ?? lesson?.YearGroup; var overridePeriod = Settings.Overrides.FirstOrDefault(o => o.Date == date && o.Period == period && (o.YearGroups?.Contains(yearGroup) ?? true)); @@ -40,7 +40,7 @@ public IList Generate(Person person) } else if (lesson is not null) { - if (Settings.Absences.Any(o => o.YearGroups.Contains(yearGroup) && o.StartDate <= date && o.EndDate >= date)) continue; + if (yearGroup is not null && Settings.Absences.Any(o => o.YearGroups.Contains(yearGroup.Value) && o.StartDate <= date && o.EndDate >= date)) continue; var clsName = lesson.Class; if (Settings.RenameDictionary.TryGetValue(clsName, out var newTitle)) diff --git a/src/InputReader.cs b/src/InputReader.cs index 730c0de..f88309a 100644 --- a/src/InputReader.cs +++ b/src/InputReader.cs @@ -207,7 +207,7 @@ private static async Task> LoadTeachersAsync() private static int? GetYearFromClassName(string className) { - var yearDigits = className.TakeWhile(char.IsDigit).ToArray(); + var yearDigits = className.TakeWhile(c => c >= '0' && c <= '9').ToArray(); return yearDigits.Length == 0 ? null : int.Parse(new string(yearDigits)); } diff --git a/src/Settings.cs b/src/Settings.cs index 1cd5e28..42cddc3 100644 --- a/src/Settings.cs +++ b/src/Settings.cs @@ -42,7 +42,7 @@ public class Override public DateTime Date { get; set; } public string Period { get; set; } public string Title { get; set; } - public IList YearGroups { get; set; } + public IList YearGroups { get; set; } } public class Rename @@ -55,7 +55,7 @@ public class Timing { public string Period { get; set; } public int Duration { get; set; } - public IList YearGroups { get; set; } + public IList YearGroups { get; set; } public IList Days { get; set; } public string StartTime