-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschedule.Rmd
79 lines (71 loc) · 2.48 KB
/
schedule.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
title: "Course Schedule"
output:
html_document:
number_sections: false
toc: no
---
```{r child = file.path("child", "setup.Rmd")}
```
All assignments are due by 11:59pm on the due date.
```{r echo=FALSE}
library(kableExtra)
library(tidyverse)
# Setup some common values
fa <- list(
assignment = '[<i class="fas fa-pencil-ruler"></i>]',
class = '[<i class="fas fa-laptop-code"></i>]',
reading = '[<i class="fas fa-book"></i>]'
)
# Make the schedule data frame
schedule <- gsheet::gsheet2tbl(settings$schedule_url) %>%
mutate(
date_raw = date,
date = format(date, format = "%b %d"),
assign_due = lead(date_raw, 1) - 1,
assign_due = format(assign_due, format = "%b %d"),
description = ifelse(is.na(description), "", description),
quiz = ifelse(is.na(quiz), "", quiz),
assign_num = ifelse(class_num == 13, NA, class_num),
assignments = ifelse(
is.na(assign_num), "", paste0(
fa$assignment, "(hw", assign_num, "-", stub, ".html) **HW ",
assign_num, "**<br>Due: ", assign_due)),
class_url = ifelse(
is.na(class_num), "",
paste0(fa$class, "(c", class_num, "-", stub, ".html)")),
class = ifelse(
is.na(class), "",
paste0("**", class, "**<br>", description)),
class = paste(class_url, class, sep = " "),
reading = ifelse(is.na(reading), "", reading),
reading = str_split(reading, '\n'),
reading_name = ifelse(is.na(reading_name), "", reading_name),
reading_name = str_split(reading_name, '\n')
)
# Fix reading names
schedule$reading_good <- ""
for (i in 1:nrow(schedule)) {
reading <- schedule[i,]$reading[[1]]
if ('' %in% reading) {
schedule[i,]$reading_good <- reading
} else {
reading_name <- schedule[i,]$reading_name [[1]]
reading <- paste0(fa$reading, '(', reading, '.html)')
reading <- paste(paste(reading, reading_name), collapse = '<br>')
schedule[i,]$reading_good <- reading
}
}
highlight <- which(Sys.Date() > schedule$date_raw)
# Make the final schedule
names(schedule) <- str_to_title(names(schedule))
schedule %>%
select(Week, Date, Quiz, Class, Assignments, Reading = Reading_good) %>%
kable(format = 'html', escape = FALSE,
align = c('c', 'c', 'l', 'l', 'l', 'l')) %>%
kable_styling(full_width = F, bootstrap_options = c("striped", "hover")) %>%
column_spec(column = 2, width = '2em') %>%
column_spec(column = 4, width = '20em') %>%
column_spec(column = 5, width = '9em') %>%
row_spec(highlight, background = "#e1e1e1")
```