private void FillAssessmentSetupToItemPanel()
 {
     foreach (JHAssessmentSetupRecord record in JHAssessmentSetup.SelectAll())
     {
         AddToList(record);
     }
 }
Esempio n. 2
0
        private void ReloadAssessmentSetupData()
        {
            cboAssessmentSetup.Items.Clear();
            cboAssessmentSetup.Items.Add(NoScoreItem);

            foreach (JHAssessmentSetupRecord each in JHAssessmentSetup.SelectAll())
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Text = each.Name;
                item.Tag  = each;
                cboAssessmentSetup.Items.Add(item);
            }
        }
Esempio n. 3
0
        public AssessmentNameEditor()
        {
            InitializeComponent();

            _record    = null;
            _orig_name = string.Empty;
            Text       = "新增評量設定";

            foreach (JHAssessmentSetupRecord item in JHAssessmentSetup.SelectAll())
            {
                cboExistTemplates.Items.Add(item);
            }
            cboExistTemplates.SelectedIndex = 0;
        }
Esempio n. 4
0
        /// <summary>
        /// 驗證課程
        /// </summary>
        /// <param name="courses"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        internal static bool ValidateCourses(List <JHCourseRecord> courses, UserConfig config)
        {
            MessageView view = new MessageView(MessageItemType.Course);

            view.ButtonVisible = false;
            view.Title         = string.Format("{0} 學年度 第 {1} 學期 {2}", config.SchoolYear, config.Semester, config.Exam.Name);

            #region 留下有效的科目課程
            List <JHCourseRecord> validCourses = new List <JHCourseRecord>();
            foreach (JHCourseRecord course in courses)
            {
                if (course.Subject != config.SourceSubject &&
                    !config.TargetSubjects.Contains(course.Subject))
                {
                    continue;
                }
                validCourses.Add(course);
            }
            #endregion

            List <JHCourseRecord> temp = new List <JHCourseRecord>();

            #region 檢查有沒有評量設定
            foreach (JHCourseRecord course in validCourses)
            {
                if (string.IsNullOrEmpty(course.RefAssessmentSetupID))
                {
                    view.Add(course.ID, course.Name, "沒有評量設定");
                }
                else
                {
                    temp.Add(course);
                }
            }
            validCourses = new List <JHCourseRecord>(temp);
            temp.Clear();
            #endregion

            #region 評量設定必須是一樣的
            List <string> asIDs = new List <string>();
            foreach (JHCourseRecord course in validCourses)
            {
                if (!asIDs.Contains(course.RefAssessmentSetupID))
                {
                    asIDs.Add(course.RefAssessmentSetupID);
                }
            }
            if (asIDs.Count > 1)
            {
                Dictionary <string, JHAssessmentSetupRecord> asDict = new Dictionary <string, JHAssessmentSetupRecord>();
                foreach (JHAssessmentSetupRecord asRecord in JHAssessmentSetup.SelectAll())
                {
                    asDict.Add(asRecord.ID, asRecord);
                }

                foreach (JHCourseRecord course in validCourses)
                {
                    view.Add(course.ID, course.Name, "評量設定為「" + asDict[course.RefAssessmentSetupID].Name + "」,所有科目需要有相同的評量設定");
                }
            }
            #endregion

            if (view.HasMessage)
            {
                view.ShowDialog();
                return(false);
            }

            #region 評量設定裡沒有選擇的試別
            if (asIDs.Count == 1)
            {
                bool found = false;
                foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupID(asIDs[0]))
                {
                    if (ae.RefExamID == config.Exam.ID)
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    JHAssessmentSetupRecord asRecord = JHAssessmentSetup.SelectByID(asIDs[0]);
                    foreach (JHCourseRecord course in validCourses)
                    {
                        view.Add(course.ID, course.Name, "評量設定「" + asRecord.Name + "」,沒有「" + config.Exam.Name + "」試別");
                    }
                }
            }
            #endregion

            if (view.HasMessage)
            {
                view.ShowDialog();
                return(false);
            }

            return(true);
        }