Beispiel #1
0
        /// <summary>
        /// Form_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CourseScoreInputForm_Load(object sender, EventArgs e)
        {
            _studentRowDict = new Dictionary <string, DataGridViewRow>();
            _dirtyCellList  = new List <DataGridViewCell>();

            #region 取得修課學生

            //_scAttendRecordList = _course.GetAttends();
            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            FillStudentsToDataGridView();
            #endregion

            #region 取得評量設定

            _assessmentSetupRecord = _course.GetAssessmentSetup();
            _aeIncludeRecordList   = JHAEInclude.SelectByAssessmentSetupID(_assessmentSetupRecord.ID).AsKHJHAEIncludeRecords();

            FillToComboBox();

            // 當沒有試別關閉
            if (cboExamList.Items.Count < 1)
            {
                this.Close();
            }

            // 載入分數顏色
            LoadDvScoreColor();

            _ExamName = cboExamList.Text;
            #endregion
        }
        private void Instance_ItemUpdated(object sender, ItemUpdatedEventArgs e)
        {
            if (e.PrimaryKeys.Count > 0)
            {
                if (cboExistTemplates.Enabled == true && cboExistTemplates.SelectedItem is AssessmentSetupRecord)
                {
                    AssessmentSetupRecord source = cboExistTemplates.SelectedItem as AssessmentSetupRecord;
                    bool executeRequired         = false;

                    List <AEIncludeRecordEditor> aeincludeEditors = new List <AEIncludeRecordEditor>();
                    foreach (var each in source.GetAEIncludes())
                    {
                        AEIncludeRecordEditor aeincludeEditor = AEInclude.Instance.AddAEInclude();
                        aeincludeEditor.RefAssessmentSetupID = e.PrimaryKeys[0];
                        aeincludeEditor.RefExamID            = each.RefExamID;
                        aeincludeEditor.UseScore             = each.UseScore;
                        aeincludeEditor.UseText   = each.UseText;
                        aeincludeEditor.UseEffort = each.UseEffort;
                        aeincludeEditor.Weight    = each.Weight;
                        aeincludeEditor.StartTime = each.StartTime;
                        aeincludeEditor.EndTime   = each.EndTime;

                        aeincludeEditors.Add(aeincludeEditor);
                        executeRequired = true;
                    }
                    if (executeRequired)
                    {
                        aeincludeEditors.SaveAllEditors();
                    }
                }
            }
            AssessmentSetup.Instance.ItemUpdated -= new EventHandler <ItemUpdatedEventArgs>(Instance_ItemUpdated);
        }
        private bool CanContinue()
        {
            if (IsDirty() || lblIsDirty.Visible)
            {
                DialogResult dr = MsgBox.Show("您未儲存目前資料,是否要儲存?", Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                if (dr == DialogResult.Cancel)
                {
                    CurrentItem.RaiseClick();
                    return(false);
                }
                else if (dr == DialogResult.Yes)
                {
                    AssessmentSetupRecord rec = CurrentItem.Tag as AssessmentSetupRecord;
                    if (rec != null)
                    {
                        SaveAssessmentSetupToDB(rec.ID);
                    }

                    if (!SaveTemplate())
                    {
                        CurrentItem.RaiseClick();
                        return(false);
                    }
                    //ReloadTempalte(CurrentItem);
                }
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Form_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CourseScoreInputForm_Load(object sender, EventArgs e)
        {
            _studentRowDict = new Dictionary <string, DataGridViewRow>();
            _dirtyCellList  = new List <DataGridViewCell>();

            #region 取得修課學生

            //_scAttendRecordList = _course.GetAttends();
            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            FillStudentsToDataGridView();

            #endregion

            #region 取得評量設定

            _assessmentSetupRecord = _course.GetAssessmentSetup();
            if (!AEInclude.Instance.Loaded)
            {
                AEInclude.Instance.SyncAllBackground();
            }
            _aeIncludeRecordList = _assessmentSetupRecord.GetAEIncludes();

            FillToComboBox();

            #endregion
        }
Beispiel #5
0
 internal AssessmentSetupRecordEditor(AssessmentSetupRecord record)
     : this()
 {
     ID              = record.ID;
     Name            = record.Name;
     Description     = record.Description;
     AssessmentSetup = record;
 }
        private void AddToList(AssessmentSetupRecord record)
        {
            ButtonItem item = new ButtonItem();

            item.Text         = record.Name;
            item.Tag          = record;
            item.OptionGroup  = "AssessmentSetup";
            item.Click       += new EventHandler(AssessmentSetup_Click);
            item.DoubleClick += new EventHandler(AssessmentSetup_DoubleClick);
            ipList.Items.Add(item);
            ipList.RecalcLayout();
        }
        /// <summary>
        /// 依試別取得所有關聯課程
        /// </summary>
        /// <param name="exam_id"></param>
        private void LoadCourses(string exam_id)
        {
            Dictionary <CourseRecord, AEIncludeRecord> courseAEDict = new Dictionary <CourseRecord, AEIncludeRecord>();

            foreach (var course in Course.Instance.Items)
            {
                if (course.SchoolYear != intSchoolYear.Value)
                {
                    continue;
                }
                if (course.Semester != intSemester.Value)
                {
                    continue;
                }

                AssessmentSetupRecord asRecord = course.GetAssessmentSetup();
                if (asRecord == null)
                {
                    continue;
                }

                foreach (var ae in asRecord.GetAEIncludes())
                {
                    if (ae.RefExamID == exam_id)
                    {
                        if (!courseAEDict.ContainsKey(course))
                        {
                            courseAEDict.Add(course, ae);
                        }
                    }
                }
            }

            Dictionary <string, List <SCETakeRecord> > courseScoreDict = GetCourseScores(exam_id);

            _courseListViewItemList.Clear();

            foreach (CourseRecord course in courseAEDict.Keys)
            {
                List <SCETakeRecord> sceList = null;
                if (courseScoreDict.ContainsKey(course.ID))
                {
                    sceList = courseScoreDict[course.ID];
                }
                else
                {
                    sceList = new List <SCETakeRecord>();
                }

                CourseListViewItem item = new CourseListViewItem(course, courseAEDict[course], sceList);
                _courseListViewItemList.Add(item);
            }
        }
        public AssessmentNameEditor(AssessmentSetupRecord record)
        {
            InitializeComponent();

            _record              = record;
            _orig_name           = record.Name;
            txtTemplateName.Text = record.Name;
            txtTemplateName.SelectAll();

            Text = "重新命名評分樣版";
            lblCopyExist.Enabled      = lblCopyExist.Visible = false;
            cboExistTemplates.Enabled = cboExistTemplates.Visible = false;
            Size = new Size(373, 104);
        }
        public AssessmentNameEditor()
        {
            InitializeComponent();

            _record    = null;
            _orig_name = string.Empty;
            Text       = "新增評分樣版";

            foreach (var item in AssessmentSetup.Instance.Items)
            {
                cboExistTemplates.Items.Add(item);
            }
            //foreach (Template tpl in templates)
            //    cboExistTemplates.Items.Add(tpl);
            cboExistTemplates.SelectedIndex = 0;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (CurrentItem == null)
                {
                    return;
                }

                string msg = "確定要刪除「" + (CurrentItem.Tag as AssessmentSetupRecord).Name + "」評量設定?\n";
                msg += "刪除後,使用此評量設定的「課程」將會自動變成未設定評量設定狀態。";

                DialogResult dr = MsgBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    AssessmentSetupRecord        record  = CurrentItem.Tag as AssessmentSetupRecord;
                    List <AEIncludeRecordEditor> editors = new List <AEIncludeRecordEditor>();
                    foreach (var item in record.GetAEIncludes())
                    {
                        AEIncludeRecordEditor editor = item.GetEditor();
                        editor.Remove = true;
                        editors.Add(editor);
                    }
                    if (editors.Count > 0)
                    {
                        editors.SaveAllEditors();
                    }

                    AssessmentSetupRecordEditor ASEditor = record.GetEditor();
                    ASEditor.Remove = true;
                    ASEditor.Save();
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.Message);
                //CurrentUser.ReportError(ex);
            }
        }
        private void RefreshItemPanel(string id)
        {
            AssessmentSetupRecord record     = AssessmentSetup.Instance.Items[id];
            ButtonItem            updateItem = null;

            foreach (ButtonItem item in ipList.Items)
            {
                AssessmentSetupRecord r = item.Tag as AssessmentSetupRecord;
                if (r.ID == id)
                {
                    updateItem = item;
                    break;
                }
            }

            if (record != null && updateItem == null) //Insert
            {
                AddToList(record);
                ipList.Refresh();
                ipList.EnsureVisible(ipList.Items[ipList.Items.Count - 1]);
            }
            else if (record != null && updateItem != null) //Update
            {
                updateItem.Tag = record;
            }
            else if (record == null && updateItem != null) //Delete
            {
                updateItem.Click       -= new EventHandler(AssessmentSetup_Click);
                updateItem.DoubleClick -= new EventHandler(AssessmentSetup_DoubleClick);
                ipList.Items.Remove(updateItem);
                ipList.Refresh();
                SelectAssessmentSetup(null);
                CurrentItem = null;
                ResetDirty();
            }
        }
        private bool SaveTemplate()
        {
            if (HasErrors())
            {
                MsgBox.Show("請修正資料後再儲存。", Application.ProductName);
                return(false);
            }

            try
            {
                //string startTime = DateToSaveFormat(CurrentItem.StartTime);
                //string endTime = DateToSaveFormat(CurrentItem.EndTime);

                //if (cboScoreSource.SelectedIndex == 0)
                //{
                //    //if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime))
                //    //{
                //    //    MsgBox.Show("由教師提供課程成績必須指定上傳時間。", Application.ProductName);
                //    //    return false;
                //    //}
                //    //由教師提供
                //    EditTemplate.UpdateTemplate(CurrentItem.Identity, CurrentItem.TemplateName, CurrentItem.AllowUpload, startTime, endTime);
                //}
                //else //由學校計算
                //{
                //    foreach (DataGridViewRow each in dataview.Rows)
                //    {
                //        if (each.IsNewRow) continue;

                //        if ((bool)each.Cells["InputRequired"].FormattedValue)
                //        {
                //            MsgBox.Show("成績由「學校計算」時,所有「評量」必需設定成「強制繳交成績」。");
                //            return false;
                //        }
                //    }

                //    EditTemplate.UpdateTemplate(CurrentItem.Identity, CurrentItem.TemplateName, CurrentItem.AllowUpload, string.Empty, string.Empty);
                //}

                AssessmentSetupRecord record = CurrentItem.Tag as AssessmentSetupRecord;

                List <AEIncludeRecordEditor> editors = new List <AEIncludeRecordEditor>();
                foreach (var item in record.GetAEIncludes())
                {
                    AEIncludeRecordEditor editor = item.GetEditor();
                    editor.Remove = true;
                    editors.Add(editor);
                }
                if (editors.Count > 0)
                {
                    editors.SaveAllEditors();
                }

                editors = new List <AEIncludeRecordEditor>();
                foreach (DataGridViewRow each in dataview.Rows)
                {
                    if (each.IsNewRow)
                    {
                        continue;
                    }

                    AEIncludeRecordEditor editor = AEInclude.Instance.AddAEInclude();
                    editor.RefAssessmentSetupID = record.ID;
                    editor.RefExamID            = "" + each.Cells[ExamID.Index].Value;
                    editor.UseScore             = GetYesNoString(each.Cells[UseScore.Index].FormattedValue, false);
                    editor.UseText   = GetYesNoString(each.Cells[UseText.Index].FormattedValue, false);
                    editor.UseEffort = GetYesNoString(each.Cells[UseEffort.Index].FormattedValue, false);
                    int i;
                    editor.Weight    = int.TryParse("" + each.Cells[Weight.Index].Value, out i) ? i : 0;
                    editor.StartTime = DateToSaveFormat("" + each.Cells[StartTime.Index].Value);
                    editor.EndTime   = DateToSaveFormat("" + each.Cells[EndTime.Index].Value);

                    editors.Add(editor);
                }
                if (editors.Count > 0)
                {
                    editors.SaveAllEditors();
                }

                _listener.Reset();

                return(true);
            }
            catch (Exception ex)
            {
                //CurrentUser.ReportError(ex);
                MsgBox.Show(ex.Message);
                return(false);
            }
        }
        private bool SaveTemplate()
        {
            if (HasErrors())
            {
                MsgBox.Show("請修正資料後再儲存。", Application.ProductName);
                return(false);
            }

            try
            {
                AssessmentSetupRecord record = CurrentItem.Tag as AssessmentSetupRecord;

                List <JHAEIncludeRecord> list = JHAEInclude.SelectByAssessmentSetupID(record.ID);
                int w = JHAEInclude.Delete(list);

                List <AEIncludeRecordEditor> editors = new List <AEIncludeRecordEditor>();
                //foreach (var item in record.GetAEIncludes())
                //{
                //    AEIncludeRecordEditor editor = item.GetEditor();
                //    editor.Remove = true;
                //    editors.Add(editor);
                //}
                //if (editors.Count > 0)
                //    editors.SaveAll();

                //editors = new List<AEIncludeRecordEditor>();
                list = new List <JHAEIncludeRecord>();
                foreach (DataGridViewRow each in dataview.Rows)
                {
                    if (each.IsNewRow)
                    {
                        continue;
                    }

                    HC.JHAEIncludeRecord hc = new HC.JHAEIncludeRecord(new JHAEIncludeRecord());
                    hc.RefAssessmentSetupID = record.ID;
                    hc.RefExamID            = "" + each.Cells[ExamID.Index].Value;
                    hc.UseScore             = GetYesNoString(each.Cells[UseScore.Index].FormattedValue, false);
                    hc.UseText            = GetYesNoString(each.Cells[UseText.Index].FormattedValue, false);
                    hc.UseAssignmentScore = GetYesNoString(each.Cells[UseAssignmentScore.Index].FormattedValue, false);
                    int i;
                    hc.Weight    = int.TryParse("" + each.Cells[Weight.Index].Value, out i) ? i : 0;
                    hc.StartTime = DateToSaveFormat("" + each.Cells[StartTime.Index].Value);
                    hc.EndTime   = DateToSaveFormat("" + each.Cells[EndTime.Index].Value);

                    list.Add(hc.AsJHAEIncludeRecord());
                }
                if (list.Count > 0)
                {
                    JHAEInclude.Insert(list);
                }

                ResetDirty();

                return(true);
            }
            catch (Exception ex)
            {
                //CurrentUser.ReportError(ex);
                MsgBox.Show(ex.Message);
                return(false);
            }
        }
Beispiel #14
0
 internal AEIncludeRecordEditor(AssessmentSetupRecord assessmentSetup, ExamRecord exam)
 {
     RefAssessmentSetupID = assessmentSetup.ID;
     RefExamID            = exam.ID;
 }
        private void SelectAssessmentSetup(ButtonItem item)
        {
            dataview.Rows.Clear();

            //cboScoreSource.Enabled = (item != null);
            //txtStartTime.Enabled = (item != null);
            //txtEndTime.Enabled = (item != null);
            ipt01.Tag = null;
            if (item == null)
            {
                peTemplateName1.Text        = string.Empty;
                dataview.AllowUserToAddRows = false;
                //panel1.Enabled = false;
                ipt01.Enabled = false;
                return;
            }
            else
            {
                AssessmentSetupRecord record = (item.Tag as AssessmentSetupRecord);
                peTemplateName1.Text        = record.Name;
                dataview.AllowUserToAddRows = true;
                //panel1.Enabled = true;


                // 需要儲存樣版比例
                if (_CheckSaveAssessmentSetup)
                {
                    SaveAssessmentSetupToDB(record.ID);
                    _CheckSaveAssessmentSetup = false;
                }

                ipt01.Text    = "50";
                ipt01.Enabled = true;

                // 取得比例
                QueryHelper qh       = new QueryHelper();
                string      selQuery = "select id,extension from exam_template where id=" + record.ID;
                DataTable   dt       = qh.Select(selQuery);
                string      xmlStr   = "<root>" + dt.Rows[0]["extension"].ToString() + "</root>";
                XElement    elmRoot  = XElement.Parse(xmlStr);

                if (elmRoot != null)
                {
                    if (elmRoot.Element("Extension") != null)
                    {
                        if (elmRoot.Element("Extension").Element("ScorePercentage") != null)
                        {
                            ipt01.Text = elmRoot.Element("Extension").Element("ScorePercentage").Value;
                        }
                    }
                }

                foreach (var ae in JHAEInclude.SelectByAssessmentSetupID(record.ID))
                {
                    HC.JHAEIncludeRecord each = new HC.JHAEIncludeRecord(ae);
                    DataGridViewRow      row  = new DataGridViewRow();
                    row.CreateCells(dataview, each.RefExamID, each.Weight, each.UseScore, each.UseAssignmentScore, each.UseText, "", each.StartTime, each.EndTime);
                    dataview.Rows.Add(row);
                }

                item.RaiseClick();
                ResetDirty();
            }
        }
        /// <summary>
        /// 依試別取得所有關聯課程
        /// </summary>
        /// <param name="exam_id"></param>
        private void LoadCourses(string exam_id)
        {
            Dictionary <CourseRecord, KH.JHAEIncludeRecord> courseAEDict = new Dictionary <CourseRecord, KH.JHAEIncludeRecord>();

            List <string> CourseIDs = new List <string>();

            foreach (var course in Course.Instance.Items)
            {
                if (course.SchoolYear != intSchoolYear.Value)
                {
                    continue;
                }
                if (course.Semester != intSemester.Value)
                {
                    continue;
                }

                CourseIDs.Add(course.ID);
                AssessmentSetupRecord asRecord = course.GetAssessmentSetup();
                if (asRecord == null)
                {
                    continue;
                }

                foreach (KH.JHAEIncludeRecord ae in _aeCache.Values)
                {
                    if (ae.RefAssessmentSetupID == asRecord.ID &&
                        ae.RefExamID == exam_id)
                    {
                        if (!courseAEDict.ContainsKey(course))
                        {
                            courseAEDict.Add(course, ae);
                        }
                    }
                }

                //foreach (var ae in asRecord.GetAEIncludes())
                //{
                //    if (ae.RefExamID == exam_id)
                //    {
                //        KH.JHAEIncludeRecord ae2 = _aeCache[ae.ID];
                //        if (!courseAEDict.ContainsKey(course))
                //            courseAEDict.Add(course, ae2);
                //    }
                //}
            }

            Dictionary <string, List <KH.JHSCETakeRecord> > courseScoreDict = GetCourseScores(exam_id, CourseIDs);

            _courseListViewItemList.Clear();
            foreach (CourseRecord course in courseAEDict.Keys)
            {
                List <KH.JHSCETakeRecord> sceList = null;
                if (courseScoreDict.ContainsKey(course.ID))
                {
                    sceList = courseScoreDict[course.ID];
                }
                else
                {
                    sceList = new List <KH.JHSCETakeRecord>();
                }

                CourseListViewItem item = new CourseListViewItem(course, courseAEDict[course], sceList);
                _courseListViewItemList.Add(item);
            }
        }
Beispiel #17
0
 /// <summary>
 /// 取得評分設定的 Editor。
 /// </summary>
 /// <returns></returns>
 public static AssessmentSetupRecordEditor GetEditor(this AssessmentSetupRecord record)
 {
     return(new AssessmentSetupRecordEditor(record));
 }
        /// <summary>
        /// Form_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CourseScoreInputForm_Load(object sender, EventArgs e)
        {
            _studentRowDict = new Dictionary <string, DataGridViewRow>();
            _dirtyCellList  = new List <DataGridViewCell>();

            #region 取得評量成績缺考暨免試設定

            PluginMain.ScoreTextMap.Clear();
            PluginMain.ScoreValueMap.Clear();

            Framework.ConfigData cd = JHSchool.School.Configuration["評量成績缺考暨免試設定"];
            if (!string.IsNullOrEmpty(cd["評量成績缺考暨免試設定"]))
            {
                XmlElement element = Framework.XmlHelper.LoadXml(cd["評量成績缺考暨免試設定"]);

                foreach (XmlElement each in element.SelectNodes("Setting"))
                {
                    var     UseText          = each.SelectSingleNode("UseText").InnerText;
                    var     AllowCalculation = bool.Parse(each.SelectSingleNode("AllowCalculation").InnerText);
                    decimal Score;
                    decimal.TryParse(each.SelectSingleNode("Score").InnerText, out Score);
                    var Active   = bool.Parse(each.SelectSingleNode("Active").InnerText);
                    var UseValue = decimal.Parse(each.SelectSingleNode("UseValue").InnerText);

                    if (Active)
                    {
                        if (!PluginMain.ScoreTextMap.ContainsKey(UseText))
                        {
                            PluginMain.ScoreTextMap.Add(UseText, new ScoreMap
                            {
                                UseText          = UseText,
                                AllowCalculation = AllowCalculation,
                                Score            = Score,
                                Active           = Active,
                                UseValue         = UseValue,
                            });
                        }
                        if (!PluginMain.ScoreValueMap.ContainsKey(UseValue))
                        {
                            PluginMain.ScoreValueMap.Add(UseValue, new ScoreMap
                            {
                                UseText          = UseText,
                                AllowCalculation = AllowCalculation,
                                Score            = Score,
                                Active           = Active,
                                UseValue         = UseValue,
                            });
                        }
                    }
                }
            }

            #endregion

            #region 取得修課學生

            //_scAttendRecordList = _course.GetAttends();
            _scAttendRecordList = JHSCAttend.SelectByCourseIDs(new string[] { _course.ID });

            FillStudentsToDataGridView();

            #endregion

            #region 取得評量設定

            _assessmentSetupRecord = _course.GetAssessmentSetup();
            _aeIncludeRecordList   = JHAEInclude.SelectByAssessmentSetupID(_assessmentSetupRecord.ID).AsHCJHAEIncludeRecords();

            FillToComboBox();

            // 當沒有試別關閉
            if (cboExamList.Items.Count < 1)
            {
                this.Close();
            }

            // 載入分數顏色
            LoadDvScoreColor();
            _ExamName = cboExamList.Text;
            #endregion
        }