// LTI Outcomes reverse the relationship between Tool Consumers and Tool Providers. The Tool // Provider becomes a consumer of the Outcomes service hosted by the Tool Consumer. In this // sample, the Tool Provider and tell the Tool Consumer to save, read, and delete scores. #region LTI 1.1 Outcomes (scores) /// <summary> /// Display the Basic Outcomes settings and provide buttons to exercise the three actions. /// </summary> /// <param name="lisOutcomeServiceUrl">The URL to the Outcomes service hosted by the Tool Consumer.</param> /// <param name="lisResultSourcedId">The SourcedId of the LisResult used in the demo.</param> /// <param name="consumerKey">The OAuth Consumer Key to use when sending requests to the Outcomes Service.</param> /// <param name="consumerSecret">The OAuth Consumer Secret to use when sending requests to the Outcomes Service.</param> /// <remarks> /// The Outcomes service is hosted by the Tool Consumer. The Tool Provider call the Outcomes service. /// </remarks> public ActionResult BasicOutcomes(string lisOutcomeServiceUrl, string lisResultSourcedId, string consumerKey, string consumerSecret) { var model = new BasicOutcomeModel { LisOutcomeServiceUrl = lisOutcomeServiceUrl, LisResultSourcedId = lisResultSourcedId, ConsumerKey = consumerKey, ConsumerSecret = consumerSecret }; return View(model); }
public ActionResult BasicOutcomes(BasicOutcomeModel model, string submit) { switch (submit) { case "Send Grade": if (LtiLibrary.Core.Outcomes.v1.OutcomesClient.PostScore(model.LisOutcomeServiceUrl, model.ConsumerKey, model.ConsumerSecret, model.LisResultSourcedId, model.Score)) { ViewBag.Message = "Grade sent"; } else { ViewBag.Message = "Invalid request"; } break; case "Read Grade": var lisResult = LtiLibrary.Core.Outcomes.v1.OutcomesClient.ReadScore(model.LisOutcomeServiceUrl, model.ConsumerKey, model.ConsumerSecret, model.LisResultSourcedId); if (lisResult.IsValid) { model.Score = lisResult.Score; ViewBag.Message = "Grade read"; } else { ViewBag.Message = "No grade"; } break; case "Delete Grade": if (LtiLibrary.Core.Outcomes.v1.OutcomesClient.DeleteScore(model.LisOutcomeServiceUrl, model.ConsumerKey, model.ConsumerSecret, model.LisResultSourcedId)) { model.Score = null; ViewBag.Message = "Grade deleted"; } else { ViewBag.Message = "Invalid request"; } break; } return View(model); }