我正在尝试确定正确回答的问题,并且问题回答错误。如果回答正确则显示“完全正确”否则如果不正确则显示“不正确”消息。问题是否正确无论是否始终显示问题的答案都不正确。
以下是代码:
$check = true;
foreach ($studentData['questions'] as $questionId => $questionData) {
if($questionData['answer'] == $questionData['studentanswer'])
{
echo '<td width="30%" class="studentanswer green"><strong>'.htmlspecialchars($questionData['studentanswer']).'</strong></td>' . PHP_EOL;
}
else
{
echo '<td width="30%" class="studentanswer red"><strong>'.htmlspecialchars($questionData['studentanswer']).'</strong></td>' . PHP_EOL;
$check = false;
}
if($check)
{
echo '<p class="green"><strong>Fully Correct</strong></p>';
}
else
{
echo '<p class="red"><strong>Not Correct / Not Fully Correct</strong></p>';
}
}
答案 0 :(得分:1)
此行后再次设为true
<{1}}。$check
if($questionData['answer'] == $questionData['studentanswer'])
{
echo '<td width="30%" class="studentanswer green"><strong>'.htmlspecialchars($questionData['studentanswer']).'</strong></td>' . PHP_EOL;
$check = true;
} else