Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks to make sure slides exist before converting them over. #5

Merged
merged 1 commit into from
Jun 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions R/convert-from-datacamp.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,42 @@ datacamp_to_learnr_pkg <-

# Copy over other files
copy_datasets_dir_to_lrnr(dc_path, lrnr_pkg_path)
copy_slides_dir_to_lrnr(dc_path, lrnr_pkg_path)
new_slide_files <-
fs::path_abs(lrnr_pkg_path) %>%
fs::path("inst", "tutorials", "slides") %>%
fs::dir_ls(glob = "*.Rmd")

# Convert chapter files to learnr tutorials
converted_chapter_files <-
purrr::map(chapter_files,
~ dc_chapter_to_lrnr_tutorial(.x, new_slide_files))
new_tutorial_path <-
fs::dir_ls(lrnr_pkg_path, regexp = "chapter[1-9]", recurse = TRUE)
purrr::walk2(converted_chapter_files,
new_tutorial_path,
~ readr::write_lines(.x, .y))

new_slide_files %>%
purrr::map(dc_slides_to_text_doc) %>%
purrr::walk2(new_slide_files,
~readr::write_lines(.x, .y))
if(fs::dir_exists(fs::path(dc_path, "slides"))){
copy_slides_dir_to_lrnr(dc_path, lrnr_pkg_path)
new_slide_files <-
fs::path_abs(lrnr_pkg_path) %>%
fs::path("inst", "tutorials", "slides") %>%
fs::dir_ls(glob = "*.Rmd")

# Convert chapter files to learnr tutorials
converted_chapter_files <-
purrr::map(chapter_files,
~ dc_chapter_to_lrnr_tutorial(.x, new_slide_files))
new_tutorial_path <-
fs::dir_ls(lrnr_pkg_path, regexp = "chapter[1-9]", recurse = TRUE)
purrr::walk2(converted_chapter_files,
new_tutorial_path,
~ readr::write_lines(.x, .y))

new_slide_files %>%
purrr::map(dc_slides_to_text_doc) %>%
purrr::walk2(new_slide_files,
~readr::write_lines(.x, .y))

} else {
# Convert chapter files to learnr tutorials
converted_chapter_files <-
purrr::map(chapter_files,
~ dc_chapter_to_lrnr_tutorial(.x))
new_tutorial_path <-
fs::dir_ls(lrnr_pkg_path, regexp = "chapter[1-9]", recurse = TRUE)
purrr::walk2(converted_chapter_files,
new_tutorial_path,
~ readr::write_lines(.x, .y))

}



}

Expand Down