SExamTeachingProduct.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. class SExamTeachingProduct extends MyActiveRecord
  3. {
  4. public static function model($className = __CLASS__)
  5. {
  6. return parent::model($className);
  7. }
  8. public function tableName()
  9. {
  10. return 'exam_teaching_product';
  11. }
  12. /**
  13. * 获取考试教师讲案信息
  14. * @param $examId
  15. * @return CDbDataReader|mixed
  16. */
  17. public function getTeachingInfo($examId){
  18. $sql = "select e.exam_group_id,e.class_id,e.subject_id,eg.is_third,e.name as exam_name,t.pdf_path,t.pdf_create_time,p.paper_id,t.is_create_pdf,c.class_name,e.tpl_index,e.tpl_data,eg.import_score_type,eg.qxk_paper_id,e.complete_time from exam_teaching_product
  19. as t join exam as e on t.exam_id=e.exam_id 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 t.exam_id = {$examId}";
  20. return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  21. }
  22. /**
  23. * 初始化教师讲案记录
  24. * @param $examId
  25. * @param $productType
  26. * @param $subjectId
  27. */
  28. public function initialize($examId, $productType, $subjectId){
  29. $model = self::model()->find("exam_id=:id and product_type=:type and subject_id=:subject", array(":id" => $examId,":type"=>$productType,":subject"=>$subjectId));
  30. if(!$model){
  31. $model = new self();
  32. $model->exam_id = $examId;
  33. $model->subject_id = $subjectId;
  34. $model->product_type = $productType;
  35. $model->create_time = time();
  36. $model->update_time = time();
  37. $model->save(false);
  38. }
  39. }
  40. /**
  41. * 教师版是否生成
  42. * @param $examId
  43. * @param $productType
  44. * @return bool
  45. */
  46. public static function isGenerate($examId, $productType){
  47. $rs = self::model()->find("exam_id=:id and product_type=:type and is_create_pdf=1", array(":id" => $examId,":type"=>$productType));
  48. return $rs ? true : false;
  49. }
  50. }