Пример #1
0
        public async Task ProcessEventsSetsEventTypeToAttendanceForZoomOrTeamsEvents()
        {
            var eventAggregator = new MockEventAggregator();
            var moodleAdapter   = new MoodleAdapter(eventAggregator, new MockIdentityResolver(), CreateLogger());

            CaliperActor caliperActor = new CaliperActor
            {
                Id         = "1",
                ActorType  = "http://purl.imsglobal.org/caliper/v1/lis/Person",
                Name       = "John Doe",
                Extensions = new CaliperActorExtensions {
                    Email = "*****@*****.**"
                }
            };
            string zoomActivityType         = "zoom";
            string studentRole              = "http://purl.imsglobal.org/vocab/lis/v2/membership#Learner";
            CaliperEventBatchDto zoomEvents = EventBatch(caliperActor, "any", "http://purl.imsglobal.org/caliper/v1/lis/" + zoomActivityType, "COMP0101", MoodleAdapter.COURSE_GROUP_TYPE, studentRole);

            await moodleAdapter.ProcessEvents(zoomEvents);

            Assert.Single(eventAggregator.processedEvents);
            var processedEvent = eventAggregator.processedEvents[0];

            Assert.Equal(EventType.Attendance, processedEvent.EventType);
        }
        public async Task ProcessEventsAcceptsEventsAboutStudentsInteractingWithCourses()
        {
            var eventAggregator = new MockEventAggregator();
            var moodleAdapter   = new MoodleAdapter(eventAggregator);

            CaliperActor caliperActor = new CaliperActor
            {
                Id         = "1",
                ActorType  = "http://purl.imsglobal.org/caliper/v1/lis/Person",
                Name       = "John Doe",
                Extensions = new CaliperActorExtensions {
                    Email = "*****@*****.**"
                }
            };
            string activityType = "survey";
            string studentRole  = "http://purl.imsglobal.org/vocab/lis/v2/membership#Learner";
            CaliperEventBatchDto eventsWithStudentRole = EventBatch(caliperActor, "any", "http://purl.imsglobal.org/caliper/v1/lis/" + activityType, "COMP0101", MoodleAdapter.COURSE_GROUP_TYPE, studentRole);

            await moodleAdapter.ProcessEvents(eventsWithStudentRole);

            Assert.Single(eventAggregator.processedEvents);
            var             processedEvent = eventAggregator.processedEvents[0];
            CaliperEventDto submittedEvent = eventsWithStudentRole.Data[0];

            Assert.Equal(submittedEvent.Actor.Name, processedEvent.Student.FirstName + " " + processedEvent.Student.LastName);
            Assert.Equal(submittedEvent.Actor.Extensions.Email, processedEvent.Student.Email);
            Assert.Equal(submittedEvent.Actor.Id, processedEvent.Student.ID);
            Assert.Equal(submittedEvent.Object.Name, processedEvent.ActivityName);
            Assert.Equal(activityType, processedEvent.ActivityType);
            Assert.Equal(submittedEvent.Group.Name, processedEvent.CourseID);
            Assert.Equal(submittedEvent.EventTime, processedEvent.Timestamp);
        }
Пример #3
0
        public async Task <IActionResult> CaliperEvent([FromHeader(Name = CALIPER_API_KEY_HEADER)] string incomingApiKey, [FromBody] CaliperEventBatchDto caliperEventBatch)
        {
            if (incomingApiKey == null || incomingApiKey != _caliperApiKey)
            {
                return(Unauthorized());
            }
            await _moodleAdapter.ProcessEvents(caliperEventBatch);

            return(Ok());
        }
Пример #4
0
        public async Task ProcessEventsIgnoresEventsIfActorNotStudent()
        {
            var eventAggregator = new MockEventAggregator();
            var moodleAdapter   = new MoodleAdapter(eventAggregator, new MockIdentityResolver(), CreateLogger());

            CaliperActor caliperActor = new CaliperActor
            {
                Id         = "1",
                ActorType  = "http://purl.imsglobal.org/caliper/v1/lis/Person",
                Name       = "John Doe",
                Extensions = new CaliperActorExtensions {
                    Email = "*****@*****.**"
                }
            };
            string instructorRole = "http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor";
            CaliperEventBatchDto eventsWithInstructorRole = EventBatch(caliperActor, "any", "http://purl.imsglobal.org/caliper/v1/lis/url", "COMP0101", MoodleAdapter.COURSE_GROUP_TYPE, instructorRole);

            await moodleAdapter.ProcessEvents(eventsWithInstructorRole);

            Assert.Empty(eventAggregator.processedEvents);
        }
Пример #5
0
        public async Task ProcessEventsIgnoresEventIfStudentIdCouldNotBeResolvedThroughEmail()
        {
            var eventAggregator         = new MockEventAggregator();
            var failingIdentityResolver = new FailingIdentityResolver();
            var moodleAdapter           = new MoodleAdapter(eventAggregator, failingIdentityResolver, CreateLogger());

            CaliperActor caliperActor = new CaliperActor
            {
                Id         = "1",
                ActorType  = "http://purl.imsglobal.org/caliper/v1/lis/Person",
                Name       = "John Doe",
                Extensions = new CaliperActorExtensions {
                    Email = "*****@*****.**"
                }
            };
            string activityType = "survey";
            string studentRole  = "http://purl.imsglobal.org/vocab/lis/v2/membership#Learner";
            CaliperEventBatchDto eventsThatShouldBeIgnored = EventBatch(caliperActor, "any", "http://purl.imsglobal.org/caliper/v1/lis/" + activityType, "COMP0101", MoodleAdapter.COURSE_GROUP_TYPE, studentRole);

            await moodleAdapter.ProcessEvents(eventsThatShouldBeIgnored);

            Assert.Empty(eventAggregator.processedEvents);
        }
 public async Task CaliperEvent([FromBody] CaliperEventBatchDto caliperEventBatch)
 {
     await _moodleAdapter.ProcessEvents(caliperEventBatch);
 }