Example #1
0
        public ActionResult Create(answerModel ansm)
        {
            try
            {
                int i = 0;
                //while (i < 3)
                //{
                answer q = new answer();
                q.answer_name = ansm.answer_name;
                //   q.formation = (System.Collections.Generic.ICollection<Data.formation>)qzv.formation;
                q.question_id_Question = ansm.question_id_Question;
                q.id_Answer            = ansm.id_Answer;
                q.flag = ansm.flag;

                ans.Add(q);
                ans.Commit();
                i++;
                //  return RedirectToAction("Create");
                //}
                return(RedirectToAction("Index", new { id = q.question_id_Question }));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
 public ActionResult Edit(int id, answerModel q)
 {
     try
     {
         var    qid = id;
         answer qq  = new answer();
         qq             = ans.GetById(id);
         qq.answer_name = q.answer_name;
         qq.id_Answer   = id;
         qq.flag        = q.flag;
         ans.Commit();
         return(RedirectToAction("Index", new { id = qid }));
     }
     catch
     {
         return(View());
     }
 }
        // GET: QuestionAnswers/Create
        public ActionResult loadQuiz(int id)
        {
            QuizQuestionAnswers qqa = new QuizQuestionAnswers();

            qqa.quizId = id;
            quiz quiz = qz.GetById(id);

            var questions = qts.GetMany().Where(x => x.quiz_id_Quiz.Equals(quiz.id_Quiz));

            qqa.Questions = new List <questionModel>();
            qqa.answers   = new List <answerModel>();
            foreach (question quest in questions)
            {
                questionModel questionModel = new questionModel();
                questionModel.id_Question          = quest.id_Question;
                questionModel.question_name        = quest.question_name;
                questionModel.question_description = quest.question_description;
                questionModel.userchoice           = null;

                var answers = ans.GetMany().Where(x => x.question_id_Question.Equals(quest.id_Question));


                foreach (answer answ in answers)
                {
                    answerModel answerModel = new answerModel();
                    answerModel.id_Answer            = answ.id_Answer;
                    answerModel.question_id_Question = answ.question_id_Question;
                    answerModel.answer_name          = answ.answer_name;
                    answerModel.flag = answ.flag;

                    qqa.answers.Add(answerModel);
                }

                qqa.Questions.Add(questionModel);
            }


            return(View(qqa));
        }