问题
I would like to use your excellent r-exams package to create a paper and pencil exam with automatic grading. I have used exams2nops in the past for a series of schoice and mchoice questions.
However, I now need to have an exam with an introduction page where I give a table with data and some outputs from statistical software (say normality tests, Levene, etc... I can generate that with Rmd)and tell a small history about the data and the experiments involved in gathering the data.
So My Exam structure would be:
Page 1. Box for student's name and number and Answer sheet
Page 2. Introductory page with dataset and selected figures/outputs for testing assumptions (and no questions)
Page 3. Question 1.1
Page 4. Question 1.2. ... Page k: Question n.
Would this be possible. I guess the novelty is the "intro" page ... after that is just an exams2nops file....
Thanks in advance for any ideas or thoughts...
João
回答1:
Our solution for - let's say - 5 different versions:
Prepare your own intro with randomly generated data (i.e. Intro.Rmd
). Our Intro.Rmd
also saves the generated data frames in a folder named Databases
. Which is then called by each exercise of the correspondent loop (i
).
When rendering rmd files to pdf you must call the right LaTeX packages in your rmd's yaml header. Our case:
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- \usepackage{wrapfig}
- \usepackage{float}
- \usepackage{colortbl}
- \usepackage{pdflscape}
- \usepackage{tabu}
- \usepackage{threeparttable}
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
- \usepackage{xcolor}
Several folders were created:
- one for the generated Intros (i.e.,
Intros
); - one for the exams2nops generated PDFs (i.e.,
nops_pdf
); - one for the spitted files (i.e.,
subsets
); - one for the final merged versions (i.e.,
exams
).
The loop:
for (i in 1:5) {
rmarkdown::render(input = "Intro.Rmd",output_file = paste0("Intros/Intro_v",i,".pdf"))
exams2nops(questions, n = 1, nsamp = 1, intro = "Leia as questões com atenção e MARQUE TODAS AS SUAS RESPOSTAS NA FOLHA DE RESPOSTAS! Este exame tem a duração de 60 minutos. Boa sorte!", language = "pt-PT", institution = "Análise Estatística II", title = "Época Normal: Métodos Tipo I - ",dir = "nops_pdf", name = paste0("Ex_AEII_MTI_v",i,"_"), date = "2020-12-01",encoding = "UTF-8", blank = 0, nchoice = 5, duplex = T, reglength = 7L, points = 4, replacement = T,schoice = list(eval = ee))
pdf_subset(input = paste0("nops_pdf/Ex_AEII_MTI_v",i,"_1.pdf"),pages = c(1,3),
output = paste0("subsets/subset_",i,"_part1.pdf"))
pdf_subset(input = paste0("nops_pdf/Ex_AEII_MTI_v",i,"_1.pdf"),pages = c(5:pdf_length(paste0("nops_pdf/Ex_AEII_MTI_v",i,"_1.pdf"))),
output = paste0("subsets/subset_",i,"_part2.pdf"))
pdf_combine(input = c(paste0("subsets/subset_",i,"_part1.pdf"),
paste0("Intros/Intro_v",i,".pdf"),
paste0("subsets/subset_",i,"_part2.pdf")),
output = paste0("exams/exams_v",i,".pdf"))
}
Achim, you say that the pdf generated by the Intro.Rmd
can be merged using exams2nops
, can you exemplify how?
回答2:
How to implement this depends on whether the introductory page is the same for all participants or whether it should contain different data/graphics/information for every exam.
Same information for everyone
You can use exams2pdf(..., intro = ...)
.
intro
: character. Either a single string with the path to a .tex file or a vector with with LaTeX code for optional introduction text on the first page of the exam.
Note that if this LaTeX code includes graphics (or other files) these need to be included with the full path because the LaTeX code is compiled in a different (temporary) directory.
Randomized information
If different data/graphics/information should be randomly generated for every exam, then the best way to implement this is to put it into the first question. You can emphasize the different roles of the materials by structuring the content of the "Question" environment in the first exercise, say:
- Starting with "General information" in bold.
- Then data/graphics/information.
- Then including "First question" in bold and/or a pagebreak, e.g., via
\newpage
. - Then the actual first question.
If you do so, then the main deviation from your ideal structure is that the first itemized point "1." is at the beginning of the general information and not the actual first question. But I don't think it would be worth going through setting up a completely new type of "random intro text" for exams2nops()
.
If you want to emphasize this to the participants so that no one overlooks the first question, you can couple it with a general intro
such as:
intro <- paste(c(
"\\textbf{\\large Important information}",
"",
"Please note that the first question a data set is introduced that is also used in subsequent questions. The actual first question is included below the general introducation.",
"\\newpage"),
collapse = "\n")
exams2nops(..., intro = intro)
来源:https://stackoverflow.com/questions/64930431/introduction-page-for-exams2nops-r-exams