Example #1
0
        public void KiemTraKQPhanLoaiTuTest1()
        {
            string strDapAnNguoiDung = string.Empty;

            string [] strCacDapAn = new string[0];

            LuyenTuVaCauBUS.KiemTraKQPhanLoaiTu(strDapAnNguoiDung, strCacDapAn);
        }
Example #2
0
        public void KiemTraKQPhanLoaiTuTest2()
        {
            string strDapAnNguoiDung = "abc";

            string[] strCacDapAn = new string[0];
            int      intKetQua   = LuyenTuVaCauBUS.KiemTraKQPhanLoaiTu(strDapAnNguoiDung, strCacDapAn);

            Assert.That(intKetQua, Is.EqualTo(-1));
        }
Example #3
0
        public void KiemTraKQPhanLoaiTuTest6()
        {
            string strDapAnNguoiDung = "abc";

            string [] strCacDapAn = { "123", "456", "abc" };

            int intKetQua = LuyenTuVaCauBUS.KiemTraKQPhanLoaiTu(strDapAnNguoiDung, strCacDapAn);

            Assert.That(intKetQua, Is.EqualTo(2));
        }
Example #4
0
        public void XemKetQua()
        {
            if (TinhTrangLamBai == TinhTrang.XemDapAn)
            {
                int i = DanhSachTu.Count - 1;
                int k = 0;

                int intSoDapAnDung = 0;
                int intTongSoDapAn = 0;

                if ((this.LoaiBai & (byte)LoaiBaiTap.PhanLoaiTu) != 0)
                {
                    int intKhoangTrongHienTai = strDapAnTungCau.Length - 1;

                    while (intKhoangTrongHienTai >= 0)
                    {
                        string[] strTungDapAn = strDapAnTungCau[intKhoangTrongHienTai].Split('|');
                        bool[]   arrFlag      = new bool[strTungDapAn.Length];
                        for (k = 0; k < strTungDapAn.Length; k++)
                        {
                            arrFlag[k] = false;
                        }

                        intTongSoDapAn += strTungDapAn.Length;

                        // Lưu lại font cũ
                        this.SelectionStart  = 0;
                        this.SelectionLength = 1;
                        Font fntFontCu = this.SelectionFont;

                        for (k = 0; k < DanhSachTu.Count; k++)
                        {
                            if (DanhSachTu[k].TenLoaiTu == "NhomTuLTVC")
                            {
                                if (DanhSachTu[k].ViTri >= DanhSachTu[i].ViTri &&
                                    DanhSachTu[k].ViTri <= (DanhSachTu[i].ViTri + ((KhoangTrongLTVC)DanhSachTu[i]).ViTriDuLieu))
                                {
                                    this.SelectionStart  = DanhSachTu[k].ViTri;
                                    this.SelectionLength = DanhSachTu[k].NoiDung.Length;
                                    this.SelectionFont   = new Font(fntFontCu, FontStyle.Italic);
                                    Font fntStrikeoutFont = new Font(fntFontCu, FontStyle.Strikeout);

                                    int intViTriDapAn = LuyenTuVaCauBUS.KiemTraKQPhanLoaiTu(DanhSachTu[k].NoiDung, strTungDapAn);
                                    if (intViTriDapAn != -1)
                                    {
                                        intSoDapAnDung++;
                                        this.SelectionColor    = Color.Blue;
                                        arrFlag[intViTriDapAn] = true;
                                    }
                                    else
                                    {
                                        this.SelectionColor = Color.Red;
                                        this.SelectionFont  = fntStrikeoutFont;
                                    }
                                }
                            }
                        }

                        // Hiện ra những đáp án còn thiếu
                        string strCacDapAnConThieu = string.Empty;
                        for (k = 0; k < strTungDapAn.Length; k++)
                        {
                            if (arrFlag[k] == false)
                            {
                                strCacDapAnConThieu += (strTungDapAn[k] + ", ");
                            }
                        }
                        this.SelectionStart  = DanhSachTu[i].ViTri + ((KhoangTrongLTVC)DanhSachTu[i]).ViTriDuLieu;
                        this.SelectionLength = strCacDapAnConThieu.Length;
                        this.SelectionFont   = fntFontCu;
                        this.SelectedText    = strCacDapAnConThieu;

                        intKhoangTrongHienTai--;
                        i--;
                    }
                    this.SelectionStart = this.Text.Length;
                    string strKetQua = "\nTỉ lệ đúng: " + intSoDapAnDung.ToString()
                                       + "/" + intTongSoDapAn.ToString();
                    this.SelectionLength = strKetQua.Length;
                    this.SelectionFont   = new Font("Arrial", 14, FontStyle.Bold | FontStyle.Italic);
                    float fltTiLeDung = (float)intSoDapAnDung / intTongSoDapAn;
                    if (fltTiLeDung > 0.5)
                    {
                        this.SelectionColor = Color.DarkGreen;
                    }
                    else
                    {
                        this.SelectionColor = Color.Red;
                    }
                    this.SelectedText = strKetQua;
                }
            }
        }