3

Is it possible to control the lengths of answer boxes in the Moodle from R-exams? The image below shows that the boxes have different lengths which probably correspond to those of the hidden answers. My answers contain a mixture of numeric and string answers. The boxes for the string answers appear to be smaller than those of numeric answers. I would like to standardise these boxes and make them all have equal lengths. Thank you!

enter image description here

Akram
  • 355
  • 1
  • 10

1 Answers1

3

Short answer:

Good question! Yes, it is possible. You can set an extra metainformation tag numwidth to TRUE. Then the width of the cells is adjusted to the same width. So in R/Markdown exercises you just add

exextra[numwidth,logical]: TRUE

And in R/LaTeX exercises:

\exextra[numwidth,logical]{TRUE}

A worked example is provided at: http://www.R-exams.org/templates/fourfold2/.

Details:

This used to be an undocumented feature for numeric sub-items in cloze exercises but has been documented in R/exams 2.4-0. The analogous stringwidth specification was also added.

In addition to the logical specification you can also use a numeric value for the maximum width (e.g., exextra[numwidth,numeric]: 8) or a number in a character value that has the desired width (e.g., exextra[numwidth,character]: 99999999).

Example:

A simple demo R/Markdown exercise using a numeric width specification with a mix of numeric and string questions is:

Question
========

List the first or first six numbers and letters, respectively.

|         | Numbers     | Letters     |
|:--------|:------------|:------------|
| First   | ##ANSWER1## | ##ANSWER3## |
| First 6 | ##ANSWER2## | ##ANSWER4## |

Answerlist
----------
* 
* 
* 
* 

Meta-information
================
exname: fixedwidth
extype: cloze
exclozetype: num|num|string|string
exsolution: 1|123456|A|ABCDEF
exextra[numwidth,numeric]: 9
exextra[stringwidth,numeric]: 9

Importing the XML output from exams2moodle("fixedwidth.Rmd") into Moodle yields blank cells with equal width:

fixedwidth-blank

Only when providing feedback after filling in the responses, Moodle still renders the cells somewhat differently. But I think that this cannot be controlled through modifications in the Moodle XML code.

fixedwidth-feedback

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Many thanks, Achim! It really works when all are the numeric answers. However, I have a mixture of numeric and string answers in my answer list. Actually, in the image above, the smaller boxes are for the string answers. My issue is how to make both string and numeric answer boxes have equal length. – Akram Aug 14 '20 at 15:01
  • I didn't notice possible to create multi-answer questions in moodle. Thanks for this question and answer! :) – uzsolt Aug 15 '20 at 05:17
  • @Akram Thanks for raising this issue. It wasn't possible to control the width of the `string` sub-items in a `cloze` exercise. But I just added this to the development version of R/exams on R-Forge. I also streamlined the code and documented it. Please install the most current development version via `install.packages("exams", repos="http://R-Forge.R-project.org")` to try it out. A worked example has been added to the revised and extended answer. – Achim Zeileis Aug 21 '20 at 23:48
  • 1
    @Achim That is really awesome! Many thanks for making this available for the R community. – Akram Aug 22 '20 at 18:00