Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgurung committed Feb 17, 2021
1 parent f7d3e8f commit 980aeed
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`**

Expand All @@ -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": "" }
],
Expand Down Expand Up @@ -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.
Expand All @@ -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.

```
{
Expand Down
4 changes: 2 additions & 2 deletions src/CalendarGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public IList<CalendarEvent> 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));

Expand All @@ -40,7 +40,7 @@ public IList<CalendarEvent> 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))
Expand Down
2 changes: 1 addition & 1 deletion src/InputReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static async Task<IEnumerable<Person>> 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));
}

Expand Down
4 changes: 2 additions & 2 deletions src/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Override
public DateTime Date { get; set; }
public string Period { get; set; }
public string Title { get; set; }
public IList<int> YearGroups { get; set; }
public IList<int?> YearGroups { get; set; }
}

public class Rename
Expand All @@ -55,7 +55,7 @@ public class Timing
{
public string Period { get; set; }
public int Duration { get; set; }
public IList<int> YearGroups { get; set; }
public IList<int?> YearGroups { get; set; }
public IList<string> Days { get; set; }

public string StartTime
Expand Down

0 comments on commit 980aeed

Please sign in to comment.