Esempio n. 1
0
        public SCETakeRecordEditor(SCAttendRecord scattend, ExamRecord exam)
        {
            Score  = null;
            Effort = null;
            Text   = string.Empty;

            RefSCAttendID = scattend.ID;
            RefExamID     = exam.ID;
            RefStudentID  = scattend.RefStudentID;
            RefCourseID   = scattend.RefCourseID;
        }
Esempio n. 2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            StringBuilder         sb     = new StringBuilder();
            List <SCAttendRecord> update = new List <SCAttendRecord>();

            if (_targetCourse != null)
            {
                //MessageBox.Show(_targetCourse.Name + ":" + _targetCourse.MajorTeacherName);

                //取得目標修課紀錄
                List <SCAttendRecord> sca_records = K12.Data.SCAttend.SelectByCourseIDs(new string[] { _targetCourse.ID });

                //整理對照目標修課紀錄
                _targetSCADic.Clear();
                foreach (SCAttendRecord scr in sca_records)
                {
                    _targetSCADic.Add(scr.RefStudentID, scr);
                }

                bool mustAsk = true;
                //複製課程成績
                foreach (SCAttendRecord source in _sourceSCAs)
                {
                    //只複製兩邊皆有的學生資料
                    if (_targetSCADic.ContainsKey(source.RefStudentID))
                    {
                        SCAttendRecord target = _targetSCADic[source.RefStudentID];
                        StudentRecord  stu    = _studentDic[source.RefStudentID];
                        //目標已有成績資料
                        if (target.Score.HasValue)
                        {
                            //選過一律覆寫就不再提問
                            if (mustAsk)
                            {
                                DialogResult result = new AskForm(string.Format("學生:{0} 已存在成績資料,確認覆寫?", stu.Name)).ShowDialog();
                                if (result == DialogResult.No)
                                {
                                    continue;
                                }
                                else if (result == DialogResult.Abort)
                                {
                                    mustAsk = false;
                                }
                            }
                        }

                        string old_score = target.Score + "";
                        string new_score = source.Score + "";

                        //前後不同的成績將被加入update清單並寫進log
                        if (old_score != new_score)
                        {
                            target.Score = source.Score;
                            update.Add(target);
                            sb.AppendLine(string.Format("學生:{0} 學號:{1} 成績由「{2}」改為「{3}」", stu.Name, stu.StudentNumber, old_score, new_score));
                        }
                    }
                }

                if (update.Count > 0)
                {
                    K12.Data.SCAttend.Update(update);
                    WriteLog(sb);
                }

                MessageBox.Show("複製完成");
            }
            else
            {
                MessageBox.Show("請選擇目標課程");
            }
        }
Esempio n. 3
0
        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();
        }