随机试卷

This commit is contained in:
flower 2019-01-17 00:05:41 +08:00
parent ae1f15d3a2
commit 692154150c
9 changed files with 775 additions and 278 deletions

View File

@ -9,9 +9,7 @@ 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.exam.service.*;
import com.ruoyi.framework.web.util.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,7 +18,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.service.IExamPaperService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
@ -28,261 +25,329 @@ import com.ruoyi.common.utils.ExcelUtil;
/**
* 试卷 信息操作处理
*
*
* @author zhujj
* @date 2018-12-16
*/
@Controller
@RequestMapping("/exam/examPaper")
public class ExamPaperController extends BaseController
{
public class ExamPaperController extends BaseController {
private String prefix = "exam/examPaper";
@Autowired
private IExamPaperService examPaperService;
@Autowired
private IExamPaperCategoryService examPaperCategoryService;
@Autowired
private IExamPaperService examPaperService;
@Autowired
private IExamPaperQuestionService examPaperQuestionService;
@Autowired
private IExamPaperCategoryService examPaperCategoryService;
@Autowired
private IExamQuestionService examQuestionService;
@RequiresPermissions("exam:examPaper:view")
@GetMapping()
public String examPaper()
{
return prefix + "/examPaper";
}
@Autowired
private IExamPaperQuestionService examPaperQuestionService;
@Autowired
private IExamQuestionService examQuestionService;
@Autowired
private IExamPaperTypeNumberService examPaperTypeNumberService;
@RequiresPermissions("exam:examPaper:view")
@GetMapping()
public String examPaper() {
return prefix + "/examPaper";
}
/**
* 查询试卷列表
*/
@RequiresPermissions("exam:examPaper:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(ExamPaper examPaper)
{
/**
* 查询试卷列表
*/
@RequiresPermissions("exam:examPaper:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(ExamPaper examPaper) {
List<ExamPaper> list = new ArrayList<>();
List<ExamPaper> listByIds = examPaperService.selectListByCategory(examPaper);
return getDataTable(listByIds);
}
List<ExamPaper> listByIds = examPaperService.selectListByCategory(examPaper);
return getDataTable(listByIds);
}
/**
* 递归找到所有下级的试卷
* @param list
* @param examPaper
* @return
*/
private List<ExamPaper> getListByIds(List<ExamPaper> list,ExamPaper examPaper){
list.addAll(examPaperService.selectExamPaperList(examPaper));
String categoryId = examPaper.getExamPaperCategoryId().toString();
ExamPaperCategory examPaperCategory = new ExamPaperCategory();
examPaperCategory.setParentId(Integer.parseInt(categoryId));
List<ExamPaperCategory> examPaperCategorys = examPaperCategoryService.selectList(examPaperCategory);
for (ExamPaperCategory questionCategory : examPaperCategorys) {
examPaper.setExamPaperCategoryId(questionCategory.getId());
getListByIds(list,examPaper);
}
return list;
}
/**
* 导出试卷列表
*/
@RequiresPermissions("exam:examPaper:export")
/**
* 递归找到所有下级的试卷
*
* @param list
* @param examPaper
* @return
*/
private List<ExamPaper> getListByIds(List<ExamPaper> list, ExamPaper examPaper) {
list.addAll(examPaperService.selectExamPaperList(examPaper));
String categoryId = examPaper.getExamPaperCategoryId().toString();
ExamPaperCategory examPaperCategory = new ExamPaperCategory();
examPaperCategory.setParentId(Integer.parseInt(categoryId));
List<ExamPaperCategory> examPaperCategorys = examPaperCategoryService.selectList(examPaperCategory);
for (ExamPaperCategory questionCategory : examPaperCategorys) {
examPaper.setExamPaperCategoryId(questionCategory.getId());
getListByIds(list, examPaper);
}
return list;
}
/**
* 导出试卷列表
*/
@RequiresPermissions("exam:examPaper:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(ExamPaper examPaper)
{
List<ExamPaper> list = examPaperService.selectExamPaperList(examPaper);
public AjaxResult export(ExamPaper examPaper) {
List<ExamPaper> list = examPaperService.selectExamPaperList(examPaper);
ExcelUtil<ExamPaper> util = new ExcelUtil<ExamPaper>(ExamPaper.class);
return util.exportExcel(list, "examPaper");
}
/**
* 新增试卷
*/
@GetMapping("/add/{id}")
public String add(@PathVariable("id") String id, ModelMap mmap)
{
mmap.put("examPaperCategoryId",id);
return prefix + "/add";
}
/**
* 新增保存试卷
*/
@RequiresPermissions("exam:examPaper:add")
@Log(title = "试卷", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(ExamPaper examPaper)
{
examPaper.setCreateBy(ShiroUtils.getLoginName());
examPaper.setCreateDate(new Date());
examPaper.setScore(0);
examPaper.setQuestionNumber(0);
examPaper.setDelFlag("0");
return toAjax(examPaperService.insert(examPaper));
}
/**
* 修改试卷
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
{
ExamPaper examPaper = examPaperService.selectById(id);
mmap.put("examPaper", examPaper);
return prefix + "/edit";
}
/**
* 修改保存试卷
*/
@RequiresPermissions("exam:examPaper:edit")
@Log(title = "试卷", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(ExamPaper examPaper)
{
examPaper.setUpdateBy(ShiroUtils.getLoginName());
examPaper.setUpdateDate(new Date());
return toAjax(examPaperService.updateSelectiveById(examPaper));
}
/**
* 删除试卷
*/
@RequiresPermissions("exam:examPaper:remove")
@Log(title = "试卷", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(examPaperService.deleteByIds(ids));
}
/**
* 新增试卷
*/
@GetMapping("/add/{id}")
public String add(@PathVariable("id") String id, ModelMap mmap) {
mmap.put("examPaperCategoryId", id);
return prefix + "/add";
}
/**
* 新增保存试卷
*/
@RequiresPermissions("exam:examPaper:add")
@Log(title = "试卷", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(ExamPaperVO examPaper) {
examPaper.setCreateBy(ShiroUtils.getLoginName());
examPaper.setCreateDate(new Date());
examPaper.setScore(0);
examPaper.setQuestionNumber(0);
examPaper.setDelFlag("0");
int insert = examPaperService.insert((ExamPaper) examPaper);
@GetMapping("/addQuestion/{id}")
public String addQuestion(@PathVariable("id") String ids, ModelMap mmap)
{
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";
}
ExamPaperTypeNumber examPaperTypeNumber1 = new ExamPaperTypeNumber();
examPaperTypeNumber1.setDelFlag("0");
examPaperTypeNumber1.setExamPaperId(examPaper.getId());
examPaperTypeNumber1.setExamQuestionType(1);
examPaperTypeNumber1.setNumber(examPaper.getChoiceNumber());
examPaperTypeNumberService.insert(examPaperTypeNumber1);
// @RequiresPermissions("exam:examPaper:add")
ExamPaperTypeNumber examPaperTypeNumber2 = new ExamPaperTypeNumber();
examPaperTypeNumber2.setDelFlag("0");
examPaperTypeNumber2.setExamPaperId(examPaper.getId());
examPaperTypeNumber2.setExamQuestionType(2);
examPaperTypeNumber2.setNumber(examPaper.getMoreChoiceNumber());
examPaperTypeNumberService.insert(examPaperTypeNumber2);
ExamPaperTypeNumber examPaperTypeNumber3 = new ExamPaperTypeNumber();
examPaperTypeNumber3.setDelFlag("0");
examPaperTypeNumber3.setExamPaperId(examPaper.getId());
examPaperTypeNumber3.setExamQuestionType(3);
examPaperTypeNumber3.setNumber(examPaper.getJudgeNumber());
examPaperTypeNumberService.insert(examPaperTypeNumber3);
return success();
}
/**
* 修改试卷
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
JSONObject jsonObject = new JSONObject(examPaperService.selectById(id));
ExamPaperVO examPaper = jsonObject.toBean(ExamPaperVO.class);
examPaper.setChoiceNumber(0);
examPaper.setMoreChoiceNumber(0);
examPaper.setJudgeNumber(0);
if (examPaper.getType().equals("2")) {
ExamPaperTypeNumber examPaperTypeNumber = new ExamPaperTypeNumber();
examPaperTypeNumber.setExamPaperId(id);
List<ExamPaperTypeNumber> examPaperTypeNumbers = examPaperTypeNumberService.selectList(examPaperTypeNumber);
for (ExamPaperTypeNumber item : examPaperTypeNumbers) {
if (item.getExamQuestionType() == 1) {
examPaper.setChoiceNumber(item.getNumber());
}
if (item.getExamQuestionType() == 2) {
examPaper.setMoreChoiceNumber(item.getNumber());
}
if (item.getExamQuestionType() == 3) {
examPaper.setJudgeNumber(item.getNumber());
}
}
}
mmap.put("examPaper", examPaper);
return prefix + "/edit";
}
/**
* 修改保存试卷
*/
@RequiresPermissions("exam:examPaper:edit")
@Log(title = "试卷", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(ExamPaperVO examPaper) {
examPaper.setUpdateBy(ShiroUtils.getLoginName());
examPaper.setUpdateDate(new Date());
examPaperService.updateSelectiveById(examPaper);
ExamPaperTypeNumber delete = new ExamPaperTypeNumber();
delete.setExamPaperId(examPaper.getId());
examPaperTypeNumberService.delete(delete);
ExamPaperTypeNumber examPaperTypeNumber1 = new ExamPaperTypeNumber();
examPaperTypeNumber1.setDelFlag("0");
examPaperTypeNumber1.setExamPaperId(examPaper.getId());
examPaperTypeNumber1.setExamQuestionType(1);
examPaperTypeNumber1.setNumber(examPaper.getChoiceNumber());
examPaperTypeNumberService.insert(examPaperTypeNumber1);
ExamPaperTypeNumber examPaperTypeNumber2 = new ExamPaperTypeNumber();
examPaperTypeNumber2.setDelFlag("0");
examPaperTypeNumber2.setExamPaperId(examPaper.getId());
examPaperTypeNumber2.setExamQuestionType(2);
examPaperTypeNumber2.setNumber(examPaper.getMoreChoiceNumber());
examPaperTypeNumberService.insert(examPaperTypeNumber2);
ExamPaperTypeNumber examPaperTypeNumber3 = new ExamPaperTypeNumber();
examPaperTypeNumber3.setDelFlag("0");
examPaperTypeNumber3.setExamPaperId(examPaper.getId());
examPaperTypeNumber3.setExamQuestionType(3);
examPaperTypeNumber3.setNumber(examPaper.getJudgeNumber());
examPaperTypeNumberService.insert(examPaperTypeNumber3);
return success();
}
/**
* 删除试卷
*/
@RequiresPermissions("exam:examPaper:remove")
@Log(title = "试卷", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
String[] split = ids.split(",");
for (String s : split) {
ExamPaperTypeNumber delete = new ExamPaperTypeNumber();
delete.setExamPaperId(Integer.parseInt(s));
examPaperTypeNumberService.delete(delete);
}
return toAjax(examPaperService.deleteByIds(ids));
}
@GetMapping("/addQuestion/{id}")
public String addQuestion(@PathVariable("id") String ids, ModelMap mmap) {
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:add")
// @Log(title = "试卷", businessType = BusinessType.DELETE)
@PostMapping( "/saveQuestion")
@ResponseBody
public AjaxResult saveQuestion(@RequestBody List<ExamPaperQuestion> paperQuestionList)
{
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();
}
@PostMapping("/saveQuestion")
@ResponseBody
public AjaxResult saveQuestion(@RequestBody List<ExamPaperQuestion> paperQuestionList) {
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";
}
@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();
}
@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);
}
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();
}
}
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);
examPaper.setId(Integer.parseInt(paperId));
examPaper.setQuestionNumber(questionNum);
examPaper.setScore(score);
examPaperService.updateSelectiveById(examPaper);
return AjaxResult.success();
}
return AjaxResult.success();
}
}

View File

@ -0,0 +1,166 @@
package com.ruoyi.exam.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
import java.util.Date;
/**
* 随机试卷题型数量表 exam_paper_type_number
*
* @author zhujj
* @date 2019-01-16
*/
public class ExamPaperTypeNumber
{
private static final long serialVersionUID = 1L;
/** 试卷题型数量ID */
@Id
private Integer id;
/** 试卷代码 */
private Integer examPaperId;
/** 问题类型(来自字典表) */
private Integer examQuestionType;
/** 题型数量 */
private Integer number;
/** 创建者 */
private String createBy;
/** 创建时间 */
private Date createDate;
/** 更新者 */
private String updateBy;
/** 更新时间 */
private Date updateDate;
/** 备注信息 */
private String remarks;
/** 删除标记 */
private String delFlag;
/** 设置试卷题型数量ID */
public void setId(Integer id)
{
this.id = id;
}
/** 获取试卷题型数量ID */
public Integer getId()
{
return id;
}
/** 设置试卷代码 */
public void setExamPaperId(Integer examPaperId)
{
this.examPaperId = examPaperId;
}
/** 获取试卷代码 */
public Integer getExamPaperId()
{
return examPaperId;
}
/** 设置问题类型(来自字典表) */
public void setExamQuestionType(Integer examQuestionType)
{
this.examQuestionType = examQuestionType;
}
/** 获取问题类型(来自字典表) */
public Integer getExamQuestionType()
{
return examQuestionType;
}
/** 设置题型数量 */
public void setNumber(Integer number)
{
this.number = number;
}
/** 获取题型数量 */
public Integer getNumber()
{
return number;
}
/** 设置创建者 */
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
/** 获取创建者 */
public String getCreateBy()
{
return createBy;
}
/** 设置创建时间 */
public void setCreateDate(Date createDate)
{
this.createDate = createDate;
}
/** 获取创建时间 */
public Date getCreateDate()
{
return createDate;
}
/** 设置更新者 */
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
/** 获取更新者 */
public String getUpdateBy()
{
return updateBy;
}
/** 设置更新时间 */
public void setUpdateDate(Date updateDate)
{
this.updateDate = updateDate;
}
/** 获取更新时间 */
public Date getUpdateDate()
{
return updateDate;
}
/** 设置备注信息 */
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
/** 获取备注信息 */
public String getRemarks()
{
return remarks;
}
/** 设置删除标记 */
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
/** 获取删除标记 */
public String getDelFlag()
{
return delFlag;
}
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("examPaperId", getExamPaperId())
.append("examQuestionType", getExamQuestionType())
.append("number", getNumber())
.append("createBy", getCreateBy())
.append("createDate", getCreateDate())
.append("updateBy", getUpdateBy())
.append("updateDate", getUpdateDate())
.append("remarks", getRemarks())
.append("delFlag", getDelFlag())
.toString();
}
}

View File

@ -0,0 +1,35 @@
package com.ruoyi.exam.domain;
/**
* Created by flower on 2019/1/16.
*/
public class ExamPaperVO extends ExamPaper {
private Integer choiceNumber;
private Integer moreChoiceNumber;
private Integer judgeNumber;
public Integer getChoiceNumber() {
return choiceNumber;
}
public void setChoiceNumber(Integer choiceNumber) {
this.choiceNumber = choiceNumber;
}
public Integer getMoreChoiceNumber() {
return moreChoiceNumber;
}
public void setMoreChoiceNumber(Integer moreChoiceNumber) {
this.moreChoiceNumber = moreChoiceNumber;
}
public Integer getJudgeNumber() {
return judgeNumber;
}
public void setJudgeNumber(Integer judgeNumber) {
this.judgeNumber = judgeNumber;
}
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.exam.mapper;
import com.ruoyi.exam.domain.ExamPaperTypeNumber;
import java.util.List;
import com.ruoyi.framework.web.base.MyMapper;
/**
* 随机试卷题型数量 数据层
*
* @author zhujj
* @date 2019-01-16
*/
public interface ExamPaperTypeNumberMapper extends MyMapper<ExamPaperTypeNumber>
{
/**
* 查询随机试卷题型数量列表
*
* @param examPaperTypeNumber 随机试卷题型数量信息
* @return 随机试卷题型数量集合
*/
public List<ExamPaperTypeNumber> selectExamPaperTypeNumberList(ExamPaperTypeNumber examPaperTypeNumber);
}

View File

@ -0,0 +1,30 @@
package com.ruoyi.exam.service;
import com.ruoyi.exam.domain.ExamPaperTypeNumber;
import java.util.List;
import com.ruoyi.framework.web.base.AbstractBaseService;
/**
* 随机试卷题型数量 服务层
*
* @author zhujj
* @date 2019-01-16
*/
public interface IExamPaperTypeNumberService extends AbstractBaseService<ExamPaperTypeNumber>
{
/**
* 查询随机试卷题型数量分页列表
*
* @param examPaperTypeNumber 随机试卷题型数量信息
* @return 随机试卷题型数量集合
*/
public List<ExamPaperTypeNumber> selectExamPaperTypeNumberPage(ExamPaperTypeNumber examPaperTypeNumber);
/**
* 查询随机试卷题型数量列表
*
* @param examPaperTypeNumber 随机试卷题型数量信息
* @return 随机试卷题型数量集合
*/
public List<ExamPaperTypeNumber> selectExamPaperTypeNumberList(ExamPaperTypeNumber examPaperTypeNumber);
}

View File

@ -0,0 +1,48 @@
package com.ruoyi.exam.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.exam.mapper.ExamPaperTypeNumberMapper;
import com.ruoyi.exam.domain.ExamPaperTypeNumber;
import com.ruoyi.exam.service.IExamPaperTypeNumberService;
import com.ruoyi.common.support.Convert;
import com.ruoyi.framework.web.base.AbstractBaseServiceImpl;
/**
* 随机试卷题型数量 服务层实现
*
* @author zhujj
* @date 2019-01-16
*/
@Service
public class ExamPaperTypeNumberServiceImpl extends AbstractBaseServiceImpl<ExamPaperTypeNumberMapper,ExamPaperTypeNumber> implements IExamPaperTypeNumberService
{
@Autowired
private ExamPaperTypeNumberMapper examPaperTypeNumberMapper;
/**
* 查询随机试卷题型数量列表
*
* @param examPaperTypeNumber 随机试卷题型数量信息
* @return 随机试卷题型数量集合
*/
@Override
public List<ExamPaperTypeNumber> selectExamPaperTypeNumberList(ExamPaperTypeNumber examPaperTypeNumber)
{
return examPaperTypeNumberMapper.selectExamPaperTypeNumberList(examPaperTypeNumber);
}
/**
* 查询随机试卷题型数量分页列表
*
* @param examPaperTypeNumber 随机试卷题型数量信息
* @return 随机试卷题型数量集合
*/
@Override
public List<ExamPaperTypeNumber> selectExamPaperTypeNumberPage(ExamPaperTypeNumber examPaperTypeNumber)
{
startPage();
return examPaperTypeNumberMapper.selectExamPaperTypeNumberList(examPaperTypeNumber);
}
}

View File

@ -0,0 +1,42 @@
<?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">
<mapper namespace="com.ruoyi.exam.mapper.ExamPaperTypeNumberMapper">
<resultMap type="ExamPaperTypeNumber" id="ExamPaperTypeNumberResult">
<result property="id" column="id" />
<result property="examPaperId" column="exam_paper_id" />
<result property="examQuestionType" column="exam_question_type" />
<result property="number" column="number" />
<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>
<sql id="selectExamPaperTypeNumberVo">
id, exam_paper_id, exam_question_type, number, create_by, create_date, update_by, update_date, remarks, del_flag </sql>
<select id="selectExamPaperTypeNumberList" parameterType="ExamPaperTypeNumber" resultMap="ExamPaperTypeNumberResult">
select
<include refid="selectExamPaperTypeNumberVo"/>
from exam_paper_type_number
<where>
<if test="id != null "> and id = #{id}</if>
<if test="examPaperId != null "> and exam_paper_id = #{examPaperId}</if>
<if test="examQuestionType != null "> and exam_question_type = #{examQuestionType}</if>
<if test="number != null "> and number = #{number}</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>
</select>
</mapper>

View File

@ -14,12 +14,37 @@
<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">试卷类型</label>
<div class="col-sm-8">
<select id="type" name="type" class="form-control m-b" th:with="type=${@dict.getType('exam_paper_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group type">
<label class="col-sm-3 control-label">单选题数量:</label>
<div class="col-sm-8">
<input id="choiceNumber" name="choiceNumber" class="form-control" type="text" value="0">
</div>
</div>
<div class="form-group type">
<label class="col-sm-3 control-label">多选题数量:</label>
<div class="col-sm-8">
<input id="moreChoiceNumber" name="moreChoiceNumber" class="form-control" type="text" value="0">
</div>
</div>
<div class="form-group type">
<label class="col-sm-3 control-label">选择题:</label>
<div class="col-sm-8">
<input id="judgeNumber" name="judgeNumber" class="form-control" type="text" value="0">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">备注信息:</label>
<div class="col-sm-8">
@ -44,6 +69,23 @@
$.operate.save(prefix + "/add", $('#form-examPaper-add').serialize());
}
}
$(function(){
if($("#type").val().toString()=="1"){
$(".type").hide()
}else{
$(".type").show()
}
$("#type").change(function(){
if($("#type").val().toString()=="1"){
$(".type").hide()
}else{
$(".type").show()
}
})
})
</script>
</body>
</html>

View File

@ -1,51 +1,96 @@
<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-examPaper-edit" th:object="${examPaper}">
<input id="id" name="id" th:field="*{id}" type="hidden">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-examPaper-edit" th:object="${examPaper}">
<input id="id" name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">名称:</label>
<div class="col-sm-8">
<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="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="remarks" name="remarks" th:field="*{remarks}" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">试卷类型:</label>
<div class="col-sm-8">
<select id="type" name="type" class="form-control m-b" th:field="*{type}"
th:with="type=${@dict.getType('exam_paper_type')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "exam/examPaper"
$("#form-examPaper-edit").validate({
rules:{
xxxx:{
required:true,
},
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-examPaper-edit').serialize());
}
}
</script>
<div class="form-group type">
<label class="col-sm-3 control-label">单选题数量:</label>
<div class="col-sm-8">
<input id="choiceNumber" name="choiceNumber" th:field="*{choiceNumber}" class="form-control"
type="text">
</div>
</div>
<div class="form-group type">
<label class="col-sm-3 control-label">多选题数量:</label>
<div class="col-sm-8">
<input id="moreChoiceNumber" name="moreChoiceNumber" th:field="*{moreChoiceNumber}" class="form-control"
type="text">
</div>
</div>
<div class="form-group type">
<label class="col-sm-3 control-label">选择题:</label>
<div class="col-sm-8">
<input id="judgeNumber" name="judgeNumber" th:field="*{judgeNumber}" 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="remarks" name="remarks" th:field="*{remarks}" class="form-control" type="text">
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
var prefix = ctx + "exam/examPaper"
$("#form-examPaper-edit").validate({
rules: {
xxxx: {
required: true,
},
}
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-examPaper-edit').serialize());
}
}
$(function () {
if ($("#type").val().toString() == "1") {
$(".type").hide()
} else {
$(".type").show()
}
$("#type").change(function () {
if ($("#type").val().toString() == "1") {
$(".type").hide()
} else {
$(".type").show()
}
})
})
</script>
</body>
</html>