SCM

Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: Combining 2 pdfs with exam2nops [ Reply ]
By: Achim Zeileis on 2023-02-21 03:27
[forum:49611]
1) The ID needs to be specified through a suitable R function. The demo-pdf.R has a worked example for this at the end.

2) & 3) Whatever you want to modify in the layout, formatting, etc. is not specified through the R function (as you did in exams2nops) but should be modified in the templates/exams.tex directly.

So you can put the \includepdf exactly in the document where you want it and can put as many \newpage at the end as you need. Or you can include arbitrary other LaTeX code in exactly those places where you need it.

And as I said before: Feel free to keep asking!

RE: Combining 2 pdfs with exam2nops [ Reply ]
By: John Wilson on 2023-02-21 01:49
[forum:49610]
Sorry, I had a typo in the first paragraph of my last post:

I've confirmed I can make edits to it and use **exams2pdf** to create exams with the 4 questions.

RE: Combining 2 pdfs with exam2nops [ Reply ]
By: John Wilson on 2023-02-21 01:47
[forum:49609]
Thank you for the additional information, Achim! With your suggestion, I've been able to create the exam.tex file to get the base code. I've confirmed I can make edits to it and use exams2nops to create exams with the 4 questions.

The couple questions I have left are some minor ones (I hope):

1) How do I increase the ID number for each exam created? Right now, when I create 2 exams, they both are labeled "00001" in the pdf.

Here is what I'm using just to get by right now:
exams2pdf(exm1, n = 2, name = fileName, template = "myExam")

Do I need to change the .tex file or a parameter in exams2pdf?

2) How can I add my own cover page? Previously, when I used exams2nops, I was able to use intro = "\\includepdf[pages=-]{C:/Users/John/Documents/buildexam/cover.pdf}", however it doesn't appear this is available in exams2pdf. Any suggestions how to add this easily? (Might be easier to do this now than figure out how to completely edit the current cover page, since I'm a little tight on time.)

3) How can I add the couple pages of scratch paper at the end? Previously, I used blank = c(2,0) when using exams2nops. Is there an equivalent for exams2pdf?

Sorry for all the questions. I usually poke around all the discussion forums to find my answers with trial and error to fix my problems, but I'm in a bit of a time crunch. I'm getting closer, though! Thank you!

RE: Combining 2 pdfs with exam2nops [ Reply ]
By: Achim Zeileis on 2023-02-21 01:12
[forum:49608]
Thanks for the explanation, this all makes perfect sense. However, I would (strongly) encourage you to move towards exams2pdf(). I can help with the template and eventually this will be (much) less work than trying to combine several exams2nops() outputs.

BTW, internally exams2nops() actually calls exams2pdf() with a custom template that was generated on the fly.

Regarding your concerns:

1) The ID can also be included in exams2pdf() in any place you like.

2) The solutions can be hidden by including just one line in the master template. There is no need to modify the individual .Rmd files.

3) I understand that the template can be uncomfortable. Do you have any experience with LaTeX at all? If so, you could start out by just writing standard .tex and then I can help with turning it into a template file. If not, maybe you can put together a desired layout for the exam in other way?

As a starting point, I would recommend to run the following code in some working directory where you want to set up your examples:

exams_skeleton(type = c("num", "string"), writer = "exams2pdf", markup = "markdown")

This copies various resources from the package into your working directory and sets up an R script demo-pdf.R containing a worked example.

RE: Combining 2 pdfs with exam2nops [ Reply ]
By: John Wilson on 2023-02-21 00:52
[forum:49607]
Thanks for responding quickly! You are correct that all I have are 4 open-ended num questions; there are no multiple choice questions.

I didn't plan to use exams2pdf() because:

1) exams2nops includes a nice ID # at the top-left of every page to help me keep track of many students.

2) exams2nops does not include the solutions to my questions (which I want), and exams2pdf includes them by default. (I tried hiding the solutions in the Rmd file when using exams2pdf, but I had other formatting issues like when using \pagebreak to ensure each question on its own page, but the numbers weren't displaying next to the text of the question.)

3) To be completely honest, I'm not comfortable/don't understand how to make my own custom template. I guess I'll have to research this more but I've always used the (mostly default) exams2nops or exams2Canvas without much hassle to editing options previously. All exams previously were multiple choice only, so I'm having to figure out how best to put together an open-ended exam the way I need it to fit. I thought I had everything all figured out (all questions coded correctly) until I realized I was being limited to only 3 open-ended questions.

I guess I'll come back later with more questions once I research how to figure out the template. Thanks.

RE: Combining 2 pdfs with exam2nops [ Reply ]
By: Achim Zeileis on 2023-02-21 00:32
[forum:49606]
If I understand you correctly, then you don't have any multiple choice questions and just four open-ended num questions, is that correct? If so, why don't you just use exams2pdf() with a custom template rather than exams2nops()?

Try to start out from exams2pdf(..., template = "exam") and then continue from there. See also vignette("exams", package = "exams") for discussion of the master LaTeX template.

If you have further questions regarding the customization of the template, feel free to ask again.

Combining 2 pdfs with exam2nops [ Reply ]
By: John Wilson on 2023-02-20 17:48
[forum:49605]
Hi! I have an exam with 4 questions that are in the num type. It appears that only 3 open-ended questions are allowed when using a single use of exam2nops, so I'm trying to merge two files/pdfs together since I have 4 questions. I'm not having success, though.

My ideal output is to have:

scantron page (will be manually deleted later since I don't need it, but is necessary b/c I don't want solutions to show),
cover page,
questions 1-4, then
two blank pages at the end for scratch work.

Below is my code so far:

library("exams")
usepackage = c("tikz", "qpdf")

set.seed(03-01-2023)

fileName <- "Exam 1"

#Step 1: Create cover page and first part of exam (first two questions)
exm1 <- list( c("Q1.Rmd"), c("Q2.Rmd") )

part1 <- exams2nops(
exm1,
n = 20,
dir = "nops_pdf",
name = "E1",
title = "Exam 1",
date = "2023-03-01",
blank = c(0,0),
duplex = FALSE,
intro = "\\includepdf[pages=-]{C:/Users/John/Documents/buildexam/cover.pdf}",
samepage = TRUE,
reglength = 8,
points = 1,
language = "lang.dcf",
usepackage = c("ragged2e"),
header = "\\renewenvironment{question}{\\item \\begin{samepage}}{\\end{samepage}}"
)

#Step 2: Create next part of exam (last two questions)
exm2 <- list( c("Q3.Rmd"), c("Q4.Rmd") )

part2 <- exams2nops(
exm2,
n = 20,
dir = "nops_pdf",
name = "E1",
title = "Exam 1",
date = "2023-03-01",
blank = c(2,0),
duplex = FALSE,
samepage = TRUE,
reglength = 8,
points = 1,
language = "lang.dcf",
usepackage = c("ragged2e"),
header = "\\renewenvironment{question}{\\item \\begin{samepage}}{\\end{samepage}}"
)


qpdf::pdf_combine( input = c(part1, part2), output = "output.pdf" )


Is there a better/different way to do this? Any help would be appreciated as I'm currently stuck!

Thanks to:
Vienna University of Economics and Business Powered By FusionForge