Exemplo n.º 1
0
        private void FillRounds()
        {
            var rounds = _quizRoundService.GetAll().Select(x => new { x.Id, x.Name }).ToList();

            DataTable dt = ExportExcelhelper.ListToDataTable(rounds);

            DataRow dr1 = dt.NewRow();

            dr1["Id"]   = 0;
            dr1["Name"] = "--Select Round --";
            dt.Rows.InsertAt(dr1, 0);

            RoundcomboBox.ValueMember   = "Id";
            RoundcomboBox.DisplayMember = "Name";

            RoundcomboBox.DataSource = dt;
        }
        public void GetQuestions()
        {
            DataTable dt = null;

            var questions = (from qq in _quizQuestionService.GetAll().ToList()
                             join ql in _quizLevelService.GetAll().ToList() on qq.LevelId equals ql.Id
                             join qr in _quizRoundService.GetAll().ToList() on qq.RoundId equals qr.Id
                             select new QuizQuestions
            {
                Id = qq.Id,
                AcademicYear = qq.AcademicYear,
                Level = ql.Name,
                Round = qr.Name,
                QuestionText = qq.Question,
                QuestionType = qq.QuestionType,
                DocUrl = qq.DocUrl,
                IsMCQ = qq.IsMCQ,
                CorrectAnswer = qq.CorrectAnswer,
                Option1 = qq.Option1,
                Option2 = qq.Option2,
                Option3 = qq.Option3,
                Option4 = qq.Option4,
                Time = qq.Time + " Sec."
            }).ToList();

            if (questions != null && questions.Count() != 0)
            {
                if (questions.Count() > 0)
                {
                    dt = ExportExcelhelper.ListToDataTable(questions);
                }
            }
            else
            {
                List <QuizQuestions> list = new List <QuizQuestions>();

                QuizQuestions quizQuestion = new QuizQuestions();
                list.Add(quizQuestion);

                dt = ExportExcelhelper.ListToDataTable(list);
                dt.Rows.RemoveAt(0);
            }

            QuestiondataGridView.AutoGenerateColumns   = true;
            QuestiondataGridView.DataSource            = dt;
            QuestiondataGridView.Columns["Id"].Visible = false;
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool   IsDisable    = false;
            string AcademicYear = Program.CurrAcademicYear;
            int    LevelId      = Convert.ToInt32(Level.Split(',')[1]);
            int    RoundId      = Convert.ToInt32(Round.Split(',')[1]);

            var NoOfQuestionPerTeam = _noQuesPerLeavelRoundService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId).Select(x => x.NoOfQuestion).FirstOrDefault();

            if (NoOfQuestionPerTeam != 0)
            {
                if (!String.IsNullOrEmpty(Program.TeamA))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamA).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }

                if (!String.IsNullOrEmpty(Program.TeamB))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamB).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }

                if (!String.IsNullOrEmpty(Program.TeamC))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamC).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }

                if (!String.IsNullOrEmpty(Program.TeamD))
                {
                    int TeamId          = _quizTeamService.GetAll().Where(x => x.Name == Program.TeamD).Select(x => x.Id).FirstOrDefault();
                    var NoOfAttemptQues = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId && x.TeamId == TeamId && x.AcademicYear == AcademicYear).ToList();

                    if (NoOfAttemptQues.Count() == NoOfQuestionPerTeam)
                    {
                        IsDisable = true;
                    }
                    else
                    {
                        IsDisable = false;
                    }
                }
            }

            if (IsDisable == true && Round.Split(',')[0] != "tie Breaker")
            {
                button1.Enabled = false;

                NexrRoundForm nextRoundForm = new NexrRoundForm();
                nextRoundForm.LevelROundLbl.Text = Level.Split(',')[0] + " " + Round.Split(',')[0] + " finished , Please click on next button";
                nextRoundForm.ShowDialog();
                this.Close();

                Program.Level = Level.Split(',')[0] + "," + LevelId.ToString();
                Program.Round = "Round4," + _quizRoundService.GetAll().Where(x => x.Name == "Round4").Select(x => x.Id).FirstOrDefault().ToString();

                Level2Round4Form Question = new Level2Round4Form();
                Question.Text = "Question";
                Question.Show();
            }
            else
            {
                GetQuestion();
            }
        }