/// <summary> /// 创建分类的页面呈现 /// </summary> /// <returns></returns> public ActionResult SortEdit() { int id = Convert.ToInt32(Request.QueryString["id"]); tbQuestionSort sort = id > 0 ? ESortBL.GetSingleByID(id) : new tbQuestionSort(); ViewData["model"] = sort; if (Request.QueryString["fatherID"] != null) { ViewData["fatherModel"] = Request.QueryString["fatherID"] == "0" ? CommonLanguage.Common_TreeFootName : ESortBL.GetAllQuestionSortDictionary()[ Request.QueryString["fatherID"].StringToInt32()].Title; ViewData["fatherID"] = Request.QueryString["fatherID"]; } else { if (id > 0) { ViewData["fatherModel"] = sort.FatherID == 0 ? CommonLanguage.Common_TreeFootName : ESortBL.GetAllQuestionSortDictionary()[sort.FatherID].Title; ViewData["fatherID"] = sort.FatherID; } else { ViewData["fatherModel"] = CommonLanguage.Common_TreeFootName; ViewData["fatherID"] = 0; } } return(View()); }
/// <summary> /// 创建分类的页面呈现 /// </summary> /// <returns></returns> public ActionResult SortEdit() { int id = Convert.ToInt32(Request.QueryString["id"]); tbQuestionSort sort = id > 0 ? ESortBL.GetSingleByID(id) : new tbQuestionSort { TenantId = CurrentTenant.TenantId }; ViewData["model"] = sort; if (Request.QueryString["fatherID"] != null) { ViewData["fatherModel"] = Request.QueryString["fatherID"] == "0" ? CurrentTenant.TenantName // RetechWing.LanguageResources.Common.Common_TreeFootName : ESortBL.GetAllQuestionSortDictionary(CurrentTenant.TenantId)[ Request.QueryString["fatherID"].GetInt32()].Title; ViewData["fatherID"] = Request.QueryString["fatherID"]; } else { if (id > 0) { ViewData["fatherModel"] = sort.FatherID == 0 ? CurrentTenant.TenantName //RetechWing.LanguageResources.Common.Common_TreeFootName : ESortBL.GetAllQuestionSortDictionary(CurrentTenant.TenantId)[sort.FatherID].Title; ViewData["fatherID"] = sort.FatherID; } else { ViewData["fatherModel"] = CurrentTenant.TenantName;// RetechWing.LanguageResources.Common.Common_TreeFootName; ViewData["fatherID"] = 0; } } return(View()); }
/// <summary> /// 修改试题库 /// </summary> /// <param name="SortID"></param> /// <param name="qSort"></param> /// <returns></returns> public int ModifyByID(int SortID, tbQuestionSort qSort) { try { MongoCollection <tbQuestionSort> coll = BaseDB.CreateInstance().GetCollection <tbQuestionSort>("tbQuestionSort"); var update = new UpdateDocument { { "FatherID", qSort.FatherID }, { "Title", qSort.Title }, { "Description", qSort.Description }, { "Status", qSort.Status } }; coll.Update(Query.EQ("_id", SortID), update); return(SortID); } catch { return(0); } finally { BaseDB.MongoService.Disconnect(); } }
public EasyuiTreeNode AddQuestionSortChild(tbQuestionSort sort, List <tbQuestionSort> list) { var node = new EasyuiTreeNode { id = sort._id.ToString(), text = sort.Title }; var tmp = list.Where(p => p.FatherID == sort._id); if (tmp.Count() > 0) { foreach (var item in tmp) { node.children.Add(AddQuestionSortChild(item, list)); } } return(node); }
/// <summary> /// 修改试题库 /// </summary> /// <param name="SortID"></param> /// <param name="qSort"></param> /// <returns></returns> public int ModifyByID(int SortID, tbQuestionSort qSort) { qSort._id = SortID; Modify(qSort); return(SortID); }
/// <summary> /// 保存问题分类 /// </summary> /// <returns></returns> public JsonResult SubmitQuestionSort() { int id = Request.QueryString["id"].StringToInt32(); int pId = Request.Form["hidfatherID"].StringToInt32(); if (ESortBL.IsExsitName(pId, id, Request.Form["txtSortName"].Trim())) { if (id == 0) { //添加 int newid = ESortBL.Insert(new tbQuestionSort { Description = Request.Form["txtMemo"], Title = Request.Form["txtSortName"], FatherID = pId, Status = 0, _id = 0 }); if (newid > 0) { return(Json(new { result = 1, content = "保存成功" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = 0, content = "提交失败" }, JsonRequestBehavior.AllowGet)); } } else { //修改 tbQuestionSort sort = ESortBL.GetSingleByID(id); sort.Description = Request.Form["txtMemo"]; sort.Title = Request.Form["txtSortName"]; int newid = ESortBL.ModifyByID(id, sort); if (newid > 0) { return(Json(new { result = 1, content = "保存成功" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = 0, content = "提交失败" }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { result = 0, content = "已存在此题库名称" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 添加试题分类 /// </summary> /// <param name="questionSort">试题分类</param> /// <returns></returns> public int Insert(tbQuestionSort questionSort) { return(sortDB.Insert(questionSort)); }
/// <summary> /// 修改试题分类 /// </summary> /// <param name="questionSort">试题分类</param> /// <returns></returns> public int Modify(tbQuestionSort questionSort) { sortDB.Modify <tbQuestionSort>(questionSort); return(questionSort._id); }
public JsonResult SubmitQuestionSort() { int id = Request.QueryString["id"].GetInt32(); int pId = Request.Form["hidfatherID"].GetInt32(); string sortName = Request.Form["txtSortName"].Trim(); if (ESortBL.IsExsitName(pId, id, sortName, CurrentTenant.TenantId)) { var level = sortName; if (pId > 0) { var parent = ESortBL.GetSingleByID(pId); level = parent.LevelPath + "/" + level; } if (id == 0) { //添加 int newid = ESortBL.Insert(new tbQuestionSort { Description = Request.Form["txtMemo"], Title = Request.Form["txtSortName"], FatherID = pId, Status = 0, _id = 0, TenantId = CurrentTenant.TenantId, LevelPath = level }); if (newid > 0) { return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet)); } } else { //修改 tbQuestionSort sort = ESortBL.GetSingleByID(id); if (sort == null) { return(Json(new { result = 0, content = RetechWing.LanguageResources.Exam.Question.message14 }, JsonRequestBehavior.AllowGet)); } if (sort.TenantId != CurrentTenant.TenantId) { return(Json(new { result = 0, content = RetechWing.LanguageResources.Exam.Question.message14 }, JsonRequestBehavior.AllowGet)); } string tmpSortLevelPath = sort.LevelPath; sort.Description = Request.Form["txtMemo"]; sort.Title = sortName; sort.LevelPath = level; int newid = ESortBL.Modify(sort); if (newid > 0) { List <tbQuestionSort> allList = ESortBL.GetAllQuestionSortList(CurrentTenant.TenantId); List <tbQuestionSort> list = new List <tbQuestionSort>(); GetChildSort(id, allList, list); if (list.Count > 0) { foreach (var item in list) { item.LevelPath = ("✈卐卍" + item.LevelPath).Replace(("✈卐卍" + tmpSortLevelPath), level); ESortBL.Modify(item); } } return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { result = 0, content = RetechWing.LanguageResources.Exam.Question.message13 }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 修改试题库 /// </summary> /// <param name="SortID"></param> /// <param name="qSort"></param> /// <returns></returns> public int ModifyByID(int SortID, tbQuestionSort qSort) { return(sortDB.ModifyByID(SortID, qSort)); }
/// <summary> /// 查看试卷呈现 /// </summary> public ViewResult ExampaperDetail(int flag = 0) { int id = Convert.ToInt32(Request.QueryString["id"]); tbExampaper expape = EBL.GetExampaper(id); List <ReExampaperQuestion> questionList = expape.QuestionList; List <ReRuleQuestion> ruleList = expape.QuestionRule; var itemArray = new List <tbQuestion>(); if (questionList.Count > 0) { //遍历试卷问题ID,获取题目 foreach (ReExampaperQuestion Pquestion in questionList) { tbQuestion baseInfor = qBL.GetSingleByID(Pquestion.Qid); baseInfor.QuestionAnswer = baseInfor.QuestionAnswer.OrderByDescending(p => p.AnswerFlag).ToList(); itemArray.Add(baseInfor); } } var itemArray1 = new List <MExamRuleShow>(); if (ruleList.Count > 0) { foreach (ReRuleQuestion qRule in ruleList) { var eq = new MExamRuleShow(); eq.QuestingScore = qRule.QScore; switch (qRule.Qtype) { case 1: //问答题 eq.QuestionType = "问答题"; break; case 2: //单选题 eq.QuestionType = "单选题"; break; case 3: //多选题 eq.QuestionType = "多选题"; break; case 4: //判断题 eq.QuestionType = "判断题"; break; case 5: //填空题 eq.QuestionType = "填空题"; break; case 6: //情景题 eq.QuestionType = "情景题"; break; } tbQuestionSort qSort = qSortBL.GetSingleByID(qRule.QSort); eq.QuestionSort = qSort.Title; string[] questionLevel = qRule.QLevelStr.Split(';'); string[] Easy = questionLevel[0].Split(':'); string[] Common = questionLevel[1].Split(':'); string[] Hard = questionLevel[2].Split(':'); eq.Leveleasy = Convert.ToInt32(Easy[1]); eq.Levelcommon = Convert.ToInt32(Common[1]); eq.Levelhard = Convert.ToInt32(Hard[1]); string qit1 = qRule.Qtype + "|" + qRule.QSort; string qit = qRule.Qtype + "|" + qRule.QSort + "|" + qRule.QScore + "|" + Easy[1] + "|" + Common[1] + "|" + Hard[1]; eq.qita = qit; eq.qitaone = qit1; itemArray1.Add(eq); } } if (Request.QueryString["sortID"] != null) { if (flag == 1) { ViewData["fatherModel"] = eSortBL.GetAllExampaperSortDictionary().Keys.Contains(expape.ExamSortID) ? eSortBL.GetAllExampaperSortDictionary()[expape.ExamSortID].Title : "无"; } else { ViewData["fatherModel"] = Request.QueryString["SortID"] == "0" ? Exampaper.NO : eSortBL.GetAllExampaperSortDictionary()[ Convert.ToInt32(Request.QueryString["sortID"])].Title; } } else { ViewData["fatherModel"] = Exampaper.NO; } ViewData["expape"] = expape; ViewData["expapeQuestion"] = itemArray; ViewData["expapeRule"] = itemArray1; return(View()); }