php laravel 计算正确率

小轩1986 发布于 2016/06/04 13:38
阅读 307
收藏 0

功能求正确率,思路是比较选择答案和正确答案的值是否相等,如果相等$a=1不相等$a=0,然后把每道题的$c进行相加,在除总共的题目数,但是我现在不会累加每道题的$c请大神帮下吗 ?

码:

@foreach($questions as $question
<tbody
<tr
<td>{{$question->q_number}}</td

<td> <?php $ans = []; 

foreach($answer_lists as $key=>$answer_list

{ $ans[$answer_list['hw_question_id']] = $answer_list['selected_answer']; } ?> 

{{ empty($ans[$question->id]) ? '' : $ans[$question->id] }} 

<?php if($ans[$question->id] == $question['answer'])

{ $a = 1; }else{ $a = 0; } ?> </td

<td>{{$question->answer}}</td> </tr

</tbody>


加载中
0
风情万种
风情万种

$c 表示?{{$question->answer}}

返回顶部
顶部