123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /**
- * 考试管理模型类
- * @author jiangfei
- * @date 2015-09-09 19:30:00
- * @company 上海风车教育有限公司.
- */
- // class Exam extends CActiveRecord{
- class Exam extends MyActiveRecord{
-
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return 'exam';
- }
-
- // 年级列表
- public function getExamList($name='',$status=array(0,2)){
-
- $data = array();
- $criteria = new CDbCriteria();
- $name && $criteria->addSearchCondition('name', $name);
- !empty($status)&&$criteria->addInCondition('status', $status);
-
- $total = $this->count($criteria);
- $pager = new CPagination($total);
- $criteria->order = 'exam_id desc';
-
- $pager->pageSize = 20;
- $pager->applyLimit($criteria);
- $data['result']=$this->findAll($criteria);
- $data['page']=$pager;
- $data['page_total']= $total;
- return $data;
- }
-
- //获取任务名称
- public function getExamName($eid) {
- $info = $this->find('exam_id=:eid',array(':eid'=>$eid));
- if (empty($info)) {
- return null;
- } else {
- return $info->name;
- }
- }
- /**
- * 获取考试教师讲案信息
- * @param $examId
- * @return CDbDataReader|mixed
- */
- public function getTeachingInfo($examId){
- $sql = "select e.exam_group_id,e.class_id,e.subject_id,eg.is_third,e.name as exam_name,e.academicr_pdf_path,e.academicr_pdf_time,p.paper_id,e.is_academicr_pdf,c.class_name,e.tpl_index,e.tpl_data,e.is_fine_paper,academicr_common_practice,eg.qxk_paper_id from exam as e left join class as c on c.class_id=e.class_id left join exam_group as eg on e.exam_group_id=eg.exam_group_id left join paper as p on p.exam_id=e.exam_id where e.exam_id = {$examId}";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- }
- /**
- * 获取考试教师讲案信息(新版物理)
- * @param $examId
- * @return CDbDataReader|mixed
- */
- public function getTeachingInfoPhysics($examId){
- $sql = "select e.exam_group_id,e.class_id,e.subject_id,e.tpl_data,e.name as exam_name,e.academicr_pdf_path,e.academicr_pdf_time,e.is_academicr_pdf from exam as e where e.exam_id = {$examId}";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- }
- /**
- * 获取组id下的考试id
- * @param $examGroupId
- * @return array|CDbDataReader
- */
- public function getExamIds($examGroupId){
- $sql = "select exam_id from exam where exam_group_id = {$examGroupId}";
- $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryColumn();
- if($info){
- return $info;
- }else{
- return array();
- }
- }
- /**
- * 获取下载所需的groupId
- * @param $examGroupId
- * @return array|CDbDataReader
- */
- public function getGroupInfo($examId){
- if(empty($examId)) return array();
- $sql = 'SELECT wb_group_id,isp_group_id,wbisp_group_id FROM exam WHERE exam_id='.$examId;
- $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- if($info){
- return $info;
- }else{
- return array();
- }
- }
- }
|