public ToolConsumerProfileController() { OnGetToolConsumerProfile = context => { // I use AssemblyInfo to store product and vendor values that may be used // in multiple places in this sample var guid = LtiUtility.GetProduct(); var code = guid; // Product and ProductFamily are the same in this sample var vendorName = LtiUtility.GetCompany(); var productName = LtiUtility.GetTitle(); var productVersion = LtiUtility.GetVersion(); // Build a minimal ToolConsumerProfile for LTI 1.2 var profile = new ToolConsumerProfile { CapabilityOffered = new[] {LtiConstants.BasicLaunchLtiMessageType}, Guid = guid, LtiVersion = context.LtiVersion, ProductInstance = new ProductInstance { Guid = guid, ProductInfo = new ProductInfo { ProductFamily = new ProductFamily { Code = code, Vendor = new Vendor { Code = code, Timestamp = DateTime.UtcNow, VendorName = new VendorName(vendorName) } }, ProductName = new ProductName(productName), ProductVersion = productVersion } } }; // Add Outcomes Management var outcomesUrl = UrlHelper.GenerateUrl("DefaultApi", null, "Outcomes", new RouteValueDictionary {{"httproute", string.Empty}}, RouteTable.Routes, HttpContext.Current.Request.RequestContext, false); Uri serviceUri; profile.ServiceOffered = new[] { new RestService { Action = new[] {"POST"}, EndPoint = Uri.TryCreate(Request.RequestUri, outcomesUrl, out serviceUri) ? serviceUri : null, Format = new[] {LtiConstants.OutcomeMediaType} } }; context.ToolConsumerProfile = profile; return Task.FromResult<object>(null); }; }
public ProfileController() { OnGetToolConsumerProfile = context => { var guid = Assembly.GetExecutingAssembly().GetName().Name; var code = "LtiLibrary"; var vendorName = "andyfmiller.com"; var productName = "LtiLibrary"; var productVersion = "1"; // Build a minimal ToolConsumerProfile for LTI 1.2 var profile = new ToolConsumerProfile { Id = Request.RequestUri, CapabilityOffered = new[] { LtiConstants.BasicLaunchLtiMessageType, "User.id", "User.username", "CourseSection.sourcedId", "Person.sourcedId", "Person.email.primary", "Person.name.given", "Person.name.family", "Person.name.full", "Membership.role" }, Guid = guid, LtiVersion = context.LtiVersion, ProductInstance = new ProductInstance { Guid = guid, ProductInfo = new ProductInfo { ProductFamily = new ProductFamily { Code = code, Vendor = new Vendor { Code = code, Timestamp = DateTime.UtcNow, VendorName = new VendorName(vendorName) } }, ProductName = new ProductName(productName), ProductVersion = productVersion }, ServiceOwner = new ServiceOwner { Name = new ServiceOwnerName(vendorName), Description = new ServiceOwnerDescription(Assembly.GetExecutingAssembly().FullName), Support = new Contact ("*****@*****.**") } } }; // Add Outcomes Management var outcomesUrl = UrlHelper.GenerateUrl("DefaultApi", null, "Outcomes", new RouteValueDictionary {{"httproute", string.Empty}}, RouteTable.Routes, HttpContext.Current.Request.RequestContext, false); Uri serviceUri; profile.ServiceOffered = new[] { new RestService { Action = new[] {"POST"}, EndPoint = Uri.TryCreate(Request.RequestUri, outcomesUrl, out serviceUri) ? serviceUri : null, Format = new[] {LtiConstants.OutcomeMediaType} } }; context.ToolConsumerProfile = profile; return Task.FromResult<object>(null); }; }
public void ToolConsumerProfile_MatchesReferenceJson() { var profile = new ToolConsumerProfile { Id = new Uri("http://lms.example.com/profile/b6ffa601-ce1d-4549-9ccf-145670a964d4"), LtiVersion = LtiConstants.LtiVersion, Guid = "b6ffa601-ce1d-4549-9ccf-145670a964d4", ProductInstance = new ProductInstance { Guid = "c86542d5-fde1-4aae-ae18-7018089fddcd", ProductInfo = new ProductInfo { Description = new ProductDescription("A fictitious Learning Management System"), ProductFamily = new ProductFamily { Code = "omega", Vendor = new Vendor { Code = "lms.example.com", Contact = new Contact("*****@*****.**"), Description = new VendorDescription("A fictitious vendor of a Learning Management System"), VendorName = new VendorName("LMS Corporation"), Timestamp = DefaultDateTime.ToDateTimeUtc(), Website = "http://lms.example.com/products/omega" } }, ProductName = new ProductName("Omega LMS"), ProductVersion = "2.3", TechnicalDescription = new ProductTechnicalDescription("LTI 1.2 compliant") }, ServiceOwner = new ServiceOwner { Id = new Uri("http://state.university.edu/"), Timestamp = DefaultDateTime.ToDateTimeUtc(), Name = new ServiceOwnerName("State University"), Description = new ServiceOwnerDescription("A fictitious university."), Support = new Contact("*****@*****.**") }, Support = new Contact("*****@*****.**"), ServiceProvider = new ServiceProvider { Id = new Uri("http://yasp.example.com/ServiceProvider"), Guid = "yasp.example.com", Timestamp = DefaultDateTime.ToDateTimeUtc(), ServiceProviderName = new ServiceProviderName("Your Application Service Provider"), Description = new ServiceProviderDescription("YASP is a fictitious application service provider"), Support = new Contact("*****@*****.**") } }, CapabilityOffered = new [] { "basic-lti-launch-request" }, ServiceOffered = new [] { new RestService { Id = new Uri("MyLTIService.all", UriKind.Relative), EndPoint = new Uri("http://lms.example.com/ltiservice/my/{contextId}"), Format = new [] { "application/x-vnd.ims.lti.v1.myltiservice+json" }, Action = new [] { "GET" } } } }; profile.Terms.Add("tcp", "https://lms.example.com/profile/b6ffa601-ce1d-4549-9ccf-145670a964d4"); JsonAssertions.AssertSameObjectJson(profile, "ToolConsumerProfile"); }