-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse_info.R
139 lines (126 loc) · 3.88 KB
/
course_info.R
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
######## Course info ########
library(dplyr)
# Unit code (change to your unit acronym)
acronym <- "abc"
# Start of semester
start_semester <- "2024-02-26"
# Week of mid-semester break
mid_semester_break <- "2024-04-01"
# Schedule
schedule <- tibble(
Week = seq(12),
Topic = c(
"Introduction to beans",
"Types of beans",
"Methods of counting",
"Week 4 topic",
"Week 5 topic",
"Week 6 topic",
"Week 7 topic",
"Week 8 topic",
"Week 9 topic",
"Week 10 topic",
"Week 11 topic",
"Week 12 topic"
),
Reference = c(
"1-4. *Advanced R*",
"5-8. *Advanced R*",
"*R Packages*",
"22-24. *Advanced R*",
"9-11. *Advanced R*",
"12-13. *Advanced R*",
"12-13. *Advanced R*",
"*Mastering Shiny*",
"*The {targets} R package user manual*",
"17-20. *Advanced R*",
"21. *Advanced R*",
"25. *Advanced R*"
),
Reference_URL = c(
"https://adv-r.hadley.nz/foundations-intro.html",
"https://adv-r.hadley.nz/foundations-intro.html",
"https://r-pkgs.org",
"https://adv-r.hadley.nz/debugging.html",
"https://adv-r.hadley.nz/fp.html",
"https://adv-r.hadley.nz/oo.html",
"https://adv-r.hadley.nz/oo.html",
"https://mastering-shiny.org",
"https://books.ropensci.org/targets/",
"https://adv-r.hadley.nz/metaprogramming.html",
"https://adv-r.hadley.nz/translation.html",
"https://adv-r.hadley.nz/rcpp.html"
)
)
# Add mid-semester break
# Date here is Monday of each week
calendar <- tibble(
Date = seq(as.Date(start_semester), by = "1 week", length.out = 13)
) |>
mutate(
Week = row_number(),
Week = if_else(Date < mid_semester_break, Week, Week - 1),
#Week =
)
# Add calendar to schedule
schedule <- schedule |>
left_join(calendar, by = "Week") |>
mutate(
Week = if_else(Date == mid_semester_break, NA, Week),
Topic = if_else(Date == mid_semester_break, "Mid-semester break", Topic),
Reference = if_else(Date == mid_semester_break, NA, Reference),
Reference_URL = if_else(Date == mid_semester_break, NA, Reference_URL)
) |>
select(Week, Date, everything())
# Add assignment details
lastmon <- function(x) {
7 * floor(as.numeric(x-1+4)/7) + as.Date(1-4, origin="1970-01-01")
}
assignments <- readr::read_csv(here::here("assignments.csv")) |>
mutate(
Date = lastmon(Due),
Moodle = paste0("https://learning.monash.edu/mod/assign/view.php?id=", Moodle),
File = paste0("assignments/", File)
)
schedule <- schedule |>
full_join(assignments, by = "Date")
show_assignments <- function(week) {
ass <- schedule |>
filter(
Week >= week,
!is.na(Assignment),
) |>
filter(Week == min(Week) | Week - week <= 2) |>
select(Assignment:File)
if(NROW(ass) > 0) {
cat("\n\n## Assignments\n\n")
for(i in seq(NROW(ass))) {
cat("* [", ass$Assignment[i], "](../", ass$File[i], ") is due on ",
format(ass$Due[i], "%A %d %B.\n"), sep="")
}
}
}
submit <- function(schedule, assignment) {
ass <- schedule |>
filter(Assignment == assignment)
due <- format(ass$Due, "%e %B %Y") |> stringr::str_trim()
url <- ass$Moodle
button <- paste0("<br><br><hr><b>Due: ", due, "</b><br>",
"<a href=",url," class = 'badge badge-large badge-blue'>",
"<font size='+2'> <b>Submit</b> </font><br></a>")
cat(button)
}
show_slides <- function(week) {
qmd_file <- here::here(paste0("week",week,"/slides.qmd"))
slides_exist <- fs::file_exists(qmd_file)
if(slides_exist) {
pdf_file <- paste0("https://", acronym, ".numbat.space/week", week, "/slides.pdf")
embed <- paste0(
"<iframe src='https://docs.google.com/gview?url=",
pdf_file,
"&embedded=true' width='100%' height=465></iframe>"
)
button <- paste0("<a href=", pdf_file, " class='badge badge-small badge-red'>Download pdf</a>")
cat(paste0("## Slides for week\n\n", embed,"\n", button))
}
}