user paper exam
parent
1a97101ee5
commit
5df6823cde
|
|
@ -6,6 +6,7 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.qinan.cedu.model.dto.PaperCoursewarePageQueryDTO;
|
import org.qinan.cedu.model.dto.PaperCoursewarePageQueryDTO;
|
||||||
|
import org.qinan.cedu.model.dto.QuestionAddDTO;
|
||||||
import org.qinan.cedu.model.dto.QuestionTypeCountQueryDTO;
|
import org.qinan.cedu.model.dto.QuestionTypeCountQueryDTO;
|
||||||
import org.qinan.cedu.model.dto.QuestionUpdateDTO;
|
import org.qinan.cedu.model.dto.QuestionUpdateDTO;
|
||||||
import org.qinan.cedu.model.vo.QuestionCoursewareVO;
|
import org.qinan.cedu.model.vo.QuestionCoursewareVO;
|
||||||
|
|
@ -30,6 +31,20 @@ public class QuestionController {
|
||||||
|
|
||||||
private final QuestionService questionService;
|
private final QuestionService questionService;
|
||||||
|
|
||||||
|
@ApiOperation("新增习题")
|
||||||
|
@PostMapping("/add")
|
||||||
|
public SingleResponse<Void> add(@Validated @RequestBody QuestionAddDTO dto) {
|
||||||
|
questionService.addQuestion(dto);
|
||||||
|
return SingleResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除习题")
|
||||||
|
@PostMapping("/del/{questionId}")
|
||||||
|
public SingleResponse<Void> del(@PathVariable @ApiParam(value = "试题id", readOnly = true) Long questionId) {
|
||||||
|
questionService.deleteById(questionId);
|
||||||
|
return SingleResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("编辑习题")
|
@ApiOperation("编辑习题")
|
||||||
@PostMapping("/modify")
|
@PostMapping("/modify")
|
||||||
public SingleResponse<Void> modify(@Validated @RequestBody QuestionUpdateDTO dto) {
|
public SingleResponse<Void> modify(@Validated @RequestBody QuestionUpdateDTO dto) {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
package org.qinan.cedu.convertor;
|
package org.qinan.cedu.convertor;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.qinan.cedu.model.dto.PaperQuestionRelUpdateDTO;
|
import org.qinan.cedu.model.dto.*;
|
||||||
import org.qinan.cedu.model.dto.PaperQuestionSaveDTO;
|
|
||||||
import org.qinan.cedu.model.dto.QuestionOptionUpdateDTO;
|
|
||||||
import org.qinan.cedu.model.dto.QuestionUpdateDTO;
|
|
||||||
import org.qinan.cedu.model.entity.QuestionDO;
|
import org.qinan.cedu.model.entity.QuestionDO;
|
||||||
import org.qinan.cedu.model.entity.QuestionOptionDO;
|
import org.qinan.cedu.model.entity.QuestionOptionDO;
|
||||||
import org.qinan.cedu.model.vo.QuestionOptionVO;
|
import org.qinan.cedu.model.vo.QuestionOptionVO;
|
||||||
|
|
@ -48,4 +45,20 @@ public interface QuestionConvertor {
|
||||||
List<QuestionOptionVO> convertOptionEListToVoList(List<QuestionOptionDO> list);
|
List<QuestionOptionVO> convertOptionEListToVoList(List<QuestionOptionDO> list);
|
||||||
|
|
||||||
QuestionDO convertPaperQuestionRelUpdateDTOToE(PaperQuestionRelUpdateDTO dto);
|
QuestionDO convertPaperQuestionRelUpdateDTOToE(PaperQuestionRelUpdateDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增习题请求转试题实体
|
||||||
|
*
|
||||||
|
* @param dto 新增内容
|
||||||
|
* @return 试题实体
|
||||||
|
*/
|
||||||
|
QuestionDO convertAddDtoToE(QuestionAddDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增选项请求转选项实体
|
||||||
|
*
|
||||||
|
* @param questionOptionAddDTO 新增内容
|
||||||
|
* @return 选项实体
|
||||||
|
*/
|
||||||
|
QuestionOptionDO convertOptionAddDtoToE(QuestionOptionAddDTO questionOptionAddDTO);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package org.qinan.cedu.model.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.qinan.cedu.enums.QuestionTypeEnum;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑习题请求(字段参考 QuestionVO)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "QuestionAddDTO", description = "新增习题请求")
|
||||||
|
public class QuestionAddDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "题目内容", required = true)
|
||||||
|
@NotBlank(message = "题干不能为空")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分值", required = true)
|
||||||
|
@NotNull(message = "分值不能为空")
|
||||||
|
@DecimalMin(value = "0.1", message = "分值必须大于0")
|
||||||
|
@DecimalMax(value = "999.9", message = "分值不能超过999.9")
|
||||||
|
@Digits(integer = 4, fraction = 1)
|
||||||
|
private BigDecimal score;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "答案解析")
|
||||||
|
private String analysis;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标签类型")
|
||||||
|
private String tagType;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "关联课件管理id", required = true)
|
||||||
|
@NotNull(message = "关联课件不能为空")
|
||||||
|
private Long coursewareManagementId;
|
||||||
|
|
||||||
|
@ApiModelProperty(QuestionTypeEnum.REMARKS)
|
||||||
|
private String questionType;
|
||||||
|
|
||||||
|
@ApiModelProperty("参考答案:逗号隔开")
|
||||||
|
private String answer;
|
||||||
|
|
||||||
|
@ApiModelProperty("答案选项id 多个逗号隔开")
|
||||||
|
private String answerQuestionOptionIds;
|
||||||
|
|
||||||
|
@ApiModelProperty("子题 多个逗号分割")
|
||||||
|
private String childrenQuestionIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 来源(1:管理员添加,2:三方添加)
|
||||||
|
*/
|
||||||
|
private Integer source;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "试题选项信息", required = true)
|
||||||
|
@NotEmpty(message = "试题选项不能为空")
|
||||||
|
@Valid
|
||||||
|
private List<QuestionOptionAddDTO> questionOptionList;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.qinan.cedu.model.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 试题选项编辑内容(id为空新增、id在库中更新,不在请求中的库内选项将被逻辑删除)
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "QuestionOptionAddDTO", description = "试题选项新增内容")
|
||||||
|
public class QuestionOptionAddDTO implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否正确答案 true 是,false 不是", required = true)
|
||||||
|
@NotNull(message = "是否正确答案不能为空")
|
||||||
|
private Boolean isCorrect;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "选项标识:A,B,C,D", required = true)
|
||||||
|
@NotBlank(message = "选项标识不能为空")
|
||||||
|
private String optionKey;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "选项内容", required = true)
|
||||||
|
@NotBlank(message = "选项内容不能为空")
|
||||||
|
private String optionText;
|
||||||
|
}
|
||||||
|
|
@ -2,10 +2,7 @@ package org.qinan.cedu.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.qinan.cedu.model.dto.PaperCoursewarePageQueryDTO;
|
import org.qinan.cedu.model.dto.*;
|
||||||
import org.qinan.cedu.model.dto.PaperQuestionPageQueryDTO;
|
|
||||||
import org.qinan.cedu.model.dto.QuestionTypeCountQueryDTO;
|
|
||||||
import org.qinan.cedu.model.dto.QuestionUpdateDTO;
|
|
||||||
import org.qinan.cedu.model.entity.QuestionDO;
|
import org.qinan.cedu.model.entity.QuestionDO;
|
||||||
import org.qinan.cedu.model.entity.QuestionOptionDO;
|
import org.qinan.cedu.model.entity.QuestionOptionDO;
|
||||||
import org.qinan.cedu.model.vo.PaperQuestionVO;
|
import org.qinan.cedu.model.vo.PaperQuestionVO;
|
||||||
|
|
@ -103,4 +100,10 @@ public interface QuestionService extends IService<QuestionDO> {
|
||||||
*/
|
*/
|
||||||
IPage<QuestionCoursewareVO> pageCourseware(PaperCoursewarePageQueryDTO query);
|
IPage<QuestionCoursewareVO> pageCourseware(PaperCoursewarePageQueryDTO query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增试题(含选项)
|
||||||
|
*
|
||||||
|
* @param dto dto
|
||||||
|
*/
|
||||||
|
void addQuestion(QuestionAddDTO dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,22 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, QuestionDO>
|
||||||
return this.baseMapper.pageCourseware(new Page<>(query.getCurrent(), query.getSize()), query);
|
return this.baseMapper.pageCourseware(new Page<>(query.getCurrent(), query.getSize()), query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addQuestion(QuestionAddDTO dto) {
|
||||||
|
QuestionDO question = questionConvertor.convertAddDtoToE(dto);
|
||||||
|
question.setCreateTime(LocalDateTime.now());
|
||||||
|
question.setUpdateTime(LocalDateTime.now());
|
||||||
|
InsertFieldDefaults.apply(question);
|
||||||
|
this.save(question);
|
||||||
|
List<QuestionOptionDO> options = new ArrayList<>();
|
||||||
|
for (QuestionOptionAddDTO questionOptionAddDTO : dto.getQuestionOptionList()) {
|
||||||
|
QuestionOptionDO option = questionConvertor.convertOptionAddDtoToE(questionOptionAddDTO);
|
||||||
|
InsertFieldDefaults.apply(option);
|
||||||
|
options.add(option);
|
||||||
|
}
|
||||||
|
Db.saveBatch(options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存试题选项(重置id并绑定试题id、统一填充时间后批量插入)
|
* 保存试题选项(重置id并绑定试题id、统一填充时间后批量插入)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue