Esempio n. 1
0
        public InitialMenuViewModel(CourseContent courseContent)
        {
            Id              = courseContent.Id;
            Title           = courseContent.Title;
            Description     = courseContent.Description;
            AverageDuration = DurationFormattingHelper.FormatNullableDuration(courseContent.AverageDuration);

            CentreName = courseContent.CentreName;
            BannerText = courseContent.BannerText;
            ShouldShowCompletionSummary = courseContent.IncludeCertification;
            Sections = courseContent.Sections.Select(section => new SectionCardViewModel(
                                                         section,
                                                         Id,
                                                         courseContent.CourseSettings.ShowPercentage
                                                         ));
            CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel(
                courseContent.Id,
                courseContent.Completed,
                courseContent.MaxPostLearningAssessmentAttempts,
                courseContent.IsAssessed,
                courseContent.PostLearningAssessmentPassThreshold,
                courseContent.DiagnosticAssessmentCompletionThreshold,
                courseContent.TutorialsCompletionThreshold
                );
            ShowTime = AverageDuration != null && courseContent.CourseSettings.ShowTime;
        }
Esempio n. 2
0
        public PostLearningAssessmentViewModel(PostLearningAssessment postLearningAssessment, int customisationId, int sectionId)
        {
            CourseTitle        = postLearningAssessment.CourseTitle;
            CourseDescription  = postLearningAssessment.CourseDescription;
            SectionName        = postLearningAssessment.SectionName;
            PostLearningLocked = postLearningAssessment.PostLearningLocked;
            CustomisationId    = customisationId;
            SectionId          = sectionId;
            NextSectionId      = postLearningAssessment.NextSectionId;

            if (postLearningAssessment.PostLearningAttempts == 0)
            {
                AssessmentStatus = "Not attempted";
            }
            else
            {
                AssessmentStatus = GetPassStatus(postLearningAssessment);
                ScoreInformation = GetScoreInformation(postLearningAssessment);
            }
            AssessmentStatusStyling = GetPassStatusStyling(postLearningAssessment);

            StartButtonText = postLearningAssessment.PostLearningAttempts == 0
                ? "Start assessment"
                : "Restart assessment";
            StartButtonAdditionalStyling = postLearningAssessment.PostLearningAttempts == 0
                ? ""
                : "nhsuk-button--secondary";


            OnlyItemInOnlySection = !postLearningAssessment.OtherItemsInSectionExist && !postLearningAssessment.OtherSectionsExist;
            OnlyItemInThisSection = !postLearningAssessment.OtherItemsInSectionExist;
            ShowCompletionSummary = OnlyItemInOnlySection && postLearningAssessment.IncludeCertification;

            CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel(
                customisationId,
                postLearningAssessment.Completed,
                postLearningAssessment.MaxPostLearningAssessmentAttempts,
                postLearningAssessment.IsAssessed,
                postLearningAssessment.PostLearningAssessmentPassThreshold,
                postLearningAssessment.DiagnosticAssessmentCompletionThreshold,
                postLearningAssessment.TutorialsCompletionThreshold
                );

            ShowNextButton = postLearningAssessment.PostLearningAttempts > 0 && !OnlyItemInOnlySection;
        }
        public SectionContentViewModel(IConfiguration config, SectionContent sectionContent, int customisationId, int sectionId)
        {
            CourseTitle                = sectionContent.CourseTitle;
            CourseDescription          = sectionContent.CourseDescription;
            SectionName                = sectionContent.SectionName;
            PercentComplete            = FormatPercentComplete(sectionContent);
            ShowPercentComplete        = sectionContent.HasLearning && sectionContent.CourseSettings.ShowPercentage;
            CustomisationId            = customisationId;
            SectionId                  = sectionId;
            ShowPostLearning           = sectionContent.PostLearningAssessmentPath != null && sectionContent.IsAssessed;
            PostLearningStatus         = GetPostLearningStatus(sectionContent);
            PostLearningStatusStyling  = GetPostLearningStatusStyling(sectionContent);
            ShowDiagnostic             = sectionContent.DiagnosticAssessmentPath != null && sectionContent.DiagnosticStatus;
            DiagnosticCompletionStatus = GetDiagnosticCompletionStatus(sectionContent);
            ConsolidationExercisePath  = sectionContent.ConsolidationPath == null
                ? null
                : OldSystemEndpointHelper.GetConsolidationPathUrl(config, sectionContent.ConsolidationPath);
            ShowConsolidation          = ConsolidationExercisePath != null;
            ConsolidationExerciseLabel = sectionContent.CourseSettings.ConsolidationExercise ?? "Consolidation Exercise";

            Tutorials = sectionContent.Tutorials.Select(tutorial => new TutorialCardViewModel(
                                                            tutorial,
                                                            sectionContent.CourseSettings.ShowTime,
                                                            sectionContent.CourseSettings.ShowLearnStatus,
                                                            sectionId,
                                                            customisationId
                                                            ));

            DisplayDiagnosticSeparator   = ShowDiagnostic && (sectionContent.Tutorials.Any() || ShowPostLearning || ShowConsolidation);
            DisplayTutorialSeparator     = sectionContent.Tutorials.Any() && (ShowPostLearning || ShowConsolidation);
            DisplayPostLearningSeparator = ShowConsolidation && ShowPostLearning;
            NextSectionId                  = sectionContent.NextSectionId;
            ShowCompletionSummary          = sectionContent.IncludeCertification && !sectionContent.OtherSectionsExist;
            OtherSectionsExist             = sectionContent.OtherSectionsExist;
            CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel(
                customisationId,
                sectionContent.Completed,
                sectionContent.MaxPostLearningAssessmentAttempts,
                sectionContent.IsAssessed,
                sectionContent.PostLearningAssessmentPassThreshold,
                sectionContent.DiagnosticAssessmentCompletionThreshold,
                sectionContent.TutorialsCompletionThreshold
                );
        }
     public DiagnosticAssessmentViewModel(DiagnosticAssessment diagnosticAssessment, int customisationId, int sectionId)
     {
         CourseTitle              = diagnosticAssessment.CourseTitle;
         CourseDescription        = diagnosticAssessment.CourseDescription;
         SectionName              = diagnosticAssessment.SectionName;
         DiagnosticAssessmentPath = diagnosticAssessment.DiagnosticAssessmentPath;
         CanSelectTutorials       = diagnosticAssessment.CanSelectTutorials && diagnosticAssessment.Tutorials.Any();
         AttemptsInformation      = diagnosticAssessment.DiagnosticAttempts switch
         {
             0 => "Not attempted",
             1 => $"{diagnosticAssessment.SectionScore}/{diagnosticAssessment.MaxSectionScore} " +
             $"- {diagnosticAssessment.DiagnosticAttempts} attempt",
             _ => $"{diagnosticAssessment.SectionScore}/{diagnosticAssessment.MaxSectionScore} " +
             $"- {diagnosticAssessment.DiagnosticAttempts} attempts"
         };
         HasPostLearningAssessment =
             diagnosticAssessment.PostLearningAssessmentPath != null && diagnosticAssessment.IsAssessed;
         NextTutorialId                 = diagnosticAssessment.NextTutorialId;
         NextSectionId                  = diagnosticAssessment.NextSectionId;
         CustomisationId                = customisationId;
         SectionId                      = sectionId;
         Tutorials                      = diagnosticAssessment.Tutorials;
         OnlyItemInOnlySection          = !diagnosticAssessment.OtherItemsInSectionExist && !diagnosticAssessment.OtherSectionsExist;
         OnlyItemInThisSection          = !diagnosticAssessment.OtherItemsInSectionExist;
         ShowCompletionSummary          = OnlyItemInOnlySection && diagnosticAssessment.IncludeCertification;
         CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel(
             customisationId,
             diagnosticAssessment.Completed,
             diagnosticAssessment.MaxPostLearningAssessmentAttempts,
             diagnosticAssessment.IsAssessed,
             diagnosticAssessment.PostLearningAssessmentPassThreshold,
             diagnosticAssessment.DiagnosticAssessmentCompletionThreshold,
             diagnosticAssessment.TutorialsCompletionThreshold
             );
         DiagnosticStartButtonAdditionalStyling = diagnosticAssessment.DiagnosticAttempts > 0 ? "nhsuk-button--secondary" : "";
         DiagnosticStartButtonText = diagnosticAssessment.DiagnosticAttempts > 0 ? "Restart assessment" : "Start assessment";
         ShowNextButton            = diagnosticAssessment.DiagnosticAttempts > 0 && !OnlyItemInOnlySection;
     }
 }
Esempio n. 5
0
        public TutorialViewModel(
            IConfiguration config,
            TutorialInformation tutorialInformation,
            int customisationId,
            int sectionId
            )
        {
            TutorialName             = tutorialInformation.Name;
            SectionName              = tutorialInformation.SectionName;
            CourseTitle              = tutorialInformation.CourseTitle;
            CourseDescription        = tutorialInformation.CourseDescription;
            TutorialPath             = tutorialInformation.TutorialPath;
            VideoPath                = tutorialInformation.VideoPath;
            Status                   = tutorialInformation.Status;
            ShowLearnStatus          = tutorialInformation.CourseSettings.ShowLearnStatus;
            SupportingMaterialsLabel =
                tutorialInformation.CourseSettings.SupportingInformation ?? "Download supporting materials";

            CustomisationId = customisationId;
            SectionId       = sectionId;
            TutorialId      = tutorialInformation.Id;
            Objectives      = ParseObjectives(tutorialInformation.Objectives);

            CanShowProgress = GetCanShowProgress(
                tutorialInformation.CourseSettings.ShowLearnStatus,
                tutorialInformation.CanShowDiagnosticStatus,
                tutorialInformation.AttemptCount
                );
            TutorialRecommendation =
                GetTutorialRecommendation(tutorialInformation.CurrentScore, tutorialInformation.PossibleScore);
            ScoreSummary = GetScoreSummary(tutorialInformation.CurrentScore, tutorialInformation.PossibleScore);
            TimeSummary  = new TutorialTimeSummaryViewModel(
                tutorialInformation.TimeSpent,
                tutorialInformation.AverageTutorialDuration,
                tutorialInformation.CourseSettings.ShowTime,
                tutorialInformation.CourseSettings.ShowLearnStatus
                );
            SupportingMaterialPath =
                ContentUrlHelper.GetNullableContentPath(config, tutorialInformation.SupportingMaterialPath);
            NextLinkViewModel = new TutorialNextLinkViewModel(
                customisationId,
                sectionId,
                tutorialInformation.PostLearningAssessmentPath,
                tutorialInformation.NextTutorialId,
                tutorialInformation.NextSectionId
                );

            OnlyItemInOnlySection = !tutorialInformation.OtherItemsInSectionExist && !tutorialInformation.OtherSectionsExist;
            OnlyItemInThisSection = !tutorialInformation.OtherItemsInSectionExist;
            ShowCompletionSummary = OnlyItemInOnlySection && tutorialInformation.IncludeCertification;

            CompletionSummaryCardViewModel = new CompletionSummaryCardViewModel(
                customisationId,
                tutorialInformation.Completed,
                tutorialInformation.MaxPostLearningAssessmentAttempts,
                tutorialInformation.IsAssessed,
                tutorialInformation.PostLearningAssessmentPassThreshold,
                tutorialInformation.DiagnosticAssessmentCompletionThreshold,
                tutorialInformation.TutorialsCompletionThreshold
                );
            TutorialStartButtonAdditionalStyling = tutorialInformation.Status == "Complete" ? "nhsuk-button--secondary" : "";
            TutorialStartButtonText = tutorialInformation.Status == "Complete" ? "Restart tutorial" : "Start tutorial";
            ShowNextButton          = tutorialInformation.Status == "Complete" && !OnlyItemInOnlySection;
        }