The ToolConsumerProfile advertises the Tool Consumer's capabilities and services offered.
The ToolConsumerProfile (and all of its members) conform to JSON-LD conventions. Briefly, JSON-LD adds semantics to a JSON document by associating properties that may appear in a document with well-defined data types through the use of a so-called "context". The JSON-LD standard reserves a handful of property names and tokens that have special meaning. These names and tokens, described below, begin with the '@' symbol. @context - Used to reference (by URI or by value) a context which declares the simple names that appear throughout a JSON document. @id - Used to uniquely identify things that are being described in the JSON document. The value of an @id property is either a fully-qualified URI, a CURIE, or a simple name that expands to a fully-qualified URI by virtue of the rules defined in the JSON-LD Context. @type - Used to set the data type of an object or property value.
Inheritance: LtiLibrary.Core.Common.JsonLdObject
        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);
            };
        }
Beispiel #2
0
        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");
        }