public void OnGetBack(int id)
        {
            Account       = UserManager.FindByIdAsync(id.ToString()).Result;
            Account.IsBan = Account.CheckIsBan();

            AnsweredQuestions = db.Questions.ToList();
            AnsweredQuestions.RemoveAll(Match);

            Answers = db.Answers.ToList();
        }
Example #2
0
 private void SaveTestResult(AnsweredQuestion answeredQuestion)
 {
     try
     {
         AnsweredQuestions.Add(answeredQuestion);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public void OnGet(Account account)
        {
            Account       = account;
            Account.IsBan = Account.CheckIsBan();

            AnsweredQuestions = db.Questions.ToList();
            AnsweredQuestions.RemoveAll(Match);


            Answers = db.Answers.ToList();
        }
Example #4
0
        public void AnswerQuestion(int questionNumber, int choiceId, int questionId)
        {
            int questionIndex = questionNumber - 1;

            if (mAnsweredQuestions.Count <= questionIndex)
            {
                AnsweredQuestions answered = new AnsweredQuestions();
                answered.ChoiceId   = choiceId;
                answered.QuestionId = questionId;
                mAnsweredQuestions.Add(answered);
            }
            else
            {
                mAnsweredQuestions[questionIndex].ChoiceId   = choiceId;
                mAnsweredQuestions[questionIndex].QuestionId = questionId;
            }
        }
Example #5
0
        public void OnPost(int Id, string answer = "")
        {
            SetCatList();
            Quizes      = Repository.GetAll().ToList();
            QuizAnswers = RepositoryAnswers.GetAll().ToList();

            if (!string.IsNullOrEmpty(answer))
            {
                var Answer = answer.Split(";");
                CatSelectedId = GetCatList(int.Parse(Answer[1]));
                SetQuizList(CatSelectedId);
                if (string.IsNullOrEmpty(AnsweredQuestions))
                {
                    AnsweredQuestions = "";
                }
                if (!AnsweredQuestions.Contains(Answer[0]))
                {
                    foreach (var answerChosen in QuizAnswers)
                    {
                        if (answerChosen.CorrectAns == int.Parse(Answer[0]))
                        {
                            TempData["AnswerCount"] = AnswerCount++;
                            break;
                        }
                    }
                    AnsweredQuestions += Answer[0].ToString() + " ";
                }
            }
            else
            {
                if (Id == 1 || Id == 2)
                {
                    SetQuizList(Id);
                }
                else
                {
                    movieQuizList = Movies.GetAll();
                }
            }
        }
Example #6
0
        private ExamPaper CreateDataSet(DataSet dsQuestion)
        {
            ExamPaper examPaper = new ExamPaper();
            List <QuestionEntities> questionEntitiesList = new List <QuestionEntities>();
            List <int> IdList = new List <int>();
            List <AnsweredQuestions> answeredQuestionsList = new List <AnsweredQuestions>();

            for (int i = 0; i < dsQuestion.Tables[0].Rows.Count; i++)
            {
                QuestionEntities questionEntities = new QuestionEntities();
                questionEntities.Id           = Convert.ToInt32(dsQuestion.Tables[0].Rows[i]["Id"].ToString());
                questionEntities.QuestionText = Convert.ToString(dsQuestion.Tables[0].Rows[i]["QuestionText"]);
                questionEntities.Marks        = Convert.ToDecimal(dsQuestion.Tables[0].Rows[i]["Marks"]);

                // IdList.Add(questionEntities.Id);

                DataTable dtAns = dsQuestion.Tables[1].AsEnumerable()
                                  .Where(r => r.Field <int>("QuestionId") == int.Parse(dsQuestion.Tables[0].Rows[i]["Id"].ToString())).CopyToDataTable();

                List <AnswerEntities> answerEntities = new List <AnswerEntities>();
                for (int j = 0; j < dtAns.Rows.Count; j++)
                {
                    AnswerEntities answerEntities1 = new AnswerEntities();
                    answerEntities1.ID            = Convert.ToInt32(dtAns.Rows[j]["Id"].ToString());
                    answerEntities1.AnswerText    = Convert.ToString(dtAns.Rows[j]["ChoiceText"]);
                    answerEntities1.QuestionID    = Convert.ToInt32(dtAns.Rows[j]["QuestionId"].ToString());
                    answerEntities1.IsRightAnswer = Convert.ToString(dtAns.Rows[j]["IsAnswer"].ToString());
                    answerEntities1.IsUserAnswer  = Convert.ToInt32(dtAns.Rows[j]["IsUserAnswer"].ToString());
                    answerEntities1.ChoiceID      = Convert.ToInt32(dtAns.Rows[j]["ChoiceId"].ToString());

                    if (dtAns.Rows[j]["IsUserAnswer"].ToString() == "1")
                    {
                        examPaper.UserAnswer = answerEntities1.ChoiceID.ToString();
                    }
                    //examPaper.RadioValue = dtAns.Rows[j]["IsUserAnswer"].ToString();



                    answerEntities.Add(answerEntities1);
                }

                questionEntities.AnswerEntities = answerEntities;
                questionEntitiesList.Add(questionEntities);
            }

            examPaper.QuestionEntities = questionEntitiesList;

            for (int i = 0; i < dsQuestion.Tables[3].Rows.Count; i++)
            {
                IdList.Add(int.Parse(dsQuestion.Tables[3].Rows[i]["Id"].ToString()));
            }

            examPaper.QuestionList = IdList;

            examPaper.QuestionCount = IdList.Count;

            List <int> qCnt = new List <int>();

            for (int k = 0; k < dsQuestion.Tables[2].Rows.Count; k++)
            {
                qCnt.Add(int.Parse(dsQuestion.Tables[2].Rows[k][0].ToString()));
            }

            examPaper.AnsweredQuestionList = qCnt;


            for (int l = 0; l < dsQuestion.Tables[4].Rows.Count; l++)
            {
                AnsweredQuestions aq = new AnsweredQuestions();

                aq.RowNo       = Convert.ToInt32(dsQuestion.Tables[4].Rows[l]["RowNo"].ToString());
                aq.QuestionId  = Convert.ToInt32(dsQuestion.Tables[4].Rows[l]["QuestionId"].ToString());
                aq.HasAnswered = Convert.ToInt32(dsQuestion.Tables[4].Rows[l]["HasAnswered"].ToString());

                answeredQuestionsList.Add(aq);
            }

            examPaper.AnsweredQuestions = answeredQuestionsList;

            return(examPaper);
        }