protected override void InitPageTemplate(HttpContext context) { Song.Entities.TestResults result = Business.Do <ITestPaper>().ResultsSingle(trid); if (result == null) { return; } this.Document.Variables.SetValue("result", result); //试卷 Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle((int)result.Tp_Id); this.Document.Variables.SetValue("pager", tp); //考生 Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle((int)result.Ac_ID); this.Document.Variables.SetValue("st", st); //加载答题信息 resXml.LoadXml(result.Tr_Results, false); //获取试题项 Song.Entities.TestPaperItem[] tpi = getTpi(tp); this.Document.Variables.SetValue("tpi", tpi); //计算得分 this.Document.RegisterGlobalFunction(this.getTypeName); this.Document.RegisterGlobalFunction(this.getTypeNumber); this.Document.RegisterGlobalFunction(this.getAnswerCount); this.Document.RegisterGlobalFunction(this.getSucessCount); this.Document.RegisterGlobalFunction(this.getErrorCount); //展示答题状态 this.Document.RegisterGlobalFunction(this.getQues); this.Document.RegisterGlobalFunction(this.getItems); //计算答题状态等 this.Document.RegisterGlobalFunction(this.getAnswerState); //获取学员答题内容与正确答案 this.Document.RegisterGlobalFunction(this.getResult); this.Document.RegisterGlobalFunction(this.getSucessAnswer); this.Document.RegisterGlobalFunction(this.getQuesScore); }
/// <summary> /// 填充“当按课程出题时”的各项题题分值 /// </summary> /// <param name="uid"></param> private void _fillItemForAll(Song.Entities.TestPaper tp) { Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForAll(tp); for (int i = 0; i < this.rptItemForAll.Items.Count; i++) { //当前索引行的试题类型 Song.Entities.TestPaperItem pi = null; foreach (Song.Entities.TestPaperItem p in tpi) { if (p.TPI_Type == i + 1) { pi = p; } } if (pi == null) { continue; } //几道题 TextBox tbCount = (TextBox)this.rptItemForAll.Items[i].FindControl("tbItemCount"); //占多少分数比 TextBox tbScore = (TextBox)this.rptItemForAll.Items[i].FindControl("tbItemScore"); //占多少分 Label lbNumber = (Label)this.rptItemForAll.Items[i].FindControl("lbItemNumber"); TextBox tbNumber = (TextBox)this.rptItemForAll.Items[i].FindControl("tbItemNumber"); tbCount.Text = pi.TPI_Count.ToString(); lbNumber.Text = tbNumber.Text = pi.TPI_Number.ToString(); tbScore.Text = pi.TPI_Percent.ToString(); } }
protected override void InitPageTemplate(HttpContext context) { this.Document.SetValue("action", action); this.Document.SetValue("tpid", tpid); //唯一值 string uid = WeiSha.Common.Request.UniqueID(); this.Document.Variables.SetValue("uid", uid); //服务器端时间 this.Document.Variables.SetValue("Time", WeiSha.Common.Server.getTime()); if (!Extend.LoginState.Accounts.IsLogin) { this.Response.Redirect("Login.ashx"); } //当前试卷 paper = Business.Do <ITestPaper>().PagerSingle(tpid); this.Document.SetValue("pager", paper); //试卷所属课程 Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(paper.Cou_ID); this.Document.SetValue("course", course); //启始页状态 if (string.IsNullOrWhiteSpace(action)) { // } //开始考试 if (action == "start") { //题型 this.Document.SetValue("quesType", WeiSha.Common.App.Get["QuesType"].Split(',')); //取果是第一次打开,则随机生成试题,此为获取试卷 //难度区间 int diff1 = paper.Tp_Diff > paper.Tp_Diff2 ? (int)paper.Tp_Diff2 : (int)paper.Tp_Diff; int diff2 = paper.Tp_Diff > paper.Tp_Diff2 ? (int)paper.Tp_Diff : (int)paper.Tp_Diff2; //当前选中的课程 Song.Entities.Course currCourse = Extend.LoginState.Accounts.Course(); //开始抽题 List <Song.Entities.Questions> ques = new List <Entities.Questions>(); Dictionary <TestPaperItem, Song.Entities.Questions[]> dic = Business.Do <ITestPaper>().Putout(paper); foreach (var d in dic) { Song.Entities.Questions[] qs = (Song.Entities.Questions[])d.Value; for (int n = 0; n < qs.Length; n++) { qs[n].Qus_Explain = ""; qs[n].Qus_Answer = ""; qs[n] = Extend.Questions.TranText(qs[n]); qs[n].Qus_Title = qs[n].Qus_Title.Replace("<", "<"); qs[n].Qus_Title = qs[n].Qus_Title.Replace(">", ">"); qs[n].Qus_Title = Extend.Html.ClearHTML(qs[n].Qus_Title, "p", "div"); ques.Add(qs[n]); } } this.Document.SetValue("ques", ques); this.Document.RegisterGlobalFunction(this.getQuesType); this.Document.RegisterGlobalFunction(this.AnswerItems); this.Document.RegisterGlobalFunction(this.GetOrder); this.Document.RegisterGlobalFunction(this.IsCollect); } }
/// <summary> /// 判断当前考试是否要显示“批阅试卷”按钮 /// </summary> /// <param name="examid"></param> /// <returns></returns> protected bool getIsCorrect(object examid) { int id = Convert.ToInt32(examid); //考生数,如果没有人考试,则不需要批阅 int students = Business.Do <IExamination>().Number4Exam(id); if (students < 1) { return(false); } Song.Entities.Examination exas = Business.Do <IExamination>().ExamSingle(id); Song.Entities.TestPaper pager = Business.Do <ITestPaper>().PagerSingle(exas.Tp_Id); if (pager == null) { return(false); } Song.Entities.TestPaperItem[] items = Business.Do <ITestPaper>().GetItemForAny(pager); foreach (Song.Entities.TestPaperItem ti in items) { if (ti.TPI_Type == 4) { return(true); } } return(false); }
/// <summary> /// 随机出题 /// </summary> /// <returns></returns> private string randomJson() { //取果是第一次打开,则随机生成试题,此为获取试卷 Song.Entities.TestPaper pager = Business.Do <ITestPaper>().PagerSingle(tpid); Dictionary <TestPaperItem, Questions[]> dics = Business.Do <ITestPaper>().Putout(pager); //生成试卷 // List <Questions> list = new List <Questions>(); //缓存 string json = "["; foreach (var di in dics) { //++++++++按题型输出 Song.Entities.TestPaperItem pi = (Song.Entities.TestPaperItem)di.Key; //试题类型 Song.Entities.Questions[] ques = (Song.Entities.Questions[])di.Value; //当前类型的试题 int type = (int)pi.TPI_Type; //试题类型 int count = ques.Length; //试题数目 float num = (float)pi.TPI_Number; //占用多少分 if (count < 1) { continue; } string tpiJosn = "{'type':'" + type + "','count':'" + count + "','number':'" + num + "',"; tpiJosn += "'ques':["; tpiJosn = tpiJosn.Replace("'", "\""); //++++++++试题输出 string quesJson = string.Empty; for (int n = 0; n < ques.Length; n++) { quesJson += getQuesJson(ques[n]) + ","; list.Add(ques[n]); //存入列表,用于缓存存储 } if (quesJson.EndsWith(",")) { quesJson = quesJson.Substring(0, quesJson.Length - 1); } //--------试题输出结束 tpiJosn += quesJson + "]}"; json += tpiJosn + ","; //--------按题型输出结束 } if (json.EndsWith(",")) { json = json.Substring(0, json.Length - 1); } json += "]"; //缓存 if (list.Count > 0) { string uid = string.Format("ExamResults:{0}-{1}-{2}", examid, tpid, stid); //缓存的uid Song.Entities.Examination exam = Business.Do <IExamination>().ExamSingle(examid); if (exam != null) { Random rn = new Random(stid); Business.Do <IQuestions>().CacheAdd(list.ToArray <Song.Entities.Questions>(), exam.Exam_Span + rn.Next(10), uid); } } return(json); }
/// <summary> /// 填充“当按章节出题时”的各项题题分值 /// </summary> /// <param name="tp"></param> private void _fileItemForOutline(Song.Entities.TestPaper tp) { //各题型的占比 Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForOlPercent(tp); if (tpi == null) { return; } for (int i = 0; i < this.rptOutlineScore.Items.Count; i++) { //当前索引行的试题类型 Song.Entities.TestPaperItem pi = null; foreach (Song.Entities.TestPaperItem p in tpi) { if (p.TPI_Type == i + 1) { pi = p; } } if (pi == null) { continue; } //占多少分数比 TextBox tbScore = (TextBox)this.rptOutlineScore.Items[i].FindControl("tbQuesScore"); tbScore.Text = pi.TPI_Percent > 0 ? pi.TPI_Percent.ToString() : ""; } //各章节的各题型试题数量 for (int i = 0; i < this.rptOutline.Items.Count; i++) { Label lbOlid = (Label)this.rptOutline.Items[i].FindControl("lbOlid"); //章节id控件 int olid = Convert.ToInt32(lbOlid.Text); //章节id //内嵌repeat,用于显示题型 Repeater rptItems = (Repeater)this.rptOutline.Items[i].FindControl("rtpOutlineItem"); Song.Entities.TestPaperItem[] tpiol = Business.Do <ITestPaper>().GetItemForOlCount(tp, olid); //当前章节的各试题抽取数量 for (int j = 0; j < rptItems.Items.Count; j++) { //当前索引行的试题类型 Song.Entities.TestPaperItem pi = null; foreach (Song.Entities.TestPaperItem p in tpiol) { if (p.TPI_Type == j + 1) { pi = p; } } if (pi == null) { continue; } //几道题 TextBox tbCount = (TextBox)rptItems.Items[j].FindControl("tbQuesCount"); tbCount.Text = pi.TPI_Count > 0 ? pi.TPI_Count.ToString() : ""; } } }
/// <summary> /// 当前考试的及格率 /// </summary> /// <param name="identify"></param> /// <returns></returns> public float ResultsPassrate(int identify) { Song.Entities.TestPaper mm = Gateway.Default.From <TestPaper>().Where(TestPaper._.Tp_Id == identify).ToFirst <TestPaper>(); //参考人次 int sum = Gateway.Default.Count <TestResults>(TestResults._.Tp_Id == identify); //及格数 int pass = Gateway.Default.Count <TestResults>(TestResults._.Tp_Id == identify && TestResults._.Tr_Score >= mm.Tp_PassScore); if (sum == 0) { return(0); } return(pass / (float)sum); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { exr = Business.Do <ITestPaper>().ResultsSingle(trid); if (exr == null) { return; } st = Business.Do <IAccounts>().AccountsSingle(exr.Ac_ID); string resPath = Upload.Get["Student"].Virtual; st.Ac_Photo = resPath + st.Ac_Photo; //当前试卷 pager = Business.Do <ITestPaper>().PagerSingle((int)exr.Tp_Id); } }
/// <summary> /// 修改是否显示的状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sbUse_Click(object sender, EventArgs e) { try { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); // Song.Entities.TestPaper entity = Business.Do <ITestPaper>().PagerSingle(id); entity.Tp_IsUse = !entity.Tp_IsUse; Business.Do <ITestPaper>().PagerSave(entity); BindData(null, null); } catch (Exception ex) { Alert(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { query = this.ClientQueryString; if (!this.IsPostBack) { string url = "TestPaper_Edit{0}.aspx?&type={0}&" + this.ClientQueryString; Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle(id); if (tp != null) { url = string.Format(url, tp.Tp_Type, tp.Tp_Type); } else { //统一试题的试卷还没有搞好,暂时先用这个 url = string.Format(url, 2, 2); } Response.Redirect(url); } }
/// <summary> /// 获取试题的大项 /// </summary> /// <returns></returns> private Song.Entities.TestPaperItem[] getTpi(Song.Entities.TestPaper tp) { Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForAny(tp); List <TestPaperItem> list = new List <TestPaperItem>(); XmlNodeList quesNodes = resXml.LastChild.ChildNodes; //当前答案中的试题分类项 foreach (Song.Entities.TestPaperItem t in tpi) { for (int i = 0; i < quesNodes.Count; i++) { int type = Convert.ToInt32(quesNodes[i].Attributes["type"].Value); if (t.TPI_Type == type) { list.Add(t); break; } } } return(list.ToArray()); }
protected override void InitPageTemplate(HttpContext context) { //当前试卷 Song.Entities.TestPaper paper = null; paper = Business.Do <ITestPaper>().PagerSingle(tpid); if (paper != null) { paper.Tp_Logo = string.IsNullOrWhiteSpace(paper.Tp_Logo) ? paper.Tp_Logo : Upload.Get["TestPaper"].Virtual + paper.Tp_Logo; //判断Logo是否存在 string hylogo = WeiSha.Common.Server.MapPath(paper.Tp_Logo); if (!System.IO.File.Exists(hylogo)) { paper.Tp_Logo = string.Empty; } this.Document.SetValue("pager", paper); //试卷所属课程 Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(paper.Cou_ID); this.Document.SetValue("course", course); } }
void fill() { Song.Entities.TestPaper mm = Business.Do <ITestPaper>().PagerSingle(id); if (mm == null) { return; } //试卷名称 lbPagerName.Text = mm.Tp_Name; //及格分,满分 lbPassnum.Text = mm.Tp_PassScore.ToString(); lbScore.Text = mm.Tp_Total.ToString(); //及格率 double pass = Business.Do <ITestPaper>().ResultsPassrate(id); pass = Math.Round(pass * 10000) / 100; lbPassPer.Text = pass.ToString(); //参考人次 lbPersontime.Text = Business.Do <ITestPaper>().ResultsPersontime(id).ToString(); //平均分 double avg = Business.Do <ITestPaper>().ResultsAverage(id); avg = Math.Round(avg * 100) / 100; lbAvg.Text = avg.ToString(); //最高分 Song.Entities.TestResults trHighest = Business.Do <ITestPaper>().ResultsHighest(id); if (trHighest != null) { lbHeight.Text = trHighest.Tr_Score.ToString(); lbHeightStudent.Text = "(" + trHighest.Ac_Name + ")"; } //最低分 Song.Entities.TestResults trLowest = Business.Do <ITestPaper>().ResultsLowest(id); if (trLowest != null) { lbLower.Text = trLowest.Tr_Score.ToString(); lbLowerStudent.Text = "(" + trLowest.Ac_Name + ")"; } }
protected override void InitPageTemplate(HttpContext context) { //服务器端时间 string time = new WeiSha.Common.Param.Method.ConvertToAnyValue(DateTime.Now.ToString()).JavascriptTime; this.Document.Variables.SetValue("Time", time); //当前试卷 Song.Entities.TestPaper paper = null; paper = Business.Do <ITestPaper>().PagerSingle(tpid); if (paper != null) { paper.Tp_Logo = string.IsNullOrWhiteSpace(paper.Tp_Logo) ? paper.Tp_Logo : Upload.Get["TestPaper"].Virtual + paper.Tp_Logo; //判断Logo是否存在 string hylogo = WeiSha.Common.Server.MapPath(paper.Tp_Logo); if (!System.IO.File.Exists(hylogo)) { paper.Tp_Logo = string.Empty; } this.Document.SetValue("pager", paper); //试卷所属课程 Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(paper.Cou_ID); this.Document.SetValue("course", course); } }
/// <summary> /// 获取考试场次 /// </summary> /// <returns></returns> private List <Song.Entities.Examination> getExamItem() { List <Song.Entities.Examination> items = new List <Song.Entities.Examination>(); for (int i = 0; i < GvItem.Rows.Count; i++) { GridViewRow gvr = GvItem.Rows[i]; if (gvr.RowType != DataControlRowType.DataRow) { continue; } //id Label lbID = (Label)gvr.FindControl("lbID"); int itemID = Convert.ToInt32(lbID.Text == string.Empty ? "-1" : lbID.Text); //考试名称 string name = ((TextBox)gvr.FindControl("tbName")).Text; //总分与及格分 TextBox tbTotal = (TextBox)gvr.FindControl("tbTotal"); int total = tbTotal.Text.Trim() == "" ? 60 : Convert.ToInt32(tbTotal.Text); TextBox tbPassscore = (TextBox)gvr.FindControl("tbPassScore"); int passcore = tbPassscore.Text.Trim() == "" ? 60 : Convert.ToInt32(tbPassscore.Text); //考试时间 TextBox tbDate = (TextBox)gvr.FindControl("tbDate"); DateTime date = Convert.ToDateTime(tbDate.Text == string.Empty ? DateTime.Now.AddYears(-100).ToString() : tbDate.Text); //考试时长 TextBox tbSpan = (TextBox)gvr.FindControl("tbSpan"); int span = Convert.ToInt32(tbSpan.Text == string.Empty ? "-1" : tbSpan.Text); //采用的试卷 TextBox tbTestPager = (TextBox)gvr.FindControl("tbTestPager"); int tpID = Convert.ToInt32(tbTestPager.Text == string.Empty ? "-1" : tbTestPager.Text); Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle(tpID); //专业 DropDownList sbjddl = (DropDownList)gvr.FindControl("ddlSubject"); int sbjID = 0; string sbjName = ""; if (sbjddl != null && sbjddl.Items.Count > 0) { sbjID = Convert.ToInt32(sbjddl.SelectedValue); sbjName = sbjddl.SelectedItem.Text; } Song.Entities.Subject sbj = Business.Do <ISubject>().SubjectSingle(sbjID); if (sbj != null) { sbjName = sbj.Sbj_Name; } //创建场次对象 Song.Entities.Examination exam = itemID < 1 ? new Song.Entities.Examination() : Business.Do <IExamination>().ExamSingle(itemID); exam = exam == null ? new Song.Entities.Examination() : exam; //赋值 exam.Exam_UID = getUID(); exam.Sbj_ID = sbjID; exam.Sbj_Name = sbjName; exam.Exam_Name = name; exam.Exam_Total = total; exam.Exam_PassScore = passcore; exam.Exam_Date = date; exam.Exam_Span = span; exam.Tp_Id = tpID; exam.Exam_Tax = i + 1; items.Add(exam); } //校验,各场次考试主题不可以相同 bool isExists = false; foreach (Song.Entities.Examination e in items) { if (string.IsNullOrWhiteSpace(e.Exam_Name)) { continue; } foreach (Song.Entities.Examination j in items) { if (e.Exam_Tax == j.Exam_Tax) { continue; } if (e.Exam_Name == j.Exam_Name) { isExists = true; break; } } if (isExists) { break; } } if (isExists) { throw new Exception("各场次考试主题不可以相同"); } return(items); }
//获取当前学科下的所有试卷 protected void Page_Load(object sender, EventArgs e) { //获取答题信息 Song.Entities.ExamResults exr = Business.Do <IExamination>().ResultSingle(examid, tpid, stid); //取试题 List <Song.Entities.Questions> quesList = new List <Questions>(); if (exr == null) { //取果是第一次打开,则随机生成试题,此为获取试卷 Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle(tpid); //难度区间 int diff1 = tp.Tp_Diff > tp.Tp_Diff2 ? (int)tp.Tp_Diff2 : (int)tp.Tp_Diff; int diff2 = tp.Tp_Diff > tp.Tp_Diff2 ? (int)tp.Tp_Diff : (int)tp.Tp_Diff2; //获取试题项 Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForAll(tp); foreach (Song.Entities.TestPaperItem pi in tpi) { //类型,试题数目,该类型占多少分, int type = (int)pi.TPI_Type; int count = (int)pi.TPI_Count; float num = (float)pi.TPI_Number; int per = (int)pi.TPI_Percent; if (count < 1) { continue; } Song.Entities.Questions[] ques = Business.Do <IQuestions>().QuesRandom(tp.Org_ID, (int)tp.Sbj_ID, -1, -1, type, diff1, diff2, true, count); float surplus = num; for (int i = 0; i < ques.Length; i++) { //当前试题的分数 float curr = ((float)pi.TPI_Number) / ques.Length; curr = ((float)Math.Round(curr * 10)) / 10; if (i < ques.Length - 1) { ques[i].Qus_Number = curr; surplus = surplus - curr; } else { ques[i].Qus_Number = surplus; } } foreach (Song.Entities.Questions q in ques) { quesList.Add(replaceText(q)); } } } else { //如果已经做过试题 if (exr.Exr_IsSubmit) { //如果已经交过卷,则不允许再做题 Response.Write("2"); Response.End(); } else { quesList = Business.Do <IExamination>().QuesForResults(exr.Exr_Results); } } string tm = "["; for (int i = 0; i < quesList.Count; i++) { string json = quesList[i].ToJson(); //如果是单选题,或多选题,或填空题 if (quesList[i].Qus_Type == 1 || quesList[i].Qus_Type == 2 || quesList[i].Qus_Type == 5) { tm += getAnserJson(quesList[i], json); } else { tm += json; } if (i < quesList.Count - 1) { tm += ","; } } tm += "]"; Response.Write(tm); Response.End(); }
protected override void InitPageTemplate(HttpContext context) { accid = Extend.LoginState.Accounts.UserID; Song.Entities.ExamResults result = null; if (exrid != 0) { result = Business.Do <IExamination>().ResultSingle(exrid); } else { result = Business.Do <IExamination>().ResultSingle(accid, examid); if (result != null) { exrid = result.Exr_ID; } } if (result == null) { return; } Song.Entities.Examination exam = Business.Do <IExamination>().ExamSingle(result.Exam_ID); if (exam == null) { return; } //加载答题信息 resXml.LoadXml(result.Exr_Results, false); //判断开始时间与结束时间,是否考试结束等 bool isOver; //判断是否已经开始、是否已经结束 if (exam.Exam_DateType == 1) { //固定时间开始 isOver = DateTime.Now > exam.Exam_Date.AddMinutes(exam.Exam_Span); //是否结束 } else { isOver = DateTime.Now > exam.Exam_DateOver; //是否结束 if (result != null && !string.IsNullOrWhiteSpace(result.Exr_Results)) { XmlNode xn = resXml.LastChild; //考试的开始与结束时间,防止学员刷新考试界面,导致时间重置 long lover; long.TryParse(xn.Attributes["overtime"] != null ? xn.Attributes["overtime"].Value : "0", out lover); lover = lover * 10000; DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); DateTime overTime = dtStart.Add(new TimeSpan(lover)); //得到转换后的结束时间 isOver = DateTime.Now > overTime; } } this.Document.Variables.SetValue("isOver", isOver); // result.Exam_Name = exam.Exam_Name; this.Document.Variables.SetValue("result", result); //试卷 Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle((int)result.Tp_Id); this.Document.Variables.SetValue("pager", tp); //考生 Song.Entities.Accounts st = Business.Do <IAccounts>().AccountsSingle((int)result.Ac_ID); this.Document.Variables.SetValue("st", st); //获取试题项 Song.Entities.TestPaperItem[] tpi = getTpi(tp); this.Document.Variables.SetValue("tpi", tpi); //计算得分 this.Document.RegisterGlobalFunction(this.getTypeName); this.Document.RegisterGlobalFunction(this.getTypeNumber); this.Document.RegisterGlobalFunction(this.getAnswerCount); this.Document.RegisterGlobalFunction(this.getSucessCount); this.Document.RegisterGlobalFunction(this.getErrorCount); //展示答题状态 this.Document.RegisterGlobalFunction(this.getQues); this.Document.RegisterGlobalFunction(this.getItems); this.Document.RegisterGlobalFunction(this.getSucessAnswer); //计算答题状态等 this.Document.RegisterGlobalFunction(this.getAnswerState); //获取学生答题内容与正确答案 this.Document.RegisterGlobalFunction(this.getResult); this.Document.RegisterGlobalFunction(this.getQuesScore); }
protected override void InitPageTemplate(HttpContext context) { if (!Extend.LoginState.Accounts.IsLogin) { context.Response.Redirect("~/student/index.ashx"); return; } this.Document.SetValue("tpid", tpid); //自定义配置项 WeiSha.Common.CustomConfig config = CustomConfig.Load(Organ.Org_Config); //如果需要学员登录后才能学习 bool isTraningLogin = config["IsTraningLogin"].Value.Boolean ?? false; this.Document.SetValue("isTraningLogin", isTraningLogin); //当前试卷 pager = Business.Do <ITestPaper>().PagerSingle(tpid); if (pager != null) { this.Document.SetValue("pager", pager); this.Document.SetValue("path", Upload.Get["TestPaper"].Virtual); //是否学习当前课程 if (this.Account != null) { if (pager != null) { Song.Entities.Course cou = Business.Do <ICourse>().CourseSingle(pager.Cou_ID); if (cou != null) { isStudy = Business.Do <ICourse>().StudyIsCourse(this.Account.Ac_ID, cou.Cou_ID); this.Document.Variables.SetValue("isStudy", isStudy || cou.Cou_IsFree); } } } //唯一值 string uid = WeiSha.Common.Request.UniqueID(); this.Document.Variables.SetValue("uid", uid); //服务器端时间 this.Document.Variables.SetValue("Time", WeiSha.Common.Server.getTime()); //试卷所属课程 Song.Entities.Course course = Business.Do <ICourse>().CourseSingle(pager.Cou_ID); this.Document.SetValue("course", course); //题型 this.Document.SetValue("quesType", WeiSha.Common.App.Get["QuesType"].Split(',')); //取果是第一次打开,则随机生成试题,此为获取试卷 //难度区间 int diff1 = pager.Tp_Diff > pager.Tp_Diff2 ? (int)pager.Tp_Diff2 : (int)pager.Tp_Diff; int diff2 = pager.Tp_Diff > pager.Tp_Diff2 ? (int)pager.Tp_Diff : (int)pager.Tp_Diff2; //开始抽题 List <Song.Entities.Questions> ques = new List <Entities.Questions>(); Dictionary <TestPaperItem, Questions[]> dic = Business.Do <ITestPaper>().Putout(pager); foreach (var d in dic) { Song.Entities.Questions[] qs = (Song.Entities.Questions[])d.Value; for (int n = 0; n < qs.Length; n++) { qs[n].Qus_Explain = ""; qs[n].Qus_Answer = ""; qs[n] = Extend.Questions.TranText(qs[n]); qs[n].Qus_Title = qs[n].Qus_Title.Replace("<", "<"); qs[n].Qus_Title = qs[n].Qus_Title.Replace(">", ">"); qs[n].Qus_Title = Extend.Html.ClearHTML(qs[n].Qus_Title, "p", "div"); ques.Add(qs[n]); } } this.Document.SetValue("ques", ques); this.Document.RegisterGlobalFunction(this.getQuesType); this.Document.RegisterGlobalFunction(this.AnswerItems); this.Document.RegisterGlobalFunction(this.GetOrder); this.Document.RegisterGlobalFunction(this.IsCollect); } }
/// <summary> /// 获取试卷名称 /// </summary> /// <param name="tpid"></param> /// <returns></returns> protected string getTestPager(string tpid) { Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle(Convert.ToInt32(tpid)); return(tp != null ? tp.Tp_Name : "【试卷不存在,可能已经被删除】"); }
void fill() { Song.Entities.TestPaper mm = id != 0 ? Business.Do <ITestPaper>().PagerSingle(id) : new Song.Entities.TestPaper(); if (id != 0) { mm = Business.Do <ITestPaper>().PagerSingle(id); //是否使用与推荐 cbIsUse.Checked = mm.Tp_IsUse; cbIsRec.Checked = mm.Tp_IsRec; //唯一标识 ViewState["UID"] = mm.Tp_UID; //所属专业 ListItem liSubj = ddlSubject.Items.FindByValue(mm.Sbj_ID.ToString()); if (liSubj != null) { ddlSubject.SelectedIndex = -1; liSubj.Selected = true; ddlSubject_SelectedIndexChanged(null, null); } //所属课程 ListItem liCous = this.ddlCourse.Items.FindByValue(mm.Cou_ID.ToString()); if (liCous != null) { ddlCourse.SelectedIndex = -1; liCous.Selected = true; } //难度 ListItem liDiff = ddlDiff.Items.FindByValue(mm.Tp_Diff.ToString()); if (liDiff != null) { ddlDiff.SelectedIndex = -1; liDiff.Selected = true; } ListItem liDiff2 = ddlDiff2.Items.FindByValue(mm.Tp_Diff2.ToString()); if (liDiff2 != null) { ddlDiff2.SelectedIndex = -1; liDiff2.Selected = true; } //时长,总分,及格分 tbSpan.Text = mm.Tp_Span.ToString(); tbTotal.Text = mm.Tp_Total.ToString(); tbPassScore_.Text = mm.Tp_PassScore.ToString(); //各项题型分值 Song.Entities.TestPaperItem[] tpi = Business.Do <ITestPaper>().GetItemForAll(mm); foreach (Song.Entities.TestPaperItem pi in tpi) { int type = (int)pi.TPI_Type; //几道题 TextBox tbCount = (TextBox)this.getWebControl("tbItem" + type + "Count"); //占多少分数比 TextBox tbScore = (TextBox)this.getWebControl("tbItem" + type + "Score"); //占多少分 Label lbNumber = (Label)this.getWebControl("lbItem" + type + "Number"); TextBox tbNumber = (TextBox)this.getWebControl("tbItem" + type + "Number"); tbCount.Text = pi.TPI_Count.ToString(); tbScore.Text = pi.TPI_Percent.ToString(); } } else { //如果是新增 mm = new Song.Entities.TestPaper(); ViewState["UID"] = WeiSha.Common.Request.UniqueID(); ddlSubject_SelectedIndexChanged(null, null); } //试卷名称 tbName.Text = mm.Tp_Name; //简介 tbIntro.Text = mm.Tp_Intro; //个人照片 if (!string.IsNullOrEmpty(mm.Tp_Logo) && mm.Tp_Logo.Trim() != "") { this.imgShow.Src = Upload.Get[_uppath].Virtual + mm.Tp_Logo; } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnter_Click(object sender, EventArgs e) { Song.Entities.TestPaper mm = id != 0 ? Business.Do <ITestPaper>().PagerSingle(id) : new Song.Entities.TestPaper(); try { //试卷名称 mm.Tp_Name = tbName.Text.Trim(); //是否使用与推荐 mm.Tp_IsUse = cbIsUse.Checked; mm.Tp_IsRec = cbIsRec.Checked; //类型 mm.Tp_Type = 1; //专业,难度 mm.Sbj_ID = Convert.ToInt32(ddlSubject.SelectedValue); mm.Sbj_Name = ddlSubject.SelectedText; mm.Cou_ID = Convert.ToInt32(ddlCourse.SelectedValue); mm.Tp_Diff = Convert.ToInt32(ddlDiff.SelectedValue); mm.Tp_Diff2 = Convert.ToInt32(ddlDiff2.SelectedValue); //时长与总分 mm.Tp_Span = Convert.ToInt32(tbSpan.Text); mm.Tp_Total = Convert.ToInt32(tbTotal.Text); mm.Tp_PassScore = Convert.ToInt32(tbPassScore_.Text); //简介 mm.Tp_Intro = tbIntro.Text; //UID mm.Tp_UID = getUID(); //图片 if (fuLoad.PostedFile.FileName != "") { try { fuLoad.UpPath = _uppath; fuLoad.IsMakeSmall = false; fuLoad.IsConvertJpg = true; fuLoad.SaveAndDeleteOld(mm.Tp_Logo); fuLoad.File.Server.ChangeSize(200, 200, false); mm.Tp_Logo = fuLoad.File.Server.FileName; // imgShow.Src = fuLoad.File.Server.VirtualPath; } catch (Exception ex) { this.Alert(ex.Message); } } } catch (Exception ex) { Message.Alert(ex); } //确定操作 try { //各项题型占比 Song.Entities.TestPaperItem[] tpi = new TestPaperItem[5]; for (int i = 0; i < tpi.Length; i++) { Song.Entities.TestPaperItem pi = new TestPaperItem(); //几道题 TextBox tbCount = (TextBox)this.getWebControl("tbItem" + (i + 1) + "Count"); //占多少分数比 TextBox tbScore = (TextBox)this.getWebControl("tbItem" + (i + 1) + "Score"); TextBox tbNumber = (TextBox)this.getWebControl("tbItem" + (i + 1) + "Number"); pi.TPI_Count = Convert.ToInt32(tbCount.Text.Trim() == "" ? "0" : tbCount.Text); pi.TPI_Percent = Convert.ToInt32(tbScore.Text.Trim() == "" ? "0" : tbScore.Text); pi.TPI_Number = Convert.ToInt32(tbNumber.Text.Trim() == "" ? "0" : tbNumber.Text); pi.TPI_Type = i + 1; tpi[i] = pi; } //if (id == 0) //id = Business.Do<ITestPaper>().PagerAdd(mm, tpi); //else //Business.Do<ITestPaper>().PagerSave(mm, tpi); Master.AlertCloseAndRefresh("操作成功!"); } catch (Exception ex) { Master.Alert(ex.Message); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnter_Click(object sender, EventArgs e) { Song.Entities.TestPaper mm = id != 0 ? Business.Do <ITestPaper>().PagerSingle(id) : new Song.Entities.TestPaper(); //试卷类型,为2时表示:随机抽题 mm.Tp_Type = 2; mm.Tp_UID = getUID(); //UID mm.Tp_Name = tbName.Text.Trim(); //试卷名称 mm.Tp_SubName = tbSubName.Text.Trim(); //试卷副标题 mm.Tp_IsUse = cbIsUse.Checked; //是否使用 mm.Tp_IsRec = cbIsRec.Checked; //是否推荐 mm.Sbj_ID = Convert.ToInt32(ddlSubject.SelectedValue); //专业id mm.Sbj_Name = ddlSubject.SelectedText; //专业名称 int couid = 0; //课程ID int.TryParse(ddlCourse.SelectedValue, out couid); mm.Cou_ID = couid; //设置课程id mm.Tp_Diff = mm.Tp_Diff2 = Convert.ToInt32(ddlDiff.SelectedValue); //难易度 mm.Tp_Span = Convert.ToInt32(tbSpan.Text); //考试限时时长 mm.Tp_Total = Convert.ToInt32(tbTotal.Text); //考试总分 mm.Tp_PassScore = Convert.ToInt32(tbPassScore_.Text); //及极分 mm.Tp_Intro = tbIntro.Text.Trim(); //简介 mm.Tp_Remind = tbRemind.Text.Trim(); //注意事项 mm.Tp_FromType = Convert.ToInt16(rblFromType.SelectedValue); //抽题范围,0为当前课程,1为按章节 //图片上传 if (fuLoad.PostedFile.FileName != "") { try { fuLoad.UpPath = _uppath; //上传路径 fuLoad.IsMakeSmall = false; //是否生成缩略图,此为不生成 fuLoad.IsConvertJpg = true; //是否转换为Jpg格式,此为转换 fuLoad.SaveAndDeleteOld(mm.Tp_Logo); //上传图片,并同步删除旧图片 fuLoad.File.Server.ChangeSize(200, 200, false); //更改图片大小 mm.Tp_Logo = fuLoad.File.Server.FileName; imgShow.Src = fuLoad.File.Server.VirtualPath; } catch (Exception ex) { this.Alert(ex.Message); } } int tpcount = 0; //出题范围的配置项 mm.Tp_FromConfig = _buildItemXML(mm.Tp_FromType, out tpcount); mm.Tp_Count = tpcount; //确定操作 try { if (id == 0) { id = Business.Do <ITestPaper>().PagerAdd(mm); } else { Business.Do <ITestPaper>().PagerSave(mm); } Master.AlertCloseAndRefresh("操作成功!"); } catch (Exception ex) { Master.Alert(ex.Message); } }
/// <summary> /// 填充数据 /// </summary> private void fill() { Song.Entities.TestPaper mm; if (id != 0) { mm = Business.Do <ITestPaper>().PagerSingle(id); cbIsUse.Checked = mm.Tp_IsUse; //是否使用 cbIsRec.Checked = mm.Tp_IsRec; //是否推荐 ViewState["UID"] = mm.Tp_UID; //唯一标识 //所属专业 ListItem liSubj = ddlSubject.Items.FindByValue(mm.Sbj_ID.ToString()); if (liSubj != null) { ddlSubject.SelectedIndex = -1; liSubj.Selected = true; ddlSubject_SelectedIndexChanged(null, null); } //所属课程 ListItem liCous = this.ddlCourse.Items.FindByValue(mm.Cou_ID.ToString()); if (liCous != null) { ddlCourse.SelectedIndex = -1; liCous.Selected = true; ddlCourse_SelectedIndexChanged(null, null); } //难度 ListItem liDiff = ddlDiff.Items.FindByValue(mm.Tp_Diff2.ToString()); if (liDiff != null) { ddlDiff.SelectedIndex = -1; liDiff.Selected = true; } //时长,总分,及格分 tbSpan.Text = mm.Tp_Span.ToString(); tbTotal.Text = mm.Tp_Total.ToString(); tbPassScore_.Text = mm.Tp_PassScore.ToString(); } else { //如果是新增 mm = new Song.Entities.TestPaper(); ViewState["UID"] = WeiSha.Common.Request.UniqueID(); //当处在课程管理中时 if (couid > 0) { Song.Entities.Course cour = Business.Do <ICourse>().CourseSingle(couid); if (cour != null) { //所属专业 ListItem liSubj = ddlSubject.Items.FindByValue(cour.Sbj_ID.ToString()); if (liSubj != null) { ddlSubject.SelectedIndex = -1; liSubj.Selected = true; ddlSubject_SelectedIndexChanged(null, null); } //所属课程 ListItem liCous = this.ddlCourse.Items.FindByValue(cour.Cou_ID.ToString()); if (liCous != null) { ddlCourse.SelectedIndex = -1; liCous.Selected = true; } } } ddlCourse_SelectedIndexChanged(null, null); } tbName.Text = mm.Tp_Name; //标题 tbSubName.Text = mm.Tp_SubName; //副标题 tbAuthor.Text = mm.Tp_Author; //出卷人 tbIntro.Text = mm.Tp_Intro; //试卷简介 tbRemind.Text = mm.Tp_Remind; //注意事项 //试卷Logo图片 if (!string.IsNullOrEmpty(mm.Tp_Logo) && mm.Tp_Logo.Trim() != "") { this.imgShow.Src = Upload.Get[_uppath].Virtual + mm.Tp_Logo; } //试题范围 ListItem liFrom = this.rblFromType.Items.FindByValue(mm.Tp_FromType.ToString()); if (liFrom != null) { rblFromType.SelectedIndex = -1; liFrom.Selected = true; } //各项题型分值 _fillItemForAll(mm); //按课程出题 _fileItemForOutline(mm); //按章节出题 }
void fill() { try { if (id < 1) { return; } Song.Entities.ExamResults mm = Business.Do <IExamination>().ResultSingle(id); if (mm == null) { return; } //考生姓名,考试主题,学科 lbAccName.Text = mm.Ac_Name; lbExamTheme.Text = mm.Exam_Title; lbExamSbj.Text = mm.Sbj_Name; //自动判卷得分 lbScore.Text = mm.Exr_Score.ToString(); //最终得分 lbScoreFinal.Text = mm.Exr_ScoreFinal.ToString(); //人工判卷 tbDraw.Text = mm.Exr_Draw.ToString(); tbColligate.Text = mm.Exr_Colligate.ToString(); } catch (Exception ex) { Message.ExceptionShow(ex); } try { if (id < 1) { return; } Song.Entities.ExamResults mm = Business.Do <IExamination>().ResultSingle(id); if (mm == null) { return; } //考生姓名,考试主题,学科 lbAccName.Text = mm.Ac_Name; lbExamTheme.Text = mm.Exam_Title; lbExamSbj.Text = mm.Sbj_Name; //应试时间 lbExamTime.Text = ((DateTime)mm.Exr_CrtTime).ToString("yyyy月MM月dd日 hh:mm"); //采用试卷 Song.Entities.TestPaper tp = Business.Do <ITestPaper>().PagerSingle((int)mm.Tp_Id); lbTestPager.Text = tp != null ? tp.Tp_Name : ""; //自动判卷得分 lbScore.Text = mm.Exr_Score.ToString(); //最终得分 lbScoreFinal.Text = mm.Exr_ScoreFinal.ToString(); //人工判卷 tbDraw.Text = mm.Exr_Draw.ToString(); tbColligate.Text = mm.Exr_Colligate.ToString(); //展示简答题 plJianda.Visible = bindShortQues(mm); } catch (Exception ex) { Message.ExceptionShow(ex); } }