Compiling Book Exercises to pdf | html | Moodle | Blackboard

The revised second edition of Analyzing Financial and Economic Data with R presents more than 100 exercises at the end section of all chapters. All exercises are freely available in the exams format, meaning that any R tutor can export the same exercises to pdf, html or e-learning platforms. In this post I’ll show how to compile exercises to pdf, html, Moodle and blackboard.

Installation

The first step is to install package afedR with devtools:

devtools::install_github('msperlin/afedR')

Another requirement is a working Latex instalation. For that, use tinytex:

tinytex::install_tinytex()

Compiling Exercises

How it works?

All book exercises in the exams format: each exercise is a .Rmd file containing code, exercise text and solution. The files themselves can be found in the installation directory of the package:

eoc_dir <- afedR::get_EOC_dir()

eoc_chapters <- fs::dir_ls(eoc_dir)
basename(eoc_chapters)
##  [1] "Chapter01-Introduction"             "Chapter02-Basic-Operations"        
##  [3] "Chapter03-Research-Scripts"         "Chapter04-Import-Local"            
##  [5] "Chapter05-Import-Internet"          "Chapter06-Dataframes-and-Others"   
##  [7] "Chapter07-Basic-Classes"            "Chapter08-Programming"             
##  [9] "Chapter09-Cleaning-and-Structuring" "Chapter10-Figures"                 
## [11] "Chapter11-FinEcon"                  "Chapter12-Reporting"               
## [13] "Chapter13-Optimizing-Code"

Each folder will have several exercises. Let’s try one out:

eoc_files <- fs::dir_ls(eoc_chapters[1])
basename(eoc_files)
##  [1] "afedR_Chap-01_01_SPLUS.Rmd"            
##  [2] "afedR_Chap-01_02_Authors-R.Rmd"        
##  [3] "afedR_Chap-01_03_About-R.Rmd"          
##  [4] "afedR_Chap-01_04_name-R.Rmd"           
##  [5] "afedR_Chap-01_05_about-R.Rmd"          
##  [6] "afedR_Chap-01_06_Tecnology-R.Rmd"      
##  [7] "afedR_Chap-01_07_rtools.Rmd"           
##  [8] "afedR_Chap-01_08_Groups.Rmd"           
##  [9] "afedR_Chap-01_09_RBloggers.Rmd"        
## [10] "afedR_Chap-01_10_Infrastructure-TI.Rmd"

We can also read one of the files to show the strucuture of the exercise in code and text:

readLines(eoc_files[1])
##  [1] "```{r datageneration, echo = FALSE, results = \"hide\"}"                                                                                                                                
##  [2] "my_answers <- c('S', "                                                                                                                                                                  
##  [3] "                'C++',"                                                                                                                                                                 
##  [4] "                'Python',"                                                                                                                                                              
##  [5] "                'Julia',"                                                                                                                                                               
##  [6] "                'Javascript')"                                                                                                                                                          
##  [7] ""                                                                                                                                                                                       
##  [8] "#check_answers(my_answers)"                                                                                                                                                             
##  [9] "```"                                                                                                                                                                                    
## [10] ""                                                                                                                                                                                       
## [11] "Question"                                                                                                                                                                               
## [12] "========"                                                                                                                                                                               
## [13] ""                                                                                                                                                                                       
## [14] "The R language was developed based on what other programming language?"                                                                                                                 
## [15] ""                                                                                                                                                                                       
## [16] "```{r questionlist, echo = FALSE, results = \"asis\"}"                                                                                                                                  
## [17] "exams::answerlist(my_answers, markup = \"markdown\")"                                                                                                                                   
## [18] "```"                                                                                                                                                                                    
## [19] ""                                                                                                                                                                                       
## [20] "Solution"                                                                                                                                                                               
## [21] "================"                                                                                                                                                                       
## [22] ""                                                                                                                                                                                       
## [23] "Straight from the book, section **What is R**: \"R is a modern version of S, a programming language originally created in Bell Laboratories (formerly AT&T, now Lucent Technologies).\""
## [24] ""                                                                                                                                                                                       
## [25] "Meta-information"                                                                                                                                                                       
## [26] "================"                                                                                                                                                                       
## [27] "extype: schoice"                                                                                                                                                                        
## [28] "exsolution: `r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE)`"                                                                                                     
## [29] "exname: \"S PLUS\""                                                                                                                                                                     
## [30] "exshuffle: TRUE"                                                                                                                                                                        
## [31] ""

Basically, we define all sections of a question – text, solution, alternatives – using a .Rmd template. Again, you can find more details about using package exams in its own website.

Be aware that, all exams .rmd files available within afedR are self contained and you can export and compile them directly from exams. An easy way to copy all exercise files to your local folder is using function afedR::path_to_copy:

# copy to "documents" folder
afedR::copy_book_files(path_to_copy = '~')
## Copying data files files to ~/afedR files/data
## 	37 files copied
## Copying end-of-chapter (eoc) exercises with solutions to ~/afedR files/eoc-exercises/
## 	99 files copied
## Copying R code to ~/afedR files/R-code
## 	15 files copied

All book files – data, code and exercises – are now available at your “Documents” folder (shorcut of ~).

Compiling to pdf

For pdf compilation, you’ll need:

  • name of students (will be printed in pdf)
  • students ids (I usually use their university card number)
  • Chapters to include
  • Exercise name
  • Course name

And use the following code

library(afedR)

names_students <- c('Michael Peterling', 'John Aspper', 'Mr. Beans')
ids_students <- 1:length(names_students) # probably id card?
chapters <- 1:3 # chapters from 1 to 13
dir_output <- file.path(tempdir(), 'pdf-example')


df_exams <- compile_pdf_exercises(students_names = names_students, 
                                  students_ids = ids_students, 
                                  chapters_to_include = chapters,
                                  dir_out = dir_output)

The output of compile_pdf_exercises is a table with the correct answers for schoice and num type of questions:

glimpse(df_exams)
## Rows: 69
## Columns: 4
## $ i_name   <chr> "Michael Peterling", "Michael Peterling", "Michael Peterling"…
## $ i_ver    <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ i_q      <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18…
## $ solution <chr> "b", "e", "e", "c", "a", NA, "c", NA, NA, NA, NA, NA, NA, NA,…

After compilation, all pdf files are available at folder dir_output:

fs::dir_ls(dir_output)
## /tmp/RtmpANdrK1/pdf-example/Sample Exercise_Ver 01_Michael Peterling.pdf
## /tmp/RtmpANdrK1/pdf-example/Sample Exercise_Ver 02_John Aspper.pdf
## /tmp/RtmpANdrK1/pdf-example/Sample Exercise_Ver 03_Mr. Beans.pdf

The final result will be as follows:

Compiling to html

You can also compile to a html file using afedR::compile_html_exercises:

library(afedR)

names_students <- c('Michael Peterling', 'John Aspper', 'Mr. Beans')
ids_students <- 1:length(names_students) # probably id card?
chapters <- 1:3 # chapters from 1 to 13
dir_output <- file.path(tempdir(), 'html-example')

df_exams <- compile_html_exercises(students_names = names_students, 
                                   students_ids = ids_students, 
                                   chapters_to_include = chapters,
                                   dir_out = dir_output)
## Exams generation initialized.
## 
## Output directory: /tmp/RtmpANdrK1/exams files file6c348a93b03
## Exercise directory: /home/msperlin/GitRepo/03-sites/msperlin-blog/content/post
## Supplement directory: /tmp/RtmpANdrK1/file6c345c25c3b7
## Temporary directory: /tmp/RtmpANdrK1/file6c342a56b7e1
## Exercises: /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_01_SPLUS, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_02_Authors-R, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_03_About-R, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_04_name-R, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_05_about-R, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_06_Tecnology-R, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_07_rtools, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_08_Groups, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_09_RBloggers, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter01-Introduction/afedR_Chap-01_10_Infrastructure-TI, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_01_Basic, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_02_Basic, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_03_getwd, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_04_download, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_05_unzip, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_06_installpkgs, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_07_filespkgs, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_08_installpkgs2, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_09_installpkgs3-cranlogs, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_10_devtools, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter02-Basic-Operations/afedR_Chap-02_11_files-in-computer, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter03-Research-Scripts/afedR_Chap-03_01_pesquisa, /home/msperlin/R/x86_64-pc-linux-gnu-library/4.2/afedR/extdata/exams_files/02-EOCE-Rmd/Chapter03-Research-Scripts/afedR_Chap-03_02_folders
## 
## Generation of individual exams.
## Exam 1: _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_01_SPLUS (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_02_Authors-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_03_About-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_04_name-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_05_about-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_06_Tecnology-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_07_rtools (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_08_Groups (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_09_RBloggers (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_10_Infrastructure-TI (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_01_Basic (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_02_Basic (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_03_getwd (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_04_download (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_05_unzip (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_06_installpkgs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_07_filespkgs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_08_installpkgs2 (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_09_installpkgs3-cranlogs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_10_devtools (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_11_files-in-computer (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter03-Research-Scripts_afedR_Chap-03_01_pesquisa (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter03-Research-Scripts_afedR_Chap-03_02_folders (srt) ... w ... done.
## Exam 2: _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_01_SPLUS (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_02_Authors-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_03_About-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_04_name-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_05_about-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_06_Tecnology-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_07_rtools (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_08_Groups (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_09_RBloggers (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_10_Infrastructure-TI (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_01_Basic (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_02_Basic (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_03_getwd (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_04_download (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_05_unzip (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_06_installpkgs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_07_filespkgs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_08_installpkgs2 (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_09_installpkgs3-cranlogs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_10_devtools (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_11_files-in-computer (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter03-Research-Scripts_afedR_Chap-03_01_pesquisa (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter03-Research-Scripts_afedR_Chap-03_02_folders (srt) ... w ... done.
## Exam 3: _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_01_SPLUS (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_02_Authors-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_03_About-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_04_name-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_05_about-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_06_Tecnology-R (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_07_rtools (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_08_Groups (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_09_RBloggers (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter01-Introduction_afedR_Chap-01_10_Infrastructure-TI (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_01_Basic (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_02_Basic (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_03_getwd (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_04_download (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_05_unzip (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_06_installpkgs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_07_filespkgs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_08_installpkgs2 (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_09_installpkgs3-cranlogs (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_10_devtools (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter02-Basic-Operations_afedR_Chap-02_11_files-in-computer (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter03-Research-Scripts_afedR_Chap-03_01_pesquisa (srt) _home_msperlin_R_x86_64-pc-linux-gnu-library_4.2_afedR_extdata_exams_files_02-EOCE-Rmd_Chapter03-Research-Scripts_afedR_Chap-03_02_folders (srt) ... w ... done.

An example of full compiled html file is available here.

Exporting to Moodle

You can also export to e-learning platforms such as Moodle. The process is quite simple as exams package does the heavy work:

require(afedR)
my_eoc_dir <- afedR::get_EOC_dir()

available_chapters <- fs::dir_ls(my_eoc_dir)
exercise_files <- fs::dir_ls(available_chapters[1])
dir_output <- file.path(tempdir(), 'moodle-test')

exams::exams2moodle(file = exercise_files, 
                    name = 'TestingMoodle', 
                    dir = dir_output)

fs::dir_ls(dir_output)
## /tmp/RtmpANdrK1/moodle-test/TestingMoodle.xml

You can later import this .xml file in your Moodle class.

Exporting to Blackboard

require(afedR)
my_eoc_dir <- afedR::get_EOC_dir()

available_chapters <- fs::dir_ls(my_eoc_dir)
exercise_files <- fs::dir_ls(available_chapters[1])
dir_output <- file.path(tempdir(), 'blackboard-test')

exams::exams2blackboard(file = exercise_files, 
                        name = 'TestingBlackBoard', 
                        dir = dir_output)

fs::dir_ls(dir_output)
## /tmp/RtmpANdrK1/blackboard-test/TestingBlackBoard.zip

This .zip file contains all exercises of chapter 01 and can be imported in your blackboard account.

Marcelo S. Perlin
Marcelo S. Perlin
Associate Professor

My research interests include data analysis, finance and cientometrics.

comments powered by Disqus