Exemplo n.º 1
0
        public void ExamSet()
        {
            Console.WriteLine($"PIB:{PIB}");

            /*if (ExamEvent != null)
             *  ExamEvent();*/
            ExamEvent?.Invoke();
        }
Exemplo n.º 2
0
 protected abstract Task HandleExamEvent(ExamEvent @event, T outputSettings);
Exemplo n.º 3
0
 public Task HandleExamEvent(ExamEvent @event, IOutput outputSettings)
 {
     return(HandleExamEvent(@event, CastSettings(outputSettings)));
 }
Exemplo n.º 4
0
 private void HandleExamEvent(ExamEvent obj)
 {
     Handle("exam", (handler, settings) => handler.HandleExamEvent(obj, settings));
 }
        protected override async Task HandleExamEvent(ExamEvent @event, IIccOutput outputSettings)
        {
            Configure(outputSettings);
            tuitionResolver.Initialize();
            examWritersResolver.Initialize();

            Regex regexUseNameAsId   = null;
            Regex regexNoStudents    = null;
            Regex regexStudentSubset = null;

            var section = new List <Tuple <string, string> >();

            if (!string.IsNullOrEmpty(outputSettings.SetNameAsIdPattern))
            {
                regexUseNameAsId = new Regex(outputSettings.SetNameAsIdPattern);
            }

            if (!string.IsNullOrEmpty(outputSettings.SetNoStudentsPattern))
            {
                regexNoStudents = new Regex(outputSettings.SetNoStudentsPattern);
            }

            if (!string.IsNullOrEmpty(outputSettings.StudentSubsetPattern))
            {
                regexStudentSubset = new Regex(outputSettings.StudentSubsetPattern);
            }

            var examIds = new List <string>();

            var exams = @event.Exams.Select(exam =>
            {
                var tuitions = new List <string>();

                foreach (var course in exam.Courses)
                {
                    foreach (var grade in exam.Grades)
                    {
                        var tuition = tuitionResolver.ResolveTuition(grade, course, null);

                        if (tuition != null)
                        {
                            tuitions.Add(tuition);
                        }
                        else
                        {
                            logger.LogDebug($"Tuition for grade {grade} and course {course} not found.");
                        }
                    }
                }

                var id = GetOrComputeId(exam);

                if (regexUseNameAsId != null && regexUseNameAsId.IsMatch(exam.Name))
                {
                    id = exam.Name;
                }

                var students = new List <string>();

                if (regexNoStudents == null || !regexNoStudents.IsMatch(exam.Name))
                {
                    var examWriters = new List <string>();

                    if (regexStudentSubset != null && regexStudentSubset.IsMatch(exam.Name))
                    {
                        foreach (Match match in regexStudentSubset.Matches(exam.Name))
                        {
                            if (match.Groups.Count < 3)
                            {
                                logger.LogError($"Matching students subset failed as {match.Groups.Count} groups were matched, 3 expected.");
                            }
                            else
                            {
                                var start = match.Groups[1].Value;
                                var end   = match.Groups[2].Value;
                                logger.LogDebug($"Only find students between {start} and {end}.");
                                foreach (var tuition in tuitions)
                                {
                                    examWriters.AddRange(examWritersResolver.ResolveStudents(tuition, exam, start, end));
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (var tuition in tuitions)
                        {
                            examWriters.AddRange(examWritersResolver.ResolveStudents(tuition, exam, null, null));
                        }
                    }

                    examWriters = examWriters.Distinct().ToList();
                    students.AddRange(examWriters);
                }

                var originalId = id;
                var roomAdded  = false;
                var number     = 1;
                while (examIds.Contains(id))
                {
                    if (roomAdded == false && exam.Rooms.Count > 0)
                    {
                        id += exam.Rooms.First();
                    }
                    else
                    {
                        id = originalId + (number++);
                    }
                }

                examIds.Add(id);

                return(new ExamData
                {
                    Id = id,
                    Date = exam.Date,
                    LessonStart = exam.LessonStart,
                    LessonEnd = exam.LessonEnd,
                    Description = exam.Remark,
                    Rooms = exam.Rooms.ToList(),
                    Supervisions = exam.Supervisions.ToList(),
                    Tuitions = tuitions,
                    Students = students
                });
            });



            var response = await iccImporter.ImportExamsAsync(exams.ToList());

            await HandleResponseAsync(response);
        }
Exemplo n.º 6
0
 protected override Task HandleExamEvent(ExamEvent @event, IFileOutput outputSettings)
 {
     return(WriteJson(@event.Exams, outputSettings, "exams.json"));
 }