多选题的给分原则是多选错选不得分,部分选对得部分分

$q_answer = 'A,B,C'; //正确答案

$s_answer = 'A,D';  //学生答案
$q_answer = explode(',',$q_answer);
$s_answer = explode(',',$s_answer);

$count = count($q_answer);

$score = 6;

if(count(array_diff($s_answer,$q_answer)) > 0)
{
      $real_score = 0;
}
else
{
      $real_score = $score * count(array_intersect($q_answer,$s_answer)) / $count;
}
echo $real_score;

运行结果为:0

Leave A Comment

Recommended Posts

在原文件名前加上前缀并实现文件的批量重命名

要在原文件名前加上前缀并实现文件的批量重命名,你可以根据你所使用的操作系统选择合适的脚本语言来编写脚本。以下是在不同操作系统上实现这一功能的示例: 在 Windows 上使用 PowerShell 在 macOS/Linux 上使用 Shell 脚本 在 Python 中使用 os 模块 注意事项 将上述脚本中的 folder_path 或 $folderPath 替换为你的文件夹路径,将 prefix 替换为你想要添加的前缀,然后运行脚本即可。

blueidea