SExamGroup.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class SExamGroup extends MyActiveRecord
  7. {
  8. public static function model($className = __CLASS__)
  9. {
  10. return parent::model($className);
  11. }
  12. public function tableName()
  13. {
  14. return 'exam_group';
  15. }
  16. public function getDetailByGroupId($groupId)
  17. {
  18. $result = array();
  19. if ($groupId AND is_numeric($groupId))
  20. {
  21. $criteria = new CDbCriteria();
  22. $criteria->addCondition("group_id = '". $groupId ."'");
  23. $result = getAttribute($this->find($criteria));
  24. }
  25. return $result;
  26. }
  27. /**
  28. * 获取考试组是否是第三方的试卷
  29. * @param $examGroupId
  30. * @param $examId
  31. * @return bool|int
  32. */
  33. public function getExamIsTird($examGroupId,$examId){
  34. if(!$examGroupId){
  35. if($examId){
  36. $_sql = "SELECT exam_group_id FROM exam where exam_id = ".$examId;
  37. $exam_info = $this->getCommandBuilder()->createSqlCommand($_sql)->queryRow();
  38. if(isset($exam_info['exam_group_id']) && $exam_info['exam_group_id']){
  39. $examGroupId = $exam_info['exam_group_id'];
  40. }
  41. }
  42. }
  43. $sql="SELECT `is_third` FROM `exam_group` WHERE exam_group_id = {$examGroupId}" ;
  44. $res = $this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  45. if($res && isset($res['is_third'])){
  46. return $res['is_third']?1:0;
  47. }else{
  48. return false;
  49. }
  50. }
  51. }