Exam.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * 考试管理模型类
  4. * @author jiangfei
  5. * @date 2015-09-09 19:30:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. // class Exam extends CActiveRecord{
  9. class Exam extends MyActiveRecord{
  10. public static function model($className = __CLASS__){
  11. return parent::model($className);
  12. }
  13. public function tableName(){
  14. return 'exam';
  15. }
  16. // 年级列表
  17. public function getExamList($name='',$status=array(0,2)){
  18. $data = array();
  19. $criteria = new CDbCriteria();
  20. $name && $criteria->addSearchCondition('name', $name);
  21. !empty($status)&&$criteria->addInCondition('status', $status);
  22. $total = $this->count($criteria);
  23. $pager = new CPagination($total);
  24. $criteria->order = 'exam_id desc';
  25. $pager->pageSize = 20;
  26. $pager->applyLimit($criteria);
  27. $data['result']=$this->findAll($criteria);
  28. $data['page']=$pager;
  29. $data['page_total']= $total;
  30. return $data;
  31. }
  32. //获取任务名称
  33. public function getExamName($eid) {
  34. $info = $this->find('exam_id=:eid',array(':eid'=>$eid));
  35. if (empty($info)) {
  36. return null;
  37. } else {
  38. return $info->name;
  39. }
  40. }
  41. /**
  42. * 获取考试教师讲案信息
  43. * @param $examId
  44. * @return CDbDataReader|mixed
  45. */
  46. public function getTeachingInfo($examId){
  47. $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}";
  48. return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  49. }
  50. /**
  51. * 获取考试教师讲案信息(新版物理)
  52. * @param $examId
  53. * @return CDbDataReader|mixed
  54. */
  55. public function getTeachingInfoPhysics($examId){
  56. $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}";
  57. return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  58. }
  59. /**
  60. * 获取组id下的考试id
  61. * @param $examGroupId
  62. * @return array|CDbDataReader
  63. */
  64. public function getExamIds($examGroupId){
  65. $sql = "select exam_id from exam where exam_group_id = {$examGroupId}";
  66. $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryColumn();
  67. if($info){
  68. return $info;
  69. }else{
  70. return array();
  71. }
  72. }
  73. /**
  74. * 获取下载所需的groupId
  75. * @param $examGroupId
  76. * @return array|CDbDataReader
  77. */
  78. public function getGroupInfo($examId){
  79. if(empty($examId)) return array();
  80. $sql = 'SELECT wb_group_id,isp_group_id,wbisp_group_id FROM exam WHERE exam_id='.$examId;
  81. $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  82. if($info){
  83. return $info;
  84. }else{
  85. return array();
  86. }
  87. }
  88. }