在线考核——一键创建考试功能实现

在线考核平台难点——一键创建考核功能实现

在线考核平台,听名字顾名思义是一个可以进行线上考核的考试平台,只需要一台电脑、手机、平板就可以随时随地进行线上考核。
当初听到老板提出这个需求的时候蒙了一下!

老板:这不是很简单吗,以我们的技术,我觉得我们阔以搞一下!!

我(心里):emm~
在这里插入图片描述
我(实际上):阔以,阔以完全NO Problambem(东北式口音)

  • 老板是个理论强者,说也说不过他,只能硬着头皮上了!
  • 开始一两天,天天捋思路,找帖子,看博客!

可能这里有人会杠我,这不是很简单!

电脑给您!您来写!

等我告诉你具体细节你就知道有多难了!

我做的考核平台,主要考核目的是为了对我司培训学员进行国家级证书考核(具体什么考核我就不说了,公司项目不便多说!)

首先考核分为理论考核和实操考核

实操考核是上机操作 ,理论考核主要是进行线上理论的考核!也就是说学员要分别进行理论和实操考核!

老板想让我最终做出来的功能是输入机器数量和电脑数量,系统自动创建考核!

听着是感觉没多少事,是不是感觉特简单!
在这里插入图片描述

实际上只是冰山一角

听我继续讲!接下来是细节 !毕竟我们是专业搞事情的!
在创建考核时,要把考场分配出来

考场有两种:理论考场和实操考场,理论考场和实操考场分为初级、中级、高级

也就是说实操考场有三类(初中高),理论考场有三类(初中高),注意我说的是三类,不是一共有三场,也就是说初级实操考场可能有3场、5场·····,初级理论考场可能有5场、7场······

考场数量怎么确定的呢?根据培训学员的数量,也就是报考初级考核、中级考核、高级考核有多少人,然后根据实际实操机器有多少和理论电脑有多少,以此算出考场有多少,都是什么类别等等!

在这里插入图片描述

你以为这就完了!no!刚开始!

我们刚才把考场算出来了吧,考场是用来干嘛的!考试的!考试得有人、有卷!

考场分完了!该分人,分卷了!

考场建立完后把对应考试等级的培训人员分配到考场中,并且自动分配机器号!
在这里插入图片描述

接下来开始分卷了!

卷子分为实操试卷和理论试卷,实操试卷是world文档,需要把实操试卷分配给每个实操考场,并且随机分配,试卷不允许出现重复!也就是说不允许有多于或等于两场考试的试卷是一样的!每场实操考核试卷不允许一样!(想想很正常!如果有重复的会出现不公平的现象,这么正规的考试!怎么可能允许发生这样的事!)

也就是说实操试卷是准备好的,上传到服务器之后,抽出来就行了,注意初级实操卷要分配给初级实操考场,中级要·····

就是这个意思!

实操试卷分配完了要进行理论试卷的分配了!

求豆麻袋!理论试卷在哪里呢!

在这里插入图片描述
理论试卷需要电脑自动分配,也就是组卷,从题库中抽出100道题组成理论试卷!

还没完!我还能学!

头发:宁别学了!球球了!考虑我的感受!

这100道题是有讲究的,首先理论考核试卷有规范要求!

  • 要求1:理论试卷题数为100题!(不能多、不能少)
  • 要求2:初级理论试卷和中级理论试卷是单选、判断题,高级理论试卷有单选、多选、判断
  • 要求3:初中级判断题、单选题的比例是1:4,也就是判断20个,选择80个,高级判断题、单选题、多选题的比例是1:3:1,单选60个,判断20个,多选20个
  • 要求4:题的难度为简单、中等、较难,其中简单和较难的试题不超过20%
  • 要求5:根据理论知识考核要素表进行出题!(最恶心的是这)
  • 要求6:满分100分,100道题
    给你们看看理论要素表啥样
    初级知识考核要素表
序号名称工作领域编号技能要求分数占比题型(判断:选择)
1****参数设置1-1***能够熟练操作什么哈哈和好好好好5%1:4
1****参数设置1-2***能够熟练操作什么哈哈和好好好好10%2:8
1****参数设置1-3***能够熟练操作什么哈哈和好好好好15%3:12
2****参数设置2-1***能够熟练操作什么哈哈和好好好好5%1:4
2****参数设置2-2***能够熟练操作什么哈哈和好好好好5%1:4
2****参数设置2-3***能够熟练操作什么哈哈和好好好好10%2:8
2****参数设置2-4***能够熟练操作什么哈哈和好好好好10%2:8
3****参数设置3-1***能够熟练操作什么哈哈和好好好好5%1:4
3****参数设置3-2***能够熟练操作什么哈哈和好好好好5%1:4
3****参数设置3-3***能够熟练操作什么哈哈和好好好好5%1:4
3****参数设置3-4***能够熟练操作什么哈哈和好好好好15%3:12
4****参数设置4-1***能够熟练操作什么哈哈和好好好好10%2:8

这是初级的还有中级的,每个等级不一样,而且高级中还有多选

想要组卷必须满足上面的所有要求,才能组出来卷,复杂度很高!

所以想抽题组卷就不是从题库里随便抽出来100个题那么容易,而是有针对的进行抽题组卷,抽出100个!

一想到这!md 不做了!

在这里插入图片描述
但是我这个人,就喜欢挑战,越难越跃跃欲试!真没想到,我最后做出来了!

思路:

  • 1.算出初中高的培训学生人数
  • 2.用人数/机器数算出理论考场和实操考场
  • 3.创建考场,把学生分配进考场,随机分配机器
  • 4.根据实操考场数抽出实操试卷对应考场
  • 5.根据理论考场数算出应该创建多少理论试卷
  • 6.组卷
  • 7.抽出对应等级试卷,根据考核要求组卷
  • 8.试卷创建完毕后,随机分配理论考核试卷
  • 9.考核创建完毕

util(抽卷、组卷代码)

package com.BuoNuo.TianJinRoboticsAssociation.util;

import com.BuoNuo.TianJinRoboticsAssociation.pojo.TIPojo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.*;

/**
 * @author :lizhenyu
 * Created on 2020/4/27 18:34
 * Function abstract:
 */
@Mapper
@Repository
public class demo
{

    Random random = new Random();//默认构造方法

    public      Map<String,Object> chou(int xuanze, ArrayList<Integer> tiku, ArrayList<Integer> nand,ArrayList<Integer> xzda) {
        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
        ArrayList<Integer> nan = new ArrayList<Integer>(); //抽出的题对应难度
        ArrayList<Integer> chouda = new ArrayList<Integer>(); //抽出的题对应难度
        Map<String,Object> map=new HashMap<>();
        for (int i=0;i<xuanze;i++)
        {
            Random random = new Random();//默认构造方法
            int t=random.nextInt(tiku.size());
            nan.add(nand.get(t));
            chouchu.add(tiku.get(t));
            chouda.add(xzda.get(t));
            xzda.remove(t);
            nand.remove(t);
            tiku.remove(t);
        }
        map.put("chouti",chouchu);
        map.put("chounan",nan);
        map.put("chouda",chouda);
        return map;
    }
    //抽出选择题
    public      Map<String,Object> chouchuxuanze(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> four_one) {
        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
        ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
        Map<String,Object> map=new HashMap<>();
        Random random = new Random();//默认构造方法
        //抽出的1-1和2-1选择
        for (int i=0;i<20;i++)
        {
            //抽出3-2
            int one4 = random.nextInt(three_two.size());
            chouchu.add(three_two.get(one4).getId());
            chouda.add(three_two.get(one4).getAnswer());
            three_two.remove(one4);
            //抽出4道题
            if(i<4) {
                //抽出1-1
                int one1 = random.nextInt(one_one.size());
                chouchu.add(one_one.get(one1).getId());
                chouda.add(one_one.get(one1).getAnswer());
                one_one.remove(one1);
                //抽出2-1
                int one2 = random.nextInt(two_one.size());
                chouchu.add(two_one.get(one2).getId());
                chouda.add(two_one.get(one2).getAnswer());
                two_one.remove(one2);
                //抽出2-3
                int one3 = random.nextInt(two_three.size());
                chouchu.add(two_three.get(one3).getId());
                chouda.add(two_three.get(one3).getAnswer());
                two_three.remove(one3);
            }
            //抽出8道题
            if (i<8)
            {
                //抽出2-2
                int one6 = random.nextInt(two_two.size());
                chouchu.add(two_two.get(one6).getId());
                chouda.add(two_two.get(one6).getAnswer());
                two_two.remove(one6);
                //抽出3-3
                int one7 = random.nextInt(three_three.size());
                chouchu.add(three_three.get(one7).getId());
                chouda.add(three_three.get(one7).getAnswer());
                three_three.remove(one7);
                //抽出4-1
                int one8 = random.nextInt(four_one.size());
                chouchu.add(four_one.get(one8).getId());
                chouda.add(four_one.get(one8).getAnswer());
                four_one.remove(one8);
            }
            //抽出12道题
            if (i<12){
                //抽出1-2
                int one9 = random.nextInt(one_two.size());
                chouchu.add(one_two.get(one9).getId());
                chouda.add(one_two.get(one9).getAnswer());
                one_two.remove(one9);
                //抽出3-1
                int one0 = random.nextInt(three_one.size());
                chouchu.add(three_one.get(one0).getId());
                chouda.add(three_one.get(one0).getAnswer());
                three_one.remove(one0);
            }

        }
        map.put("chouti",chouchu);
        map.put("chouda",chouda);
        return map;
    }
    //抽出判断

    public      Map<String,Object> chouchupanduan(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> four_one) {
        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
        ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
        Map<String,Object> map=new HashMap<>();
        Random random = new Random();//默认构造方法
        //抽出的1-1和2-1选择
        for (int i=0;i<5;i++)
        {
            //抽出3-2
            int one4 = random.nextInt(three_two.size());
            chouchu.add(three_two.get(one4).getId());
            chouda.add(three_two.get(one4).getAnswer());
            three_two.remove(one4);
            //抽出4道题
            if(i<1) {
                //抽出1-1
                int one1 = random.nextInt(one_one.size());
                chouchu.add(one_one.get(one1).getId());
                chouda.add(one_one.get(one1).getAnswer());
                one_one.remove(one1);
                //抽出2-1
                int one2 = random.nextInt(two_one.size());
                chouchu.add(two_one.get(one2).getId());
                chouda.add(two_one.get(one2).getAnswer());
                two_one.remove(one2);
                //抽出2-3
                int one3 = random.nextInt(two_three.size());
                chouchu.add(two_three.get(one3).getId());
                chouda.add(two_three.get(one3).getAnswer());
                two_three.remove(one3);
            }
            //抽出8道题
            if (i<2)
            {
                //抽出2-2
                int one6 = random.nextInt(two_two.size());
                chouchu.add(two_two.get(one6).getId());
                chouda.add(two_two.get(one6).getAnswer());
                two_two.remove(one6);
                //抽出3-3
                int one7 = random.nextInt(three_three.size());
                chouchu.add(three_three.get(one7).getId());
                chouda.add(three_three.get(one7).getAnswer());
                three_three.remove(one7);
                //抽出4-1
                int one8 = random.nextInt(four_one.size());
                chouchu.add(four_one.get(one8).getId());
                chouda.add(four_one.get(one8).getAnswer());
                four_one.remove(one8);
            }
            //抽出12道题
            if (i<3){
                //抽出1-2
                int one9 = random.nextInt(one_two.size());
                chouchu.add(one_two.get(one9).getId());
                chouda.add(one_two.get(one9).getAnswer());
                one_two.remove(one9);
                //抽出3-1
                int one0 = random.nextInt(three_one.size());
                chouchu.add(three_one.get(one0).getId());
                chouda.add(three_one.get(one0).getAnswer());
                three_one.remove(one0);
            }

        }
        map.put("chouti",chouchu);
        map.put("chouda",chouda);
        return map;
    }
    //抽中及的选择题
    public      Map<String,Object> chouzhongxuanze(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> one_three, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> two_four, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> three_four, ArrayList<TIPojo> four_one) {
        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
        ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
        Map<String,Object> map=new HashMap<>();
        Random random = new Random();//默认构造方法
        //抽出的1-1和2-1选择
        for (int i=0;i<12;i++)
        {
            //抽出1--3
            int one1 = random.nextInt(one_three.size());
            chouchu.add(one_three.get(one1).getId());
            chouda.add(one_three.get(one1).getAnswer());
            one_three.remove(one1);
            //抽出3-4
            int oneb = random.nextInt(three_four.size());
            chouchu.add(three_four.get(oneb).getId());
            chouda.add(three_four.get(oneb).getAnswer());
            three_four.remove(oneb);
            //抽出4道题
            if(i<4) {
                //抽出1-1
                int one2 = random.nextInt(one_one.size());
                chouchu.add(one_one.get(one2).getId());
                chouda.add(one_one.get(one2).getAnswer());
                one_one.remove(one2);
                //抽出2-1
                int one3 = random.nextInt(two_one.size());
                chouchu.add(two_one.get(one3).getId());
                chouda.add(two_one.get(one3).getAnswer());
                two_one.remove(one3);
                //抽出2-2
                int one4 = random.nextInt(two_two.size());
                chouchu.add(two_two.get(one4).getId());
                chouda.add(two_two.get(one4).getAnswer());
                two_two.remove(one4);
                //抽出3-1
                int one5 = random.nextInt(three_one.size());
                chouchu.add(three_one.get(one5).getId());
                chouda.add(three_one.get(one5).getAnswer());
                three_one.remove(one5);
                //抽出3-2
                int one6 = random.nextInt(three_two.size());
                chouchu.add(three_two.get(one6).getId());
                chouda.add(three_two.get(one6).getAnswer());
                three_two.remove(one6);
                //抽出3-3
                int one7= random.nextInt(three_three.size());
                chouchu.add(three_three.get(one7).getId());
                chouda.add(three_three.get(one7).getAnswer());
                three_three.remove(one7);
            }
            //抽出8道题
            if (i<8)
            {
                //抽出1-2
                int one8 = random.nextInt(one_two.size());
                chouchu.add(one_two.get(one8).getId());
                chouda.add(one_two.get(one8).getAnswer());
                one_two.remove(one8);
                //抽出2-3
                int one9 = random.nextInt(two_three.size());
                chouchu.add(two_three.get(one9).getId());
                chouda.add(two_three.get(one9).getAnswer());
                two_three.remove(one9);
                //抽出2-4
                int one0 = random.nextInt(two_four.size());
                chouchu.add(two_four.get(one0).getId());
                chouda.add(two_four.get(one0).getAnswer());
                two_four.remove(one0);
                //抽出4-1
                int onea = random.nextInt(four_one.size());
                chouchu.add(four_one.get(onea).getId());
                chouda.add(four_one.get(onea).getAnswer());
                four_one.remove(onea);
            }
        }
        map.put("chouti",chouchu);
        map.put("chouda",chouda);
        return map;
    }
//抽出中级判断 chouzhongpanduan
public      Map<String,Object> chouzhongpanduan(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> one_three, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> two_four, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> three_four, ArrayList<TIPojo> four_one) {
    ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
    ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
    Map<String,Object> map=new HashMap<>();
    Random random = new Random();//默认构造方法
    //抽出的1-1和2-1选择
    for (int i=0;i<3;i++)
    {
        //抽出1--3
        int one1 = random.nextInt(one_three.size());
        chouchu.add(one_three.get(one1).getId());
        chouda.add(one_three.get(one1).getAnswer());
        one_three.remove(one1);
        //抽出3-4
        int oneb = random.nextInt(three_four.size());
        chouchu.add(three_four.get(oneb).getId());
        chouda.add(three_four.get(oneb).getAnswer());
        three_four.remove(oneb);

        //抽出4道题
        if(i<1) {
            //抽出1-1
            int one2 = random.nextInt(one_one.size());
            chouchu.add(one_one.get(one2).getId());
            chouda.add(one_one.get(one2).getAnswer());
            one_one.remove(one2);
            //抽出2-1
            int one3 = random.nextInt(two_one.size());
            chouchu.add(two_one.get(one3).getId());
            chouda.add(two_one.get(one3).getAnswer());
            two_one.remove(one3);
            //抽出2-2
            int one4 = random.nextInt(two_two.size());
            chouchu.add(two_two.get(one4).getId());
            chouda.add(two_two.get(one4).getAnswer());
            two_two.remove(one4);
            //抽出3-1
            int one5 = random.nextInt(three_one.size());
            chouchu.add(three_one.get(one5).getId());
            chouda.add(three_one.get(one5).getAnswer());
            three_one.remove(one5);
            //抽出3-2
            int one6 = random.nextInt(three_two.size());
            chouchu.add(three_two.get(one6).getId());
            chouda.add(three_two.get(one6).getAnswer());
            three_two.remove(one6);
            //抽出3-3
            int one7= random.nextInt(three_three.size());
            chouchu.add(three_three.get(one7).getId());
            chouda.add(three_three.get(one7).getAnswer());
            three_three.remove(one7);
        }
        //抽出8道题
        if (i<2)
        {
            //抽出1-2
            int one8 = random.nextInt(one_two.size());
            chouchu.add(one_two.get(one8).getId());
            chouda.add(one_two.get(one8).getAnswer());
            one_two.remove(one8);
            //抽出2-3
            int one9 = random.nextInt(two_three.size());
            chouchu.add(two_three.get(one9).getId());
            chouda.add(two_three.get(one9).getAnswer());
            two_three.remove(one9);
            //抽出2-4
            int one0 = random.nextInt(two_four.size());
            chouchu.add(two_four.get(one0).getId());
            chouda.add(two_four.get(one0).getAnswer());
            two_four.remove(one0);
            //抽出4-1
            int onea = random.nextInt(four_one.size());
            chouchu.add(four_one.get(onea).getId());
            chouda.add(four_one.get(onea).getAnswer());
            four_one.remove(onea);
        }
    }
    map.put("chouti",chouchu);
    map.put("chouda",chouda);
    return map;
}
//抽出的高级的选择题
    public      Map<String,Object> chougaoxuanze(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> two_four, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> four_one) {
        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
        ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
        Map<String,Object> map=new HashMap<>();
        Random random = new Random();//默认构造方法
        //抽出的1-1和2-1选择
        for (int i=0;i<15;i++)
        {
            //抽出2-3
            int one9 = random.nextInt(two_three.size());
            chouchu.add(two_three.get(one9).getId());
            chouda.add(two_three.get(one9).getAnswer());
            two_three.remove(one9);
            //抽出4道题
            if(i<3) {
                //抽出1-1
                int one2 = random.nextInt(one_one.size());
                chouchu.add(one_one.get(one2).getId());
                chouda.add(one_one.get(one2).getAnswer());
                one_one.remove(one2);
                //抽出2-1
                int one3 = random.nextInt(two_one.size());
                chouchu.add(two_one.get(one3).getId());
                chouda.add(two_one.get(one3).getAnswer());
                two_one.remove(one3);
                //抽出2-2
                int one4 = random.nextInt(two_two.size());
                chouchu.add(two_two.get(one4).getId());
                chouda.add(two_two.get(one4).getAnswer());
                two_two.remove(one4);
                //抽出3-1
                int one5 = random.nextInt(three_one.size());
                chouchu.add(three_one.get(one5).getId());
                chouda.add(three_one.get(one5).getAnswer());
                three_one.remove(one5);
            }
            //抽出8道题
            if (i<6)
            {
                //抽出1-2
                int one8 = random.nextInt(one_two.size());
                chouchu.add(one_two.get(one8).getId());
                chouda.add(one_two.get(one8).getAnswer());
                one_two.remove(one8);

                //抽出3-2
                int one6 = random.nextInt(three_two.size());
                chouchu.add(three_two.get(one6).getId());
                chouda.add(three_two.get(one6).getAnswer());
                three_two.remove(one6);
                //抽出2-4
                int one0 = random.nextInt(two_four.size());
                chouchu.add(two_four.get(one0).getId());
                chouda.add(two_four.get(one0).getAnswer());
                two_four.remove(one0);
                //抽出4-1
                int onea = random.nextInt(four_one.size());
                chouchu.add(four_one.get(onea).getId());
                chouda.add(four_one.get(onea).getAnswer());
                four_one.remove(onea);
            }
            if(i<9)
            {
                //抽出3-3
                int one7= random.nextInt(three_three.size());
                chouchu.add(three_three.get(one7).getId());
                chouda.add(three_three.get(one7).getAnswer());
                three_three.remove(one7);
            }
        }
        map.put("chouti",chouchu);
        map.put("chouda",chouda);
        return map;
    }
//抽出高级的判断
public      Map<String,Object> chougaopanduan(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> two_four, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> four_one) {
    ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
    ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
    Map<String,Object> map=new HashMap<>();
    Random random = new Random();//默认构造方法
    //抽出的1-1和2-1选择
    for (int i=0;i<5;i++)
    {
        //抽出2-3
        int one9 = random.nextInt(two_three.size());
        chouchu.add(two_three.get(one9).getId());
        chouda.add(two_three.get(one9).getAnswer());
        two_three.remove(one9);
        //抽出4道题
        if(i<1) {
            //抽出1-1
            int one2 = random.nextInt(one_one.size());
            chouchu.add(one_one.get(one2).getId());
            chouda.add(one_one.get(one2).getAnswer());
            one_one.remove(one2);
            //抽出2-1
            int one3 = random.nextInt(two_one.size());
            chouchu.add(two_one.get(one3).getId());
            chouda.add(two_one.get(one3).getAnswer());
            two_one.remove(one3);
            //抽出2-2
            int one4 = random.nextInt(two_two.size());
            chouchu.add(two_two.get(one4).getId());
            chouda.add(two_two.get(one4).getAnswer());
            two_two.remove(one4);
            //抽出3-1
            int one5 = random.nextInt(three_one.size());
            chouchu.add(three_one.get(one5).getId());
            chouda.add(three_one.get(one5).getAnswer());
            three_one.remove(one5);
        }
        //抽出8道题
        if (i<2)
        {
            //抽出1-2
            int one8 = random.nextInt(one_two.size());
            chouchu.add(one_two.get(one8).getId());
            chouda.add(one_two.get(one8).getAnswer());
            one_two.remove(one8);

            //抽出3-2
            int one6 = random.nextInt(three_two.size());
            chouchu.add(three_two.get(one6).getId());
            chouda.add(three_two.get(one6).getAnswer());
            three_two.remove(one6);
            //抽出2-4
            int one0 = random.nextInt(two_four.size());
            chouchu.add(two_four.get(one0).getId());
            chouda.add(two_four.get(one0).getAnswer());
            two_four.remove(one0);
            //抽出4-1
            int onea = random.nextInt(four_one.size());
            chouchu.add(four_one.get(onea).getId());
            chouda.add(four_one.get(onea).getAnswer());
            four_one.remove(onea);
        }
        if(i<3)
        {
            //抽出3-3
            int one7= random.nextInt(three_three.size());
            chouchu.add(three_three.get(one7).getId());
            chouda.add(three_three.get(one7).getAnswer());
            three_three.remove(one7);
        }
    }
    map.put("chouti",chouchu);
    map.put("chouda",chouda);
    return map;
}
    //抽出高级的多选
    //抽出高级的判断
    public      Map<String,Object>  chougaoduoxuan(ArrayList<TIPojo> one_one, ArrayList<TIPojo> one_two, ArrayList<TIPojo> two_one, ArrayList<TIPojo> two_two, ArrayList<TIPojo> two_three, ArrayList<TIPojo> two_four, ArrayList<TIPojo> three_one, ArrayList<TIPojo> three_two, ArrayList<TIPojo> three_three, ArrayList<TIPojo> four_one) {
        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
        ArrayList<String> chouda = new ArrayList<String>(); //抽出的题对应答案
        Map<String,Object> map=new HashMap<>();
        Random random = new Random();//默认构造方法
        //抽出的1-1和2-1选择
        for (int i=0;i<5;i++)
        {
            //抽出2-3
            int one9 = random.nextInt(two_three.size());
            chouchu.add(two_three.get(one9).getId());
            chouda.add(two_three.get(one9).getAnswer());
            two_three.remove(one9);
            //抽出4道题
            if(i<1) {
                //抽出1-1
                int one2 = random.nextInt(one_one.size());
                chouchu.add(one_one.get(one2).getId());
                chouda.add(one_one.get(one2).getAnswer());
                one_one.remove(one2);
                //抽出2-1
                int one3 = random.nextInt(two_one.size());
                chouchu.add(two_one.get(one3).getId());
                chouda.add(two_one.get(one3).getAnswer());
                two_one.remove(one3);
                //抽出2-2
                int one4 = random.nextInt(two_two.size());
                chouchu.add(two_two.get(one4).getId());
                chouda.add(two_two.get(one4).getAnswer());
                two_two.remove(one4);
                //抽出3-1
                int one5 = random.nextInt(three_one.size());
                chouchu.add(three_one.get(one5).getId());
                chouda.add(three_one.get(one5).getAnswer());
                three_one.remove(one5);
            }
            //抽出8道题
            if (i<2)
            {
                //抽出1-2
                int one8 = random.nextInt(one_two.size());
                chouchu.add(one_two.get(one8).getId());
                chouda.add(one_two.get(one8).getAnswer());
                one_two.remove(one8);

                //抽出3-2
                int one6 = random.nextInt(three_two.size());
                chouchu.add(three_two.get(one6).getId());
                chouda.add(three_two.get(one6).getAnswer());
                three_two.remove(one6);
                //抽出2-4
                int one0 = random.nextInt(two_four.size());
                chouchu.add(two_four.get(one0).getId());
                chouda.add(two_four.get(one0).getAnswer());
                two_four.remove(one0);
                //抽出4-1
                int onea = random.nextInt(four_one.size());
                chouchu.add(four_one.get(onea).getId());
                chouda.add(four_one.get(onea).getAnswer());
                four_one.remove(onea);
            }
            if(i<3)
            {
                //抽出3-3
                int one7= random.nextInt(three_three.size());
                chouchu.add(three_three.get(one7).getId());
                chouda.add(three_three.get(one7).getAnswer());
                three_three.remove(one7);
            }
        }
        map.put("chouti",chouchu);
        map.put("chouda",chouda);
        return map;
    }



    //抽出的卷子
    public      ArrayList<Integer>  choujuan(int number, ArrayList<Integer> shijuan) {
        ArrayList<Integer> choujuan = new ArrayList<Integer>(); //抽出的题
        for (int i=0;i<number;i++)
        {
            Random random = new Random();//默认构造方法
            int t=random.nextInt(shijuan.size());
            choujuan.add(shijuan.get(t));
            shijuan.remove(t);
        }
        return choujuan;
    }
//    public      Map<String,Object> huan(int xuanze, ArrayList<Integer> tiku, ArrayList<Integer> nand,ArrayList<Integer> xzda) {
//        ArrayList<Integer> chouchu = new ArrayList<Integer>(); //抽出的题
//        ArrayList<Integer> nan = new ArrayList<Integer>(); //抽出的题对应难度
//        ArrayList<Integer> chouda = new ArrayList<Integer>(); //抽出的题对应难度
//        Map<String,Object> map=new HashMap<>();
//        for (int i=0;i<xuanze;i++)
//        {
//            Random random = new Random();//默认构造方法
//            int t=random.nextInt(tiku.size());
//            nan.add(nand.get(t));
//            chouchu.add(tiku.get(t));
//            chouda.add(xzda.get(t));
//            xzda.remove(t);
//            nand.remove(t);
//            tiku.remove(t);
//        }
//        map.put("chouti",chouchu);
//        map.put("chounan",nan);
//        map.put("chouda",chouda);
//        return map;
//    }


    //难度
    public     double suannandu(ArrayList<Integer> DD) {
        float t=0;
        for (int i=0;i<DD.size();i++)
        {
           t=t+DD.get(i);
        }

        return t;
    }
}

service

 public int createShiJiKaoShi(ZY s) {
        //判断是否有符合条件参加考试的学生 如果没有直接返回
        if (kpMapper.stunumber()==0){

            return 0;//未有学生符合条件 参加考试
        }
        //哪期考试的uuid
        String ksuuid=randomUUID();
        kpMapper.createks(ksuuid);
        int jiqi=s.getId();//机器数
        int diannao=s.getLilunnumber();//电脑数
        //查询未分配考场的学生人数
        int chustuNo=kpMapper.cxChuStu();//初级
        int zhongstuNo=kpMapper.cxZhongStu();//中级
        int gaostuNo=kpMapper.cxGaoStu();//高级

        //算出实操初级考场数
        int chuKaoNo=chustuNo/jiqi;
        int chuyu=chustuNo%jiqi;
        //如果余数大于0考场数+1
        if (chuyu>0){
            chuKaoNo++;
        }
        //算出理论初级考场数
        int chudianNo=chustuNo/diannao;
        int chudianyu=chustuNo%diannao;
        if (chudianyu>0){
            chudianNo++;
        }
        //算出实操中级考场数
        int zhongKaoNo=zhongstuNo/jiqi;
        int zhongyu=zhongstuNo%jiqi;
        if (zhongyu>0){
            zhongKaoNo++;
        }
        //算出理论中级考场数
        int zhongdianNo=zhongstuNo/diannao;
        int zhongdianyu=zhongstuNo%diannao;
        if (zhongdianyu>0){
            zhongdianNo++;
        }

        //算出实操高级考场数
        int gaoKaoNo=gaostuNo/jiqi;
        int gaoyu=gaostuNo%jiqi;
        if (gaoyu>0){
            gaoKaoNo++;
        }
        //算出理论高级考场数
        int gaodianNo=gaostuNo/diannao;
        int gaoianyu=gaostuNo%diannao;
        if (gaoianyu>0){
            gaodianNo++;
        }
        //抽出对应初级场数的试卷
        ArrayList<Integer> chujuanid=kpMapper.chujuanid();//所有初级试卷的id
        ArrayList<Integer> zhongjuanid=kpMapper.zhongjuanid();//所有中级试卷的id
        ArrayList<Integer> gaojuanid=kpMapper.gaojuanid();//所有高级试卷的id
        ArrayList<Integer>   chouChuJuan = demos.choujuan(chuKaoNo, chujuanid);//抽初级卷
        ArrayList<Integer>   chouZongJuan = demos.choujuan(zhongKaoNo, zhongjuanid);//抽中级卷
        ArrayList<Integer>   chouGaoJuan = demos.choujuan(gaoKaoNo, gaojuanid);//抽高级卷

        //报名初级的学生id
        ArrayList<String> chuid=kpMapper.chuid();
        //循环初级考场添加试卷 分配学生  分配机器号 这是创建实操考场
        for (int t=0;t<chuKaoNo;t++)
        {
            String uuid=randomUUID();
            kpMapper.createKaoChang(chouChuJuan.get(t),uuid,2);
            System.out.println("我是初级实操第"+t+"场考试");
            for (int i=t*jiqi,f=1;i<(t+1)*jiqi;i++,f++){
                if (i==chuid.size()){
                    System.out.println("到此为止");
                   break;
                }
                //创建学生考场表
               kpMapper.createKCSTU(uuid,chuid.get(i),f,ksuuid);
            }
        }


        //循环中级考场添加试卷 分配学生  分配机器号 这是创建实操考场
        ArrayList<String> zhongid=kpMapper.zhongid();
        for (int t=0;t<zhongKaoNo;t++)
        {
            String uuid=randomUUID();
            kpMapper.createKaoChang(chouZongJuan.get(t),uuid,2);
            System.out.println("我是中级实操第"+t+"场考试");
            for (int i=t*jiqi,f=1;i<(t+1)*jiqi;i++,f++){
                if (i==zhongid.size()){
                    System.out.println("到此为止");
                    break;
                }
                //创建学生考场表
                kpMapper.createKCSTU(uuid,zhongid.get(i),f,ksuuid);
            }
        }

        //报名高级的学生id
        ArrayList<String> gaoid=kpMapper.gaoid();
        for (int t=0;t<gaoKaoNo;t++)
        {
            String uuid=randomUUID();
            kpMapper.createKaoChang(chouGaoJuan.get(t),uuid,2);
            System.out.println("我是高级实操第"+t+"场考试");
            for (int i=t*jiqi,f=1;i<(t+1)*jiqi;i++,f++){
                if (i==gaoid.size()){
                    System.out.println("到此为止");
                    break;
                }
                //创建学生考场表
                kpMapper.createKCSTU(uuid,gaoid.get(i),f,ksuuid);
            }
        }
        //初级单选
        ArrayList<TIPojo>  one_one=kpMapper.select1_1();//查询1-1的选择
        ArrayList<TIPojo>  one_two=kpMapper.select1_2();//查询1-2的选择
        ArrayList<TIPojo>  two_one=kpMapper.select2_1();//查询2-1的选择
        ArrayList<TIPojo>  two_two=kpMapper.select2_2();//查询2-2的选择
        ArrayList<TIPojo>  two_three=kpMapper.select2_3();//查询2-3的选择
        ArrayList<TIPojo>  three_one=kpMapper.select3_1();//查询3-1的选择
        ArrayList<TIPojo>  three_two=kpMapper.select3_2();//查询3-2的选择
        ArrayList<TIPojo>  three_three=kpMapper.select3_3();//查询3-3的选择
        ArrayList<TIPojo>  four_one=kpMapper.select4_1();//查询4-1的选择
        //初级判断
        //抽出=初级题判断
        ArrayList<TIPojo>  one_onep=kpMapper.select1_1p();//查询1-1的判断
        ArrayList<TIPojo>  one_twop=kpMapper.select1_2p();//查询1-2的判断
        ArrayList<TIPojo>  two_onep=kpMapper.select2_1p();//查询2-1的判断
        ArrayList<TIPojo>  two_twop=kpMapper.select2_2p();//查询2-2的判断
        ArrayList<TIPojo>  two_threep=kpMapper.select2_3p();//查询2-3的判断
        ArrayList<TIPojo>  three_onep=kpMapper.select3_1p();//查询3-1的判断
        ArrayList<TIPojo>  three_twop=kpMapper.select3_2p();//查询3-2的判断
        ArrayList<TIPojo>  three_threep=kpMapper.select3_3p();//查询3-3的判断
        ArrayList<TIPojo>  four_onep=kpMapper.select4_1p();//查询4-1的判断
        //循环初级考场 分配学生  分配座位号 这是创建理论考场
        for (int t=0;t<chudianNo;t++)
        {
            String uuid=randomUUID();
            // one_one,one_two,two_one,two_two,two_three,three_one,three_two,three_three,four_one,one_onep,one_twop,two_onep,two_twop,two_threep,three_onep,three_twop,three_threep,four_onep
            String  sid= chouchuti();//传递初级考场的参数  返回抽题的uuid
            kpMapper.createshijiKaoChang(sid,uuid,1);
            System.out.println("我是初级理论第"+t+"场考试");
            for (int i=t*diannao,f=1;i<(t+1)*diannao;i++,f++){
                if (i==chuid.size()){
                    System.out.println("到此为止");
                    break;
                }
                //修改学生考场表中学生的理论考场信息
                kpMapper.updateKCSTU(uuid,chuid.get(i),f,ksuuid);//机器号
            }
        }
        //循环中级理论考场添加试卷 分配学生  分配机器号 这是创建实操考场
        for (int t=0;t<zhongdianNo;t++)
        {
            String uuid=randomUUID();
            String  sid= chouzhongti();//传递中级考场的参数  返回抽题的uuid
            kpMapper.createshijiKaoChang(sid,uuid,1);
            System.out.println("我是中级理论第"+t+"场考试");
            for (int i=t*diannao,f=1;i<(t+1)*diannao;i++,f++){
                if (i==zhongid.size()){
                    System.out.println("到此为止");
                    break;
                }
                //修改学生考场表中学生的理论考场信息
                kpMapper.updateKCSTU(uuid,zhongid.get(i),f,ksuuid);//机器号
            }
        }
        //循环高级理论考场添加试卷 分配学生  分配机器号 这是创建实操考场
        for (int t=0;t<gaodianNo;t++)
        {
            String  sid=  chougaoti();//传递初级考场的参数  返回抽题的uuid
            String uuid=randomUUID();
            kpMapper.createshijiKaoChang(sid,uuid,1);
            System.out.println("我是高级理论第"+t+"场考试");
            for (int i=t*diannao,f=1;i<(t+1)*diannao;i++,f++){
                if (i==gaoid.size()){
                    System.out.println("到此为止");
                    break;
                }
                //修改学生考场表中学生的理论考场信息

                kpMapper.updateKCSTU(uuid,gaoid.get(i),f,ksuuid);//机器号
            }
        }
        //分配后更改学生--培训表状态为已分配
        kpMapper.upstuzt();
        return 1;
    }

真正有意义的代码就这么多!希望对你有帮助!主要看思路!有不会的可以找我啊!扩列扩列!

在这里插入图片描述

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值