getDbConnection(); $rs = $connect->createCommand($sql)->queryRow(); $markCount= isset($rs['count']) ? $rs['count'] : 0; return $markCount; } public function getStuMarkingStatus($studentIds, $ewId) { $result = array(); if ($studentIds) { $sql = "select distinct m.student_id from english_writing_marking m where m.ew_id={$ewId} and m.student_id IN (" . implode(',', $studentIds) . ")"; $connect = $this->getDbConnection(); $rs = $connect->createCommand($sql)->queryAll(); if ($rs) { foreach ($rs as $item) { $result[$item['student_id']] = 1; } } } return $result; } /** * 获取班级学生写作宝统计表格数据 * @param $ewId * @return array * @throws CException */ public function getStudentRateList($ewId) { $result = array(); $sql = "select m.ocr_text,s.realname from english_writing_marking m inner join student_info s on m.student_id=s.student_id where ew_id='{$ewId}';"; $connect = $this->getDbConnection(); $rs = $connect->createCommand($sql)->queryAll(); $studentInfo = array(); if ($rs) { foreach ($rs as $item) { $text = json_decode($item['ocr_text'],true); $studentInfo['score'] = isset($text['total_score']) ? $text['total_score'] : 0; $studentInfo['student_name'] = $item['realname']; $studentInfo['composition_ocr'] = isset($text['compositon_ocr'])? $text['compositon_ocr'] : ''; array_push($result, $studentInfo); } } if($result) { $rate = _array_column($result, 'score'); array_multisort($rate, SORT_DESC, $result); } return $result; } }