TestPaperQuestions.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\wap\model\topic;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. use service\UtilService as Util;
  15. use app\wap\model\topic\Questions;
  16. use app\wap\model\topic\ExaminationRecord;
  17. use app\wap\model\topic\ExaminationTestRecord;
  18. /**
  19. * 试卷试题 Model
  20. * Class TestPaperQuestions
  21. */
  22. class TestPaperQuestions extends ModelBasic
  23. {
  24. use ModelTrait;
  25. /**获取试卷中的试题
  26. * @param $test_id
  27. * @param $type
  28. * @return array|false|\PDOStatement|string|\think\Collection
  29. * @throws \think\db\exception\DataNotFoundException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. * @throws \think\exception\DbException
  32. */
  33. public static function getQuestionslist($test_id, $type, $question_type = 0)
  34. {
  35. $model = self::alias('p')->join('Questions q', 'p.questions_id=q.id')
  36. ->where(['p.type' => $type, 'p.test_id' => $test_id, 'q.is_del' => 0]);
  37. if ($question_type) {
  38. $model = $model->where('p.question_type', $question_type);
  39. }
  40. $list = $model->field('p.*,q.option,q.stem,q.image,q.answer,q.difficulty,q.analysis,q.relation,q.is_img,q.is_del')
  41. ->order('p.sort desc')->select();
  42. $list = count($list) > 0 ? $list->toArray() : [];
  43. return $list;
  44. }
  45. }