Esempio n. 1
0
        private void startExamBtn_Click(object sender, EventArgs e)
        {
            ExamLog.Add($"[{DateTime.Now}] Exam Started");
            startExamBtn.Enabled = false;
            myTimer.Interval     = 1000;
            myTimer.Tick        += (s, ee) => { RemainingExamTime -= 1; UpdateRemainingExamTime(); };
            myTimer.Start();

            submitExamBtn.Visible = true;

            ExaminationFlowLayoutHelper.AddQuestionToFlowLayout(ref flowlayout, ref aLogger, ref anExam,
                                                                ref assetsrtb, ref ExamLog);
        }
Esempio n. 2
0
        private void startExamBtn_Click(object sender, EventArgs e)
        {
            ExamLog.Add($"[{DateTime.Now}] Exam Started");
            startExamBtn.Enabled = false;
            myTimer.Interval     = 1000;
            myTimer.Tick        += (s, ee) => { RemainingExamTime -= 1; UpdateRemainingExamTime(); };
            myTimer.Start();

            submitExamBtn.Visible = true;

            ExaminationFlowLayoutHelper.AddQuestionToFlowLayout(ref flowlayout, ref aLogger, ref anExam, ref assetsrtb, ref ExamLog);
            return;
            // Prepare Questions

            //for (int i = 0; i < anExam.QuestionsList.Count; i++)
            //{
            //    var question = anExam.QuestionsList[i];
            //    var questionNumber = question.QuestionNumber;
            //    QuizHelper.AddQuestionTortb(ref assetsrtb, questionNumber, question, true, false);


            //    //Button question1Btn = new Button();
            //    //question1Btn.Tag = question;
            //    //question1Btn.AutoSize = true;
            //    //question1Btn.Text = "<- Add";
            //    //question1Btn.Click += (s, ee) =>
            //    //{
            //    //    QuizHelper.AddQuestionTortb(ref aRtb, questionNumber++, (Question)((Button)s).Tag, addAssets, addAnswers);
            //    //    FinalQuestions.Add((Question)((Button)s).Tag);

            //    //};

            //    Label question1Lbl = new Label();
            //    question1Lbl.Text = $"Q{questionNumber}. " + question.ToString();
            //    question1Lbl.AutoSize = true;
            //    question1Lbl.Font = new Font("Courier New", 12, FontStyle.Bold);

            //    flowlayout.Controls.Add(question1Lbl);
            //    // flowlayout.SetFlowBreak(question1Lbl, true);
            //    if (question.GetType() == typeof(MultipleChoiceQuestion))
            //    {
            //        GroupBox gb = new GroupBox();
            //        gb.Location = new Point(5, 20);
            //        gb.MinimumSize = new Size(100, 30);
            //        gb.AutoSize = true;
            //        gb.AutoSizeMode = AutoSizeMode.GrowOnly;
            //        gb.Text = "Choices";
            //        gb.Tag = questionNumber;

            //        int lastpos = 0;
            //        for (int j = 0; j < question.Choices.Count; j++)
            //        {
            //            var option = question.Choices[j];

            //            RadioButton rb = new RadioButton();
            //            rb.Location = new Point(7, lastpos += 20);
            //            rb.AutoSize = true;
            //            rb.Text = option;
            //            rb.Font = new Font("Courier New", 12, FontStyle.Bold);
            //            rb.CheckedChanged += (s, ee) =>
            //            {
            //                var rbb = s as RadioButton;
            //                if (rbb == null) return;
            //                //var selectedRb = gb.Controls.OfType<RadioButton>()
            //                //           .FirstOrDefault(r => r.Checked);
            //                if (rbb.Checked)
            //                {
            //                    question.StudentAnswer = rbb.Text;
            //                    aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
            //                    ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
            //                }

            //            };

            //            gb.Controls.Add(rb);
            //        }
            //        flowlayout.Controls.Add(gb);
            //        flowlayout.SetFlowBreak(gb, true);
            //    }
            //    else if (question.GetType() == typeof(TrueFalseQuestion))
            //    {
            //        GroupBox gb = new GroupBox();
            //        gb.Location = new Point(5, 20);
            //        gb.MinimumSize = new Size(100, 50);
            //        gb.AutoSize = true;
            //        gb.AutoSizeMode = AutoSizeMode.GrowOnly;
            //        gb.Text = "Choices";


            //        RadioButton rbt = new RadioButton();
            //        rbt.Location = new Point(7, 20);
            //        rbt.AutoSize = true;
            //        rbt.Text = true.ToString();
            //        rbt.Font = new Font("Courier New", 12, FontStyle.Bold);

            //        rbt.CheckedChanged += (s, ee) =>
            //        {
            //            var rbb = s as RadioButton;
            //            if (rbb == null) return;
            //                //var selectedRb = gb.Controls.OfType<RadioButton>()
            //                //           .FirstOrDefault(r => r.Checked);
            //                if (rbb.Checked)
            //            {
            //                question.StudentAnswer = rbb.Text;
            //                aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
            //                ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
            //            }

            //        };

            //        gb.Controls.Add(rbt);

            //        RadioButton rbf = new RadioButton();
            //        rbf.Location = new Point(7, 40);
            //        rbf.AutoSize = true;
            //        rbf.Text = false.ToString();
            //        rbf.Font = new Font("Courier New", 12, FontStyle.Bold);
            //        rbf.CheckedChanged += (s, ee) =>
            //        {
            //            var rbb = s as RadioButton;
            //            if (rbb == null) return;
            //            //var selectedRb = gb.Controls.OfType<RadioButton>()
            //            //           .FirstOrDefault(r => r.Checked);
            //            if (rbb.Checked)
            //            {
            //                question.StudentAnswer = rbb.Text;
            //                aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
            //                ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
            //            }

            //        };
            //        gb.Controls.Add(rbf);


            //        flowlayout.Controls.Add(gb);
            //        flowlayout.SetFlowBreak(gb, true);

            //    }
            //    else if (question.GetType() == typeof(ValueInputQuestion))
            //    {
            //        TextBox tb = new TextBox();
            //        tb.Width = 100;
            //        //tb.MouseLeave += (s, ee) =>
            //        //{
            //        //    question.StudentAnswer = tb.Text;
            //        //    aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
            //        //    ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
            //        //};
            //        tb.TextChanged += (s, ee) =>
            //        {
            //            if (_typingTimer == null)
            //            {
            //                /* WinForms: */
            //                _typingTimer = new Timer();
            //                _typingTimer.Interval = 1000;
            //                /* WPF:
            //                _typingTimer = new DispatcherTimer();
            //                _typingTimer.Interval = TimeSpan.FromMilliseconds(300);
            //                */

            //                _typingTimer.Tick += handleTypingTimerTimeout;
            //            }
            //            _typingTimer.Stop(); // Resets the timer
            //            question.StudentAnswer = tb.Text;
            //            aLogger.LogMessage($"[Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}", LogMsgType.Verbose);
            //            ExamLog.Add($"[{DateTime.Now}] [Answer Update for Question {questionNumber}.] [{question.ToString()}]  updated,  student answer = {question.StudentAnswer.ToString()}");
            //            // _typingTimer.Tag = (sender as TextBox).Text; // This should be done with EventArgs
            //            _typingTimer.Start();
            //        };
            //        flowlayout.Controls.Add(tb);
            //        flowlayout.SetFlowBreak(tb, true);
            //    }
            // }
        }