/// <summary> /// 考卷预览试卷 /// </summary> /// <param name="singleList"></param> /// <param name="judgeList"></param> /// <returns></returns> public ActionResult ViewSelectedPaper(string paperTitle, string singleList, string judgeList) { // 教师选中的试卷题目数据 DataTable singleTable = new SingleBLL().GetSingleList(singleList); DataTable judgeTable = new JudgeBLL().GetJudgeList(judgeList); DataSet dataSet = new DataSet(); dataSet.Tables.Add(singleTable); dataSet.Tables.Add(judgeTable); if (singleTable.Rows.Count > 0 && judgeTable.Rows.Count > 0) { return(Content(new AjaxResult { state = ResultType.success.ToString(), data = dataSet }.ToJson())); } else { return(Content(new AjaxResult { state = ResultType.info.ToString(), data = null, message = "试卷预览失败,题量出错!" }.ToJson())); } }
/// <summary> /// 考试信息发布页面显示 /// </summary> /// <returns></returns> public ActionResult ExamRelease() { // 获取教师信息 User user = (User)Session["User"]; Guid userId = user.ID; DataTable userTable = new TeacherBLL().GetTeacher(userId); ViewBag.TeacherName = userTable.Rows[0]["Name"]; ViewBag.CourseName = userTable.Rows[0]["CourseName"]; // 教师任课的所有班级 DataTable classTable = new ClassBLL().GetTeacherAllClass(userId); // 教师专业的题库数据 Guid courseId = Guid.Parse(userTable.Rows[0]["CourseID"].ToString()); DataTable singleTable = new SingleBLL().GetSingleOptinsByCourse(courseId); DataTable judegTable = new JudgeBLL().GetJudgeOptinsByCourse(courseId); // 打包DataSet传到前端 DataSet ds = new DataSet(); ds.Tables.Add(singleTable); ds.Tables.Add(judegTable); ds.Tables.Add(classTable); return(View(ds)); }
public bool Update(JudgeBLL judge1) { bool isSuccess = false; SqlConnection conn = new SqlConnection(UserDAL.myconnstrng); try { string sql = "UPDATE tbl_Judge1 SET Score1=@Score1, Score2=@Score2, Score3=@Score3, Score4=@Score4, Score5=@Score5, Score6=@Score6, Score7=@Score7, Score8=@Score8, Score9=@Score9, Score10=@Score10, Score11=@Score11, Score12=@Score12, Score13=@Score13, Score14=@Score14, Score15=@Score15 WHERE JudgeID=@Judge1ID"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Score1", judge1.Score1); cmd.Parameters.AddWithValue("@Score2", judge1.Score2); cmd.Parameters.AddWithValue("@Score3", judge1.Score3); cmd.Parameters.AddWithValue("@Score4", judge1.Score4); cmd.Parameters.AddWithValue("@Score5", judge1.Score5); cmd.Parameters.AddWithValue("@Score6", judge1.Score6); cmd.Parameters.AddWithValue("@Score7", judge1.Score7); cmd.Parameters.AddWithValue("@Score8", judge1.Score8); cmd.Parameters.AddWithValue("@Score9", judge1.Score9); cmd.Parameters.AddWithValue("@Score10", judge1.Score10); cmd.Parameters.AddWithValue("@Score11", judge1.Score11); cmd.Parameters.AddWithValue("@Score12", judge1.Score12); cmd.Parameters.AddWithValue("@Score13", judge1.Score13); cmd.Parameters.AddWithValue("@Score14", judge1.Score14); cmd.Parameters.AddWithValue("@Score15", judge1.Score15); cmd.Parameters.AddWithValue("@Judge1ID", judge1.JudgeID); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { // Query successful isSuccess = true; } else { // Query failed isSuccess = false; } } catch (Exception ex) { // Throw message if any error occurs MessageBox.Show(ex.Message, "Update data in Database Information!", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { conn.Close(); } return(isSuccess); }
/// <summary> /// 开始考试 /// </summary> /// <returns></returns> public ActionResult BeginExam(Guid guid) { DataTable table_paper = new ExaminationBLL().GetExamByID(guid); // 获取试卷信息 // 检测考试是否过期 if (table_paper.Rows.Count == 0) { return(RedirectToAction("../Student/ExamOnline")); } // 给前台传递试卷信息 ViewBag.PaperName = table_paper.Rows[0]["PaperTitle"].ToString(); // 试卷名称 ViewBag.ReleaseTime = Convert.ToDateTime(table_paper.Rows[0]["ReleaseTime"]).ToString("yyyy年MM月dd日HH时mm分"); // 发布时间 ViewBag.CourseName = table_paper.Rows[0]["CourseName"].ToString(); // 科目名 ViewBag.TeacherName = table_paper.Rows[0]["Name"].ToString(); // 教师名 ViewBag.RollOutTime = table_paper.Rows[0]["RollOutTime"].ToString(); // 考试时长 // 选择题信息 string single_list = table_paper.Rows[0]["SingleList"].ToString(); DataTable single_table = new SingleBLL().GetSingleList(single_list, "desc"); // 选择题信息列表 // 判断题信息 string judge_list = table_paper.Rows[0]["JudgeList"].ToString(); DataTable judge_table = new JudgeBLL().GetJudgeList(judge_list, "desc"); // 判断题信息列表 // 选择题排序规则 string single_option = table_paper.Rows[0]["SingleOption"].ToString(); DataTable s_option_table = GetOptionsTable(single_option); // 选择题选项排序规则 // 判断题排序规则 string judge_option = table_paper.Rows[0]["JudgeOption"].ToString(); DataTable j_option_table = GetOptionsTable(judge_option); // 判断题选项排序规则 // 打包提交 DataSet dataSet = new DataSet(); dataSet.Tables.Add(single_table); dataSet.Tables.Add(s_option_table); dataSet.Tables.Add(judge_table); dataSet.Tables.Add(j_option_table); // 试卷信息 Session["PaperID"] = guid; Session["PaperOptions"] = dataSet; // 试卷题目所有信息(包含排序规则) return(View(dataSet)); }
/// <summary> /// 历史考试详细信息 /// </summary> /// <param name="guid"></param> /// <returns></returns> public ActionResult HistoryExam(Guid guid) { DataTable table_paper = new ResultDetailBLL().GethistoryDetailByID(guid); // 获取试卷信息 // 给前台传递试卷信息 ViewBag.PaperName = table_paper.Rows[0]["PaperTitle"].ToString(); // 试卷名称 ViewBag.ReleaseTime = Convert.ToDateTime(table_paper.Rows[0]["ReleaseTime"]).ToString("yyyy年MM月dd日HH时mm分"); // 发布时间 ViewBag.CourseName = table_paper.Rows[0]["CourseName"].ToString(); // 科目名 ViewBag.TeacherName = table_paper.Rows[0]["Name"].ToString(); // 教师名 ViewBag.RollOutTime = table_paper.Rows[0]["RollOutTime"].ToString(); ViewBag.ResultPoint = table_paper.Rows[0]["Result"].ToString(); ViewBag.OverTime = Convert.ToDateTime(table_paper.Rows[0]["OverTime"]).ToString("yyyy/MM/dd HH:mm"); // 提交时间 // 选择题信息 string single_list = table_paper.Rows[0]["SingleList"].ToString(); DataTable single_table = new SingleBLL().GetSingleList(single_list, "desc"); // 选择题信息列表 // 判断题信息 string judge_list = table_paper.Rows[0]["JudgeList"].ToString(); DataTable judge_table = new JudgeBLL().GetJudgeList(judge_list, "desc"); // 判断题信息列表 // 选择题排序规则 string single_option = table_paper.Rows[0]["SingleOption"].ToString(); DataTable s_option_table = GetOptionsTable(single_option); // 选择题选项排序规则 // 判断题排序规则 string judge_option = table_paper.Rows[0]["JudgeOption"].ToString(); DataTable j_option_table = GetOptionsTable(judge_option); // 判断题选项排序规则 // 用户选择答案 string user_select = table_paper.Rows[0]["SelectList"].ToString(); DataTable select_table = GetOptionsTable(user_select); // 打包提交 DataSet dataSet = new DataSet(); dataSet.Tables.Add(single_table); dataSet.Tables.Add(s_option_table); dataSet.Tables.Add(judge_table); dataSet.Tables.Add(j_option_table); dataSet.Tables.Add(select_table); return(View(dataSet)); }
public bool Insert(JudgeBLL judge1) { bool isSuccess = false; SqlConnection conn = new SqlConnection(UserDAL.myconnstrng); try { string sql = "INSERT INTO tbl_Judge1 (candidate1, candidate2, candidate3) VALUES (@candidate1, @candidate2, @candidate3)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@candidate1", judge1.Score1); cmd.Parameters.AddWithValue("@candidate2", judge1.Score2); cmd.Parameters.AddWithValue("@candidate3", judge1.Score3); conn.Open(); int rows = cmd.ExecuteNonQuery(); // If the query is executed successfully then the value to rows will be greaten than 0 else it will be less than 0 if (rows > 0) { // Query successful isSuccess = true; } else { // Query failed isSuccess = false; } } catch (Exception ex) { // Throw message if any error occurs MessageBox.Show(ex.Message, "Insert data in Database Information!", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { conn.Close(); } return(isSuccess); }
// Top 5 Judge 5 #region Update1Judge5Top5 data in Database public bool Update1Judge5Top5(JudgeBLL updateCandNoAndCandName) { bool isSuccess = false; SqlConnection conn = new SqlConnection(UserDAL.myconnstrng); try { string sql = "UPDATE tbl_Judge5Top5 SET CandidateNo=@CandidateNo1, CandidateName=@CandidateName1 WHERE CandidateID=1"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@CandidateNo1", updateCandNoAndCandName.CandidateNo1); cmd.Parameters.AddWithValue("@CandidateName1", updateCandNoAndCandName.CandidateName1); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { // Query successful isSuccess = true; } else { // Query failed isSuccess = false; } } catch (Exception ex) { // Throw message if any error occurs MessageBox.Show(ex.Message, "Update data in Database Information!", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { conn.Close(); } return(isSuccess); }
public bool Delete(JudgeBLL judge1) { bool isSuccess = false; SqlConnection conn = new SqlConnection(UserDAL.myconnstrng); try { string sql = "DELETE FROM tbl_Judge1 WHERE JudgeID=@Judge1ID"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Judge1ID", judge1.JudgeID); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { // Query successful isSuccess = true; } else { // Query failed isSuccess = false; } } catch (Exception ex) { // Throw message if any error occurs MessageBox.Show(ex.Message, "Delete data from Database Information!", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { conn.Close(); } return(isSuccess); }
public bool UpdateDependency1(JudgeBLL judge1) { bool isSuccess = false; SqlConnection conn = new SqlConnection(UserDAL.myconnstrng); try { string sql = "UPDATE tbl_Dependency SET Score=@Score WHERE ScoreNo=2"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Score", judge1.Total); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { // Query successful isSuccess = true; } else { // Query failed isSuccess = false; } } catch (Exception ex) { // Throw message if any error occurs MessageBox.Show(ex.Message, "Update data in Database Information!", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { conn.Close(); } return(isSuccess); }