Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var attemptQuestions = _attamtedQuestionsService.GetAll().ToList();

            foreach (var item in attemptQuestions)
            {
                item.Marks = 0;
                _attamtedQuestionsService.Edit(item);
                _attamtedQuestionsService.Save();
            }

            ChooseTeam2comboBox.SelectedValue = 0;
            ChooseTeam1comboBox.SelectedValue = 0;
            ChooseTeam3comboBox.SelectedValue = 0;
            ChooseTeam4comboBox.SelectedValue = 0;

            DScorelabel.Visible = false;
            BScorelabel.Visible = false;
            AScorelabel.Visible = false;
            CScorelabel.Visible = false;
        }
Exemple #2
0
        private void ShowAnswerbtn_Click(object sender, EventArgs e)
        {
            timer1.Stop();

            int questionnid = Convert.ToInt32(questionidlabel.Text);
            int LevelId     = Convert.ToInt32(Level.Split(',')[1]);
            int RoundId     = Convert.ToInt32(Round.Split(',')[1]);

            var checkforattamt = _attamtedQuestionsService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId &&
                                                                          x.QuestionId == questionnid && x.AcademicYear == Program.CurrAcademicYear).ToList();

            if (checkforattamt.Count() == 0)
            {
                AttamtedQuestions attamtedQuestions = new AttamtedQuestions();
                attamtedQuestions.QuestionId = Convert.ToInt32(questionidlabel.Text);
                attamtedQuestions.LevelId    = Convert.ToInt32(Level.Split(',')[1]);
                attamtedQuestions.RoundId    = Convert.ToInt32(Round.Split(',')[1]);

                if (CorrecttextBox.Text != "" && WrongtextBox.Text != "")
                {
                    attamtedQuestions.Marks = Convert.ToInt32(CorrecttextBox.Text) * 10 + Convert.ToInt32(WrongtextBox.Text) * (-5);
                }

                attamtedQuestions.TeamId       = _quizTeamService.GetAll().Where(x => x.Name == TeanNamelabel.Text).Select(x => x.Id).FirstOrDefault();
                attamtedQuestions.TeamName     = TeanNamelabel.Text;
                attamtedQuestions.AcademicYear = AcademicYearlabel.Text;
                attamtedQuestions.IsTrue       = true;
                attamtedQuestions.CreatedBy    = "Admin";
                attamtedQuestions.CreatedDate  = DateTime.Now;

                _attamtedQuestionsService.Add(attamtedQuestions);
                _attamtedQuestionsService.Save();

                QuizTeam quizTeam = _quizTeamService.FindBy(x => x.Id == attamtedQuestions.TeamId).FirstOrDefault();
                quizTeam.Marks += attamtedQuestions.Marks;

                _quizTeamService.Edit(quizTeam);
                _quizTeamService.Save();

                CalculateMarks();
            }
            else
            {
                MessageBox.Show("You have already attempted this question, please go to next question", "Alert");
            }
        }
Exemple #3
0
        private void GetQuestion()
        {
            List <QuizQuestion> unattemptQuestions = null;

            Timelabel.BackColor = Color.OrangeRed;
            string AcademicYear = Program.CurrAcademicYear;
            int    LevelId      = Convert.ToInt32(Level.Split(',')[1]);
            int    RoundId      = Convert.ToInt32(Round.Split(',')[1]);

            var attempted = _attamtedQuestionsService.GetAll().Where(x => x.AcademicYear == AcademicYear).ToList();

            var questions = _quizQuestionService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId &&
                                                                x.AcademicYear == AcademicYear).ToList();

            if (attempted.Count() > 0)
            {
                unattemptQuestions = (from qu in questions
                                      where !attempted.Any(x => x.QuestionId == qu.Id)
                                      select qu).ToList();
            }
            else
            {
                unattemptQuestions = questions;
            }

            if (unattemptQuestions.Count() > 0)
            {
                var question = unattemptQuestions.ElementAt(RandomNumber(0, unattemptQuestions.Count()));

                Questionlabel.Text = question.Question;

                questionidlabel.Text    = question.Id.ToString();
                AcademicYearlabel.Text  = question.AcademicYear;
                CorrectAnswerlabel.Text = question.CorrectAnswer;

                Timelabel.Text = question.Time.ToString().Split('.')[0];
                quick          = Convert.ToInt32(question.Time);

                if (Convert.ToInt16(TeamIndexlabel.Text) >= Teams.Count())
                {
                    Teamindex = 0;
                }
                else
                {
                    Teamindex = Convert.ToInt16(TeamIndexlabel.Text);
                }

                QuizLevelandRoundlabel.Text = "Quiz " + Level.Split(',')[0] + " " + Round.Split(',')[0];

                if (IsSkip == false)
                {
                    QuestionForlabel.Text = "Question for Team " + Teams.ElementAt(Teamindex);
                    TeanNamelabel.Text    = Teams.ElementAt(Teamindex);
                    TeamIndexlabel.Text   = (Teamindex + 1).ToString();
                }

                CalculateMarks();
                QuespictureBox.ImageLocation = startupPath + "" + question.DocUrl;
            }
            else
            {
                MessageBox.Show(Level.Split(',')[0] + " " + Round.Split(',')[0] + " questions are finished", "Alert");
                button1.Enabled = false;
            }
        }
        private void GetQuestion()
        {
            BuzzPressTeamlbl.Text = "";
            label2.BackColor      = Color.OrangeRed;
            TAbutton.BackColor    = Color.Brown;
            TBbutton.BackColor    = Color.Brown;
            TCbutton.BackColor    = Color.Brown;
            TDbutton.BackColor    = Color.Brown;
            TDbutton.ForeColor    = Color.White;
            TBbutton.ForeColor    = Color.White;
            TCbutton.ForeColor    = Color.White;
            TAbutton.ForeColor    = Color.White;

            List <QuizQuestion> unattemptQuestions = null;

            string AcademicYear = Program.CurrAcademicYear;
            int    LevelId      = Convert.ToInt32(Level.Split(',')[1]);
            int    RoundId      = Convert.ToInt32(Round.Split(',')[1]);

            var attempted = _attamtedQuestionsService.GetAll().Where(x => x.AcademicYear == AcademicYear).ToList();

            var questions = _quizQuestionService.GetAll().Where(x => x.LevelId == LevelId && x.RoundId == RoundId &&
                                                                x.AcademicYear == AcademicYear).ToList();

            if (attempted.Count() > 0)
            {
                unattemptQuestions = (from qu in questions
                                      where !attempted.Any(x => x.QuestionId == qu.Id)
                                      select qu).ToList();
            }
            else
            {
                unattemptQuestions = questions;
            }

            if (unattemptQuestions.Count() > 0)
            {
                var question = unattemptQuestions.ElementAt(RandomNumber(0, unattemptQuestions.Count()));

                Questionlabel.Text = question.Question;

                questionidlabel.Text    = question.Id.ToString();
                AcademicYearlabel.Text  = question.AcademicYear;
                CorrectAnswerlabel.Text = question.CorrectAnswer;

                label2.Text = question.Time.ToString().Split('.')[0];
                quick       = Convert.ToInt32(question.Time);

                if (Convert.ToInt16(TeamIndexlabel.Text) >= Teams.Count())
                {
                    Teamindex = 0;
                }
                else
                {
                    Teamindex = Convert.ToInt16(TeamIndexlabel.Text);
                }

                QuizLevelandRoundlabel.Text = "Quiz " + Level.Split(',')[0] + " " + Round.Split(',')[0];

                if (IsSkip == false)
                {
                    QuestionForlabel.Text = "Question for all team";
                    TeanNamelabel.Text    = Teams[Teamindex];
                    TeamIndexlabel.Text   = (Teamindex + 1).ToString();
                }

                CalculateMarks();

                if (question.QuestionType == "Audio" || question.QuestionType == "Video")
                {
                    ImageBox.Visible = false;
                    axWindowsMediaPlayer1.Visible = true;
                    axWindowsMediaPlayer1.URL     = startupPath + "" + question.DocUrl;
                }
                else if (question.QuestionType == "Image")
                {
                    axWindowsMediaPlayer1.Visible = false;
                    ImageBox.Visible       = true;
                    ImageBox.ImageLocation = startupPath + "" + question.DocUrl;
                }
            }
            else
            {
                MessageBox.Show(Level.Split(',')[0] + " " + Round.Split(',')[0] + " questions are finished", "Alert");
                button3.Enabled = false;
            }
        }