diff --git a/pom.xml b/pom.xml index c4adc0d8590a907983d9e84e1664c9ce0c4eb394..d86132b438c5dceb1c8fbefcad147cb706cf3e96 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,12 @@ 4.7 - + + + cn.hutool + hutool-all + 4.5.16 + diff --git a/src/main/java/com/lyt/bean/Course.java b/src/main/java/com/lyt/bean/Course.java index 17a3542efb86036f3dd5bf83df3405c3fd4cae56..bdf54f8b74ad554d9229b50763116b3eed614dfd 100644 --- a/src/main/java/com/lyt/bean/Course.java +++ b/src/main/java/com/lyt/bean/Course.java @@ -3,6 +3,11 @@ package com.lyt.bean; import lombok.AllArgsConstructor; import lombok.Data; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: 课程 + */ //课程类 @Data @AllArgsConstructor diff --git a/src/main/java/com/lyt/bean/LinkAnswer.java b/src/main/java/com/lyt/bean/LinkAnswer.java new file mode 100644 index 0000000000000000000000000000000000000000..ce0569b57841f2f1a95075827e140a9d54048ff3 --- /dev/null +++ b/src/main/java/com/lyt/bean/LinkAnswer.java @@ -0,0 +1,75 @@ +package com.lyt.bean; + +/** + * @Author:张勇 + * @Date:2023/5/18 10:10 + * @Info: + */ +public class LinkAnswer { + private Integer id; + private Integer stuTestId; + private Integer paperId; + private Integer _index; + private Integer questionId; + private String answer; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getStu_test_id() { + return stuTestId; + } + + public void setStu_test_id(Integer stu_test_id) { + this.stuTestId = stu_test_id; + } + + public Integer getPaper_id() { + return paperId; + } + + public void setPaper_id(Integer paper_id) { + this.paperId = paper_id; + } + + public Integer getIndex() { + return _index; + } + + public void setIndex(Integer index) { + this._index = index; + } + + public Integer getQuestion_id() { + return questionId; + } + + public void setQuestion_id(Integer question_id) { + this.questionId = question_id; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + @Override + public String toString() { + return "LinkAnswer{" + + "id=" + id + + ", stu_test_id=" + stuTestId + + ", paper_id=" + paperId + + ", _index=" + _index + + ", question_id=" + questionId + + ", answer='" + answer + '\'' + + '}'; + } +} diff --git a/src/main/java/com/lyt/bean/Paper.java b/src/main/java/com/lyt/bean/Paper.java index 9c396aec6bcb3c561d5b381df1e722f97d2990c1..cca7df2a3aaa9912be80ee8e42aa3752574311e2 100644 --- a/src/main/java/com/lyt/bean/Paper.java +++ b/src/main/java/com/lyt/bean/Paper.java @@ -1,15 +1,18 @@ package com.lyt.bean; -import lombok.AllArgsConstructor; import lombok.Data; -import java.util.List; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: 试卷 + */ @Data //试卷类 public class Paper { private Integer paperId;//试卷编号 private String paperName;//试卷名字 - private String score;//分数 + private Integer score;//分数 2023/5/4/zjx private Integer courseId;//课程编号 private String course;//课程 // private int paperType; diff --git a/src/main/java/com/lyt/bean/PaperQuestion.java b/src/main/java/com/lyt/bean/PaperQuestion.java index f659bca57a24527daef3d1959c38288dde1a7003..42cceadf415a447dfbfa668f7cda0104c6901198 100644 --- a/src/main/java/com/lyt/bean/PaperQuestion.java +++ b/src/main/java/com/lyt/bean/PaperQuestion.java @@ -1,13 +1,11 @@ package com.lyt.bean; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; /** * @Author: zjx - * @Date: 2023/04/09/20:03 - * @Description: + * @Date: 2023/04/27/20:03 + * @Description: 试卷和试题关系 */ @Data @AllArgsConstructor diff --git a/src/main/java/com/lyt/bean/Question.java b/src/main/java/com/lyt/bean/Question.java index 556e724efebb73ffb23d5d0968868ddac6a64993..884387bb58da1fe452e3fd6c7b97fc33ce3fa3cd 100644 --- a/src/main/java/com/lyt/bean/Question.java +++ b/src/main/java/com/lyt/bean/Question.java @@ -1,9 +1,11 @@ package com.lyt.bean; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - +import lombok.*; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: 试题 + */ //试题类 @Data @AllArgsConstructor @@ -12,7 +14,7 @@ public class Question { private Integer questionId;//试题编号 private String questionName;//试题名 - private Integer type;//试卷类型,0单选题,1多选题,2判断题,3问答题 + private Integer type;//试卷类型,1单选题,2多选题,3问答题,4判断题 private String courseId;//课程编号 private String content; // 试题内容 最后需要将这个json串转换为 options diff --git a/src/main/java/com/lyt/bean/TestAnswer.java b/src/main/java/com/lyt/bean/TestAnswer.java new file mode 100644 index 0000000000000000000000000000000000000000..1c036933bb2c2eea900dd3622eb62769537f6f35 --- /dev/null +++ b/src/main/java/com/lyt/bean/TestAnswer.java @@ -0,0 +1,59 @@ +package com.lyt.bean; + +import com.lyt.vo.LinkAnswerVo; + +import java.util.List; + +/** + * @Author:张勇 + * @Date:2023/5/16 19:46 + * @Info: + */ +public class TestAnswer { + private Integer test_id; + private Integer stu_test_id; + private Integer paper_id; + private String linkAnswers; + + public Integer getTest_id() { + return test_id; + } + + public void setTest_id(Integer test_id) { + this.test_id = test_id; + } + + public Integer getStu_test_id() { + return stu_test_id; + } + + public void setStu_test_id(Integer stu_test_id) { + this.stu_test_id = stu_test_id; + } + + public Integer getPaper_id() { + return paper_id; + } + + public void setPaper_id(Integer paper_id) { + this.paper_id = paper_id; + } + + public String getLinkAnswers() { + return linkAnswers; + } + + public void setLinkAnswers(String linkAnswers) { + this.linkAnswers = linkAnswers; + } + + @Override + public String toString() { + return "TestAnswer{" + + "test_id=" + test_id + + ", stu_test_id=" + stu_test_id + + ", paper_id=" + paper_id + + ", linkAnswer='" + linkAnswers + '\'' + + '}'; + } +} diff --git a/src/main/java/com/lyt/bean/TestStatus.java b/src/main/java/com/lyt/bean/TestStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..245e816ee28d09725d8779d70449a5d03b943693 --- /dev/null +++ b/src/main/java/com/lyt/bean/TestStatus.java @@ -0,0 +1,23 @@ +package com.lyt.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * @Author:张勇 + * @Date:2023/5/11 22:46 + * @Info: + */ +@Data +@AllArgsConstructor +public class TestStatus { + private Integer stu_test_id; + private Integer student_id; + private Integer cutNum; + private String name; + private String date; + + public TestStatus() { + + } +} diff --git a/src/main/java/com/lyt/bean/TitleContent.java b/src/main/java/com/lyt/bean/TitleContent.java index 88b852e23e86715d7381e081c255617b6777b991..18284ce89e04e04b9d904575db8b31566a839d01 100644 --- a/src/main/java/com/lyt/bean/TitleContent.java +++ b/src/main/java/com/lyt/bean/TitleContent.java @@ -15,4 +15,5 @@ import lombok.NoArgsConstructor; public class TitleContent { private String titleName; private int sort; + private int type; } diff --git a/src/main/java/com/lyt/controller/CourseContoller.java b/src/main/java/com/lyt/controller/CourseContoller.java new file mode 100644 index 0000000000000000000000000000000000000000..b72e0e3685341638f93847ccc1a2a2f7ca03a0bd --- /dev/null +++ b/src/main/java/com/lyt/controller/CourseContoller.java @@ -0,0 +1,24 @@ +package com.lyt.controller; + +import com.lyt.bean.Course; +import com.lyt.service.CourseService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +public class CourseContoller { + + @Autowired + CourseService courseService; + + @RequestMapping("/course/get") + public List getAllCourse(){ + return courseService.getAllCourse(); + } + // public String getAllCourse(){ +// return JSON.toJSONString(courseService.getAllCourse()); +// } +} diff --git a/src/main/java/com/lyt/controller/PaperController.java b/src/main/java/com/lyt/controller/PaperController.java index d21b0bc195e854fab00d62f05681a0923a8ffed6..c56a572bbbff1c1a6aab0ac5223b086c9d9fc82c 100644 --- a/src/main/java/com/lyt/controller/PaperController.java +++ b/src/main/java/com/lyt/controller/PaperController.java @@ -6,14 +6,20 @@ import com.lyt.vo.QuestionVo; import com.lyt.vo.QuestionsVo; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @RestController @CrossOrigin public class PaperController { + + //添加试卷,lyt @Autowired PaperService paperService; @RequestMapping("/edit/paper") @@ -23,10 +29,56 @@ public class PaperController { return "okkkk"; } + //自动添加试卷,zjx + @RequestMapping("/addPaperAut") + public String addPaperAut(@RequestBody PaperVo paperVo ){ + int i = paperService.addPaperAut(paperVo); + if (i == 2){ + return "选择题数量不足"; + }else if (i == 3){ + return "判断题数量不足"; + }else if (i == 4){ + return "问答题数量不足"; + } + return "创建成功"; + } + //根据试卷编号获取试卷,lyt @RequestMapping("/get/paper") public PaperVo getPaper(@Param("id") Integer id){ + System.out.println("---------------------"+id); PaperVo paperVo = paperService.getPaperById(id); return paperVo; } + + //根据试卷编号删除试卷,zjx + @RequestMapping("/paper/delete/{id}") + public int deletePaper(@PathVariable("id") Integer id){ + return paperService.deletePaper(id); + } + + //根据年级查询所有试卷,zjx + @RequestMapping("/paper/grade") + public List getAllByGradePaper(@Param("grade") Integer grade){ + return paperService.getAllByGradePaper(grade); + } + + //查询所有试卷,zjx + @RequestMapping("/paper/get") + public List getAllPaper(){ + return paperService.getAllPaper(); + } + + //根据试卷编号删除试卷,zjx + @RequestMapping("/paper/courseId") + public List getAllByCoursePaper(@Param("courseId") Integer courseId){ + return paperService.getAllByCoursePaper(courseId); + } + + //发布试卷,zjx + @RequestMapping("/commit/paper") + public String commitPaper(@Param("paperId")Integer paperId){ + paperService.commitPaper(1,paperId); + return "okkkk"; + } } diff --git a/src/main/java/com/lyt/controller/QuestionController.java b/src/main/java/com/lyt/controller/QuestionController.java index 23b31fa1d53a84402231b6cb07bc6a6df1a93c8c..35b05b5515164e2adb05b5bfbb85e517bb49a26c 100644 --- a/src/main/java/com/lyt/controller/QuestionController.java +++ b/src/main/java/com/lyt/controller/QuestionController.java @@ -7,20 +7,21 @@ import com.lyt.service.QuestionService; import com.lyt.vo.QuestionVo; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; - +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @RestController @CrossOrigin public class QuestionController { @Autowired QuestionService questionService; - @RequestMapping("/question/edit") + @RequestMapping("/question/edit")//添加试题 public String addQuestion(@RequestBody QuestionVo questionVo)throws Exception{ // System.out.println(questionVo); questionService.addQuestion(questionVo); @@ -29,14 +30,15 @@ public class QuestionController { return "ok"; } - @RequestMapping("/question/get") - public List getQuestionList()throws Exception{ + @RequestMapping("/question/get")//查询所有试题 + public List getAllQuestion()throws Exception{ // System.out.println(questionVo); // questionService.addQuestion(questionVo); return questionService.getAllQuestion(); } - @RequestMapping("/question/id") + + @RequestMapping("/question/id")//根据id查询试题 public QuestionVo getQuestionListById(@Param("id") Integer id)throws Exception{ // System.out.println(questionVo); @@ -51,4 +53,35 @@ public class QuestionController { // questionService.addQuestion(questionVo); return questionService.questionList(); } + + //zjx + @RequestMapping("/question/delete/{id}") + public int deleteQuestion(@PathVariable("id") Integer id)throws Exception{ + return questionService.deleteQuestion(id); + } + + //zjx + @RequestMapping("/question/courseIdortype") + public List getAllQuestionByCourseIdOrType(@Param("type") Integer type,@Param("courseId")Integer courseId)throws Exception{ + return questionService.getAllQuestionByCourseIdOrType(type,courseId); + } + + //zjx 5/7 + @RequestMapping("/question/courseId")//根据课程Id查询试题 + public List getAllByCourseQuestion(@Param("courseId") Integer courseId)throws Exception{ + return questionService.getAllByCourseQuestion(courseId); + } + + //zjx 5/7 + @RequestMapping("/question/type")//根据课程Id查询试题 + public List getAllBytypeuestion(@Param("type") Integer type)throws Exception{ + return questionService.getAllBytypeuestion(type); + } + + //zjx 5/8 + @RequestMapping("/question/update")//根据课程Id查询试题 + public int getAllBytypeuestion(@RequestBody QuestionVo questionVo)throws Exception{ + questionService.updateQuestion(questionVo); + return 1; + } } diff --git a/src/main/java/com/lyt/controller/TestAnswerController.java b/src/main/java/com/lyt/controller/TestAnswerController.java new file mode 100644 index 0000000000000000000000000000000000000000..f48a8395320513000a604d99900ce719fd2289fb --- /dev/null +++ b/src/main/java/com/lyt/controller/TestAnswerController.java @@ -0,0 +1,45 @@ +package com.lyt.controller; + +import com.lyt.bean.LinkAnswer; +import com.lyt.service.TestAnswerService; +import com.lyt.vo.LinkAnswerVo; +import com.lyt.vo.RetAnswerVo; +import com.lyt.vo.TestAnswerVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Author:张勇 + * @Date:2023/5/16 19:44 + * @Info: + */ +@RestController +@CrossOrigin +public class TestAnswerController { + @Autowired + public TestAnswerService testAnswerservice; + + @RequestMapping("/testAnswer/add") + public int addAnswer(@RequestBody TestAnswerVo testAnswerVo)throws Exception{ + + System.out.println(testAnswerVo); + int xx = testAnswerservice.addTestStatus(testAnswerVo); + return 1; + } + + @RequestMapping("/testAnswer/selAnswer") + public List selAnswer(@Param("paper_id")Integer paper_id, @Param("stu_id") Integer stu_id)throws Exception{ + List list = testAnswerservice.selAnswerByPaperIdAndStuId(paper_id, stu_id); + System.out.println(list); + return list; + } + +} + diff --git a/src/main/java/com/lyt/controller/TestStatusController.java b/src/main/java/com/lyt/controller/TestStatusController.java new file mode 100644 index 0000000000000000000000000000000000000000..826ff1e8f7c15b5753e5ca8801437feb2270d172 --- /dev/null +++ b/src/main/java/com/lyt/controller/TestStatusController.java @@ -0,0 +1,45 @@ +package com.lyt.controller; + + +import com.lyt.bean.TestStatus; +import com.lyt.service.TestStatuService; +import com.lyt.vo.TestStatusVo; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.sql.Date; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; + +/** + * @Author: 张勇 + * @Date: 2023/05/11 + * @Info: + */ +@RestController +@CrossOrigin +public class TestStatusController { + @Autowired + public TestStatuService service; + + @RequestMapping("/testStatus/add") //添加考试的学生 + public int addTestStuts(@Param("id")Integer stu_id,@Param("name") String name)throws Exception{ + Integer stuId = service.selStuByStuId(stu_id); + int xx = 0; + if(stuId != null){ + System.out.println("我找到你了"); + return stuId; + }else { + System.out.println("我没找到你 我要添加你"); + LocalDateTime dateTime = LocalDateTime.now(); + TestStatusVo testStatusVo = new TestStatusVo(stu_id,name,dateTime.toString(),0); + System.out.println(testStatusVo.toString()); + //xx = service.addTestStatus(studentInfo); + } + return xx; + } +} diff --git a/src/main/java/com/lyt/dao/CourseDao.java b/src/main/java/com/lyt/dao/CourseDao.java index 01b6f49d6f3adc080e5003239d63a2a7f02161cd..31cdec99110d1b111402458ebb221e320897097c 100644 --- a/src/main/java/com/lyt/dao/CourseDao.java +++ b/src/main/java/com/lyt/dao/CourseDao.java @@ -5,6 +5,11 @@ import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @Repository public interface CourseDao { @Select("select * from course") diff --git a/src/main/java/com/lyt/dao/PaperDao.java b/src/main/java/com/lyt/dao/PaperDao.java index 7cb71b02001e53448196e3690e346e3884b05ce2..a701a08a3a4d71c0319d066c1257562c0036ada0 100644 --- a/src/main/java/com/lyt/dao/PaperDao.java +++ b/src/main/java/com/lyt/dao/PaperDao.java @@ -7,6 +7,11 @@ import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; import java.util.List; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @Repository public interface PaperDao { @@ -37,9 +42,15 @@ public interface PaperDao { @Select("select * from paper where course_id = #{courseId}") public List getAllByCoursePaper(int courseId);//根据课程获取所有试卷中的试题 + @Select("select * from paper where grade = #{grade}") + public List getAllByGradePaper(Integer grade);//根据课程获取所有试卷中的试题 + @Update("update paper set status=#{status} where paper_id = #{paperId}") public int commitPaper(@Param("status")Integer status,@Param("paperId")Integer paperId);//发布试卷 + @Select("select * from paper") + public List getAllPaper();//获取所有试卷 + // @Results(value = {@Result(id = true,column="paper_id",property="paperId"), // @Result(property="questions",column="paper_id",javaType = List.class, // many = @Many(select = "com.lyt.dao.QuestionDao.selectByQuestionId")) diff --git a/src/main/java/com/lyt/dao/QuestionDao.java b/src/main/java/com/lyt/dao/QuestionDao.java index 6febf7b5f28be238f621dcb03a015e9266a303ba..b79025394308157c260d97d299a0a93c451c4097 100644 --- a/src/main/java/com/lyt/dao/QuestionDao.java +++ b/src/main/java/com/lyt/dao/QuestionDao.java @@ -6,13 +6,19 @@ import org.apache.ibatis.annotations.*; import org.springframework.stereotype.Repository; import java.util.List; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @Repository public interface QuestionDao { @Select("select * from paper_question where paper_id =#{id}") public List getPaperQuestionById(int id); + @Select("select * from question where question_id =#{id}") - public Question getQuestionById( int id); + public Question getQuestionById(int id); @Select("select question_id,question_name,type from question ") public List getQuestionList(); @@ -20,7 +26,7 @@ public interface QuestionDao { @Select("select * from question ") public List getAllQuestion(); - @Update("update question set question_name=#{questionName},a=#{a},b=#{b},c=#{c},d=#{d},score=#{score}," + + @Update("update question set question_name=#{questionName},content=#{content},score=#{score}," + "answer=#{answer},detail=#{detail} where question_id = #{questionId}") public int updateQuestion(Question question);//根据试卷编号更新试题 @@ -40,6 +46,12 @@ public interface QuestionDao { @Select("select * from question where user_id = #{userId}") public List getAllByUserIdQuestion(int userId);//根据创建者id获取所有试题 + @Select("select * from question where type = #{type}") + public List getAllBytypeuestion(int type);//根据创建者id获取所有试题 zjx + @Select("select * from paper_question pq,question q where pq.question_id = q.question_id and pq.paper_id = #{paperId}") public List selectUnion(int paperId);//获取所有试卷中的试题 + + //二级查询 + public List getAllQuestionByCourseIdOrType(Integer type,Integer courseId); } diff --git a/src/main/java/com/lyt/dao/TestAnswerDao.java b/src/main/java/com/lyt/dao/TestAnswerDao.java new file mode 100644 index 0000000000000000000000000000000000000000..9e88c8a285d67052723f2ecde3f63fc52bf1f88d --- /dev/null +++ b/src/main/java/com/lyt/dao/TestAnswerDao.java @@ -0,0 +1,35 @@ +package com.lyt.dao; + +import com.lyt.bean.LinkAnswer; +import com.lyt.bean.TestAnswer; +import com.lyt.vo.TestAnswerVo; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * @Author:张勇 + * @Date:2023/5/18 10:47 + * @Info: + */ +@Repository +public interface TestAnswerDao { + + @Insert("insert into test_answer (stu_test_id,paper_id,linkAnswers) " + + "values(#{stu_test_id},#{paper_id},#{linkAnswers})") + public int addAnswer(TestAnswer testAnswer); + + @Insert("insert into link_answer (stu_test_id,paper_id,_index,question_id,answer) " + + "values(#{stu_test_id},#{paper_id},#{index},#{question_id},#{answer})") + public void addLinkAnswer(LinkAnswer linkAnswer); + + @Select("select * from link_answer where paper_id = #{id} and stu_test_id = #{stu_id}") + public List selAnswerByPaperIdAndStuId(@Param("id") Integer id,@Param("stu_id") Integer stu_id); + + @Delete("delete from link_answer where paper_id = #{id} and stu_test_id = #{stu_id}") + public Integer delAnswerByPaperIdAndStuId(Integer id,Integer stu_id); +} diff --git a/src/main/java/com/lyt/dao/TestStatusDao.java b/src/main/java/com/lyt/dao/TestStatusDao.java new file mode 100644 index 0000000000000000000000000000000000000000..83da51574f6ecfb69651b5037aea6d836f498f93 --- /dev/null +++ b/src/main/java/com/lyt/dao/TestStatusDao.java @@ -0,0 +1,21 @@ +package com.lyt.dao; + +import com.lyt.bean.TestStatus; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Select; +import org.springframework.stereotype.Repository; + +/** + * @Author:张勇 + * @Date:2023/5/11 22:36 + * @Info: + */ +@Repository +public interface TestStatusDao { + + @Insert("insert into test_status values(#{stu_test_id},#{student_id},#{name},#{date},#{cutNum})") + public int addTestStatus(TestStatus testStatus); + + @Select("select student_id from test_status where student_id = #{0}") + public Integer selStuByStuId(Integer id); +} diff --git a/src/main/java/com/lyt/service/CourseService.java b/src/main/java/com/lyt/service/CourseService.java index 240d1f1c640423420ec26a4f2bcbf0abaf4021b9..5ca21996457b2d7f92a09370d56c002ac0a6752d 100644 --- a/src/main/java/com/lyt/service/CourseService.java +++ b/src/main/java/com/lyt/service/CourseService.java @@ -6,6 +6,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @Service public class CourseService { diff --git a/src/main/java/com/lyt/service/PaperService.java b/src/main/java/com/lyt/service/PaperService.java index 81d8ff1ef62cc2f4e48d8bbed0f988504b4f2a85..3a851e8b8f0431f61b5d5fb3bf0f59af03f87fa4 100644 --- a/src/main/java/com/lyt/service/PaperService.java +++ b/src/main/java/com/lyt/service/PaperService.java @@ -1,5 +1,6 @@ package com.lyt.service; +import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.lyt.bean.Paper; @@ -17,9 +18,19 @@ import org.apache.ibatis.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.rmi.server.ServerCloneException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.stream.Collectors; +import cn.hutool.core.util.RandomUtil; +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @Service public class PaperService { @Autowired @@ -38,6 +49,7 @@ public class PaperService { //根据paperId获取 试题 List paperQuestions = questionDao.getPaperQuestionById(id); // System.out.println("打印一下 paperQuestions"+paperQuestions); + //获取所有小题 List questionVos = new ArrayList<>(); //获取所有的相关题目 并写入 item中 for (PaperQuestion paperQuestion : paperQuestions) { @@ -74,28 +86,81 @@ public class PaperService { System.out.println("遍历输出 titleName"+titleContent.getTitleName()); QuestionsVo questionsVo = new QuestionsVo(); questionsVo.setQuestionName(titleContent.getTitleName()); - questionsVos.add(questionsVo); + questionsVo.setType(titleContent.getType()); + questionsVos.add(questionsVo);//将titleContent转为questionsVos } for (QuestionsVo questionsVo : questionsVos) { //把小题塞进大题里面 - questionsVo.setQuestionItems(questionVos); - - + List questionVo1 = new ArrayList<>(); +// for (int i=0 ; i papersVos(List papers){ + List paperVos = new ArrayList<>(); + for (Paper paper : papers) { + PaperVo paperVo = new PaperVo(); + BeanUtil.beanConvert(paper,paperVo); + List questionsVos = (List) JSON.parse(paper.getTitleContent());//获取大题 + paperVo.setTitleItems(questionsVos); + paperVos.add(paperVo); + //将content转换 + } + return paperVos; + } + + //zjx 获取所有试卷 + public List getAllPaper(){ + List papers = paperDao.getAllPaper(); + return papersVos(papers); + }; + + //zjx 根据年级获取所有试卷 + public List getAllByGradePaper(Integer grade){ + List papers = paperDao.getAllByGradePaper(grade); + return papersVos(papers); + }; + + //根据课程获取所有试卷 + public List getAllByCoursePaper(int courseId){ + List papers = paperDao.getAllByCoursePaper(courseId); + return papersVos(papers); + }; + public int updatePaper(Paper paper){ return paperDao.updatePaper(paper); };//根据试卷编号更新试卷名字,年级 @@ -111,14 +176,25 @@ public class PaperService { public int addPaper(PaperVo paperVo){ Paper paper = new Paper(); - BeanUtil.beanConvert(paperVo,paper); + BeanUtil.beanConvert(paperVo,paper);//将paperVo转为paper //先写paper表 // TODO: 2023/5/2 还有很多逻辑需要处理 例如 one two three - + // TODO: 2023/5/4 完成 one two three 和 score逻辑 //因为id是自增的 取数据库中最大id然后+1即可 ,但是这样处理存在并发风险 int newId = paperDao.getPaperMaxId()+1; + int one = 0;//记录选择题数量 + int two = 0;//记录判断题数量 + int three = 0;//记录问答题数量 + int score = 0;//记录试卷总分分数 paper.setPaperId(newId); //这个是自增的 + paper.setStatus(0);//试卷状态初始化为0(zjx) + + //添加时间 + SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(System.currentTimeMillis()); + System.out.println(formatter.format(date)); + paper.setTime(formatter.format(date)); System.out.println("转换后的paper "+paper); //处理 titleContent @@ -126,32 +202,62 @@ public class PaperService { //遍历所有的大题获取 name List titleItems = paperVo.getTitleItems(); - for (int i = 0; i < titleItems.size(); i++) { - QuestionsVo titleItem = titleItems.get(i); - TitleContent titleContent = new TitleContent(); - titleContent.setTitleName(titleItem.getQuestionName()); - titleContent.setSort(i); - titleContents.add(titleContent); - } - String titleContentJson = JSON.toJSONString(titleContents); - paper.setTitleContent(titleContentJson); - paperDao.addPaper(paper); +// for (int i = 0; i < titleItems.size(); i++) { +// QuestionsVo titleItem = titleItems.get(i); +// TitleContent titleContent = new TitleContent(); +// titleContent.setTitleName(titleItem.getQuestionName());//大题名字 +// titleContent.setSort(i);//大题编号 +// titleContents.add(titleContent); +// } +// paperDao.addPaper(paper);//zjx + + int index = 0; //再写试卷 -- 题目关系表 List paperQuestions = new ArrayList<>(); //建立 试卷 试题关系映射 - for (QuestionsVo titleItem : paperVo.getTitleItems()) { - for (QuestionVo questionItem : titleItem.getQuestionItems()) { - int questionId = questionItem.getQuestionId(); - PaperQuestion paperQuestion = new PaperQuestion(); + for (QuestionsVo titleItem : paperVo.getTitleItems()) {//遍历大题 + titleItem = titleItems.get(index); + TitleContent titleContent = new TitleContent(); + titleContent.setTitleName(titleItem.getQuestionName());//大题名字 + titleContent.setSort(index);//大题编号 + index++; + for (QuestionVo questionItem : titleItem.getQuestionItems()) {//遍历大题中的小题 + int questionId = questionItem.getQuestionId();//获取小题中的id + PaperQuestion paperQuestion = new PaperQuestion();//创建一个试卷试题关联对象 //设置paperId paperQuestion.setPaperId(paper.getPaperId()); // 设置questionId paperQuestion.setQuestionId(questionId); + //zjx + int type = questionDao.getQuestionById(questionId).getType(); + titleContent.setType(type); + if (type == 1 || type == 2){ + one++; + }else if (type == 4){ + two++; + }else if (type == 3){ + three++; + } + score = score + questionDao.getQuestionById(questionId).getScore(); - paperQuestions.add(paperQuestion); + paperQuestions.add(paperQuestion);//添加关联 } + titleContents.add(titleContent); } + + String titleContentJson = JSON.toJSONString(titleContents);//转为json格式 + paper.setTitleContent(titleContentJson); + + //zjx + paper.setOne(one); + paper.setTwo(two); + paper.setThree(three); + paper.setScore(score); + paperDao.addPaper(paper); + + + System.out.println("打印一下 paperQuestion "+paperQuestions); for (PaperQuestion paperQuestion : paperQuestions) { @@ -161,9 +267,120 @@ public class PaperService { return 1; };//创建试卷 - public List getAllByCoursePaper(int courseId){ - return paperDao.getAllByCoursePaper(courseId); - };//根据课程获取所有试卷中的试题 + + //自动添加大题封装,zjx 2023/5/5 + private void settitleContents(int paperquestionSize,List titleContents,String TitleName,int Sort,int type){ + if (paperquestionSize > 0){ + TitleContent titleContent = new TitleContent(); + titleContent.setTitleName(TitleName); + titleContent.setSort(Sort); + titleContent.setType(type); + titleContents.add(titleContent); + } + } + + //试卷和试题关联关系封装方法,zjx 2023/5/5 + private int getPaperQuestion(int questionSize,int paperquestionSize,List source,int paperId,List paperQuestions){ + int score = 0; + List typeRandomList = getEleList(questionSize,paperquestionSize); + for (Integer index : typeRandomList){ + Question question = source.get(index);//在各题目数组中取 + score = score + question.getScore(); + PaperQuestion paperQuestion = new PaperQuestion(); + paperQuestion.setPaperId(paperId); + paperQuestion.setQuestionId(question.getQuestionId()); + paperQuestions.add(paperQuestion); + } + return score; + } + + //不重复随机数,zjx 2023/5/5 + private List getEleList(int sourceSize,int resultSize){ + List list = CollUtil.newArrayList(); + for (int i = 0; i < sourceSize ;i++){ + list.add(i); + } + return RandomUtil.randomEles(list,resultSize); + } + + + //zjx 2023/5/5 自动组卷 + public int addPaperAut(PaperVo paperVo){ + Paper paper = new Paper(); + BeanUtil.beanConvert(paperVo,paper);//将paperVo转为paper + + //因为id是自增的 取数据库中最大id然后+1即可 ,但是这样处理存在并发风险 + int newId = paperDao.getPaperMaxId()+1; + int score = 0;//记录试卷总分分数 + paper.setPaperId(newId); //这个是自增的 + paper.setStatus(0);//试卷状态初始化为0 + + //添加时间 + SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(System.currentTimeMillis()); + System.out.println(formatter.format(date)); + paper.setTime(formatter.format(date)); + + //首先根据课程编号获取所有试题 + List questions = questionDao.getAllByCourseQuestion(paper.getCourseId()); + //根据题目类型查询所有题目,将各类题目放入到数组中,重新排序 + //选择 + List type1list = questions.stream().filter(question -> question.getType().equals(1) || question.getType().equals(2)).collect(Collectors.toList()); + //判断 + List type2list = questions.stream().filter(question -> question.getType().equals(4)).collect(Collectors.toList()); + //问答 + List type3list = questions.stream().filter(question -> question.getType().equals(3)).collect(Collectors.toList()); + System.out.println("转换后的paper "+paper); + + if ( type1list.size() < paper.getOne()){ + System.out.println("选择题数量不足"); + return 2; + } + if ( type2list.size() < paper.getTwo()){ + System.out.println("判断题数量不足"); + return 3; + } + if ( type3list.size() < paper.getThree()){ + System.out.println("问答题数量不足"); + return 4; + } + + List paperQuestions = new ArrayList<>();//存放试卷和试题关系集合 + + //开始自动组卷 + //从选择题中随机抽取指定数量的题目放入到paperQuestions集合,平且获取各大题分数 + int score1 = getPaperQuestion(type1list.size(),paper.getOne(),type1list,paper.getPaperId(),paperQuestions); + //从判断题中随机抽取指定数量的题目放入到paperQuestions集合 + int score2 = getPaperQuestion(type2list.size(),paper.getTwo(),type2list,paper.getPaperId(),paperQuestions); + //从问答题中随机抽取指定数量的题目放入到paperQuestions集合 + int score3 = getPaperQuestion(type3list.size(),paper.getThree(),type3list,paper.getPaperId(),paperQuestions); + + //总分 + score = score1 + score2 + score3; + + System.out.println("打印一下 paperQuestion "+paperQuestions); + for (PaperQuestion paperQuestion : paperQuestions) { + paperDao.addPaperQuestion(paperQuestion);//添加试卷试题关联关系 + } + + //处理 titleContent + List titleContents = new ArrayList<>(); + + //如果选择题数量大于0,自动创建选择大题 + settitleContents(paper.getOne(),titleContents,"选择题",0,1); + //如果判断题数量大于0,自动创建判断题大题 + settitleContents(paper.getTwo(),titleContents,"判断题",1,2); + //如果问答题数量大于0,自动创建问答题大题 + settitleContents(paper.getThree(),titleContents,"问答题",2,3); + + String titleContentJson = JSON.toJSONString(titleContents);//转为json格式 + paper.setTitleContent(titleContentJson); + + paper.setScore(score); + paperDao.addPaper(paper); + + return 1; + };//自动创建试卷 public int commitPaper(@Param("status")Integer status, @Param("paperId")Integer paperId){ return paperDao.commitPaper(1,paperId); diff --git a/src/main/java/com/lyt/service/QuestionService.java b/src/main/java/com/lyt/service/QuestionService.java index 9d9cc1f4fc357e869a43e0f4d276401321293875..6510dcdb5f7949779a1fee82f836d7e8e1a90e6d 100644 --- a/src/main/java/com/lyt/service/QuestionService.java +++ b/src/main/java/com/lyt/service/QuestionService.java @@ -4,14 +4,21 @@ import com.alibaba.fastjson.JSON; import com.lyt.bean.Question; import com.lyt.dao.QuestionDao; import com.lyt.util.BeanUtil; +import com.lyt.vo.AnswerVo; import com.lyt.vo.ItemVo; import com.lyt.vo.QuestionVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; - +/** + * @Author: zjx + * @Date: 2023/04/27/20:03 + * @Description: + */ @Service public class QuestionService { @Autowired @@ -22,28 +29,88 @@ public class QuestionService { System.out.println("查询到的question"+question); QuestionVo questionVo = new QuestionVo(); - BeanUtil.beanConvert(question,questionVo); + BeanUtil.beanConvert(question,questionVo);//将question转换为questionVo List items = (List) JSON.parse(question.getContent()); questionVo.setItems(items); + if (questionVo.getType() == 2){ + List answerVos = (List) JSON.parse(question.getAnswer());//转为数组传送给前端 + questionVo.setAnswerVos(answerVos); + } return questionVo; }; + //封装Question转为QuestionVo + private List questionVos(List questions){ + List questionVos = new ArrayList<>(); + for (Question question : questions) { + QuestionVo questionVo = new QuestionVo(); + BeanUtil.beanConvert(question,questionVo); + List items = (List) JSON.parse(question.getContent()); + if (question.getType() == 2){//数据库的所有数据都要按最新标准,不然格式出错 + List answerVos = (List) JSON.parse(question.getAnswer());//转为数组传送给前端 + questionVo.setAnswerVos(answerVos); + } + questionVo.setItems(items); + System.out.println(questionVo.toString()); + questionVos.add(questionVo); + //将content转换 + } + return questionVos; + } + + //zjx 2023/5/7 public List getAllQuestion(){ List questions = questionDao.getAllQuestion(); - List questionVos = new ArrayList<>(); - for (Question question : questions) { - QuestionVo questionVo = new QuestionVo(); - BeanUtil.beanConvert(question,questionVo); - List items = (List) JSON.parse(question.getContent()); - questionVo.setItems(items); - questionVos.add(questionVo); - //将content转换 - } - return questionVos; + System.out.println(11111); + return questionVos(questions); }; - public int updateQuestion(Question question){ - return questionDao.updateQuestion(question); + public List getAllQuestionByCourseIdOrType(Integer type,Integer courseId){ + List questions = questionDao.getAllQuestionByCourseIdOrType(type,courseId); + return questionVos(questions); + } + + public int updateQuestion(QuestionVo questionVo){ + System.out.println("执行 updateQuestion"); + Question question = new Question(); + Question newQuestion = BeanUtil.beanConvert(questionVo,question);//将questionVo转换为question + String contentJson = JSON.toJSONString(questionVo.getItems()); + + //zjx +// SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); + SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(System.currentTimeMillis()); + System.out.println(formatter.format(date)); + newQuestion.setTime(formatter.format(date)); + + System.out.println("选项的json串"+contentJson); + newQuestion.setContent(contentJson); + System.out.println("这是新创建的 对象"+ newQuestion); + + + //zjx + if (newQuestion.getType() == 2){ + List answerVos2 = new ArrayList<>();//用于重新接收答案数组,直接添加会添加修改前的数据 + for (int i = questionVo.getLength();i0){ + System.out.println("修改试题成功"); + return 1; + } + return 1; };//根据试卷编号更新试卷 public int deleteQuestion(Integer questionId){ @@ -53,13 +120,26 @@ public class QuestionService { public int addQuestion(QuestionVo questionVo){ System.out.println("执行 addQuestion"); Question question = new Question(); - - Question newQuestion = BeanUtil.beanConvert(questionVo,question); + Question newQuestion = BeanUtil.beanConvert(questionVo,question);//将questionVo转换为question String contentJson = JSON.toJSONString(questionVo.getItems()); + + //zjx +// SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); + SimpleDateFormat formatter= new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(System.currentTimeMillis()); + System.out.println(formatter.format(date)); + newQuestion.setTime(formatter.format(date)); + System.out.println("选项的json串"+contentJson); newQuestion.setContent(contentJson); System.out.println("这是新创建的 对象"+ newQuestion); + //zjx + if (newQuestion.getType() == 2){ + String answerJson = JSON.toJSONString(questionVo.getAnswerVos()); + newQuestion.setAnswer(answerJson); + } + //将选项转换为 json 串 int num = questionDao.addQuestion(newQuestion); if(num >0){ @@ -67,14 +147,20 @@ public class QuestionService { return 1; } return 0; - };//创建试卷 + };//创建试题 - - - public List getAllByCourseQuestion(int courseId){ - return questionDao.getAllByCourseQuestion(courseId); + //zjx 5/7 + public List getAllByCourseQuestion(int courseId){ + List questions = questionDao.getAllByCourseQuestion(courseId); + return questionVos(questions); };//根据课程获取所有试题 + //zjx 5/7 + public List getAllBytypeuestion(int type){ + List questions = questionDao.getAllBytypeuestion(type); + return questionVos(questions); + }; + public List getAllByUserIdQuestion(int userId){ return questionDao.getAllByUserIdQuestion(userId); };//根据创建者获取所有试题 diff --git a/src/main/java/com/lyt/service/TestAnswerService.java b/src/main/java/com/lyt/service/TestAnswerService.java new file mode 100644 index 0000000000000000000000000000000000000000..f0c40aac2f3b11da25af223345b7fd8213186baa --- /dev/null +++ b/src/main/java/com/lyt/service/TestAnswerService.java @@ -0,0 +1,72 @@ +package com.lyt.service; + + +import com.alibaba.fastjson.JSON; +import com.lyt.bean.LinkAnswer; +import com.lyt.bean.TestAnswer; +import com.lyt.dao.TestAnswerDao; +import com.lyt.util.BeanUtil; +import com.lyt.vo.LinkAnswerVo; +import com.lyt.vo.RetAnswerVo; +import com.lyt.vo.TestAnswerVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * @Author:张勇 + * @Date:2023/5/18 10:47 + * @Info: + */ +@Service +public class TestAnswerService { + + @Autowired + TestAnswerDao dao; + + public Integer addTestStatus(TestAnswerVo testAnswerVo) { + + System.out.println("---------------------------------"); + TestAnswer testAnswer = new TestAnswer(); + TestAnswer newTestAnswer = BeanUtil.beanConvert(testAnswerVo, testAnswer); + List linkAnswers = new ArrayList<>(); + for(LinkAnswerVo linkAnswerVo: testAnswerVo.getLinkAnswerVos()){ + LinkAnswer linkAnswer = new LinkAnswer(); + linkAnswer.setStu_test_id(testAnswerVo.getStu_test_id()); + linkAnswer.setPaper_id(testAnswerVo.getPaper_id()); + linkAnswer.setIndex(linkAnswerVo.getIndex()); + linkAnswer.setQuestion_id(linkAnswerVo.getQuestion_id()); + linkAnswer.setAnswer(JSON.toJSONString(linkAnswerVo.getAnswer())); + linkAnswers.add(linkAnswer); + } + for (LinkAnswer linkAnswer : linkAnswers){ + dao.addLinkAnswer(linkAnswer); + } + testAnswer.setLinkAnswers(JSON.toJSONString(linkAnswers)); + int flag = dao.addAnswer(testAnswer); + return 1; +} + //找出关联表中某个学生答的某张试卷的所有答案 + public List selAnswerByPaperIdAndStuId(Integer id,Integer stuId){ + List list = dao.selAnswerByPaperIdAndStuId(id,stuId); + System.out.println(list); + List voList = new ArrayList<>(); + for (LinkAnswer linkAnswer:list){ + RetAnswerVo linkAnswerVo = new RetAnswerVo(); + linkAnswerVo.setIndex(linkAnswer.getIndex()); + linkAnswerVo.setQuestion_id(linkAnswer.getQuestion_id()); + linkAnswerVo.setAnswer(linkAnswer.getAnswer()); + voList.add(linkAnswerVo); + System.out.println(linkAnswerVo.toString()); + } + return voList; + } + + //删除关联表中某个学生答的某张试卷的所有答案--》修改不如删除 + public Integer delAnswerByPaperIdAndStuId(Integer id,Integer stuId){ + Integer num = dao.delAnswerByPaperIdAndStuId(id,stuId); + return num; + } +} \ No newline at end of file diff --git a/src/main/java/com/lyt/service/TestStatuService.java b/src/main/java/com/lyt/service/TestStatuService.java new file mode 100644 index 0000000000000000000000000000000000000000..de75a6a5defc723b4b29a7ada026572d64dec339 --- /dev/null +++ b/src/main/java/com/lyt/service/TestStatuService.java @@ -0,0 +1,32 @@ +package com.lyt.service; + +import com.lyt.bean.TestStatus; +import com.lyt.dao.TestStatusDao; +import com.lyt.util.BeanUtil; +import com.lyt.vo.TestStatusVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Author:张勇 + * @Date:2023/5/11 22:34 + * @Info: + */ +@Service +public class TestStatuService { + @Autowired + TestStatusDao dao; + + public int addTestStatus(TestStatusVo testStatusVo){ + TestStatus testStatus = new TestStatus(); + TestStatus newTestStatus = BeanUtil.beanConvert(testStatusVo,testStatus); + int num = dao.addTestStatus(newTestStatus); + + return num; + } + public Integer selStuByStuId(Integer id){ + Integer num = dao.selStuByStuId(id); + return num; + } + +} diff --git a/src/main/java/com/lyt/vo/AnswerVo.java b/src/main/java/com/lyt/vo/AnswerVo.java new file mode 100644 index 0000000000000000000000000000000000000000..af27ee8a522b1b5cc7ee6f192a15310da56cec33 --- /dev/null +++ b/src/main/java/com/lyt/vo/AnswerVo.java @@ -0,0 +1,12 @@ +package com.lyt.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AnswerVo { + private String prefix; +} diff --git a/src/main/java/com/lyt/vo/ItemVo.java b/src/main/java/com/lyt/vo/ItemVo.java index cdf4e0592f9c1e3b6288300e7d3262d3ba60ffe8..0da556c1c9df4fd8a4ffecb5553885a5b58a373f 100644 --- a/src/main/java/com/lyt/vo/ItemVo.java +++ b/src/main/java/com/lyt/vo/ItemVo.java @@ -1,8 +1,6 @@ package com.lyt.vo; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; /** * @Author: lyt diff --git a/src/main/java/com/lyt/vo/LinkAnswerVo.java b/src/main/java/com/lyt/vo/LinkAnswerVo.java new file mode 100644 index 0000000000000000000000000000000000000000..dae5046f8cc1270b8d0eeded6be48ec18c3c0815 --- /dev/null +++ b/src/main/java/com/lyt/vo/LinkAnswerVo.java @@ -0,0 +1,81 @@ +package com.lyt.vo; + +/** + * @Author:张勇 + * @Date:2023/5/18 10:10 + * @Info: + */ +public class LinkAnswerVo { + private Integer id; + private Integer stu_test_id; + private Integer paper_id; + private Integer index; + private Integer question_id; + private String[] answer; + + public LinkAnswerVo() { + } + + public LinkAnswerVo(Integer index, Integer questionId, String[] answer) { + this.index = index; + this.question_id = questionId; + this.answer = answer; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getStu_test_id() { + return stu_test_id; + } + + public void setStu_test_id(Integer stu_test_id) { + this.stu_test_id = stu_test_id; + } + + public Integer getPaper_id() { + return paper_id; + } + + public void setPaper_id(Integer paper_id) { + this.paper_id = paper_id; + } + + public Integer getIndex() { + return index; + } + + public void setIndex(Integer index) { + this.index = index; + } + + public Integer getQuestion_id() { + return question_id; + } + + public void setQuestion_id(Integer question_id) { + this.question_id = question_id; + } + + public String[] getAnswer() { + return answer; + } + + public void setAnswer(String[] answer) { + this.answer = answer; + } + + @Override + public String toString() { + return "LinkAnswerVo{" + + "index=" + index + + ",question_id=" + question_id + + ", answer='" + answer + '\'' + + '}'; + } +} diff --git a/src/main/java/com/lyt/vo/PaperVo.java b/src/main/java/com/lyt/vo/PaperVo.java index 9386955461d2c2924ad1a07694d844ee8b8ce3d3..329ca4185d4c454ed1ad9c8598226c0856ed2738 100644 --- a/src/main/java/com/lyt/vo/PaperVo.java +++ b/src/main/java/com/lyt/vo/PaperVo.java @@ -1,9 +1,7 @@ package com.lyt.vo; import com.lyt.bean.OnlineExam.Question; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.List; @@ -22,11 +20,14 @@ public class PaperVo { private int paperType; //试卷类型 ab卷? private Integer grade;//试卷年级 private Integer courseId;//课程编号 + private Integer one;//选择题 + private Integer two;//判断题 + private Integer three;//问答题 private String paperName;//试卷名字 private String suggestTime; private Integer status;//试卷状态 - private String score;//试卷总分分数 + private Integer score;//试卷总分分数 private List titleItems; //大题 // private String limitTime; // diff --git a/src/main/java/com/lyt/vo/QuestionVo.java b/src/main/java/com/lyt/vo/QuestionVo.java index 312c9fb8ac40d8ac31169022128a671f1db7a02a..03feecf9a46234325970e15b4a1dc8220735821e 100644 --- a/src/main/java/com/lyt/vo/QuestionVo.java +++ b/src/main/java/com/lyt/vo/QuestionVo.java @@ -1,8 +1,6 @@ package com.lyt.vo; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.List; @@ -19,15 +17,16 @@ public class QuestionVo { private int gradeLevel; //班级 private String courseId; //subjectId; private String questionName; // (title)标题:例如第一题。。。 - private Integer type; //试卷类型,0单选题,1多选题,2判断题,3问答题 + private Integer type; //试卷类型,1单选题,2多选题,3问答题, 4判断题 zjx private String detail; //详细解答 private String answer; //答案 - private Integer score; //总分 + private Integer score; //总分 zjx private String difficult; //难度 private Integer userId;//用户编号 private String time;//创建时间 List items; //选择题选项 后面会转换成json - + List answerVos; //多选题答案 + private int length;//接收answerVos数组原始长度 } diff --git a/src/main/java/com/lyt/vo/QuestionsVo.java b/src/main/java/com/lyt/vo/QuestionsVo.java index 6ba93e52e14495845d598ec18c8c551935964bf1..bc86c93cf6cc7284bec42222ea174d9a112d08ee 100644 --- a/src/main/java/com/lyt/vo/QuestionsVo.java +++ b/src/main/java/com/lyt/vo/QuestionsVo.java @@ -1,8 +1,6 @@ package com.lyt.vo; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.List; @@ -17,4 +15,5 @@ import java.util.List; public class QuestionsVo { private String questionName; private List questionItems; + private int type; } diff --git a/src/main/java/com/lyt/vo/RetAnswerVo.java b/src/main/java/com/lyt/vo/RetAnswerVo.java new file mode 100644 index 0000000000000000000000000000000000000000..8683a2ee82dcf806197153841e416dd0f8fc7a9a --- /dev/null +++ b/src/main/java/com/lyt/vo/RetAnswerVo.java @@ -0,0 +1,49 @@ +package com.lyt.vo; + +import com.alibaba.fastjson.JSONArray; + +import java.lang.reflect.Array; + +/** + * @Author:张勇 + * @Date:2023/5/18 17:55 + * @Info: + */ +public class RetAnswerVo { + private Integer index; + private Integer question_id; + private String answer; + + public Integer getIndex() { + return index; + } + + public void setIndex(Integer index) { + this.index = index; + } + + public Integer getQuestion_id() { + return question_id; + } + + public void setQuestion_id(Integer question_id) { + this.question_id = question_id; + } + + public String getAnswer() { + return answer; + } + + public void setAnswer(String answer) { + this.answer = answer; + } + + @Override + public String toString() { + return "RetAnswerVo{" + + "index=" + index + + ", question_id=" + question_id + + ", answer='" + answer + '\'' + + '}'; + } +} diff --git a/src/main/java/com/lyt/vo/TestAnswerVo.java b/src/main/java/com/lyt/vo/TestAnswerVo.java new file mode 100644 index 0000000000000000000000000000000000000000..83900fa04f7287d44cd350e93deae33e159f28b8 --- /dev/null +++ b/src/main/java/com/lyt/vo/TestAnswerVo.java @@ -0,0 +1,65 @@ +package com.lyt.vo; + +import java.util.List; + +/** + * @Author:张勇 + * @Date:2023/5/16 19:46 + * @Info: + */ +public class TestAnswerVo { + private Integer test_id; + private Integer stu_test_id; + private Integer paper_id; + private List linkAnswerVos; + + + + public Integer getTest_id() { + return test_id; + } + + public void setTest_id(Integer test_id) { + this.test_id = test_id; + } + + public Integer getStu_test_id() { + return stu_test_id; + } + + public void setStu_test_id(Integer stu_test_id) { + this.stu_test_id = stu_test_id; + } + + public Integer getPaper_id() { + return paper_id; + } + + public void setPaper_id(Integer paper_id) { + this.paper_id = paper_id; + } + + public List getLinkAnswerVos() { + return linkAnswerVos; + } + + public void setLinkAnswerVos(List linkAnswerVos) { + this.linkAnswerVos = linkAnswerVos; + } + + public TestAnswerVo(Integer stu_test_id, Integer paper_id, List stu_answer) { + this.stu_test_id = stu_test_id; + this.paper_id = paper_id; + this.linkAnswerVos = stu_answer; + } + + @Override + public String toString() { + return "TestAnswerVo{" + + "test_id=" + test_id + + ", stu_test_id=" + stu_test_id + + ", paper_id=" + paper_id + + ", linkAnswerVos=" + linkAnswerVos + + '}'; + } +} diff --git a/src/main/java/com/lyt/vo/TestStatusVo.java b/src/main/java/com/lyt/vo/TestStatusVo.java new file mode 100644 index 0000000000000000000000000000000000000000..beabddba62f29a263549024638e19d7f09a8a1f4 --- /dev/null +++ b/src/main/java/com/lyt/vo/TestStatusVo.java @@ -0,0 +1,40 @@ +package com.lyt.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author:张勇 + * @Date:2023/5/11 22:03 + * @Info: 参加考试的学生实体类 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TestStatusVo { + private Integer stu_test_id; + private Integer student_id; + private Integer cutNum; + private String name; + private String date; + + + public TestStatusVo(Integer student_idm, String name, String date, Integer cutNu) { + this.student_id = student_id; + this.name = name; + this.date = date; + this.cutNum = cutNum; + } + + @Override + public String toString() { + return "TestStatusVo{" + + "stu_test_id=" + stu_test_id + + ", student_id=" + student_id + + ", cutNum=" + cutNum + + ", name='" + name + '\'' + + ", date='" + date + '\'' + + '}'; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 580cb452151d627f9324a614b6a3c0e4fd57b196..778081ab6305494b5e56592e6ab101c10f7e5804 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,9 +4,9 @@ spring: datasource: #MySQL配置 driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/onlineexamsystem?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC + url: jdbc:mysql://localhost:3306/onlineexamsystem?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC username: root - password: root + password: ZY584726 mybatis: mapper-locations: classpath:mapper/*.xml diff --git a/src/main/resources/mapper/QuestionMapper.xml b/src/main/resources/mapper/QuestionMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..4037abb235d2173c2eb858305211c0a1234cac30 --- /dev/null +++ b/src/main/resources/mapper/QuestionMapper.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/src/test/java/com/lyt/QuestionTest.java b/src/test/java/com/lyt/QuestionTest.java index e66bf67d521da0191f016601aeb003ecd76ae35b..5945a11664ef73b3df87b547d2df7fea1453ec94 100644 --- a/src/test/java/com/lyt/QuestionTest.java +++ b/src/test/java/com/lyt/QuestionTest.java @@ -36,6 +36,16 @@ public class QuestionTest { List questions = questionDao.getAllQuestion(); System.out.println(questions); } + + //二级查询 + @Test + public void getAllQuestionByCourseIdOrType(){ + List questions = questionDao.getAllQuestionByCourseIdOrType(null,1); + for (Question question : questions){ + System.out.println(question.toString()); + } + + } // // //测试根据试卷编号查看试卷中所有试题 // @Test