Exemple #1
0
        public void ChangeCourseSelection()
        {
            var academicYear =
                new AcademicYear(
                    startYear: 2040,
                    endYear: 2041);

            var academicTerm =
                new AcademicTerm(
                    value: 1,
                    academicYear: academicYear);

            var courses =
                new List <Course>
            {
                new Course(
                    code: "Math11",
                    name: "Basic Math",
                    units: 3)
            };

            var id           = Guid.NewGuid();
            var registration =
                new Registration(id,
                                 studentNumber: "016-00125",
                                 academicTerm: academicTerm,
                                 courses: courses);

            var newCourses =
                new List <Course>
            {
                new Course(
                    code: "MMS100",
                    name: "Introduction to Multimedia",
                    units: 3),
                new Course(
                    code: "MMS112",
                    name: "Multimedia and Law",
                    units: 3)
            };

            registration.ChangeCourseSelection(
                courses: newCourses);

            Assert.Equal("016-00125", registration.StudentNumber);
            Assert.Equal("2040-1", registration.AcademicTerm.ToString());
            Assert.Equal(2, registration.Courses.Count);
            Assert.Equal("MMS100", registration.Courses[0].Code);
            Assert.Equal("MMS112", registration.Courses[1].Code);

            Assert.Equal(2, registration.Events.Count);
            var courseSelectionChangedEvent = (RegistrationCourseSelectionChangedEvent)registration.Events[1];

            Assert.Equal(id, courseSelectionChangedEvent.Id);
            Assert.Equal(2, courseSelectionChangedEvent.Courses.Count);
            Assert.Equal("MMS100", courseSelectionChangedEvent.Courses[0].Code);
            Assert.Equal("MMS112", courseSelectionChangedEvent.Courses[1].Code);
            Assert.Equal(1, courseSelectionChangedEvent.Version);
        }
        private void LoadFromModel(AcademicTerm model)
        {
            AcademicYearId = model.AcademicYearId;
            Name           = model.Name;
            StartDate      = model.StartDate;
            EndDate        = model.EndDate;

            if (model.AcademicYear != null)
            {
                AcademicYear = new AcademicYearModel(model.AcademicYear);
            }
        }
 public RegistrationCreatedEvent(
     Guid id,
     int version,
     string studentNumber,
     AcademicTerm academicTerm,
     IReadOnlyList <Course> courses)
 {
     Id            = id;
     Version       = version;
     StudentNumber = studentNumber;
     AcademicTerm  = academicTerm;
     Courses       = courses;
 }
        public async Task CreateAcademicYear(params CreateAcademicYearModel[] createModels)
        {
            using (var unitOfWork = await DataConnectionFactory.CreateUnitOfWork())
            {
                foreach (var model in createModels)
                {
                    var academicYear = new AcademicYear
                    {
                        Name = model.Name
                    };

                    foreach (var termModel in model.AcademicTerms)
                    {
                        var term = new AcademicTerm
                        {
                            Name      = termModel.Name,
                            StartDate = termModel.StartDate,
                            EndDate   = termModel.EndDate
                        };

                        foreach (var attendanceWeek in termModel.AttendanceWeeks)
                        {
                            term.AttendanceWeeks.Add(new AttendanceWeek
                            {
                                Beginning      = attendanceWeek.WeekBeginning,
                                WeekPatternId  = attendanceWeek.WeekPatternId,
                                IsNonTimetable = attendanceWeek.NonTimetable
                            });
                        }

                        foreach (var schoolHoliday in termModel.Holidays)
                        {
                            unitOfWork.DiaryEvents.Create(new DiaryEvent
                            {
                                Description = "School Holiday",
                                EventTypeId = EventTypes.SchoolHoliday,
                                StartTime   = schoolHoliday.Date,
                                EndTime     = schoolHoliday.GetEndOfDay()
                            });
                        }

                        academicYear.AcademicTerms.Add(term);
                    }

                    unitOfWork.AcademicYears.Create(academicYear);

                    await unitOfWork.SaveChangesAsync();
                }
            }
        }
Exemple #5
0
        public void New()
        {
            var academicYear =
                new AcademicYear(
                    startYear: 2040,
                    endYear: 2041);

            var academicTerm =
                new AcademicTerm(
                    value: 1,
                    academicYear: academicYear);

            Assert.Equal(1, academicTerm.Value);
            Assert.Equal("2040-2041", academicTerm.AcademicYear.ToString());
        }
Exemple #6
0
        public void New()
        {
            var academicYear =
                new AcademicYear(
                    startYear: 2040,
                    endYear: 2041);

            var academicTerm =
                new AcademicTerm(
                    value: 1,
                    academicYear: academicYear);

            var courses =
                new List <Course>
            {
                new Course(
                    code: "Math11",
                    name: "Basic Math",
                    units: 3)
            };

            var id           = Guid.NewGuid();
            var registration =
                new Registration(id,
                                 studentNumber: "016-00125",
                                 academicTerm: academicTerm,
                                 courses: courses);

            Assert.Equal("016-00125", registration.StudentNumber);
            Assert.Equal("2040-1", registration.AcademicTerm.ToString());
            Assert.Equal(1, registration.Courses.Count);
            Assert.Equal("Math11", registration.Courses[0].Code);

            Assert.Equal(1, registration.Events.Count);
            var createdEvent = (RegistrationCreatedEvent)registration.Events[0];

            Assert.Equal(id, createdEvent.Id);
            Assert.Equal("016-00125", createdEvent.StudentNumber);
            Assert.Equal("2040-1", createdEvent.AcademicTerm.ToString());
            Assert.Equal(1, createdEvent.Courses.Count);
            Assert.Equal("Math11", createdEvent.Courses[0].Code);
            Assert.Equal(0, createdEvent.Version);
        }
Exemple #7
0
        public UserViewModel(User user)
        {
            this.user = user;

            // TODO: DELETE
            var term1 = new AcademicTerm()
            {
                School = "Northeastern University",
                Term   = "Fall",
                Year   = 2016
            };

            user.AddTerm(term1);

            terms = new ObservableCollection <AcademicTermViewModel>();
            foreach (var term in user.Terms)
            {
                terms.Add(new AcademicTermViewModel(term));
            }
        }
Exemple #8
0
        public AcademicTermViewModel(AcademicTerm term)
        {
            this.term = term;

            // TODO: DELETE
            var course1 = new Course()
            {
                DeptNumber      = "CS 5800",
                Name            = "Algorithms and Data",
                Instructor      = "Rajmohan Rajaraman",
                GoalModeEnabled = true,
                GoalEarned      = 80
            };

            term.AddCourse(course1);

            courses = new ObservableCollection <CourseViewModel>();
            foreach (var course in term.Courses)
            {
                courses.Add(new CourseViewModel(course));
            }
        }
Exemple #9
0
        public async Task Post([FromBody] RegistrationPostModel model)
        {
            var academicTerm =
                new AcademicTerm(
                    value: model.AcademicTerm.Value,
                    academicYear:
                    new AcademicYear(
                        startYear: new Year(model.AcademicTerm.StartYear),
                        endYear: new Year(model.AcademicTerm.EndYear)
                        ));

            var entity =
                new Registration(
                    id: Guid.NewGuid(),
                    studentNumber: model.StudentNumber,
                    academicTerm: academicTerm,
                    courses: model.Courses
                    .Select(x => new Course(x.Code, x.Name, x.Units))
                    .ToList());

            var registrationRepository = new RegistrationRepository();
            await registrationRepository.Save(entity, DateTimeOffset.UtcNow);
        }
 internal AcademicTermModel(AcademicTerm model) : base(model)
 {
     LoadFromModel(model);
 }
Exemple #11
0
 public ClassOffering GetClassInTerm(Course course, AcademicTerm term)
 {
     return(null);
 }
Exemple #12
0
        public void Test3()
        {
            var term = new AcademicTerm()
            {
                School = "Northeastern University",
                Term = "Fall",
                Year = 2016
            };

            var course = new Course()
            {
                DeptNumber = "CS 5800",
                Name = "Algorithms and Data",
                Instructor = "Rajmohan Rajaraman",
                GoalModeEnabled = true,
                GoalEarned = 80
            };
            term.AddCourse(course);

            var midterms = new Section()
            {
                Name = "Midterms",
                Weight = .35
            };
            course.AddSection(midterms);

            var final = new Section()
            {
                Name = "Final",
                Weight = .65
            };
            course.AddSection(final);

            var a1 = new Assignment(1)
            {
                Name = "Midterm 1",
                Earned = 65,
                Worth = 100
            };
            midterms.AddAssignment(a1);

            var a2 = new Assignment(2)
            {
                Name = "Midterm 2",
                Earned = 90,
                Worth = 100
            };
            midterms.AddAssignment(a2);

            var a3 = new Assignment(3)
            {
                Name = "Midterm 3",
                Earned = 0,
                Worth = 100,
                GoalSelected = true
            };
            midterms.AddAssignment(a3);

            var a4 = new Assignment(4)
            {
                Name = "Final 1",
                Earned = 95,
                Worth = 100
            };
            final.AddAssignment(a4);

            var a5 = new Assignment(5)
            {
                Name = "Final 2",
                Earned = 0,
                Worth = 100,
                GoalSelected = true
            };
            final.AddAssignment(a5);

            var a6 = new Assignment(6)
            {
                Name = "Final 3",
                Earned = 0,
                Worth = 100,
                GoalSelected = true
            };
            final.AddAssignment(a6);

            course.CalculateGoals(ObjectiveType.Weighted);
        }
Exemple #13
0
 public AcademicTermReadModel(AcademicTerm academicTerm)
 {
     Value     = academicTerm.Value;
     StartYear = academicTerm.AcademicYear.StartYear.Value;
     EndYear   = academicTerm.AcademicYear.EndYear.Value;
 }