| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.base.SystemCode; |
| | | import com.ycl.jxkg.domain.entity.Question; |
| | | import com.ycl.jxkg.domain.entity.TextContent; |
| | | import com.ycl.jxkg.domain.enums.QuestionTypeEnum; |
| | | import com.ycl.jxkg.domain.question.QuestionObject; |
| | | import com.ycl.jxkg.service.QuestionService; |
| | | import com.ycl.jxkg.service.TextContentService; |
| | | import com.ycl.jxkg.utils.*; |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionEditRequestVO; |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionPageRequestVO; |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionResponseVO; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.service.QuestionService; |
| | | import com.ycl.jxkg.service.TextContentService; |
| | | import com.ycl.jxkg.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | | public Result<PageInfo<QuestionResponseVO>> pageList(@RequestBody QuestionPageRequestVO model) { |
| | | PageInfo<Question> pageInfo = questionService.page(model); |
| | | PageInfo<QuestionResponseVO> pageInfo = questionService.page(model); |
| | | PageInfo<QuestionResponseVO> page = PageInfoHelper.copyMap(pageInfo, q -> { |
| | | QuestionResponseVO vo = new QuestionResponseVO(); |
| | | BeanUtils.copyProperties(q, vo); |
| | | vo.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime())); |
| | | vo.setScore(ExamUtil.scoreToVM(q.getScore())); |
| | | TextContent textContent = textContentService.getById(q.getInfoTextContentId()); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class); |
| | | vo.setScore(ExamUtil.scoreToVM(Integer.valueOf(q.getScore()))); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(q.getContent(), QuestionObject.class); |
| | | String clearHtml = HtmlUtil.clear(questionObject.getTitleContent()); |
| | | vo.setShortTitle(clearHtml); |
| | | return vo; |
| | |
| | | QuestionPageStudentResponseVO vo = new QuestionPageStudentResponseVO(); |
| | | BeanUtils.copyProperties(q, vo); |
| | | vo.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime())); |
| | | TextContent textContent = textContentService.getById(q.getQuestionTextContentId()); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(q.getQuestionContent(), QuestionObject.class); |
| | | String clearHtml = HtmlUtil.clear(questionObject.getTitleContent()); |
| | | vo.setShortTitle(clearHtml); |
| | | vo.setSubjectName(subject.getName()); |
| | |
| | | package com.ycl.jxkg.domain.base; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | |
| | | // @TableField(value = "gmt_update", fill = FieldFill.INSERT_UPDATE) |
| | | // private Date gmtUpdate; |
| | | |
| | | @TableField(value = "deleted", fill = FieldFill.INSERT) |
| | | @TableField(value = "deleted", fill = FieldFill.INSERT, select = false) |
| | | @TableLogic |
| | | private Integer deleted; |
| | | |
| | | } |
| | |
| | | /** |
| | | * 问题内容 |
| | | */ |
| | | @TableField("question_text_content_id") |
| | | private Integer questionTextContentId; |
| | | @TableField("questionContent") |
| | | private String questionContent; |
| | | |
| | | /** |
| | | * 做题答案 |
| | |
| | | /** |
| | | * 题目 填空、 题干、解析、答案等信息 |
| | | */ |
| | | @TableField("info_text_content_id") |
| | | private Integer infoTextContentId; |
| | | @TableField("content") |
| | | private String content; |
| | | |
| | | /** |
| | | * 创建人 |
| | |
| | | |
| | | private Integer questionType; |
| | | |
| | | private Integer textContentId; |
| | | private String questionTypeName; |
| | | |
| | | private String content; |
| | | |
| | | private String createTime; |
| | | |
| | | private Integer subjectId; |
| | | |
| | | private String subjectName; |
| | | |
| | | private Integer createUser; |
| | | |
| | | private String createUserName; |
| | | |
| | | private String score; |
| | | |
| | | private Integer status; |
| | |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionEditRequestVO; |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionPageRequestVO; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionResponseVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface QuestionService extends IService<Question> { |
| | | |
| | | PageInfo<Question> page(QuestionPageRequestVO requestVM); |
| | | PageInfo<QuestionResponseVO> page(QuestionPageRequestVO requestVM); |
| | | |
| | | Question insertFullQuestion(QuestionEditRequestVO model, Integer userId); |
| | | |
| | |
| | | examPaperQuestionCustomerAnswer.setCreateTime(now); |
| | | examPaperQuestionCustomerAnswer.setCreateUser(user.getId()); |
| | | examPaperQuestionCustomerAnswer.setQuestionType(question.getQuestionType()); |
| | | examPaperQuestionCustomerAnswer.setQuestionTextContentId(question.getInfoTextContentId()); |
| | | examPaperQuestionCustomerAnswer.setQuestionContent(question.getContent()); |
| | | if (null == customerQuestionAnswer) { |
| | | examPaperQuestionCustomerAnswer.setCustomerScore(0); |
| | | } else { |
| | |
| | | import com.ycl.jxkg.domain.enums.QuestionTypeEnum; |
| | | import com.ycl.jxkg.domain.question.QuestionItemObject; |
| | | import com.ycl.jxkg.domain.question.QuestionObject; |
| | | import com.ycl.jxkg.domain.vo.admin.question.QuestionResponseVO; |
| | | import com.ycl.jxkg.mapper.QuestionMapper; |
| | | import com.ycl.jxkg.service.QuestionService; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<Question> page(QuestionPageRequestVO requestVM) { |
| | | public PageInfo<QuestionResponseVO> page(QuestionPageRequestVO requestVM) { |
| | | return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> |
| | | questionMapper.page(requestVM) |
| | | ); |
| | |
| | | Integer gradeLevel = subjectService.levelBySubjectId(model.getSubjectId()); |
| | | |
| | | //题干、解析、选项等 插入 |
| | | TextContent infoTextContent = new TextContent(); |
| | | infoTextContent.setCreateTime(now); |
| | | setQuestionInfoFromVM(infoTextContent, model); |
| | | textContentService.save(infoTextContent); |
| | | String questionObject = setQuestionInfoFromVM(model); |
| | | |
| | | Question question = new Question(); |
| | | question.setSubjectId(model.getSubjectId()); |
| | |
| | | question.setCorrectFromVM(model.getCorrect(), model.getCorrectArray()); |
| | | question.setScore(ExamUtil.scoreFromVM(model.getScore())); |
| | | question.setDifficult(model.getDifficult()); |
| | | question.setInfoTextContentId(infoTextContent.getId()); |
| | | question.setContent(questionObject); |
| | | question.setCreateUser(userId); |
| | | questionMapper.insert(question); |
| | | return question; |
| | |
| | | question.setScore(ExamUtil.scoreFromVM(model.getScore())); |
| | | question.setDifficult(model.getDifficult()); |
| | | question.setCorrectFromVM(model.getCorrect(), model.getCorrectArray()); |
| | | questionMapper.updateById(question); |
| | | |
| | | //题干、解析、选项等 更新 |
| | | TextContent infoTextContent = textContentService.getById(question.getInfoTextContentId()); |
| | | setQuestionInfoFromVM(infoTextContent, model); |
| | | textContentService.updateById(infoTextContent); |
| | | |
| | | String questionObject = setQuestionInfoFromVM(model); |
| | | question.setContent(questionObject); |
| | | questionMapper.updateById(question); |
| | | return question; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public QuestionEditRequestVO getQuestionEditRequestVM(Question question) { |
| | | //题目映射 |
| | | TextContent questionInfoTextContent = textContentService.getById(question.getInfoTextContentId()); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(questionInfoTextContent.getContent(), QuestionObject.class); |
| | | QuestionObject questionObject = JsonUtil.toJsonObject(question.getContent(), QuestionObject.class); |
| | | QuestionEditRequestVO questionEditRequestVO = new QuestionEditRequestVO(); |
| | | BeanUtils.copyProperties(question, questionEditRequestVO); |
| | | questionEditRequestVO.setTitle(questionObject.getTitleContent()); |
| | |
| | | return questionEditRequestVO; |
| | | } |
| | | |
| | | public void setQuestionInfoFromVM(TextContent infoTextContent, QuestionEditRequestVO model) { |
| | | public String setQuestionInfoFromVM(QuestionEditRequestVO model) { |
| | | List<QuestionItemObject> itemObjects = model.getItems().stream().map(i -> |
| | | { |
| | | QuestionItemObject item = new QuestionItemObject(); |
| | |
| | | questionObject.setAnalyze(model.getAnalyze()); |
| | | questionObject.setTitleContent(model.getTitle()); |
| | | questionObject.setCorrect(model.getCorrect()); |
| | | infoTextContent.setContent(JsonUtil.toJsonStr(questionObject)); |
| | | return JsonUtil.toJsonStr(questionObject); |
| | | } |
| | | |
| | | @Override |
| | |
| | | <result column="subject_id" jdbcType="INTEGER" property="subjectId"/> |
| | | <result column="customer_score" jdbcType="INTEGER" property="customerScore"/> |
| | | <result column="question_score" jdbcType="INTEGER" property="questionScore"/> |
| | | <result column="question_text_content_id" jdbcType="INTEGER" property="questionTextContentId"/> |
| | | <result column="question_content" jdbcType="VARCHAR" property="questionContent"/> |
| | | <result column="answer" jdbcType="VARCHAR" property="answer"/> |
| | | <result column="text_content_id" jdbcType="INTEGER" property="textContentId"/> |
| | | <result column="do_right" jdbcType="BIT" property="doRight"/> |
| | |
| | | <sql id="Base_Column_List"> |
| | | id |
| | | , question_id, exam_paper_id, exam_paper_answer_id, question_type, subject_id, |
| | | customer_score, question_score, question_text_content_id, answer, text_content_id, |
| | | customer_score, question_score, question_content, answer, text_content_id, |
| | | do_right, create_user, create_time, item_order |
| | | </sql> |
| | | |
| | |
| | | subject_id, create_time, create_user, |
| | | text_content_id, exam_paper_id, question_type, |
| | | answer, customer_score, exam_paper_answer_id , |
| | | do_right,question_text_content_id,item_order) |
| | | do_right,question_content,item_order) |
| | | values |
| | | <foreach collection="list" item="item" index="index" |
| | | separator=","> |
| | |
| | | <result column="grade_level" jdbcType="INTEGER" property="gradeLevel"/> |
| | | <result column="difficult" jdbcType="INTEGER" property="difficult"/> |
| | | <result column="correct" jdbcType="VARCHAR" property="correct"/> |
| | | <result column="info_text_content_id" jdbcType="INTEGER" property="infoTextContentId"/> |
| | | <result column="content" jdbcType="VARCHAR" property="content"/> |
| | | <result column="create_user" jdbcType="INTEGER" property="createUser"/> |
| | | <result column="status" jdbcType="INTEGER" property="status"/> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> |
| | |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id |
| | | , question_type, subject_id, score, grade_level, difficult, correct, info_text_content_id, |
| | | , question_type, subject_id, score, grade_level, difficult, correct, content, |
| | | create_user, status, create_time, deleted |
| | | </sql> |
| | | |
| | | |
| | | <select id="page" resultMap="BaseResultMap" parameterType="com.ycl.jxkg.domain.vo.admin.question.QuestionPageRequestVO"> |
| | | <select id="page" resultType="com.ycl.jxkg.domain.vo.admin.question.QuestionResponseVO" parameterType="com.ycl.jxkg.domain.vo.admin.question.QuestionPageRequestVO"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | FROM t_question |
| | | tq.*, |
| | | CASE WHEN tq.question_type = 1 THEN '单选题' WHEN tq.question_type = 2 THEN '多选题' WHEN tq.question_type = 3 THEN '判断题' WHEN tq.question_type = 4 THEN '填空题' WHEN tq.question_type = 5 THEN '简答题' END AS questionTypeName, |
| | | ts.name AS subjectName, |
| | | tu.real_name AS createUserName |
| | | FROM t_question tq |
| | | LEFT JOIN t_subject ts ON tq.subject_id = ts.id |
| | | LEFT JOIN t_user tu ON tq.create_user = tu.id |
| | | <where> |
| | | and deleted=0 |
| | | and tq.deleted=0 |
| | | <if test="id != null "> |
| | | and id= #{id} |
| | | and tq.id= #{id} |
| | | </if> |
| | | <if test="level != null "> |
| | | and grade_level= #{level} |
| | | and tq.grade_level= #{level} |
| | | </if> |
| | | <if test="subjectId != null "> |
| | | and subject_id= #{subjectId} |
| | | and tq.subject_id= #{subjectId} |
| | | </if> |
| | | <if test="questionType != null "> |
| | | and question_type= #{questionType} |
| | | and tq.question_type= #{questionType} |
| | | </if> |
| | | <if test="content != null"> |
| | | and info_text_content_id in (SELECT id FROM t_text_content WHERE content like concat('%',#{content},'%') |
| | | ) |
| | | and instr(tq.content, #{content}) |
| | | </if> |
| | | </where> |
| | | </select> |