private TracNghiemCollection TaoDanhSachCauTraLoi(TuVungCollection tuvunglambantest, TracNghiemCollection CauHoicoll) { int i = 0; while (i < CauHoicoll.Count) { int ques_pos = 1; while (ques_pos < 4) { //Chọn ngẫu nhiên 1 trả lời trong tuvunglambaitest int stt = RandomTuVung(tuvunglambantest.Count); TuVungBO temp = tuvunglambantest.Index(stt); //Kiểm tra câu trả lời đã có trong danh sách trả lời chưa //Nếu có rồi: Tạo lại -->Kiểm tra //Nếu chưa: Add vào --> i++ while (KiemTraTrungCauTraLoi(CauHoicoll.Index(i).Choices, temp, ques_pos) == true) { stt = RandomTuVung(tuvunglambantest.Count); temp = tuvunglambantest.Index(stt); } CauHoicoll.Index(i).Choices[ques_pos] = temp; ques_pos++; } i++; } return CauHoicoll; }
private TracNghiemCollection SapXepNgauNhien(TracNghiemCollection CauTraLoiColl) { TracNghiemCollection BaiTest = new TracNghiemCollection(); for (int i = 0; i < CauTraLoiColl.Count; i++) { int new_pos = -1; new_pos = RandomTuVung(4); if (i > 1) { while (new_pos == CauTraLoiColl.Index(i - 2).CauTraLoiDung) { new_pos = RandomTuVung(4); } } CauTraLoiColl.Index(i).CauTraLoiDung = new_pos; //Hóan vị câu trả lới đúng với câu trả lời bất kỳ TuVungBO oldtv = CauTraLoiColl.Index(i).Choices[0]; TuVungBO newtv = CauTraLoiColl.Index(i).Choices[new_pos]; CauTraLoiColl.Index(i).Choices[0] = newtv; CauTraLoiColl.Index(i).Choices[new_pos] = oldtv; } BaiTest = CauTraLoiColl; return BaiTest; }