12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * Created by 上海互教教育科技有限公司.
- * User: 刘红伟
- * QQ : 454303753
- * Date: 2017/7/26 0026
- * Time: 上午 11:01
- */
- class SClassExamPrinter extends MyActiveRecord{
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return 'class_exam_printer';
- }
- public function getExamTime($examId){
- $sql = "select add_time from ".$this->tableName()." where exam_id = {$examId} and type = 0";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryScalar();
- }
- /**
- * 获取上一次考试id
- * @param $examId
- * @return bool|CDbDataReader|mixed|string
- */
- public function getPreExamId($examId,$subjectId,$classId){
- $examDate = $this->getExamTime($examId);
- if(in_array($subjectId, Yii::app()->params['mathSubjectId']))
- {
- $subjectCondition = ' e.subject_id in ('.implode(',',Yii::app()->params['mathSubjectId']).')';
- }else
- {
- $subjectCondition = ' e.subject_id = '.$subjectId;
- }
- $sql = "select cep.exam_id,e.exam_group_id from class_exam_printer as cep left join exam as e on e.exam_id = cep.exam_id where {$subjectCondition} and cep.add_time < {$examDate} and e.class_id = {$classId} and cep.type = 0 and e.status = 1 order by add_time desc";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- }
- /**
- * 获取上一次考试id
- * @param $examId
- * @return bool|CDbDataReader|mixed|string
- */
- public function getTirdExamIds($examId,$subjectId,$classId){
- $examDate = $this->getExamTime($examId);
- $sql = "select cep.exam_id,cep.add_time from class_exam_printer as cep left join exam as e on e.exam_id = cep.exam_id where e.subject_id = {$subjectId} and cep.add_time <= {$examDate} and e.class_id = {$classId} and cep.type = 0 and e.status = 1 order by add_time desc limit 3";
- return $this->getCommandBuilder()->createSqlCommand($sql)->queryAll();
- }
- /**
- * (1)、如果这学校从来生成过数学个性化学习宝,他们依然会有标注任务,这种学校不能带有New标签。
- (2)、我们对于学校新使用定义的的情况1,该学校下,数学个性化学习宝(含试用和正式使用)的最早生成日期,与该份试卷的考试日期,差距在一个月内,即为学校新使用。
- 3)、我们对于学校新使用定义的情况2,该学校下,最近一次数学个性化学习宝的使用时间,与该份试卷的考试时间,间隔超过了3个月,我们认为该学校是长期未使用个性化学习宝,现在又用了,我们需要重点维护,也视为学校新使用。
- (4)、只要达到了上述的情况1或情况2,即显示new标签。
- * @return array|CDbDataReader
- */
- public function getNewLabel($examTime)
- {
- $isNewLabel = false;
- $month_time = 30 * 24 * 3600;
- $time = time();
- $sql = "select add_time from class_exam_printer where type = 2 order by add_time asc";
- $earliestTime = $this->getCommandBuilder()->createSqlCommand($sql)->queryScalar();
- if ($time - $earliestTime <= $month_time) {
- $isNewLabel = true;
- }
- if (!$isNewLabel) {
- $sql = "select add_time from class_exam_printer where type = 2 order by add_time desc";
- $nearestTime = $this->getCommandBuilder()->createSqlCommand($sql)->queryScalar();
- if ($nearestTime - $examTime > $month_time * 3) {
- $isNewLabel = true;
- }
- }
- return $isNewLabel;
- }
- }
|