You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

exams2moodle单选题负分设置异常问题咨询

问题描述

使用R的exams包生成Moodle考试时,单选题(含判断题)的扣分规则不符合预期:需要实现答错任意错误选项固定扣0.25分(无论错误选项数量多少),但当前生成的XML中错误选项的fraction属性为-50(预期为-25)。

示例需求:

问题:1+1等于多少?
a) 2(正确)
b) 3(错误)
c) 4(错误)
选b或c均扣0.25分;新增更多错误选项(如d)5、e)6)时规则保持一致

使用的代码:

library("exams")
elearn_exam <- c("11_sc_MCAB.Rnw")
eSChoice <- exams_eval(negative = 0.25)
exams2moodle(elearn_exam, 
             schoice = list(eval = eSChoice))

注:11_sc_MCAB.Rnw为含3个选项的单选题

生成的XML片段(错误选项fraction异常):

<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>
解决方案

问题根源

exams_eval(negative = 0.25)采用默认的平均扣分规则:将设定的总扣分上限平均分配到所有错误选项,导致错误选项的扣分会随错误选项数量变化,无法满足固定扣分的需求。

修正代码

library("exams")
elearn_exam <- c("11_sc_MCAB.Rnw")
# 设置每个错误选项固定扣0.25分(相对于满分1分)
eSChoice <- exams_eval(negative = list(rule = "false", penalty = 0.25))
exams2moodle(elearn_exam, 
             schoice = list(eval = eSChoice))

参数说明

  • rule = "false":指定对所有错误选项应用固定扣分规则,不受错误选项数量影响
  • penalty = 0.25:设置每个错误选项的扣分值(相对于满分1分)

修改后生成的XML中,错误选项的fraction属性会变为-25,正确选项保持100,完全符合“答错任意错误选项扣0.25分”的需求。

内容的提问来源于stack exchange,提问作者userfb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 23:12:25