private void GetESLTemplate() { picLoading.Visible = true; string courseIDs = string.Join(",", _CourseIDList); #region 取得ESL 課程資料 // 2018/06/12 抓取課程且其有ESL 樣板設定規則的,才做後續整理, 在table exam_template 欄位 description 不為空代表其為ESL 的樣板 string query = @" SELECT course.id AS courseID ,course.course_name ,exam_template.description ,exam_template.id AS templateID ,exam_template.name AS templateName FROM course LEFT JOIN exam_template ON course.ref_exam_template_id =exam_template.id WHERE course.id IN( " + courseIDs + ") AND exam_template.description IS NOT NULL "; QueryHelper qh = new QueryHelper(); DataTable dt = qh.Select(query); _CourseIDList.Clear(); // 清空 //整理目前的ESL 課程資料 if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { ESLCourse record = new ESLCourse(); _CourseIDList.Add("" + dr["courseID"]); // 加入真正的 是ESL 課程ID if (!_ESLCourseIDExamTermIDDict.ContainsKey("" + dr["courseID"])) { _ESLCourseIDExamTermIDDict.Add("" + dr["courseID"], "" + dr["templateID"]); } if (!_ESLTemplateDict.ContainsKey("" + dr["templateID"])) { ESLTemplate template = new ESLTemplate(); template.ID = "" + dr["templateID"]; template.ESLTemplateName = "" + dr["templateName"]; template.Description = "" + dr["description"]; _ESLTemplateDict.Add("" + dr["templateID"], template); } // 建立課程名稱對照 if (!_ESLCourseIDNameDict.ContainsKey("" + dr["courseID"])) { _ESLCourseIDNameDict.Add("" + dr["courseID"], "" + dr["course_name"]); } } } #endregion #region 解析ESL 課程 計算規則 // 解析計算規則 foreach (string templateID in _ESLTemplateDict.Keys) { string xmlStr = "<root>" + _ESLTemplateDict[templateID].Description + "</root>"; XElement elmRoot = XElement.Parse(xmlStr); //解析讀下來的 descriptiony 資料 if (elmRoot != null) { if (elmRoot.Element("ESLTemplate") != null) { foreach (XElement ele_term in elmRoot.Element("ESLTemplate").Elements("Term")) { Term t = new Term(); t.Name = ele_term.Attribute("Name").Value; t.Weight = ele_term.Attribute("Weight").Value; t.InputStartTime = ele_term.Attribute("InputStartTime").Value; t.InputEndTime = ele_term.Attribute("InputEndTime").Value; t.Ref_exam_id = ele_term.Attribute("Ref_exam_id").Value; t.SubjectList = new List <Subject>(); foreach (XElement ele_subject in ele_term.Elements("Subject")) { Subject s = new Subject(); s.Name = ele_subject.Attribute("Name").Value; s.Weight = ele_subject.Attribute("Weight").Value; s.AssessmentList = new List <Assessment>(); foreach (XElement ele_assessment in ele_subject.Elements("Assessment")) { Assessment a = new Assessment(); a.Name = ele_assessment.Attribute("Name").Value; a.Weight = ele_assessment.Attribute("Weight").Value; a.TeacherSequence = ele_assessment.Attribute("TeacherSequence").Value; a.Type = ele_assessment.Attribute("Type").Value; a.AllowCustomAssessment = ele_assessment.Attribute("AllowCustomAssessment").Value; if (a.Type == "Comment") // 假如是 評語類別,多讀一項 輸入限制屬性 { a.InputLimit = ele_assessment.Attribute("InputLimit").Value; } a.IndicatorsList = new List <Indicators>(); if (ele_assessment.Element("Indicators") != null) { foreach (XElement ele_Indicator in ele_assessment.Element("Indicators").Elements("Indicator")) { Indicators i = new Indicators(); i.Name = ele_Indicator.Attribute("Name").Value; i.Description = ele_Indicator.Attribute("Description").Value; a.IndicatorsList.Add(i); } } s.AssessmentList.Add(a); } t.SubjectList.Add(s); } _ESLTemplateDict[templateID].TermList.Add(t); } } } } #endregion #region 取得學生修課資料 _scaList = K12.Data.SCAttend.SelectByCourseIDs(_CourseIDList); #endregion }
public ESLTransferScoreInputForm(string targetScAttendID) { InitializeComponent(); _targetScAttendID = targetScAttendID; #region 取得學生修課資料 _scAttendRecord = K12.Data.SCAttend.SelectByID(_targetScAttendID); #endregion #region 取得ESL 課程資料 _targetCourseID = _scAttendRecord.RefCourseID; _targetCourseName = _scAttendRecord.Course.Name; _targetTemplateID = _scAttendRecord.Course.RefAssessmentSetupID; string query = @" SELECT course.id AS courseID ,course.course_name ,exam_template.description ,exam_template.id AS templateID ,exam_template.name AS templateName FROM course LEFT JOIN exam_template ON course.ref_exam_template_id =exam_template.id WHERE course.id IN( " + _targetCourseID + ") AND exam_template.description IS NOT NULL "; QueryHelper qh = new QueryHelper(); DataTable dt = qh.Select(query); _CourseIDList.Clear(); // 清空 //整理目前的ESL 課程資料 if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { ESLCourse record = new ESLCourse(); _CourseIDList.Add("" + dr["courseID"]); // 加入真正的 是ESL 課程ID if (!_ESLCourseIDExamTermIDDict.ContainsKey("" + dr["courseID"])) { _ESLCourseIDExamTermIDDict.Add("" + dr["courseID"], "" + dr["templateID"]); } if (!_ESLTemplateDict.ContainsKey("" + dr["templateID"])) { ESLTemplate template = new ESLTemplate(); template.ID = "" + dr["templateID"]; template.ESLTemplateName = "" + dr["templateName"]; template.Description = "" + dr["description"]; _ESLTemplateDict.Add("" + dr["templateID"], template); } // 建立課程名稱對照 if (!_ESLCourseIDNameDict.ContainsKey("" + dr["courseID"])) { _ESLCourseIDNameDict.Add("" + dr["courseID"], "" + dr["course_name"]); } } } #endregion #region 解析ESL 課程 計算規則 // 解析計算規則 foreach (string templateID in _ESLTemplateDict.Keys) { string xmlStr = "<root>" + _ESLTemplateDict[templateID].Description + "</root>"; XElement elmRoot = XElement.Parse(xmlStr); //解析讀下來的 descriptiony 資料 if (elmRoot != null) { if (elmRoot.Element("ESLTemplate") != null) { foreach (XElement ele_term in elmRoot.Element("ESLTemplate").Elements("Term")) { Term t = new Term(); t.Name = ele_term.Attribute("Name").Value; t.Weight = ele_term.Attribute("Weight").Value; t.InputStartTime = ele_term.Attribute("InputStartTime").Value; t.InputEndTime = ele_term.Attribute("InputEndTime").Value; t.Ref_exam_id = ele_term.Attribute("Ref_exam_id").Value; t.SubjectList = new List <Subject>(); foreach (XElement ele_subject in ele_term.Elements("Subject")) { Subject s = new Subject(); s.Name = ele_subject.Attribute("Name").Value; s.Weight = ele_subject.Attribute("Weight").Value; s.AssessmentList = new List <Assessment>(); foreach (XElement ele_assessment in ele_subject.Elements("Assessment")) { Assessment a = new Assessment(); a.Name = ele_assessment.Attribute("Name").Value; a.Weight = ele_assessment.Attribute("Weight").Value; a.TeacherSequence = ele_assessment.Attribute("TeacherSequence").Value; a.Type = ele_assessment.Attribute("Type").Value; a.AllowCustomAssessment = ele_assessment.Attribute("AllowCustomAssessment").Value; if (a.Type == "Comment") // 假如是 評語類別,多讀一項 輸入限制屬性 { a.InputLimit = ele_assessment.Attribute("InputLimit").Value; } a.IndicatorsList = new List <Indicators>(); if (ele_assessment.Element("Indicators") != null) { foreach (XElement ele_Indicator in ele_assessment.Element("Indicators").Elements("Indicator")) { Indicators i = new Indicators(); i.Name = ele_Indicator.Attribute("Name").Value; i.Description = ele_Indicator.Attribute("Description").Value; a.IndicatorsList.Add(i); } } s.AssessmentList.Add(a); } t.SubjectList.Add(s); } _ESLTemplateDict[templateID].TermList.Add(t); } } } } #endregion _eslTemplate = _ESLTemplateDict[_ESLCourseIDExamTermIDDict[_targetCourseID]]; //_scoreDict = scoreDict; labelX1.Text = _targetCourseName; // 填 試別 FillcboExam(); // 填入分數 //FillScore(); }