public string getHtmlDeThi(KiThiLopHocSinhVien KiThiLopHocSinhVien, out string strScript) { List <DapAn> dapAn; DapAn dapAn1; strScript = "function InitData() {"; string strScriptTemp = ""; string strHtml = string.Format("<div style='width: 100%; text-align:center; padding-bottom: 10px; padding-top: 10px; font-weight: bold; color:red;'>{0}</div>", KiThiLopHocSinhVien.Mota); List <CauHoi> lsCauHois = JsonConvert.DeserializeObject <List <CauHoi> >(KiThiLopHocSinhVien.NoiDungDeThi); //List<DapAn> lsDapAns = JsonConvert.DeserializeObject<List<DapAn>>(KiThiLopHocSinhVien.DapAn); string strAnswares = KiThiLopHocSinhVien.BaiLam; List <DapAn> lsAnswares = Utils.convertListDapAnFromAnswares(strAnswares); List <DapAn> lsDapAns = JsonConvert.DeserializeObject <List <DapAn> >(KiThiLopHocSinhVien.DapAn); int l = 0; int l1 = 0; strHtml += string.Format("<div style='width: 100%; text-align:left; padding-bottom: 2px; padding-top: 2px;padding-left: 10px;padding-right: 10px;'>"); foreach (CauHoi cauhoi in lsCauHois) { l++; dapAn = lsAnswares.FindAll(x => x.CauHoiID.Equals(cauhoi.CauHoiID)); //string strMatch = dapAn != null ? dapAn.Match : ""; //strMatch = ";" + strMatch + ";"; dapAn1 = lsDapAns.Find(x => x.CauHoiID.Equals(cauhoi.CauHoiID)); //string strMatchDapAn = dapAn1 != null ? dapAn1.Match : ""; //strMatchDapAn = ";" + strMatchDapAn + ";"; string strType = cauhoi.Type; switch (strType) { case "SC": case "MC": case "TQ": case "FQ": strHtml += getDivRowHtmlNormal(cauhoi, dapAn, dapAn1, l, l * 20, l.ToString(), "blue", out strScriptTemp); strScript += strScriptTemp; #region loai binh thuong #endregion break; case "TL": strHtml += string.Format("<div id='divCauHoi_{0}' style='width: 100%;color:blue; text-align:left; padding-bottom: 2px; padding-top: 2px;'><span style='font-weight: bold;'>Câu {0}: </span><span>{1}</span></div>", l, HttpUtility.HtmlDecode(cauhoi.Content)); if (!(cauhoi.Image.ToUpper().Equals("") || cauhoi.Image.ToUpper().Equals("NULL"))) { strHtml += string.Format("<div style='width: 100%;text-align:center; padding-bottom: 2px; padding-top: 2px;'><image src='/Portals/{0}/{1}' hight='100px;'></image></div>", "0", cauhoi.Image); } if (cauhoi.ChildCauHois != null && cauhoi.ChildCauHois.Count > 0) { l1 = 0; foreach (CauHoi cauhoi1 in cauhoi.ChildCauHois) { l1++; strHtml += "<div style='padding-left:10px;'>"; dapAn = lsAnswares.FindAll(x => x.CauHoiID.Equals(cauhoi1.CauHoiID)); dapAn1 = lsDapAns.Find(x => x.CauHoiID.Equals(cauhoi1.CauHoiID)); strHtml += getDivRowHtmlNormal(cauhoi1, dapAn, dapAn1, l, l * 20 + l1, string.Format("{0}.{1}", l, l1), "green", out strScriptTemp); strHtml += "</div>"; strScript += strScriptTemp; } } break; } } strHtml += "</div>"; // strScript += " alert (' hi hi');};"; strScript += " };"; return(strHtml); }
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; } KiThiLopHocSinhVien KiThiLopHocSinhVien = m_KiThiLopHocSinhViens[iKiThiLopHocSinhVienID]; //string strMoTa = "<div style='padding-left:20%;width: 80%;text-align: center;font-weight: bold;font-size: 12px;color: red;padding-top: 20px;'>"; string strMoTa = string.Format("<table style='border-collapse: separate; margin:10px;'>"); strMoTa += string.Format("<tr><td style='color:red;font-weight: bold;'>Mã: </td><td style='padding-right:50px;'> {0}</td>", m_SinhVien.MaSV); strMoTa += string.Format("<td style='color:red;font-weight: bold;'>Tên thí sinh: </td><td> {0} {1}</td></tr>", m_SinhVien.Ho, m_SinhVien.Ten); if (KiThiLopHocSinhVien.Status.Equals(3) || KiThiLopHocSinhVien.Status.Equals(4) || KiThiLopHocSinhVien.Status.Equals(5)) { //strMoTa += string.Format("<tr><td style='color:red;font-weight: bold;'>Mã đề: </td><td>{0}/td>", KiThiLopHocSinhVien.MaDe); //strMoTa += string.Format("<td style='color:red;font-weight: bold;'>Ngày nộp bài: </td><td>{0:dd/MM/yyyy - hh:mm:ss}</td></tr>", KiThiLopHocSinhVien.NgayGioBatDau); //strMoTa += string.Format("<tr><td style='color:red;font-weight: bold;'>Tổng thời gian thi: </td><td>{0} phút</td>", KiThiLopHocSinhVien.TongThoiGianThi); //strMoTa += string.Format("<td style='color:red;font-weight: bold;'>Tổng thời gian còn lại: </td><td>{0} phút {1} giây</td></tr>", KiThiLopHocSinhVien.TongThoiGianConLai / 60, KiThiLopHocSinhVien.TongThoiGianConLai % 60); //strMoTa += string.Format("<tr><td style='color:red;font-weight: bold;'>Điểm: </td><td>{0:N2}</td>", KiThiLopHocSinhVien.Diem); //strMoTa += string.Format("<td style='color:red;font-weight: bold;'>Địa chỉ nộp bài: </td><td>{0}</td></tr>", ""); } // strMoTa += string.Format("<tr><td style='color:red;font-weight: bold;'>Ghi chú: </td><td colspan='3'>{0}</td></tr>", KiThiLopHocSinhVien.Mota); strMoTa += "</table>"; //strMoTa += "</div>"; KiThiLopHocSinhVien.Mota = strMoTa; //KiThiLopHocSinhVien.Mota = string.Format("Bài thi được {0:N2} điểm", float.Parse(dtKiThiLopHocSinhVien.Rows[i]["Diem"].ToString())); string strScript = "<script>"; if (KiThiLopHocSinhVien.Status.Equals(1) || KiThiLopHocSinhVien.Status.Equals(2) || KiThiLopHocSinhVien.Status.Equals(8) || KiThiLopHocSinhVien.Status.Equals(6) || KiThiLopHocSinhVien.Status.Equals(9)) { divMenu.Visible = false; writeLog("Canh Bao", "Ket qua thi voi ma de " + KiThiLopHocSinhVien.MaDe + " là: " + KiThiLopHocSinhVien.Mota); //divContent.InnerHtml = KiThiLopHocSinhVien.Mota; } else { divMenu.Visible = true; // status=2: Chuan bi thi // status=3: Dang thi // status=4: Da thi xong // status=5: Thi tiep // status=6: thi lai if (KiThiLopHocSinhVien.Status.Equals(3)) { // Co the la truong hop refresh TimeSpan ts = DateTime.Now.Subtract(KiThiLopHocSinhVien.NgayGioBatDau); int iTongThoiGianConLai = KiThiLopHocSinhVien.TongThoiGianConLai - (ts.Hours * 60 * 60 + ts.Minutes * 60 + ts.Seconds); KiThiLopHocSinhVien.TongThoiGianConLai = iTongThoiGianConLai; } strScript += string.Format("var iIDKiThiLopHocSinhVien={0};", KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien); List <CauHoi> lsCauHois = JsonConvert.DeserializeObject <List <CauHoi> >(KiThiLopHocSinhVien.NoiDungDeThi); int iSoCauHoi = lsCauHois.Count; string strHtmlMenuCauHoi = "<table style='width:90%; margin: 0 auto;' border='1px'>"; int iSoCauHoi6 = iSoCauHoi / 6; if (iSoCauHoi > 0) { for (int i = 0; i < iSoCauHoi / 6; i++) { strHtmlMenuCauHoi += "<tr>"; strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", (i * 6) + 1); strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", (i * 6) + 2); strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", (i * 6) + 3); strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", (i * 6) + 4); strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", (i * 6) + 5); strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", (i * 6) + 6); strHtmlMenuCauHoi += "</tr>"; } } if (iSoCauHoi - iSoCauHoi6 * 6 > 0) { strHtmlMenuCauHoi += "<tr>"; for (int i = iSoCauHoi6 * 6 + 1; i <= iSoCauHoi; i++) { strHtmlMenuCauHoi += string.Format("<td id='tdMenuCauHoi_{0}' onclick='gotocauhoi({0});' style='background: rgb(230, 230, 230) none repeat scroll 0% 0%; text-align: center; font-weight: bold; padding: 3px; color: red; cursor: pointer;'>{0}</td>", i); } for (int i = iSoCauHoi + 1; i <= iSoCauHoi6 * 6 + 6; i++) { strHtmlMenuCauHoi += string.Format("<td></td>"); } strHtmlMenuCauHoi += "</tr>"; } strHtmlMenuCauHoi += "</table>"; divMenuCauHoi.InnerHtml = strHtmlMenuCauHoi; string strOutScript = ""; //divContent.InnerHtml = getHtmlDeThi(KiThiLopHocSinhVien, out strOutScript); divProcessData.InnerHtml = string.Format("<script>{0}</script>", strOutScript); m_KiThiLopHocSinhVien = KiThiLopHocSinhVien; spanThoiGianNopBai.InnerHtml = KiThiLopHocSinhVien.NgayGioNopBai.ToString("dd/MM/yyyy HH:mm"); spanDiemThi.InnerHtml = m_KiThiLopHocSinhVien.Diem.ToString(); //divContent.InnerHtml = KiThiLopHocSinhVien.MaDe + "---" + KiThiLopHocSinhVien.NoiDungDeThi + "---" + KiThiLopHocSinhVien.DapAn; } strScript += "</script>"; divInitData.InnerHtml = strScript; } }
protected void Page_Load(object sender, EventArgs e) { string strData = "-1"; try { #region KiThiLopHocSinhVien SinhVien sv = new SinhVien(); sv = (SinhVien)Session[Utils.session_sinhvien]; DataTable dtKiThiLopHocSinhVien = dnn_NuceThi_KiThi_LopHoc_SinhVien.getBySinhVien(sv.SinhVienID); Dictionary <int, KiThiLopHocSinhVien> KiThiLopHocSinhViens = new Dictionary <int, KiThiLopHocSinhVien>(); if (dtKiThiLopHocSinhVien.Rows.Count > 0) { int iLenghKiThiLopHocSinhVien = dtKiThiLopHocSinhVien.Rows.Count; for (int i = 0; i < iLenghKiThiLopHocSinhVien; i++) { model.KiThiLopHocSinhVien KiThiLopHocSinhVien = new KiThiLopHocSinhVien(); KiThiLopHocSinhVien.BoDeID = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["BoDeID"].ToString()); KiThiLopHocSinhVien.DeThiID = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["DeThiID"].ToString()); KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["KiThi_LopHoc_SinhVienID"].ToString()); KiThiLopHocSinhVien.Status = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["Status"].ToString()); KiThiLopHocSinhVien.StatusKiThi = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["StatusKiThi"].ToString()); KiThiLopHocSinhVien.TenBlockHoc = dtKiThiLopHocSinhVien.Rows[i]["PhongThi"].ToString(); KiThiLopHocSinhVien.TenKiThi = dtKiThiLopHocSinhVien.Rows[i]["TenKiThi"].ToString(); KiThiLopHocSinhVien.TenMonHoc = dtKiThiLopHocSinhVien.Rows[i]["TenMonHoc"].ToString(); KiThiLopHocSinhVien.NoiDungDeThi = dtKiThiLopHocSinhVien.Rows[i]["NoiDungDeThi"].ToString(); KiThiLopHocSinhVien.DapAn = dtKiThiLopHocSinhVien.Rows[i]["DapAn"].ToString(); KiThiLopHocSinhVien.Diem = float.Parse(dtKiThiLopHocSinhVien.Rows[i]["Diem"].ToString()); KiThiLopHocSinhVien.BaiLam = dtKiThiLopHocSinhVien.Rows[i]["BaiLam"].ToString(); KiThiLopHocSinhVien.TenBoDe = dtKiThiLopHocSinhVien.Rows[i]["TenBoDe"]?.ToString(); KiThiLopHocSinhVien.MaDe = dtKiThiLopHocSinhVien.Rows[i].IsNull("MaDe") ? "" : dtKiThiLopHocSinhVien.Rows[i]["MaDe"].ToString(); KiThiLopHocSinhVien.NgayGioBatDau = dtKiThiLopHocSinhVien.Rows[i].IsNull("NgayGioBatDau") ? DateTime.Now : DateTime.Parse(dtKiThiLopHocSinhVien.Rows[i]["NgayGioBatDau"].ToString()); KiThiLopHocSinhVien.NgayGioNopBai = dtKiThiLopHocSinhVien.Rows[i].IsNull("NgayGioNopBai") ? DateTime.Now : DateTime.Parse(dtKiThiLopHocSinhVien.Rows[i]["NgayGioNopBai"].ToString()); KiThiLopHocSinhVien.LoaiDe = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["LoaiDe"].ToString()); KiThiLopHocSinhVien.ThoiGianNopTruoc = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["tuluan_thoigiannoptruoc"].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]["ThoiGianThi"].ToString()); if (KiThiLopHocSinhVien.Status.Equals(4)) { KiThiLopHocSinhVien.Mota = string.Format("<div style='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())); } } else { KiThiLopHocSinhVien.TongThoiGianConLai = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["TongThoiGianConLai"].ToString()); KiThiLopHocSinhVien.TongThoiGianThi = int.Parse(dtKiThiLopHocSinhVien.Rows[i]["ThoiGianThi"].ToString()); } KiThiLopHocSinhViens.Add(KiThiLopHocSinhVien.KiThi_LopHoc_SinhVien, KiThiLopHocSinhVien); } Session[Utils.session_kithi_lophoc_sinhvien] = KiThiLopHocSinhViens; } #endregion strData = JsonConvert.SerializeObject(KiThiLopHocSinhViens, Formatting.Indented); } catch (Exception ex) { strData = ex.Message; } Response.Clear(); Response.ContentType = "text/plain"; Response.Write(strData); }