Exemple #1
0
        public async Task <IActionResult> GenerateEvent()
        {
            if (!_enabled)
            {
                return(NotFound());
            }
            StudentEvent testEvent = new StudentEvent
            {
                CourseID     = "COMP0199", // Course ID Upper case.
                Timestamp    = DateTime.UtcNow,
                EventType    = EventType.Attendance,
                ActivityType = "Video",
                ActivityName = "Weekly Lecture",
                Student      = new Student
                {
                    Email     = "*****@*****.**",
                    FirstName = "Vcdin",
                    LastName  = "Zard",
                    ID        = "202001955"
                }
            };
            await _eventAggregator.ProcessEvent(testEvent);

            return(Ok(testEvent));
        }
Exemple #2
0
        public async Task ProcessEvents(CaliperEventBatchDto caliperEventBatch)
        {
            var filteredCaliperEvents = caliperEventBatch.Data.Where(e => IsAboutStudent(e) && IsAboutCourse(e));

            foreach (var caliperEvent in filteredCaliperEvents)
            {
                string studentEmail = caliperEvent.Actor.Extensions.Email;
                string studentId    = await _identityResolver.GetUserIdByEmail(studentEmail);

                if (studentId != null)
                {
                    //TODO cleaner way to get firstname/lastname
                    var    studentName            = caliperEvent.Actor.Name.Split(' ', 2);
                    string caliperActivityType    = caliperEvent.Object.ObjectType;
                    string activityTypeWithoutUrl = caliperActivityType.Substring(caliperActivityType.LastIndexOf('/') + 1);
                    var    studentEvent           = new StudentEvent
                    {
                        CourseID = caliperEvent.Group.Name,
                        //TODO don't have this hardcoded in case of live lecture links
                        EventType    = activityTypeWithoutUrl == "zoom" || activityTypeWithoutUrl == "teams" ? EventType.Attendance : EventType.Engagement,
                        ActivityName = caliperEvent.Object.Name,
                        ActivityType = activityTypeWithoutUrl,
                        Student      = new Student {
                            ID = studentId, FirstName = studentName[0], LastName = studentName[1], Email = studentEmail
                        },
                        Timestamp = caliperEvent.EventTime
                    };
                    await _eventAggregator.ProcessEvent(studentEvent);
                }
                else
                {
                    _logger.LogError($"Event for student with email '{studentEmail}' ignored as no student ID could be resolved.");
                }
            }
        }
        public async Task ProcessEvents(CaliperEventBatchDto caliperEventBatch)
        {
            var filteredCaliperEvents = caliperEventBatch.Data.Where(e => IsAboutStudent(e) && IsAboutCourse(e));

            foreach (var caliperEvent in filteredCaliperEvents)
            {
                //TODO cleaner way to get firstname/lastname
                var    studentName            = caliperEvent.Actor.Name.Split(' ', 2);
                string caliperActivityType    = caliperEvent.Object.ObjectType;
                string activityTypeWithoutUrl = caliperActivityType.Substring(caliperActivityType.LastIndexOf('/') + 1);
                var    studentEvent           = new StudentEvent
                {
                    CourseID = caliperEvent.Group.Name,
                    //TODO don't have this hardcoded in case of live lecture links
                    EventType    = EventType.Engagement,
                    ActivityName = caliperEvent.Object.Name,
                    ActivityType = activityTypeWithoutUrl,
                    Student      = new Student {
                        ID = caliperEvent.Actor.Id, FirstName = studentName[0], LastName = studentName[1], Email = caliperEvent.Actor.Extensions.Email
                    },
                    Timestamp = caliperEvent.EventTime
                };
                await _eventAggregator.ProcessEvent(studentEvent);
            }
        }
Exemple #4
0
 public async Task ProcessEvent(ResourciumEventDto manualAttendanceEvent)
 {
     StudentEvent convertedEvent = new StudentEvent
     {
         CourseID = MANUAL_ATTENDANCE_COURSE_ID,
         Student  = new Student
         {
             ID        = manualAttendanceEvent.Student.ID,
             Email     = manualAttendanceEvent.Student.Email,
             FirstName = manualAttendanceEvent.Student.FirstName,
             LastName  = manualAttendanceEvent.Student.LastName
         },
         Timestamp = manualAttendanceEvent.Timestamp,
         EventType = EventType.Attendance
     };
     await _eventAggregator.ProcessEvent(convertedEvent);
 }
Exemple #5
0
        public async Task ProcessEvents(string callRecordId)
        {
            var callRecordString = await _graphHelper.GetCallRecordSessions(callRecordId);

            var callRecord = JsonConvert.DeserializeObject <Entities.CallRecord>(callRecordString);

            var organizerId = (callRecord != null ? callRecord.Organizer.User.Id : null);
            var joinWebUrl  = (callRecord != null ? callRecord.JoinWebUrl : null);

            if (joinWebUrl != null && _courseCatalog.CheckJoinWebURLExist(joinWebUrl))
            {
                await _courseCatalog.UpdateInMemoryMapping();

                string targetCourseID = _courseCatalog.GetCourseIDForJoinWebURL(joinWebUrl);
                foreach (Session session in callRecord.Sessions)
                {
                    var caller = session.Caller;
                    var user   = await _graphHelper.GetUserAsync(caller.Identity.User.Id);

                    if (user != null && user.Id != organizerId)
                    {
                        StudentEvent studentEvent = new StudentEvent
                        {
                            CourseID     = targetCourseID.ToUpper(),
                            Timestamp    = ((DateTimeOffset)session.StartDateTime).UtcDateTime,
                            EventType    = EventType.Attendance,
                            ActivityType = "Meeting",
                            ActivityName = "Weekly Lecture",
                            Student      = new Student
                            {
                                Email     = user.Mail,
                                FirstName = user.GivenName,
                                LastName  = user.Surname,
                                ID        = user.Id
                            }
                        };
                        _logger.LogDebug("Student to be processed: " + studentEvent.ToString());
                        await _eventAggregator.ProcessEvent(studentEvent);
                    }
                }
            }
        }
Exemple #6
0
        public StudentEvent GenerateEvent()
        {
            StudentEvent testEvent = new StudentEvent
            {
                CourseID     = "COMP0101", // Course ID Upper case.
                Timestamp    = DateTime.UtcNow,
                EventType    = EventType.Attendance,
                ActivityType = "Video",
                ActivityName = "Weekly Lecture",
                Student      = new Student
                {
                    Email     = "*****@*****.**",
                    FirstName = "Vcd",
                    LastName  = "Zard",
                    ID        = "2020019878"
                }
            };

            _eventAggregator.ProcessEvent(testEvent);
            // Print event info in console.
            return(testEvent);
            // Get response on the swagger UI.
        }