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

R/exams中exams2webquiz对数字型字符串答案的识别问题

问题分析与解决方案

核心原因

exams2webquiz()在处理string类型的exsolution时存在隐式类型转换问题:当exsolution是纯数字(如10)时,会被自动解析为数值而非字符串,导致和用户输入的字符串"10"匹配失败;而带百分号的"35%"因为包含非数字字符,被正确识别为字符串,所以能正常匹配。

修复方案

方案1:强制标记纯数字答案为字符串

在Meta-information里给exsolution加上双引号,明确指定其为字符串类型:

Question
========
Type the character string `10`.

Solution
========
Just type `1` and then `0`.

Meta-information
================
exname: numeric string
extype: string
exsolution: "10"

修改后exams2webquiz()会将"10"当作字符串处理,和用户输入的内容完全匹配,无论是手动输入还是通过auto参数自动填入都能正确判定。

方案2:动态切换extype

如果题目是动态生成的,可根据exsolution的格式自动调整extype:

  • 当exsolution包含%时,设置extype: string
  • 当exsolution是纯数字时,设置extype: numeric
    这种方式能兼顾两种答案格式的匹配需求,从根源避免类型识别冲突。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.01 20:24:51