AStudentScanTask.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class AStudentScanTask extends BusinessActiveRecord {
  7. public static function model($className = __CLASS__){
  8. return parent::model($className);
  9. }
  10. public function tableName(){
  11. return "assist_student_scan_task";
  12. }
  13. public function primaryKey(){
  14. return array('task_id');
  15. }
  16. //读取任务类别
  17. public function getTaskTypesByExamGroupId($examGroupId){
  18. if(!$examGroupId){
  19. return null;
  20. }
  21. $selectSql="(select task_id,task_type from assist_student_scan_task where task_type=1 and exam_group_id='{$examGroupId}' limit 1)
  22. union
  23. (select task_id,task_type from assist_student_scan_task where task_type=2 and exam_group_id='{$examGroupId}' limit 1)
  24. union
  25. (select task_id,task_type from assist_student_scan_task where task_type=3 and exam_group_id='{$examGroupId}' limit 1)
  26. union
  27. (select task_id,task_type from assist_student_scan_task where task_type=4 and exam_group_id='{$examGroupId}' limit 1) ";
  28. $data=$this->getDbConnection()->createCommand($selectSql)->queryAll();
  29. $taskType=array(
  30. 1=>'组卷--Word',
  31. 2=>"组卷--在线答题卡",
  32. 3=>'第三方--切割模板',
  33. 4=>'第三方--在线答题卡'
  34. );
  35. $result=array();
  36. if($data){
  37. foreach ($data as $val){
  38. $result[$val['task_type']]=$taskType[$val['task_type']];
  39. }
  40. }
  41. return $result;
  42. }
  43. //查询任务数量
  44. public function getTaskCount($examGroupId){
  45. if(!$examGroupId){
  46. return null;
  47. }
  48. $sql="select task_id,status from assist_student_scan_task where exam_group_id='{$examGroupId}'";
  49. $data=$this->getDbConnection()->createCommand($sql)->queryAll();
  50. $result=array();
  51. $result['total']=count($data);
  52. $result['surplus']=0;
  53. $result['processed']=0;
  54. if($data){
  55. foreach($data as $val){
  56. if($val['status']==1){
  57. $result['processed']++;
  58. }else{
  59. $result['surplus']++;
  60. }
  61. }
  62. }
  63. return $result;
  64. }
  65. }