AssistSchoolManager.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @author: Rick Guo
  4. * @brief: 学校管理器
  5. */
  6. class AssistSchoolManager extends AssistModel {
  7. public $coachId;
  8. public $coach;
  9. public $coachRole;
  10. public $role;
  11. function __construct($schoolId){
  12. parent::__construct($schoolId);
  13. }
  14. //查询考试上传学生数量
  15. public function getStudentCountByExamGroupId($examGroupId,$hasFeedback=0){
  16. if(!$examGroupId){
  17. return null;
  18. }
  19. $result=array();
  20. $result['total']=0; //总数
  21. $result['is_feedback']=0; // 已扫描
  22. $result['is_del']=0; //缺考
  23. $result['abnormal']=0; //异常总量
  24. $result['complete']=0; //完成数量
  25. $result['surplus']=0; //剩余量
  26. $sql="select exam_id from exam where exam_group_id='{$examGroupId}'";
  27. $data=$this->sConn->createCommand($sql)->queryAll();
  28. $examIds=array();
  29. if($data){
  30. if($hasFeedback){
  31. foreach ($data as $val){
  32. $examIds[]=$val['exam_id'];
  33. }
  34. $studentSql="select student_id,is_feedback,is_del from student_paper_relation where exam_id in(".implode(',',$examIds).")";
  35. $studentData=$this->sConn->createCommand($studentSql)->queryAll();
  36. if($studentData){
  37. foreach ($studentData as $val){
  38. if($val['is_feedback']==1){
  39. $result['is_feedback']++;
  40. }
  41. if($val['is_del']==1){
  42. $result['is_del']++;
  43. }else{
  44. $result['total']++;
  45. }
  46. }
  47. }
  48. }
  49. $abnormalSql="select status from assist_student_scan_task where exam_group_id = '{$examGroupId}'";
  50. $abnormalData=$this->conn->createCommand($abnormalSql)->queryAll();
  51. if($abnormalData){
  52. $result['abnormal']=count($abnormalData);
  53. foreach ($abnormalData as $val){
  54. if($val['status']==0){
  55. $result['surplus']++;
  56. }
  57. if($val['status']==1){
  58. $result['complete']++;
  59. }
  60. }
  61. }
  62. }
  63. return $result;
  64. }
  65. //查询待处理数据
  66. public function getSurplusDataByExamGroupId($examGroupId){
  67. $abnormalSql="select status,task_id,`data` from assist_student_scan_task where exam_group_id = '{$examGroupId}' and status=0";
  68. $abnormalData=$this->conn->createCommand($abnormalSql)->queryAll();
  69. $result=array();
  70. if($abnormalData){
  71. foreach ($abnormalData as $val){
  72. $result[]=array(
  73. 'task_id'=>$val['task_id'],
  74. 'student'=>$val['data']
  75. );
  76. }
  77. }
  78. return $result;
  79. }
  80. }