$val) { $tplData = json_decode($val["tpl_data"], true); $paperSize = null; $examDate = null; if(in_array($val["tpl_index"], Yii::app()->params["custom_tpls_ids"])){ switch($val["tpl_index"]){ case "12": $paperSize = "A3"; break; case "13": $paperSize = "A4"; break; case "14": $paperSize = "8K"; break; case "15": $paperSize = "16K"; break; case "2012": $paperSize = "A3"; break; case "2013": $paperSize = "A4"; break; case "2014": $paperSize = "8K"; break; case "2015": $paperSize = "16K"; break; case "2016": $paperSize = "A3"; break; case "2017": $paperSize = "A4"; break; case "2018": $paperSize = "8K"; break; case "2019": $paperSize = "16K"; break; case "1012": $paperSize = "A3"; break; case "1013": $paperSize = "A4"; break; case "1014": $paperSize = "8K"; break; case "1015": $paperSize = "16K"; break; case "1016": $paperSize = "A3"; break; case "1017": $paperSize = "A4"; break; case "1018": $paperSize = "8K"; break; case "1019": $paperSize = "16K"; break; case "3012": $paperSize = "A3"; break; case "3013": $paperSize = "A4"; break; case "3014": $paperSize = "8K"; break; case "3015": $paperSize = "16K"; break; case "3016": $paperSize = "A3"; break; case "3017": $paperSize = "A4"; break; case "3018": $paperSize = "8K"; break; case "3019": $paperSize = "16K"; break; case "4012": $paperSize = "A3"; break; case "4013": $paperSize = "A4"; break; case "4014": $paperSize = "8K"; break; case "4015": $paperSize = "16K"; break; case "4016": $paperSize = "A3"; break; case "4017": $paperSize = "A4"; break; case "4018": $paperSize = "8K"; break; case "4019": $paperSize = "16K"; break; case "2011": $paperSize = "A3"; break; case "3011": $paperSize = "A3"; break; } } if(in_array($val["tpl_index"], Yii::app()->params["custom_tpls_ids"])){ switch($val["tpl_index"]){ case "16": $paperSize = "A3"; break; case "3016": $paperSize = "A3"; break; case "3017": $paperSize = "A4"; break; case "3013": $paperSize = "A4"; break; case "3007": $paperSize = "A3"; break; case "17": $paperSize = "A4"; break; case "18": $paperSize = "8K"; break; case "19": $paperSize = "16K"; break; case "2011": $paperSize = "A3"; break; case "3011": $paperSize = "A3"; break; } } if($tplData){ if(!isset($tplData["examDate"]) || !($examDate = strtotime($tplData["examDate"]))) $examDate = $val["create_time"]; if($paperSize === null && isset($tplData["paper"]) && $tplData["paper"] == 1) $paperSize = "A3"; } if($examDate === null) { $examDate = $val["create_time"]; } if($paperSize === null) { $paperSize = "A4"; } $rs["rs"][$key]["exam_time"] = $examDate; $rs["rs"][$key]["paper_size"] = $paperSize; } } return $rs; } /** * 获取考试列表 * 用于: * * @param $condition * @param $orderBy * @param int $pageSize 页码 */ public function getPrintGroupList($condition,$orderBy,$pageSize=9) { $condition = $this->condition($condition); $orderBy = $this->orderBy($orderBy); $handle = $this->sConn->createCommand(" select e.name as print_name,e.class_id,e.is_display,e.subject_id,e.exam_id,e.create_time,e.tpl_data,e.tpl_index,e.is_new,e.school_card_status,e.school_card_length,eg.*,c.grade from exam_group as eg left JOIN exam e ON eg.exam_group_id = e.exam_group_id and e.semester_id = {$this->semester['id']} and eg.status >0 left join class c on c.class_id=e.class_id {$condition} group by eg.exam_group_id {$orderBy} ")->query(); //进行分页 $rs = $this->paging($this->sConn, $handle, $pageSize); if($rs["rs"] && !empty($rs["rs"])) { return $this->setPaperSize($rs); } return $rs; } /** * 获取考试列表 * 用于:个性化学习宝督学列表 * * @param $condition * @param $orderBy * @param int $pageSize 页码 */ public function getExamGroupList($condition,$orderBy,$pageSize=9) { $condition = $this->condition($condition); $orderBy = $this->orderBy($orderBy); $sql = "select e.name,e.exam_id,e.create_time,e.tpl_data,count(e.class_id) as class_count,e.exam_group_id,eg.mark_type,e.subject_id from exam_group as eg JOIN exam e ON eg.exam_group_id = e.exam_group_id and e.semester_id = {$this->semester['id']} and eg.status >0 join student_improve_score_plan_topics spt on e.exam_id=spt.plan_id {$condition} group by eg.exam_group_id {$orderBy}"; $handle = $this->sConn->createCommand($sql)->query(); //进行分页 $rs = $this->paging($this->sConn, $handle, $pageSize); return $rs; } /** * 获取已发送标注或未发送标注的考试 * @param $is_labelled * * @return array|\CDbDataReader */ public function getPaerLabelledByExam($is_labelled) { return $this->sConn->createCommand("select p.exam_id from paper as p JOIN exam as e on p.exam_id = e.exam_id where e.semester_id = {$this->semester['id']} and p.is_labelled = ".$is_labelled)->queryAll(); } /** * 通过班级ID,获取考试信息 * @param $class_ids *r * @return array|\CDbDataReader */ public function getClassIdByExam($class_ids) { if(!$class_ids || !is_array($class_ids)) { return array(); } return $this->sConn->createCommand("select exam_id from exam where class_id in (".implode(',',$class_ids).")")->queryAll(); } /** * 通过学期获取班级信息 * @param $semesterId * * @return array|\CDbDataReader */ public function getSemesterClasses($semesterId){ $classes = array(); if($semesterId){ $classes = $this->sConn->createCommand("select * from class where semester_id = '{$semesterId}' and is_hide=0")->queryAll(); } return $classes; } /** * * 班级考试列表 * @param $condition * @param $orderBy * @param int $pageSize * * @return array */ public function getExamsByExamGroupIdList($condition,$orderBy,$pageSize=9) { $condition = $this->condition($condition); $orderBy = $this->orderBy($orderBy); $handle = $this->sConn->createCommand(" select exam_id,exam_group_id,semester_id,upload_status,`status`,class_id,subject_id,`name` as print_name,`type`,create_time,tpl_index,tpl_data,is_new from exam {$condition} {$orderBy} ")->query(); //进行分页 $rs = $this->paging($this->sConn, $handle, $pageSize); if($rs["rs"] && !empty($rs["rs"])) { return $this->setPaperSize($rs); } return $rs; } /** * 通过老师名称获取老师与班级信息 */ public function getTeachersByteacherName($teacher_name){ $teachers = array(); $class_ids = array(); if($teacher_name){ $teacher_data = $this->sConn->createCommand(" select * from teacher where teacher_name LIKE '%{$teacher_name}%' ")->queryAll(); if($teacher_data) { foreach($teacher_data as $v) { $teachers[$v['teacher_id']] = $v['teacher_id']; } if($teachers) { $class_teacher_data = $this->sConn->createCommand(" select * from teacher_class_relation where teacher_id in(".implode(',',$teachers).") and semester_id =".$this->semester['id']." ")->queryAll(); if($class_teacher_data) { foreach($class_teacher_data as $v) { $class_ids[$v['class_id']] = $v['class_id']; } } } } } return $class_ids; } public function getBacklogList($condition = array(), $orderBy = array("add_time desc")){ $condition = Arr::merge($condition, array("c.semester_id = '{$this->semester["id"]}'")); $condition = $this->condition($condition); $orderBy = $this->orderBy($orderBy); $handle =$this->sConn->createCommand(" SELECT c.class_name, e.`name` AS exam_name, e.subject_id, e.class_id, e.exam_id, e.is_backlog, e.create_time, e.is_display, eg.upload_status AS group_upload_status, eg.mark_type, eg.mark_status, e.exam_group_id, eg.import_score_type FROM exam AS e JOIN `class` AS c ON e.class_id = c.class_id JOIN exam_group eg ON eg.exam_group_id = e.exam_group_id {$condition} GROUP BY e.class_id, e.exam_id {$orderBy}"); $rs = $handle->queryAll(); $examsIds = $this->grouping($rs, "exam_id", true); $studentAnswerImg=array(); if($examsIds){ $paperData=$this->sConn->createCommand("select paper_id,exam_id from paper where exam_id in(".implode(',',$examsIds).")")->queryAll(); $studentAnswerImg=array(); $paperIds=array(); $paperIdToExamId=array(); if($paperData){ foreach ($paperData as $val){ $paperIds[]=$val['paper_id']; $paperIdToExamId[$val['paper_id']]=$val['exam_id']; } $sql="select count(DISTINCT student_id) as count,paper_id from student_paper_topic_rs where paper_id in(".implode(',',$paperIds).") and answer_url<>'' group by paper_id "; $rsImg=$this->sConn->createCommand($sql)->queryAll(); if($rsImg){ foreach ($rsImg as $val){ $studentAnswerImg[$paperIdToExamId[$val['paper_id']]]=$val['count']; } } } } $examsIds = "'".implode("','", $examsIds)."'"; $sprs = $this->sConn->createCommand("select exam_id, is_complete, is_feedback,is_wrongbook_pdf,is_wbisp_pdf,is_isp_pdf from student_paper_relation where exam_id in({$examsIds}) and is_del=0")->queryAll(); $examsSprs = array(); foreach($sprs as $key => $val){ if(!isset($examsSprs[$val["exam_id"]])) $examsSprs[$val["exam_id"]] = array(); $examsSprs[$val["exam_id"]][] = $val; } $examsStudentsCount = array(); foreach($examsSprs as $examId => $sprs){ $examsStudentsCount[$examId] = array( "is_complete_count" => 0, "is_uploaded_count" => 0, "wrongbook_pdf_count" => 0, "wbisp_pdf_count" => 0, "isp_pdf_count" => 0, ); $examsStudentsCount[$examId]["students_count"] = count($sprs); foreach($sprs as $k => $v){ if($v["is_complete"] == 1) { $examsStudentsCount[$examId]["is_complete_count"]++; } if($v["is_feedback"] == 1) { $examsStudentsCount[$examId]["is_uploaded_count"]++; } if($v["is_wrongbook_pdf"] == 1) { $examsStudentsCount[$examId]["wrongbook_pdf_count"]++; } if($v["is_wbisp_pdf"] == 1) { $examsStudentsCount[$examId]["wbisp_pdf_count"]++; } if($v["is_isp_pdf"] == 1) { $examsStudentsCount[$examId]["isp_pdf_count"]++; } } } foreach($rs as $key => $val){ if(isset($examsStudentsCount[$val["exam_id"]])){ $rs[$key]["students_count"] = $examsStudentsCount[$val["exam_id"]]["students_count"]; $rs[$key]["is_complete_count"] = $examsStudentsCount[$val["exam_id"]]["is_complete_count"]; $rs[$key]["is_uploaded_count"] = $examsStudentsCount[$val["exam_id"]]["is_uploaded_count"]; $rs[$key]["wrongbook_pdf_count"] = $examsStudentsCount[$val["exam_id"]]["wrongbook_pdf_count"]; $rs[$key]["wbisp_pdf_count"] = $examsStudentsCount[$val["exam_id"]]["wbisp_pdf_count"]; $rs[$key]["isp_pdf_count"] = $examsStudentsCount[$val["exam_id"]]["isp_pdf_count"]; } else{ $rs[$key]["students_count"] = 0; $rs[$key]["is_complete_count"] = 0; $rs[$key]["is_uploaded_count"] = 0; $rs[$key]["wrongbook_pdf_count"] = 0; $rs[$key]["wbisp_pdf_count"] = 0; $rs[$key]["isp_pdf_count"] = 0; } $rs[$key]["student_answer_img"] =0; if($val['import_score_type']){ //导入成绩,判断图片 if(isset($studentAnswerImg[$val['exam_id']])){ $rs[$key]["student_answer_img"] =$studentAnswerImg[$val['exam_id']] ; } } } return $rs; } public function getPaperIdsByExamIds($examIds){ $paperIds = array(); if($examIds && is_array($examIds)){ $sql = "select paper_id,exam_id from paper where exam_id in (".implode(',',$examIds).")"; $paperInfo = $this->sConn->createCommand($sql)->queryAll(); if($paperInfo){ foreach ($paperInfo as $item) { $paperIds[] = $item['paper_id']; } } } return $paperIds; } public function getTopicWord($examGroupId){ } }