diff --git a/source/data/specific.csv b/source/data/specific.csv deleted file mode 100644 index d036c18..0000000 --- a/source/data/specific.csv +++ /dev/null @@ -1,11 +0,0 @@ -"x" -7 -6 -2 -5 -3 -6 -2 -2 -4 -6 diff --git a/source/prefixe_template_specific.Rnw b/source/prefixe_template_specific.Rnw index e87a654..ab8626d 100644 --- a/source/prefixe_template_specific.Rnw +++ b/source/prefixe_template_specific.Rnw @@ -1,156 +1,159 @@ % ############################################### % # parameters # % ############################################### <<>>= prefixe <- "prefixe" name <- "template" specific <- "specific" section <- paste0(prefixe, "/", name) scriptname <- paste0(prefixe, "_", name, "_", specific, ".R") currentfile <- paste0(scriptname, "nw") dataset.name <- paste0(specific, ".csv") # precision nbdecimal <- 3 precision <- 10^(-nbdecimal) @ % ############################################### % # files availability # % ############################################### <<copyfiles>>= # include_supplement(file = scriptname, recursive = TRUE) # this file is copied in the current tempory folder # and hence is available further include_supplement(file = "cc-by-sa.png", recursive = TRUE) include_supplement(file = "givendata.csv", recursive = TRUE) @ % ############################################### % # sourcing process # % ############################################### <<mysource>>= source(paste0(script.path, scriptname)) @ % ############################################### % # optional: libraries loading # % ############################################### <<>>= # install package if needed if(!require("ggplot2")) install.packages("ggplot2") # package loading library(ggplot2) @ % ############################################### % # Data # % ############################################### <<exercise data>>= # initilialize a solution vector question <- list() response <- list() sol <- c() type <- c() point <- c() +tol <- c() question[[1]] <- paste("option",1:5) solution <- mchoice2string(c(rep(F,4),T)) sol <- c(sol, solution) response[[1]] <- question[[1]][string2mchoice(solution)] type <- c(type,"schoice") point <- c(point, 1L) +tol <- c(tol, 0) question[[2]] <- paste("option",1:5) solution <- mchoice2string(c(T,F,T,F,T)) sol <- c(sol, solution) response[[2]] <- question[[2]][string2mchoice(solution)] type <- c(type, "mchoice") point <- c(point, sum(string2mchoice(solution))) +tol <- c(tol, 0) question[[3]] <- "" solution <- round(mean(x), nbdecimal) sol <- c(sol, solution) response[[3]] <- solution type <- c(type, "num") point <- c(point, 3L) +tol <- c(tol, precision) question[[4]] <- dat[2, selectedindex] solution <- dat[1, selectedindex] sol <- c(sol, solution) response[[4]] <- solution type <- c(type, "string") point <- c(point, 1L) - -tol <- ifelse(type == "num", precision, 0) +tol <- c(tol, 0) # data export to a local folder write.csv(df, file = paste0(data.path,dataset.name), row.names = FALSE) # data export to temporary folder so that it is available in the question section write.csv(df, file = dataset.name, row.names = FALSE) @ % ############################################### % # statement # % ############################################### \begin{question} Text of the statement.\\ Question file \url{\Sexpr{dataset.name}}.\\ Use a precision of \Sexpr{precision}. \begin{enumerate} \item (\Sexpr{point[1]} pt) First question: a simple choice. ##ANSWER1## \item (\Sexpr{point[2]} pt) Second question: multiple choice. ##ANSWER2## \item (\Sexpr{point[3]} pt) Third question: a numerical value. ##ANSWER3## \item (\Sexpr{point[4]} pt) Fourth question: a character string. ##ANSWER4## \end{enumerate} <<proposition, echo = FALSE, results = tex>>= answerlist(unlist(question)) @ \end{question} % ############################################### % # solution # % ############################################### \begin{solution} Les réponses sont : <<>>= response @ Graphics <<fig=TRUE, echo=FALSE>>= ggplot(data=df, aes(x)) + geom_bar() @ Other information <<>>= summary(x) @ Data read locally <<>>= localdata @ { \vspace{5mm} \tiny\it \begin{tabular}{ll} author & \href{https://people.hes-so.ch/fr/profile/211212093-sacha-varone}{Sacha Varone}, HES-SO\\ licence & \includegraphics{cc-by-sa.png} \end{tabular} \end{solution} %% ---------- meta-data --------- % %% \extype{cloze} %% \exsolution{\Sexpr{paste(sol, collapse = "|")}} %% \exclozetype{\Sexpr{paste(type, collapse = "|")}} %% \exsection{\Sexpr{section}} %% \exname{\Sexpr{name}} %% \extol{\Sexpr{paste(tol, collapse = "|")}} %% \expoints{\Sexpr{noquote(paste(point, collapse = "|"))}} %% \exversion{v0}