Collection.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace app\admin\controller\student;
  3. use app\common\controller\Backend;
  4. use app\common\model\Config as ConfigModel;
  5. use app\admin\model\Report;
  6. /**
  7. * sim-考试集合管理
  8. *
  9. * @icon fa fa-circle-o
  10. */
  11. class Collection extends Backend
  12. {
  13. /**
  14. * Collection模型对象
  15. * @var \app\admin\model\teacher\Collection
  16. */
  17. protected $model = null;
  18. protected $exam_model = null;
  19. protected $whereExtend = null;
  20. public function _initialize()
  21. {
  22. parent::_initialize();
  23. $this->model = new \app\admin\model\teacher\Collection;
  24. $this->exam_model = new \app\admin\model\teacher\Exams;
  25. $this->assignConfig('sim_sim_type', ConfigModel::getSimTypeList());
  26. $this->assignConfig('sim_question_setting_method', ConfigModel::getSimQuestionList());
  27. $this->whereExtend['exam_collection_type'] = 3;
  28. $this->whereExtend['exam_collection_state'] = 2;
  29. }
  30. /**
  31. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  32. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  33. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  34. */
  35. //进入考试
  36. public function into($ids = null)
  37. {
  38. $row = $this->model->get($ids);
  39. if(!$row){
  40. $this->error('未找到记录');
  41. }
  42. $info = $this->exam_model->where(['user_id'=>$this->auth->id,'exam_collection_id'=>$ids])->find();
  43. if(empty($info)){
  44. $arr = [
  45. 'exam_collection_id' => $ids,
  46. 'user_id' => $this->auth->id,
  47. 'seat_id' => 1,
  48. 'sim_id' => 12,
  49. ];
  50. $this->exam_model->save($arr);
  51. }
  52. if ($this->request->isPost()) {
  53. $exam_collection_id = $this->request->post('exam_collection_id');
  54. $info->start_time = date('Y-m-d H:i:s');
  55. $info->save();
  56. $this->success('开始成功','/ZQOtIMLKud.php/student/collection/examing/ids/'.$info['exam_id']);
  57. }
  58. $this->view->assign('row', $row);
  59. return $this->view->fetch();
  60. }
  61. public function examing($ids = null)
  62. {
  63. $row = $this->exam_model->get($ids);
  64. if(!$row){
  65. $this->error('未找到记录');
  66. }
  67. $this->assignConfig('timer', 60*$this->model->where(['exam_collection_id'=>$row['exam_collection_id']])->value('limit_duration'));
  68. $this->view->assign('row', $row);
  69. $departmentdata = [];
  70. $departmentdata = Report::where(['level'=>4,'is_replace'=>1])->select();
  71. // foreach ($result as $k => $v) {
  72. // $departmentdata[$v['report_id']] = $v['name'];
  73. // }
  74. // halt($departmentdata);
  75. if ($this->request->isPost()) {
  76. $params = $this->request->post('row/a');
  77. $this->success('交卷成功','/ZQOtIMLKud.php/student/collection/analysis/ids/'.$row['exam_id']);
  78. }
  79. $this->view->assign('departmentdata', $departmentdata);
  80. return $this->view->fetch();
  81. }
  82. public function analysis($ids = null)
  83. {
  84. $row = $this->exam_model->get($ids);
  85. if(!$row){
  86. $this->error('未找到记录');
  87. }
  88. if ($this->request->isPost()) {
  89. $params = $this->request->post('row/a');
  90. $this->success('操作成功','/ZQOtIMLKud.php/student/collection/index');
  91. }
  92. return $this->view->fetch();
  93. }
  94. }