Ejemplo n.º 1
0
 public CCauTracNghiem(CCauTracNghiem cauHoi)
 {
     this.NoiDungCauHoi = cauHoi.NoiDungCauHoi;
     this.DapAnA        = cauHoi.DapAnA;
     this.DapAnB        = cauHoi.DapAnB;
     this.DapAnC        = cauHoi.DapAnC;
     this.DapAnD        = cauHoi.DapAnD;
     this.DapAnDung     = cauHoi.DapAnDung;
     this.CauTraLoi     = cauHoi.CauTraLoi;
 }
Ejemplo n.º 2
0
        private void LoadDeThi()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "Chon tap tin .xml|*.xml";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                arrCauHoi.Clear();
                string filePath = dlg.FileName;
                txtDuongDan.Text = filePath;
                XmlDocument doc = new XmlDocument();
                doc.Load(filePath);
                XmlElement  root       = doc.DocumentElement;
                XmlNodeList rootCauHoi = root.ChildNodes;
                for (int i = 0; i < rootCauHoi.Count; i++)
                {
                    CCauTracNghiem CauTracNghiem     = new CCauTracNghiem();
                    XmlNode        nodeNoiDungCauHoi = rootCauHoi[i].SelectSingleNode("NoiDung");
                    CauTracNghiem.NoiDungCauHoi = nodeNoiDungCauHoi.InnerText.ToString();
                    XmlNode nodeDapAnA = rootCauHoi[i].SelectSingleNode("DapAnA");
                    CauTracNghiem.DapAnA = nodeDapAnA.InnerText.ToString();
                    XmlNode nodeDapAnB = rootCauHoi[i].SelectSingleNode("DapAnB");
                    CauTracNghiem.DapAnB = nodeDapAnB.InnerText;
                    XmlNode nodeDapAnC = rootCauHoi[i].SelectSingleNode("DapAnC");
                    CauTracNghiem.DapAnC = nodeDapAnC.InnerText;
                    XmlNode nodeDapAnD = rootCauHoi[i].SelectSingleNode("DapAnD");
                    CauTracNghiem.DapAnD = nodeDapAnD.InnerText;
                    XmlNode nodeDapAnDung = rootCauHoi[i].SelectSingleNode("DapAnDung");
                    CauTracNghiem.DapAnDung = int.Parse(nodeDapAnDung.InnerText);
                    //them cau hoi vao list
                    arrCauHoi.Add(CauTracNghiem);
                }
                DialogResult r = MessageBox.Show("Đề thi được nạp thành công. Nhấn [Bắt đầu thi] để làm bài", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (r == DialogResult.OK)
                {
                    btnduongDan.Enabled = false;
                    btnBatDau.Enabled   = true;
                    tongThoiGianThi     = arrCauHoi.Count * 15;
                    thoiGianThi         = new DateTime(2000, 1, 1, 0, tongThoiGianThi / 60, tongThoiGianThi % 60, 0);
                    lbThoiGian.Text     = thoiGianThi.Minute.ToString() + " : " + thoiGianThi.Second.ToString();
                }
            }
            else
            {
                DialogResult r = MessageBox.Show("Đề thi chưa được nạp. Bạn không thể bắt đầu bài thi.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (r == DialogResult.OK)
                {
                    btnduongDan.Enabled = true;
                    btnBatDau.Enabled   = false;
                }
            }
        }