diff --git a/manuscript/Book.txt b/manuscript/Book.txt index 6576cbb6..c0552c97 100644 --- a/manuscript/Book.txt +++ b/manuscript/Book.txt @@ -1,5 +1,6 @@ 1-Introduction.md +quiz_ch1.md 2-A-new-chapter.md 3-References.md -About-this-Course.md About-the-Authors.md +About-this-Course.md diff --git a/quiz_jsons/quiz_ch1.json b/quiz_jsons/quiz_ch1.json new file mode 100644 index 00000000..1211c9a5 --- /dev/null +++ b/quiz_jsons/quiz_ch1.json @@ -0,0 +1 @@ +{"question_info_df":[{"question":"First question to ask goes here. (Note- you need a question mark at end like this. Just one is required if using a question mark in your question field)?","question_type":"multiple_choice","shuffle_opt":true,"correct_answer":1,"_row":"First question to ask goes here. (Note- you need a question mark at end like this. Just one is required if using a question mark in your question field)?"},{"question":"Question example with just a question mark?","question_type":"multiple_choice","shuffle_opt":true,"correct_answer":1,"_row":"Question example with just a question mark?"},{"question":"Second question to ask goes here?","question_type":"multiple_choice","shuffle_opt":true,"correct_answer":1,"_row":"Second question to ask goes here?"},{"question":"A more complicated example. Note the question mark at the end of the options! Which of the following are correct","question_type":"multiple_choice","shuffle_opt":true,"correct_answer":1,"_row":"A more complicated example. Note the question mark at the end of the options! Which of the following are correct"},{"question":"A question in which the order of choices is important?","question_type":"multiple_choice","shuffle_opt":false,"correct_answer":4,"_row":"A question in which the order of choices is important?"}],"choice_vectors":[["One correct answer here marked with a \"C\"","Mandatory incorrect answers have an \"m\"","A second mandatory incorrect answer","An optional incorrect answer here marked with an \"o\"","A second optional incorrect answer here"],["One correct answer here marked with a \"C\"","Mandatory incorrect answers have an \"m\"","A second mandatory incorrect answer","An optional incorrect answer here marked with an \"o\"","A second optional incorrect answer here"],["A correct answer here!","Mandatory incorrect answers have an \"m\"","A second mandatory incorrect answer","An optional incorrect answer here marked with an \"o\"","A second optional incorrect answer here"],["All of the examples listed except 5","1, 3, and 5","1, 2, and 3","All of the examples except 1 and 5","All of the examples listed"],["The possible responses should be labeled a, b, c, etc","The correct answer has a capital letter, in this case \"D\" is correct","both a and b","All of the above will always be last choice in this question"]]} diff --git a/resources/course_units.tsv b/resources/course_units.tsv new file mode 100644 index 00000000..8fa606f3 --- /dev/null +++ b/resources/course_units.tsv @@ -0,0 +1,7 @@ +md_name type url chapt_title full_urls +1-Introduction.md chapter introduction.html 1 Introduction https://jhudatascience.org/OTTR_Template/introduction.html +quiz_ch1.md quiz NA NA NA +2-A-new-chapter.md chapter a-new-chapter.html 2 A new chapter https://jhudatascience.org/OTTR_Template/a-new-chapter.html +3-References.md chapter references.html 3 References https://jhudatascience.org/OTTR_Template/references.html +About-the-Authors.md chapter about-the-authors.html About the Authors https://jhudatascience.org/OTTR_Template/about-the-authors.html +About-this-Course.md chapter index.html About this Course https://jhudatascience.org/OTTR_Template/index.html diff --git a/scripts/make_material_df.R b/scripts/make_material_df.R index bc922f8f..f5bd0db2 100644 --- a/scripts/make_material_df.R +++ b/scripts/make_material_df.R @@ -21,6 +21,18 @@ library(optparse) library(magrittr) option_list <- list( + optparse::make_option( + c("--owner_id"), + type = "character", + default = NULL, + help = "Owner id", + ), + optparse::make_option( + c("--course_name"), + type = "character", + default = NULL, + help = "Course name for this", + ), optparse::make_option( c("--repo"), type = "character", @@ -44,6 +56,11 @@ option_list <- list( type = "character", default = NULL, help = "Output directory where the chapter's screen images should be stored", + ), + optparse::make_option( + c("--make_book_txt"), + action = "store_true", + help = "Should book.txt file be made freshly?", ) ) @@ -72,65 +89,33 @@ retrieve_chapters <- ottrpal::get_chapters(base_url) ## Get chapter list and urls chapter_df <- data.frame( retrieve_chapters, - full_urls = paste0(base_url, retrieve_chapters$url) + full_urls = paste0(base_url, retrieve_chapters$url), + md_name = paste0(gsub(" ", "-", retrieve_chapters$chapt_title), ".md") ) ##### Get Quizzes -quiz_dir <- file.path(root_dir, "quizzes") +quiz_files <- list.files(file.path(root_dir, "quizzes"), pattern = ".md") -## Autogenerate Book.txt file -ottrpal::bookdown_to_book_txt(quiz_dir) +if (opt$make_book_txt) { + # Make book.txt fresh + ottrpal::bookdown_to_book_txt(md_files = list.files(file.path(root_dir, "manuscript"), pattern = ".md")) +} ## Read in Book.txt book_txt <- readLines(file.path(root_dir, "manuscript", "Book.txt")) ## Make a data frame from this -book_txt_df <- data.frame(file_names = book_txt) %>% +book_txt_df <- data.frame(md_name = book_txt) %>% dplyr::mutate(type = dplyr::case_when( - grepl("quiz", file_names) ~ "quiz", + grepl("quiz", md_name) ~ "quiz", TRUE ~ "chapter")) # Join it to the chapter df book_txt_df <- book_txt_df %>% - dplyr::inner_join(book_txt_df, - by = "chapt_title") - -# We need to make this column so we can link swirl modules to their chapters -chapter_df <- chapter_df %>% - dplyr::mutate(core_file_name = gsub("_quiz.md$", "", chapter_df $quiz_file)) - -#### Link swirl modules to chapters -swirl_modules <- googlesheets4::read_sheet( - "https://docs.google.com/spreadsheets/d/1b60iMYr6gtJ0X0ifcXlR4u3TSe1JaUW3uIUN9SOl14E/edit#gid=0", - sheet = "Swirl_Key") %>% - dplyr::filter(!is.na(module_name)) %>% - dplyr::select(-rowname) - -chapter_df <- chapter_df %>% - dplyr::left_join(swirl_modules, - by = c("core_file_name" = "associated_chapter")) - -### Signify which chapters are projects -chapter_df <- chapter_df %>% - dplyr::mutate(type = dplyr::case_when( - grepl("Project$", chapter_df$chapt_title) ~ "Project", - grepl(paste0(topics, collapse = "$|"), chapter_df$chapt_title) ~ "New topic", - TRUE ~ "Chapter")) - -chapter_df <- chapter_df %>% - ### Establish unit times - dplyr::mutate(unit_time = dplyr::case_when(type == "Chapter" ~ 1, - type == "Project" ~ 5, - TRUE ~ 0)) %>% - dplyr::mutate(swirl_yn = !is.na(module_name), - quiz_yn = !is.na(quiz_file), - unit_time = unit_time + swirl_yn + quiz_yn) - -googlesheets4::write_sheet( - chapter_df, - "https://docs.google.com/spreadsheets/d/14PRS2qEed3E636QsorJFkgN94ikj3SeF1AgpoC-0bo0/edit#gid=0", - sheet = "chapter_df" - ) + dplyr::left_join(chapter_df, + by = "md_name") + +## Write this file. +### You may want to add due dates to this file manually. +readr::write_tsv(book_txt_df, file.path("resources", "course_units.tsv")) -# Write this to a TSV -readr::write_tsv(chapter_df, file.path(root_dir, "materials_order.tsv")) diff --git a/scripts/port_quizzes_to_google.R b/scripts/port_to_google_classroom.R similarity index 100% rename from scripts/port_quizzes_to_google.R rename to scripts/port_to_google_classroom.R