Exam.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace app\admin\controller\student;
  3. use app\admin\model\Fault;
  4. use app\admin\model\Report;
  5. use app\common\controller\Backend;
  6. use app\common\model\Config as ConfigModel;
  7. use think\Db;
  8. use app\admin\model\department\Department;
  9. /**
  10. * sim-考试表/成绩总分
  11. *
  12. * @icon fa fa-circle-o
  13. */
  14. class Exam extends Backend
  15. {
  16. /**
  17. * Exams模型对象
  18. * @var \app\admin\model\teacher\Exams
  19. */
  20. protected $model = null;
  21. protected $whereExtend = null;
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->model = new \app\admin\model\teacher\Exams;
  26. $groupIds = $this->auth->getGroupIds();
  27. //学员查看自己的
  28. if(in_array(8, $groupIds)){
  29. $this->whereExtend['user_id'] = $this->auth->id;
  30. }
  31. $this->assignconfig("groupIds", $groupIds[0]);
  32. $this->whereExtend['exam_collection_type'] = 3;
  33. $this->whereExtend['endtime'] = ['>',0];
  34. }
  35. /**
  36. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  37. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  38. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  39. */
  40. public function view($ids = null)
  41. {
  42. $row = Db::name('real_exam_score')->where('exam_id', $ids)->find();
  43. if (!$row) {
  44. $this->error(__('未交卷'));
  45. }
  46. $rows = $this->model->get($ids);
  47. $row['seat_id'] = $rows->seat_id;
  48. $row['user_nickname'] = $rows->user_nickname;
  49. $row['user_username'] = $rows->user_username;
  50. $row['user_depart_id'] = $rows->user_depart_id;
  51. $row['user_depart_name'] = Department::where('id',$rows->user_depart_id)->value('name');
  52. $row['start_time'] = $rows->start_time;
  53. $row['end_time'] = $rows->end_time;
  54. $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
  55. $row['fault_name_one'] = Fault::where('fault_id',$fault_list[0]['fault_id'])->value('name');
  56. $row['fault_name_two'] = Fault::where('fault_id',$fault_list[1]['fault_id'])->value('name');
  57. $row['fault_name_three'] = Fault::where('fault_id',$fault_list[2]['fault_id'])->value('name');
  58. $row['xianxian_content_name'] = '';
  59. if(!empty($row['xianxian_content']))
  60. {
  61. $row['xianxian_content_name'] = json_decode($row['xianxian_content'],true);
  62. }
  63. $row['yuanyin_content_name'] = '';
  64. if(!empty($row['yuanyin_content']))
  65. {
  66. $row['yuanyin_content_name'] = json_decode($row['yuanyin_content'],true);
  67. }
  68. $row['buwei_content_name'] = '';
  69. if(!empty($row['buwei_content']))
  70. {
  71. $row['buwei_content_name'] = json_decode($row['buwei_content'],true);
  72. }
  73. $row['fangfa_content_name'] = '';
  74. if(!empty($row['fangfa_content']))
  75. {
  76. $row['fangfa_content_name'] = json_decode($row['fangfa_content'],true);
  77. }
  78. $other_report = !empty($row['other_report']) ? json_decode($row['other_report'],true):[];
  79. $this->view->assign('other_report', $other_report);
  80. $this->view->assign('row', $row);
  81. return $this->view->fetch();
  82. }
  83. }