//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_answer_record", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.answer_record bll = new BLL.answer_record(); Model.answer_record model = bll.GetModel(this.id); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.user_id = Convert.ToInt32(txtuser_id.Text); model.exa_id = Convert.ToInt32(txtexa_id.Text); model.q_id = Convert.ToInt32(txtq_id.Text); model.answer = Convert.ToString(txtanswer.Text); model.is_truth = Convert.ToInt32(txtis_truth.Text); model.score = Convert.ToInt32(txtscore.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改答题记录信息,主键:" + id); //记录日志 JscriptMsg("修改答题记录信息成功!", "Manage.aspx"); } else { JscriptMsg("保存过程中发生错误!", ""); } }
private void SetAnswerIsTruth() { int id = RequestHelper.GetFormInt("id"); int score = RequestHelper.GetFormInt("score"); BLL.answer_record bll = new BLL.answer_record(); Model.answer_record model = bll.GetModel(id); if (model != null) { if (model.is_truth == (int)EnumCollection.YesOrNot.是) { model.is_truth = (int)EnumCollection.YesOrNot.否; } else if (model.is_truth == (int)EnumCollection.YesOrNot.否) { model.is_truth = (int)EnumCollection.YesOrNot.是; } else { score = 0; } model.score = score; bll.Update(model); SumScore(model.exa_id, model.user_id); } }
private void BindData() { #region 组装查询条件 string whereStr = " 1 = 1 "; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", "")); return; } } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.answer_record bll = new BLL.answer_record(); this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("Manage.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_answer_record", EnumCollection.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.answer_record bll = new BLL.answer_record(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除答题记录" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", this.keywords)); }
private void SetAnswerScore() { int id = RequestHelper.GetFormInt("id"); int score = RequestHelper.GetFormInt("score"); BLL.answer_record bll = new BLL.answer_record(); Model.answer_record model = bll.GetModel(id); if (model != null) { model.score = score; bll.Update(model); } }
private void BindInfo() { BLL.answer_record bll = new BLL.answer_record(); Model.answer_record model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtgroup_id.Text = model.group_id + ""; txtuser_id.Text = model.user_id + ""; txtexa_id.Text = model.exa_id + ""; txtq_id.Text = model.q_id + ""; txtanswer.Text = model.answer + ""; txtis_truth.Text = model.is_truth + ""; txtscore.Text = model.score + ""; txtadd_time.Text = model.add_time + ""; }
private void BindData() { Model.common_questions quModel = new BLL.common_questions().GetModel(this.id); if (quModel == null) { JscriptMsg("没有此题目", "back"); return; } this.question = quModel.title; #region 组装查询条件 string whereStr = " group_id = " + (int)EnumCollection.examination_group.课堂作业 + " and exa_id = " + this.exa_id + " and q_id = " + this.id; string _keywords = keywords.Replace("'", ""); if (!string.IsNullOrEmpty(_keywords)) { if (Utils.IsSafeSqlString(_keywords)) { whereStr += " and (Title like '%" + _keywords + "%')"; } else { JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("currect_answer_list.aspx", "keywords={0}", "")); return; } } #endregion this.page = RequestHelper.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.answer_record bll = new BLL.answer_record(); this.rptList.DataSource = bll.GetListByPage("*", "View_Currect_Question", whereStr, "id", this.page, this.pageSize); this.rptList.DataBind(); this.totalCount = bll.GetRecordCount(whereStr); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("currect_answer_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_answer_record", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4) { strError += "分组ID为空或超出长度![br]"; } if (txtuser_id.Text.Trim() == "" || txtuser_id.Text.Trim().Length > 4) { strError += "答题者ID为空或超出长度![br]"; } if (txtexa_id.Text.Trim() == "" || txtexa_id.Text.Trim().Length > 4) { strError += "试卷ID为空或超出长度![br]"; } if (txtq_id.Text.Trim() == "" || txtq_id.Text.Trim().Length > 4) { strError += "题目ID为空或超出长度![br]"; } if (txtanswer.Text.Trim() == "" || txtanswer.Text.Trim().Length > 4000) { strError += "答案为空或超出长度![br]"; } if (txtis_truth.Text.Trim() == "" || txtis_truth.Text.Trim().Length > 4) { strError += "结果为空或超出长度![br]"; } if (txtscore.Text.Trim() == "" || txtscore.Text.Trim().Length > 4) { strError += "为空或超出长度![br]"; } if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8) { strError += "完成时间为空或超出长度![br]"; } if (strError != string.Empty) { JscriptMsg(strError, "", "Error"); return; } #endregion Model.answer_record model = new Model.answer_record(); BLL.answer_record bll = new BLL.answer_record(); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.user_id = Convert.ToInt32(txtuser_id.Text); model.exa_id = Convert.ToInt32(txtexa_id.Text); model.q_id = Convert.ToInt32(txtq_id.Text); model.answer = Convert.ToString(txtanswer.Text); model.is_truth = Convert.ToInt32(txtis_truth.Text); model.score = Convert.ToInt32(txtscore.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加答题记录信息,主键:" + id); //记录日志 JscriptMsg("添加答题记录信息成功!", "Manage.aspx", ""); } else { JscriptMsg("保存过程中发生错误!", ""); } }
private void SumScore(int exa_id, int uid) { int truth_count = 0; int score = 0; BLL.common_questions qBll = new BLL.common_questions(); BLL.answer_record arBll = new BLL.answer_record(); BLL.common_answers aBll = new BLL.common_answers(); Model.user_info user = new BLL.user_info().GetModel(uid); Model.common_examination exa = new BLL.common_examination().GetModel(exa_id); if (exa != null) { DataTable dt = arBll.GetList(" exa_id = " + exa_id + " and user_id = " + uid); foreach (DataRow item in dt.Rows) { #region 批改作业按老师选择对错为准 int is_truth = Convert.ToInt32(item["is_truth"]); if (is_truth == 1) { truth_count++; score += Convert.ToInt32(item["score"]); } #endregion #region 批改作业按答题记录为准 //int q_id = Convert.ToInt32(item["q_id"]); //string answer = item["answer"].ToString(); //Model.common_questions question = qBll.GetModel(q_id); //if (!string.IsNullOrEmpty(answer))//没有答题 //{ // if (question.type == (int)EnumCollection.questions_type.单选题 || question.type == (int)EnumCollection.questions_type.判断题) // { // Model.common_answers anModel = aBll.GetModel(Convert.ToInt32(answer)); // if (anModel.options == question.answer) // { // truth_count++; // score += Convert.ToInt32(item["score"]); // } // } // if (question.type == (int)EnumCollection.questions_type.多选题) // { // string[] ids = answer.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // string anids = string.Empty; // foreach (string id in ids) // { // Model.common_answers anModel = aBll.GetModel(Convert.ToInt32(id)); // anids += anModel.options + ","; // } // if (question.answer == Utils.DelLastComma(anids)) // { // truth_count++; // score += Convert.ToInt32(item["score"]); // } // } // if (question.type == (int)EnumCollection.questions_type.填空题 || question.type == (int)EnumCollection.questions_type.主观题) // { // if (answer.Contains(question.answer)) // { // truth_count++; // score += Convert.ToInt32(item["score"]); // } // } //} #endregion } BLL.answer_result bll = new BLL.answer_result(); Model.answer_result model = bll.GetModel(" group_id = " + (int)EnumCollection.examination_group.课堂作业 + " and exa_id = " + exa_id + " and user_id = " + uid); if (model != null) { model.truth_num = truth_count; model.count = exa.nums; model.truth_ratio = Convert.ToDecimal((decimal)model.truth_num / (decimal)model.count) * 100; model.score = score; model.status = (int)EnumCollection.correcting_status.已批改; bll.Update(model); } else { model = new Model.answer_result(); model.group_id = (int)EnumCollection.examination_group.课堂作业; model.exa_id = exa_id; model.exa_title = exa.name; model.user_id = uid; model.avatar = user.avatar; model.nick_name = user.nick_name; model.use_min = 0; model.use_sec = 0; model.truth_num = truth_count; model.count = exa.nums; model.truth_ratio = 0; model.score = score; model.status = (int)EnumCollection.correcting_status.未批改; model.add_time = System.DateTime.Now; bll.Add(model); } } }