How to ask a question of type "file upload" - r-exams

Using exams2openolat for exporting exercises from R/exams to OpenOlat, is there a way to ask a question where the student can upload a file as an answer (pdf, jpg, ...)? This would be useful for mathematical proofs for example which are just easier written by hand and then scanned rather than typed.
According to this tweet
[...] The QTI engine in OpenOlat is very cool & powerful!
We're trying to catch up with its interaction features (e.g.,
matching, ordering) but some (e.g., file upload) have been added in
#rexams devel. [...]
https://twitter.com/achimzeileis/status/1333912916299485184
there should be such an option in the development version of R/exams, but I can not find anything else about that.

Extended string items
Indeed, this feature is available in exams2openolat (and exams2qti21 more generally; partially also in exams2moodle) starting from version 2.4-0. The simple idea is that you can set a "type" for string exercises and string elements in cloze exercises:
string: This is the default type for a string exercise, leading to a small fill-in-the-blank field. This is scored automatically by exact string matching.
essay: Alternatively, you can get a larger text field where students can enter longer answers. This has to be scored manually by the lecturer.
file: As another alternative you can get a file upload interaction at the end of the exercise. Again this has to be scored manually by the lecturer.
Simple string example
A very basic example asking for a proof (as described in your question) is provided below. The exstringtype is set to file and hence no exsolution is needed (because it cannot be scored automatically) which is therefore set to nil. The exercise uses R/Markdown .Rmd markup - it would, of course, be also possible to use R/LaTeX .Rnw markup. Also you could include a Solution section if you wanted to.
Question
========
Under which assumptions is the ordinary least squares (OLS) estimator
for the coefficients in the linear regression model unbiased?
Outline the steps for the corresponding proof.
Please upload your solution as an image file (PDF, PNG, JPG, ...).
Meta-information
================
exname: Unbiasedness OLS
extype: string
exstringtype: file
exsolution: nil
More complex cloze example
Similarly, in a cloze exercise you could set the exclozetype to essay or file for a certain element. A worked example is available in the development version of the package as lm3.Rmd which combines all possible elements in a single cloze: string, mchoice, num, schoice, essay, file. Try: exams2openolat("lm3.Rmd", ...). In OpenOlat the open-ended elements (essay and file) have to be scored by the lecturer while the remaining elements can be scored automatically as usual.

Related

R/exams: Open-ended text question in exams2blackboard

Using string questions in exams2blackboard() from R/exams, is there a way to set the size of the box where students type in their answer in an open-ended question? Using string generates just a single row. The idea would be to have a text editor with a larger box for an open-ended text question.
Overview
Starting from R/exams version 2.4-0 (the current CRAN release at the time of writing), different types of string exercises can be easily distinguished:
string: The default is a "closed" string questions where the participants typically enter a short string (e.g., a name of a function or method etc.). The answer entered then needs to match exactly the specified correct solution in order to obtain the point(s) associated with the exercise.
essay: Alternatively, an open-ended text question can be used where participants enter an "essay" in a text editor in the browser. The presentation depends to a certain degree on the specific learning management system. Instructors need to assign points manually.
file: Rather than providing the answer to an open-ended question in a text editor, participants can use a file upload (e.g., a PDF, HTML, Docx, etc.). Again, instructors need to assign points manually.
Some exams2xyz() interfaces (notably exams2moodle() and exams2qti21() and hence exams2openolat()) also allow the combination of several types, typically essay|file so that student have the text editor and file upload. This is illustrated by the essayreg exercise template provided on the R/exams web page.
Solution
In order to use an open-ended essay question in exams2blackboard() you need to specify the following meta-information (here shown in R/Markdown style):
Meta-information
================
exname: [...]
extype: string
exstringtype: essay
exsolution: nil
where [...] should be a short description for your exercise.
Example
To try this out, please download the essayreg exercise template and save it as myessay.Rmd. Then, edit the line specifying the stringtype to exstringtype: essay and run
exams2blackboard("myessay.Rmd", ...)

With R markdown (or Quarto) can I reorder output sections?

I am working on a scientific paper in R Markdown and it needs an abstract (with embedded results) at the start of the paper. Currently the paper has analyses interspersed before the paragraphs and/or tables and figures where I report the results. I can render the abstract at the end because all the parts have been calculated but I cant submit the paper like this. I hate to front load all the analysis code (out of context) so I have the numbers ready for the abstract.
Does anybody have a strategy for this?
I know I can manually cut and paste the abstract to the top after rendering the document but that wrecks an otherwise fully reproducible workflow.
The best idea I have come up with (but I have not tried yet) is to save the .md file that is generated as the Rmd is processed and then programmatically parse the file and feed the abstract then the body of the paper directly to pandoc.
Is there a good solution to this using Quarto?
Both rmarkdown (through {bookdown}) and {quarto} will allow you to assemble a series of rmd/qmd files into a single document and use a YAML file to specify the order in which they should be assembled.
I'm currently using something like this for developing a standard reporting format for some research on human/machine interfaces. Intended for an applied scientist/engineer audience, which is not so different from your academic journal application.

Fill initial student IDs with zeros in R/exams exams2nops()

When using the exams package to produce PDF files for NOPS exams I want to edit the number of digits that are available to my students (reglength). I am aware that the package only admits a minimum of 7 digits. However, our students only have 5 digits in their ID number. As so I would to know if it is possible to edit the template via PDF manipulation (I tried with the staplr::get_fields() function, but it does not work) or any other way... I simply want to add 0to the two first digits (i.e., 00xxxxx).
This is a good idea which I have implemented in exams 2.4-0. If you specify a reglength < 7 now, it is still enforced to be 7 internally - and thus this length is necessary in the registration CSV file! But on the exam sheet the initial IDs are fixed to "0" and the corresponding boxes are ticked already.
For example, the following code will give you a warning but produce the output below:
exams2nops(..., reglength = 5)
## Warning message:
## In make_nops_page(n, nchoice = nchoice, reglength = reglength) :
## 'reglength = 5' too small, using 7 instead, but fixing initial IDs to 0
Notes:
I haven't tested yet whether the scanning of these sheets actually works well enough because I'm in my home office for the foreseeable future without access to a suitable printer/scanner. I don't see sources for potential problems, though.
I assumed that you referred to exams2nops() rather than exams2pdf() and hence have modified your question accordingly. In exams2pdf() you can need to provide your template anyway and can edit it in any way you like, adding the zeros where you need them.
We added the XX manually to the exams2nops pdf generated file manually, and the scans did work fine. I see no reason why they should not work with your solution. Thanks for implementing it.

How do I handle randomly selected graphics files in R exams for export to qti and moodle?

I have a spreadsheet of exam questions that I want to use to generate quizzes and exams using R exams, and I'd like to include graphics in some of the questions.
The template here (http://www.r-exams.org/templates/fruit/) begins by defining the images as long base 64 encoded strings as generated by
base64enc::base64encode("file.png")
This seems fine, but if I have a dozen or so images of which I might only want a question to use one, two, or three images selected at random for programmatically generated exercises, how can I avoid including the encoding for all dozen images with every single exercise?
The best I can think of at the moment is to include LaTeX syntax for graphics inclusion in a spreadsheet of possible question options, and as exercises are generated, use regular expressions to find the file names inside the \includegraphics{} commands that will be included, encode those as base 64 strings, and include them in the exercise file, but I'm wondering if there's a way I can do this without writing my own code to parse LaTeX.
First a few clarifications:
The fruit exercises include the images as Base64 strings because the three icons are quite small (12K per icon) and it is convenient to have all information within the Rnw/Rmd exercise without the need to store graphics files separately. It is just one trick that can be nifty and that we wanted to demonstrate.
For more and larger images one could do the same trick but it is probably less convenient. To illustrate how static images can be included in an exercise, the following template is available: http://www.R-exams.org/templates/Rlogo/ It uses the include_supplement() function to declare a certain file as a supplement for the exercises. If this is a graphic it can then be integrated into the exercises via \includegraphics{...} in Rnw exercises and via ![...](...) in Rmd exercises.
Each exercise just has to include the supplements it actually uses (and not all files from which these were sampled). And there is no need to do the Base64 encoding manually. This is done by the exams2xyz(...) functions automatically if needed.
Now for the scenario you describe. Say you have an exercise foo.Rmd in which you want to show one of three static images foo-1.png, foo-2.png, foo-3.png and ask questions about it. Then your R code might do something like:
i <- sample(1:3, 1)
img <- paste0("foo-", i, ".png")
include_supplement(img)
which randomly selects one of the three files and declares it to be an attachment. Then within the question text you would include the image via something like:
![](`r img`)
Caveats:
The code above assumes that the PNG images are located in the same directory as the Rmd exercise itself. If it is in a sub-directory bar/ say, you would need include_supplement(img, dir = "bar") etc.
If this exercise is rendered into HTML then the original file name (foo-1.png or foo-2.png or foo-3.png) would be visible in the HTML source code. This may (or may not) provide a hint for students what the correct answer is. If so, it would be better to include the file with a neutral name, e.g., include_supplement(img, target = "foo.png").
In Rnw exercises the code for including the graphic would be something like: \includegraphics{\Sexpr{img}}.

Annotating Adobe Reader PDFs with math symbols

Many of the math textbooks and other literature I read is in PDF format, so I frequently find myself annotating these with the Adobe Reader comments tool.
I did find a helpful guide here, but sometimes I'd like the option of inserting math symbols, too. Has anyone found a reliable way to insert math symbols, TeX, or other arbitrary formatting into the annotations?
So far, the best I've come up with is to enter the unicode prefixed by "0x" and hit alt+X after it. Maybe with the Adobe javascript SDK you could write a script to shortcut this.
I don't think any of the current commercial editors make this easy, which is too bad. I am sure the vendors monitor this site, so there is hope.
In the meantime, here is a manual workaround.
Use tikz to create your comment boxes. Here are the two examples I found to be most relevant: Boxes and Positioning. Play around with the options to get both the shape and the placement you want. Generate a pdf file from the latex source that contains your comments.
IMPORTANT: if your comments end before the last page of the original document, insert:
\pagebreak{} % create empty page
\thispagestyle{empty} % get rid of page numbers et al
~ % put a space so the page gets generated
before your \end{document}, to get an empty last page. The following command will reuse the last page of your comments document on all subsequent pages of the original document.
Use a recent version of pdftk with the multistamp command to overlay your equations file with your original file like so:
pdftk original.pdf multistamp comments.pdf output out.pdf
Also see this question.
The free (as speech) PDF tool, Okular, supports this functionality by putting latex formula directly between $$...$$.

Resources