SThirdMultiTemplate.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class SThirdMultiTemplate extends MyActiveRecord
  7. {
  8. public static function model($className = __CLASS__)
  9. {
  10. return parent::model($className);
  11. }
  12. public function tableName()
  13. {
  14. return 'third_multi_template';
  15. }
  16. public function getByCondition(){}
  17. /*根据考试id,判断上传状态*/
  18. public function getStatusByExamGroupId($ExamGroupId){
  19. $result = array();
  20. $criteria = new CDbCriteria();
  21. $criteria->addCondition('exam_group_id=:exam_group_id');
  22. $criteria->params[':exam_group_id']=$ExamGroupId;
  23. $data = getAttributes($this->findAll($criteria));
  24. if($data){
  25. foreach ($data as $val){
  26. $result[$val['template_type']]=$val;
  27. }
  28. }
  29. return $result;
  30. }
  31. /**
  32. * 获取多个答案和题上传完成的组id
  33. * @param $examGroupIds
  34. * @return array
  35. */
  36. public function getMulUploadGroupId($examGroupIds){
  37. $group_ids = array();
  38. if($examGroupIds){
  39. $sql = "SELECT exam_group_id,topic_upload,answer_upload,template_type FROM third_multi_template where exam_group_id in (".implode(',',$examGroupIds).") ";
  40. $upload_info = $this->queryAll($sql);
  41. $rs = array();
  42. if($upload_info){
  43. foreach($upload_info as $v){
  44. if(!isset($rs[$v['exam_group_id']])){
  45. $rs[$v['exam_group_id']] = 0;
  46. }
  47. if($v['template_type'] == 1){
  48. if($v['topic_upload'] == 1){
  49. $rs[$v['exam_group_id']]++;
  50. }
  51. }elseif($v['template_type'] == 2){
  52. if($v['answer_upload'] == 1){
  53. $rs[$v['exam_group_id']]++;
  54. }
  55. }
  56. }
  57. unset($upload_info);
  58. }
  59. if($rs){
  60. foreach($rs as $gId => $v){
  61. if($v == 2){
  62. $group_ids[] = $gId;
  63. }
  64. }
  65. }
  66. }
  67. return $group_ids;
  68. }
  69. }