diff --git a/DESCRIPTION b/DESCRIPTION index 7a3c389..67d7dfc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: exams2sakai Title: Automatic Generation of Exams in R for 'Sakai' -Version: 0.1 +Version: 0.2 Authors@R: c( person(given = "Fuensanta", family = "Arnaldos GarcĂ­a", diff --git a/NEWS.md b/NEWS.md index ae707ba..2517711 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# exams2sakai 0.2 + +* Adding tolerance for Numeric Response Questions. + +* Set converter = "pandoc-mathjax" by default option. + +* Fixing bug 'owd not found' when zip=FALSE. + # exams2sakai 0.1 * First CRAN release version. diff --git a/R/exams2sakai.R b/R/exams2sakai.R index 9057ab6..d742d76 100644 --- a/R/exams2sakai.R +++ b/R/exams2sakai.R @@ -10,12 +10,8 @@ exams2sakai <- function(file, n = 1L, nsamp = NULL, dir = ".", sdescription = "Please answer the following question.", maxattempts = 1, cutvalue = 0, solutionswitch = TRUE, zip = TRUE, points = NULL, eval = list(partial = TRUE, negative = FALSE), - converter = NULL, xmlcollapse = FALSE, ...) + converter = "pandoc-mathjax", xmlcollapse = FALSE, ...) { - ## default converter is "ttm" if all exercises are Rnw, otherwise "pandoc" - if(is.null(converter)) { - converter <- if(any(tolower(tools::file_ext(unlist(file))) == "rmd")) "pandoc" else "ttm" - } ## set up .html transformer htmltransform <- make_exercise_transform_html(converter = converter, ...) @@ -337,12 +333,11 @@ exams2sakai <- function(file, n = 1L, nsamp = NULL, dir = ".", on.exit(setwd(owd), add = TRUE) setwd(test_dir) utils::zip(zipfile = zipname <- paste(name, "zip", sep = "."), files = list.files(test_dir)) + if(dir == ".") { + dir = owd + } } else zipname <- list.files(test_dir) - if(dir == ".") { - dir = owd - } - ## copy the final .zip file file.copy(file.path(test_dir, zipname), dir, recursive = TRUE) @@ -606,29 +601,46 @@ make_itembody_sakai <- function(rtiming = FALSE, shuffle = FALSE, rshuffle = shu if(fix_num) { correct_num[[i]] <- c(correct_num[[i]], paste('', sep = "") ) } - wrong_num[[i]] <- paste( - paste(c('\n', paste('\n', sep = "")), collapse = '\n', sep = ''), - '\n', - paste('\n', sep = ""), - paste('\n', sep = ""), - '', - '\n', - collapse = '\n', sep = '' - ) + if (tol[[i]] == 0) { + wrong_num[[i]] <- paste( + paste(c('\n', paste('\n', sep = "")), collapse = '\n', sep = ''), + '\n', + paste('\n', sep = ""), + paste('\n', sep = ""), + '', + '\n', + collapse = '\n', sep = '' + ) + } + else { + wrong_num[[i]] <- paste( + paste(c('\n', paste('\n', sep = "")), collapse = '\n', sep = ''), + '\n', + paste('\n', sep = ""), + paste('\n', sep = ""), + '', + '\n', + collapse = '\n', sep = '' + ) + } } ) } diff --git a/README.md b/README.md index 876b305..d8c70f0 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ library( exams2sakai ) myexam <- list( "boxplots", "regression", "scatterplot", "relfreq" ) -ex1 <- exams2sakai( myexam, n = 1, converter="pandoc-mathjax", +ex1 <- exams2sakai( myexam, n = 1, verbose = TRUE, dir = ".", points = c( 1 ) ) @@ -74,6 +74,7 @@ extype: mchoice extype: num # Only working with one solution exsingle: TRUE # mcss exsingle: FALSE # mca +extol: 0.1 # Tolerance for Numeric Response questions exsolution: 0100001 exshuffle: 5 exextra[randomize]: TRUE # Randomize answers diff --git a/man/exams2sakai.Rd b/man/exams2sakai.Rd index 16900a7..0cc2077 100644 --- a/man/exams2sakai.Rd +++ b/man/exams2sakai.Rd @@ -22,7 +22,7 @@ maxattempts = 1, cutvalue = 0, solutionswitch = TRUE, zip = TRUE, points = NULL, eval = list(partial = TRUE, negative = FALSE), - converter = NULL, xmlcollapse = FALSE, \dots) + converter = "pandoc-mathjax", xmlcollapse = FALSE, \dots) make_itembody_sakai(rtiming = FALSE, shuffle = FALSE, rshuffle = shuffle, minnumber = NULL, maxnumber = NULL, @@ -111,8 +111,7 @@ correct solutions for numeric exercises/answers as well as to obtain results when archiving tests. Note that this is a workaround, which works e.g. within OLAT.} \item{converter}{character. Argument passed on to \code{make_exercise_transform_html}. - The default for \code{converter} is set to \code{"ttm"} unless there are Rmd - exercises in \code{file} where \code{"pandoc"} is used.} + The default for \code{converter} is set to \code{"pandoc-mathjax"}} \item{xmlcollapse}{logical or character. Should line breaks be collapsed in the XML code. If \code{TRUE} everything is collapsed with spaces (\code{" "}) but other collapse characters could be supplied.} @@ -231,7 +230,7 @@ myexam <- list( "boxplots", "regression", "scatterplot", "relfreq" ) dir.create(mydir <- tempfile()) ## generate Sakai quiz in temporary directory -exams2sakai( myexam, n = 1, converter="pandoc-mathjax", +exams2sakai( myexam, n = 1, verbose = TRUE, dir = "mydir", points = c( 1 ) )