12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- class SExamTeachingProduct extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
- public function tableName()
- {
- return 'exam_teaching_product';
- }
- /**
- * 获取考试教师讲案信息
- * @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,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
- 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}";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- }
- /**
- * 初始化教师讲案记录
- * @param $examId
- * @param $productType
- * @param $subjectId
- */
- public function initialize($examId, $productType, $subjectId){
- $model = self::model()->find("exam_id=:id and product_type=:type and subject_id=:subject", array(":id" => $examId,":type"=>$productType,":subject"=>$subjectId));
- if(!$model){
- $model = new self();
- $model->exam_id = $examId;
- $model->subject_id = $subjectId;
- $model->product_type = $productType;
- $model->create_time = time();
- $model->update_time = time();
- $model->save(false);
- }
- }
- /**
- * 教师版是否生成
- * @param $examId
- * @param $productType
- * @return bool
- */
- public static function isGenerate($examId, $productType){
- $rs = self::model()->find("exam_id=:id and product_type=:type and is_create_pdf=1", array(":id" => $examId,":type"=>$productType));
- return $rs ? true : false;
- }
- }
|