123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- namespace app\admin\controller\exam;
- use addons\exam\model\QuestionModel;
- use app\common\controller\Backend;
- class RoomGrade extends Backend
- {
- protected $noNeedRight = ['index'];
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\exam\RoomGradeModel;
- $this->view->assign("isPassList", $this->model->getIsPassList());
- $this->view->assign("isMakeupList", $this->model->getIsMakeupList());
- }
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['user', 'cate', 'room', 'paper', 'signup1'])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
- $row->getRelation('user')->visible(['nickname']);
- $row->getRelation('cate')->visible(['name']);
- $row->getRelation('room')->visible(['name']);
- $row->getRelation('paper')->visible(['title']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
-
- public function detail($ids = null)
- {
- $row = $this->model->get($ids, ['user', 'paper', 'cate']);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- $adminIds = $this->getDataLimitAdminIds();
- if (is_array($adminIds)) {
- if (!in_array($row[$this->dataLimitField], $adminIds)) {
- $this->error(__('You have no permission'));
- }
- }
- if (
- (!isset($row['question_ids']) || !$row['question_ids']) ||
- (!isset($row['user_answers']) || !$row['user_answers']) ||
- (!isset($row['configs']) || !$row['configs'])
- ) {
- $this->error('答卷数据缺少,无法查看(可能是旧版本未记录数据导致)');
- }
- $row['questions'] = QuestionModel::whereIn('id', $row['question_ids'])->orderRaw("find_in_set(id, '" . $row['question_ids'] . "')")->select();
- $row['user_answers'] = json_decode($row['user_answers'], true);
- $row['configs'] = json_decode($row['configs'], true);
- $row['createtime_text'] = date('Y-m-d H:i:s', $row['createtime']);
- $this->view->assign("row", $row);
- return $this->view->fetch();
- }
- }
|