2

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

JPMD
  • 644
  • 1
  • 7
  • 19

2 Answers2

3

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?

Sinval
  • 1,315
  • 1
  • 16
  • 25
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)
Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Thanks Achim. Yes, random data for 5ge first page... The intro solution works great for Moodle, but for exams2nops I really think it would be worth it to create a ”intro" environment question free. Another solution would be to generate the first intro page using Rmd (save the generate data in a rds file and use that one in the following series of questions), generate the pdf, and then manually insert it on the pdf file generated by nops. But thanks anyway. – JPMD Nov 21 '20 at 13:09
  • But what would be the benefit of all that effort other than getting the first itemized point "1." on the second page after the introductory materials? Am I missing something here? I get that it would be "nice" but I'm not sure that it is really worth the effort that it entails. – Achim Zeileis Nov 22 '20 at 02:27
  • I guess having the description of the overall intro as item 1 would confuse students where to answer to Question 1? No? Note that with my structure, a general data set with the description of the experiment is given in the intro and then the "true" questions start after the intro. The all exam has a set of question for that data set. For example Q1 asks for checking normality of variables, Q2 asks for a paired student t-test, Q3 a Pearson between two variables (in the Intro data set), etc... So, being able to separate the intro from the questions would be easier for the students... – JPMD Dec 01 '20 at 17:46
  • I think if they are informed beforehand about this, there shouldn't be much confusion. You can additionally emphasize this in an `intro` text (see my modified answer above). But my feeling is that the most important clue for the students are bold headings within the first exercise for "General information" and "First question". – Achim Zeileis Dec 02 '20 at 02:52
  • Thanks for the repply!. So this is how we will do it: 1. Generate the Intro page and dataset for the questions and save it as pdf 2. Create the items with exams2nops. Each question rmd will read the rds dataset to make sure that the data used is the correct one 3. Use Rpdftools to insert the intro.pdf into the exams.pdf generated by exams2nops 4. Do 1 to 3, k times to generate k different exams (same questions, but diferent datasets) (no worries we will use a for loop :-)) Anyway, maybe in some future version there could be space for a introduction page just with data. – JPMD Dec 03 '20 at 10:40
  • You don t need pdftools to insert the page. Simply include usepackage = "pdfpages" and use \includepdf{} in the intro = ... – Achim Zeileis Dec 03 '20 at 17:22
  • Oh and additionally: I would encourage you to post your approach as an additional answer to your own question (ideally including some code snippets). And then you can accept your answer so that the question is flagged as resolved here on SO. – Achim Zeileis Dec 03 '20 at 17:24
  • I added the general approach which we used in our solution. – Sinval Dec 07 '20 at 19:13
  • 1
    Dear Achim, did you created a solution for this issue? – Sinval May 24 '21 at 13:17