Ejemplo n.º 1
0
        private void TimerTest_Tick(object sender, EventArgs e)
        {
            clockTest.Value = System.DateTime.Now;
            string   s       = string.Format("{0}:{1}:{2}", Convert.ToDateTime(pemp.testDateBegin.Value).Hour, Convert.ToDateTime(pemp.testDateBegin.Value).Minute, Convert.ToDateTime(pemp.testDateBegin.Value).Second);
            TimeSpan m       = pemp.testDateBegin.Value.AddMinutes(pemp.testTimeToLive.Value).TimeOfDay - System.DateTime.Now.TimeOfDay;
            int      hours   = (int)m.TotalSeconds / 3600;
            int      minutes = ((int)m.TotalSeconds % 3600) / 60;
            int      seconds = ((int)m.TotalSeconds % 3600 % 60);

            lbTimeToEnd.Text = string.Format("{0}:{1}", minutes, seconds);
            if (m.TotalSeconds < 0)
            {
                timerTest.Stop();
                gpQuiz.Enabled = false;
                //tự động kết thúc bài thi
                //tổng hợp các điểm số từ bảng tạm
                int    qt = TracNghiem.SoCauTraLoiDung(temp.id, pemp.id);
                string tb = string.Format("Điểm là {0}, số câu đúng {1}", qt * 10.0 / 60, qt);
                //lưu vào bảng kết quả
                RESULT t = new RESULT()
                {
                    idCom = pemp.id, idStudent = temp.id, score = qt * 10.0 / 60
                };
                TracNghiem.GhiKetQuaLai(t);
                //xóa tất cả các record từ bảng tạm
            }
        }
Ejemplo n.º 2
0
        private void btnEndCom_Click(object sender, EventArgs e)
        {
            //tổng hợp các điểm số từ bảng tạm
            int    qt = TracNghiem.SoCauTraLoiDung(temp.id, pemp.id);
            string tb = string.Format("Điểm là {0}, số câu đúng {1}", qt * 10.0 / 60, qt);

            MessageBox.Show(tb);
            //lưu vào bảng kết quả
            //xóa tất cả các record từ bảng tạm
            RESULT t = new RESULT()
            {
                idCom = pemp.id, idStudent = temp.id, idSubtract = pemp.subtractID, score = qt * 10.0 / 60
            };

            TracNghiem.GhiKetQuaLai(t);
            TracNghiem.XoaBangTam(pemp.id, temp.id, pemp.subtractID);
            gpQuiz.Enabled = false;
            Close();
        }