Пример #1
0
 private void SaveProperties(object sender, EventArgs e)
 {
     Shared.Properties properties = new Shared.Properties()
     {
         Code         = txt_code.Text,
         Instructions = txt_instruction.Text,
         Passmark     = (int)num_passmark.Value,
         TimeLimit    = (int)num_time_limit.Value,
         Title        = txt_title.Text,
         Version      = (int)float.Parse(lbl_version.Text)
     };
     //
     if (trv_view_exam.Nodes.Count > 0)
     {
         ExamNode examNode = (ExamNode)trv_view_exam.Nodes[0];
         examNode.Properties = properties;
     }
     else
     {
         ExamNode examNode = new ExamNode(properties);
         trv_view_exam.Nodes.Add(examNode);
     }
     //
     trv_view_exam.ExpandAll();
     //
     EnableExamControls();
     EnableSectionControls();
     //
     IsDirty = true;
 }
Пример #2
0
 private void Open()
 {
     this.exam = Helper.GetExamFromFile(currentExamFile);
     if (this.exam != null)
     {
         //
         trv_view_exam.Nodes.Clear();
         EnableExamControls();
         EnableSectionControls();
         //
         ExamNode examNode = new ExamNode(exam.Properties);
         trv_view_exam.Nodes.Add(examNode);
         foreach (Section section in exam.Sections)
         {
             SectionNode sectionNode = new SectionNode(section.Title)
             {
                 ContextMenuStrip = cms_section
             };
             foreach (Question question in section.Questions)
             {
                 QuestionNode questionNode = new QuestionNode(question)
                 {
                     ContextMenuStrip = cms_question
                 };
                 //
                 sectionNode.Nodes.Add(questionNode);
             }
             examNode.Nodes.Add(sectionNode);
         }
         trv_view_exam.ExpandAll();
         //
         if (splitContainer2.Panel2.Controls.Contains(pan_splash))
         {
             splitContainer2.Panel2.Controls.Remove(pan_splash);
             splitContainer2.Panel2.Controls.Add(pan_exam_properties);
         }
         //
         txt_code.Text        = exam.Properties.Code;
         txt_instruction.Text = exam.Properties.Instructions;
         txt_title.Text       = exam.Properties.Title;
         num_passmark.Value   = (decimal)exam.Properties.Passmark;
         num_time_limit.Value = exam.Properties.TimeLimit;
         //
         this.undoRedo = new UndoRedo();
     }
     else
     {
         MessageBox.Show("Sorry, the exam selected is either old or corrupt. If it is an old exam, please upgrade it with the upgrade tool at:\nhttps://sourceforge.net/projects/exam-upgrade-tool/", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #3
0
 private void Save(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(currentExamFile))
     {
         SaveAs(sender, e);
     }
     else
     {
         if (trv_view_exam.SelectedNode != null)
         {
             if (trv_view_exam.SelectedNode.GetType() == typeof(QuestionNode))
             {
                 CommitQuestion();
             }
         }
         //
         ExamNode examNode = (ExamNode)trv_view_exam.Nodes[0];
         this.exam.Properties = examNode.Properties;
         this.exam.Sections.Clear();
         foreach (SectionNode sectionNode in examNode.Nodes)
         {
             Section section = new Section()
             {
                 Title = sectionNode.Title
             };
             foreach (QuestionNode questionNode in sectionNode.Nodes)
             {
                 Question question = new Question();
                 question = questionNode.Question;
                 //
                 section.Questions.Add(question);
             }
             this.exam.Sections.Add(section);
         }
         //
         Helper.WriteExamToFile(this.exam, currentExamFile);
         MessageBox.Show("Exam has been sucessfully saved.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         IsDirty = false;
     }
     //
     if (Properties.Settings.Default.Exams == null)
     {
         Properties.Settings.Default.Exams = new System.Collections.Specialized.StringCollection();
     }
     if (!Properties.Settings.Default.Exams.Contains(currentExamFile))
     {
         Properties.Settings.Default.Exams.Add(currentExamFile);
     }
     Properties.Settings.Default.Save();
 }
Пример #4
0
        private void Open()
        {
            this.exam = Helper.GetExamFromFile(currentExamFile);
            //
            trv_view_exam.Nodes.Clear();
            EnableExamControls();
            EnableSectionControls();
            //
            ExamNode examNode = new ExamNode(exam.Properties);

            trv_view_exam.Nodes.Add(examNode);
            foreach (Section section in exam.Sections)
            {
                SectionNode sectionNode = new SectionNode(section.Title)
                {
                    ContextMenuStrip = cms_section
                };
                foreach (Question question in section.Questions)
                {
                    QuestionNode questionNode = new QuestionNode(question)
                    {
                        ContextMenuStrip = cms_question
                    };
                    //
                    sectionNode.Nodes.Add(questionNode);
                }
                examNode.Nodes.Add(sectionNode);
            }
            trv_view_exam.ExpandAll();
            //
            if (splitContainer2.Panel2.Controls.Contains(pan_splash))
            {
                splitContainer2.Panel2.Controls.Remove(pan_splash);
                splitContainer2.Panel2.Controls.Add(pan_exam_properties);
            }
            //
            txt_code.Text        = exam.Properties.Code;
            txt_instruction.Text = exam.Properties.Instructions;
            txt_title.Text       = exam.Properties.Title;
            num_passmark.Value   = (decimal)exam.Properties.Passmark;
            num_time_limit.Value = exam.Properties.TimeLimit;
            //
            this.undoRedo = new UndoRedo();
        }
Пример #5
0
        private void SaveProperties(object sender, EventArgs e)
        {
            Shared.Properties properties = new Shared.Properties();
            properties.Code         = txt_code.Text;
            properties.Instructions = txt_instruction.Text;
            properties.Passmark     = (int)num_passmark.Value;
            properties.TimeLimit    = (int)num_time_limit.Value;
            properties.Title        = txt_title.Text;
            properties.Version      = int.Parse(lbl_version.Text);
            //
            ExamNode examNode = new ExamNode(properties);

            trv_view_exam.Nodes.Add(examNode);
            //
            trv_view_exam.ExpandAll();
            //
            EnableExamControls();
            EnableSectionControls();
            //
            IsDirty = true;
        }
Пример #6
0
 public void SetExamNode(ExamNode node)
 {
     this.currentExamNode = node;
 }