示例#1
0
        /// <summary>          
        /// 插入基本试卷信息
        /// </summary>
        /// <param name="s">基本试卷实体</param>
        public static int InsertBasicExam(BasicExamInfo s)
        {
            ExamDbDataContext dc = DataAccess.CreateDBContext();

            dc.BasicExamInfo.InsertOnSubmit(s);

            dc.SubmitChanges();
            // PurgeCacheItems("AllSubjects_" + s.DepartmentID.ToString());
            return s.BasicExamID;
        }
示例#2
0
 /// <summary>
 /// 删除基本试卷信息
 /// </summary>
 /// <param name="s">基本试卷实体</param>
 public static void DeleteBasicExam(BasicExamInfo s, ExamDbDataContext dc)
 {
     AttachInfo<BasicExamInfo>(dc.BasicExamInfo, s);
     dc.BasicExamInfo.DeleteOnSubmit(s);
     dc.SubmitChanges();
 }
示例#3
0
        /// <summary>
        /// 更新基本试卷信息
        /// </summary>
        /// <param name="s">基本试卷实体</param>
        public static void UpdateBasicExam(BasicExamInfo s, ExamDbDataContext dc)
        {
            AttachInfo<BasicExamInfo>(dc.BasicExamInfo, s);
            dc.SubmitChanges();

            // PurgeCacheItems("AllBasicExams_" + s.DepartmentID.ToString());
        }
示例#4
0
        private static IList<int> GetMutilChoicesIDs(ExamDbDataContext dc, BasicExamInfo exam)
        {
            var allMutilChoiceIDs = dc.SelectChoiceInfo.Where(p => p.IsSingleSelect == false&&(exam.ChapterID == 0 ? p.CourseID == exam.CourseID : p.ChapterID == exam.ChapterID)).Select(p => p.SelectChoiceID).ToList();
            if (allMutilChoiceIDs == null || allMutilChoiceIDs.Count() == 0) return null;
            int totalCount = allMutilChoiceIDs.Count();
            IList<int> mutilChoices = Utility.GetRandomList(allMutilChoiceIDs, (int)exam.MutilChoiceNum);

            return mutilChoices;
        }
示例#5
0
        private static IList<int> GetSingleChoicesIDs(ExamDbDataContext dc, BasicExamInfo exam)
        {
            var allsingleChoiceIDs = dc.SelectChoiceInfo.Where(p => p.IsSingleSelect == true&&(exam.ChapterID==0?p.CourseID==exam.CourseID:p.ChapterID==exam.ChapterID)).Select(p => p.SelectChoiceID).ToList();

            int totalCount = allsingleChoiceIDs.Count();

            IList<int> singleChoices = Utility.GetRandomList(allsingleChoiceIDs, (int)exam.SingChoiceNum);

            return singleChoices;
        }
示例#6
0
 private static IList<int> GetJudgesIDs(ExamDbDataContext dc, BasicExamInfo exam)
 {
     var allJudgeIDs = dc.JudgeInfo.Where(p=>exam.ChapterID == 0 ? p.CourseID == exam.CourseID : p.ChapterID == exam.ChapterID).Select(p => p.JudgeID).ToList();
     int totalCount = allJudgeIDs.Count();
     IList<int> judges = Utility.GetRandomList(allJudgeIDs, (int)exam.JudgeNum);
     return judges;
 }
示例#7
0
        /// <summary>
        /// 建立选择题结点,包括单选和多选
        /// </summary>
        /// <param name="dc"></param>
        /// <param name="exam"></param>
        /// <param name="choiceIDs"></param>
        /// <param name="elementName"></param>
        /// <returns></returns>
        private static XElement GetChoices(ExamDbDataContext dc, BasicExamInfo exam, IList<int> choiceIDs,string elementName)
        {
            if (choiceIDs == null) return null;
            XElement choicesElement = new XElement(elementName+"s");

            if (elementName == "SingleChoice")
            {
                choicesElement.SetAttributeValue("count", exam.SingChoiceNum);

                choicesElement.SetAttributeValue("eachMark", exam.SingChoiceMark);
            }
            else
            {
                choicesElement.SetAttributeValue("count", exam.MutilChoiceNum);

                choicesElement.SetAttributeValue("eachMark", exam.MutilChoiceMark);
            }

            choicesElement.SetAttributeValue("getMark", 0);

           
            foreach (int choiceID in choiceIDs)
            {
                //每一选择题都创建一个xml结点

                SelectChoiceInfo s = dc.SelectChoiceInfo.Single(p => p.SelectChoiceID == choiceID);

                XElement choice = GetChoice(dc, choiceID, s, elementName);

                choicesElement.Add(choice);
            }

            return choicesElement;
        }
示例#8
0
        private static XElement GetJudgesELement(ExamDbDataContext dc, BasicExamInfo exam, IList<int> judgesIDs)
        {
            XElement judgesElement = new XElement("Judges");

            judgesElement.SetAttributeValue("count", exam.JudgeNum);

            judgesElement.SetAttributeValue("eachMark", exam.JudgeMark);

            judgesElement.SetAttributeValue("getMark", 0);

            foreach (int judgeID in judgesIDs)
            {
                JudgeInfo j = dc.JudgeInfo.Single(p => p.JudgeID == judgeID);

                XElement judgeElement = new XElement("JudgeItem");

                judgeElement.SetAttributeValue("judgeID",j.JudgeID);

                judgeElement.SetAttributeValue("title", j.Title);

                judgeElement.SetAttributeValue("setTrue", "-1");

                judgesElement.Add(judgeElement);
            
            }

            return judgesElement;
        
        }
示例#9
0
		private void detach_BasicExamInfo(BasicExamInfo entity)
		{
			this.SendPropertyChanging();
			entity.CourseInfo = null;
		}
示例#10
0
        protected void imgBtnConfirm_Click(object sender, ImageClickEventArgs e)
        {
            int courseID=int.Parse(ddlCourses.SelectedValue);

            if (courseID == 0)
            {
                lblMessage.Text = "请选择课程!!";
                return;
            }
            
            int singNum = int.Parse(txtSingleNum.Text);

            int singMark = int.Parse(txtSingleFen.Text);

            int mutilNum = int.Parse(txtMultiNum.Text);

            int mutilMark = int.Parse(txtMultiFen.Text);

            int judgeNum = int.Parse(txtJudgeNum.Text);

            int judgeMark = int.Parse(txtJudgeFen.Text);

            int totalMark=int.Parse(txtTotalMark.Text);
            int  sumMark= singMark * singNum + mutilMark * mutilNum + judgeMark * judgeNum;

            if (totalMark != sumMark)
                lblMessage.Text = "试卷总分不匹配,请重新计算!";
            else
            { 
             //插入试卷。
                BasicExamInfo exam = null;

                ExamDbDataContext dc=new ExamDbDataContext();

                if (string.IsNullOrEmpty(hideExamID.Value))
                {
                    exam = new BasicExamInfo();
                    exam.AddedDate = DateTime.Now;
                }
                else exam = BasicExam.GetBasicExamByID(int.Parse(hideExamID.Value), out dc);

                exam.BasicExamTitle = txtPaperName.Text;
                exam.BasicExamDesc = txtDesc.Text;
                exam.JudgeNum = judgeNum;
                exam.JudgeMark = judgeMark;
                exam.MutilChoiceNum = mutilNum;
                exam.MutilChoiceMark = mutilMark;
                exam.SingChoiceNum = singNum;
                exam.SingChoiceMark = singMark;
                exam.CourseID = courseID;

                

                if (ddlChapters.Items.Count == 0)
                    exam.ChapterID = 0;
                else exam.ChapterID = int.Parse(ddlChapters.SelectedValue);

                exam.TimeUse = int.Parse(txtTotalTime.Text);
                
                
                
                 if(string.IsNullOrEmpty(hideExamID.Value))
                BasicExam.InsertBasicExam(exam);
                 else dc.SubmitChanges();
                this.ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('成功保存试卷')</script>");

                ClearTextBoxValue();

                hideExamID.Value="";
            
            }
            Egv.DataBind();

        }