Example #1
0
        GetAllLearningObjectives()
        {
            var errors = new List <Error>();
            var learningObjectivesBuilder = LearningObjectives.CreateBuilder();
            var conceptsAndObjectives     = designDocFileHandler.GetExerciseDesignsForTrack()
                                            .SelectMany(
                designDetails => designDocParser.ParseDesignDoc(
                    GetExerciseNameFromPath(designDetails.DesignDocPath),
                    designDetails.DesignDocContents));

            foreach (var conceptAndObjective in conceptsAndObjectives)
            {
                switch (conceptAndObjective)
                {
                case (Result.Success, _, (string designDocId, string conceptName)conceptDetails, string objective):
                    learningObjectivesBuilder.Add(conceptDetails, objective);
                    break;

                case (Result.Errors, string error, _, _):
                    errors.Add(new Error(ErrorSource.Design, Severity.Error, error));
                    break;

                case (_, _, _, _):
                    throw new ArgumentException();
                }
            }

            return(learningObjectivesBuilder.CreateLearningObjectives(), errors);
        }
Example #2
0
        private void MergeLearningObjectives(ExerciseObjectTree exerciseObjectTree,
                                             LearningObjectives learningObjectives)
        {
            var concepts = exerciseObjectTree.Exercises.SelectMany(ex => ex.Concepts);

            foreach (var concept in concepts)
            {
                var objectives = learningObjectives.GetObjectivesForConcept(concept.Name);
                if (objectives != null)
                {
                    concept.LearningObjectives.Clear();
                    foreach (string objective in objectives)
                    {
                        concept.LearningObjectives.Add(objective);
                    }
                }
            }
        }
Example #3
0
        private List <Error> ReportUnmatchedConcepts(ExerciseObjectTree exerciseObjectTree,
                                                     LearningObjectives learningObjectives)
        {
            var exerciseMap = exerciseObjectTree.Exercises
                              .SelectMany(ex => ex.Concepts)
                              .Select(con => con.Name)
                              .ToHashSet();

            List <Error> errors = new List <Error>();

            foreach ((string DocId, string ConceptName)conceptDetails in learningObjectives.ConceptsInclDesignDocId)
            {
                if (!exerciseMap.Contains(conceptDetails.ConceptName))
                {
                    errors.Add(new Error(ErrorSource.Merge, Severity.Error,
                                         $"Failed to find concept {conceptDetails.ConceptName}, from the {conceptDetails.DocId} {Constants.DesignMd}, in {Constants.ExercisesJson} file"));
                }
            }

            return(errors);
        }