Exemplo n.º 1
0
 public ActionResult Index(Lti1TestLaunch model, string link)
 {
     if (ModelState.IsValid)
     {
         return(RedirectToAction("TestSuite", "Lti1", new { Url = model.Url, ConsumerKey = model.ConsumerKey, ConsumerSecret = model.ConsumerSecret }));
     }
     return(View(model));
 }
Exemplo n.º 2
0
        // GET: Lti1
        public ActionResult Index()
        {
            var model = new Lti1TestLaunch
            {
                Url = "https://www.imsglobal.org/lti/cert/tc_tool.php?x=With%20Space&y=yes",
                CustomParameters = CustomParameters
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Index(Lti1TestLaunch model, string link)
        {
            if (ModelState.IsValid)
            {
                // Store the secret to LineItemsController and ResultsController can authenticate requests
                InMemoryDb.ConsumerSecret = model.ConsumerSecret;
                InMemoryDb.LineItem       = null;
                InMemoryDb.Result         = null;

                return(RedirectToAction("TestSuite", "Lti1", new { Url = model.Url, ConsumerKey = model.ConsumerKey, ConsumerSecret = model.ConsumerSecret }));
            }
            return(View(model));
        }
Exemplo n.º 4
0
 public ActionResult TestSuite(Lti1TestLaunch model)
 {
     return(View(model));
 }
Exemplo n.º 5
0
        public ActionResult LtiLaunch(Lti1TestLaunch model, int link)
        {
            var request = new LtiRequest(LtiConstants.BasicLaunchLtiMessageType);

            request.ConsumerKey = model.ConsumerKey;
            request.Url         = new Uri(model.Url);
            request.AddCustomParameters(CustomParameters);
            request.LaunchPresentationLocale         = Thread.CurrentThread.CurrentUICulture.Name;
            request.LaunchPresentationDocumentTarget = DocumentTarget.frame;
            request.LaunchPresentationWidth          = 400;
            request.LaunchPresentationHeight         = 300;
            request.LaunchPresentationCssUrl         = GetLaunchPresentationCssUrl();
            request.LaunchPresentationReturnUrl      = Request.Url.AbsoluteUri;
            request.LineItemServiceUrl   = GetLineItemsServiceUrl(InMemoryDb.ContextId, InMemoryDb.LineItemId);
            request.LineItemsServiceUrl  = GetLineItemsServiceUrl(InMemoryDb.ContextId);
            request.LisOutcomeServiceUrl = GetLisOutcomeServiceUrl();
            request.ResultServiceUrl     = GetResultsServiceUrl(InMemoryDb.ContextId, InMemoryDb.LineItemId, InMemoryDb.ResultId);
            request.ResultsServiceUrl    = GetResultsServiceUrl(InMemoryDb.ContextId, InMemoryDb.LineItemId);
            request.ToolConsumerInfoProductFamilyCode = "LtiLibrary";
            request.ToolConsumerInfoVersion           = "1";
            request.ToolConsumerProfileUrl            = GetToolConsumerProfileUrl();
            request.ToolConsumerInstanceContactEmail  = "*****@*****.**";
            request.ToolConsumerInstanceDescription   = Assembly.GetExecutingAssembly().GetName().ToString();
            request.ToolConsumerInstanceGuid          = Assembly.GetExecutingAssembly().GetName().Name;
            request.ToolConsumerInstanceName          = "andyfmiller.com";

            switch (link)
            {
            case 1:     // Instructor, Course 1, Resource 1
                request.ContextId    = Course1.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel = request.ContextId;
                request.ContextTitle = ConvertToPlainText(Course1.Title);
                request.ContextType  = LisContextType.CourseSection;
                request.LisCourseOfferingSourcedId = request.ContextId;
                request.LisCourseSectionSourcedId  = request.ContextId;
                request.ResourceLinkId             = Course1.Links[0].LinkId;
                request.ResourceLinkTitle          = ConvertToPlainText(Course1.Links[0].Title);
                request.ResourceLinkDescription    = ConvertToPlainText(Course1.Links[0].Description);
                request.LisPersonEmailPrimary      = Instructor.Email;
                request.LisPersonNameFamily        = Instructor.FamilyName;
                request.LisPersonNameGiven         = Instructor.GivenName;
                request.LisPersonSourcedId         = Instructor.UserId;
                request.UserId   = Instructor.UserId;
                request.UserName = Instructor.Username;
                request.Roles    = Role.Instructor.ToString();
                break;

            case 2:     // Instructor, Course 1, Resource 2
                request.ContextId               = Course1.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel            = request.ContextId;
                request.ContextTitle            = ConvertToPlainText(Course1.Title);
                request.ContextType             = LisContextType.CourseSection;
                request.ResourceLinkId          = Course1.Links[1].LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(Course1.Links[1].Title);
                request.ResourceLinkDescription = ConvertToPlainText(Course1.Links[1].Description);
                request.LisPersonEmailPrimary   = Instructor.Email;
                request.LisPersonNameFamily     = Instructor.FamilyName;
                request.LisPersonNameGiven      = Instructor.GivenName;
                request.LisPersonSourcedId      = Instructor.UserId;
                request.UserId   = Instructor.UserId;
                request.UserName = Instructor.Username;
                request.Roles    = Role.Instructor.ToString();
                break;

            case 3:     // Instructor, Course 2, Resource 1
                request.ContextId               = Course2.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel            = request.ContextId;
                request.ContextTitle            = ConvertToPlainText(Course2.Title);
                request.ContextType             = LisContextType.CourseSection;
                request.ResourceLinkId          = Course2.Links[0].LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(Course2.Links[0].Title);
                request.ResourceLinkDescription = ConvertToPlainText(Course2.Links[0].Description);
                request.LisPersonEmailPrimary   = Instructor.Email;
                request.LisPersonNameFamily     = Instructor.FamilyName;
                request.LisPersonNameGiven      = Instructor.GivenName;
                request.LisPersonSourcedId      = Instructor.UserId;
                request.UserId   = Instructor.UserId;
                request.UserName = Instructor.Username;
                request.Roles    = Role.Instructor.ToString();
                break;

            case 4:     // Student, Course 1, Resource 1
                request.ContextId               = Course1.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel            = request.ContextId;
                request.ContextTitle            = ConvertToPlainText(Course1.Title);
                request.ContextType             = LisContextType.CourseSection;
                request.ResourceLinkId          = Course1.Links[0].LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(Course1.Links[0].Title);
                request.ResourceLinkDescription = ConvertToPlainText(Course1.Links[0].Description);
                request.LisPersonEmailPrimary   = Student.Email;
                request.LisPersonNameFamily     = Student.FamilyName;
                request.LisPersonNameGiven      = Student.GivenName;
                request.LisPersonSourcedId      = Student.UserId;
                request.LisResultSourcedId      = $"{Student.UserId}-{Course1.Links[0].LinkId}";
                request.UserId   = Student.UserId;
                request.UserName = Student.Username;
                request.Roles    = Role.Learner.ToString();
                break;

            case 5:     // Student, Course 1, Resource 2
                request.ContextId               = Course1.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel            = request.ContextId;
                request.ContextTitle            = ConvertToPlainText(Course1.Title);
                request.ContextType             = LisContextType.CourseSection;
                request.ResourceLinkId          = Course1.Links[1].LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(Course1.Links[1].Title);
                request.ResourceLinkDescription = ConvertToPlainText(Course1.Links[1].Description);
                //request.LisPersonEmailPrimary = Student.Email;
                request.LisPersonNameFamily = Student.FamilyName;
                request.LisPersonNameGiven  = Student.GivenName;
                request.LisPersonSourcedId  = Student.UserId;
                request.LisResultSourcedId  = $"{Student.UserId}-{Course1.Links[1].LinkId}";
                request.UserId   = Student.UserId;
                request.UserName = Student.Username;
                request.Roles    = Role.Learner.ToString();
                break;

            case 6:     // Student, Course 2, Resource 1
                request.ContextId               = Course2.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel            = request.ContextId;
                request.ContextTitle            = ConvertToPlainText(Course2.Title);
                request.ContextType             = LisContextType.CourseSection;
                request.ResourceLinkId          = Course2.Links[0].LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(Course2.Links[0].Title);
                request.ResourceLinkDescription = ConvertToPlainText(Course2.Links[0].Description);
                //request.LisPersonEmailPrimary = Student.Email;
                //request.LisPersonNameFamily = Student.FamilyName;
                //request.LisPersonNameGiven = Student.GivenName;
                request.LisPersonSourcedId = Student.UserId;
                request.LisResultSourcedId = $"{Student.UserId}-{Course2.Links[0].LinkId}";
                request.UserId             = Student.UserId;
                request.UserName           = Student.Username;
                request.Roles = Role.Learner.ToString();
                break;

            case 7:     // Mentor, Course 1, Resource 1
                        // Tests passed with this launch
                        // 5.9
                request.ContextId               = Course1.CourseId.ToString(CultureInfo.InvariantCulture);
                request.ContextLabel            = request.ContextId;
                request.ContextTitle            = ConvertToPlainText(Course1.Title);
                request.ContextType             = LisContextType.CourseSection;
                request.ResourceLinkId          = Course1.Links[0].LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(Course1.Links[0].Title);
                request.ResourceLinkDescription = ConvertToPlainText(Course1.Links[0].Description);
                request.LisPersonEmailPrimary   = Mentor.Email;
                request.LisPersonNameFamily     = Mentor.FamilyName;
                request.LisPersonNameGiven      = Mentor.GivenName;
                request.UserId          = Mentor.UserId;
                request.UserName        = Mentor.Username;
                request.Roles           = Role.Mentor.ToString();
                request.RoleScopeMentor = Mentor.MentoringUserId;
                break;

            case 8:     // Instructor, No context (6.4)
                        // Tests passed with this launch
                        // 6.4
                request.ResourceLinkId          = GradebookTool.LinkId;
                request.ResourceLinkTitle       = ConvertToPlainText(GradebookTool.Title);
                request.ResourceLinkDescription = ConvertToPlainText(GradebookTool.Description);
                request.LisPersonEmailPrimary   = Instructor.Email;
                request.LisPersonNameFamily     = Instructor.FamilyName;
                request.LisPersonNameGiven      = Instructor.GivenName;
                request.LisPersonSourcedId      = Instructor.UserId;
                request.UserId   = Instructor.UserId;
                request.UserName = Instructor.Username;
                request.Roles    = Role.Instructor.ToString();
                break;
            }
            return(View(request.GetViewModel(model.ConsumerSecret)));
        }
Exemplo n.º 6
0
        // GET: Lti1
        public ActionResult Index()
        {
            var model = new Lti1TestLaunch();

            return(View(model));
        }