public virtual ActionResult Index(string id, QuizResultViewModel model) { var x = CurrentResource.CanUserTakeQuiz( CurrentUser, DateTime.UtcNow, Results.GetResults(CurrentResource, CurrentUser)); if (!x.Available) { return(View("Unavailable", x)); } // score the quiz var result = CurrentResource.Score(CurrentUser, model.Answers); // possibly award points if (result.Passed && result.PointsEarned.HasValue && result.PointsEarned > 0) { var tx = TryAwardPoints(result.PointsEarned.Value); if (null != tx) { result.Transaction = tx.Document.Id; } } Results.Save(result); // show the review screen return(RedirectToAction(MVC.Site.Quiz.Review(id, result.Document.Id))); }
public virtual ActionResult Index(string id) { var x = CurrentResource.CanUserTakeQuiz( CurrentUser, DateTime.UtcNow, Results.GetResults(CurrentResource, CurrentUser)); if (!x.Available) { return(View("Unavailable", x)); } return(View(QuizViewModel.FromDomain(CurrentResource))); }