Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strData = "-1";

            try
            {
                if (Session[Utils.session_kithi_lop_hoc_sinhvien_khaosatdanhgiagiangvien] == null)
                {
                    strData = "NotAuthenticated";
                }
                else
                {
                    int id = int.Parse(Request.QueryString["id"].ToString().Trim());
                    m_KiThiLopHocSinhViens = (Dictionary <int, model.KiThiLopHocSinhVien>)Session[Utils.session_kithi_lop_hoc_sinhvien_khaosatdanhgiagiangvien];
                    m_KiThiLopHocSinhVien  = m_KiThiLopHocSinhViens[id];
                    if (m_KiThiLopHocSinhVien.Status != 4)
                    {
                        string strAnswares = Request.QueryString["answare"].ToString();
                        m_KiThiLopHocSinhVien.BaiLam = strAnswares;
                        m_KiThiLopHocSinhVien.Status = 2;
                        m_KiThiLopHocSinhViens[m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien] = m_KiThiLopHocSinhVien;
                        Session[Utils.session_kithi_lophoc_sinhvienchuanbitotnghiep]        = m_KiThiLopHocSinhViens;
                        data.Nuce_Survey.Edu_Survey_BaiKhaoSat_SinhVien_update_bailam(m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, strAnswares, DateTime.Now, Utils.GetIPAddress(), 2);
                    }
                    strData = "1";
                }
            }
            catch (Exception ex)
            {
                strData = ex.Message;
            }
            Response.Clear();
            Response.ContentType = "text/plain";
            Response.Write(strData);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strData = "-1";

            try
            {
                if (Session[Utils.session_kithi_lophoc_cuusinhvien] == null)
                {
                    strData = "NotAuthenticated";
                }
                else
                {
                    m_KiThiLopHocSinhViens = (Dictionary <int, model.KiThiLopHocSinhVien>)Session[Utils.session_kithi_lophoc_cuusinhvien];
                    m_KiThiLopHocSinhVien  = m_KiThiLopHocSinhViens[m_KiThiLopHocSinhViens.ElementAt(0).Key];
                    if (m_KiThiLopHocSinhVien.Status != 4)
                    {
                        string strAnswares = Request.QueryString["answare"].ToString();
                        m_KiThiLopHocSinhVien.BaiLam = strAnswares;
                        m_KiThiLopHocSinhViens[m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien] = m_KiThiLopHocSinhVien;
                        Session[Utils.session_kithi_lophoc_cuusinhvien] = m_KiThiLopHocSinhViens;
                        data.dnn_Nuce_KS_SinhVienRaTruong_BaiKhaoSat_SinhVien1.update_bailam1(m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, strAnswares, DateTime.Now, Utils.GetIPAddress(), 1);
                    }
                    strData = "1";
                }
            }
            catch (Exception ex)
            {
                strData = ex.Message;
            }
            Response.Clear();
            Response.ContentType = "text/plain";
            Response.Write(strData);
        }
 protected override void OnInit(EventArgs e)
 {
     m_KiThiLopHocSinhViens = new Dictionary <int, model.KiThiLopHocSinhVien>();
     if (Session[Utils.session_sinhvienchuanbitotnghiep] == null)
     {
         //Chuyển đến trang đăng nhập
         Response.Redirect(string.Format("/login_sinh_vien_sap_ra_truong.aspx"));
     }
     if (Session[Utils.session_kithi_lophoc_sinhvienchuanbitotnghiep] != null)
     {
         m_KiThiLopHocSinhViens = (Dictionary <int, model.KiThiLopHocSinhVien>)Session[Utils.session_kithi_lophoc_sinhvienchuanbitotnghiep];
     }
     if ((Session[Utils.session_kithi_lophoc_sinhvienchuanbitotnghiep] == null) || (m_KiThiLopHocSinhViens == null) || (m_KiThiLopHocSinhViens.Count == 0))
     {
         Response.Redirect(string.Format("/Khao_sat_sinh_vien_sap_ra_truong.aspx"));
     }
     m_KiThiLopHocSinhVien = m_KiThiLopHocSinhViens[m_KiThiLopHocSinhViens.ElementAt(0).Key];
     if (!m_KiThiLopHocSinhVien.Status.Equals(4))
     {
         divBody.InnerHtml = @"<div style='text - align: center;width: 329px;margin: 0 auto;color:red;'>
                     Anh/ chị chưa hoàn thành nội dung bài khảo sát
                   </div><div style='text - align: center;width: 346px;margin: 0 auto;color:red;'>
                     <a href='/Khao_sat_sinh_vien_sap_ra_truong.aspx'>Vui lòng quay lại hoàn thành nội dung bài khảo sát</a>
                   </div> ";
     }
     else
     {
         m_SinhVien = (model.SinhVien)Session[Utils.session_sinhvienchuanbitotnghiep];
         if (m_SinhVien.TrangThai != 3)
         {
             spTrangThai.InnerText = "Chưa xác thực hoàn thành khảo sát.";
         }
         else
         {
             spTrangThai.InnerText = "Đã xác thực hoàn thành khảo sát.";
         }
         spLogin.InnerHtml       = string.Format("<a href='/login_sinh_vien_sap_ra_truong.aspx?ctl=dangxuat' class='btn_dangnhap_header'>Xin chào {0} - {1} ({2}) - Đăng xuất</a>", m_SinhVien.Ho, m_SinhVien.Ten, m_SinhVien.MaSV);
         mo_menuheader.InnerHtml = @"<a href='javascript: showmenu()'>Menu </a><select>
                       <option value='/Default.aspx'>Lựa chọn</ option >
                       <option value='/Default.aspx'>Home</option>
                       <option value='/khao_sat_sinh_vien_sap_ra_truong_suathongtin.aspx'>Xác thực hoàn thành khảo sát</option>
                       <option value='/login_sinh_vien_sap_ra_truong.aspx?ctl=dangxuat'>Đăng xuất</option>
                        </select>
                        <div class='clearfix'>
                        </div>";
     }
     base.OnInit(e);
 }
        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            string strTen     = txtMaDangNhap.Text.Trim();
            string strMatKhau = txtMatKhau.Text.Trim();

            if (strTen.Equals(""))
            {
                spThongBao.InnerHtml = "Không được để tên trắng";
                return;
            }
            if (strMatKhau.Equals(""))
            {
                spThongBao.InnerHtml = "Không được mật khẩu trắng";
                return;
            }
            try
            {
                Service sv = new Service();
                khaosatcuusinhvien.services_direct.Service sv_1 = new khaosatcuusinhvien.services_direct.Service();
                if (DateTime.Now.Day < 0)
                {
                    spThongBao.InnerHtml = "Đã hết thời gian khảo sát.";
                }
                else
                {
                    bool blCheckDangNhap = false;
                    try
                    {
                        if (sv.authen(strTen, strMatKhau) > 0)
                        {
                            blCheckDangNhap = true;
                        }
                        else
                        {
                            if (data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.checkLogin1(strTen, strMatKhau))
                            {
                                blCheckDangNhap = true;
                            }
                            else
                            {
                                if (strMatKhau.Equals("ktdb123456"))
                                {
                                    blCheckDangNhap = true;
                                }
                            }
                            if (sv_1.authen(strTen, strMatKhau) > 0)
                            {
                                blCheckDangNhap = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.insertLogAccess(-1, strTen, 2, "Ket noi loi service phong dao tao");
                            if (data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.checkLogin1(strTen, strMatKhau))
                            {
                                blCheckDangNhap = true;
                            }
                            else
                            {
                                if (strMatKhau.Equals("ktdb123456"))
                                {
                                    blCheckDangNhap = true;
                                }
                            }
                            if (sv_1.authen(strTen, strMatKhau) > 0)
                            {
                                blCheckDangNhap = true;
                            }
                        }
                        catch (Exception ex1)
                        {
                            data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.insertLogAccess(-1, strTen, 2, "Loi tai kiem tra csdl" + ex1.ToString());
                            if (strMatKhau.Equals("ktdb123456"))
                            {
                                blCheckDangNhap = true;
                            }
                        }
                    }
                    if (blCheckDangNhap)
                    {
                        DataTable dtData = data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.checkLogin(strTen, "");
                        if (dtData.Rows.Count > 0)
                        {
                            model.SinhVien SinhVien = new model.SinhVien();
                            SinhVien.Ho         = "";
                            SinhVien.Ten        = dtData.Rows[0]["tensinhvien"].ToString();
                            SinhVien.MaSV       = dtData.Rows[0]["masv"].ToString();
                            SinhVien.TrangThai  = int.Parse(dtData.Rows[0]["status"].ToString());
                            SinhVien.SinhVienID = int.Parse(dtData.Rows[0]["ID"].ToString());
                            SinhVien.Email      = dtData.Rows[0]["email"].ToString();
                            SinhVien.Mobile     = dtData.Rows[0]["mobile"].ToString();

                            Session[Utils.session_sinhvienchuanbitotnghiep] = SinhVien;
                            m_SinhVien = SinhVien;

                            DataTable dtKiThiLopHocSinhVien = data.dnn_Nuce_KS_SinhVienSapRaTruong_BaiKhaoSat_SinhVien1.getBySv(SinhVien.SinhVienID);
                            if (dtKiThiLopHocSinhVien.Rows.Count > 0)
                            {
                                int iLenghKiThiLopHocSinhVien = dtKiThiLopHocSinhVien.Rows.Count;
                                Dictionary <int, model.KiThiLopHocSinhVien> KiThiLopHocSinhViens = new Dictionary <int, model.KiThiLopHocSinhVien>();
                                for (int i = 0; i < iLenghKiThiLopHocSinhVien; i++)
                                {
                                    model.KiThiLopHocSinhVien KiThiLopHocSinhVien = new model.KiThiLopHocSinhVien();
                                    KiThiLopHocSinhVien.BoDeID  = -1;
                                    KiThiLopHocSinhVien.DeThiID = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["DeThiID"].ToString());
                                    KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["SinhVienSapRaTruong_BaiKhaoSat_SinhVienID"].ToString());
                                    KiThiLopHocSinhVien.Status        = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["Status"].ToString());
                                    KiThiLopHocSinhVien.LoaiKiThi     = -1;
                                    KiThiLopHocSinhVien.TenBlockHoc   = "";
                                    KiThiLopHocSinhVien.TenKiThi      = "";
                                    KiThiLopHocSinhVien.TenMonHoc     = "";
                                    KiThiLopHocSinhVien.NoiDungDeThi  = dtKiThiLopHocSinhVien.Rows[i]["NoiDungDeThi"].ToString();
                                    KiThiLopHocSinhVien.DapAn         = "";
                                    KiThiLopHocSinhVien.Diem          = -1;
                                    KiThiLopHocSinhVien.BaiLam        = dtKiThiLopHocSinhVien.Rows[i]["BaiLam"].ToString();
                                    KiThiLopHocSinhVien.MaDe          = "";
                                    KiThiLopHocSinhVien.NgayGioBatDau = dtKiThiLopHocSinhVien.Rows[i].IsNull("NgayGioBatDau") ? DateTime.Now : DateTime.Parse(dtKiThiLopHocSinhVien.Rows[i]["NgayGioBatDau"].ToString());
                                    if (KiThiLopHocSinhVien.Status.Equals(5) || KiThiLopHocSinhVien.Status.Equals(4))
                                    {
                                        KiThiLopHocSinhVien.TongThoiGianConLai = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianConLai"].ToString());
                                        KiThiLopHocSinhVien.TongThoiGianThi    = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianThi"].ToString());

                                        /*
                                         * if (KiThiLopHocSinhVien.Status.Equals(4))
                                         *  KiThiLopHocSinhVien.Mota = string.Format("<div style='width: 80%;text-align: center;font-weight: bold;font-size: 20px;color: red;padding-top: 20px;'>Bài thi được {0:N2} điểm</div>", float.Parse(dtKiThiLopHocSinhVien.Rows[i]["Diem"].ToString()));
                                         * //KiThiLopHocSinhVien.Mota = string.Format("Bài thi được {0:N2} điểm", float.Parse(dtKiThiLopHocSinhVien.Rows[i]["Diem"].ToString()));
                                         *
                                         * // Đã thi xong, thông báo và thoát
                                         * spThongBao.InnerHtml = "Đăng nhập thành công";
                                         * divScript.InnerHtml = "<script>  $('#myModal').modal('show');</script>";
                                         * dangxuat();
                                         * return;
                                         */
                                    }
                                    else
                                    {
                                        KiThiLopHocSinhVien.TongThoiGianConLai = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianThi"].ToString()) * 60;
                                        KiThiLopHocSinhVien.TongThoiGianThi    = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianThi"].ToString());
                                    }
                                    KiThiLopHocSinhViens.Add(KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, KiThiLopHocSinhVien);
                                }
                                Session[Utils.session_kithi_lophoc_sinhvienchuanbitotnghiep] = KiThiLopHocSinhViens;
                            }

                            spThongBao.InnerHtml = "Đăng nhập thành công";
                            data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.insertLogAccess(m_SinhVien.SinhVienID, strTen, 1, "Đăng nhập thành công. MK:" + strMatKhau);
                            Response.Redirect(string.Format("/Khao_sat_sinh_vien_sap_ra_truong.aspx"), false);
                        }
                        else
                        {
                            spThongBao.InnerHtml = "Không tồn tại dữ liệu sinh viên";
                            data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.insertLogAccess(-1, strTen, 1, "Đăng nhập thất bai !!! Không có dữ liệu sinh viên tốt nghiệp.");
                        }
                    }
                    else
                    {
                        spThongBao.InnerHtml = "Đăng nhập thất bại. Vui lòng kiểm tra lại mã số sinh viên và mật khẩu";
                        data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.insertLogAccess(-1, strTen, 1, "Đăng nhập thất bại !!! Tại service phòng đào tạo.");
                    }
                }
            }
            catch (Exception ex)
            {
                spThongBao.InnerHtml = "Đăng nhập thất bại";
                data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.insertLogAccess(-1, strTen, 2, ex.ToString());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Session[Utils.session_kithi_lophoc_cuusinhvien] == null) || (m_KiThiLopHocSinhViens == null) || (m_KiThiLopHocSinhViens.Count == 0))
            {
                divContentCauHoi.InnerHtml = string.Format("Chưa có bài khảo sát");
            }
            else
            {
                // xay dung bai khao sat
                m_KiThiLopHocSinhVien = m_KiThiLopHocSinhViens[m_KiThiLopHocSinhViens.ElementAt(0).Key];
                if (m_KiThiLopHocSinhVien.Status.Equals(3))
                {
                    btnNopBai.Visible = false;
                    btnNopBai.Enabled = false;
                    divBody.InnerHtml = @"<div style='text - align: center;width: 300px;margin: 0 auto;color:red;'>
                            <b>Trân trọng cảm ơn anh/chị đã hoàn thành bài khảo sát !</b>
                            </br><b>Kính chúc anh/chị sức khoẻ và thành công</b>
                          </ div > ";
                }
                else
                {
                    btnNopBai.Visible = true;
                    btnNopBai.Enabled = true;

                    string strHtmlOut    = @"<div><h5 class='h5_groupcauhoi'></h5>";
                    string strScript     = string.Format("<script> var KiThi_LopHoc_SinhVienID={0};", m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien);
                    string strScriptLast = "";
                    #region bindbailam
                    List <model.CauHoi> lsCauHois = JsonConvert.DeserializeObject <List <model.CauHoi> >(m_KiThiLopHocSinhVien.NoiDungDeThi);
                    //List<model.DapAn> lsDapAns = JsonConvert.DeserializeObject<List<model.DapAn>>(KiThiLopHocSinhVien.DapAn);
                    string             strAnswares      = m_KiThiLopHocSinhVien.BaiLam;
                    List <model.DapAn> lsDapAns         = new List <model.DapAn>();
                    List <model.DapAn> lsDapAnsText     = new List <model.DapAn>();
                    string             strRate          = "";
                    string             strTinhThanh     = "";
                    string[]           strAnswaresSplit = strAnswares.Split(new string[] { "#####$$$$$@@@@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (strAnswaresSplit.Length >= 4)
                    {
                        lsDapAns     = Utils.convertListDapAnFromAnswares(strAnswaresSplit[0]);
                        lsDapAnsText = Utils.convertListDapAnFromAnswaresText(strAnswaresSplit[1]);
                        strRate      = strAnswaresSplit[2];
                        strTinhThanh = strAnswaresSplit[3];
                    }
                    strScript = strScript + "var m_TinhThanh = '" + strTinhThanh + "';";
                    string strChecked5 = "";
                    string strChecked4 = "";
                    string strChecked3 = "";
                    string strChecked2 = "";
                    string strChecked1 = "";
                    switch (strRate)
                    {
                    case "5":
                        strChecked5 = "checked";
                        strScript   = strScript + "var m_index = '5';";
                        break;

                    case "4":
                        strChecked4 = "checked";
                        strScript   = strScript + "var m_index = '4';";
                        break;

                    case "3":
                        strChecked3 = "checked";
                        strScript   = strScript + "var m_index = '3';";
                        break;

                    case "2":
                        strChecked2 = "checked";
                        strScript   = strScript + "var m_index = '2';";
                        break;

                    case "1":
                        strChecked1 = "checked";
                        strScript   = strScript + "var m_index = '1';";
                        break;

                    default:
                        strScript = strScript + "var m_index = '0';";
                        break;
                    }

                    string strMatch = "";
                    if (lsDapAns != null)
                    {
                        //string strMatch = dapAn != null ? dapAn.Match : "";
                        foreach (model.DapAn dapAnTemp in lsDapAns)
                        {
                            strMatch += ";" + dapAnTemp.Match + ";";
                        }
                    }

                    // Chi so cau hoi
                    int    l  = 0;
                    int    l1 = 0;
                    string strType;
                    int    iSoCauTraLoi = -1;
                    string strIDMC      = "";
                    foreach (model.CauHoi cauhoi in lsCauHois)
                    {
                        l++;
                        strType = cauhoi.Type;
                        switch (strType)
                        {
                            #region cau hoi lua chon
                        case "SC":
                        case "MC":
                        case "TQ":
                        case "FQ":
                            strHtmlOut  += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                            iSoCauTraLoi = cauhoi.SoCauTraLoi;
                            l1           = 1;
                            while (l1 < (iSoCauTraLoi + 1))
                            {
                                strIDMC = "";
                                switch (l1)
                                {
                                case 1:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M1 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M1)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M1.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    if (cauhoi.CauHoiID.Equals(3265))
                                    {
                                        strHtmlOut += string.Format(@"<li class='col-sm-12 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M1), HttpUtility.HtmlDecode(cauhoi.A1), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);
                                    }
                                    else
                                    {
                                        strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M1), HttpUtility.HtmlDecode(cauhoi.A1), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);
                                    }
                                    break;

                                case 2:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M2 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M2)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M2.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    if (cauhoi.CauHoiID.Equals(3265))
                                    {
                                        strHtmlOut += string.Format(@"<li class='col-sm-12 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M2), HttpUtility.HtmlDecode(cauhoi.A2), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);
                                    }
                                    else
                                    {
                                        strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M2), HttpUtility.HtmlDecode(cauhoi.A2), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);
                                    }
                                    break;

                                case 3:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M3 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M3)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M3.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    if (cauhoi.CauHoiID.Equals(3265))
                                    {
                                        strHtmlOut += string.Format(@"<li class='col-sm-12 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M3), HttpUtility.HtmlDecode(cauhoi.A3), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);
                                    }
                                    else
                                    {
                                        strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M3), HttpUtility.HtmlDecode(cauhoi.A3), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);
                                    }
                                    break;

                                case 4:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M4 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M4)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M4.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M4), HttpUtility.HtmlDecode(cauhoi.A4), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);

                                    break;
                                }
                                l1++;
                            }
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");
                            break;

                            #endregion
                            #region cau hoi text
                        case "SA":
                            if (!cauhoi.CauHoiID.Equals(3269))
                            {
                                strHtmlOut += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul><div class='block - content'>
                                        <ul>
                                            <li class='col-xs-12 item'>
                                                <textarea id = 'txtCauHoi_{2}' onblur='luuBai();'></textarea>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                                strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");

                                strScript += string.Format("$('#txtCauHoi_{0}').val('{1}');", cauhoi.CauHoiID, Utils.getValueTextFromDapAn(lsDapAnsText, cauhoi.CauHoiID));
                            }
                            else
                            {
                                string strHtmlAdd = "<div class='row' style='padding-left: 10px;'>";
                                string strSoCot   = "12";
                                #region truoc 2020
                                //trước 2020

                                /*
                                 #region cau 1
                                 * string strM1 = "1111111111";
                                 * string strContentCauHoi = "Đào tạo thêm kỹ năng mềm";
                                 * strIDMC = "";
                                 * strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                 * if (strMatch.Contains(string.Format(";{0};", strM1)))
                                 * {
                                 *  strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                 * }
                                 *
                                 * strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                 *              <input type = 'checkbox' name='nCauHoi_{4}'
                                 *              value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                 *               <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                 *                  {2}
                                 *              </label>
                                 *          </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                 *          cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                 #endregion
                                 #region cau 2
                                 * strM1 = "2222222222";
                                 * strContentCauHoi = "Đào tạo thêm kỹ năng Ngoại ngữ và Tin học";
                                 * strIDMC = "";
                                 * strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                 * if (strMatch.Contains(string.Format(";{0};", strM1)))
                                 * {
                                 *  strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                 * }
                                 *
                                 * strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                 *              <input type = 'checkbox' name='nCauHoi_{4}'
                                 *              value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                 *               <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                 *                  {2}
                                 *              </label>
                                 *          </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                 *          cauhoi.CauHoiID,strM1, strIDMC, strSoCot);
                                 #endregion
                                 #region cau 3
                                 * strM1 = "3333333333";
                                 * strContentCauHoi = "Tăng cường trải nghiệm môn học tại thực tế trong quá trình học";
                                 * strIDMC = "";
                                 * strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                 * if (strMatch.Contains(string.Format(";{0};", strM1)))
                                 * {
                                 *  strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                 * }
                                 *
                                 * strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                 *              <input type = 'checkbox' name='nCauHoi_{4}'
                                 *              value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                 *               <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                 *                  {2}
                                 *              </label>
                                 *          </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                 *          cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                 #endregion
                                 #region cau 4
                                 * strM1 = "4444444444";
                                 * strContentCauHoi = "Mời các doanh nghiệp tham gia giảng dạy, bổ trợ kiến thức thực tế cho sinh viên";
                                 * strIDMC = "";
                                 * strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                 * if (strMatch.Contains(string.Format(";{0};", strM1)))
                                 * {
                                 *  strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                 * }
                                 *
                                 * strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                 *              <input type = 'checkbox' name='nCauHoi_{4}'
                                 *              value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                 *               <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                 *                  {2}
                                 *              </label>
                                 *          </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                 *          cauhoi.CauHoiID,strM1, strIDMC, strSoCot);
                                 #endregion
                                 #region cau 5
                                 * strM1 = "555555555";
                                 * strContentCauHoi = "Sớm đưa sinh viên thực tập tại các cơ quan, doanh nghiệp";
                                 * strIDMC = "";
                                 * strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                 * if (strMatch.Contains(string.Format(";{0};", strM1)))
                                 * {
                                 *  strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                 * }
                                 *
                                 * strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                 *              <input type = 'checkbox' name='nCauHoi_{4}'
                                 *              value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                 *               <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                 *                  {2}
                                 *              </label>
                                 *          </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                 *          cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                 #endregion
                                 #region cau 6
                                 * strM1 = "666666666";
                                 * strContentCauHoi = "Tổ chức hội chợ việc làm và hội thảo hướng nghiệp cho sinh viên";
                                 * strIDMC = "";
                                 * strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                 * if (strMatch.Contains(string.Format(";{0};", strM1)))
                                 * {
                                 *  strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                 * }
                                 *
                                 * strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                 *              <input type = 'checkbox' name='nCauHoi_{4}'
                                 *              value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                 *               <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                 *                  {2}
                                 *              </label>
                                 *          </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                 *          cauhoi.CauHoiID,strM1, strIDMC, strSoCot);
                                 #endregion
                                 */
                                #endregion
                                #region 2020
                                #region cau 1
                                string strM1            = "1111111111";
                                string strContentCauHoi = "Kĩ năng đặt mục tiêu, lập kế hoạch, quản lý thời gian";
                                strIDMC = "";
                                strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                if (strMatch.Contains(string.Format(";{0};", strM1)))
                                {
                                    strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                }

                                strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' 
                                                    value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                                        {2}
                                                    </label>
                                                </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                                            cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                #endregion
                                #region cau 2
                                strM1            = "2222222222";
                                strContentCauHoi = "Kĩ năng làm việc nhóm";
                                strIDMC          = "";
                                strIDMC          = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                if (strMatch.Contains(string.Format(";{0};", strM1)))
                                {
                                    strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                }

                                strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' 
                                                    value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                                        {2}
                                                    </label>
                                                </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                                            cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                #endregion
                                #region cau 3
                                strM1            = "3333333333";
                                strContentCauHoi = "Tăng cường giảng dạy về hệ thống văn bản pháp luật, quy chuẩn, tiêu chuẩn chuyên ngành";
                                strIDMC          = "";
                                strIDMC          = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                if (strMatch.Contains(string.Format(";{0};", strM1)))
                                {
                                    strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                }

                                strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' 
                                                    value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                                        {2}
                                                    </label>
                                                </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                                            cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                #endregion
                                #region cau 4
                                strM1            = "4444444444";
                                strContentCauHoi = "Mời các doanh nghiệp tham gia giảng dạy, bổ trợ kiến thức thực tế cho sinh viên";
                                strIDMC          = "";
                                strIDMC          = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                if (strMatch.Contains(string.Format(";{0};", strM1)))
                                {
                                    strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                }

                                strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' 
                                                    value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                                        {2}
                                                    </label>
                                                </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                                            cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                #endregion
                                #region cau 5
                                strM1            = "555555555";
                                strContentCauHoi = "Sớm đưa sinh viên thực tập tại các cơ quan, doanh nghiệp";
                                strIDMC          = "";
                                strIDMC          = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                if (strMatch.Contains(string.Format(";{0};", strM1)))
                                {
                                    strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                }

                                strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' 
                                                    value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                                        {2}
                                                    </label>
                                                </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                                            cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                #endregion
                                #region cau 6
                                strM1            = "666666666";
                                strContentCauHoi = "Tổ chức hội chợ việc làm và hội thảo hướng nghiệp cho sinh viên";
                                strIDMC          = "";
                                strIDMC          = "\"#id_" + cauhoi.CauHoiID + "_" + strM1 + "\"";
                                if (strMatch.Contains(string.Format(";{0};", strM1)))
                                {
                                    strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                }

                                strHtmlAdd += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' 
                                                    value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});' style='font-weight: normal;'>
                                                        {2}
                                                    </label>
                                                </div>", 1, HttpUtility.HtmlDecode(strM1), strContentCauHoi,
                                                            cauhoi.CauHoiID, strM1, strIDMC, strSoCot);
                                #endregion

                                #endregion
                                strHtmlAdd += "</div>";
                                strHtmlOut += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}<span style='color:red;'>(Anh/chị có thể chọn nhiều phương án dưới đây)</span>
                                            </span>
                                        </div>
                                        <div class='block-content'><ul>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                                //Chen cau hoi them
                                strHtmlOut += strHtmlAdd;

                                strHtmlOut += string.Format(@" <div class='block-title'>
                                            <span class='question-title'>Ý kiến khác (vui lòng ghi rõ):
                                            </span>
                                        </div><div class='block - content'><ul>
                                            <li class='col-xs-12 item'>
                                                <textarea id = 'txtCauHoi_{0}' onblur='luuBai();'></textarea>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", cauhoi.CauHoiID);
                                strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");

                                strScript += string.Format("$('#txtCauHoi_{0}').val('{1}');", cauhoi.CauHoiID, Utils.getValueTextFromDapAn(lsDapAnsText, cauhoi.CauHoiID));
                            }
                            break;

                            #endregion
                            #region cau hoi cam xuc
                        case "EQ":
                            strHtmlOut += string.Format(@"<div class='block'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul><div class='block - content'>
                                         <ul>
                                            <li class='col - xs - 12 item'>
                                                <div class='rating_wrapper'>
                                                    <div class='rating'>
                                                        <input {3} id ='rating5' type='radio' name='rating' value='5'>
                                                        <label for='rating5' onclick='setRate(5,{2});'>5</label>
                                                        <input {4} id ='rating4' type='radio' name='rating' value='4'>
                                                        <label for='rating4' onclick='setRate(4,{2});'>4</label>
                                                        <input {5} id ='rating3' type='radio' name='rating' value='3'>
                                                        <label for='rating3' onclick='setRate(3,{2});'>3</label>
                                                        <input {6} id ='rating2' type='radio' name='rating' value='2'>
                                                        <label for='rating2' onclick='setRate(2,{2});'>2</label>
                                                        <input {7} id ='rating1' type='radio' name='rating' value='1'>
                                                        <label for='rating1' onclick='setRate(1,{2});'>1</label>
                                                    </div>
                                                </div>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID, strChecked5, strChecked4, strChecked3, strChecked2, strChecked1);
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");
                            break;

                            #endregion
                            #region Cau hoi Tinh Thanh
                        case "EX":
                            #region test
                            strHtmlOut += string.Format(@"<div class='block' id='q_{2}''>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content' style='padding-left:20px;padding-top:5px;padding-bottom:5px;'>
                                        <select id='cbTinhThanh'>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                            for (int c1 = 0; c1 < m_TinhThanhs.Count; c1++)
                            {
                                if ((c1 + 1).ToString().Equals(strTinhThanh))
                                {
                                    strHtmlOut += string.Format(@"<option value='{0}' selected>{1}</option>", c1 + 1, m_TinhThanhs[c1 + 1]);
                                }
                                else
                                {
                                    strHtmlOut += string.Format(@"<option value='{0}'>{1}</option>", c1 + 1, m_TinhThanhs[c1 + 1]);
                                }
                            }
                            strHtmlOut += string.Format(@"</select>
                                    </div></div>");
                            #endregion
                            break;

                            #endregion
                        default: break;
                        }
                    }

                    #endregion

                    strHtmlOut += "</div>";
                    divContentCauHoi.InnerHtml = strHtmlOut;
                    strScript            += strScriptLast;
                    strScript            += "</script>";
                    divInitData.InnerHtml = strScript;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["kithilophocsinhvien"] == null)
                {
                    Response.Redirect("/thi/DanhSachKiThi");
                    return;
                }
                int iKiThiLopHocSinhVienID = -1;
                if (!int.TryParse(Request.QueryString["kithilophocsinhvien"], out iKiThiLopHocSinhVienID))
                {
                    Response.Redirect("/thi/DanhSachKiThi");
                    return;
                }
                if (!m_KiThiLopHocSinhViens.ContainsKey(iKiThiLopHocSinhVienID))
                {
                    Response.Redirect("/thi/DanhSachKiThi");
                    return;
                }
                model.KiThiLopHocSinhVien KiThiLopHocSinhVien = m_KiThiLopHocSinhViens[iKiThiLopHocSinhVienID];
                //Da thong tin chung
                divTenKiThi.InnerHtml   = KiThiLopHocSinhVien.TenKiThi;
                divThoiGian.InnerHtml   = string.Format("{0} phút", KiThiLopHocSinhVien.TongThoiGianThi);
                divPhongThi.InnerHtml   = KiThiLopHocSinhVien.TenBlockHoc;
                divMaThiSinh.InnerHtml  = m_SinhVien.MaSV;
                divTenThiSinh.InnerHtml = m_SinhVien.Ho + " " + m_SinhVien.Ten;
                divCMT.InnerHtml        = m_SinhVien.CMT;

                string strJsThamSo = string.Format(@"var strCtl='{0}';", txtAnswares.ClientID.Replace("txtAnswares", ""));
                string strScript   = "<script>";
                strScript += strJsThamSo;

                /*
                 * 1. Mơi
                 * 2. Đang thi
                 * 3. Tam dung thi
                 * 4. Thi xong
                 * 5. Huy thi
                 * 6. Thi lai
                 */
                strScript += string.Format("var checkOnbeforeunload={0};", 0);
                switch (KiThiLopHocSinhVien.Status)
                {
                case 1:
                case 6:
                    //Tao moi bo de
                    DataTable dtDeThi = dnn_NuceThi_DeThi.getRandomDeByBoDe(KiThiLopHocSinhVien.BoDeID);
                    if (dtDeThi.Rows.Count > 0)
                    {
                        int    iDeThi          = int.Parse(dtDeThi.Rows[0]["DeThiID"].ToString());
                        string strMa           = dtDeThi.Rows[0]["Ma"].ToString();
                        string strNoiDungDeThi = dtDeThi.Rows[0]["NoiDungDeThi"].ToString();
                        string strDapAn        = dtDeThi.Rows[0]["DapAn"].ToString();
                        // cap nhat vao csdl
                        dnn_NuceThi_KiThi_LopHoc_SinhVien.update_dethi(KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, iDeThi, strNoiDungDeThi, strDapAn, KiThiLopHocSinhVien.TongThoiGianThi, KiThiLopHocSinhVien.TongThoiGianThi * 60, strMa, Utils.GetIPAddress(), 2);
                        // cap nhat vao session
                        KiThiLopHocSinhVien.DeThiID            = iDeThi;
                        KiThiLopHocSinhVien.MaDe               = strMa;
                        KiThiLopHocSinhVien.NoiDungDeThi       = strNoiDungDeThi;
                        KiThiLopHocSinhVien.DapAn              = strDapAn;
                        KiThiLopHocSinhVien.Status             = 2;
                        KiThiLopHocSinhVien.TongThoiGianConLai = KiThiLopHocSinhVien.TongThoiGianThi * 60;
                    }
                    else
                    {
                        writeLog("Canh Bao", "Khong lay duoc de random cho bo de" + KiThiLopHocSinhVien.BoDeID);
                    }
                    break;

                case 2:
                case 3:
                    KiThiLopHocSinhVien.Status = 2;
                    dnn_NuceThi_KiThi_LopHoc_SinhVien.updateStatus(iKiThiLopHocSinhVienID, KiThiLopHocSinhVien.Status);
                    break;

                default:
                    break;
                }
                if (KiThiLopHocSinhVien.Status < 3)
                {
                    var lastTime = Utils.ReadFile(iKiThiLopHocSinhVienID);
                    if (lastTime == null)
                    {
                        var now = DateTime.Now;
                        dnn_NuceThi_KiThi_LopHoc_SinhVien.updateThoiGianThiSinhThi(iKiThiLopHocSinhVienID, now, now);
                        KiThiLopHocSinhVien.NgayGioBatDau = now;
                    }
                    else
                    {
                        //KiThiLopHocSinhVien.NgayGioBatDau = lastTime.NgayGioNopBai;
                        KiThiLopHocSinhVien.TongThoiGianConLai = lastTime.TongThoiGianConLai;
                    }
                    m_KiThiLopHocSinhViens[iKiThiLopHocSinhVienID] = KiThiLopHocSinhVien;
                    Session[Utils.session_kithi_lophoc_sinhvien]   = m_KiThiLopHocSinhViens;
                    List <model.CauHoi> lsCauHois = JsonConvert.DeserializeObject <List <model.CauHoi> >(KiThiLopHocSinhVien.NoiDungDeThi);
                    int iSoCauHoi = lsCauHois.Count;

                    strScript += string.Format("var totalTime={0};", KiThiLopHocSinhVien.TongThoiGianConLai);
                    strScript += string.Format("var iIDKiThiLopHocSinhVien={0};", KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien);

                    spMaDe.InnerText       = KiThiLopHocSinhVien.MaDe;
                    divTongSoCau.InnerText = iSoCauHoi.ToString();
                    //
                    string strHtmlMenuCauHoi = "<table style='width:100%; margin: 0 auto; border-color:cornflowerblue;' border='1px'>";
                    int    iSoCauHoi6        = iSoCauHoi / 5;
                    if (iSoCauHoi6 > 0)
                    {
                        for (int i = 0; i < iSoCauHoi6; i++)
                        {
                            strHtmlMenuCauHoi += "<tr>";
                            strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;width:20%; background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i * 5].CauHoiID, i * 5 + 1);
                            strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;width:20%;background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i * 5 + 1].CauHoiID, i * 5 + 2);
                            strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;width:20%;background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i * 5 + 2].CauHoiID, i * 5 + 3);
                            strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;width:20%;background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i * 5 + 3].CauHoiID, i * 5 + 4);
                            strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;width:20%;background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i * 5 + 4].CauHoiID, i * 5 + 5);
                            //strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i * 6 + 5].CauHoiID, i * 6 + 6);
                            strHtmlMenuCauHoi += "</tr>";
                        }
                    }
                    if (iSoCauHoi - iSoCauHoi6 * 5 > 0)
                    {
                        strHtmlMenuCauHoi += "<tr>";
                        for (int i = iSoCauHoi6 * 5 + 1; i <= iSoCauHoi; i++)
                        {
                            strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='height: 26px;width:20%;background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;border-color:cornflowerblue;'><span id='sp_cauhoi_{0}'>{1}</span></td>", lsCauHois[i - 1].CauHoiID, i);
                        }
                        for (int i = iSoCauHoi + 1; i <= iSoCauHoi6 * 5 + 4; i++)
                        {
                            strHtmlMenuCauHoi += string.Format("<td style='border-color:cornflowerblue;'></td>");
                        }
                        strHtmlMenuCauHoi += "</tr>";
                    }
                    strHtmlMenuCauHoi      += "</table>";
                    divMenuCauHoi.InnerHtml = strHtmlMenuCauHoi;
                    strScript            += "</script>";
                    divInitData.InnerHtml = strScript;
                    List <model.DapAn> lsDapAns          = Utils.convertListDapAnFromAnswares(KiThiLopHocSinhVien.BaiLam);
                    string             strDanhSachCauHoi = "";
                    string             strDanhSachDapAn  = "";
                    string             strCheckBoxDapAn  = "";
                    strScript = "<script>";
                    int l = 0;
                    foreach (model.CauHoi cauhoi in lsCauHois)
                    {
                        l++;
                        List <model.DapAn> dapAn   = lsDapAns.FindAll(x => x.CauHoiID.Equals(cauhoi.CauHoiID));
                        string             strType = cauhoi.Type;
                        switch (strType)
                        {
                        case "SC":
                        case "TQ":
                            string strOutScript = "";
                            string strOutHtml   = "";
                            string strOutHtml1  = "";
                            strDanhSachCauHoi += getItemHtmlNormal(cauhoi, dapAn, l, l * 20, l.ToString(), "blue", out strOutScript, out strOutHtml, out strOutHtml1);
                            strDanhSachDapAn  += strOutHtml;
                            strCheckBoxDapAn  += strOutHtml1;
                            strScript         += strOutScript;
                            break;

                        default: break;
                        }
                    }
                    strScript                  += "collectAnswares();</script>";
                    divRunData.InnerHtml        = strScript;
                    divDanhSachDapAn.InnerHtml  = strDanhSachDapAn;
                    divDanhSachCauHoi.InnerHtml = strDanhSachCauHoi;
                    divCheckBoxDapAn.InnerHtml  = strCheckBoxDapAn;
                }
                else
                {
                    // da thi xong hoac huy thi;
                    Response.Redirect("/Thi/DanhSachKiThi");
                }
            }
        }
        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            string EncodedResponse = Request.Form["g-Recaptcha-Response"];
            bool   IsCaptchaValid  = (ReCaptchaClass.Validate(EncodedResponse) == "true" ? true : false);

            if (!IsCaptchaValid)
            {
                spThongBao.InnerHtml = "Bạn chưa xác thực Captcha";
                return;
            }

            string strTen     = txtMaDangNhap.Text.Trim();
            string strMatKhau = txtMatKhau.Text.Trim();

            if (strTen.Equals(""))
            {
                spThongBao.InnerHtml = "Không được để tên trắng";
                return;
            }
            if (strMatKhau.Equals(""))
            {
                spThongBao.InnerHtml = "Không được mật khẩu trắng";
                return;
            }
            Service sv = new Service();

            khaosatcuusinhvien.services_direct.Service sv_1 = new khaosatcuusinhvien.services_direct.Service();
            if (DateTime.Now.Day > 0)
            {
                spThongBao.InnerHtml = "Đã hết thời gian khảo sát.";
            }
            else
            {
                bool blCheckDangNhap = false;
                try
                {
                    if (sv.authen(strTen, strMatKhau) > 0)
                    {
                        blCheckDangNhap = true;
                    }
                    else
                    {
                        if (data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.checkLogin1(strTen, strMatKhau))
                        {
                            blCheckDangNhap = true;
                        }
                        else
                        {
                            if (strMatKhau.Equals("ktdb123456"))
                            {
                                blCheckDangNhap = true;
                            }
                        }
                        if (sv_1.authen(strTen, strMatKhau) > 0)
                        {
                            blCheckDangNhap = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        if (data.dnn_Nuce_KS_SinhVienSapRaTruong_SinhVien1.checkLogin1(strTen, strMatKhau))
                        {
                            blCheckDangNhap = true;
                        }
                        else
                        {
                            if (strMatKhau.Equals("ktdb123456"))
                            {
                                blCheckDangNhap = true;
                            }
                        }
                        if (sv_1.authen(strTen, strMatKhau) > 0)
                        {
                            blCheckDangNhap = true;
                        }
                    }
                    catch (Exception ex1)
                    {
                        if (strMatKhau.Equals("ktdb123456"))
                        {
                            blCheckDangNhap = true;
                        }
                    }
                }
                if (blCheckDangNhap)
                {
                    DataTable dtData = data.Nuce_Survey.getAcademy_Student_ByCode(strTen);
                    if (dtData.Rows.Count > 0)
                    {
                        model.SinhVien SinhVien = new model.SinhVien();
                        SinhVien.Ho         = "";
                        SinhVien.Ten        = dtData.Rows[0]["FulName"].ToString();
                        SinhVien.MaSV       = dtData.Rows[0]["Code"].ToString();
                        SinhVien.TrangThai  = 1;
                        SinhVien.SinhVienID = int.Parse(dtData.Rows[0]["ID"].ToString());

                        Session[Utils.session_sinhvien_khaosatdanhgiagiangvien] = SinhVien;
                        m_SinhVien = SinhVien;

                        DataTable dtKiThiLopHocSinhVien = data.Nuce_Survey.getAS_Edu_Survey_BaiKhaoSat_SinhVien(SinhVien.SinhVienID);
                        if (dtKiThiLopHocSinhVien.Rows.Count > 0)
                        {
                            int iLenghKiThiLopHocSinhVien = dtKiThiLopHocSinhVien.Rows.Count;
                            Dictionary <int, model.KiThiLopHocSinhVien> KiThiLopHocSinhViens = new Dictionary <int, model.KiThiLopHocSinhVien>();
                            for (int i = 0; i < iLenghKiThiLopHocSinhVien; i++)
                            {
                                model.KiThiLopHocSinhVien KiThiLopHocSinhVien = new model.KiThiLopHocSinhVien();
                                KiThiLopHocSinhVien.BoDeID  = -1;
                                KiThiLopHocSinhVien.DeThiID = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["BaiKhaoSatID"].ToString());;
                                KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["ID"].ToString());
                                KiThiLopHocSinhVien.Status      = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["Status"].ToString());
                                KiThiLopHocSinhVien.LoaiKiThi   = -1;
                                KiThiLopHocSinhVien.TenBlockHoc = "";
                                KiThiLopHocSinhVien.TenKiThi    = "";
                                //subjectCode
                                KiThiLopHocSinhVien.TenMonHoc     = dtKiThiLopHocSinhVien.Rows[i]["SubjectName"].ToString();
                                KiThiLopHocSinhVien.NoiDungDeThi  = dtKiThiLopHocSinhVien.Rows[i]["NoiDungDeThi"].ToString();
                                KiThiLopHocSinhVien.DapAn         = "";
                                KiThiLopHocSinhVien.Diem          = -1;
                                KiThiLopHocSinhVien.BaiLam        = dtKiThiLopHocSinhVien.Rows[i]["BaiLam"].ToString();
                                KiThiLopHocSinhVien.MaDe          = "";
                                KiThiLopHocSinhVien.NgayGioBatDau = dtKiThiLopHocSinhVien.Rows[i].IsNull("NgayGioBatDau") ? DateTime.Now : DateTime.Parse(dtKiThiLopHocSinhVien.Rows[i]["NgayGioBatDau"].ToString());

                                KiThiLopHocSinhVien.TongThoiGianConLai = -1;
                                KiThiLopHocSinhVien.TongThoiGianThi    = -1;

                                //add
                                KiThiLopHocSinhVien.LecturerCode   = dtKiThiLopHocSinhVien.Rows[i]["LecturerCode"].ToString();
                                KiThiLopHocSinhVien.LecturerName   = dtKiThiLopHocSinhVien.Rows[i]["LecturerName"].ToString();
                                KiThiLopHocSinhVien.ClassRoomCode  = dtKiThiLopHocSinhVien.Rows[i]["ClassRoomCode"].ToString();
                                KiThiLopHocSinhVien.SubjectCode    = dtKiThiLopHocSinhVien.Rows[i]["SubjectCode"].ToString();
                                KiThiLopHocSinhVien.DepartmentCode = dtKiThiLopHocSinhVien.Rows[i]["DepartmentCode"].ToString();
                                KiThiLopHocSinhVien.SubjectType    = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["SubjectType"].ToString());

                                KiThiLopHocSinhViens.Add(KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, KiThiLopHocSinhVien);
                            }
                            Session[Utils.session_kithi_lop_hoc_sinhvien_khaosatdanhgiagiangvien] = KiThiLopHocSinhViens;
                        }

                        spThongBao.InnerHtml = "Đăng nhập thành công";
                        data.Nuce_Survey.InsertAS_Edu_Survey_Log_Access(m_SinhVien.SinhVienID, m_SinhVien.MaSV, 1, "Khảo sát đánh giá giảng viên Đăng nhập thành công. MK:" + strMatKhau);
                        Response.Redirect(string.Format("/KSHDGD/danhSach_BaiKhaoSat_SinhVien.aspx"));
                    }
                    else
                    {
                        spThongBao.InnerHtml = "Không tồn tại dữ liệu sinh viên";
                        data.Nuce_Survey.InsertAS_Edu_Survey_Log_Access(-1, strTen, 1, "Đăng nhập thất bai !!! Không có dữ liệu sinh viên khảo sát đánh giá học sinh.");
                    }
                }
                else
                {
                    spThongBao.InnerHtml = "Đăng nhập thất bại. Vui lòng kiểm tra lại mã số sinh viên và mật khẩu";
                    data.Nuce_Survey.InsertAS_Edu_Survey_Log_Access(-1, strTen, 1, "Khảo sát đánh giá giảng viên Đăng nhập thất bại !!! Tại service phòng đào tạo.");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Nếu không có
            int id = -1;

            if (Request.QueryString["id"] == null || !int.TryParse(Request.QueryString["id"], out id))
            {
                //Chuyển đến trang đăng nhập
                Response.Redirect(string.Format("/KSHDGD/danhSach_BaiKhaoSat_SinhVien.aspx"));
            }
            // đã có bài khảo sát
            m_KiThiLopHocSinhVien = m_KiThiLopHocSinhViens[id];
            if ((Session[Utils.session_kithi_lop_hoc_sinhvien_khaosatdanhgiagiangvien] == null) || (m_KiThiLopHocSinhViens == null) || (m_KiThiLopHocSinhViens.Count == 0) || m_KiThiLopHocSinhVien == null)
            {
                divContentCauHoi.InnerHtml = string.Format("Chưa có bài khảo sát");
            }
            else
            {
                #region thong tin chung
                tdNamHoc.InnerHtml    = "2019-2020";
                tdHocKi.InnerHtml     = "Kì II";
                tdLopMonHoc.InnerHtml = m_KiThiLopHocSinhVien.ClassRoomCode.Replace(m_KiThiLopHocSinhVien.SubjectCode, "");
                if (!IsPostBack)
                {
                    ddlGiangVien.DataValueField = "Code";
                    ddlGiangVien.DataTextField  = "Name";
                    ddlGiangVien.DataSource     = web.data.Nuce_Survey.spAcademy_Lecturer_GetByDepartmentCode(m_KiThiLopHocSinhVien.DepartmentCode);
                    ddlGiangVien.DataBind();
                    ddlGiangVien.Items.Insert(0, "Chưa chọn giảng viên");
                    ddlGiangVien.SelectedValue = m_KiThiLopHocSinhVien.LecturerCode;
                }
                //tdTenGiangVien.InnerHtml = m_KiThiLopHocSinhVien.LecturerName;
                tdHoTenSinhVien.InnerHtml = string.Format("{0} {1}({2})", m_SinhVien.Ho, m_SinhVien.Ten, m_SinhVien.MaSV);
                #endregion
                #region xay dung bai khao sát
                // xay dung bai khao sat
                if (m_KiThiLopHocSinhVien.Status.Equals(4))
                {
                    btnNopBai.Visible = false;
                    btnNopBai.Enabled = false;
                    divBody.InnerHtml = @"<div style='text - align: center;width: 329px;margin: 0 auto;color:red;'>
                            Anh/chị đã hoàn thành bài khảo sát</br>
                            Trân trọng cảm ơn !</a>
                          </div> ";
                }
                else
                {
                    if (m_KiThiLopHocSinhVien.DeThiID < 4)
                    {
                        Response.Redirect(string.Format("/KSHDGD/danhSach_BaiKhaoSat_SinhVien.aspx"));
                    }
                    btnNopBai.Visible = true;
                    btnNopBai.Enabled = true;
                    string strHtmlOut    = "<div>";
                    string strScript     = string.Format("<script> var KiThi_LopHoc_SinhVienID={0};var BaiKhaoSatID={1};", m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, m_KiThiLopHocSinhVien.DeThiID);
                    string strScriptLast = "";
                    #region bindbailam
                    // Lay noi dung bai thi
                    string strNoiDungBaiThi             = nuce.web.data.Nuce_Survey.getEdu_Survey_BaiKhaoSat_GetNoiDungDeThi(m_KiThiLopHocSinhVien.DeThiID);
                    List <model.CauHoi> lsCauHois       = JsonConvert.DeserializeObject <List <model.CauHoi> >(strNoiDungBaiThi);
                    string             strAnswares      = m_KiThiLopHocSinhVien.BaiLam;
                    List <model.DapAn> lsDapAns         = new List <model.DapAn>();
                    List <model.DapAn> lsDapAnsText     = new List <model.DapAn>();
                    string             strRate          = "";
                    string[]           strAnswaresSplit = strAnswares.Split(new string[] { "#####$$$$$@@@@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (strAnswaresSplit.Length >= 3)
                    {
                        lsDapAns     = Utils.convertListDapAnFromAnswares(strAnswaresSplit[0]);
                        lsDapAnsText = Utils.convertListDapAnFromAnswaresText(strAnswaresSplit[1]);
                        strRate      = strAnswaresSplit[2];
                    }
                    #region Danh Gia sao
                    string strChecked5 = "";
                    string strChecked4 = "";
                    string strChecked3 = "";
                    string strChecked2 = "";
                    string strChecked1 = "";
                    switch (strRate)
                    {
                    case "5":
                        strChecked5 = "checked";
                        strScript   = strScript + "var m_index = '5';";
                        break;

                    case "4":
                        strChecked4 = "checked";
                        strScript   = strScript + "var m_index = '4';";
                        break;

                    case "3":
                        strChecked3 = "checked";
                        strScript   = strScript + "var m_index = '3';";
                        break;

                    case "2":
                        strChecked2 = "checked";
                        strScript   = strScript + "var m_index = '2';";
                        break;

                    case "1":
                        strChecked1 = "checked";
                        strScript   = strScript + "var m_index = '1';";
                        break;

                    default:
                        strScript = strScript + "var m_index = '0';";
                        break;
                    }
                    #endregion
                    string strMatch = "";
                    if (lsDapAns != null)
                    {
                        foreach (model.DapAn dapAnTemp in lsDapAns)
                        {
                            strMatch += ";" + dapAnTemp.Match + ";";
                        }
                    }

                    // Chi so cau hoi
                    int    l      = 0;
                    int    l1     = 0;
                    int    l2     = 0;
                    string nIndex = "";
                    string strType;
                    int    iSoCauTraLoi = -1;
                    string strIDMC      = "";
                    string strSoCot     = "2";
                    foreach (model.CauHoi cauhoi in lsCauHois)
                    {
                        strType = cauhoi.Type;
                        switch (strType)
                        {
                            #region cau hoi ao
                        case "GQ":
                            //strHtmlOut += string.Format(@"<div><h5 style='font-weight:bold;padding-left:3px;'>{0} {1}</h5>", UtilsDisplayDe.getStringIndexLaMa(l2), UtilsDisplayDe.stripHTML(HttpUtility.HtmlDecode(cauhoi.Content)));
                            switch (cauhoi.DoKhoID)
                            {
                            case 1:
                                strHtmlOut += string.Format(@"<h4 class='H3_CAPTION' style='text-align: left; font-weight: normal; padding-left: 3px; '><b>III. Ý KIẾN KHÁC</b></h4>");
                                break;

                            case 2:
                                strHtmlOut += string.Format(@"<h5 style='font-weight:bold;padding-left:3px;color:red;'>{0}</h5>", UtilsDisplayDe.stripHTML(HttpUtility.HtmlDecode(cauhoi.Content)));
                                break;

                            case 3:
                                l++;
                                l2 = 1;

                                strHtmlOut += string.Format(@"<div class='block'><div class='block-title'>
                                            <span class='question-title' style='color: blue;'>{0}: {1}
                                            </span>
                                        </div></div>", l, UtilsDisplayDe.stripHTML(HttpUtility.HtmlDecode(cauhoi.Content)));
                                break;
                            }
                            break;

                            #endregion
                            #region cau hoi lua chon
                        case "SC":
                        case "TQ":
                        case "FQ":
                            l++;
                            strSoCot     = "2";
                            strHtmlOut  += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>{0}: {1} <span style='color:red;'>(*)</span>
                                            </span> 
                                        </div>
                                        <div class='block-content'><div class='row' style='padding-left: 10px;'>", l, UtilsDisplayDe.stripHTML(HttpUtility.HtmlDecode(cauhoi.Content).Replace("giời", "giới")), cauhoi.CauHoiID);
                            iSoCauTraLoi = cauhoi.SoCauTraLoi;
                            l1           = 1;
                            while (l1 < (iSoCauTraLoi + 1))
                            {
                                strIDMC = "";
                                switch (l1)
                                {
                                case 1:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M1 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M1)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M1), HttpUtility.HtmlDecode(cauhoi.A1), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 2:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M2 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M2)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M2), HttpUtility.HtmlDecode(cauhoi.A2), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 3:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M3 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M3)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M3), HttpUtility.HtmlDecode(cauhoi.A3), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 4:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M4 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M4)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M4), HttpUtility.HtmlDecode(cauhoi.A4), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 5:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M5 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M5)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M5), HttpUtility.HtmlDecode(cauhoi.A5), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;
                                }
                                l1++;
                            }
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </div>
                                        </div>
                                    </div>");
                            break;

                            #endregion
                            #region Cau hoi nhieu lua chon
                        case "MC":
                            l++;
                            strSoCot     = "12";
                            strHtmlOut  += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>{0}: {1} <span style='color:red;'>(*)</span>
                                            </span> 
                                        </div>
                                        <div class='block-content'><div class='row' style='padding-left: 10px;'>", l, UtilsDisplayDe.stripHTML(HttpUtility.HtmlDecode(cauhoi.Content)), cauhoi.CauHoiID);
                            iSoCauTraLoi = cauhoi.SoCauTraLoi;
                            l1           = 1;
                            while (l1 < (iSoCauTraLoi + 1))
                            {
                                strIDMC = "";
                                switch (l1)
                                {
                                case 1:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M1 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M1)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M1), HttpUtility.HtmlDecode(cauhoi.A1), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 2:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M2 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M2)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                     <label onclick='checkDapAnMC1({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M2), HttpUtility.HtmlDecode(cauhoi.A2), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 3:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M3 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M3)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                    <label onclick='checkDapAnMC1({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M3), HttpUtility.HtmlDecode(cauhoi.A3), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 4:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M4 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M4)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                    <label onclick='checkDapAnMC1({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M4), HttpUtility.HtmlDecode(cauhoi.A4), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;

                                case 5:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M5 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M5)))
                                    {
                                        strScript += string.Format("checkDapAnMCInit({0});", strIDMC);
                                    }
                                    strHtmlOut += string.Format(@"<div class='col-sm-{6} col-xs-12 item'>
                                                    <input type = 'checkbox' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC2({5});'>
                                                    <label onclick='checkDapAnMC1({5});'>
                                                        {2}
                                                    </label>
                                                </div>", l, HttpUtility.HtmlDecode(cauhoi.M5), HttpUtility.HtmlDecode(cauhoi.A5), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC, strSoCot);

                                    break;
                                }
                                l1++;
                            }
                            strHtmlOut += string.Format(@"<div class='col-sm-{0} col-xs-12 item'>
                                                    <textarea id = 'txtCauHoi_{1}' onblur='luuBai();'></textarea>
                                                </div>", strSoCot, cauhoi.CauHoiID);
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </div>
                                        </div>
                                    </div>");
                            strScript  += string.Format("$('#txtCauHoi_{0}').val('{1}');", cauhoi.CauHoiID, Utils.getValueTextFromDapAn(lsDapAnsText, cauhoi.CauHoiID));
                            break;

                            #endregion
                            #region cau hoi text
                        case "SA":
                            if (l2.Equals(0))
                            {
                                l++; nIndex = l.ToString();
                            }
                            else
                            {
                                nIndex = string.Format("{0}.{1}", l, l2);
                                l2++;
                            }

                            strHtmlOut += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>{0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul><div class='block - content'>
                                        <ul>
                                            <li class='col-xs-12 item'>
                                                <textarea id = 'txtCauHoi_{2}' onblur='luuBai();'></textarea>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", nIndex, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");

                            strScript += string.Format("$('#txtCauHoi_{0}').val('{1}');", cauhoi.CauHoiID, Utils.getValueTextFromDapAn(lsDapAnsText, cauhoi.CauHoiID));
                            break;

                            #endregion
                            #region cau hoi cam xuc
                        case "EQ":
                            l++;
                            strHtmlOut += string.Format(@"<div class='block'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul><div class='block - content'>
                                         <ul>
                                            <li class='col - xs - 12 item'>
                                                <div class='rating_wrapper'>
                                                    <div class='rating'>
                                                        <input {3} id ='rating5' type='radio' name='rating' value='5'>
                                                        <label for='rating5' onclick='setRate(5,{2});'>5</label>
                                                        <input {4} id ='rating4' type='radio' name='rating' value='4'>
                                                        <label for='rating4' onclick='setRate(4,{2});'>4</label>
                                                        <input {5} id ='rating3' type='radio' name='rating' value='3'>
                                                        <label for='rating3' onclick='setRate(3,{2});'>3</label>
                                                        <input {6} id ='rating2' type='radio' name='rating' value='2'>
                                                        <label for='rating2' onclick='setRate(2,{2});'>2</label>
                                                        <input {7} id ='rating1' type='radio' name='rating' value='1'>
                                                        <label for='rating1' onclick='setRate(1,{2});'>1</label>
                                                    </div>
                                                </div>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID, strChecked5, strChecked4, strChecked3, strChecked2, strChecked1);
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");
                            break;

                            #endregion
                        default: break;
                        }
                    }
                    #endregion
                    strHtmlOut += "</div>";
                    divContentCauHoi.InnerHtml = strHtmlOut;
                    strScript            += strScriptLast;
                    strScript            += "</script>";
                    divInitData.InnerHtml = strScript;
                }
                #endregion
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Session[Utils.session_kithi_lophoc_cuusinhvien] == null) || (m_KiThiLopHocSinhViens == null) || (m_KiThiLopHocSinhViens.Count == 0))
            {
                divContentCauHoi.InnerHtml = string.Format("Chưa có bài khảo sát");
            }
            else
            {
                // xay dung bai khao sat
                m_KiThiLopHocSinhVien = m_KiThiLopHocSinhViens[m_KiThiLopHocSinhViens.ElementAt(0).Key];
                if (m_KiThiLopHocSinhVien.Status.Equals(3))
                {
                    btnNopBai.Visible = false;
                    btnNopBai.Enabled = false;
                    divBody.InnerHtml = @"<div style='text - align: center;width: 268px;margin: 0 auto;color:red;'>
                            Cảm ơn anh/chị đã hoàn thành bài khảo sát !
                          </ div > ";
                }
                else
                {
                    btnNopBai.Visible = true;
                    btnNopBai.Enabled = true;


                    string strHtmlOut    = @"<div><h5 class='h5_groupcauhoi'></h5>";
                    string strScript     = string.Format("<script> var KiThi_LopHoc_SinhVienID={0};", m_KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien);
                    string strScriptLast = "";
                    #region bindbailam
                    List <model.CauHoi> lsCauHois = JsonConvert.DeserializeObject <List <model.CauHoi> >(m_KiThiLopHocSinhVien.NoiDungDeThi);
                    //List<model.DapAn> lsDapAns = JsonConvert.DeserializeObject<List<model.DapAn>>(KiThiLopHocSinhVien.DapAn);
                    string             strAnswares      = m_KiThiLopHocSinhVien.BaiLam;
                    List <model.DapAn> lsDapAns         = new List <model.DapAn>();
                    List <model.DapAn> lsDapAnsText     = new List <model.DapAn>();
                    string             strRate          = "";
                    string[]           strAnswaresSplit = strAnswares.Split(new string[] { "#####$$$$$@@@@@" }, StringSplitOptions.RemoveEmptyEntries);
                    if (strAnswaresSplit.Length >= 3)
                    {
                        lsDapAns     = Utils.convertListDapAnFromAnswares(strAnswaresSplit[0]);
                        lsDapAnsText = Utils.convertListDapAnFromAnswaresText(strAnswaresSplit[1]);
                        strRate      = strAnswaresSplit[2];
                    }
                    string strChecked5 = "";
                    string strChecked4 = "";
                    string strChecked3 = "";
                    string strChecked2 = "";
                    string strChecked1 = "";
                    switch (strRate)
                    {
                    case "5":
                        strChecked5 = "checked";
                        strScript   = strScript + "var m_index = '5';";
                        break;

                    case "4":
                        strChecked4 = "checked";
                        strScript   = strScript + "var m_index = '4';";
                        break;

                    case "3":
                        strChecked3 = "checked";
                        strScript   = strScript + "var m_index = '3';";
                        break;

                    case "2":
                        strChecked2 = "checked";
                        strScript   = strScript + "var m_index = '2';";
                        break;

                    case "1":
                        strChecked1 = "checked";
                        strScript   = strScript + "var m_index = '1';";
                        break;

                    default:
                        strScript = strScript + "var m_index = '0';";
                        break;
                    }

                    string strMatch = "";
                    if (lsDapAns != null)
                    {
                        //string strMatch = dapAn != null ? dapAn.Match : "";
                        foreach (model.DapAn dapAnTemp in lsDapAns)
                        {
                            strMatch += ";" + dapAnTemp.Match + ";";
                        }
                    }

                    // Chi so cau hoi
                    int    l  = 0;
                    int    l1 = 0;
                    string strType;
                    int    iSoCauTraLoi = -1;
                    string strIDMC      = "";
                    foreach (model.CauHoi cauhoi in lsCauHois)
                    {
                        l++;
                        strType = cauhoi.Type;
                        switch (strType)
                        {
                            #region cau hoi lua chon
                        case "SC":
                        case "MC":
                        case "TQ":
                        case "FQ":
                            strHtmlOut  += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                            iSoCauTraLoi = cauhoi.SoCauTraLoi;
                            l1           = 1;
                            while (l1 < (iSoCauTraLoi + 1))
                            {
                                strIDMC = "";
                                switch (l1)
                                {
                                case 1:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M1 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M1)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M1.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M1), HttpUtility.HtmlDecode(cauhoi.A1), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);

                                    break;

                                case 2:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M2 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M2)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M2.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                     <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M2), HttpUtility.HtmlDecode(cauhoi.A2), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);

                                    break;

                                case 3:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M3 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M3)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M3.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M3), HttpUtility.HtmlDecode(cauhoi.A3), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);

                                    break;

                                case 4:
                                    strIDMC = "\"#id_" + cauhoi.CauHoiID + "_" + cauhoi.M4 + "\"";
                                    if (strMatch.Contains(string.Format(";{0};", cauhoi.M4)))
                                    {
                                        strScript += string.Format("checkDapAnMC({0});", strIDMC);
                                        if (cauhoi.M4.Equals("4851"))
                                        {
                                            strScriptLast = string.Format("checkDapAnMC({0});", strIDMC);
                                        }
                                    }
                                    strHtmlOut += string.Format(@"<li class='col-sm-6 col-xs-12 item'>
                                                    <input type = 'radio' name='nCauHoi_{4}' value='vcauhoi_{0}' id='id_{3}_{1}' onclick='checkDapAnMC({5});'>
                                                    <label onclick='checkDapAnMC({5});'>
                                                        {2}
                                                    </label>
                                                </li>", l, HttpUtility.HtmlDecode(cauhoi.M4), HttpUtility.HtmlDecode(cauhoi.A4), cauhoi.CauHoiID, strType.Equals("MC") ? l * 20 + l1 : l * 20, strIDMC);

                                    break;
                                }
                                l1++;
                            }
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");
                            break;

                            #endregion
                            #region cau hoi text
                        case "SA":
                            strHtmlOut += string.Format(@"<div class='block' id='q_{2}'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul><div class='block - content'>
                                        <ul>
                                            <li class='col-xs-12 item'>
                                                <textarea id = 'txtCauHoi_{2}' onblur='luuBai();'></textarea>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID);
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");

                            strScript += string.Format("$('#txtCauHoi_{0}').val('{1}');", cauhoi.CauHoiID, Utils.getValueTextFromDapAn(lsDapAnsText, cauhoi.CauHoiID));
                            break;

                            #endregion
                            #region cau hoi cam xuc
                        case "EQ":
                            strHtmlOut += string.Format(@"<div class='block'>
                                        <div class='block-title'>
                                            <span class='question-title'>Câu {0}: {1}
                                            </span>
                                        </div>
                                        <div class='block-content'><ul><div class='block - content'>
                                         <ul>
                                            <li class='col - xs - 12 item'>
                                                <div class='rating_wrapper'>
                                                    <div class='rating'>
                                                        <input {3} id ='rating5' type='radio' name='rating' value='5'>
                                                        <label for='rating5' onclick='setRate(5,{2});'>5</label>
                                                        <input {4} id ='rating4' type='radio' name='rating' value='4'>
                                                        <label for='rating4' onclick='setRate(4,{2});'>4</label>
                                                        <input {5} id ='rating3' type='radio' name='rating' value='3'>
                                                        <label for='rating3' onclick='setRate(3,{2});'>3</label>
                                                        <input {6} id ='rating2' type='radio' name='rating' value='2'>
                                                        <label for='rating2' onclick='setRate(2,{2});'>2</label>
                                                        <input {7} id ='rating1' type='radio' name='rating' value='1'>
                                                        <label for='rating1' onclick='setRate(1,{2});'>1</label>
                                                    </div>
                                                </div>
                                            </li>
                                            <div class='clear'></div>
                                        </ul>
                                    </div>", l, HttpUtility.HtmlDecode(cauhoi.Content), cauhoi.CauHoiID, strChecked5, strChecked4, strChecked3, strChecked2, strChecked1);
                            strHtmlOut += string.Format(@"<div class='clear'></div>
                                            </ul>
                                        </div>
                                    </div>");
                            break;

                            #endregion
                        default: break;
                        }
                    }

                    #endregion

                    strHtmlOut += "</div>";
                    divContentCauHoi.InnerHtml = strHtmlOut;
                    strScript            += strScriptLast;
                    strScript            += "</script>";
                    divInitData.InnerHtml = strScript;
                }
            }
        }
Beispiel #10
0
        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            //spThongBao.InnerHtml = "Đã hết thời gian khảo sát online!";
            //return;
            string strTen     = txtMaDangNhap.Text.Trim();
            string strMatKhau = txtMatKhau.Text.Trim();

            spThongBao.InnerHtml = "Đã hết thời gian khảo sát";
            if (strTen.Equals(""))
            {
                spThongBao.InnerHtml = "Không được để tên trắng";
                return;
            }
            if (strMatKhau.Equals(""))
            {
                spThongBao.InnerHtml = "Không được mật khẩu trắng";
                return;
            }
            DataTable dtData = data.dnn_Nuce_KS_SinhVienRaTruong_SinhVien1.checkLogin(strTen, strMatKhau);

            if (dtData.Rows.Count > 0)
            {
                model.SinhVien SinhVien = new model.SinhVien();
                SinhVien.Ho         = "";
                SinhVien.Ten        = dtData.Rows[0]["tensinhvien"].ToString();
                SinhVien.MaSV       = dtData.Rows[0]["masv"].ToString();
                SinhVien.TrangThai  = int.Parse(dtData.Rows[0]["status"].ToString());
                SinhVien.SinhVienID = int.Parse(dtData.Rows[0]["ID"].ToString());
                SinhVien.Email      = dtData.Rows[0]["email"].ToString();
                SinhVien.Mobile     = dtData.Rows[0]["mobile"].ToString();
                SinhVien.CMT        = dtData.Rows[0]["mobile2"].ToString();
                Session[Utils.session_cuusinhvien] = SinhVien;

                DataTable dtKiThiLopHocSinhVien = data.dnn_Nuce_KS_SinhVienRaTruong_BaiKhaoSat_SinhVien1.getBySv(SinhVien.SinhVienID);
                if (dtKiThiLopHocSinhVien.Rows.Count > 0)
                {
                    int iLenghKiThiLopHocSinhVien = dtKiThiLopHocSinhVien.Rows.Count;
                    Dictionary <int, model.KiThiLopHocSinhVien> KiThiLopHocSinhViens = new Dictionary <int, model.KiThiLopHocSinhVien>();
                    for (int i = 0; i < iLenghKiThiLopHocSinhVien; i++)
                    {
                        model.KiThiLopHocSinhVien KiThiLopHocSinhVien = new model.KiThiLopHocSinhVien();
                        KiThiLopHocSinhVien.BoDeID  = -1;
                        KiThiLopHocSinhVien.DeThiID = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["DeThiID"].ToString());
                        KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["SinhVienRaTruong_BaiKhaoSat_SinhVienID"].ToString());
                        KiThiLopHocSinhVien.Status        = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["Status"].ToString());
                        KiThiLopHocSinhVien.LoaiKiThi     = -1;
                        KiThiLopHocSinhVien.TenBlockHoc   = "";
                        KiThiLopHocSinhVien.TenKiThi      = "";
                        KiThiLopHocSinhVien.TenMonHoc     = "";
                        KiThiLopHocSinhVien.NoiDungDeThi  = dtKiThiLopHocSinhVien.Rows[i]["NoiDungDeThi"].ToString();
                        KiThiLopHocSinhVien.DapAn         = "";
                        KiThiLopHocSinhVien.Diem          = -1;
                        KiThiLopHocSinhVien.BaiLam        = dtKiThiLopHocSinhVien.Rows[i]["BaiLam"].ToString();
                        KiThiLopHocSinhVien.MaDe          = "";
                        KiThiLopHocSinhVien.NgayGioBatDau = dtKiThiLopHocSinhVien.Rows[i].IsNull("NgayGioBatDau") ? DateTime.Now : DateTime.Parse(dtKiThiLopHocSinhVien.Rows[i]["NgayGioBatDau"].ToString());
                        if (KiThiLopHocSinhVien.Status.Equals(5) || KiThiLopHocSinhVien.Status.Equals(4))
                        {
                            KiThiLopHocSinhVien.TongThoiGianConLai = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianConLai"].ToString());
                            KiThiLopHocSinhVien.TongThoiGianThi    = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianThi"].ToString());

                            /*
                             * if (KiThiLopHocSinhVien.Status.Equals(4))
                             *  KiThiLopHocSinhVien.Mota = string.Format("<div style='width: 80%;text-align: center;font-weight: bold;font-size: 20px;color: red;padding-top: 20px;'>Bài thi được {0:N2} điểm</div>", float.Parse(dtKiThiLopHocSinhVien.Rows[i]["Diem"].ToString()));
                             * //KiThiLopHocSinhVien.Mota = string.Format("Bài thi được {0:N2} điểm", float.Parse(dtKiThiLopHocSinhVien.Rows[i]["Diem"].ToString()));
                             *
                             * // Đã thi xong, thông báo và thoát
                             * spThongBao.InnerHtml = "Đăng nhập thành công";
                             * divScript.InnerHtml = "<script>  $('#myModal').modal('show');</script>";
                             * dangxuat();
                             * return;
                             */
                        }
                        else
                        {
                            KiThiLopHocSinhVien.TongThoiGianConLai = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianThi"].ToString()) * 60;
                            KiThiLopHocSinhVien.TongThoiGianThi    = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianThi"].ToString());
                        }
                        KiThiLopHocSinhViens.Add(KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, KiThiLopHocSinhVien);
                    }
                    Session[Utils.session_kithi_lophoc_cuusinhvien] = KiThiLopHocSinhViens;
                }

                spThongBao.InnerHtml = "Đăng nhập thành công";
                Response.Redirect(string.Format("/Khao_sat_cuu_sinh_vien.aspx"));
            }
            else
            {
                spThongBao.InnerHtml = "Đăng nhập thất bại";
            }
        }
Beispiel #11
0
        public static model.KiThiLopHocSinhVien chamBai(model.KiThiLopHocSinhVien KiThiLopHocSinhVien, string Answares)
        {
            float fTongDiem             = 0;
            float fTongDiemToiDa        = 0;
            List <model.DapAn> lsDapAns = JsonConvert.DeserializeObject <List <model.DapAn> >(KiThiLopHocSinhVien.DapAn);
            List <model.DapAn> lsAnswares;
            List <int>         lsDapAnIDs;

            // Tinh tong diem toi da
            foreach (model.DapAn DapAnTemp in lsDapAns)
            {
                if (!DapAnTemp.Type.Equals("TL"))
                {
                    fTongDiemToiDa += DapAnTemp.Mark;
                }
            }
            lsAnswares = convertListDapAnFromAnswares(Answares, out lsDapAnIDs);

            /*
             * // Xu ly chuoi Answare thanh list dap an
             * string[] strAnswareSplits = Answares.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             * foreach (string Answare in strAnswareSplits)
             * {
             *  string[] strSplitTemp = Answare.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
             *  int iIDTemp = -1;
             *  if (strSplitTemp.Length > 1 && int.TryParse(strSplitTemp[0].Trim(), out iIDTemp))
             *  {
             *      model.DapAn DapAnTemp1 = new model.DapAn() { CauHoiID = int.Parse(strSplitTemp[0].Trim()), Match = strSplitTemp[1].Trim() };
             *      lsAnswares.Add(DapAnTemp1);
             *      if (!lsDapAnIDs.Contains(iIDTemp))
             *      {
             *          lsDapAnIDs.Add(iIDTemp);
             *      }
             *  }
             * }*/
            // Xu ly cham diem
            foreach (int iID in lsDapAnIDs)
            {
                model.DapAn        DapAnTemp    = lsDapAns.Find(x => x.CauHoiID.Equals(iID));
                string             strMatchTemp = DapAnTemp.Match;
                List <model.DapAn> lsMatchs1    = new List <model.DapAn>();
                string[]           strSplitTemp = strMatchTemp.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string str in strSplitTemp)
                {
                    model.DapAn DapAnTemp1 = new model.DapAn()
                    {
                        CauHoiID = iID, Match = str
                    };
                    lsMatchs1.Add(DapAnTemp1);
                }
                List <model.DapAn> lsMatchs2 = lsAnswares.FindAll(x => x.CauHoiID.Equals(iID));

                lsMatchs1.Sort(delegate(model.DapAn x, model.DapAn y)
                {
                    if (x.Match == null && y.Match == null)
                    {
                        return(0);
                    }
                    else if (x.Match == null)
                    {
                        return(-1);
                    }
                    else if (y.Match == null)
                    {
                        return(1);
                    }
                    else
                    {
                        return(x.Match.CompareTo(y.Match));
                    }
                });

                lsMatchs2.Sort(delegate(model.DapAn x, model.DapAn y)
                {
                    if (x.Match == null && y.Match == null)
                    {
                        return(0);
                    }
                    else if (x.Match == null)
                    {
                        return(-1);
                    }
                    else if (y.Match == null)
                    {
                        return(1);
                    }
                    else
                    {
                        return(x.Match.CompareTo(y.Match));
                    }
                });

                if (lsMatchs1.Count > 1)
                {
                    int test = lsMatchs2.Count;
                }
                if (lsMatchs1.SequenceEqual(lsMatchs2))
                {
                    fTongDiem += DapAnTemp.Mark;
                }
            }
            KiThiLopHocSinhVien.Diem = (fTongDiem / fTongDiemToiDa) * 10;
            KiThiLopHocSinhVien.Mota = string.Format("Bài thi được {0:N1} điểm trên tổng số {1:N1} (Quy ra được {2:N2} điểm trên thang điểm 10) ", fTongDiem, fTongDiemToiDa, KiThiLopHocSinhVien.Diem);
            //KiThiLopHocSinhVien.Mota = string.Format("<div style='text-align: center;font-weight: bold;font-size: 20px;color: red;padding-top: 20px;'>{0}</div>", KiThiLopHocSinhVien.Mota);

            DateTime dtNopBai            = DateTime.Now;
            TimeSpan ts                  = dtNopBai.Subtract(KiThiLopHocSinhVien.NgayGioBatDau);
            int      iTongThoiGianConLai = KiThiLopHocSinhVien.TongThoiGianConLai - (ts.Hours * 60 * 60 + ts.Minutes * 60 + ts.Seconds);

            KiThiLopHocSinhVien.Status             = 4;
            KiThiLopHocSinhVien.BaiLam             = Answares;
            KiThiLopHocSinhVien.TongThoiGianConLai = iTongThoiGianConLai > 0 ? iTongThoiGianConLai : 0;
            return(KiThiLopHocSinhVien);
        }