1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- class SEnglishWritingMarking extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
- public function tableName()
- {
- return 'english_writing_marking';
- }
- public function getMarkingCount($ewId)
- {
- $sql = "select count(distinct student_id) as count from english_writing_marking where ew_id={$ewId};";
- $connect = $this->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;
- }
- }
|