Beispiel #1
0
        public void tronDapAn(CauHoi c)
        {
            int indexDA = 0;

            switch (c.DapAn)
            {
            case "A":
                indexDA = 0;
                break;

            case "B":
                indexDA = 1;
                break;

            case "C":
                indexDA = 2;
                break;

            case "D":
                indexDA = 3;
                break;
            }

            List <int> randLuaChon = new List <int>();

            RandomNumber(randLuaChon);


            string[] chTam = new string[4];
            chTam[0] = c.A;
            chTam[1] = c.B;
            chTam[2] = c.C;
            chTam[3] = c.D;

            c.A = chTam[randLuaChon[0]];
            c.B = chTam[randLuaChon[1]];
            c.C = chTam[randLuaChon[2]];
            c.D = chTam[randLuaChon[3]];

            switch (randLuaChon.IndexOf(indexDA))
            {
            case 0:
                c.DapAn = "A";
                break;

            case 1:
                c.DapAn = "B";
                break;

            case 2:
                c.DapAn = "C";
                break;

            case 3:
                c.DapAn = "D";
                break;
            }
            randLuaChon.Clear();
        }
Beispiel #2
0
        public CauHoi LayCauHoiTuBDS(int vitri)
        {
            CauHoi c = new CauHoi();

            c.IDCauHoi = ((DataRowView)bdsDethi[vitri])["CAUHOI"].ToString().Trim();
            c.MaMH     = ((DataRowView)bdsDethi[vitri])["MAMH"].ToString().Trim();
            c.MaGV     = ((DataRowView)bdsDethi[vitri])["MAGV"].ToString().Trim();
            c.TrinhDo  = ((DataRowView)bdsDethi[vitri])["TRINHDO"].ToString().Trim();
            c.NoiDUng  = ((DataRowView)bdsDethi[vitri])["NOIDUNG"].ToString().Trim();
            c.A        = ((DataRowView)bdsDethi[vitri])["A"].ToString().Trim();
            c.B        = ((DataRowView)bdsDethi[vitri])["B"].ToString().Trim();
            c.C        = ((DataRowView)bdsDethi[vitri])["C"].ToString().Trim();
            c.D        = ((DataRowView)bdsDethi[vitri])["D"].ToString().Trim();
            c.DapAn    = ((DataRowView)bdsDethi[vitri])["DAP_AN"].ToString().Trim();
            c.DaChon   = "X";

            tronDapAn(c);
            return(c);
        }