protected override void InitPageTemplate(HttpContext context) { Song.Entities.Questions ques = Business.Do <IQuestions>().QuesSingle(qid); this.Document.SetValue("ques", ques); if (string.IsNullOrWhiteSpace(errtype) && string.IsNullOrWhiteSpace(errinfo)) { return; } if (string.IsNullOrWhiteSpace(ques.Qus_ErrorInfo)) { ques.Qus_WrongInfo = errtype + "\r" + errinfo; } else { ques.Qus_WrongInfo += "\r" + errtype + "\r" + errinfo; } try { ques.Qus_IsWrong = true; Business.Do <IQuestions>().QuesSave(ques); this.Document.SetValue("isSuccess", true); } catch { this.Document.SetValue("isSuccess", false); } }
/// <summary> /// 试题的答案 /// </summary> /// <param name="objs"></param> /// <returns></returns> protected string GetAnswer(object[] objs) { //当前试题 Song.Entities.Questions qus = null; if (objs.Length > 0) { qus = objs[0] as Song.Entities.Questions; } if (qus == null) { return(""); } string ansStr = ""; if (qus.Qus_Type == 1) { //当前试题的答案 Song.Entities.QuesAnswer[] ans = Business.Do <IQuestions>().QuestionsAnswer(qus, null); for (int i = 0; i < ans.Length; i++) { if (ans[i].Ans_IsCorrect) { ansStr += (char)(65 + i); } } } if (qus.Qus_Type == 2) { Song.Entities.QuesAnswer[] ans = Business.Do <IQuestions>().QuestionsAnswer(qus, null); for (int i = 0; i < ans.Length; i++) { if (ans[i].Ans_IsCorrect) { ansStr += (char)(65 + i) + "、"; } } ansStr = ansStr.Substring(0, ansStr.LastIndexOf("、")); } if (qus.Qus_Type == 3) { ansStr = qus.Qus_IsCorrect ? "正确" : "错误"; } if (qus.Qus_Type == 4) { if (qus != null && !string.IsNullOrEmpty(qus.Qus_Answer)) { ansStr = qus.Qus_Answer; } } if (qus.Qus_Type == 5) { //当前试题的答案 Song.Entities.QuesAnswer[] ans = Business.Do <IQuestions>().QuestionsAnswer(qus, null); for (int i = 0; i < ans.Length; i++) { ansStr += (char)(65 + i) + "、" + ans[i].Ans_Context + "<br/>"; } } return(ansStr); }
protected override void InitPageTemplate(HttpContext context) { //当前试题 Song.Entities.Questions qus = Business.Do <IQuestions>().QuesSingle(id); if (qus != null) { Song.Entities.Knowledge knl = Business.Do <IKnowledge>().KnowledgeSingle(qus.Kn_ID); this.Document.Variables.SetValue("knl", knl); } }
protected override void InitPageTemplate(HttpContext context) { //当前试题 Song.Entities.Questions qus = Business.Do <IQuestions>().QuesSingle(id); if (qus != null) { if (!string.IsNullOrWhiteSpace(qus.Qus_Explain)) { qus.Qus_Explain = qus.Qus_Explain.Replace("\n", "<br/>"); qus.Qus_Explain = Extend.Html.ClearHTML(qus.Qus_Explain, "font", "pre"); } this.Document.SetValue("explain", qus.Qus_Explain); } }
/// <summary> /// 处理试题的文本,用于前端显示 /// </summary> /// <param name="qs"></param> /// <returns></returns> public static Song.Entities.Questions TranText(Song.Entities.Questions qs) { if (qs == null) { return(qs); } qs.Qus_Title = _ClearAttr(qs.Qus_Title, new string[] { "p", "span", "pre", "font" }); qs.Qus_Title = Extend.Html.ClearHTML(qs.Qus_Title, "pre"); qs.Qus_Title = _tran(qs.Qus_Title); qs.Qus_Explain = _ClearAttr(qs.Qus_Explain, new string[] { "p", "span", "pre", "font" }); qs.Qus_Explain = _tran(qs.Qus_Explain); qs.Qus_Answer = _ClearAttr(qs.Qus_Answer, new string[] { "p", "span", "pre", "font" }); //qs.Qus_Answer = _tranAnswer(qs.Qus_Answer); return(qs); }
/// <summary> /// 当前试题的选项,仅用于单选与多选 /// </summary> /// <returns>0为没有子级,其它有子级</returns> protected object AnswerItems(object[] p) { Song.Entities.Questions qus = null; if (p.Length > 0) { qus = (Song.Entities.Questions)p[0]; } //当前试题的答案 Song.Entities.QuesAnswer[] ans = Business.Do <IQuestions>().QuestionsAnswer(qus, null); for (int i = 0; i < ans.Length; i++) { ans[i] = Extend.Questions.TranText(ans[i]); //ans[i].Ans_Context = ans[i].Ans_Context.Replace("<", "<"); //ans[i].Ans_Context = ans[i].Ans_Context.Replace(">", ">"); } return(ans); }
private string getAnserJson(Song.Entities.Questions q, string json) { //当前试题的答案 Song.Entities.QuesAnswer[] ans = Business.Do <IQuestions>().QuestionsAnswer(q, null); string ansStr = "["; for (int i = 0; i < ans.Length; i++) { ans[i] = Extend.Questions.TranText(ans[i]); ansStr += ans[i].ToJson(); if (i < ans.Length - 1) { ansStr += ","; } } ansStr += "]"; json = json.Replace("}", ",\"Answer\":" + ansStr + "}"); return(json); }
public void ProcessRequest(HttpContext context) { Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); context.Response.ContentType = "text/plain"; Song.Entities.Questions[] ques = Business.Do <IQuestions>().QuesRandom(org.Org_ID, sbjid, -1, -1, type, diff, diff, true, 1); string tm = ""; if (ques.Length > 0) { Song.Entities.Questions q = Extend.Questions.TranText(ques[0]); tm = q.ToJson(); //如果是单选题,或多选题 if (q.Qus_Type == 1 || q.Qus_Type == 2 || q.Qus_Type == 5) { tm = getAnserJson(q, tm); } } context.Response.Write(tm); context.Response.End(); }
/// <summary> /// 获取列表 /// </summary> private void list_note() { int size = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条 int index = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页 int stid = Extend.LoginState.Accounts.CurrentUser.Ac_ID; //当前学员 Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser; Song.Entities.Course currCourse = Extend.LoginState.Accounts.Course(); int sumcount = 0; Song.Entities.Student_Notes[] notes = Business.Do <IStudent>().NotesPager(stid, 0, null, size, index, out sumcount); string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ","; json += "\"items\":["; for (int n = 0; n < notes.Length; n++) { notes[n].Stn_Context = notes[n].Stn_Context.Replace("\r", "").Replace("\n", "").Replace("\t", ""); Song.Entities.Questions q = Business.Do <IQuestions>().QuesSingle(notes[n].Qus_ID); Dictionary <string, object> addParas = new Dictionary <string, object>(); if (q != null) { addParas.Add("Qus_Title", q.Qus_Title); } else { addParas.Add("Qus_Title", "试题不存在!"); } json += notes[n].ToJson(null, null, addParas) + ","; } if (json.EndsWith(",")) { json = json.Substring(0, json.Length - 1); } json += "]}"; Response.Write(json); Response.End(); }
/// <summary> /// 获取当前试题的笔记 /// </summary> /// <param name="objs"></param> /// <returns></returns> protected string GetNote(object[] objs) { //当前试题 Song.Entities.Questions qus = null; if (objs.Length > 0) { qus = objs[0] as Song.Entities.Questions; } if (qus == null) { return(""); } // Song.Entities.Student_Notes note = null; int acid = Extend.LoginState.Accounts.CurrentUserId; note = Business.Do <IStudent>().NotesSingle(qus.Qus_ID, acid); if (note == null) { return(""); } return(note.Stn_Context); }
protected override void InitPageTemplate(HttpContext context) { //题型 string[] types = WeiSha.Common.App.Get["QuesType"].Split(','); //试题 Song.Entities.Questions ques = Business.Do <IQuestions>().QuesSingle(qid); if (ques == null) { return; } ques = Extend.Questions.TranText(ques); ques.Qus_Title = ques.Qus_Title.Replace("<", "<"); ques.Qus_Title = ques.Qus_Title.Replace(">", ">"); ques.Qus_Title = ques.Qus_Title.Replace("\n", "<br/>"); ques.Qus_Title = Extend.Html.ClearHTML(ques.Qus_Title, "p", "div", "font"); // this.Document.SetValue("q", ques); this.Document.SetValue("quesType", types[ques.Qus_Type - 1]); this.Document.RegisterGlobalFunction(this.GetNote); this.Document.RegisterGlobalFunction(this.AnswerItems); this.Document.RegisterGlobalFunction(this.GetAnswer); this.Document.RegisterGlobalFunction(this.GetOrder); }