//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_answer_result", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.answer_result bll = new BLL.answer_result(); Model.answer_result model = bll.GetModel(this.id); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.exa_id = Convert.ToInt32(txtexa_id.Text); model.exa_title = Convert.ToString(txtexa_title.Text); model.user_id = Convert.ToInt32(txtuser_id.Text); model.avatar = Convert.ToString(txtavatar.Text); model.nick_name = Convert.ToString(txtnick_name.Text); model.use_min = Convert.ToInt32(txtuse_min.Text); model.use_sec = Convert.ToInt32(txtuse_sec.Text); model.truth_num = Convert.ToInt32(txttruth_num.Text); model.count = Convert.ToInt32(txtcount.Text); model.truth_ratio = Convert.ToDecimal(txttruth_ratio.Text); model.score = Convert.ToInt32(txtscore.Text); model.status = Convert.ToInt32(txtstatus.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 BindInfo() { BLL.answer_result bll = new BLL.answer_result(); Model.answer_result model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtgroup_id.Text = model.group_id + ""; txtexa_id.Text = model.exa_id + ""; txtexa_title.Text = model.exa_title + ""; txtuser_id.Text = model.user_id + ""; txtavatar.Text = model.avatar + ""; txtnick_name.Text = model.nick_name + ""; txtuse_min.Text = model.use_min + ""; txtuse_sec.Text = model.use_sec + ""; txttruth_num.Text = model.truth_num + ""; txtcount.Text = model.count + ""; txttruth_ratio.Text = model.truth_ratio + ""; txtscore.Text = model.score + ""; txtstatus.Text = model.status + ""; txtadd_time.Text = model.add_time + ""; }
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); } } }