Skip to content

Commit

Permalink
Merge pull request #5 from reuning/master
Browse files Browse the repository at this point in the history
Checks to make sure slides exist before converting them over.
  • Loading branch information
lwjohnst86 authored Jun 7, 2019
2 parents 624e7a2 + 93f4ec9 commit 171453e
Showing 1 changed file with 36 additions and 20 deletions.
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

0 comments on commit 171453e

Please sign in to comment.