|
1 | | -#' Insert a GitHub assignation in the document |
| 1 | +#' Insert a GitHub assignation or challenge in the document |
2 | 2 | #' |
3 | | -#' Insert a block of class `assign` with data related to a GitHub (Classroom) |
| 3 | +#' Insert a block of class `assign`, `assign2`, `challenge` or `challenge2` with data related to a GitHub (Classroom) |
4 | 4 | #' assignment. |
5 | 5 | #' |
6 | | -#' @param name The name of the assignation (usually the same as the name of the |
| 6 | +#' @param name The name of the assignation or the challenge (usually the same as the name of the |
7 | 7 | #' template GitHub repository). |
8 | | -#' @param url The URL of the assignation (could be a named list for different |
| 8 | +#' @param url The URL of the assignation or challenge (could be a named list for different |
9 | 9 | #' versions depending on the course). |
10 | 10 | #' @param course.urls Named vector with the Classroom URLS for each course. |
11 | 11 | #' Names are the course identifiers in Moodle. If `NULL`, no course-specific |
|
25 | 25 | #' the ex-toc. |
26 | 26 | #' @param assign.link The link to the learnr help page (when the user clicks on |
27 | 27 | #' the image in the ex-toc). |
| 28 | +#' @param block The class of the div, or the LaTeX environment to use for the assignment block. |
28 | 29 | #' @param title The title of the block. |
29 | 30 | #' @param part.name The word to use for "part". |
30 | 31 | #' @param alt The text to display for alternate access to the repository (for |
|
45 | 46 | assignation <- function(name, url, course.urls = NULL, part = NULL, |
46 | 47 | course.names = c(course1 = "Data Science"), toc = "", |
47 | 48 | texts = assignation_en(), assign.img = "images/list-assign.png", |
48 | | -assign.link = "github_assignation") { |
| 49 | +assign.link = "github_assignation", block = "assign") { |
49 | 50 | if (is.null(part)) { |
50 | 51 | anchor <- name |
51 | 52 | part <- "" |
@@ -85,17 +86,47 @@ assign.link = "github_assignation") { |
85 | 86 |
|
86 | 87 | alt_text <- glue::glue(texts$alt) |
87 | 88 |
|
88 | | - glue::glue("\n\\BeginKnitrBlock{{assign}}<div class=\"assign\"> |
| 89 | + glue::glue("\n\\BeginKnitrBlock{{{block}}}<div class=\"{block}\"> |
89 | 90 | {texts$title} **[{name}]{{#{anchor} }}{part}**. |
90 | 91 |
|
91 | 92 | {course_text} |
92 | 93 |
|
93 | 94 | {alt_text} |
94 | 95 |
|
95 | 96 | *{texts$sub}{part}.* |
96 | | -</div>\\EndKnitrBlock{{assign}}\n\n") |
| 97 | +</div>\\EndKnitrBlock{{{block}}}\n\n") |
97 | 98 | } |
98 | 99 |
|
| 100 | +#' @rdname assignation |
| 101 | +#' @export |
| 102 | +assignation2 <- function(name, url, course.urls = NULL, part = NULL, |
| 103 | +course.names = c(course1 = "Data Science"), toc = "", |
| 104 | +texts = assignation2_en(), assign.img = "images/list-assign2.png", |
| 105 | +assign.link = "github_assignation", block = "assign2") |
| 106 | + assignation(name, url, course.urls = course.urls, part = part, |
| 107 | + course.names = course.names, toc = toc, texts = texts, |
| 108 | + assign.img = assign.img, assign.link = assign.link, block = block) |
| 109 | + |
| 110 | +#' @rdname assignation |
| 111 | +#' @export |
| 112 | +challenge <- function(name, url, course.urls = NULL, part = NULL, |
| 113 | + course.names = c(course1 = "Data Science"), toc = "", |
| 114 | + texts = challenge_en(), assign.img = "images/list-challenge.png", |
| 115 | + assign.link = "github_assignation", block = "challenge") |
| 116 | + assignation(name, url, course.urls = course.urls, part = part, |
| 117 | + course.names = course.names, toc = toc, texts = texts, |
| 118 | + assign.img = assign.img, assign.link = assign.link, block = block) |
| 119 | + |
| 120 | +#' @rdname assignation |
| 121 | +#' @export |
| 122 | +challenge2 <- function(name, url, course.urls = NULL, part = NULL, |
| 123 | + course.names = c(course1 = "Data Science"), toc = "", |
| 124 | + texts = challenge2_en(), assign.img = "images/list-challenge2.png", |
| 125 | + assign.link = "github_assignation", block = "challenge2") |
| 126 | + assignation(name, url, course.urls = course.urls, part = part, |
| 127 | + course.names = course.names, toc = toc, texts = texts, |
| 128 | + assign.img = assign.img, assign.link = assign.link, block = block) |
| 129 | + |
99 | 130 | #' @rdname assignation |
100 | 131 | #' @export |
101 | 132 | assignation_en <- function(title, part.name, alt, sub, course, toc.def) { |
@@ -137,3 +168,129 @@ assignation_fr <- function(title, part.name, alt, sub, course, toc.def) { |
137 | 168 |
|
138 | 169 | texts |
139 | 170 | } |
| 171 | + |
| 172 | +#' @rdname assignation |
| 173 | +#' @export |
| 174 | +assignation2_en <- function(title, part.name, alt, sub, course, toc.def) { |
| 175 | + texts <- list( |
| 176 | + title = "Complete this group assignation:", |
| 177 | + part.name = "part", |
| 178 | + alt = "If you are not a registered user, or if you work outside of a course, fork [this]({url}){{target=\"_blank\"}} repository.", |
| 179 | + sub = "See the explanations in the `README.md`", |
| 180 | + course = "Group assignation for the students enrolled at the course", |
| 181 | + toc.def = "Group assignation {name}" |
| 182 | + ) |
| 183 | + if (!missing(title)) texts$title <- title |
| 184 | + if (!missing(part.name)) texts$part.name <- part.name |
| 185 | + if (!missing(alt)) texts$alt <- alt |
| 186 | + if (!missing(sub)) texts$sub <- sub |
| 187 | + if (!missing(course)) texts$course <- course |
| 188 | + if (!missing(toc.def)) texts$toc.def <- toc.def |
| 189 | + |
| 190 | + texts |
| 191 | +} |
| 192 | + |
| 193 | +#' @rdname assignation |
| 194 | +#' @export |
| 195 | +assignation2_fr <- function(title, part.name, alt, sub, course, toc.def) { |
| 196 | + texts <- list( |
| 197 | + title = "R\u00e9alisez en groupe l'assignation", |
| 198 | + part.name = "partie", |
| 199 | + alt = "Si vous \u00eates un utilisateur non enregistr\u00e9 ou que vous travaillez en dehors d'un cours, faites un \"fork\" de [ce]({url}){{target=\"_blank\"}} d\u00e9p\u00f4t.", |
| 200 | + sub = "Voyez les explications dans le fichier `README.md`", |
| 201 | + course = "Assignation en groupe pour les \u00e9tudiants inscrits au cours de", |
| 202 | + toc.def = "Assignation en groupe {name}" |
| 203 | + ) |
| 204 | + if (!missing(title)) texts$title <- title |
| 205 | + if (!missing(part.name)) texts$part.name <- part.name |
| 206 | + if (!missing(alt)) texts$alt <- alt |
| 207 | + if (!missing(sub)) texts$sub <- sub |
| 208 | + if (!missing(course)) texts$course <- course |
| 209 | + if (!missing(toc.def)) texts$toc.def <- toc.def |
| 210 | + |
| 211 | + texts |
| 212 | +} |
| 213 | + |
| 214 | +#' @rdname assignation |
| 215 | +#' @export |
| 216 | +challenge_en <- function(title, part.name, alt, sub, course, toc.def) { |
| 217 | + texts <- list( |
| 218 | + title = "Accept this challenge:", |
| 219 | + part.name = "part", |
| 220 | + alt = "If you are not a registered user, or if you work outside of a course, fork [this]({url}){{target=\"_blank\"}} repository.", |
| 221 | + sub = "See the explanations in the `README.md`", |
| 222 | + course = "Challenge for the students enrolled at the course", |
| 223 | + toc.def = "Challenge {name}" |
| 224 | + ) |
| 225 | + if (!missing(title)) texts$title <- title |
| 226 | + if (!missing(part.name)) texts$part.name <- part.name |
| 227 | + if (!missing(alt)) texts$alt <- alt |
| 228 | + if (!missing(sub)) texts$sub <- sub |
| 229 | + if (!missing(course)) texts$course <- course |
| 230 | + if (!missing(toc.def)) texts$toc.def <- toc.def |
| 231 | + |
| 232 | + texts |
| 233 | +} |
| 234 | + |
| 235 | +#' @rdname assignation |
| 236 | +#' @export |
| 237 | +challenge_fr <- function(title, part.name, alt, sub, course, toc.def) { |
| 238 | + texts <- list( |
| 239 | + title = "Relevez le challenge", |
| 240 | + part.name = "partie", |
| 241 | + alt = "Si vous \u00eates un utilisateur non enregistr\u00e9 ou que vous travaillez en dehors d'un cours, faites un \"fork\" de [ce]({url}){{target=\"_blank\"}} d\u00e9p\u00f4t.", |
| 242 | + sub = "Voyez les explications dans le fichier `README.md`", |
| 243 | + course = "Challenge pour les \u00e9tudiants inscrits au cours de", |
| 244 | + toc.def = "Challenge {name}" |
| 245 | + ) |
| 246 | + if (!missing(title)) texts$title <- title |
| 247 | + if (!missing(part.name)) texts$part.name <- part.name |
| 248 | + if (!missing(alt)) texts$alt <- alt |
| 249 | + if (!missing(sub)) texts$sub <- sub |
| 250 | + if (!missing(course)) texts$course <- course |
| 251 | + if (!missing(toc.def)) texts$toc.def <- toc.def |
| 252 | + |
| 253 | + texts |
| 254 | +} |
| 255 | + |
| 256 | +#' @rdname assignation |
| 257 | +#' @export |
| 258 | +challenge2_en <- function(title, part.name, alt, sub, course, toc.def) { |
| 259 | + texts <- list( |
| 260 | + title = "Accept this group challenge:", |
| 261 | + part.name = "part", |
| 262 | + alt = "If you are not a registered user, or if you work outside of a course, fork [this]({url}){{target=\"_blank\"}} repository.", |
| 263 | + sub = "See the explanations in the `README.md`", |
| 264 | + course = "Group challenge for the students enrolled at the course", |
| 265 | + toc.def = "Group challenge {name}" |
| 266 | + ) |
| 267 | + if (!missing(title)) texts$title <- title |
| 268 | + if (!missing(part.name)) texts$part.name <- part.name |
| 269 | + if (!missing(alt)) texts$alt <- alt |
| 270 | + if (!missing(sub)) texts$sub <- sub |
| 271 | + if (!missing(course)) texts$course <- course |
| 272 | + if (!missing(toc.def)) texts$toc.def <- toc.def |
| 273 | + |
| 274 | + texts |
| 275 | +} |
| 276 | + |
| 277 | +#' @rdname assignation |
| 278 | +#' @export |
| 279 | +challenge2_fr <- function(title, part.name, alt, sub, course, toc.def) { |
| 280 | + texts <- list( |
| 281 | + title = "Relevez ce challenge par groupe:", |
| 282 | + part.name = "partie", |
| 283 | + alt = "Si vous \u00eates un utilisateur non enregistr\u00e9 ou que vous travaillez en dehors d'un cours, faites un \"fork\" de [ce]({url}){{target=\"_blank\"}} d\u00e9p\u00f4t.", |
| 284 | + sub = "Voyez les explications dans le fichier `README.md`", |
| 285 | + course = "Challenge en groupe pour les \u00e9tudiants inscrits au cours de", |
| 286 | + toc.def = "Challenge en groupe {name}" |
| 287 | + ) |
| 288 | + if (!missing(title)) texts$title <- title |
| 289 | + if (!missing(part.name)) texts$part.name <- part.name |
| 290 | + if (!missing(alt)) texts$alt <- alt |
| 291 | + if (!missing(sub)) texts$sub <- sub |
| 292 | + if (!missing(course)) texts$course <- course |
| 293 | + if (!missing(toc.def)) texts$toc.def <- toc.def |
| 294 | + |
| 295 | + texts |
| 296 | +} |
0 commit comments