|
@@ -0,0 +1,303 @@
|
|
|
+package com.miaxis.test;
|
|
|
+
|
|
|
+import com.miaxis.ZzjsApplication;
|
|
|
+import com.miaxis.question.domain.QuestionInfo;
|
|
|
+import com.miaxis.question.domain.TAppExamRule;
|
|
|
+import com.miaxis.question.dto.QuestionInfoTestDTO;
|
|
|
+import com.miaxis.question.service.IQuestionInfoService;
|
|
|
+import com.miaxis.question.service.ITAppExamRuleService;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+
|
|
|
+import java.sql.Array;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Random;
|
|
|
+
|
|
|
+@SpringBootTest(classes = ZzjsApplication.class)
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+public class TestRule {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITAppExamRuleService appExamRuleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQuestionInfoService questionInfoService;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test() throws Exception {
|
|
|
+
|
|
|
+ //全题库
|
|
|
+ List<QuestionInfo> allList = new ArrayList<QuestionInfo>();
|
|
|
+ //选择
|
|
|
+ List<QuestionInfo> judgeList = new ArrayList<QuestionInfo>();
|
|
|
+ //判断题
|
|
|
+ List<QuestionInfo> choiceList = new ArrayList<QuestionInfo>();
|
|
|
+ //简单题
|
|
|
+ List<Integer> easyDegree = new ArrayList<Integer>();
|
|
|
+ easyDegree.add(1);
|
|
|
+ easyDegree.add(2);
|
|
|
+ easyDegree.add(3);
|
|
|
+ //难题
|
|
|
+ List<Integer> diffDegree = new ArrayList<Integer>();
|
|
|
+ diffDegree.add(4);
|
|
|
+ diffDegree.add(5);
|
|
|
+ //科目一通用
|
|
|
+ TAppExamRule tAppExamRule = new TAppExamRule();
|
|
|
+ tAppExamRule.setKemu(1);
|
|
|
+ tAppExamRule.setGs("xc");
|
|
|
+ tAppExamRule.setAreacode(0);
|
|
|
+
|
|
|
+ List<TAppExamRule> list = appExamRuleService.selectTAppExamRuleList(tAppExamRule);
|
|
|
+ int total = 0;
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ TAppExamRule er = list.get(i);
|
|
|
+ int easyJudge = er.getJudgeCount();
|
|
|
+ int easyChoice = er.getChoiceCount();
|
|
|
+
|
|
|
+ Random random = new Random();
|
|
|
+ int d = 0; //单选题
|
|
|
+ int p = 0; //判断题
|
|
|
+ for (int j = 0; j < er.getDifficultCount(); j++) {
|
|
|
+ if (random.nextInt(10) >= 5) { //单选题
|
|
|
+ if (easyJudge - 1 < 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ d++;
|
|
|
+ easyJudge--;
|
|
|
+ }
|
|
|
+ } else { //判断题
|
|
|
+ if (easyChoice - 1 < 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ p++;
|
|
|
+ easyChoice--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("简单判断:" + easyJudge);
|
|
|
+ System.out.println("简单选择:" + easyChoice);
|
|
|
+ System.out.println("难题判断:" + p);
|
|
|
+ System.out.println("难题选择:" + d);
|
|
|
+ total += easyJudge + easyChoice + p + d;
|
|
|
+ System.out.println("---------------------------------------------");
|
|
|
+
|
|
|
+
|
|
|
+ //判断简单
|
|
|
+ QuestionInfoTestDTO qt = new QuestionInfoTestDTO();
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setLiceCar("1"); //车型
|
|
|
+ qt.setNum(easyJudge); //题数
|
|
|
+ List<QuestionInfo> easyJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+
|
|
|
+ //单选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(2); //判断题
|
|
|
+ qt.setLiceCar("1"); //车型
|
|
|
+ qt.setNum(easyChoice); //题数
|
|
|
+ List<QuestionInfo> easyChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+
|
|
|
+
|
|
|
+ //判断难题
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setLiceCar("1"); //车型
|
|
|
+ qt.setNum(p); //题数
|
|
|
+ List<QuestionInfo> diffJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+
|
|
|
+
|
|
|
+ //单选难题
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setLiceCar("1"); //车型
|
|
|
+ qt.setNum(d); //题数
|
|
|
+ List<QuestionInfo> diffChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+
|
|
|
+
|
|
|
+ judgeList.addAll(easyJudgeList);
|
|
|
+ judgeList.addAll(diffJudgeList);
|
|
|
+ choiceList.addAll(easyChoiceList);
|
|
|
+ choiceList.addAll(diffChoiceList);
|
|
|
+ }
|
|
|
+
|
|
|
+ allList.addAll(judgeList);
|
|
|
+ allList.addAll(choiceList);
|
|
|
+ System.out.println("judgeList:" + judgeList.size());
|
|
|
+ System.out.println("choiceList:" + choiceList.size());
|
|
|
+ System.out.println("allList:" + allList.size());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test2() throws Exception {
|
|
|
+ //全题库
|
|
|
+ List<QuestionInfo> allList = new ArrayList<QuestionInfo>();
|
|
|
+ int error = 0;
|
|
|
+ while (allList.size()!=50 && error<10) {
|
|
|
+ System.out.println("error:"+error);
|
|
|
+ allList = new ArrayList<QuestionInfo>();
|
|
|
+ //判断题
|
|
|
+ List<QuestionInfo> judgeList = new ArrayList<QuestionInfo>();
|
|
|
+ //选择题
|
|
|
+ List<QuestionInfo> choiceList = new ArrayList<QuestionInfo>();
|
|
|
+ //多选题
|
|
|
+ List<QuestionInfo> multipleList = new ArrayList<QuestionInfo>();
|
|
|
+
|
|
|
+ //简单题
|
|
|
+ List<Integer> easyDegree = new ArrayList<Integer>();
|
|
|
+ easyDegree.add(1);
|
|
|
+ easyDegree.add(2);
|
|
|
+ easyDegree.add(3);
|
|
|
+ //难题
|
|
|
+ List<Integer> diffDegree = new ArrayList<Integer>();
|
|
|
+ diffDegree.add(4);
|
|
|
+ diffDegree.add(5);
|
|
|
+ //科目一通用
|
|
|
+ TAppExamRule tAppExamRule = new TAppExamRule();
|
|
|
+ tAppExamRule.setKemu(4);
|
|
|
+ tAppExamRule.setGs("hc");
|
|
|
+ tAppExamRule.setAreacode(0);
|
|
|
+
|
|
|
+ List<TAppExamRule> list = appExamRuleService.selectTAppExamRuleList(tAppExamRule);
|
|
|
+ int total = 0;
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ TAppExamRule er = list.get(i);
|
|
|
+ int easyJudge = er.getJudgeCount();
|
|
|
+ int easyChoice = er.getChoiceCount();
|
|
|
+ int easyMultiple = er.getMultipleChoiceCount();
|
|
|
+ int x = i + 1;
|
|
|
+ System.out.println("第" + x + "轮easyJudge:" + easyJudge);
|
|
|
+
|
|
|
+ Random random = new Random();
|
|
|
+ int p = 0; //判断题
|
|
|
+ int d = 0; //单选题
|
|
|
+ int m = 0; //多选题
|
|
|
+ for (int j = 0; j < er.getDifficultCount(); j++) {
|
|
|
+ if (random.nextInt(9) <= 2) { //判断题
|
|
|
+ if (easyJudge - 1 < 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ p++;
|
|
|
+ easyJudge--;
|
|
|
+ }
|
|
|
+ } else if (random.nextInt(9) <= 5) { //单选题
|
|
|
+ if (easyChoice - 1 < 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ d++;
|
|
|
+ easyChoice--;
|
|
|
+ }
|
|
|
+ } else if (random.nextInt(9) <= 8) { //多选题
|
|
|
+ if (easyMultiple - 1 < 0) {
|
|
|
+ j--;
|
|
|
+ } else {
|
|
|
+ m++;
|
|
|
+ easyMultiple--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println("简单判断:" + easyJudge);
|
|
|
+ System.out.println("简单选择:" + easyChoice);
|
|
|
+ System.out.println("简单多选:" + easyMultiple);
|
|
|
+ System.out.println("难题判断:" + p);
|
|
|
+ System.out.println("难题选择:" + d);
|
|
|
+ System.out.println("难题多择:" + m);
|
|
|
+ total += easyJudge + easyChoice + easyMultiple + p + d + m;
|
|
|
+ System.out.println("---------------------------------------------");
|
|
|
+
|
|
|
+
|
|
|
+ //判断简单
|
|
|
+ QuestionInfoTestDTO qt = new QuestionInfoTestDTO();
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setLiceTruck("1"); //车型
|
|
|
+ qt.setNum(easyJudge); //题数
|
|
|
+ List<QuestionInfo> easyJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+ //单选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(2); //判断题
|
|
|
+ qt.setNum(easyChoice); //题数
|
|
|
+ List<QuestionInfo> easyChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+ //多选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(easyDegree); //简单难度
|
|
|
+ qt.setQuestionType(3); //判断题
|
|
|
+ qt.setNum(easyMultiple); //题数
|
|
|
+ List<QuestionInfo> easyMultipleList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+
|
|
|
+ //判断难题
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(1); //判断题
|
|
|
+ qt.setNum(p); //题数
|
|
|
+ List<QuestionInfo> diffJudgeList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+ if(p!=diffJudgeList.size()){
|
|
|
+ System.out.println("p!=diffJudgeList.size()");
|
|
|
+ error++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ //单选难题
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(2); //判断题
|
|
|
+ qt.setNum(d); //题数
|
|
|
+ List<QuestionInfo> diffChoiceList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+ if(d!=diffChoiceList.size()){
|
|
|
+ System.out.println("d!=diffChoiceList.size()");
|
|
|
+ error++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //多选简单
|
|
|
+ qt.setChapterId(er.getChapterId()); //章节ID
|
|
|
+ qt.setDiffDegree(diffDegree); //高难度
|
|
|
+ qt.setQuestionType(3); //判断题
|
|
|
+ qt.setNum(m); //题数
|
|
|
+ List<QuestionInfo> diffMultipleList = questionInfoService.selectTestQuestionInfoList(qt);
|
|
|
+ if(m!=diffMultipleList.size()){
|
|
|
+ System.out.println("m!=diffMultipleList.size()");
|
|
|
+ error++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ judgeList.addAll(easyJudgeList);
|
|
|
+ judgeList.addAll(diffJudgeList);
|
|
|
+ int judge = easyJudgeList.size() + diffJudgeList.size();
|
|
|
+ System.out.println("第" + x + "轮:" + judge);
|
|
|
+
|
|
|
+ choiceList.addAll(easyChoiceList);
|
|
|
+ choiceList.addAll(diffChoiceList);
|
|
|
+ multipleList.addAll(easyMultipleList);
|
|
|
+ multipleList.addAll(diffMultipleList);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ allList.addAll(judgeList);
|
|
|
+ allList.addAll(choiceList);
|
|
|
+ allList.addAll(multipleList);
|
|
|
+ System.out.println("error:"+error);
|
|
|
+ System.out.println("allList:" + allList.size());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|