RoomGrade.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace addons\exam\controller;
  3. use addons\exam\model\BaseModel;
  4. use addons\exam\model\RoomGradeModel;
  5. /**
  6. * 考场考试成绩接口
  7. */
  8. class RoomGrade extends Base
  9. {
  10. protected $noNeedLogin = [''];
  11. protected $noNeedRight = ['*'];
  12. /**
  13. * 获取成绩列表
  14. */
  15. public function index()
  16. {
  17. $list = RoomGradeModel::with(
  18. [
  19. // 'user' => BaseModel::withSimpleUser(),
  20. 'cate' => BaseModel::withSimpleCate(),
  21. 'paper' => BaseModel::withSimplePaper(),
  22. 'room' => BaseModel::withSimpleRoom(),
  23. ]
  24. )
  25. ->where('user_id', $this->auth->id)
  26. ->order('id desc')
  27. ->paginate(15, true);
  28. $this->success('', compact('list'));
  29. }
  30. /**
  31. * 排行榜
  32. */
  33. public function rank()
  34. {
  35. if (!$room_id = input('room_id/d', '0')) {
  36. $this->error('缺少考场信息');
  37. }
  38. $result = RoomGradeModel::rankData($room_id);
  39. $this->success('', $result);
  40. }
  41. }