多选题的给分原则是多选错选不得分,部分选对得部分分
$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