增加试卷、试卷试题功能

This commit is contained in:
WenG 2022-05-17 00:25:48 +08:00
parent 2828b5ff4f
commit 7e43419034
21 changed files with 2645 additions and 48 deletions

View File

@ -0,0 +1,120 @@
package ink.wgink.module.examine.controller.api.paper;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.exceptions.ParamsException;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.module.examine.pojo.dtos.paper.PaperDTO;
import ink.wgink.module.examine.pojo.vos.paper.PaperVO;
import ink.wgink.module.examine.service.paper.IPaperService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @ClassName: PaperController
* @Description: 试卷
* @Author: WenG
* @Date: 2020-09-11 11:50
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "试卷接口")
@RestController
@RequestMapping(ISystemConstant.API_PREFIX + "/paper")
public class PaperController extends DefaultBaseController {
@Autowired
private IPaperService paperService;
@ApiOperation(value = "新增试卷", notes = "新增试卷接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("save")
@CheckRequestBodyAnnotation
public SuccessResult savePaper(@RequestBody PaperVO paperVO) throws Exception {
if (paperVO.getPassScore() > paperVO.getTotalScore()) {
throw new ParamsException("及格分数不能大于总分");
}
paperService.save(paperVO);
return new SuccessResult();
}
@ApiOperation(value = "删除试卷(id列表)", notes = "删除试卷(id列表)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@DeleteMapping("remove/{ids}")
public SuccessResult remove(@PathVariable("ids") String ids) throws RemoveException {
paperService.remove(Arrays.asList(ids.split("\\_")));
return new SuccessResult();
}
@ApiOperation(value = "修改试卷", notes = "修改试卷接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "paperId", value = "试卷ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update/{paperId}")
@CheckRequestBodyAnnotation
public SuccessResult updatePaper(@PathVariable("paperId") String paperId, @RequestBody PaperVO paperVO) throws Exception {
if (paperVO.getPassScore() > paperVO.getTotalScore()) {
throw new ParamsException("及格分数不能大于总分");
}
paperService.update(paperId, paperVO);
return new SuccessResult();
}
@ApiOperation(value = "试卷详情(通过ID)", notes = "试卷详情(通过ID)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "paperId", value = "试卷ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get/{paperId}")
public PaperDTO getPaperById(@PathVariable("paperId") String paperId) throws SearchException {
return paperService.getById(paperId);
}
@ApiOperation(value = "试卷列表", notes = "试卷列表接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("list")
public List<PaperDTO> list() throws SearchException {
Map<String, Object> params = requestParams();
return paperService.list(params);
}
@ApiOperation(value = "试卷分页列表", notes = "试卷分页列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpage")
public SuccessResultList<List<PaperDTO>> listPage(ListPage page) throws SearchException {
Map<String, Object> params = requestParams();
page.setParams(params);
return paperService.listPage(page);
}
@ApiOperation(value = "试卷统计", notes = "试卷统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count")
SuccessResultData<Integer> countPaper() throws SearchException {
Map<String, Object> params = requestParams();
Integer count = paperService.count(params);
return new SuccessResultData<>(count);
}
}

View File

@ -0,0 +1,39 @@
package ink.wgink.module.examine.controller.route.paper;
import ink.wgink.interfaces.consts.ISystemConstant;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
* @Description: 试卷
* @Author: WenG
* @Date: 2022/5/16 22:26
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "试卷路由")
@Controller
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/paper")
public class PaperRouteController {
@GetMapping("save")
public ModelAndView save() {
ModelAndView mv = new ModelAndView("paper/save");
return mv;
}
@GetMapping("update")
public ModelAndView update() {
ModelAndView mv = new ModelAndView("paper/update");
return mv;
}
@GetMapping("list")
public ModelAndView list() {
ModelAndView mv = new ModelAndView("paper/list");
return mv;
}
}

View File

@ -0,0 +1,89 @@
package ink.wgink.module.examine.dao.paper;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.interfaces.init.IInitBaseTable;
import ink.wgink.module.examine.pojo.dtos.paper.PaperDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @Description: 试卷
* @Author: WenG
* @Date: 2022/5/16 20:45
* @Version: 1.0
**/
@Repository
public interface IPaperDao extends IInitBaseTable {
/**
* 新增
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 删除
*
* @param params
* @throws RemoveException
*/
void remove(Map<String, Object> params) throws RemoveException;
/**
* 删除
*
* @param params
* @throws RemoveException
*/
void delete(Map<String, Object> params) throws RemoveException;
/**
* 修改
*
* @param params
* @throws UpdateException
*/
void update(Map<String, Object> params) throws UpdateException;
/**
* 修改试卷状态
*
* @param params
* @throws UpdateException
*/
void updatePaperStatus(Map<String, Object> params) throws UpdateException;
/**
* 详情
*
* @param params
* @return
* @throws SearchException
*/
PaperDTO get(Map<String, Object> params) throws SearchException;
/**
* 列表
*
* @param params
* @return
* @throws SearchException
*/
List<PaperDTO> list(Map<String, Object> params) throws SearchException;
/**
* 总数
*
* @param params
* @return
* @throws SearchException
*/
Integer count(Map<String, Object> params) throws SearchException;
}

View File

@ -0,0 +1,56 @@
package ink.wgink.module.examine.dao.paper;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.exceptions.UpdateException;
import ink.wgink.interfaces.init.IInitBaseTable;
import ink.wgink.module.examine.pojo.dtos.paper.PaperDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @Description: 试卷试题
* @Author: WenG
* @Date: 2022/5/16 20:45
* @Version: 1.0
**/
@Repository
public interface IPaperQuestionDao extends IInitBaseTable {
/**
* 新增
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 删除
*
* @param params
* @throws RemoveException
*/
void delete(Map<String, Object> params) throws RemoveException;
/**
* 修改试题排序
*
* @param params
* @throws UpdateException
*/
void updateQuestionSort(Map<String, Object> params) throws UpdateException;
/**
* 列表
*
* @param params
* @return
* @throws SearchException
*/
List<PaperDTO> listPO(Map<String, Object> params) throws SearchException;
}

View File

@ -0,0 +1,196 @@
package ink.wgink.module.examine.pojo.dtos.paper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: ExaminationPaperDTO
* @Description: 试卷
* @Author: WenG
* @Date: 2020-09-11 11:50
* @Version: 1.0
**/
@ApiModel
public class PaperDTO {
@ApiModelProperty(name = "paperId", value = "主键")
private String paperId;
@ApiModelProperty(name = "paperName", value = "试卷名称")
private String paperName;
@ApiModelProperty(name = "paperNumber", value = "试卷编码")
private String paperNumber;
@ApiModelProperty(name = "paperType", value = "试卷类型")
private String paperType;
@ApiModelProperty(name = "passScore", value = "及格分数")
private Double passScore;
@ApiModelProperty(name = "totalScore", value = "总分")
private Double totalScore;
@ApiModelProperty(name = "choiceSingleCount", value = "单选数量")
private Integer choiceSingleCount;
@ApiModelProperty(name = "choiceSingleEachScore", value = "单选每题得分")
private Double choiceSingleEachScore;
@ApiModelProperty(name = "choiceMultipleCount", value = "多选数量")
private Integer choiceMultipleCount;
@ApiModelProperty(name = "choiceMultipleEachScore", value = "多选每题得分")
private Double choiceMultipleEachScore;
@ApiModelProperty(name = "tureOrFalseCount", value = "判断数量")
private Integer tureOrFalseCount;
@ApiModelProperty(name = "tureOrFalseEachScore", value = "判断每题得分")
private Double tureOrFalseEachScore;
@ApiModelProperty(name = "fillInTheBlanksCount", value = "填空数量")
private Integer fillInTheBlanksCount;
@ApiModelProperty(name = "fillInTheBlanksEachScore", value = "填空每题得分")
private Double fillInTheBlanksEachScore;
@ApiModelProperty(name = "answerCount", value = "解答数量")
private Integer answerCount;
@ApiModelProperty(name = "answerEachScore", value = "解答每题得分")
private Double answerEachScore;
@ApiModelProperty(name = "gmtCreate", value = "添加时间")
private String gmtCreate;
@ApiModelProperty(name = "paperStatus", value = "试卷状态0未就绪1已就绪")
private Integer paperStatus;
public String getPaperId() {
return paperId;
}
public void setPaperId(String paperId) {
this.paperId = paperId;
}
public String getPaperName() {
return paperName;
}
public void setPaperName(String paperName) {
this.paperName = paperName;
}
public String getPaperNumber() {
return paperNumber;
}
public void setPaperNumber(String paperNumber) {
this.paperNumber = paperNumber;
}
public String getPaperType() {
return paperType;
}
public void setPaperType(String paperType) {
this.paperType = paperType;
}
public Double getPassScore() {
return passScore;
}
public void setPassScore(Double passScore) {
this.passScore = passScore;
}
public Double getTotalScore() {
return totalScore;
}
public void setTotalScore(Double totalScore) {
this.totalScore = totalScore;
}
public Integer getChoiceSingleCount() {
return choiceSingleCount;
}
public void setChoiceSingleCount(Integer choiceSingleCount) {
this.choiceSingleCount = choiceSingleCount;
}
public Double getChoiceSingleEachScore() {
return choiceSingleEachScore;
}
public void setChoiceSingleEachScore(Double choiceSingleEachScore) {
this.choiceSingleEachScore = choiceSingleEachScore;
}
public Integer getChoiceMultipleCount() {
return choiceMultipleCount;
}
public void setChoiceMultipleCount(Integer choiceMultipleCount) {
this.choiceMultipleCount = choiceMultipleCount;
}
public Double getChoiceMultipleEachScore() {
return choiceMultipleEachScore;
}
public void setChoiceMultipleEachScore(Double choiceMultipleEachScore) {
this.choiceMultipleEachScore = choiceMultipleEachScore;
}
public Integer getTureOrFalseCount() {
return tureOrFalseCount;
}
public void setTureOrFalseCount(Integer tureOrFalseCount) {
this.tureOrFalseCount = tureOrFalseCount;
}
public Double getTureOrFalseEachScore() {
return tureOrFalseEachScore;
}
public void setTureOrFalseEachScore(Double tureOrFalseEachScore) {
this.tureOrFalseEachScore = tureOrFalseEachScore;
}
public Integer getFillInTheBlanksCount() {
return fillInTheBlanksCount;
}
public void setFillInTheBlanksCount(Integer fillInTheBlanksCount) {
this.fillInTheBlanksCount = fillInTheBlanksCount;
}
public Double getFillInTheBlanksEachScore() {
return fillInTheBlanksEachScore;
}
public void setFillInTheBlanksEachScore(Double fillInTheBlanksEachScore) {
this.fillInTheBlanksEachScore = fillInTheBlanksEachScore;
}
public Integer getAnswerCount() {
return answerCount;
}
public void setAnswerCount(Integer answerCount) {
this.answerCount = answerCount;
}
public Double getAnswerEachScore() {
return answerEachScore;
}
public void setAnswerEachScore(Double answerEachScore) {
this.answerEachScore = answerEachScore;
}
public String getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Integer getPaperStatus() {
return paperStatus;
}
public void setPaperStatus(Integer paperStatus) {
this.paperStatus = paperStatus;
}
}

View File

@ -0,0 +1,117 @@
package ink.wgink.module.examine.pojo.dtos.paper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
* @ClassName: PaperQuestionDTO
* @Description: 试卷考题
* @Author: WenG
* @Date: 2020-09-11 12:31
* @Version: 1.0
**/
@ApiModel
public class PaperQuestionDTO {
@ApiModelProperty(name = "paperQuestionId", value = "试卷问题ID")
private String paperQuestionId;
@ApiModelProperty(name = "paperId", value = "试卷ID")
private String paperId;
@ApiModelProperty(name = "paperName", value = "试卷名称")
private String paperName;
@ApiModelProperty(name = "questionId", value = "问题")
private String questionId;
@ApiModelProperty(name = "questionSubject", value = "问题题目")
private String questionSubject;
@ApiModelProperty(name = "questionType", value = "问题种类")
private String questionType;
@ApiModelProperty(name = "questionChoiceType", value = "问题选择类别")
private String questionChoiceType;
@ApiModelProperty(name = "questionAnalysis", value = "问题解析")
private String questionAnalysis;
@ApiModelProperty(name = "questionDifficulty", value = "难度")
private String questionDifficulty;
@ApiModelProperty(name = "questionSource", value = "问题来源")
private String questionSource;
public String getPaperQuestionId() {
return paperQuestionId;
}
public void setPaperQuestionId(String paperQuestionId) {
this.paperQuestionId = paperQuestionId;
}
public String getPaperId() {
return paperId;
}
public void setPaperId(String paperId) {
this.paperId = paperId;
}
public String getPaperName() {
return paperName;
}
public void setPaperName(String paperName) {
this.paperName = paperName;
}
public String getQuestionId() {
return questionId;
}
public void setQuestionId(String questionId) {
this.questionId = questionId;
}
public String getQuestionSubject() {
return questionSubject;
}
public void setQuestionSubject(String questionSubject) {
this.questionSubject = questionSubject;
}
public String getQuestionType() {
return questionType;
}
public void setQuestionType(String questionType) {
this.questionType = questionType;
}
public String getQuestionChoiceType() {
return questionChoiceType;
}
public void setQuestionChoiceType(String questionChoiceType) {
this.questionChoiceType = questionChoiceType;
}
public String getQuestionAnalysis() {
return questionAnalysis;
}
public void setQuestionAnalysis(String questionAnalysis) {
this.questionAnalysis = questionAnalysis;
}
public String getQuestionDifficulty() {
return questionDifficulty;
}
public void setQuestionDifficulty(String questionDifficulty) {
this.questionDifficulty = questionDifficulty;
}
public String getQuestionSource() {
return questionSource;
}
public void setQuestionSource(String questionSource) {
this.questionSource = questionSource;
}
}

View File

@ -0,0 +1,52 @@
package ink.wgink.module.examine.pojo.pos.paper;
import java.io.Serializable;
/**
*
* @ClassName: PaperQuestionDTO
* @Description: 试卷考题
* @Author: WenG
* @Date: 2020-09-11 12:31
* @Version: 1.0
**/
public class PaperQuestionPO implements Serializable {
private static final long serialVersionUID = -562410874161823539L;
private String paperQuestionId;
private String paperId;
private String questionId;
private String questionType;
public String getPaperQuestionId() {
return paperQuestionId;
}
public void setPaperQuestionId(String paperQuestionId) {
this.paperQuestionId = paperQuestionId;
}
public String getPaperId() {
return paperId;
}
public void setPaperId(String paperId) {
this.paperId = paperId;
}
public String getQuestionId() {
return questionId;
}
public void setQuestionId(String questionId) {
this.questionId = questionId;
}
public String getQuestionType() {
return questionType;
}
public void setQuestionType(String questionType) {
this.questionType = questionType;
}
}

View File

@ -0,0 +1,174 @@
package ink.wgink.module.examine.pojo.vos.paper;
import ink.wgink.annotation.CheckEmptyAnnotation;
import ink.wgink.annotation.CheckNumberAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: ExaminationPaperVO
* @Description: 试卷
* @Author: WenG
* @Date: 2020-09-11 11:50
* @Version: 1.0
**/
@ApiModel
public class PaperVO {
@ApiModelProperty(name = "name", value = "名称")
@CheckEmptyAnnotation(name = "名称")
private String paperName;
@ApiModelProperty(name = "type", value = "类型")
@CheckEmptyAnnotation(name = "类型", types = {"test", "simulation", "examination"})
private String paperType;
@ApiModelProperty(name = "passScore", value = "及格分数")
@CheckNumberAnnotation(name = "及格分数", min = 0)
private Double passScore;
@ApiModelProperty(name = "totalScore", value = "总分")
@CheckNumberAnnotation(name = "总分", min = 0)
private Double totalScore;
@ApiModelProperty(name = "choiceSingleCount", value = "单选数量")
@CheckNumberAnnotation(name = "单选数量", min = 0)
private Integer choiceSingleCount;
@ApiModelProperty(name = "choiceSingleEachScore", value = "单选每题得分")
@CheckNumberAnnotation(name = "单选每题得分", min = 0)
private Double choiceSingleEachScore;
@ApiModelProperty(name = "choiceMultipleCount", value = "多选数量")
@CheckNumberAnnotation(name = "多选数量", min = 0)
private Integer choiceMultipleCount;
@ApiModelProperty(name = "choiceMultipleEachScore", value = "多选每题得分")
@CheckNumberAnnotation(name = "多选每题得分", min = 0)
private Double choiceMultipleEachScore;
@ApiModelProperty(name = "tureOrFalseCount", value = "判断数量")
@CheckNumberAnnotation(name = "判断数量", min = 0)
private Integer tureOrFalseCount;
@ApiModelProperty(name = "tureOrFalseEachScore", value = "判断每题得分")
@CheckNumberAnnotation(name = "判断每题得分", min = 0)
private Double tureOrFalseEachScore;
@ApiModelProperty(name = "fillInTheBlanksCount", value = "填空数量")
@CheckNumberAnnotation(name = "填空数量", min = 0)
private Integer fillInTheBlanksCount;
@ApiModelProperty(name = "fillInTheBlanksEachScore", value = "填空每题得分")
@CheckNumberAnnotation(name = "填空每题得分", min = 0)
private Double fillInTheBlanksEachScore;
@ApiModelProperty(name = "answerCount", value = "解答数量")
@CheckNumberAnnotation(name = "解答数量", min = 0)
private Integer answerCount;
@ApiModelProperty(name = "answerEachScore", value = "解答每题得分")
@CheckNumberAnnotation(name = "解答每题得分", min = 0)
private Double answerEachScore;
public String getPaperName() {
return paperName;
}
public void setPaperName(String paperName) {
this.paperName = paperName;
}
public String getPaperType() {
return paperType;
}
public void setPaperType(String paperType) {
this.paperType = paperType;
}
public Double getPassScore() {
return passScore == null ? 0D : passScore;
}
public void setPassScore(Double passScore) {
this.passScore = passScore;
}
public Double getTotalScore() {
return totalScore == null ? 0D : totalScore;
}
public void setTotalScore(Double totalScore) {
this.totalScore = totalScore;
}
public Integer getChoiceSingleCount() {
return choiceSingleCount == null ? 0 : choiceSingleCount;
}
public void setChoiceSingleCount(Integer choiceSingleCount) {
this.choiceSingleCount = choiceSingleCount;
}
public Double getChoiceSingleEachScore() {
return choiceSingleEachScore == null ? 0D : choiceSingleEachScore;
}
public void setChoiceSingleEachScore(Double choiceSingleEachScore) {
this.choiceSingleEachScore = choiceSingleEachScore;
}
public Integer getChoiceMultipleCount() {
return choiceMultipleCount == null ? 0 : choiceMultipleCount;
}
public void setChoiceMultipleCount(Integer choiceMultipleCount) {
this.choiceMultipleCount = choiceMultipleCount;
}
public Double getChoiceMultipleEachScore() {
return choiceMultipleEachScore == null ? 0D : choiceMultipleEachScore;
}
public void setChoiceMultipleEachScore(Double choiceMultipleEachScore) {
this.choiceMultipleEachScore = choiceMultipleEachScore;
}
public Integer getTureOrFalseCount() {
return tureOrFalseCount == null ? 0 : tureOrFalseCount;
}
public void setTureOrFalseCount(Integer tureOrFalseCount) {
this.tureOrFalseCount = tureOrFalseCount;
}
public Double getTureOrFalseEachScore() {
return tureOrFalseEachScore == null ? 0D : tureOrFalseEachScore;
}
public void setTureOrFalseEachScore(Double tureOrFalseEachScore) {
this.tureOrFalseEachScore = tureOrFalseEachScore;
}
public Integer getFillInTheBlanksCount() {
return fillInTheBlanksCount == null ? 0 : fillInTheBlanksCount;
}
public void setFillInTheBlanksCount(Integer fillInTheBlanksCount) {
this.fillInTheBlanksCount = fillInTheBlanksCount;
}
public Double getFillInTheBlanksEachScore() {
return fillInTheBlanksEachScore == null ? 0D : fillInTheBlanksEachScore;
}
public void setFillInTheBlanksEachScore(Double fillInTheBlanksEachScore) {
this.fillInTheBlanksEachScore = fillInTheBlanksEachScore;
}
public Integer getAnswerCount() {
return answerCount == null ? 0 : answerCount;
}
public void setAnswerCount(Integer answerCount) {
this.answerCount = answerCount;
}
public Double getAnswerEachScore() {
return answerEachScore == null ? 0D : answerEachScore;
}
public void setAnswerEachScore(Double answerEachScore) {
this.answerEachScore = answerEachScore;
}
}

View File

@ -0,0 +1,101 @@
package ink.wgink.module.examine.service.paper;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.module.examine.pojo.dtos.paper.PaperDTO;
import ink.wgink.module.examine.pojo.vos.paper.PaperVO;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import java.util.List;
import java.util.Map;
/**
* @ClassName: IPaperService
* @Description: 试卷
* @Author: WenG
* @Date: 2020-09-11 11:50
* @Version: 1.0
**/
public interface IPaperService {
/**
* 新增试卷
*
* @param paperVO
* @return
* @throws Exception
*/
void save(PaperVO paperVO) throws Exception;
/**
* 新增试卷
*
* @param paperVO
* @return paperId
* @throws Exception
*/
String saveReturnId(PaperVO paperVO) throws Exception;
/**
* 删除试卷
*
* @param paperIds 试卷ID列表
* @throws RemoveException
*/
void remove(List<String> paperIds);
/**
* 删除试卷
*
* @param paperIds
*/
void delete(List<String> paperIds);
/**
* 修改试卷
*
* @param paperId
* @param paperVO
* @return
* @throws Exception
*/
void update(String paperId, PaperVO paperVO) throws Exception;
/**
* 试卷详情(通过ID)
*
* @param paperId
* @return
* @throws SearchException
*/
PaperDTO getById(String paperId);
/**
* 试卷列表
*
* @param params
* @return
* @throws SearchException
*/
List<PaperDTO> list(Map<String, Object> params);
/**
* 试卷分页列表
*
* @param page
* @return
* @throws SearchException
*/
SuccessResultList<List<PaperDTO>> listPage(ListPage page);
/**
* 试卷统计
*
* @param params
* @return
* @throws SearchException
*/
Integer count(Map<String, Object> params);
}

View File

@ -0,0 +1,103 @@
package ink.wgink.module.examine.service.paper.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.exceptions.RemoveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.module.examine.dao.paper.IPaperDao;
import ink.wgink.module.examine.pojo.dtos.paper.PaperDTO;
import ink.wgink.module.examine.pojo.vos.paper.PaperVO;
import ink.wgink.module.examine.service.paper.IPaperService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.util.UUIDUtil;
import ink.wgink.util.map.HashMapUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @ClassName: PaperServiceImpl
* @Description: 试卷
* @Author: WenG
* @Date: 2020-09-11 11:50
* @Version: 1.0
**/
@Service
public class PaperServiceImpl extends DefaultBaseService implements IPaperService {
@Autowired
private IPaperDao paperDao;
@Override
public void save(PaperVO paperVO) throws Exception {
saveReturnId(paperVO);
}
@Override
public String saveReturnId(PaperVO paperVO) throws Exception {
String paperId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(paperVO);
params.put("paperId", paperId);
params.put("paperNumber", "SJ-" + System.currentTimeMillis());
setSaveInfo(params);
paperDao.save(params);
return paperId;
}
@Override
public void remove(List<String> paperIds) throws RemoveException {
// 已经使用的试卷无法修改
Map<String, Object> params = getHashMap(3);
params.put("paperIds", paperIds);
setUpdateInfo(params);
paperDao.remove(params);
}
@Override
public void delete(List<String> paperIds) {
// 已经使用的试卷无法修改
Map<String, Object> params = getHashMap(3);
params.put("paperIds", paperIds);
paperDao.delete(params);
}
@Override
public void update(String paperId, PaperVO paperVO) throws Exception {
// 已经使用的试卷无法修改
Map<String, Object> params = HashMapUtil.beanToMap(paperVO);
params.put("paperId", paperId);
setUpdateInfo(params);
paperDao.update(params);
}
@Override
public PaperDTO getById(String paperId) throws SearchException {
Map<String, Object> params = super.getHashMap(2);
params.put("paperId", paperId);
return paperDao.get(params);
}
@Override
public List<PaperDTO> list(Map<String, Object> params) throws SearchException {
return paperDao.list(params);
}
@Override
public SuccessResultList<List<PaperDTO>> listPage(ListPage page) throws SearchException {
PageHelper.startPage(page.getPage(), page.getRows());
List<PaperDTO> paperDTOs = paperDao.list(page.getParams());
PageInfo<PaperDTO> pageInfo = new PageInfo<>(paperDTOs);
return new SuccessResultList<>(paperDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public Integer count(Map<String, Object> params) throws SearchException {
Integer count = paperDao.count(params);
return count == null ? 0 : count;
}
}

View File

@ -0,0 +1,287 @@
<?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="ink.wgink.module.examine.dao.paper.IPaperDao">
<resultMap id="paperDTO" type="ink.wgink.module.examine.pojo.dtos.paper.PaperDTO">
<id column="paper_id" property="paperId"/>
<result column="paper_name" property="paperName"/>
<result column="paper_number" property="paperNumber"/>
<result column="paper_type" property="paperType"/>
<result column="pass_score" property="passScore"/>
<result column="total_score" property="totalScore"/>
<result column="choice_single_count" property="choiceSingleCount"/>
<result column="choice_single_each_score" property="choiceSingleEachScore"/>
<result column="choice_multiple_count" property="choiceMultipleCount"/>
<result column="choice_multiple_each_score" property="choiceMultipleEachScore"/>
<result column="ture_or_false_count" property="tureOrFalseCount"/>
<result column="ture_or_false_each_score" property="tureOrFalseEachScore"/>
<result column="fill_in_the_blanks_count" property="fillInTheBlanksCount"/>
<result column="fill_in_the_blanks_each_score" property="fillInTheBlanksEachScore"/>
<result column="answer_count" property="answerCount"/>
<result column="answer_each_score" property="answerEachScore"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="paper_status" property="paperStatus"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `exam_paper` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`paper_id` char(36) NOT NULL COMMENT '试卷主键',
`paper_name` varchar(255) DEFAULT NULL COMMENT '试卷名称',
`paper_number` varchar(255) DEFAULT NULL COMMENT '试卷编码',
`paper_type` varchar(255) DEFAULT NULL COMMENT '试卷类型',
`pass_score` double(11,2) DEFAULT NULL COMMENT '及格分数',
`total_score` double(11,2) DEFAULT NULL COMMENT '总分',
`choice_single_count` int(11) DEFAULT NULL COMMENT '单选数量',
`choice_single_each_score` double(11,2) DEFAULT NULL COMMENT '单选每题得分',
`choice_multiple_count` int(11) DEFAULT NULL COMMENT '多选数量',
`choice_multiple_each_score` double(11,2) DEFAULT NULL COMMENT '多选每题得分',
`ture_or_false_count` int(11) DEFAULT NULL COMMENT '判断数量',
`ture_or_false_each_score` double(11,2) DEFAULT NULL COMMENT '判断每题得分',
`fill_in_the_blanks_count` int(11) DEFAULT NULL COMMENT '填空数量',
`fill_in_the_blanks_each_score` double(11,2) DEFAULT NULL COMMENT '填空每题得分',
`answer_count` int(11) DEFAULT NULL COMMENT '解答数量',
`answer_each_score` double(11,2) DEFAULT NULL COMMENT '解答每题得分',
`paper_status` int(1) DEFAULT '0' COMMENT '试卷状态0未就绪1已就绪',
`creator` char(36) DEFAULT NULL,
`gmt_create` datetime DEFAULT NULL,
`modifier` char(36) DEFAULT NULL,
`gmt_modified` datetime DEFAULT NULL,
`is_delete` int(1) DEFAULT '0',
PRIMARY KEY (`id`,`paper_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update>
<!-- 新增试卷 -->
<insert id="save" parameterType="map">
INSERT INTO exam_paper(
paper_id,
paper_name,
paper_number,
paper_type,
pass_score,
total_score,
choice_single_count,
choice_single_each_score,
choice_multiple_count,
choice_multiple_each_score,
ture_or_false_count,
ture_or_false_each_score,
fill_in_the_blanks_count,
fill_in_the_blanks_each_score,
answer_count,
answer_each_score,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{paperId},
#{paperName},
#{paperNumber},
#{paperType},
#{passScore},
#{totalScore},
#{choiceSingleCount},
#{choiceSingleEachScore},
#{choiceMultipleCount},
#{choiceMultipleEachScore},
#{tureOrFalseCount},
#{tureOrFalseEachScore},
#{fillInTheBlanksCount},
#{fillInTheBlanksEachScore},
#{answerCount},
#{answerEachScore},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除试卷 -->
<update id="remove" parameterType="map">
UPDATE
exam_paper
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
paper_id IN
<foreach collection="paperIds" index="index" open="(" separator="," close=")">
#{paperIds[${index}]}
</foreach>
</update>
<!-- 删除试卷(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
exam_paper
WHERE
paper_id IN
<foreach collection="paperIds" index="index" open="(" separator="," close=")">
#{paperIds[${index}]}
</foreach>
</update>
<!-- 修改试卷 -->
<update id="update" parameterType="map">
UPDATE
exam_paper
SET
<if test="paperName != null and paperName != ''">
paper_name = #{paperName},
</if>
<if test="paperNumber != null and paperNumber != ''">
paper_number = #{paperNumber},
</if>
<if test="paperType != null and paperType != ''">
paper_type = #{paperType},
</if>
<if test="passScore != null">
pass_score = #{passScore},
</if>
<if test="totalScore != null">
total_score = #{totalScore},
</if>
<if test="choiceSingleCount != null">
choice_single_count = #{choiceSingleCount},
</if>
<if test="choiceSingleEachScore != null">
choice_single_each_score = #{choiceSingleEachScore},
</if>
<if test="choiceMultipleCount != null">
choice_multiple_count = #{choiceMultipleCount},
</if>
<if test="choiceMultipleEachScore != null">
choice_multiple_each_score = #{choiceMultipleEachScore},
</if>
<if test="tureOrFalseCount != null">
ture_or_false_count = #{tureOrFalseCount},
</if>
<if test="tureOrFalseEachScore != null">
ture_or_false_each_score = #{tureOrFalseEachScore},
</if>
<if test="fillInTheBlanksCount != null">
fill_in_the_blanks_count = #{fillInTheBlanksCount},
</if>
<if test="fillInTheBlanksEachScore != null">
fill_in_the_blanks_each_score = #{fillInTheBlanksEachScore},
</if>
<if test="answerCount != null">
answer_count = #{answerCount},
</if>
<if test="answerEachScore != null">
answer_each_score = #{answerEachScore},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
paper_id = #{paperId}
</update>
<!-- 修改试卷状态 -->
<update id="updatePaperStatus" parameterType="map">
UPDATE
exam_paper
SET
paper_status = #{paperStatus}
WHERE
paper_id = #{paperId}
</update>
<!-- 试卷详情 -->
<select id="get" parameterType="map" resultMap="paperDTO">
SELECT
t1.paper_id,
t1.paper_name,
t1.paper_type,
t1.pass_score,
t1.total_score,
t1.choice_single_count,
t1.choice_single_each_score,
t1.choice_multiple_count,
t1.choice_multiple_each_score,
t1.ture_or_false_count,
t1.ture_or_false_each_score,
t1.fill_in_the_blanks_count,
t1.fill_in_the_blanks_each_score,
t1.answer_count,
t1.answer_each_score,
t1.paper_status
FROM
exam_paper t1
WHERE
t1.is_delete = 0
<if test="paperId != null and paperId != ''">
AND
t1.paper_id = #{paperId}
</if>
</select>
<!-- 试卷列表 -->
<select id="list" parameterType="map" resultMap="paperDTO">
SELECT
t1.paper_id,
t1.paper_name,
t1.paper_number,
t1.paper_type,
t1.pass_score,
t1.total_score,
t1.choice_single_count,
t1.choice_single_each_score,
t1.choice_multiple_count,
t1.choice_multiple_each_score,
t1.ture_or_false_count,
t1.ture_or_false_each_score,
t1.fill_in_the_blanks_count,
t1.fill_in_the_blanks_each_score,
t1.answer_count,
t1.answer_each_score,
LEFT(t1.gmt_create, 19) gmt_create,
t1.paper_status
FROM
exam_paper t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
t1.paper_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="paperIds != null and paperIds.size > 0">
AND
t1.paper_id IN
<foreach collection="paperIds" index="index" open="(" separator="," close=")">
#{paperIds[${index}]}
</foreach>
</if>
</select>
<!-- 试卷统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
exam_paper t1
WHERE
t1.is_delete = 0
<if test="creator != null and creator != ''">
AND
t1.creator = #{creator}
</if>
</select>
</mapper>

View File

@ -0,0 +1,87 @@
<?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="ink.wgink.module.examine.dao.paper.IPaperQuestionDao">
<resultMap id="paperDTO" type="ink.wgink.module.examine.pojo.dtos.paper.PaperQuestionDTO">
<id column="paper_id" property="paperId"/>
<result column="paper_name" property="paperName"/>
</resultMap>
<resultMap id="paperQuestionPO" type="ink.wgink.module.examine.pojo.pos.paper.PaperQuestionPO">
<id column="paper_question_id" property="paperQuestionId"/>
<result column="paper_id" property="paperId"/>
<result column="question_id" property="questionId"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `exam_paper_question` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`paper_question_id` char(36) NOT NULL COMMENT '主键',
`paper_id` char(36) DEFAULT NULL COMMENT '试卷ID',
`question_id` varchar(255) DEFAULT NULL COMMENT '试题ID',
`question_sort` varchar(255) DEFAULT 'ZZZ-000' COMMENT '试题排序'
PRIMARY KEY (`id`,`paper_question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</update>
<!-- 新增试卷 -->
<insert id="save" parameterType="map">
INSERT INTO exam_paper_question(
paper_question_id,
paper_id,
question_id,
question_sort
) VALUES(
#{paperQuestionId},
#{paperId},
#{questionId},
#{questionSort}
)
</insert>
<!-- 删除试卷(物理) -->
<delete id="delete" parameterType="map">
DELETE FROM
exam_paper_question
WHERE
paper_id IN
<foreach collection="paperIds" index="index" open="(" separator="," close=")">
#{paperIds[${index}]}
</foreach>
</delete>
<!-- 修改试题排序 -->
<update id="updateQuestionSort" parameterType="map">
UPDATE
exam_paper_question
SET
question_sort = #{questionSort}
WHERE
paper_question_id = #{paperQuestionId}
</update>
<!-- 试卷试题列表 -->
<select id="listPO" parameterType="map" resultMap="paperQuestionPO">
SELECT
paper_question_id,
paper_id,
question_id,
question_sort
FROM
exam_paper_question
<where>
<if test="paperId != null and paperId != ''">
paper_id = #{paperId}
</if>
<if test="paperIds != null and paperIds.size > 0">
AND
paper_id IN
<foreach collection="paperIds" index="index" open="(" separator="," close=")">
#{paperIds[${index}]}
</foreach>
</if>
</where>
</select>
</mapper>

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
!function(e){const t=e["zh-cn"]=e["zh-cn"]||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"第 %0 步,共 %1 步",Aquamarine:"海蓝色",Black:"黑色","Block quote":"块引用",Blue:"蓝色",Bold:"加粗","Break text":"","Bulleted List":"项目符号列表",Cancel:"取消","Cannot upload file:":"无法上传的文件:","Centered image":"图片居中","Change image text alternative":"更改图片替换文本","Choose heading":"标题类型",Column:"列","Could not insert image at the current position.":"无法在当前位置插入图片","Could not obtain resized image URL.":"无法获取重设大小的图片URL","Decrease indent":"减少缩进","Delete column":"删除本列","Delete row":"删除本行","Dim grey":"暗灰色",Downloadable:"可下载","Dropdown toolbar":"下拉工具栏","Edit block":"编辑框","Edit link":"修改链接","Editor toolbar":"编辑器工具栏","Enter image caption":"输入图片标题","Full size image":"图片通栏显示",Green:"绿色",Grey:"灰色","Header column":"标题列","Header row":"标题行",Heading:"标题","Heading 1":"标题 1","Heading 2":"标题 2","Heading 3":"标题 3","Heading 4":"标题 4","Heading 5":"标题 5","Heading 6":"标题 6","Image toolbar":"图片工具栏","image widget":"图像小部件","In line":"","Increase indent":"增加缩进","Insert column left":"左侧插入列","Insert column right":"右侧插入列","Insert image":"插入图像","Insert image or file":"插入图片或文件","Insert media":"插入媒体","Insert paragraph after block":"在后面插入段落","Insert paragraph before block":"在前面插入段落","Insert row above":"在上面插入一行","Insert row below":"在下面插入一行","Insert table":"插入表格","Inserting image failed":"插入图片失败",Italic:"倾斜","Left aligned image":"图片左侧对齐","Light blue":"浅蓝色","Light green":"浅绿色","Light grey":"浅灰色",Link:"超链接","Link URL":"链接网址","Media URL":"媒体URL","media widget":"媒体小部件","Merge cell down":"向下合并单元格","Merge cell left":"向左合并单元格","Merge cell right":"向右合并单元格","Merge cell up":"向上合并单元格","Merge cells":"合并单元格",Next:"下一步","Numbered List":"项目编号列表","Open in a new tab":"在新标签页中打开","Open link in new tab":"在新标签页中打开链接",Orange:"橙色",Paragraph:"段落","Paste the media URL in the input.":"在输入中粘贴媒体URL",Previous:"上一步",Purple:"紫色",Red:"红色",Redo:"重做","Rich Text Editor":"富文本编辑器","Rich Text Editor, %0":"富文本编辑器, %0","Right aligned image":"图片右侧对齐",Row:"行",Save:"保存","Select all":"全选","Select column":"选择列","Select row":"选择行","Selecting resized image failed":"选择重设大小的图片失败","Show more items":"显示更多","Side image":"图片侧边显示","Split cell horizontally":"横向拆分单元格","Split cell vertically":"纵向拆分单元格","Table toolbar":"表格工具栏","Text alternative":"替换文本","The URL must not be empty.":"URL不可以为空。","This link has no URL":"此链接没有设置网址","This media URL is not supported.":"不支持此媒体URL。","Tip: Paste the URL into the content to embed faster.":"提示将URL粘贴到内容中可更快地嵌入","Toggle caption off":"","Toggle caption on":"",Turquoise:"青色",Undo:"撤销",Unlink:"取消超链接","Upload failed":"上传失败","Upload in progress":"正在上传",White:"白色","Widget toolbar":"小部件工具栏","Wrap text":"",Yellow:"黄色"}),t.getPluralForm=function(e){return 0}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));

View File

@ -0,0 +1,309 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'} ">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/paper/listpage';
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, []),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'paperName', width: 300, title: '试卷名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'paperNumber', width: 180, title: '试卷编码', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'paperType', width: 100, title: '试卷类型', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
if(rowData === 'test') {
return '测试试卷';
} else if(rowData === 'simulation') {
return '模拟试卷';
} else if(rowData === 'examination') {
return '考试试卷';
}
return '错误';
}
},
{field: 'score', width: 180, title: '分数', align:'center', exportType: 'text',
templet: function(row) {
return '<span class="layui-badge layui-bg-green">及格:'+ row.passScore +'</span> / <span class="layui-badge layui-bg-cyan">总分:'+ row.totalScore +'</span>';
}
},
{field: 'choiceSingle', width: 160, title: '单选题', align:'center', exportType: 'text',
templet: function(row) {
if(row.questionType === 'random') {
return '随机'
}
return '<button class="layui-btn layui-btn-xs layui-btn-normal layui-bg-green" data-count="'+ row.choiceSingleCount +'" lay-event="choiceSingleEvent">共 '+ row.choiceSingleCount +' 题【'+ row.choiceSingleEachScore +'分 / 题】</button>';
}
},
{field: 'choiceMultiple', width: 160, title: '多选题', align:'center', exportType: 'text',
templet: function(row) {
if(row.questionType === 'random') {
return '随机'
}
return '<button class="layui-btn layui-btn-xs layui-btn-normal layui-bg-red" data-count="'+ row.choiceMultipleCount +'" lay-event="choiceMultipleEvent">共 '+ row.choiceMultipleCount +' 题【'+ row.choiceMultipleEachScore +'分 / 题】</button>';
}
},
{field: 'tureOrFalse', width: 160, title: '判断题', align:'center', exportType: 'text',
templet: function(row) {
if(row.questionType === 'random') {
return '随机'
}
return '<button class="layui-btn layui-btn-xs layui-btn-normal" data-count="'+ row.tureOrFalseCount +'" lay-event="tureOrFalseEvent">共 '+ row.tureOrFalseCount +' 题【'+ row.tureOrFalseEachScore +'分 / 题】</button>';
}
},
{field: 'fillInTheBlanks', width: 160, title: '填空题', align:'center', exportType: 'text',
templet: function(row) {
if(row.questionType === 'random') {
return '随机'
}
return '<button class="layui-btn layui-btn-xs layui-btn-normal layui-bg-cyan" data-count="'+ row.fillInTheBlanksCount +'" lay-event="fillInTheBlanksEvent">共 '+ row.fillInTheBlanksCount +' 题【'+ row.fillInTheBlanksEachScore +'分 / 题】</button>';
}
},
{field: 'answer', width: 160, title: '解答题', align:'center', exportType: 'text',
templet: function(row) {
if(row.questionType === 'random') {
return '随机'
}
return '<button class="layui-btn layui-btn-xs layui-btn-normal layui-bg-orange" data-count="'+ row.answerCount +'" lay-event="answerEvent">共 '+ row.answerCount +' 题【'+ row.answerEachScore +'分 / 题】</button>';
}
},
{field: 'gmtCreate', width: 180, title: '添加时间', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
]
],
page: true,
parseData: function(data) {
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path(tableUrl, []),
where: {
keywords: $('#keywords').val(),
},
page: {
curr: currentPage
},
});
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/paper/remove/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/paper/save', []),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'updateEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/paper/update?paperId={paperId}', [checkDatas[0].paperId]),
end: function() {
reloadTable();
}
});
}
} else if(layEvent === 'removeEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item['paperId'];
}
removeData(ids);
}
}
});
// 试卷考题
function openPaperQuestion(title, questionType, data, count) {
top.dialog.open({
url: top.restAjax.path('route/pager/question/list?paperId={paperId}&questionType={questionType}&selectCount={count}', [data.paperId, questionType, count]),
title: '【'+ title +'】试题列表',
width: '1000px',
height: '80%',
onClose: function() {}
});
}
table.on('tool(dataTable)', function(obj) {
var data = obj.data;
var event = obj.event;
if(event === 'choiceSingleEvent') {
openPaperQuestion('单选', 'choiceSingle', data, this.dataset.count);
} else if(event === 'choiceMultipleEvent') {
openPaperQuestion('多选', 'choiceMultiple', data, this.dataset.count);
} else if(event === 'tureOrFalseEvent') {
openPaperQuestion('判断', 'tureOrFalse', data, this.dataset.count);
} else if(event === 'fillInTheBlanksEvent') {
openPaperQuestion('填空', 'fillInTheBlanks', data, this.dataset.count);
} else if(event === 'answerEvent') {
openPaperQuestion('解答', 'answer', data, this.dataset.count);
}
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,364 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'} ">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="randomSaveEvent">
<i class="fa fa-lg fa-plus"></i> 随机抽取
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" lay-event="manualSaveEvent">
<i class="fa fa-lg fa-hand-pointer-o"></i> 手动选择
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" lay-event="clearSaveEvent">
<i class="fa fa-lg fa-remove"></i> 删除
</button>
</div>
</script>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var queryParams = top.restAjax.params(window.location.href);
var paperId = queryParams.paperId;
var questionType = queryParams.questionType;
var selectCount = queryParams.selectCount;
var selectedCount = 0;
var tableUrl = 'api/paper/question/listpage?paperId={paperId}&questionType={questionType}';
function getDifficulty(num) {
var result = '';
for(var i = 0; i < num; i++) {
result += '⭐'
}
return result;
}
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, [paperId, questionType]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
request: {
pageName: 'page',
limitName: 'rows'
},
cols: [
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'questionSubject', width: 400, title: '题目', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'questionType', width: 150, title: '种类', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
if(rowData == 'choice') {
return '选择题';
} else if(rowData == 'tureOrFalse') {
return '判断题';
} else if(rowData == 'fillInTheBlanks') {
return '填空题';
} else if(rowData == 'answer') {
return '解答题';
}
return rowData;
}
},
{field: 'questionChoiceType', width: 150, title: '选择类别', align:'center',
templet: function(row) {
if(row.questionType != 'choice') {
return '-';
}
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
if(rowData == 'single') {
return '单选';
} else if(rowData == 'multiple') {
return '多选';
}
return rowData;
}
},
{field: 'questionDifficulty', width: 150, title: '难度', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return getDifficulty(rowData);
}
},
{field: 'questionSource', width: 150, title: '来源', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'getQuestion', width: 90, title: '详情', fixed: 'right', align:'center', exportType: 'text',
templet: function(row) {
return '<button class="layui-btn layui-btn layui-btn-xs layui-btn-normal" lay-event="getQuestionEvent"><i class="fa fa-search"></i> 查看</button>';
}
},
]
],
page: true,
parseData: function(data) {
selectedCount = data.total;
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
url: top.restAjax.path(tableUrl, [paperId, questionType]),
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
},
page: {
curr: currentPage
},
height: $win.height() - 60,
});
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/paper/question/delete/{paperId}/{ids}', [paperId, ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
initTable();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', function() {
reloadTable(1);
});
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/examinationpaperquestion/removeexaminationpaperquestion/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
}
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'randomSaveEvent') {
top.dialog.msg('将随机抽取该类型试题,原有试题将全部删除,确定操作?', {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.post(top.restAjax.path('api/examinationpaperquestion/saveexaminationpaperquestionrandom', []), {
paperId: paperId,
questionType: questionType
}, null, function (code, data) {
top.dialog.msg('操作成功', {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
});
} else if(layEvent === 'manualSaveEvent') {
var type;
var choiceType;
if(questionType === 'choiceSingle') {
type = 'choice';
choiceType = 'single';
} else if(questionType === 'choiceMultiple') {
type = 'choice';
choiceType = 'multiple';
} else if(questionType === 'tureOrFalse') {
type = 'tureOrFalse';
choiceType = '';
} else if(questionType === 'fillInTheBlanks') {
type = 'fillInTheBlanks';
choiceType = '';
} else if(questionType === 'answer') {
type = 'answer';
choiceType = '';
}
top.dialog.open({
url: top.restAjax.path('route/question/list-select?selectCount={selectCount}&type={type}&choiceType={choiceType}', [parseInt(selectCount - selectedCount), type, choiceType]),
title: '选择考题',
width: '75%',
height: '80%',
onClose: function() {
var newSelectedQuestionList = top.dialog.dialogData.newSelectedQuestionList;
if(newSelectedQuestionList.length != 0) {
var questionIds = [];
for(var i = 0, item; item = newSelectedQuestionList[i++];) {
questionIds.push(item.questionId);
}
if(questionIds.length > 0) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/paper/question/save', []), {
paperId: paperId,
questionType: questionType,
questionIds: questionIds
}, null, function(code, data) {
top.dialog.msg('添加成功', {time: 1000});
reloadTable();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
}
}
top.dialog.dialogData.oldSelectedQuestionList = [];
}
});
} else if(layEvent === 'clearSaveEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item['paperQuestionId'];
}
removeData(ids);
}
}
});
table.on('tool(dataTable)', function(obj) {
var data = obj.data;
var event = obj.event;
if(event === 'getQuestionEvent') {
top.dialog.open({
url: top.restAjax.path('route/question/get?questionId={questionId}', [data.questionId]),
title: '查看试题,难度:' + getDifficulty(data.questionDifficulty),
width: '500px',
height: '80%',
onClose: function() {
}
});
}
})
});
</script>
</body>
</html>

View File

@ -0,0 +1,258 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'} ">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
.layui-form-pane .layui-form-label {width: 130px;}
.layui-form-pane .layui-input-block {margin-left: 130px;}
</style>
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>新增内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm8 layui-col-md8">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">名称</label>
<div class="layui-input-block">
<input type="text" id="paperName" name="paperName" class="layui-input" value="" placeholder="请输入名称" lay-verify="required">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">试卷类型</label>
<div class="layui-input-block">
<input type="radio" name="paperType" value="test" title="测试试卷" checked>
<input type="radio" name="paperType" value="simulation" title="模拟试卷">
<input type="radio" name="paperType" value="examination" title="考试试卷">
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">单选数量</label>
<div class="layui-input-block">
<input type="number" id="choiceSingleCount" name="choiceSingleCount" class="layui-input question-count" value="30" placeholder="请输入单选数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">单选每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="choiceSingleEachScore" name="choiceSingleEachScore" class="layui-input question-score" value="2.0" placeholder="请输入单选每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">多选数量</label>
<div class="layui-input-block">
<input type="number" id="choiceMultipleCount" name="choiceMultipleCount" class="layui-input question-count" value="10" placeholder="请输入多选数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">多选每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="choiceMultipleEachScore" name="choiceMultipleEachScore" class="layui-input question-score" value="2.0" placeholder="请输入多选每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">判断数量</label>
<div class="layui-input-block">
<input type="number" id="tureOrFalseCount" name="tureOrFalseCount" class="layui-input question-count" value="10" placeholder="请输入判断数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">判断每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="tureOrFalseEachScore" name="tureOrFalseEachScore" class="layui-input question-score" value="2.0" placeholder="请输入判断每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">填空数量</label>
<div class="layui-input-block">
<input type="number" id="fillInTheBlanksCount" name="fillInTheBlanksCount" class="layui-input question-count" value="10" placeholder="请输入填空数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">填空每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="fillInTheBlanksEachScore" name="fillInTheBlanksEachScore" class="layui-input question-score" value="1.0" placeholder="请输入填空每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">解答数量</label>
<div class="layui-input-block">
<input type="number" id="answerCount" name="answerCount" class="layui-input question-count" value="2" placeholder="请输入解答数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">解答每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="answerEachScore" name="answerEachScore" class="layui-input question-score" value="5.0" placeholder="请输入解答每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">及格分数</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="passScore" name="passScore" class="layui-input" value="60.0" placeholder="请输入及格分数" lay-verify="required|minNumberVerify|passScoreVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">总分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="totalScore" name="totalScore" class="layui-input" value="100.0" placeholder="请输入总分" lay-verify="required|minNumberVerify" readonly>
</div>
</div>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化内容
function initData() {
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/paper/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
$('.question-count, .question-score').on('keyup', function() {
var choiceSingleCount = $('#choiceSingleCount').val() ? $('#choiceSingleCount').val() : 0;
var choiceMultipleCount = $('#choiceMultipleCount').val() ? $('#choiceMultipleCount').val() : 0;
var tureOrFalseCount = $('#tureOrFalseCount').val() ? $('#tureOrFalseCount').val() : 0;
var fillInTheBlanksCount = $('#fillInTheBlanksCount').val() ? $('#fillInTheBlanksCount').val() : 0;
var answerCount = $('#answerCount').val() ? $('#answerCount').val() : 0;
var choiceSingleEachScore = parseFloat($('#choiceSingleEachScore').val() ? $('#choiceSingleEachScore').val() : 0);
var choiceMultipleEachScore = parseFloat($('#choiceMultipleEachScore').val() ? $('#choiceMultipleEachScore').val() : 0);
var tureOrFalseEachScore = parseFloat($('#tureOrFalseEachScore').val() ? $('#tureOrFalseEachScore').val() : 0);
var fillInTheBlanksEachScore = parseFloat($('#fillInTheBlanksEachScore').val() ? $('#fillInTheBlanksEachScore').val() : 0);
var answerEachScore = parseFloat($('#answerEachScore').val() ? $('#answerEachScore').val() : 0);
var totalScore = choiceSingleCount * choiceSingleEachScore +
choiceMultipleCount * choiceMultipleEachScore +
tureOrFalseCount * tureOrFalseEachScore +
fillInTheBlanksCount * fillInTheBlanksEachScore +
answerCount * answerEachScore;
form.val('dataForm', {
totalScore: totalScore
});
});
// 校验
form.verify({
minNumberVerify: function(value, item) {
if(parseFloat(value) < 0) {
return '数字不能小于0';
}
},
passScoreVerify: function(value, item) {
if(parseFloat(value) > parseFloat($('#totalScore').val() ? $('#totalScore').val() : 0)) {
return '及格分数不能大于总分';
}
}
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,276 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'} ">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
.layui-form-pane .layui-form-label {width: 130px;}
.layui-form-pane .layui-input-block {margin-left: 130px;}
</style>
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm8 layui-col-md8">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">名称</label>
<div class="layui-input-block">
<input type="text" id="paperName" name="paperName" class="layui-input" value="" placeholder="请输入名称" lay-verify="required">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">试卷类型</label>
<div class="layui-input-block">
<input type="radio" name="paperType" value="test" title="测试试卷" checked>
<input type="radio" name="paperType" value="simulation" title="模拟试卷">
<input type="radio" name="paperType" value="examination" title="考试试卷">
</div>
</div>
<div class="layui-row">
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">单选数量</label>
<div class="layui-input-block">
<input type="number" id="choiceSingleCount" name="choiceSingleCount" class="layui-input question-count" value="20" placeholder="请输入单选数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">单选每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="choiceSingleEachScore" name="choiceSingleEachScore" class="layui-input question-score" value="2.0" placeholder="请输入单选每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">多选数量</label>
<div class="layui-input-block">
<input type="number" id="choiceMultipleCount" name="choiceMultipleCount" class="layui-input question-count" value="10" placeholder="请输入多选数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">多选每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="choiceMultipleEachScore" name="choiceMultipleEachScore" class="layui-input question-score" value="2.0" placeholder="请输入多选每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">判断数量</label>
<div class="layui-input-block">
<input type="number" id="tureOrFalseCount" name="tureOrFalseCount" class="layui-input question-count" value="10" placeholder="请输入判断数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">判断每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="tureOrFalseEachScore" name="tureOrFalseEachScore" class="layui-input question-score" value="2.0" placeholder="请输入判断每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">填空数量</label>
<div class="layui-input-block">
<input type="number" id="fillInTheBlanksCount" name="fillInTheBlanksCount" class="layui-input question-count" value="10" placeholder="请输入填空数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">填空每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="fillInTheBlanksEachScore" name="fillInTheBlanksEachScore" class="layui-input question-score" value="1.0" placeholder="请输入填空每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">解答数量</label>
<div class="layui-input-block">
<input type="number" id="answerCount" name="answerCount" class="layui-input question-count" value="2" placeholder="请输入解答数量" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">解答每题得分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="answerEachScore" name="answerEachScore" class="layui-input question-score" value="5.0" placeholder="请输入解答每题得分" lay-verify="required|minNumberVerify">
</div>
</div>
</div>
</div>
</div>
<div class="layui-row">
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">及格分数</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="passScore" name="passScore" class="layui-input" value="60.0" placeholder="请输入及格分数" lay-verify="required|minNumberVerify|passScoreVerify">
</div>
</div>
</div>
<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">总分</label>
<div class="layui-input-block">
<input type="number" step="0.01" id="totalScore" name="totalScore" class="layui-input" value="100.0" placeholder="请输入总分" lay-verify="required|minNumberVerify" readonly>
</div>
</div>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var paperId = top.restAjax.params(window.location.href).paperId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化内容
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/paper/get/{paperId}', [paperId]), {}, null, function(code, data) {
var dataFormData = {};
for(var i in data) {
dataFormData[i] = data[i] +'';
}
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/paper/update/{paperId}', [paperId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
$('.question-count, .question-score').on('keyup', function() {
var choiceSingleCount = $('#choiceSingleCount').val() ? $('#choiceSingleCount').val() : 0;
var choiceMultipleCount = $('#choiceMultipleCount').val() ? $('#choiceMultipleCount').val() : 0;
var tureOrFalseCount = $('#tureOrFalseCount').val() ? $('#tureOrFalseCount').val() : 0;
var fillInTheBlanksCount = $('#fillInTheBlanksCount').val() ? $('#fillInTheBlanksCount').val() : 0;
var answerCount = $('#answerCount').val() ? $('#answerCount').val() : 0;
var choiceSingleEachScore = parseFloat($('#choiceSingleEachScore').val() ? $('#choiceSingleEachScore').val() : 0);
var choiceMultipleEachScore = parseFloat($('#choiceMultipleEachScore').val() ? $('#choiceMultipleEachScore').val() : 0);
var tureOrFalseEachScore = parseFloat($('#tureOrFalseEachScore').val() ? $('#tureOrFalseEachScore').val() : 0);
var fillInTheBlanksEachScore = parseFloat($('#fillInTheBlanksEachScore').val() ? $('#fillInTheBlanksEachScore').val() : 0);
var answerEachScore = parseFloat($('#answerEachScore').val() ? $('#answerEachScore').val() : 0);
var totalScore = choiceSingleCount * choiceSingleEachScore +
choiceMultipleCount * choiceMultipleEachScore +
tureOrFalseCount * tureOrFalseEachScore +
fillInTheBlanksCount * fillInTheBlanksEachScore +
answerCount * answerEachScore;
form.val('dataForm', {
totalScore: totalScore
});
});
// 校验
form.verify({
minNumberVerify: function(value, item) {
if(parseFloat(value) < 0) {
return '数字不能小于0';
}
},
passScoreVerify: function(value, item) {
if(parseFloat(value) > parseFloat($('#totalScore').val() ? $('#totalScore').val() : 0)) {
return '及格分数不能大于总分';
}
}
});
});
</script>
</body>
</html>

View File

@ -118,19 +118,6 @@
return result;
}
// 初始化试题类型下拉选择
function initQuestionTypeSelect() {
top.restAjax.get(top.restAjax.path('api/data/listbyparentid/a7d1ab3d-fbd2-48ca-bfb8-353cad9f3eba', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('questionTypeSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('questionTypeSelectTemplateBox').innerHTML = html;
});
form.render('select', 'questionTypeSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
initQuestionTypeSelect();
// 初始化表格
function initTable() {
$.extend(table, {config: {checkName: 'checked'}});
@ -294,23 +281,9 @@
page: {
curr: currentPage
},
height: $win.height() - 60,
});
}
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#startTime',
format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#endTime',
format: 'yyyy-MM-dd'
});
}
initTable();
initDate();
function isQuestionSelected(questionId) {
for(var i = 0, item; item = newSelectedQuestionList[i++];) {
if(questionId == item.questionId) {
@ -398,30 +371,30 @@
}
});
$('#customQuestionTypeName').on('click', function() {
$('#questionTypeName').on('click', function() {
top.dialog.open({
url: top.restAjax.path('route/questiontype/list-tree-select.html?questionTypeIds={questionTypeIds}', [$('#customQuestionType').val()]),
url: top.restAjax.path('route/questiontype/list-tree-select.html?questionTypeIds={questionTypeIds}', [$('#questionType').val()]),
title: '选择自定义类型',
width: '200px',
height: '400px',
onClose: function() {
var selectedNodes = top.dialog.dialogData.selectedNodes;
if(selectedNodes.length > 0) {
var customQuestionType = '';
var customQuestionTypeName = '';
var questionType = '';
var questionTypeName = '';
for(var i = 0, item; item = selectedNodes[i++];) {
if(customQuestionType.length > 0) {
customQuestionType += ',';
customQuestionTypeName += ',';
if(questionType.length > 0) {
questionType += ',';
questionTypeName += ',';
}
customQuestionType += item.id;
customQuestionTypeName += item.name;
questionType += item.id;
questionTypeName += item.name;
}
$('#customQuestionType').val(customQuestionType);
$('#customQuestionTypeName').val(customQuestionTypeName);
$('#questionType').val(questionType);
$('#questionTypeName').val(questionTypeName);
} else {
$('#customQuestionType').val('');
$('#customQuestionTypeName').val('');
$('#questionType').val('');
$('#questionTypeName').val('');
}
}
});

View File

@ -16,6 +16,8 @@
.option-td-center .layui-form-checkbox {margin: 0;}
.option-td-center .layui-form-checkbox i {font-weight:bold; border-left: 1px solid #d2d2d2;}
.custom-course-type {width: 200px;height:30px;display: inline-block;margin: 3px 10px;}
.w-e-text ol li {list-style: decimal;}
.w-e-text ul li {list-style: disc;}
</style>
</head>
<body>

View File

@ -16,6 +16,8 @@
.option-td-center .layui-form-checkbox {margin: 0;}
.option-td-center .layui-form-checkbox i {font-weight:bold; border-left: 1px solid #d2d2d2;}
.custom-course-type {width: 200px;height:30px;display: inline-block;margin: 3px 10px;}
.w-e-text ol li {list-style: decimal;}
.w-e-text ul li {list-style: disc;}
</style>
</head>
<body>