Ejemplo n.º 1
0
        private void button3_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.Marks        = 0;
                attamtedQuestions.LevelId      = Convert.ToInt32(Level.Split(',')[1]);
                attamtedQuestions.RoundId      = Convert.ToInt32(Round.Split(',')[1]);
                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       = false;
                attamtedQuestions.IsSkip       = true;
                attamtedQuestions.CreatedBy    = "Admin";
                attamtedQuestions.CreatedDate  = DateTime.Now;

                _attamtedQuestionsService.Add(attamtedQuestions);
                _attamtedQuestionsService.Save();
            }
            IsSkip = true;
            GetQuestion();
        }
        private void Wrongbutton_Click_1(object sender, EventArgs e)
        {
            timer1.Stop();

            if (!string.IsNullOrEmpty(BuzzPressTeamlbl.Text))
            {
                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]);
                    attamtedQuestions.Marks        = -10;
                    attamtedQuestions.TeamId       = _quizTeamService.GetAll().Where(x => x.Name == BuzzPressTeamlbl.Text).Select(x => x.Id).FirstOrDefault();
                    attamtedQuestions.TeamName     = BuzzPressTeamlbl.Text;
                    attamtedQuestions.AcademicYear = AcademicYearlabel.Text;
                    attamtedQuestions.IsTrue       = false;
                    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();

                    WrongForm wrong = new WrongForm();
                    wrong.Text = "Wrong answer";
                    wrong.ShowDialog();

                    CalculateMarks();
                }
                else
                {
                    MessageBox.Show("You have already attempted this question, please go to next question", "Alert");
                }
            }
            else
            {
                MessageBox.Show("Please select team name", "Alert");
            }
        }
Ejemplo n.º 3
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");
            }
        }
 public void Edit(AttamtedQuestions entity)
 {
     this.attamtedQuestionsRepository.Edit(entity);
 }
 public void Delete(AttamtedQuestions entity)
 {
     this.attamtedQuestionsRepository.Delete(entity);
 }
 public void Add(AttamtedQuestions entity)
 {
     this.attamtedQuestionsRepository.Add(entity);
 }