练习页面

This commit is contained in:
flower 2019-01-10 01:31:10 +08:00
parent 3054b861e7
commit 55f1cc845d
7 changed files with 112 additions and 31 deletions

View File

@ -1,9 +1,7 @@
package com.ruoyi.exam.controller;
import com.ruoyi.exam.domain.ExamPractice;
import com.ruoyi.exam.domain.ExamPracticeQuestion;
import com.ruoyi.exam.domain.ExamPracticeQuestionVO;
import com.ruoyi.exam.domain.ExamQuestion;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.exam.domain.*;
import com.ruoyi.exam.service.IExamPracticeQuestionService;
import com.ruoyi.exam.service.IExamPracticeService;
import com.ruoyi.exam.service.IExamQuestionService;
@ -13,8 +11,7 @@ import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
/**
* Created by flower on 2019/1/9.
@ -35,23 +32,42 @@ public class ApiPracticeController extends BaseController {
@PostMapping("/list")
public TableDataInfo list(ExamPractice examPractice) {
public AjaxResult list(ExamPractice examPractice) {
List<ExamPractice> list = examPracticeService.selectListFromWeb(examPractice);
return getDataTable( list );
AjaxResult success = success("查询成功");
success.put("data",list);
return success;
}
@GetMapping("/queryone/question/{id}")
public TableDataInfo queryOne(@PathVariable("id") Integer id) {
ExamPracticeQuestionVO examPracticeQuestion = new ExamPracticeQuestionVO();
examPracticeQuestion.setId(id);
List<ExamPracticeQuestionVO> list = examPracticeQuestionService.selectExamPracticeQuestionList(examPracticeQuestion);
List<String> ids = new ArrayList<>();
for (ExamPracticeQuestionVO item : list) {
ids.add(item.getExamQuestionId().toString());
/**
* 查询练习具体的问题列表
* @param map
* @return
*/
@PostMapping("/queryone/question")
public AjaxResult queryOne(@RequestParam Map<String,Object> map) {
List<ExamQuestionVO> result = examQuestionService.selectQuestionListByPracticeId(map);
if(map.containsKey("disorder")&&map.get("disorder").toString().equals("1")){
Collections.shuffle(result);
}
List<ExamQuestion> result = examQuestionService.selectByIdsPage(ids);
return getDataTable( result );
AjaxResult success = success("查询成功");
success.put("data",result);
return success;
}
@PostMapping("/answer")
public AjaxResult answer(@RequestBody List<Map<String,Object>> answers) {
for (Map<String, Object> answer : answers) {
String questionId = answer.get("questionId").toString();
String userAnswer = answer.get("userAnswer").toString();
ExamQuestion examQuestion = examQuestionService.selectById(questionId);
if(!examQuestion.getAnswer().equals(userAnswer)){
}
}
AjaxResult success = success("查询成功");
return success;
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.exam.domain;
import java.util.List;
/**
* Created by flower on 2019/1/10.
*/
public class ExamQuestionVO extends ExamQuestion{
private List<ExamQuestionItem> questionItem;
public List<ExamQuestionItem> getQuestionItem() {
return questionItem;
}
public void setQuestionItem(List<ExamQuestionItem> questionItem) {
this.questionItem = questionItem;
}
}

View File

@ -2,6 +2,9 @@ package com.ruoyi.exam.mapper;
import com.ruoyi.exam.domain.ExamQuestion;
import java.util.List;
import java.util.Map;
import com.ruoyi.exam.domain.ExamQuestionVO;
import com.ruoyi.framework.web.base.MyMapper;
/**
@ -61,4 +64,6 @@ public interface ExamQuestionMapper extends MyMapper<ExamQuestion>
public int deleteExamQuestionByIds(String[] ids);
List<ExamQuestion> selectListBycategory(ExamQuestion examQuestion);
List<ExamQuestionVO> selectQuestionListByPracticeId(Map<String, Object> map);
}

View File

@ -2,8 +2,10 @@ package com.ruoyi.exam.service;
import com.ruoyi.exam.domain.ExamQuestion;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.ruoyi.exam.domain.ExamQuestionVO;
import com.ruoyi.framework.web.base.AbstractBaseService;
/**
* 问题 服务层
@ -63,5 +65,5 @@ public interface IExamQuestionService extends AbstractBaseService<ExamQuestion>
List<ExamQuestion> selectListBycategory(ExamQuestion examQuestion);
List<ExamQuestion> selectByIdsPage(List<String> ids);
List<ExamQuestionVO> selectQuestionListByPracticeId(Map<String, Object> map);
}

View File

@ -1,10 +1,11 @@
package com.ruoyi.exam.service.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.ruoyi.exam.domain.ExamQuestionItem;
import com.ruoyi.exam.domain.ExamQuestionVO;
import com.ruoyi.exam.mapper.ExamQuestionItemMapper;
import com.ruoyi.framework.web.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -162,14 +163,10 @@ public class ExamQuestionServiceImpl extends AbstractBaseServiceImpl<ExamQuestio
}
@Override
public List<ExamQuestion> selectByIdsPage(List<String> ids) {
StringBuffer sb = new StringBuffer();
for (String id : ids) {
sb.append(id+",");
}
String substring = sb.substring(0, sb.length() - 1);
public List<ExamQuestionVO> selectQuestionListByPracticeId(Map<String, Object> map) {
startPage();
return examQuestionMapper.selectByIds(substring.toString());
return examQuestionMapper.selectQuestionListByPracticeId(map);
}

View File

@ -48,8 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectExamPracticeVo"/>
from exam_practice
<where>
((enable_control_time = '1' and end_time > NOW() and start_time < NOW())
or enable_control_time = '0')
<![CDATA[((enable_control_time = '1' and end_time > now() and start_time < now())
or enable_control_time = '0')]]>
<if test="id != null "> and id = #{id}</if>
<if test="deptId != null "> and dept_id = #{deptId}</if>
<if test="name != null and name != '' "> and name = #{name}</if>

View File

@ -18,6 +18,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remarks" column="remarks" />
<result property="delFlag" column="del_flag" />
</resultMap>
<resultMap type="ExamQuestionVO" id="ExamQuestionResultVO">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="answer" column="answer" />
<result property="type" column="type" />
<result property="label" column="label" />
<result property="categoryId" column="category_id" />
<result property="createBy" column="create_by" />
<result property="createDate" column="create_date" />
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="remarks" column="remarks" />
<result property="delFlag" column="del_flag" />
<collection property="questionItem" ofType="com.ruoyi.exam.domain.ExamQuestionItem">
<result property="id" column="item_id" />
<result property="content" column="item_content" />
<result property="number" column="item_number" />
<result property="examQuestionId" column="item_exam_question_id" />
<result property="createBy" column="item_create_by" />
<result property="createDate" column="item_create_date" />
<result property="updateBy" column="item_update_by" />
<result property="updateDate" column="item_update_date" />
<result property="remarks" column="item_remarks" />
<result property="delFlag" column="item_del_flag" />
</collection>
</resultMap>
<sql id="selectExamQuestionVo">
select id, title, answer, type, label, category_id, create_by, create_date, update_by, update_date, remarks, del_flag from exam_question
@ -41,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectExamQuestionById" parameterType="String" resultMap="ExamQuestionResult">
<select id="selectExamQuestionById" resultMap="ExamQuestionResult">
<include refid="selectExamQuestionVo"/>
where id = #{id}
</select>
@ -66,6 +94,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectQuestionListByPracticeId" resultMap="ExamQuestionResultVO">
select eq.id, eq.title, eq.answer, eq.type, eq.label, eq.category_id,
eq.create_by, eq.create_date, eq.update_by, eq.update_date, eq.remarks, eq.del_flag ,
eqi.id AS item_id,
eqi.content AS item_content,
eqi.number AS item_number,
eqi.exam_question_id AS item_exam_question_id,
eqi.remarks AS item_remarks
from exam_question eq
INNER JOIN exam_practice_question epq ON eq.id = epq.exam_question_id
INNER JOIN exam_question_item eqi ON eqi.exam_question_id = eq.id
where epq.exam_practice_id = #{practiceId}
order by epq.order_num
</select>
<insert id="insertExamQuestion" keyProperty="id" useGeneratedKeys="true" parameterType="ExamQuestion">
insert into exam_question
<trim prefix="(" suffix=")" suffixOverrides=",">