12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php namespace App\Http\Controllers\Api\Video;
- use App\Http\Controllers\Api\Api;
- use App\Models\Video\ExamAnswer as Model;
- use App\Models\Video\Answer as VideoAnswer;
- use App\Models\Video\Question as VideoQuestion;
- /**
- * 课程
- *
- * @author 刘相欣
- *
- */
- class ExamAnswer extends Api{
-
-
- /**
- * 获取答题记录 /api/video_learn_answer/get_list
- *
- */
- public function get_list(Model $Model,VideoQuestion $VideoQuestion,VideoAnswer $VideoAnswer){
- // 用户登录
- $uid = $this->checkLogin();
- // 接收参数
- $recordId = request('record_id',0);
- // 如果不是课中习题
- if( !$recordId ) return json_send(['code'=>'error','msg'=>'请选择评测记录']);
- // 查询答题记录
- $answerList = $Model->query()
- ->where([['custom_uid','=',$uid],['record_id','=',$recordId]])
- ->select(['id','record_id','course_id','question_id','answer_id','is_answer','get_score'])
- ->get()->toArray();
- // 循环答题
- foreach ($answerList as $key => $value) {
- // 题目标题
- $value['question_title']= $VideoQuestion->getOne($value['question_id'],'title');
- $value['answer_list'] = $VideoAnswer->getListByQuestion($value['question_id']);
- $value['answer_list'] = array_values($value['answer_list']);
- // 重组
- $answerList[$key] = $value;
- }
- // 返回结果
- return json_send(['code'=>'success','msg'=>'获取成功','data'=>$answerList]);
- }
- }
|