完善试卷试题基础功能
This commit is contained in:
parent
31ec86a158
commit
9cad965750
@ -1,11 +1,14 @@
|
||||
package ink.wgink.module.examine.controller.api.paper.question;
|
||||
|
||||
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.question.PaperQuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.dtos.question.QuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.vos.paper.question.PaperQuestionRandomSaveVO;
|
||||
import ink.wgink.module.examine.service.paper.question.IPaperQuestionService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
@ -16,6 +19,7 @@ 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;
|
||||
|
||||
@ -48,6 +52,29 @@ public class PaperQuestionController extends DefaultBaseController {
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "随机保存试题", notes = "随机保存试题接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "paperId", value = "试卷ID", paramType = "path"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("save-random/paper-id/{paperId}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult saveRandom(@PathVariable("paperId") String paperId, @RequestBody PaperQuestionRandomSaveVO paperQuestionRandomSaveVO) {
|
||||
paperQuestionService.saveRandom(paperId, paperQuestionRandomSaveVO);
|
||||
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("delete/{ids}")
|
||||
public SuccessResult delete(@PathVariable("ids") String ids) throws RemoveException {
|
||||
paperQuestionService.delete(Arrays.asList(ids.split("\\_")));
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "试卷试题列表", notes = "试卷试题列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "paperId", value = "试卷ID", paramType = "path"),
|
||||
|
@ -72,4 +72,12 @@ public interface IPaperQuestionDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<QuestionDTO> listQuestion(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* ID列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<String> listId(Map<String, Object> params);
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package ink.wgink.module.examine.pojo.vos.paper.question;
|
||||
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: PaperQuestionRandomSaveVO
|
||||
* @Description: 试卷试题随机保存
|
||||
* @Author: wanggeng
|
||||
* @Date: 2022/5/26 15:43
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@ApiModel
|
||||
public class PaperQuestionRandomSaveVO {
|
||||
|
||||
@ApiModelProperty(name = "questionType", value = "")
|
||||
@CheckEmptyAnnotation(name = "试题种类")
|
||||
private String questionType;
|
||||
@ApiModelProperty(name = "questionChoiceType", value = "")
|
||||
@CheckEmptyAnnotation(name = "试题选择类型")
|
||||
private String questionChoiceType;
|
||||
|
||||
public String getQuestionType() {
|
||||
return questionType == null ? "" : questionType.trim();
|
||||
}
|
||||
|
||||
public void setQuestionType(String questionType) {
|
||||
this.questionType = questionType;
|
||||
}
|
||||
|
||||
public String getQuestionChoiceType() {
|
||||
return questionChoiceType == null ? "" : questionChoiceType.trim();
|
||||
}
|
||||
|
||||
public void setQuestionChoiceType(String questionChoiceType) {
|
||||
this.questionChoiceType = questionChoiceType;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package ink.wgink.module.examine.service.paper.question;
|
||||
|
||||
import ink.wgink.module.examine.pojo.dtos.paper.question.PaperQuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.dtos.question.QuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.vos.paper.question.PaperQuestionRandomSaveVO;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
|
||||
@ -24,6 +25,21 @@ public interface IPaperQuestionService {
|
||||
*/
|
||||
void save(String paperId, List<String> questionIds);
|
||||
|
||||
/**
|
||||
* 随机保存
|
||||
*
|
||||
* @param paperId
|
||||
* @param paperQuestionRandomSaveVO
|
||||
*/
|
||||
void saveRandom(String paperId, PaperQuestionRandomSaveVO paperQuestionRandomSaveVO);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param paperQuestionIds
|
||||
*/
|
||||
void delete(List<String> paperQuestionIds);
|
||||
|
||||
/**
|
||||
* 试卷试题列表
|
||||
*
|
||||
|
@ -1,12 +1,20 @@
|
||||
package ink.wgink.module.examine.service.paper.question.impl;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.module.examine.dao.paper.question.IPaperQuestionDao;
|
||||
import ink.wgink.module.examine.enums.question.QuestionChoiceTypeEnum;
|
||||
import ink.wgink.module.examine.enums.question.QuestionTypeEnum;
|
||||
import ink.wgink.module.examine.pojo.dtos.paper.PaperDTO;
|
||||
import ink.wgink.module.examine.pojo.dtos.paper.question.PaperQuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.dtos.question.QuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.vos.paper.question.PaperQuestionRandomSaveVO;
|
||||
import ink.wgink.module.examine.service.paper.IPaperService;
|
||||
import ink.wgink.module.examine.service.paper.question.IPaperQuestionService;
|
||||
import ink.wgink.module.examine.service.question.IQuestionService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
@ -27,6 +35,10 @@ public class PaperQuestionServiceImpl extends DefaultBaseService implements IPap
|
||||
|
||||
@Autowired
|
||||
private IPaperQuestionDao paperQuestionDao;
|
||||
@Autowired
|
||||
private IPaperService paperService;
|
||||
@Autowired
|
||||
private IQuestionService questionService;
|
||||
|
||||
@Override
|
||||
public void save(String paperId, List<String> questionIds) {
|
||||
@ -40,6 +52,72 @@ public class PaperQuestionServiceImpl extends DefaultBaseService implements IPap
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRandom(String paperId, PaperQuestionRandomSaveVO paperQuestionRandomSaveVO) {
|
||||
PaperDTO paperDTO = paperService.getById(paperId);
|
||||
QuestionTypeEnum questionTypeEnum = null;
|
||||
QuestionChoiceTypeEnum questionChoiceTypeEnum = null;
|
||||
int randomCount = 0;
|
||||
// 单选
|
||||
if (StringUtils.equals(paperQuestionRandomSaveVO.getQuestionType(), QuestionTypeEnum.CHOICE.getValue()) &&
|
||||
StringUtils.equals(paperQuestionRandomSaveVO.getQuestionChoiceType(), QuestionChoiceTypeEnum.SINGLE.getValue())) {
|
||||
questionTypeEnum = QuestionTypeEnum.CHOICE;
|
||||
questionChoiceTypeEnum = QuestionChoiceTypeEnum.SINGLE;
|
||||
randomCount = paperDTO.getChoiceSingleCount();
|
||||
}
|
||||
// 多选
|
||||
if (StringUtils.equals(paperQuestionRandomSaveVO.getQuestionType(), QuestionTypeEnum.CHOICE.getValue()) &&
|
||||
StringUtils.equals(paperQuestionRandomSaveVO.getQuestionChoiceType(), QuestionChoiceTypeEnum.MULTIPLE.getValue())) {
|
||||
questionTypeEnum = QuestionTypeEnum.CHOICE;
|
||||
questionChoiceTypeEnum = QuestionChoiceTypeEnum.MULTIPLE;
|
||||
randomCount = paperDTO.getChoiceMultipleCount();
|
||||
}
|
||||
// 判断
|
||||
if (StringUtils.equals(paperQuestionRandomSaveVO.getQuestionType(), QuestionTypeEnum.TURE_OR_FALSE.getValue())) {
|
||||
questionTypeEnum = QuestionTypeEnum.TURE_OR_FALSE;
|
||||
randomCount = paperDTO.getTureOrFalseCount();
|
||||
}
|
||||
// 填空
|
||||
if (StringUtils.equals(paperQuestionRandomSaveVO.getQuestionType(), QuestionTypeEnum.FILL_IN_THE_BLANKS.getValue())) {
|
||||
questionTypeEnum = QuestionTypeEnum.FILL_IN_THE_BLANKS;
|
||||
randomCount = paperDTO.getFillInTheBlanksCount();
|
||||
}
|
||||
// 解答
|
||||
if (StringUtils.equals(paperQuestionRandomSaveVO.getQuestionType(), QuestionTypeEnum.ANSWER.getValue())) {
|
||||
questionTypeEnum = QuestionTypeEnum.ANSWER;
|
||||
randomCount = paperDTO.getAnswerCount();
|
||||
}
|
||||
// 随机抽题
|
||||
List<String> randomQuestionIds = questionService.listRandomIdByRandomCountAndTypeAndChoiceType(randomCount, questionTypeEnum, questionChoiceTypeEnum);
|
||||
if (randomQuestionIds.isEmpty()) {
|
||||
throw new SaveException("没有试题可以随机");
|
||||
}
|
||||
|
||||
// 删除对应的试题
|
||||
Map<String, Object> params = getHashMap(6);
|
||||
params.put("questionType", questionTypeEnum.getValue());
|
||||
params.put("questionChoiceType", questionChoiceTypeEnum == null ? null : questionChoiceTypeEnum.getValue());
|
||||
params.put("paperId", paperId);
|
||||
List<String> wantDeleteIds = paperQuestionDao.listId(params);
|
||||
|
||||
if (!wantDeleteIds.isEmpty()) {
|
||||
// 删除
|
||||
params.clear();
|
||||
params.put("paperQuestionIds", wantDeleteIds);
|
||||
paperQuestionDao.delete(params);
|
||||
}
|
||||
|
||||
// 保存试题
|
||||
save(paperId, randomQuestionIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(List<String> paperQuestionIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("paperQuestionIds", paperQuestionIds);
|
||||
paperQuestionDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaperQuestionDTO> list(String paperId, Map<String, Object> params) {
|
||||
params = params == null ? getHashMap(0) : params;
|
||||
|
@ -2,6 +2,8 @@ package ink.wgink.module.examine.service.question;
|
||||
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.module.examine.enums.question.QuestionChoiceTypeEnum;
|
||||
import ink.wgink.module.examine.enums.question.QuestionTypeEnum;
|
||||
import ink.wgink.module.examine.pojo.dtos.question.QuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.vos.question.QuestionVO;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
@ -145,5 +147,14 @@ public interface IQuestionService {
|
||||
*/
|
||||
Integer count(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 随机试题ID
|
||||
*
|
||||
* @param randomCount
|
||||
* @param questionTypeEnum
|
||||
* @param questionChoiceTypeEnum
|
||||
* @return
|
||||
*/
|
||||
List<String> listRandomIdByRandomCountAndTypeAndChoiceType(int randomCount, QuestionTypeEnum questionTypeEnum, QuestionChoiceTypeEnum questionChoiceTypeEnum);
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.module.examine.dao.question.IQuestionDao;
|
||||
import ink.wgink.module.examine.enums.question.QuestionChoiceTypeEnum;
|
||||
import ink.wgink.module.examine.enums.question.QuestionTypeEnum;
|
||||
import ink.wgink.module.examine.pojo.dtos.question.QuestionDTO;
|
||||
import ink.wgink.module.examine.pojo.dtos.question.QuestionOptionsDTO;
|
||||
@ -24,9 +25,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ClassName: QuestionServiceImpl
|
||||
@ -243,6 +242,29 @@ public class QuestionServiceImpl extends DefaultBaseService implements IQuestion
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listRandomIdByRandomCountAndTypeAndChoiceType(int randomCount, QuestionTypeEnum questionTypeEnum, QuestionChoiceTypeEnum questionChoiceTypeEnum) {
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("type", questionTypeEnum.getValue());
|
||||
params.put("choiceType", questionChoiceTypeEnum == null ? null : questionChoiceTypeEnum.getValue());
|
||||
List<String> questionIds = questionDao.listIds(params);
|
||||
// 试题数小于随机总数,返回全部试题ID
|
||||
if (questionIds.size() <= randomCount) {
|
||||
return questionIds;
|
||||
}
|
||||
Random random = new Random(System.currentTimeMillis());
|
||||
Map<Integer, String> randomMap = new HashMap<>(randomCount * 2);
|
||||
while (randomMap.size() < randomCount) {
|
||||
int randomNumber = random.nextInt(questionIds.size());
|
||||
randomMap.put(randomNumber, questionIds.get(randomNumber));
|
||||
}
|
||||
List<String> randomQuestionIds = new ArrayList<>();
|
||||
for (Map.Entry<Integer, String> kv : randomMap.entrySet()) {
|
||||
randomQuestionIds.add(kv.getValue());
|
||||
}
|
||||
return randomQuestionIds;
|
||||
}
|
||||
|
||||
private List<QuestionPO> listPOByIds(List<String> questionIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("questionIds", questionIds);
|
||||
|
@ -48,14 +48,14 @@
|
||||
)
|
||||
</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}]}
|
||||
paper_question_id IN
|
||||
<foreach collection="paperQuestionIds" index="index" open="(" separator="," close=")">
|
||||
#{paperQuestionIds[${index}]}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
@ -131,6 +131,10 @@
|
||||
AND
|
||||
jt1.type = #{questionType}
|
||||
</if>
|
||||
<if test="questionChoiceType != null and questionChoiceType != ''">
|
||||
AND
|
||||
jt1.choice_type = #{questionChoiceType}
|
||||
</if>
|
||||
<if test="sort != null and (sort == 'questionSort')">
|
||||
ORDER BY
|
||||
<if test="sort == 'questionSort'">
|
||||
@ -186,6 +190,10 @@
|
||||
AND
|
||||
t1.choice_type = #{choiceType}
|
||||
</if>
|
||||
<if test="questionType != null and questionType != ''">
|
||||
AND
|
||||
t1.question_type = #{questionType}
|
||||
</if>
|
||||
<if test="questionIds != null and questionIds.size > 0">
|
||||
AND
|
||||
t1.question_id IN
|
||||
@ -224,4 +232,31 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 试题ID列表 -->
|
||||
<select id="listId" parameterType="map" resultType="java.lang.String">
|
||||
SELECT
|
||||
t1.paper_question_id
|
||||
FROM
|
||||
exam_paper_question t1
|
||||
<if test="questionType != null and questionType != ''">
|
||||
INNER JOIN
|
||||
exam_question jt1
|
||||
ON
|
||||
t1.question_id = jt1.question_id
|
||||
</if>
|
||||
<where>
|
||||
<if test="paperId != null and paperId != ''">
|
||||
t1.paper_id = #{paperId}
|
||||
</if>
|
||||
<if test="questionType != null and questionType != ''">
|
||||
AND
|
||||
jt1.type = #{questionType}
|
||||
<if test="questionChoiceType != null and questionChoiceType != ''">
|
||||
AND
|
||||
jt1.choice_type = #{questionChoiceType}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -279,9 +279,9 @@
|
||||
}
|
||||
});
|
||||
// 试卷考题
|
||||
function openPaperQuestion(title, questionType, data, count) {
|
||||
function openPaperQuestion(title, questionType, questionChoiceType, data, count) {
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/paper/question/list?paperId={paperId}&questionType={questionType}&selectCount={count}', [data.paperId, questionType, count]),
|
||||
url: top.restAjax.path('route/paper/question/list?paperId={paperId}&questionType={questionType}&questionChoiceType={questionChoiceType}&selectCount={count}', [data.paperId, questionType, questionChoiceType, count]),
|
||||
title: '【'+ title +'】试题列表',
|
||||
width: '1000px',
|
||||
height: '80%',
|
||||
@ -292,15 +292,15 @@
|
||||
var data = obj.data;
|
||||
var event = obj.event;
|
||||
if(event === 'choiceSingleEvent') {
|
||||
openPaperQuestion('单选', 'choiceSingle', data, this.dataset.count);
|
||||
openPaperQuestion('单选', 'choice', 'single', data, this.dataset.count);
|
||||
} else if(event === 'choiceMultipleEvent') {
|
||||
openPaperQuestion('多选', 'choiceMultiple', data, this.dataset.count);
|
||||
openPaperQuestion('多选', 'choice', 'multiple', data, this.dataset.count);
|
||||
} else if(event === 'tureOrFalseEvent') {
|
||||
openPaperQuestion('判断', 'tureOrFalse', data, this.dataset.count);
|
||||
openPaperQuestion('判断', 'tureOrFalse', '', data, this.dataset.count);
|
||||
} else if(event === 'fillInTheBlanksEvent') {
|
||||
openPaperQuestion('填空', 'fillInTheBlanks', data, this.dataset.count);
|
||||
openPaperQuestion('填空', 'fillInTheBlanks', '', data, this.dataset.count);
|
||||
} else if(event === 'answerEvent') {
|
||||
openPaperQuestion('解答', 'answer', data, this.dataset.count);
|
||||
openPaperQuestion('解答', 'answer', '', data, this.dataset.count);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -23,6 +23,7 @@
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<div style="float: right;">可添加题目量:<span id="canAddCount">0</span></div>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
<!-- 表头按钮组 -->
|
||||
@ -62,9 +63,11 @@
|
||||
var queryParams = top.restAjax.params(window.location.href);
|
||||
var paperId = queryParams.paperId;
|
||||
var questionType = queryParams.questionType;
|
||||
var questionChoiceType = queryParams.questionChoiceType;
|
||||
var selectCount = queryParams.selectCount;
|
||||
var selectedCount = 0;
|
||||
var tableUrl = 'api/paper/question/listpage/paper-id/{paperId}?questionType={questionType}';
|
||||
var canAddCount = 0;
|
||||
var tableUrl = 'api/paper/question/listpage/paper-id/{paperId}?questionType={questionType}&questionChoiceType={questionChoiceType}';
|
||||
|
||||
function getDifficulty(num) {
|
||||
var result = '';
|
||||
@ -79,7 +82,7 @@
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, [paperId, questionType]),
|
||||
url: top.restAjax.path(tableUrl, [paperId, questionType, questionChoiceType]),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 60,
|
||||
limit: 20,
|
||||
@ -165,6 +168,8 @@
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
selectedCount = data.total;
|
||||
canAddCount = parseInt(selectCount) - parseInt(selectedCount);
|
||||
$('#canAddCount').text(canAddCount);
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
@ -177,7 +182,6 @@
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, [paperId, questionType]),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
startTime: $('#startTime').val(),
|
||||
@ -186,7 +190,6 @@
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 60,
|
||||
});
|
||||
}
|
||||
// 删除
|
||||
@ -232,7 +235,7 @@
|
||||
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.restAjax.delete(top.restAjax.path('api/paper/question/delete/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||
reloadTable();
|
||||
}, function (code, data) {
|
||||
@ -258,9 +261,9 @@
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var layIndex;
|
||||
top.restAjax.post(top.restAjax.path('api/examinationpaperquestion/saveexaminationpaperquestionrandom', []), {
|
||||
paperId: paperId,
|
||||
questionType: questionType
|
||||
top.restAjax.post(top.restAjax.path('api/paper/question/save-random/paper-id/{paperId}', [paperId]), {
|
||||
questionType: questionType,
|
||||
questionChoiceType: questionChoiceType
|
||||
}, null, function (code, data) {
|
||||
top.dialog.msg('操作成功', {time: 1000});
|
||||
reloadTable();
|
||||
@ -274,26 +277,8 @@
|
||||
}
|
||||
});
|
||||
} 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/paper/question/save-select?paperId={paperId}&selectCount={selectCount}&type={type}&choiceType={choiceType}', [paperId, parseInt(selectCount - selectedCount), type, choiceType]),
|
||||
url: top.restAjax.path('route/paper/question/save-select?paperId={paperId}&selectCount={selectCount}&questionType={type}&questionChoiceType={choiceType}', [paperId, canAddCount, questionType, questionChoiceType]),
|
||||
title: '选择试题',
|
||||
width: '75%',
|
||||
height: '80%',
|
||||
|
@ -20,22 +20,6 @@
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="type" name="type" lay-filter="typeFilter">
|
||||
<option value="">选择类型</option>
|
||||
<option value="choice">选择题</option>
|
||||
<option value="tureOrFalse">判断题</option>
|
||||
<option value="fillInTheBlanks">填空题</option>
|
||||
<option value="answer">解答题</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="choiceTypeBox" class="layui-inline layui-form search-item" style="display: none;">
|
||||
<select id="choiceType" name="choiceType">
|
||||
<option value="">选择类型</option>
|
||||
<option value="single">单选</option>
|
||||
<option value="multiple">多选</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline layui-form search-item">
|
||||
<select id="difficulty" name="difficulty" lay-filter="difficultyFilter">
|
||||
<option value="">选择难度</option>
|
||||
@ -48,7 +32,7 @@
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="hidden" id="questionType" readonly style="cursor: pointer;">
|
||||
<input type="text" id="questionTypeName" class="layui-input search-item search-item-width-100" placeholder="自定义类型" readonly style="cursor: pointer;">
|
||||
<input type="text" id="questionTypeName" class="layui-input search-item search-item-width-100" placeholder="试题类型" readonly style="cursor: pointer;">
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
@ -83,7 +67,7 @@
|
||||
var questionType = queryParams.questionType;
|
||||
var questionChoiceType = queryParams.questionChoiceType;
|
||||
|
||||
var tableUrl = 'api/paper/question/listpage-question/exclude-paper-id/{paperId}?questionType={questionType}&questionChoiceType={questionChoiceType}';
|
||||
var tableUrl = 'api/paper/question/listpage-question/exclude-paper-id/{paperId}?type={questionType}&choiceType={questionChoiceType}';
|
||||
|
||||
var selectObj = {};
|
||||
|
||||
@ -132,41 +116,6 @@
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field: 'type', 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: 'choiceType', width: 100, title: '选择类别', align:'center',
|
||||
templet: function(row) {
|
||||
if(row.type != '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: 'difficulty', width: 150, title: '难度', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
@ -229,7 +178,6 @@
|
||||
type: $('#type').val(),
|
||||
choiceType: $('#choiceType').val(),
|
||||
questionType: $('#questionType').val(),
|
||||
questionType: $('#questionType').val(),
|
||||
difficulty: $('#difficulty').val()
|
||||
},
|
||||
page: {
|
||||
@ -307,7 +255,7 @@
|
||||
var event = obj.event;
|
||||
if(event === 'getQuestionEvent') {
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/question/get-question.html?questionId={questionId}', [data.questionId]),
|
||||
url: top.restAjax.path('route/question/get?questionId={questionId}', [data.questionId]),
|
||||
title: '查看试题,难度:' + getDifficulty(data.difficulty),
|
||||
width: '500px',
|
||||
height: '80%',
|
||||
@ -329,7 +277,7 @@
|
||||
|
||||
$('#questionTypeName').on('click', function() {
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/questiontype/list-tree-select.html?questionTypeIds={questionTypeIds}', [$('#questionType').val()]),
|
||||
url: top.restAjax.path('route/question-type/list-tree-select?questionTypeIds={questionTypeIds}', [$('#questionType').val()]),
|
||||
title: '选择自定义类型',
|
||||
width: '200px',
|
||||
height: '400px',
|
||||
@ -354,7 +302,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user