##############################################################################
# Packages
library(exams)
library(manacc)
library(writR)
library(lubridate)
library(tibble)
library(dplyr)


##############################################################################
# Initialization
question_id <- "EN00000001"
wdir <- getwd()
parameters <- teachR::param_quest(wdir, question_id, "mcq", altlevel = "1 Remember")
for (i in 1:length(parameters)) assign(names(parameters)[[i]], parameters[[i]])
options(xtable.comment = FALSE, xtable.floating = FALSE, xtable.timestamp = "")
set.seed(seed)


##############################################################################
# Data
true_statement <- manacc::ma_truefalse %>%
  dplyr::filter(subsection == "0212 Cost behavior", value == TRUE) %>%
  dplyr::sample_n(1)

false_statements<- manacc::ma_truefalse %>%
  dplyr::filter(subsection == "0212 Cost behavior", value == FALSE, explanation != true_statement$explanation) %>%
  dplyr::group_by(explanation) %>%
  dplyr::sample_n(1) %>%
  dplyr::ungroup() %>%

  dplyr::sample_n(4)


##############################################################################
# Answers

#if (reqexpl != "" & exasolu == "exam") nbrlines <- selection$lines[[1]] else nbrlines <- 2
#lines <- rep("\\ ", nbrlines)
lines <- rep("\\ ", 2)

questions <- c(
  right1 = true_statement$statement[[1]],
  wrong1 = false_statements$statement[[1]],
  wrong2 = false_statements$statement[[2]],
  wrong3 = false_statements$statement[[3]],
  wrong4 = false_statements$statement[[4]]
)

solutions <- c(TRUE,FALSE,FALSE,FALSE,FALSE)

explanations <- c(
  true_statement$explanation[[1]],
  false_statements$explanation[[1]],
  false_statements$explanation[[2]],
  false_statements$explanation[[3]],
  false_statements$explanation[[4]]
)


##############################################################################
# Randomize order (do not edit)
alea <- sample(c(1, sample(2:length(questions), (alternatives-1))), alternatives)
questions <- questions[alea]
solutions <- solutions[alea]
explanations <- explanations[alea]

Question

r txt_question_id Which of the following statements is true? r reqexpl r points

if (reqexpl == "") exams::answerlist(questions, markup = "markdown") else
  writeLines(lines)

Solution

if (reqexpl == "") exams::answerlist(ifelse(solutions, "True", "False"), explanations, markup = "markdown") else
  writeLines(c("\\ ","\\ "))

Meta-information

extype: r extype exsolution: r exams::mchoice2string(solutions, single = TRUE) exname: r question_id



NicolasJBM/manacc documentation built on Jan. 16, 2020, 1:42 p.m.