From 26b6a6f0f142e6a833229ac8747d8cd485998f0b Mon Sep 17 00:00:00 2001 From: flower Date: Thu, 10 Jan 2019 02:44:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=83=E4=B9=A0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiPracticeController.java | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ApiPracticeController.java b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ApiPracticeController.java index c589205ac..c26a31432 100644 --- a/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ApiPracticeController.java +++ b/ruoyi-exam/src/main/java/com/ruoyi/exam/controller/ApiPracticeController.java @@ -5,8 +5,10 @@ import com.ruoyi.exam.domain.*; import com.ruoyi.exam.service.IExamPracticeQuestionService; import com.ruoyi.exam.service.IExamPracticeService; import com.ruoyi.exam.service.IExamQuestionService; +import com.ruoyi.exam.service.IExamUserErrorQuestionService; import com.ruoyi.framework.web.base.BaseController; import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.framework.web.util.ShiroUtils; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -30,9 +32,12 @@ public class ApiPracticeController extends BaseController { @Autowired private IExamQuestionService examQuestionService; + @Autowired + private IExamUserErrorQuestionService examUserErrorQuestionService; - @GetMapping("/list") - public AjaxResult list( ExamPractice examPractice) { + + @PostMapping("/list") + public AjaxResult list(@RequestBody ExamPractice examPractice) { List list = examPracticeService.selectListFromWeb(examPractice); AjaxResult success = success("查询成功"); @@ -56,17 +61,57 @@ public class ApiPracticeController extends BaseController { return success; } + /** + * 回答问题 + * @param answers + * @return + */ @PostMapping("/answer") public AjaxResult answer(@RequestBody List> answers) { + int error = 0; for (Map answer : answers) { String questionId = answer.get("questionId").toString(); String userAnswer = answer.get("userAnswer").toString(); ExamQuestion examQuestion = examQuestionService.selectById(questionId); if(!examQuestion.getAnswer().equals(userAnswer)){ - + ExamUserErrorQuestion examUserErrorQuestion = new ExamUserErrorQuestion(); + examUserErrorQuestion.setExamQuestionId(Integer.parseInt(questionId)); + examUserErrorQuestion.setVipUserId(Integer.parseInt(ShiroUtils.getUserId().toString())); + examUserErrorQuestion.setCreateBy(ShiroUtils.getLoginName()); + examUserErrorQuestion.setCreateDate(new Date()); + examUserErrorQuestion.setDelFlag("0"); + examUserErrorQuestionService.insert(examUserErrorQuestion); + error++; } } + AjaxResult success = success(error+"题进入错题本"); + return success; + } + + /** + * 查询错题本列表 + * @return + */ + @GetMapping("/queryerror") + public AjaxResult answer() { + ExamUserErrorQuestion examUserErrorQuestion = new ExamUserErrorQuestion(); + examUserErrorQuestion.setVipUserId(Integer.parseInt(ShiroUtils.getUserId().toString())); + List list = examUserErrorQuestionService.selectExamUserErrorQuestionDetailPage(examUserErrorQuestion); AjaxResult success = success("查询成功"); + success.put("data",list); + return success; + } + + /** + * 查询问题详情 + * @param questionId + * @return + */ + @GetMapping("/queryquestion/{id}") + public AjaxResult queryQuestion(@PathVariable("id") String questionId) { + ExamQuestionVO result = examQuestionService.selectQuestionDetail(questionId); + AjaxResult success = success("查询成功"); + success.put("data",result); return success; }