public CurrentPageViewModel(
            SearchSortFilterPaginationResult <CurrentLearningItem> result,
            bool apiIsAccessible,
            string?bannerText
            ) : base(result, false, searchLabel: "Search your current courses")
        {
            ApiIsAccessible = apiIsAccessible;
            BannerText      = bannerText;

            CurrentActivities = result.ItemsToDisplay.Select <BaseLearningItem, CurrentLearningItemViewModel>(
                activity =>
            {
                return(activity switch
                {
                    CurrentCourse currentCourse => new CurrentCourseViewModel(
                        currentCourse,
                        result.GetReturnPageQuery($"{currentCourse.Id}-course-card")
                        ),
                    SelfAssessment selfAssessment => new SelfAssessmentCardViewModel(
                        selfAssessment,
                        result.GetReturnPageQuery($"{selfAssessment.Id}-sa-card")
                        ),
                    _ => new CurrentLearningResourceViewModel(
                        (ActionPlanResource)activity,
                        result.GetReturnPageQuery($"{activity.Id}-lhr-card")
                        ),
                });
            }
Esempio n. 2
0
        public void Get_current_courses_should_return_courses_for_candidate()
        {
            // When
            const int candidateId = 1;
            var       result      = courseDataService.GetCurrentCourses(candidateId).ToList();

            // Then
            var expectedFirstCourse = new CurrentCourse
            {
                Name                 = "Office 2013 Essentials for the Workplace - Erin Test 01",
                Id                   = 15853,
                LastAccessed         = new DateTime(2019, 1, 22, 8, 20, 39, 133),
                StartedDate          = new DateTime(2016, 7, 6, 11, 12, 15, 393),
                DiagnosticScore      = 0,
                IsAssessed           = true,
                HasDiagnostic        = true,
                HasLearning          = true,
                Passes               = 2,
                Sections             = 6,
                CompleteByDate       = new DateTime(2018, 12, 31, 0, 0, 0, 0),
                GroupCustomisationId = 0,
                SupervisorAdminId    = 0,
                ProgressID           = 173218,
                EnrollmentMethodID   = 1,
                PLLocked             = false,
            };

            result.Should().HaveCount(4);
            result.First().Should().BeEquivalentTo(expectedFirstCourse);
        }
Esempio n. 3
0
 public CurrentCourseViewModel(CurrentCourse course) : base(course)
 {
     UserIsSupervisor    = course.SupervisorAdminId != 0;
     IsEnrolledWithGroup = course.GroupCustomisationId != 0;
     SelfEnrolled        = course.EnrollmentMethodID == 1;
     IsLocked            = course.PLLocked;
 }
Esempio n. 4
0
    void createNewCourse()
    {
        c = new CurrentCourse(coursecode);
        //Debug.Log(c + " = c i createNewCourse i Parser.cs");
        c.setCoursecode(coursecode);
        //c.setLevel(int.Parse(momentcode));

        if (coursecode != null && courseList != null)
        {
            bool newCourse = true;
            foreach (Course course in courseList)
            {
                //Debug.Log(co + " = co in createNewCourse i Parser:s foreachloop");


                /* if (course == null)
                 * {
                 *   //courseList.Remove(co);
                 *   //Debug.Log(" co = null Vi hoppar över den!!");
                 * }
                 * else*/
                if (course != null)
                {
                    //Debug.Log(course.getCoursecode() + " = course:s kurskod in createNewCourse i Parser:s foreachloop");

                    if (course.getCoursecode().Equals(coursecode))
                    {
                        newCourse = false;
                        c         = course;
                    }
                }
            }

            if (newCourse)
            {
                //HasNewCourse = true;
                courseList.Add(c);
                //Debug.Log(c + " was added in courselist");
            }
            createNewMoment(c);
        }
    }
Esempio n. 5
0
        public CurrentPageViewModel(
            IEnumerable <CurrentCourse> currentCourses,
            string?searchString,
            string sortBy,
            string sortDirection,
            IEnumerable <SelfAssessment> selfAssessments,
            IEnumerable <ActionPlanResource> actionPlanResources,
            string?bannerText,
            int page
            ) : base(searchString, page, false, sortBy, sortDirection, searchLabel: "Search your current courses")
        {
            BannerText = bannerText;
            var allItems = currentCourses.Cast <CurrentLearningItem>().ToList();

            allItems.AddRange(selfAssessments);
            allItems.AddRange(actionPlanResources);

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

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

            CurrentActivities = paginatedItems.Select <BaseLearningItem, CurrentLearningItemViewModel>(
                activity =>
            {
                return(activity switch
                {
                    CurrentCourse currentCourse => new CurrentCourseViewModel(currentCourse),
                    SelfAssessment selfAssessment => new SelfAssessmentCardViewModel(selfAssessment),
                    _ => new CurrentLearningResourceViewModel((ActionPlanResource)activity)
                });
            }