/** * 整个考试所有小题的正确率 * @param $exam_id * @param null $begin * @param null $end * @return mixed */ public function questionRightRateInExam($exam_id,$begin = null,$end = null){
$time_sql = $this->convertTimeSql($begin,$end);
$data = $this->exam_record->field(' question_id,ROUND(avg(case isright when '.self::ANSWER_NOT_ANSWER.' then null else score end),2) as avg_score,sum(case isright when '.self::ANSWER_RIGHT.' then 1 else 0 end) as right_num,sum(case isright when '.self::ANSWER_WRONG.' then 1 else 0 end) as wrong_num,sum(case isright when '.self::ANSWER_NOT_ANSWER.' then 1 else 0 end) as not_answer_num ')->where(' exam_id ='.$exam_id.' AND '.$time_sql)->group(' question_id ')->order(' question_id ')->select();
$count = count($data);
for($i = 0;$i<$count;$i++){
$data[$i] = $this->convertRightNum($data[$i]);
}
return $data;
}
转载于:https://my.oschina.net/jesusslim/blog/415522