/*--------------------------------------------------------------------------*/ public int GetInsert(M_Exam_Sys_Questions model) { B_KeyWord keybll = new B_KeyWord(); keybll.AddKeyWord(model.Tagkey, 2); return(DBCenter.Insert(model)); }
public bool GetUpdate(M_Exam_Sys_Questions model) { B_KeyWord keybll = new B_KeyWord(); keybll.AddKeyWord(model.Tagkey, 2); return(DBCenter.UpdateByID(model, model.p_id)); }
private M_Exam_Sys_Questions FillMod() { M_Exam_Sys_Questions questMod = null; M_AdminInfo adminMod = B_Admin.GetLogin(); if (Mid > 0) { questMod = questBll.GetSelect(Mid); } else { questMod = new M_Exam_Sys_Questions(); //questMod.UserID = mu.UserID; //questMod.p_Inputer = mu.UserName; } questMod.p_title = txtP_title.Text; //questMod.p_Difficulty = DataConverter.CLng(rblDiff.SelectedValue); questMod.p_Difficulty = DataConverter.CDouble(Diffcult_T.Text); questMod.p_Class = DataConverter.CLng(NodeID_Hid.Value); //questMod.p_Shipin = QuestType_Hid.Value; questMod.p_Views = DataConverter.CLng(Grade_Radio.SelectedValue); questMod.p_Knowledge = DataConverter.CLng(Request.Form["knowname"]); string tagkey = Request.Form["Tabinput"]; if (string.IsNullOrEmpty(tagkey)) { questMod.Tagkey = ""; } else { int firstid = nodeBll.SelFirstNodeID(questMod.p_Class); questMod.Tagkey = knowBll.AddKnows(firstid, tagkey); } if (string.IsNullOrEmpty(AnswerHtml_T.Text)) { AnswerHtml_T.Text = Answer_T.Text; } questMod.p_Type = DataConverter.CLng(Request.Form["qtype_rad"]); questMod.p_shuming = AnswerHtml_T.Text; if (questMod.p_Type == 10) { questMod.p_Content = Qids_Hid.Value; questMod.LargeContent = txtP_Content.Text; } else { questMod.p_Content = txtP_Content.Text; } questMod.Qinfo = Qinfo_Hid.Value; questMod.p_ChoseNum = DataConverter.CLng(ddlNumber1.SelectedValue); questMod.IsBig = 0; questMod.p_Inputer = adminMod.AdminName; //后台试题强制分享 questMod.IsShare = 1;// IsShare_Chk.Checked ? 1 : 0; questMod.p_defaultScores = DataConverter.CFloat(txtDefaSocre.Text); questMod.p_Answer = Answer_T.Text.Trim(); //questMod.p_Optioninfo = Optioninfo_Hid.Value; questMod.Jiexi = txtJiexi.Value; questMod.Version = DataConverter.CLng(Version_Rad.SelectedValue); return(questMod); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindType(); int id = DataConverter.CLng(Request.QueryString["id"]); M_Exam_Sys_Questions mq = bq.GetSelect(id); if (mq != null && mq.p_id > 0) { this.ddlType.SelectedValue = mq.p_Type.ToString(); ddlType.Enabled = false; this.shuming.Text = mq.p_shuming.ToString(); hfpid.Value = mq.p_id.ToString(); txtP_Content.Text = mq.p_Content; hffilename.Value = mq.p_Shipin; txtCourse.Text = mq.p_defaultScores.ToString(); hfParentId.Value = mq.parentId.ToString(); ddlNumber1.SelectedValue = mq.p_ChoseNum.ToString(); hfoption.Value = SafeSC.ReadFileStr(M_Exam_Sys_Questions.OptionDir + mq.p_id + ".opt"); hfanw.Value = mq.p_Answer; } else { ddlType.Enabled = true; hfParentId.Value = Request.QueryString["p_Id"]; } option(); } Call.SetBreadCrumb(Master, "<li>教育模块</li><li><a href='QuestionManage.aspx'>在线考试系统</a></li><li>课程管理</li>"); }
public void Question_Add() { var model = new VM_Question(); M_Exam_Sys_Questions questMod = Question_FillMod(); if (Mid > 0) { questBll.GetUpdate(questMod); } else { questMod.p_id = questBll.GetInsert(questMod); } SafeSC.WriteFile(questMod.GetOPDir(), Request.Form["Optioninfo_Hid"]); if (model.IsSmall > 0)//判断当前是否是添加小题状态 { DataTable dt = questBll.SelByIDSForType(questMod.p_id.ToString()); string json = JsonConvert.SerializeObject(dt); //function.Script(this, "parent.SelQuestion(" + json + ")"); } else { function.WriteSuccessMsg("操作成功!", "QuestList?NodeID=" + model.NodeID); return; } }
public VM_Question(HttpContext ctx) { this.ctx = ctx; gradeDT = new B_GradeOption().GetGradeList(6, 0); verDT = verBll.Sel(); if (Mid > 0) { questMod = questBll.GetSelect(Mid); } }
private M_Exam_Sys_Questions Question_FillMod() { M_Exam_Sys_Questions questMod = null; if (Mid > 0) { questMod = questBll.GetSelect(Mid); } else { questMod = new M_Exam_Sys_Questions(); questMod.UserID = mu.UserID; questMod.p_Inputer = mu.UserName; } questMod.p_title = Request.Form["p_title"]; //questMod.p_Difficulty = DataConverter.CLng(rblDiff.SelectedValue); questMod.p_Difficulty = DataConverter.CDouble(Request.Form["Diffcult_T"]); questMod.p_Class = DataConverter.CLng(Request.Form["TreeTlp_hid"]); //questMod.p_Shipin = QuestType_Hid.Value; questMod.p_Views = DataConverter.CLng(Request.Form["Grade_Rad"]); questMod.p_Knowledge = DataConverter.CLng(Request.Form["knowname"]); string tagkey = Request.Form["Tabinput"]; if (string.IsNullOrEmpty(tagkey)) { questMod.Tagkey = ""; } else { int firstid = clsBll.SelFirstNodeID(questMod.p_Class); questMod.Tagkey = knowBll.AddKnows(firstid, tagkey, 0, false); } questMod.p_Type = DataConverter.CLng(Request.Form["qtype_rad"]); questMod.p_shuming = string.IsNullOrEmpty(Request.Form["AnswerHtml_T"]) ? Request.Form["Answer_T"] : Request.Form["AnswerHtml_T"]; if (questMod.p_Type == 10) { questMod.p_Content = Request.Form["Qids_Hid"]; questMod.LargeContent = Request.Form["txtP_Content"]; } else { questMod.p_Content = Request.Form["txtP_Content"]; } questMod.Qinfo = Request.Form["Qinfo_Hid"]; questMod.p_ChoseNum = DataConverter.CLng(Request.Form["p_ChoseNum_DP"]); questMod.IsBig = 0; questMod.IsShare = string.IsNullOrEmpty(Request.Form["IsShare_Chk"]) ? 1 : 0; questMod.p_defaultScores = DataConverter.CFloat(Request.Form["p_defaultScores"]); questMod.p_Answer = Request.Form["p_Answer"]; //questMod.p_Optioninfo = Optioninfo_Hid.Value; questMod.Jiexi = Request.Form["txtJiexi"]; questMod.Version = DataConverter.CLng(Request.Form["Version_Rad"]); return(questMod); }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void EBtnSubmit_Click(object sender, EventArgs e) { string[] cont = GetContent(); bq = new B_Exam_Sys_Questions(); int id = DataConverter.CLng(hfpid.Value); M_Exam_Sys_Questions questions = bq.GetSelect(id); questions.p_Shipin = hffilename.Value; questions.p_shuming = this.shuming.Text; questions.p_Content = this.txtP_Content.Text; questions.p_ChoseNum = DataConverter.CLng(ddlNumber1.SelectedValue); questions.p_defaultScores = DataConverter.CFloat(txtCourse.Text); if (cont != null && cont.Length > 0) { questions.p_Answer = cont[1]; } if (cont != null && cont.Length > 0) { SafeSC.WriteFile(M_Exam_Sys_Questions.OptionDir + id + ".opt", cont[0]); } //questions.p_Optioninfo = cont[0]; if (id > 0) //修改 { bool result = bq.GetUpdate(questions); if (result) { function.WriteSuccessMsg("修改成功!"); Response.Write("<script>window.close();</script>"); } else { function.WriteErrMsg("修改失败!"); } } else //添加 { questions.p_Type = DataConverter.CLng(ddlType.SelectedValue); questions.p_Inputer = badmin.GetAdminLogin().AdminName; //当前登录ID questions.p_CreateTime = DateTime.Now.Date; questions.p_Views = 1; questions.parentId = DataConverter.CLng(hfParentId.Value); int result = bq.GetInsert(questions); if (result > 0) { Response.Write("<script>alert('添加成功!');window.close();</script>"); } else { function.WriteErrMsg("添加失败!"); } } }
public VM_Question(M_UserInfo mu) { gradeDT = B_GradeOption.GetGradeList(6, 0); verDT = verBll.Sel(); if (Mid > 0) { questMod = questBll.GetSelect(Mid); if (questMod.UserID != mu.UserID) { function.WriteErrMsg("你无权修改该试题"); } } }
private M_Exam_Sys_Questions Question_FillMod() { M_Exam_Sys_Questions questMod = null; if (Mid > 0) { questMod = questBll.GetSelect(Mid); } else { questMod = new M_Exam_Sys_Questions(); M_UserInfo mu = buser.GetLogin(); questMod.UserID = mu.UserID; questMod.p_Inputer = mu.UserName; } questMod.p_title = Request.Form["p_title"]; questMod.p_Difficulty = DataConverter.CDouble(Request.Form["p_Difficulty"]); questMod.p_Class = DataConverter.CLng(Request.Form["TreeTlp_hid"]); questMod.p_Views = DataConverter.CLng(Request.Form["p_Views"]); questMod.p_Knowledge = DataConverter.CLng(Request.Form["knowname"]); string tagkey = Request.Form["tabinput"]; if (string.IsNullOrEmpty(tagkey)) { questMod.Tagkey = ""; } else { int firstid = clsBll.SelFirstNodeID(questMod.p_Class); questMod.Tagkey = knowBll.AddKnows(firstid, tagkey, 0); } questMod.p_Type = DataConverter.CLng(Request.Form["qtype_rad"]); questMod.p_shuming = Request.Form["p_shuming"] ?? Request.Form["p_Answer"]; questMod.p_Answer = Request.Form["p_Answer"]; if (questMod.p_Type == 10) { questMod.p_Content = Request.Form["Qids_Hid"]; questMod.LargeContent = Request.Form["p_Content"]; } else { questMod.p_Content = Request.Form["p_Content"]; } questMod.Qinfo = Request.Form["Qinfo_Hid"]; questMod.p_ChoseNum = DataConverter.CLng(Request.Form["p_ChoseNum_DP"]); questMod.IsBig = 0; questMod.IsShare = string.IsNullOrEmpty(Request.Form["IsShare"]) ? 1 : 0; questMod.p_defaultScores = DataConverter.CFloat(Request.Form["p_defaultScores"]); questMod.Jiexi = Request.Form["Jiexi"]; questMod.Version = DataConverter.CLng(Request.Form["Version"]); return(questMod); }
public ActionResult QuestShow() { M_Exam_Sys_Questions model = questBll.GetSelect(Mid); if (model == null) { function.WriteErrMsg("试题不存在"); return(null); } DataTable dt = questBll.SelByIDSForExam(model.p_id.ToString()); dt.DefaultView.RowFilter = "pid>0"; dt.DefaultView.Sort = "order desc"; ViewBag.questDt = dt.DefaultView.ToTable(); return(View(model)); }
public IActionResult Question_Add() { var model = new VM_Question(HttpContext); M_Exam_Sys_Questions questMod = Question_FillMod(); if (Mid > 0) { questBll.GetUpdate(questMod); } else { questMod.p_id = questBll.GetInsert(questMod); } SafeSC.WriteFile(questMod.GetOPDir(), RequestEx["Optioninfo_Hid"]); return(WriteOK("操作成功!", "QuestList?NodeID=" + model.NodeID)); }
public void Question_Add() { var model = new VM_Question(); M_Exam_Sys_Questions questMod = Question_FillMod(); if (Mid > 0) { questBll.GetUpdate(questMod); } else { questMod.p_id = questBll.GetInsert(questMod); } SafeSC.WriteFile(questMod.GetOPDir(), Request.Form["Optioninfo_Hid"]); function.WriteSuccessMsg("操作成功!", "QuestList?NodeID=" + model.NodeID); }
public ActionResult SmallQuest_Add() { M_Exam_Sys_Questions questMod = Question_FillMod(); questMod.IsSmall = 1; if (Mid > 0) { questBll.GetUpdate(questMod); } else { questMod.p_id = questBll.GetInsert(questMod); } DataTable dt = questBll.SelByIDSForType(questMod.p_id.ToString()); string json = JsonConvert.SerializeObject(dt); return(Content("<Script>parent.SelQuestion(" + json + "," + Mid + ");</Script>")); }
public ActionResult AddSmallQuest() { int Pid = DataConverter.CLng(Request.QueryString["pid"]); M_Exam_Sys_Questions questMod = questBll.GetSelect(Mid); if (questMod.p_id <= 0 && Pid > 0) { M_Exam_Sys_Questions pMod = questBll.GetSelect(Pid); questMod.p_Difficulty = pMod.p_Difficulty; questMod.p_Class = pMod.p_Class; questMod.Tagkey = pMod.Tagkey; questMod.IsShare = pMod.IsShare; questMod.p_defaultScores = pMod.p_defaultScores; questMod.Jiexi = pMod.Jiexi; questMod.Version = pMod.Version; } return(View(questMod)); }
public void MyBind() { M_Exam_Sys_Questions model = questionBll.GetSelect(QID); if (model == null) { function.WriteErrMsg("无效id!"); } Title_L.Text = model.p_title; Grade_L.Text = B_GradeOption.GetGradeOption(model.p_Views).GradeName; Diff_L.Text = questionBll.GetDiffStr(model.p_Difficulty); QType_L.Text = M_Exam_Sys_Questions.GetTypeStr(model.p_Type); if (!string.IsNullOrEmpty(model.Tagkey)) { KeyWord_L.Text = knowBll.GetNamesByIDS(model.Tagkey); } Content_Li.Text = model.p_Content; if (model.p_Type == 10) { Content_Li.Text = model.LargeContent; Option_Li.Visible = false; Quest_RPT.Visible = true; DataTable dt = questionBll.SelByIDSForExam(model.p_id.ToString()); dt.DefaultView.RowFilter = "pid>0"; dt.DefaultView.Sort = "order desc"; Quest_RPT.DataSource = dt; Quest_RPT.DataBind(); } else { Option_Li.Text = questionBll.GetSubmit(model.p_id, model.p_Type, ref AngularJS); } Socre_L.Text = model.p_defaultScores.ToString(); QuestNum_L.Text = model.p_ChoseNum.ToString(); Answer_L.Text = model.p_Answer; AnswerHtml_Li.Text = model.p_shuming; Jiexi_Li.Text = model.Jiexi; }
// 保存 protected void EBtnSubmit_Click(object sender, EventArgs e) { M_Exam_Sys_Questions questMod = FillMod(); if (Mid > 0) { questBll.GetUpdate(questMod); } else { questMod.p_id = questBll.GetInsert(questMod); } SafeSC.WriteFile(questMod.GetOPDir(), Optioninfo_Hid.Value); if (IsSmall > 0)//判断当前是否是添加小题状态 { DataTable dt = questBll.SelByIDSForType(questMod.p_id.ToString()); string json = JsonConvert.SerializeObject(dt); function.Script(this, "parent.SelQuestion(" + json + ")"); } else { function.WriteSuccessMsg("操作完成!", "QuestList.aspx?NodeID=" + NodeID); } }
//根据IDS计算出各类型题的数目,给Js展示 public string GetCountByIDS(string ids) { ids = ids ?? ""; ids = ids.Trim(','); string result = ""; string sql = "SELECT p_Type as type,typestr='',COUNT(*) AS count FROM " + strTableName + " WHERE p_id IN(" + ids + ") GROUP BY p_Type"; if (string.IsNullOrEmpty(ids)) { return(result); } SafeSC.CheckIDSEx(ids); DataTable dt = SqlHelper.ExecuteTable(CommandType.Text, sql); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["typestr"] = M_Exam_Sys_Questions.GetTypeStr(DataConvert.CLng(dt.Rows[i]["type"])); } result = JsonConvert.SerializeObject(dt); } return(result); }
//取题型 public string GetType(string id) { return(M_Exam_Sys_Questions.GetTypeStr(DataConverter.CLng(id))); }
//自动校验答案 private M_Exam_Answer CheckIsRight(M_Exam_Answer answerMod) { M_Exam_Sys_Questions questMod = questBll.GetSelect(answerMod.QID); if (string.IsNullOrEmpty(questMod.p_Answer)) { answerMod.IsRight = NOAUDIT; return(answerMod); } switch (questMod.MyQType) { case M_Exam_Sys_Questions.QType.Radio: answerMod.IsRight = answerMod.Answer.Equals(questMod.p_Answer) ? RIGHT : ERROR; break; case M_Exam_Sys_Questions.QType.Multi: //检测是否包含指定选项,数量不能有差异,顺序可以不计 { answerMod.Answer = answerMod.Answer.TrimEnd(','); string[] answerArr = answerMod.Answer.Split(','); string[] rightArr = questMod.p_Answer.Split('|'); if (answerArr.Length != rightArr.Length) { answerMod.IsRight = ERROR; break; } foreach (string answer in answerArr) { if (!rightArr.Contains(answer)) { answerMod.IsRight = ERROR; break; } } answerMod.IsRight = RIGHT; } break; case M_Exam_Sys_Questions.QType.FillBlank: { //检测是否包含指定选项,数量不能有差异,需要按顺序 answerMod.Answer = answerMod.Answer.TrimEnd("|".ToCharArray()); string[] answerArr = Regex.Split(answerMod.Answer, Regex.Escape("|||")); string[] rightArr = questMod.p_Answer.Split('|'); if (answerArr.Length != rightArr.Length) { answerMod.IsRight = ERROR; break; } for (int i = 0; i < answerArr.Length; i++) { if (answerArr[i] != rightArr[i]) { answerMod.IsRight = ERROR; break; } } answerMod.IsRight = RIGHT; } break; case M_Exam_Sys_Questions.QType.Answer: { //解析题如果答案相符则计对,否则人工审核 answerMod.Answer = answerMod.Answer.Trim().TrimStart("解:".ToCharArray()); answerMod.IsRight = answerMod.Answer.Equals(questMod.p_Answer) ? RIGHT : NOAUDIT; } break; } return(answerMod); }
protected void Page_Load(object sender, EventArgs e) { Call.HideBread(Master); if (!IsPostBack) { if (NodeID > 0) { M_Exam_Class nodeMod = nodeBll.GetSelect(NodeID); CurNode_L.Text = "[" + nodeMod.C_ClassName + "]"; } else { nodetr.Style.Remove("display"); } if (Grade > 0) { CurNode_L.Text += "[" + B_GradeOption.GetGradeOption(Grade).GradeName + "]"; Grade_Radio.SelectedValue = Grade.ToString(); } //-------------- GetQuesType(); InitQuestGrade(); if (Mid > 0) { SaveNew_Btn.Visible = true; M_Exam_Sys_Questions questMod = questBll.GetSelect(Mid); if (questMod != null && questMod.p_id > 0) { txtP_title.Text = questMod.p_title; //rblDiff.SelectedValue = questMod.p_Difficulty.ToString(); Diffcult_T.Text = questMod.p_Difficulty.ToString("f2"); AnswerHtml_T.Text = questMod.p_shuming; Grade_Radio.SelectedValue = questMod.p_Views.ToString(); if (!string.IsNullOrEmpty(questMod.Tagkey)) { TagKey_T.Value = knowBll.GetNamesByIDS(questMod.Tagkey); } //TagKey_T.Text = questMod.Tagkey; NodeID_Hid.Value = questMod.p_Class.ToString(); txtP_Content.Text = questMod.p_Content; if (questMod.p_Type == 10) { txtP_Content.Text = questMod.LargeContent; } txtDefaSocre.Text = questMod.p_defaultScores.ToString(); Qinfo_Hid.Value = questMod.Qinfo; ddlNumber1.SelectedValue = questMod.p_ChoseNum.ToString(); Optioninfo_Hid.Value = SafeSC.ReadFileStr(questMod.GetOPDir()); Answer_T.Text = questMod.p_Answer; txtJiexi.Value = questMod.Jiexi; IsShare_Chk.Checked = questMod.IsShare == 1; Version_Rad.SelectedValue = questMod.Version.ToString(); function.Script(this, "SetRadVal('qtype_rad'," + questMod.p_Type + ");"); } } else { if (NodeID > 0) { NodeID_Hid.Value = NodeID.ToString(); } } } }
public ActionResult QuestView() { M_Exam_Sys_Questions questMod = questBll.GetSelect(Mid); return(View(questMod)); }