public virtual ActionResult Index(string id, SurveyResultViewModel model) { var count = Results.GetResults(CurrentResource, CurrentUser).Count; if (CurrentResource.MaxTimes.HasValue && count > CurrentResource.MaxTimes) { return(View("Unavailable", AvailabilityResult.No("This survey can only be taken " + CurrentResource.MaxTimes + " times."))); } // score the Survey var result = CurrentResource.Score(CurrentUser, model.Answers); // possibly award points if (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.Survey.Review(id, result.Document.Id))); }
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, GameResultViewModel model) { // score the Game var result = CurrentResource.Score(CurrentUser, model.Time, model.Score); // possibly award points if (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(Request.IsAjaxRequest() ? (ActionResult)Content(Url.Action(MVC.Site.Game.Review(id, result.Document.Id))) : RedirectToAction(MVC.Site.Game.Review(id, result.Document.Id))); }