Hello and thank you in advance.
I am trying to create a moodle exam and all seems okay except points for single choice questions. What I would like to have is a maximum of -0.25 for a wrong answer of a single choice question (including true/false), e.g.,
What is 1+1? a) 2 b) 3 c) 4 should be 0.25 if someones chose b) or c); this should also be the case if there were more options, e.g., d) 5, e) 6, and f) 7.
What I have tried is the following
library("exams")
elearn_exam <- c("11_sc_MCAB.Rnw")
eSChoice <- exams_eval(negative = 0.25)
exams2moodle(elearn_exam,
schoice = list(eval = eSChoice))
Note: 11_sc_MCAB.Rnw is a single choice question with 3 answer possibilities
When I import it into moodle or have a look a t the XML file (see below), it states fraction="-50" while I would expect fraction="-25"
<question type="multichoice">
<name>
<text> Q1 : 11_sc_MCAB </text>
</name>
<questiontext format="html">
<text><![CDATA[
<p>
<p>EN: Question - here is the question?</p>
</p>]]></text>
</questiontext>
<penalty>0</penalty>
<defaultgrade>1</defaultgrade>
<shuffleanswers>false</shuffleanswers>
<single>true</single>
<answernumbering>abc</answernumbering>
<answer fraction="-50" format="html">
<text><![CDATA[<p>
ANSWER A
</p>]]></text>
</answer>
<answer fraction="100" format="html">
<text><![CDATA[<p>
ANSWER B</p>]]></text>
</answer>
<answer fraction="-50" format="html">
<text><![CDATA[<p>
ANSWER C
</p>]]></text>
</answer>
</question>
TL;DR Thanks for the report, this is a bug in exams
versions up to 2.4-0 (the current CRAN version at the time of writing). I just fixed it in the development version on R-Forge.
Details: After installation of exams
> 2.4-0 (see below) your code should work as expected. I created a file 11_sc_MCAB.Rnw
with:
\begin{question}
EN: Question - here is the question?
\begin{answerlist}
\item ANSWER A
\item ANSWER B
\item ANSWER C
\end{answerlist}
\end{question}
\exname{11_sc_MCAB}
\extype{schoice}
\exsolution{010}
Then I ran:
exams2moodle("11_sc_MCAB.Rnw",
schoice = list(eval = exams_eval(negative = 0.25)),
table = NULL)
This yields the output moodlequiz.xml
with:
<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<question type="category">
<category>
<text>$course$/moodlequiz/Exercise 1</text>
</category>
</question>
<question type="multichoice">
<name>
<text> Q1 : 11_sc_MCAB </text>
</name>
<questiontext format="html">
<text><![CDATA[
<p>
<p>EN: Question - here is the question?</p>
</p>]]></text>
</questiontext>
<penalty>0</penalty>
<defaultgrade>1</defaultgrade>
<shuffleanswers>false</shuffleanswers>
<single>true</single>
<answernumbering>abc</answernumbering>
<answer fraction="-25" format="html">
<text><![CDATA[<p>
ANSWER A
</p>]]></text>
</answer>
<answer fraction="100" format="html">
<text><![CDATA[<p>
ANSWER B
</p>]]></text>
</answer>
<answer fraction="-25" format="html">
<text><![CDATA[<p>
ANSWER C
</p>]]></text>
</answer>
</question>
</quiz>
with the fraction="-25"
as you expected.
Note: The table = NULL
argument is not necessary in the exams2moodle()
call above. It just makes the XML a bit simpler. For exams
> 2.4-0 by default some additional CSS is included in order to yield somewhat nicer table formatting.
Installation of the development version: Until exams
> 2.4-0 is released on CRAN, you can install the development version from R-Forge or R-universe. At the time of writing only the latter works for technical reasons. Use:
install.packages("exams", repos = "https://zeileis.R-universe.dev")