试卷题目管理
This commit is contained in:
parent
3e0b7c5dbf
commit
f4c4967d54
|
|
@ -1,14 +1,17 @@
|
|||
package com.ruoyi.exam.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.exam.domain.ExamPaperCategory;
|
||||
import com.ruoyi.exam.domain.ExamQuestion;
|
||||
import com.ruoyi.exam.domain.ExamQuestionCategory;
|
||||
import cn.hutool.core.lang.*;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.ruoyi.exam.domain.*;
|
||||
import com.ruoyi.exam.service.IExamPaperCategoryService;
|
||||
import com.ruoyi.exam.service.IExamPaperQuestionService;
|
||||
import com.ruoyi.exam.service.IExamQuestionService;
|
||||
import com.ruoyi.framework.web.util.ShiroUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -17,7 +20,6 @@ import org.springframework.ui.ModelMap;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.exam.domain.ExamPaper;
|
||||
import com.ruoyi.exam.service.IExamPaperService;
|
||||
import com.ruoyi.framework.web.base.BaseController;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
|
|
@ -45,6 +47,9 @@ public class ExamPaperController extends BaseController
|
|||
@Autowired
|
||||
private IExamPaperQuestionService examPaperQuestionService;
|
||||
|
||||
@Autowired
|
||||
private IExamQuestionService examQuestionService;
|
||||
|
||||
@RequiresPermissions("exam:examPaper:view")
|
||||
@GetMapping()
|
||||
public String examPaper()
|
||||
|
|
@ -119,6 +124,8 @@ public class ExamPaperController extends BaseController
|
|||
{
|
||||
examPaper.setCreateBy(ShiroUtils.getLoginName());
|
||||
examPaper.setCreateDate(new Date());
|
||||
examPaper.setScore(0);
|
||||
examPaper.setQuestionNumber(0);
|
||||
examPaper.setDelFlag("0");
|
||||
return toAjax(examPaperService.insert(examPaper));
|
||||
}
|
||||
|
|
@ -162,21 +169,117 @@ public class ExamPaperController extends BaseController
|
|||
|
||||
|
||||
@GetMapping("/addQuestion/{id}")
|
||||
public String addQuestion(@PathVariable("id") Integer id, ModelMap mmap)
|
||||
public String addQuestion(@PathVariable("id") String ids, ModelMap mmap)
|
||||
{
|
||||
mmap.put("examPaperId", id);
|
||||
mmap.put("examPaperQuestionIds",examPaperQuestionService.selectQuestionIdsForPaperId(id));
|
||||
String[] split = ids.split(",");
|
||||
List<String> strings = Arrays.asList(split);
|
||||
mmap.put("examPaperId", strings.get(0));
|
||||
mmap.put("examPaperQuestionIds",strings.subList(1,strings.size()));
|
||||
return prefix + "/examQuestion";
|
||||
}
|
||||
|
||||
@RequiresPermissions("exam:examPaper:remove")
|
||||
@Log(title = "试卷", businessType = BusinessType.DELETE)
|
||||
// @RequiresPermissions("exam:examPaper:add")
|
||||
// @Log(title = "试卷", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/saveQuestion")
|
||||
@ResponseBody
|
||||
public AjaxResult saveQuestion(@RequestParam(value = "questionId[]" ,required = false) String[] questionId,@RequestParam("paperId")String paperId)
|
||||
public AjaxResult saveQuestion(@RequestBody List<ExamPaperQuestion> paperQuestionList)
|
||||
{
|
||||
|
||||
return toAjax(examPaperQuestionService.saveQuestion(paperId,questionId));
|
||||
ExamPaperQuestion examPaperQuestion = paperQuestionList.get(0);
|
||||
ExamPaperQuestion delete = new ExamPaperQuestion();
|
||||
delete.setExamPaperId(examPaperQuestion.getExamPaperId());
|
||||
ExamPaper examPaper = new ExamPaper();
|
||||
examPaper.setId(examPaperQuestion.getExamPaperId());
|
||||
examPaperQuestionService.delete(delete);
|
||||
int num =0;
|
||||
int score = 0;
|
||||
for (int i = 1; i < paperQuestionList.size(); i++) {
|
||||
ExamPaperQuestion item = paperQuestionList.get(i);
|
||||
item.setDelFlag("0");
|
||||
examPaperQuestionService.insert(item);
|
||||
num++;
|
||||
score+=item.getScore();
|
||||
}
|
||||
examPaper.setQuestionNumber(num);
|
||||
examPaper.setScore(score);
|
||||
examPaperService.updateSelectiveById(examPaper);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/toManagerPaperQuestion/{id}")
|
||||
public String toManagerPaperQuestion(@PathVariable("id") Integer id, ModelMap mmap)
|
||||
{
|
||||
mmap.put("examPaper", examPaperService.selectById(id));
|
||||
JSONObject json = new JSONObject();
|
||||
List<ExamPaperQuestionVO> examPaperQuestions = examPaperQuestionService.selectQuestionForPaperId(id);
|
||||
for (ExamPaperQuestionVO examPaperQuestion : examPaperQuestions) {
|
||||
//排序用
|
||||
json.append(examPaperQuestion.getOrderNum().toString()+examPaperQuestion.getExamQuestionId().toString(),new JSONObject(examPaperQuestion).toString());
|
||||
}
|
||||
mmap.put("examPaperQuestion",json.toString());
|
||||
return prefix + "/managerPaperQuestion";
|
||||
}
|
||||
|
||||
@RequiresPermissions("exam:examPaper:add")
|
||||
@Log(title = "试卷", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/addQuestionForModel")
|
||||
@ResponseBody
|
||||
public AjaxResult addQuestionForModel(@RequestParam(value = "questionId[]" ,required = false) String[] questionId,@RequestParam("paperId")String paperId)
|
||||
{
|
||||
//题目数量和总分数
|
||||
int questionNum = 0;
|
||||
int score = 0;
|
||||
ExamPaperQuestion examPaperQuestion = new ExamPaperQuestion();
|
||||
examPaperQuestion.setExamPaperId(Integer.parseInt(paperId));
|
||||
ExamPaper examPaper = new ExamPaper();
|
||||
if(questionId==null){
|
||||
examPaperQuestionService.delete(examPaperQuestion);
|
||||
examPaper.setId(Integer.parseInt(paperId));
|
||||
examPaper.setQuestionNumber(0);
|
||||
examPaper.setScore(0);
|
||||
examPaperService.updateSelectiveById(examPaper);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
List<ExamPaperQuestionVO> dbDatas = examPaperQuestionService.selectExamPaperQuestionList(examPaperQuestion);
|
||||
questionNum +=dbDatas.size();
|
||||
HashSet<Integer> dbSet = new HashSet<>();
|
||||
for (ExamPaperQuestionVO dbData : dbDatas) {
|
||||
dbSet.add(dbData.getExamQuestionId());
|
||||
score+=dbData.getScore();
|
||||
}
|
||||
|
||||
HashSet<Integer> htmlSet = new HashSet<>();
|
||||
//新增的
|
||||
for (String s : questionId) {
|
||||
Integer i = Integer.parseInt(s);
|
||||
if(!dbSet.contains(i)){
|
||||
ExamPaperQuestion insert = new ExamPaperQuestion();
|
||||
insert.setExamPaperId(Integer.parseInt(paperId));
|
||||
insert.setDelFlag("0");
|
||||
insert.setCreateDate(new Date());
|
||||
insert.setCreateBy(ShiroUtils.getLoginName());
|
||||
insert.setExamQuestionId(i);
|
||||
insert.setOrderNum(9999);
|
||||
insert.setScore(0);
|
||||
examPaperQuestionService.insert(insert);
|
||||
questionNum++;
|
||||
}
|
||||
htmlSet.add(i);
|
||||
}
|
||||
|
||||
for (ExamPaperQuestionVO dbData : dbDatas) {
|
||||
if(!htmlSet.contains(dbData.getExamQuestionId())){
|
||||
examPaperQuestionService.delete(dbData);
|
||||
questionNum--;
|
||||
score-=dbData.getScore();
|
||||
}
|
||||
}
|
||||
|
||||
examPaper.setId(Integer.parseInt(paperId));
|
||||
examPaper.setQuestionNumber(questionNum);
|
||||
examPaper.setScore(score);
|
||||
examPaperService.updateSelectiveById(examPaper);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,29 @@ private static final long serialVersionUID = 1L;
|
|||
/** 删除标记 */
|
||||
private String delFlag;
|
||||
|
||||
/** 设置试卷题目ID */
|
||||
private Integer score;
|
||||
|
||||
private Integer orderNum;
|
||||
|
||||
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Integer score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
/** 设置试卷题目ID */
|
||||
public void setId(Integer id)
|
||||
{
|
||||
this.id = id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.ruoyi.exam.domain;
|
||||
|
||||
/**
|
||||
* Created by flower on 2018/12/23.
|
||||
*/
|
||||
public class ExamPaperQuestionVO extends ExamPaperQuestion {
|
||||
|
||||
private Integer questionType;
|
||||
|
||||
private String questionName;
|
||||
|
||||
public Integer getQuestionType() {
|
||||
return questionType;
|
||||
}
|
||||
|
||||
public void setQuestionType(Integer questionType) {
|
||||
this.questionType = questionType;
|
||||
}
|
||||
|
||||
public String getQuestionName() {
|
||||
return questionName;
|
||||
}
|
||||
|
||||
public void setQuestionName(String questionName) {
|
||||
this.questionName = questionName;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package com.ruoyi.exam.mapper;
|
|||
|
||||
import com.ruoyi.exam.domain.ExamPaperQuestion;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.exam.domain.ExamPaperQuestionVO;
|
||||
import com.ruoyi.framework.web.base.MyMapper;
|
||||
|
||||
/**
|
||||
|
|
@ -19,6 +21,7 @@ public interface ExamPaperQuestionMapper extends MyMapper<ExamPaperQuestion>
|
|||
* @param examPaperQuestion 试卷题目信息
|
||||
* @return 试卷题目集合
|
||||
*/
|
||||
public List<ExamPaperQuestion> selectExamPaperQuestionList(ExamPaperQuestion examPaperQuestion);
|
||||
public List<ExamPaperQuestionVO> selectExamPaperQuestionList(ExamPaperQuestion examPaperQuestion);
|
||||
|
||||
List<ExamPaperQuestion> selectquestionByIds(List<String> ids);
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package com.ruoyi.exam.service;
|
|||
|
||||
import com.ruoyi.exam.domain.ExamPaperQuestion;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.exam.domain.ExamPaperQuestionVO;
|
||||
import com.ruoyi.framework.web.base.AbstractBaseService;
|
||||
/**
|
||||
* 试卷题目 服务层
|
||||
|
|
@ -17,17 +19,22 @@ public interface IExamPaperQuestionService extends AbstractBaseService<ExamPaper
|
|||
* @param examPaperQuestion 试卷题目信息
|
||||
* @return 试卷题目集合
|
||||
*/
|
||||
public List<ExamPaperQuestion> selectExamPaperQuestionPage(ExamPaperQuestion examPaperQuestion);
|
||||
public List<ExamPaperQuestionVO> selectExamPaperQuestionPage(ExamPaperQuestion examPaperQuestion);
|
||||
/**
|
||||
* 查询试卷题目列表
|
||||
*
|
||||
* @param examPaperQuestion 试卷题目信息
|
||||
* @return 试卷题目集合
|
||||
*/
|
||||
public List<ExamPaperQuestion> selectExamPaperQuestionList(ExamPaperQuestion examPaperQuestion);
|
||||
public List<ExamPaperQuestionVO> selectExamPaperQuestionList(ExamPaperQuestion examPaperQuestion);
|
||||
|
||||
|
||||
int saveQuestion(String paperId, String[] questionId);
|
||||
|
||||
List<String> selectQuestionIdsForPaperId(Integer id);
|
||||
|
||||
List<ExamPaperQuestionVO> selectQuestionForPaperId(Integer id);
|
||||
|
||||
List<ExamPaperQuestion> selectquestionByIds(List<String> ids);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,4 +54,6 @@ public interface IExamQuestionService extends AbstractBaseService<ExamQuestion>
|
|||
int insertQuestion(ExamQuestion examQuestion, String[] number, String[] content);
|
||||
|
||||
int updateQuestion(ExamQuestion examQuestion, String[] number, String[] content);
|
||||
|
||||
List<ExamQuestion> selectByIds(List<String> ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,13 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.exam.domain.ExamPaper;
|
||||
import com.ruoyi.exam.mapper.ExamPaperMapper;
|
||||
import com.ruoyi.exam.domain.ExamPaperQuestionVO;
|
||||
import com.ruoyi.framework.web.util.ShiroUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.exam.mapper.ExamPaperQuestionMapper;
|
||||
import com.ruoyi.exam.domain.ExamPaperQuestion;
|
||||
import com.ruoyi.exam.service.IExamPaperQuestionService;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
|
||||
/**
|
||||
* 试卷题目 服务层实现
|
||||
|
|
@ -35,7 +33,7 @@ public class ExamPaperQuestionServiceImpl extends AbstractBaseServiceImpl<ExamPa
|
|||
* @return 试卷题目集合
|
||||
*/
|
||||
@Override
|
||||
public List<ExamPaperQuestion> selectExamPaperQuestionList(ExamPaperQuestion examPaperQuestion)
|
||||
public List<ExamPaperQuestionVO> selectExamPaperQuestionList(ExamPaperQuestion examPaperQuestion)
|
||||
{
|
||||
return examPaperQuestionMapper.selectExamPaperQuestionList(examPaperQuestion);
|
||||
}
|
||||
|
|
@ -69,15 +67,30 @@ public class ExamPaperQuestionServiceImpl extends AbstractBaseServiceImpl<ExamPa
|
|||
public List<String> selectQuestionIdsForPaperId(Integer id) {
|
||||
ExamPaperQuestion examPaperQuestion = new ExamPaperQuestion();
|
||||
examPaperQuestion.setExamPaperId(id);
|
||||
List<ExamPaperQuestion> examPaperQuestions = examPaperQuestionMapper.selectExamPaperQuestionList(examPaperQuestion);
|
||||
List<ExamPaperQuestionVO> examPaperQuestions = examPaperQuestionMapper.selectExamPaperQuestionList(examPaperQuestion);
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (ExamPaperQuestion paperQuestion : examPaperQuestions) {
|
||||
for (ExamPaperQuestionVO paperQuestion : examPaperQuestions) {
|
||||
ids.add(paperQuestion.getExamQuestionId().toString());
|
||||
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExamPaperQuestionVO> selectQuestionForPaperId(Integer id) {
|
||||
ExamPaperQuestion examPaperQuestion = new ExamPaperQuestion();
|
||||
examPaperQuestion.setExamPaperId(id);
|
||||
List<ExamPaperQuestionVO> examPaperQuestions = examPaperQuestionMapper.selectExamPaperQuestionList(examPaperQuestion);
|
||||
return examPaperQuestions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExamPaperQuestion> selectquestionByIds(List<String> ids) {
|
||||
return examPaperQuestionMapper.selectquestionByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询试卷题目分页列表
|
||||
*
|
||||
|
|
@ -85,7 +98,7 @@ public class ExamPaperQuestionServiceImpl extends AbstractBaseServiceImpl<ExamPa
|
|||
* @return 试卷题目集合
|
||||
*/
|
||||
@Override
|
||||
public List<ExamPaperQuestion> selectExamPaperQuestionPage(ExamPaperQuestion examPaperQuestion)
|
||||
public List<ExamPaperQuestionVO> selectExamPaperQuestionPage(ExamPaperQuestion examPaperQuestion)
|
||||
{
|
||||
startPage();
|
||||
return examPaperQuestionMapper.selectExamPaperQuestionList(examPaperQuestion);
|
||||
|
|
|
|||
|
|
@ -140,4 +140,14 @@ public class ExamQuestionServiceImpl extends AbstractBaseServiceImpl<ExamQuestio
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExamQuestion> selectByIds(List<String> ids) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String id : ids) {
|
||||
sb.append(id+",");
|
||||
}
|
||||
String substring = sb.substring(0, sb.length() - 1);
|
||||
return examQuestionMapper.selectByIds(substring.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.exam.mapper.ExamPaperQuestionMapper">
|
||||
|
||||
<resultMap type="ExamPaperQuestion" id="ExamPaperQuestionResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="examPaperId" column="exam_paper_id" />
|
||||
<result property="examQuestionId" column="exam_question_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" />
|
||||
<resultMap type="ExamPaperQuestionVO" id="ExamPaperQuestionResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="examPaperId" column="exam_paper_id"/>
|
||||
<result property="examQuestionId" column="exam_question_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"/>
|
||||
<result property="score" column="score"/>
|
||||
<result property="orderNum" column="order_num"/>
|
||||
<result property="questionName" column="name"/>
|
||||
<result property="questionType" column="type"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectExamPaperQuestionVo">
|
||||
id, exam_paper_id, exam_question_id, create_by, create_date, update_by, update_date, remarks, del_flag </sql>
|
||||
<sql id="selectExamPaperQuestionVo">
|
||||
epq.id, epq.exam_paper_id, epq.exam_question_id, epq.create_by, epq.create_date, epq.update_by, epq.update_date, epq.remarks, epq.del_flag,epq.score,epq.order_num </sql>
|
||||
|
||||
<select id="selectExamPaperQuestionList" parameterType="ExamPaperQuestion" resultMap="ExamPaperQuestionResult">
|
||||
select
|
||||
<include refid="selectExamPaperQuestionVo"/>
|
||||
from exam_paper_question
|
||||
<include refid="selectExamPaperQuestionVo"/>,eq.title as name,eq.type as type
|
||||
from exam_paper_question epq
|
||||
INNER JOIN exam_question eq on epq.exam_question_id = eq.id
|
||||
<where>
|
||||
<if test="id != null "> and id = #{id}</if>
|
||||
<if test="examPaperId != null "> and exam_paper_id = #{examPaperId}</if>
|
||||
<if test="examQuestionId != null "> and exam_question_id = #{examQuestionId}</if>
|
||||
<if test="createBy != null and createBy != '' "> and create_by = #{createBy}</if>
|
||||
<if test="createDate != null "> and create_date = #{createDate}</if>
|
||||
<if test="updateBy != null and updateBy != '' "> and update_by = #{updateBy}</if>
|
||||
<if test="updateDate != null "> and update_date = #{updateDate}</if>
|
||||
<if test="remarks != null and remarks != '' "> and remarks = #{remarks}</if>
|
||||
<if test="delFlag != null and delFlag != '' "> and del_flag = #{delFlag}</if>
|
||||
</where>
|
||||
<if test="id != null ">and id = #{id}</if>
|
||||
<if test="examPaperId != null ">and epq.exam_paper_id = #{examPaperId}</if>
|
||||
<if test="examQuestionId != null ">and epq.exam_question_id = #{examQuestionId}</if>
|
||||
<if test="createBy != null and createBy != '' ">and epq.create_by = #{createBy}</if>
|
||||
<if test="createDate != null ">and epq.create_date = #{createDate}</if>
|
||||
<if test="updateBy != null and updateBy != '' ">and epq.update_by = #{updateBy}</if>
|
||||
<if test="updateDate != null ">and epq.update_date = #{updateDate}</if>
|
||||
<if test="remarks != null and remarks != '' ">and epq.remarks = #{remarks}</if>
|
||||
<if test="delFlag != null and delFlag != '' ">and epq.del_flag = #{delFlag}</if>
|
||||
</where>
|
||||
order by order_num
|
||||
</select>
|
||||
<select id="selectquestionByIds" resultMap="ExamPaperQuestionResult">
|
||||
select
|
||||
<include refid="selectExamPaperQuestionVo"/>,eq.title as name,eq.type as type
|
||||
from exam_paper_question epq
|
||||
INNER JOIN exam_question eq on epq.exam_question_id = eq.id
|
||||
where epq.exam_question_id in
|
||||
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
<input id="name" name="name" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">试卷类型(1-固定试卷;2-随机试卷):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="type" name="type" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="form-group"> -->
|
||||
<!--<label class="col-sm-3 control-label">试卷类型(1-固定试卷;2-随机试卷):</label>-->
|
||||
<!--<div class="col-sm-8">-->
|
||||
<!--<input id="type" name="type" class="form-control" type="text">-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">备注信息:</label>
|
||||
<div class="col-sm-8">
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">试卷类型:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="type" name="type" th:field="*{type}" class="form-control" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="form-group"> -->
|
||||
<!--<label class="col-sm-3 control-label">试卷类型:</label>-->
|
||||
<!--<div class="col-sm-8">-->
|
||||
<!--<input id="type" name="type" th:field="*{type}" class="form-control" type="text">-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">备注信息:</label>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
</div>
|
||||
<div class="box-tools pull-right">
|
||||
<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="examPaperCategory()"
|
||||
title="题库管理"><i
|
||||
title="试卷分类管理"><i
|
||||
class="fa fa-edit"></i></a>
|
||||
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
|
||||
class="fa fa-chevron-up"></i></button>
|
||||
|
|
@ -121,11 +121,7 @@
|
|||
title: '名称',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '试卷类型(1-固定试卷;2-随机试卷)',
|
||||
sortable: true
|
||||
},
|
||||
|
||||
{
|
||||
field: 'score',
|
||||
title: '总分数',
|
||||
|
|
@ -158,7 +154,7 @@
|
|||
formatter: function (value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="addQuestion(\'' + row.id + '\')"><i class="fa fa-edit"></i>添加试题</a> ');
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="toPaperquestion(\'' + row.id + '\')"><i class="fa fa-edit"></i>管理试题</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
|
|
@ -209,6 +205,10 @@
|
|||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
if($("#examPaperCategoryId").val()==1){
|
||||
$.modal.alertWarning("请选择试卷分类");
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/add/"+$("#examPaperCategoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加试卷",url);
|
||||
}
|
||||
|
|
@ -217,6 +217,12 @@
|
|||
var url = prefix + "/addQuestion/"+id;
|
||||
$.operate.jumpModeltoUrl("添加试题",url,1000,600);
|
||||
}
|
||||
|
||||
|
||||
function toPaperquestion(id) {
|
||||
var url = ctx + "exam/examPaper/toManagerPaperQuestion/"+id;
|
||||
createMenuItem(url, "试卷题目管理");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -76,11 +76,14 @@
|
|||
<script th:inline="javascript">
|
||||
var editFlag = [[${@permission.hasPermi('exam:examQuestion:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('exam:examQuestion:remove')}]];
|
||||
var type = [[${@dict.getType('exam_question_type')}]];
|
||||
var prefix = ctx + "exam/examQuestion";
|
||||
var overAllIds = new Array();
|
||||
$(function () {
|
||||
$('body').layout({west__size: 150});
|
||||
queryExamQuestionList();
|
||||
$("#categoryId").val(1);
|
||||
$.table.search();
|
||||
queryExamQuestionCategoryTree();
|
||||
debugger;
|
||||
overAllIds = [[${examPaperQuestionIds}]];
|
||||
|
|
@ -111,33 +114,27 @@
|
|||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
sortable: true
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '问题标题',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'answer',
|
||||
title: '问题答案',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '问题类型',
|
||||
sortable: true
|
||||
formatter: function(value, item, index) {
|
||||
debugger
|
||||
return $.table.selectDictLabel(type, item.type);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createBy',
|
||||
title: '创建者',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'remarks',
|
||||
title: '备注信息',
|
||||
sortable: true
|
||||
}]
|
||||
}
|
||||
]
|
||||
// {
|
||||
// title: '操作',
|
||||
// align: 'center',
|
||||
|
|
@ -162,9 +159,7 @@
|
|||
$.tree.init(options);
|
||||
|
||||
function zOnClick(event, treeId, treeNode) {
|
||||
if (treeNode.pId == 1 || treeNode.pId == 0 || treeNode.pId == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$("#categoryId").val(treeNode.id);
|
||||
$.table.search();
|
||||
}
|
||||
|
|
@ -193,32 +188,7 @@
|
|||
createMenuItem(url, "题库管理");
|
||||
}
|
||||
|
||||
function addChoiceQuestion() {
|
||||
if ($("#categoryId").val() == null || $("#categoryId").val() == '') {
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/choiceadd/" + $("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加单选题", url);
|
||||
}
|
||||
|
||||
function addMoreChoiceQuestion() {
|
||||
if ($("#categoryId").val() == null || $("#categoryId").val() == '') {
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/morechoiceadd/" + $("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题", url);
|
||||
}
|
||||
|
||||
function addJudgeQuestion() {
|
||||
if ($("#categoryId").val() == null || $("#categoryId").val() == '') {
|
||||
alert("请选择题库!")
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/judgeadd/" + $("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题", url);
|
||||
}
|
||||
|
||||
var overAllIds = new Array(); //全局数组
|
||||
function getSelectCheck() {
|
||||
|
|
@ -248,7 +218,7 @@
|
|||
|
||||
function submitHandler() {
|
||||
debugger
|
||||
$.operate.save(ctx + "exam/examPaper"+ "/saveQuestion",$.param({questionId:overAllIds,paperId:$("#examPaperId").val()}));
|
||||
$.operate.save(ctx + "exam/examPaper"+ "/addQuestionForModel",$.param({questionId:overAllIds,paperId:$("#examPaperId").val()}));
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,239 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<meta charset="utf-8">
|
||||
<head th:include="include :: header"></head>
|
||||
<link th:href="@{/ruoyi/css/ry-ui.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/ajax/libs/datapicker/datepicker3.css}" rel="stylesheet"/>
|
||||
<style>
|
||||
.droppable-active {
|
||||
background-color: #ffe !important
|
||||
}
|
||||
|
||||
.tools a {
|
||||
cursor: pointer;
|
||||
font-size: 80%
|
||||
}
|
||||
|
||||
.form-body .col-md-6, .form-body .col-md-12 {
|
||||
min-height: 400px
|
||||
}
|
||||
|
||||
.draggable {
|
||||
cursor: move
|
||||
}
|
||||
</style>
|
||||
<body class="gray-bg">
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<input type="hidden" id="paperId" th:value="${examPaper.id}">
|
||||
<input type="hidden" id="paperScore" th:value="${examPaper.score}">
|
||||
<input type="hidden" id="paperName" th:value="${examPaper.name}">
|
||||
<input type="hidden" id="paperQuestion" th:value="${examPaperQuestion}">
|
||||
<input type="hidden" id="paperQuestionNumber" th:value="${examPaper.questionNumber}">
|
||||
<div class="form-group draggable">
|
||||
<button onclick="addQuestion()" class="btn btn-warning" >添加试题</button>
|
||||
<button onclick="saveQuestion(true)" class="btn btn-success" >保存</button>
|
||||
</div>
|
||||
<div class="form-group draggable">
|
||||
设置默认单选题分数:
|
||||
<input onkeyup="defaultScore(1,$(this))" type="text" size="4">
|
||||
</div>
|
||||
<div class="form-group draggable">
|
||||
设置默认多选题分数:
|
||||
<input onkeyup="defaultScore(2,$(this))" type="text" size="4">
|
||||
</div>
|
||||
<div class="form-group draggable">
|
||||
设置默认选择题分数:
|
||||
<input onkeyup="defaultScore(3,$(this))" type="text" size="4">
|
||||
</div>
|
||||
|
||||
<div class="form-group draggable">
|
||||
试卷名称:<label id="name"></label>
|
||||
</div>
|
||||
|
||||
<div class="form-group draggable">
|
||||
题目数量:<label id="number"></label>
|
||||
</div>
|
||||
|
||||
<div class="form-group draggable">
|
||||
总分数:<label id="score"></label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50%">题目</th>
|
||||
<th>题型</th>
|
||||
<th>分数</th>
|
||||
<th>向上移动</th>
|
||||
<th>向上移动</th>
|
||||
<th>删除</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div th:include="include :: footer"></div>
|
||||
<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
|
||||
<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
|
||||
<script th:src="@{/ajax/libs//datapicker/bootstrap-datepicker.js}"></script>
|
||||
<script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){setup_draggable();$("#n-columns").on("change",function(){var v=$(this).val();if(v==="1"){var $col=$(".form-body .col-md-12").toggle(true);$(".form-body .col-md-6 .draggable").each(function(i,el){$(this).remove().appendTo($col)});$(".form-body .col-md-6").toggle(false)}else{var $col=$(".form-body .col-md-6").toggle(true);$(".form-body .col-md-12 .draggable").each(function(i,el){$(this).remove().appendTo(i%2?$col[1]:$col[0])});$(".form-body .col-md-12").toggle(false)}});$("#copy-to-clipboard").on("click",function(){var $copy=$(".form-body").clone().appendTo(document.body);$copy.find(".tools, :hidden").remove();$.each(["draggable","droppable","sortable","dropped","ui-sortable","ui-draggable","ui-droppable","form-body"],function(i,c){$copy.find("."+c).removeClass(c).removeAttr("style")});var html=html_beautify($copy.html());$copy.remove();$modal=get_modal(html).modal("show");$modal.find(".btn").remove();$modal.find(".modal-title").html("复制HTML代码");$modal.find(":input:first").select().focus();return false})});var setup_draggable=function(){$(".draggable").draggable({appendTo:"body",helper:"clone"});$(".droppable").droppable({accept:".draggable",helper:"clone",hoverClass:"droppable-active",drop:function(event,ui){$(".empty-form").remove();var $orig=$(ui.draggable);if(!$(ui.draggable).hasClass("dropped")){var $el=$orig.clone().addClass("dropped").css({"position":"static","left":null,"right":null}).appendTo(this);var id=$orig.find(":input").attr("id");if(id){id=id.split("-").slice(0,-1).join("-")+"-"+(parseInt(id.split("-").slice(-1)[0])+1);$orig.find(":input").attr("id",id);$orig.find("label").attr("for",id)}$('<p class="tools col-sm-12 col-sm-offset-3"> <a class="edit-link">编辑HTML<a> | <a class="remove-link">移除</a></p>').appendTo($el)}else{if($(this)[0]!=$orig.parent()[0]){var $el=$orig.clone().css({"position":"static","left":null,"right":null}).appendTo(this);$orig.remove()}}}}).sortable()};var get_modal=function(content){var modal=$('<div class="modal" style="overflow: auto;" tabindex="-1"> <div class="modal-dialog"><div class="modal-content"><div class="modal-header"><a type="button" class="close" data-dismiss="modal" aria-hidden="true">×</a><h4 class="modal-title">编辑HTML</h4></div><div class="modal-body ui-front"> <textarea class="form-control" style="min-height: 200px; margin-bottom: 10px;font-family: Monaco, Fixed">'+content+'</textarea><button class="btn btn-success">更新HTML</button></div> </div></div></div>').appendTo(document.body);return modal};$(document).on("click",".edit-link",function(ev){var $el=$(this).parent().parent();var $el_copy=$el.clone();var $edit_btn=$el_copy.find(".edit-link").parent().remove();var $modal=get_modal(html_beautify($el_copy.html())).modal("show");$modal.find(":input:first").focus();$modal.find(".btn-success").click(function(ev2){var html=$modal.find("textarea").val();if(!html){$el.remove()}else{$el.html(html);$edit_btn.appendTo($el)}$modal.modal("hide");return false})});$(document).on("click",".remove-link",function(ev){$(this).parent().parent().remove()});
|
||||
$(".input-group.date").datepicker({todayBtn: "linked",keyboardNavigation: !1,forceParse: !1,calendarWeeks: !0,autoclose: !0});
|
||||
var prefix = ctx + "exam/examPaper";
|
||||
var questionArr = new Array();
|
||||
$(function () {
|
||||
$("#name").html($("#paperName").val())
|
||||
$("#number").html($("#paperQuestionNumber").val())
|
||||
$("#score").html($("#paperScore").val())
|
||||
debugger
|
||||
questionArr = $.parseJSON($("#paperQuestion").val())
|
||||
var questionOfTable = '';
|
||||
|
||||
|
||||
debugger
|
||||
for (var i in questionArr) {
|
||||
var item = $.parseJSON(questionArr[i][0])
|
||||
questionOfTable+="<tr class = 'questionItem'><th>"+item.questionName+"</th>"
|
||||
questionOfTable+="<input class = 'itemId' type='hidden' value='"+item.examQuestionId+"'>"
|
||||
questionOfTable+="<input class = 'itemType' type='hidden' value='"+item.questionType+"'>"
|
||||
questionOfTable+="<th>"+formatType(item.questionType)+"</th>"
|
||||
questionOfTable+="<th><input onkeyup='changeScore($(this))'class = 'itemScore' type='text' size='3' value='"+item.score+"'></th>"
|
||||
questionOfTable+="<th><button onclick='moveUp($(this))' class='badge badge-primary'>" + "上移" + "</button></th>"
|
||||
questionOfTable+="<th><button onclick='moveDown($(this))' class='badge badge-primary'>" + "下移" + "</button></th>"
|
||||
questionOfTable+="<th><button onclick='deleteObj($(this))' class='badge badge-delete'>" + "删除" + "</button></th></tr>"
|
||||
}
|
||||
$("tbody").html(questionOfTable)
|
||||
})
|
||||
|
||||
function formatType(questionType) {
|
||||
switch (questionType+""){
|
||||
case "1" : return "<span class='badge badge-primary'>" + "单选题" + "</span>"
|
||||
case "2" : return "<span class='badge badge-important'>" + "多选题" + "</span>"
|
||||
case "3" : return "<span class='badge badge-success'>" + "选择题" + "</span>"
|
||||
}
|
||||
}
|
||||
|
||||
function moveUp(obj) {
|
||||
var me = obj.parent("th").parent(".questionItem");
|
||||
var meHtml = obj.parent("th").parent(".questionItem").html();
|
||||
var up = obj.parent("th").parent(".questionItem").prev(".questionItem");
|
||||
var upHtml = obj.parent("th").parent(".questionItem").prev(".questionItem").html();
|
||||
me.html(upHtml);
|
||||
up.html(meHtml);
|
||||
|
||||
}
|
||||
|
||||
function moveDown(obj) {
|
||||
var me = obj.parent("th").parent(".questionItem");
|
||||
var meHtml = obj.parent("th").parent(".questionItem").html();
|
||||
var up = obj.parent("th").parent(".questionItem").next(".questionItem");
|
||||
var upHtml = obj.parent("th").parent(".questionItem").next(".questionItem").html();
|
||||
me.html(upHtml);
|
||||
up.html(meHtml);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function changeScore(obj) {
|
||||
obj.parent("th").html("<input onkeyup='changeScore($(this))'class = 'itemScore' type='text' size='3' value='"+obj.val()+"'>")
|
||||
var scorc = 0
|
||||
$(".questionItem").each(function(){
|
||||
scorc += parseInt($(this).find(".itemScore").eq(0).val());
|
||||
})
|
||||
$("#score").html(scorc)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function defaultScore(type,obj) {
|
||||
|
||||
$(".questionItem").each(function(){
|
||||
debugger
|
||||
var t = $(this).find(".itemType").eq(0).val()
|
||||
if(type == t){
|
||||
$(this).find(".itemScore").eq(0).parent("th").html("<input onkeyup='changeScore($(this))'class = 'itemScore' type='text' size='3' value='"+obj.val()+"'>")
|
||||
}
|
||||
})
|
||||
var scorc = 0
|
||||
$(".questionItem").each(function(){
|
||||
scorc += parseInt($(this).find(".itemScore").eq(0).val());
|
||||
})
|
||||
$("#score").html(scorc)
|
||||
|
||||
}
|
||||
|
||||
function deleteObj(obj) {
|
||||
var me = obj.parent("th").parent(".questionItem");
|
||||
me.remove()
|
||||
var scorc = 0
|
||||
$(".questionItem").each(function(){
|
||||
scorc += parseInt($(this).find(".itemScore").eq(0).val());
|
||||
})
|
||||
$("#score").html(scorc)
|
||||
$("#number").html(parseInt($("#number").html())-1)
|
||||
}
|
||||
|
||||
function addQuestion() {
|
||||
saveQuestion(false)
|
||||
|
||||
var ids = $("#paperId").val();
|
||||
$(".questionItem").each(function(){
|
||||
ids+=","+$(this).find("input").eq(0).val()
|
||||
})
|
||||
var url = prefix + "/addQuestion/"+ids;
|
||||
$.operate.jumpModeltoUrl("管理试题",url,1000,600);
|
||||
}
|
||||
|
||||
function saveQuestion(value){
|
||||
var index = 1;
|
||||
var data = new Array();
|
||||
data.push({examQuestionId:0,score:0,orderNum:0,examPaperId:$("#paperId").val()})
|
||||
$(".questionItem").each(function(){
|
||||
var examQuestionId = $(this).find(".itemId").eq(0).val();
|
||||
var score = $(this).find(".itemScore").eq(0).val();
|
||||
var order = index++;
|
||||
var json = {examQuestionId:examQuestionId,score:score,orderNum:order,examPaperId:$("#paperId").val()}
|
||||
data.push(json);
|
||||
})
|
||||
debugger
|
||||
|
||||
var config = {
|
||||
url: ctx + "exam/examPaper"+ "/saveQuestion",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(data),
|
||||
contentType:"application/json",
|
||||
success: function(result) {
|
||||
// $.operate.successCallback(result);
|
||||
}
|
||||
};
|
||||
$.ajax(config)
|
||||
if(value){
|
||||
$.modal.alert("保存成功", modal_status.SUCCESS);
|
||||
}
|
||||
// $.operate.save(ctx + "exam/examPaper"+ "/saveQuestion",$.param({paperQuestionList:data}));
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -200,6 +200,10 @@
|
|||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
if($("#categoryId").val()==1){
|
||||
$.modal.alertWarning("请选择试题分类");
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/choiceadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加单选题",url);
|
||||
}
|
||||
|
|
@ -208,6 +212,10 @@
|
|||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
if($("#categoryId").val()==1){
|
||||
$.modal.alertWarning("请选择试题分类");
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/morechoiceadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
||||
}
|
||||
|
|
@ -216,6 +224,10 @@
|
|||
if(!$.tree.notAllowParents($._tree)){
|
||||
return ;
|
||||
}
|
||||
if($("#categoryId").val()==1){
|
||||
$.modal.alertWarning("请选择试题分类");
|
||||
return;
|
||||
}
|
||||
var url = prefix + "/judgeadd/"+$("#categoryId").val();
|
||||
$.operate.jumpModeltoUrl("添加多选题",url);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue