Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult TakeQuiz(int id = 0)
- {
- QuizModel model = db.Quizzes.Single(m => m.ID == id);
- List<QuestionAnswer> qas = new List<QuestionAnswer>();
- ViewBag.Questions = (from entry in db.Questions.ToList() where entry.QuizID == id orderby entry.Question ascending select entry);
- foreach (QuestionModel qm in ViewBag.Questions)
- {
- QuestionAnswer qa = new QuestionAnswer();
- qa.Question = qm;
- qa.Answers = (from entry in db.Answers.ToList() where entry.QuestionID == qm.ID orderby entry.Answer ascending select entry).ToList();
- qas.Add(qa);
- }
- ViewBag.QAs = qas;
- return View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement