public FrmExam(ExamineeTake examineeTake)
        {
            InitializeComponent();

            _examineeTakeInfo = examineeTake;

            _examBLL  = new ExamBLL();
            _examList = _examBLL.GetActiveExamList();

            _minutes = _examList.Sum(e => e.TimeLimit);

            _timeSpan = new TimeSpan(0, _minutes, 0);
            //_oneSecond = new TimeSpan(0, 0, 1);

            _subjectScoreList = new List <SubjectScore>();
            _questionBankList = new List <QuestionBank>();

            foreach (var question in _examList)
            {
                _questionBankList.AddRange(question.QuestionBank);
            }

            _examScore      = 0;
            _index          = 0;
            _questionNumber = 0;
            _counter        = 0;
            _millisecond    = 0;
            _doLoop         = true;

            _examineeExamList = _examineeTakeInfo.ExamineeExam.ToList();
            _examId           = _examineeExamList[_index].ExamId;

            SetQuestion();  //  set the first question
        }
Esempio n. 2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string          examCode        = txtExamCode.Text;
            ExamineeTakeBLL examineeTakeBLL = new ExamineeTakeBLL();
            ExamineeTake    examineeTake    = examineeTakeBLL.GetExamineeTakeInfo(examCode);

            if (examineeTake != null)
            {
                examineeTakeBLL.SetExamineeTakeChildInfo(examineeTake);

                Thread thread = new Thread(() =>
                {
                    //FrmExam frmExam = new FrmExam();
                    //frmExam.ExamineeTakeInfo = examineeTake;
                    //Application.Run(frmExam);
                    Application.Run(new FrmExam(examineeTake));
                });
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();

                this.Close();
            }
            else
            {
                lblStatus.Text = "  Invalid Exam Code!";
            }
        }
 public void UpdateOne(ExamineeTake examineeTake)
 {
     using (_context = new ExaminationContext())
     {
         //examineeTake.ExamDateTimeTaken = DateTime.Now.Date;
         _context.ExamineeExam.AddRange(examineeTake.ExamineeExam);
         //_context.ExamineeTake.Attach(examineeTake);
         _context.Entry(examineeTake).State = EntityState.Modified;
         _context.SaveChanges();
     }
 }
        public string InsertExamineeTake(ExamineeTake examineeTake)
        {
            using (_context = new ExaminationContext())
            {
                examineeTake.CodeDateTimeIssued = GetServerDateTime(_context);
                examineeTake.UserId             = UserInfo.UserId;
                _context.ExamineeTake.Add(examineeTake);
                _context.SaveChanges();
            }

            return(examineeTake.ExamCode);
        }
        public void UpdateExamineeTake(ExamineeTake examineeTake)
        {
            using (_context = new ExaminationContext())
            {
                //_context.ExamineeTake.Attach(examineeTake);
                //_context.ExamineeAnswer.AddRange(examineeTake.ExamineeExam.(s => s.ExamineeAnswer));

                //_context.Entry(examineeTake).State = EntityState.Modified;
                _context.ExamineeExam.AddRange(examineeTake.ExamineeExam);
                _context.Entry(examineeTake).State = EntityState.Modified;
                _context.SaveChanges();
            }
        }
        public string InsertExamineeTake(ExamineeTake examineeTake)
        {
            bool   doLoop   = true;
            string examCode = string.Empty;

            while (doLoop)
            {
                examCode = CreateExamCode();
                doLoop   = _examineeTakeDAL.IsUniqueExamCode(examCode) == true ? false : true;
            }

            examineeTake.ExamCode = examCode;

            return(_examineeTakeDAL.InsertExamineeTake(examineeTake));
        }
        public void SetExamineeTakeChildInfo(ExamineeTake examineeTake)
        {
            ExamBLL             examBLL     = new ExamBLL();
            List <Exam>         examList    = examBLL.GetActiveExamList();
            List <Exam>         newExamList = new List <Exam>();
            List <QuestionBank> questionBankList;

            string[] subjects;

            subjects = examList.Select(s => s.Subject.SubjectName).Distinct().ToArray();
            subjects.Shuffle();

            foreach (var subj in subjects)
            {
                newExamList.AddRange(examList.Where(ex => ex.Subject.SubjectName == subj));
            }

            foreach (var exam in newExamList)
            {
                //Console.WriteLine(exam.Subject.SubjectName);
                examineeTake.ExamineeExam.Add(new ExamineeExam
                {
                    ExamineeTakeId = examineeTake.ExamineeTakeId,
                    ExamId         = exam.ExamId,
                    Score          = 0
                                     //Exam = exam
                });

                questionBankList = exam.QuestionBank.ToList();
                questionBankList.Shuffle();

                foreach (var question in questionBankList)
                //foreach (var question in exam.QuestionBank)
                {
                    examineeTake.ExamineeExam.Single(s => s.ExamineeTakeId == examineeTake.ExamineeTakeId && s.ExamId == exam.ExamId)
                    .ExamineeAnswer.Add(new ExamineeAnswer
                    {
                        QuestionId = question.QuestionId,
                        IsCorrect  = false
                                     //QuestionBank = question
                    });
                }
            }
        }
Esempio n. 8
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(string.Format("Generate exam code for\nName: {0}\nEmail: {1} ?",
                                                                _examineeTakeStatusViewModelList[_index].FullName,
                                                                _examineeTakeStatusViewModelList[_index].Email), "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                //Console.WriteLine("CREATE EXAM CODE!");
                ExamineeTake examineeTake = new ExamineeTake();
                examineeTake.ExamineeId = _examineeTakeStatusViewModelList[_index].ExamineeId;

                string examCode = _examineeTakeBLL.InsertExamineeTake(examineeTake);

                lblExamCode.Text    = string.Format("Exam Code: {0}", examCode);
                lblStatus.Text      = "  Successfully created exam code for examinee";
                btnGenerate.Enabled = false;

                PopulateDataGridView(_nameOrEmail);
            }
        }
 public void UpdateOne(ExamineeTake examineeTake)
 {
     _examineeTakeDAL.UpdateOne(examineeTake);
 }