Example #1
0
        public void Get_completed_courses_should_return_courses_for_candidate()
        {
            // When
            const int candidateId = 1;
            var       result      = courseDataService.GetCompletedCourses(candidateId).ToList();

            // Then
            var expectedFirstCourse = new CompletedCourse
            {
                Name            = "Staying Safe Online Test PLA Issue - test",
                Id              = 25140,
                StartedDate     = new DateTime(2018, 5, 29, 9, 11, 45, 943),
                Completed       = new DateTime(2018, 5, 29, 14, 28, 5, 557),
                LastAccessed    = new DateTime(2018, 5, 29, 14, 28, 5, 020),
                Evaluated       = new DateTime(2019, 4, 5, 7, 10, 28, 507),
                ArchivedDate    = null,
                DiagnosticScore = 0,
                IsAssessed      = true,
                HasDiagnostic   = true,
                HasLearning     = true,
                Passes          = 1,
                Sections        = 2,
                ProgressID      = 251571,
            };

            result.Should().HaveCount(15);
            result.First().Should().BeEquivalentTo(expectedFirstCourse);
        }
        public CompletedPageViewModel(
            SearchSortFilterPaginationResult <CompletedLearningItem> result,
            bool apiIsAccessible,
            IConfiguration config,
            string?bannerText
            ) : base(result, false, searchLabel: "Search your completed courses")
        {
            ApiIsAccessible = apiIsAccessible;
            BannerText      = bannerText;

            CompletedActivities = result.ItemsToDisplay.Select <BaseLearningItem, CompletedLearningItemViewModel>(
                activity =>
            {
                return(activity switch
                {
                    CompletedCourse completedCourse => new CompletedCourseViewModel(completedCourse, config),
                    _ => new CompletedLearningResourceViewModel((CompletedActionPlanResource)activity),
                });
            }
Example #3
0
        public CompletedPageViewModel(
            IEnumerable <CompletedCourse> completedCourses,
            IEnumerable <CompletedActionPlanResource> completedResources,
            IConfiguration config,
            string?searchString,
            string sortBy,
            string sortDirection,
            string?bannerText,
            int page
            ) : base(searchString, page, false, sortBy, sortDirection, searchLabel: "Search your completed courses")
        {
            BannerText = bannerText;
            var allItems = completedCourses.Cast <CompletedLearningItem>().ToList();

            allItems.AddRange(completedResources);

            var sortedItems = GenericSortingHelper.SortAllItems(
                allItems.AsQueryable(),
                sortBy,
                sortDirection
                );
            var filteredItems = GenericSearchHelper.SearchItems(sortedItems, SearchString).ToList();

            MatchingSearchResults = filteredItems.Count;
            SetTotalPages();
            var paginatedItems = GetItemsOnCurrentPage(filteredItems);

            CompletedActivities = paginatedItems.Select <BaseLearningItem, CompletedLearningItemViewModel>(
                activity =>
            {
                return(activity switch
                {
                    CompletedCourse completedCourse => new CompletedCourseViewModel(completedCourse, config),
                    _ => new CompletedLearningResourceViewModel((CompletedActionPlanResource)activity),
                });
            }
Example #4
0
        /// <summary>
        /// Seeds the given database with Student/StudentSkill/CompletedCourses if needed.
        /// </summary>
        /// <param name="context">The context (database) to be used.</param>
        public static void Initialize(URC_Context context, UserManager <URCUser> userManager)
        {
            // Look for any student aplications.
            if (context.Students.Any())
            {
                return; // DB has been seeded
            }

            var sid1 = userManager.FindByEmailAsync("*****@*****.**").Result.Id.ToString();
            var sid2 = userManager.FindByEmailAsync("*****@*****.**").Result.Id.ToString();
            var studentApplications = new Student[]
            {
                new Student {
                    Sid = sid2, StudentName = "Ashley Eaton", ExpectedGraduationDate = DateTime.Parse("2022-05-10"), DegreePlan = "CE", GPA = (float)3.9, Uid = "u0000002", AvailableHoursPerWeek = 10, PersonalStatement = "Hi, I would like to be considered for a research position. I believe that I will be a great addition to any team. I am a really good student.", ProfileCreationDate = DateTime.Parse("2020-10-11"), Active = true
                },
                new Student {
                    Sid = sid1, StudentName = "Oliver Allphin", ExpectedGraduationDate = DateTime.Parse("2021-05-10"), DegreePlan = "CS", GPA = (float)3.7, Uid = "u0000001", AvailableHoursPerWeek = 20, PersonalStatement = "This is my personal statement. I am a great student and am very interested in research. Please consider me! This is my personal statement. I am a great student and am very interested in research. Please consider me! This is my personal statement. I am a great student and am very interested in research. Please consider me!", ProfileCreationDate = DateTime.Parse("2020-10-10"), Active = true
                }
            };

            context.Students.AddRange(studentApplications);
            context.SaveChanges();

            var studentSkills = new StudentSkill[]
            {
                new StudentSkill {
                    SkillName = "C#", StudentID = 1
                },
                new StudentSkill {
                    SkillName = "ASP.NET Core", StudentID = 1
                },
                new StudentSkill {
                    SkillName = "Entity Framework", StudentID = 1
                },
                new StudentSkill {
                    SkillName = "Javascript", StudentID = 1
                },
                new StudentSkill {
                    SkillName = "HTML", StudentID = 1
                },
                new StudentSkill {
                    SkillName = "Java", StudentID = 2
                },
                new StudentSkill {
                    SkillName = "Bootstrap", StudentID = 2
                },
                new StudentSkill {
                    SkillName = "MongoDB", StudentID = 2
                },
                new StudentSkill {
                    SkillName = "ElasticSearch", StudentID = 2
                }
            };

            context.StudentSkills.AddRange(studentSkills);
            context.SaveChanges();

            // Seed Popular Student Skills
            foreach (var s in studentSkills)
            {
                context.PopularStudentSkills.Add(new PopularStudentSkill {
                    name = s.SkillName.ToUpper(), count = 1
                });
            }

            context.SaveChanges();
            var interests = new Interest[]
            {
                new Interest {
                    InterestName = "Basketball", StudentID = 1
                },
                new Interest {
                    InterestName = "Snowboarding", StudentID = 1
                },
                new Interest {
                    InterestName = "Web Software Architecture", StudentID = 1
                },
                new Interest {
                    InterestName = "Wake Boarding", StudentID = 1
                },
                new Interest {
                    InterestName = "Art", StudentID = 2
                },
                new Interest {
                    InterestName = "Piano", StudentID = 2
                },
                new Interest {
                    InterestName = "Rock Climbing", StudentID = 2
                },
                new Interest {
                    InterestName = "Chess", StudentID = 2
                }
            };

            context.Interests.AddRange(interests);
            context.SaveChanges();

            var completedCourses = new CompletedCourse[]
            {
                new CompletedCourse {
                    CompletedCourseName = "CS-3100", StudentID = 1
                },
                new CompletedCourse {
                    CompletedCourseName = "CS-2420", StudentID = 1
                },
                new CompletedCourse {
                    CompletedCourseName = "CS-4480", StudentID = 1
                },
                new CompletedCourse {
                    CompletedCourseName = "CS-3505", StudentID = 1
                },
                new CompletedCourse {
                    CompletedCourseName = "CS-2420", StudentID = 2
                },
                new CompletedCourse {
                    CompletedCourseName = "CS-1030", StudentID = 2
                },
                new CompletedCourse {
                    CompletedCourseName = "CS-1410", StudentID = 2
                },
                new CompletedCourse {
                    CompletedCourseName = "MATH-2270", StudentID = 2
                }
            };

            context.CompletedCourses.AddRange(completedCourses);
            context.SaveChanges();
        }