Пример #1
0
        public Slide Load(FileInfo file, Unit unit, int slideIndex, string courseId, CourseSettings settings)
        {
            var quiz = file.DeserializeXml <Quiz>();

            quiz.Meta?.FixPaths(file);

            var scoringGroupsIds = settings.Scoring.Groups.Keys;

            if (!string.IsNullOrEmpty(quiz.ScoringGroup) && !scoringGroupsIds.Contains(quiz.ScoringGroup))
            {
                throw new CourseLoadingException(
                          $"Неизвестная группа оценки у теста {quiz.Title}: {quiz.ScoringGroup}\n" +
                          "Возможные значения: " + string.Join(", ", scoringGroupsIds));
            }

            if (string.IsNullOrEmpty(quiz.ScoringGroup))
            {
                quiz.ScoringGroup = settings.Scoring.DefaultScoringGroupForQuiz;
            }

            BuildUp(quiz, unit, courseId, settings);
            quiz.InitQuestionIndices();
            var slideInfo = new SlideInfo(unit, file, slideIndex);

            return(new QuizSlide(slideInfo, quiz));
        }
Пример #2
0
		public BuildUpContext(DirectoryInfo dir, CourseSettings courseSettings, Lesson lesson)
		{
			Dir = dir;
			CourseSettings = courseSettings;
			Lesson = lesson;
			Extractors = new List<RegionsExtractor>();
		}
Пример #3
0
		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var sourceCode = file.ContentAsUtf8();
			var prelude = GetPrelude(file.Directory);
			var fs = new FileSystem(file.Directory);
			return SlideParser.ParseCode(sourceCode, new SlideInfo(unitName, file, slideIndex), prelude, fs);
		}
Пример #4
0
        public void Get_tutorial_information_should_parse_course_settings()
        {
            using (new TransactionScope())
            {
                // Given
                const int    candidateId        = 1;
                const int    customisationId    = 1379;
                const int    sectionId          = 74;
                const int    tutorialId         = 50;
                const string courseSettingsText =
                    "{\"lm.sp\":false,\"lm.st\":false,\"lm.sl\":false,\"df.sd\":false,"
                    + "\"df.sm\":false,\"df.ss\":false,\"lm:ce\":\"consolidation/exercise\","
                    + "\"lm:si\":\"supporting/information\"}";
                var expectedCourseSettings = new CourseSettings(courseSettingsText);

                courseContentTestHelper.AddCourseSettings(customisationId, courseSettingsText);

                // When
                var tutorial = tutorialContentDataService.GetTutorialInformation(candidateId, customisationId, sectionId, tutorialId);

                // Then
                tutorial.Should().NotBeNull();
                tutorial !.CourseSettings.Should().BeEquivalentTo(expectedCourseSettings);
            }
        }
Пример #5
0
 public BuildUpContext(IFileSystem fileSystem, CourseSettings courseSettings, Lesson lesson)
 {
     FileSystem     = fileSystem;
     CourseSettings = courseSettings;
     Lesson         = lesson;
     Extractors     = new List <RegionsExtractor>();
 }
Пример #6
0
 public CourseController(
     IPermissionService permissionService,
     IAclService aclService,
     IWorkContext workContext,
     IStoreMappingService storeMappingService,
     ICustomerActivityService customerActivityService,
     IGenericAttributeService genericAttributeService,
     IWebHelper webHelper,
     IStoreContext storeContext,
     ILocalizationService localizationService,
     ICustomerActionEventService customerActionEventService,
     ICourseService courseService,
     ICourseLessonService courseLessonService,
     IDownloadService downloadService,
     IMediator mediator,
     CourseSettings courseSettings)
 {
     _permissionService       = permissionService;
     _aclService              = aclService;
     _workContext             = workContext;
     _storeMappingService     = storeMappingService;
     _customerActivityService = customerActivityService;
     _genericAttributeService = genericAttributeService;
     _webHelper                  = webHelper;
     _storeContext               = storeContext;
     _localizationService        = localizationService;
     _customerActionEventService = customerActionEventService;
     _courseService              = courseService;
     _courseLessonService        = courseLessonService;
     _downloadService            = downloadService;
     _mediator       = mediator;
     _courseSettings = courseSettings;
 }
Пример #7
0
        public static void BuildUp(Quiz quiz, Unit unit, string courseId, CourseSettings settings)
        {
            var context = new BuildUpContext(unit, settings, null, courseId, quiz.Title);
            var blocks  = quiz.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet <string> .Empty));

            quiz.Blocks = blocks.ToArray();
        }
Пример #8
0
        public static void BuildUp(Quiz quiz, DirectoryInfo slideDir, CourseSettings settings)
        {
            var context = new BuildUpContext(slideDir, settings, null, quiz.Title);
            var blocks  = quiz.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet <string> .Empty));

            quiz.Blocks = blocks.ToArray();
        }
Пример #9
0
 public CourseController(
     IPermissionService permissionService,
     IAclService aclService,
     IWorkContext workContext,
     IGroupService groupService,
     ICustomerActivityService customerActivityService,
     IUserFieldService userFieldService,
     ITranslationService translationService,
     ICustomerActionEventService customerActionEventService,
     ICourseService courseService,
     ICourseLessonService courseLessonService,
     IDownloadService downloadService,
     IMediator mediator,
     CourseSettings courseSettings)
 {
     _permissionService          = permissionService;
     _aclService                 = aclService;
     _workContext                = workContext;
     _groupService               = groupService;
     _customerActivityService    = customerActivityService;
     _userFieldService           = userFieldService;
     _translationService         = translationService;
     _customerActionEventService = customerActionEventService;
     _courseService              = courseService;
     _courseLessonService        = courseLessonService;
     _downloadService            = downloadService;
     _mediator       = mediator;
     _courseSettings = courseSettings;
 }
Пример #10
0
		public BuildUpContext(IFileSystem fileSystem, CourseSettings courseSettings, Lesson lesson)
		{
			FileSystem = fileSystem;
			CourseSettings = courseSettings;
			Lesson = lesson;
			Extractors = new List<RegionsExtractor>();
		}
Пример #11
0
        public void CourseSettings_should_have_default_ShowTime_when_wrong_type()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.st\":3}");

            // Then
            courseSettings.ShowTime.Should().BeTrue();
        }
Пример #12
0
        public void CourseSettings_should_have_default_SupportingInformation_when_whitespace()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.si\":\"   \"}");

            // Then
            courseSettings.SupportingInformation.Should().BeNull();
        }
Пример #13
0
        public void CourseSettings_should_take_SupportingInformation_from_json()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.si\":\"Supporting information\"}");

            // Then
            courseSettings.SupportingInformation.Should().Be("Supporting information");
        }
Пример #14
0
        public void CourseSettings_should_have_default_SupportingInformation_when_not_in_json()
        {
            // When
            var courseSettings = new CourseSettings(null);

            // Then
            courseSettings.SupportingInformation.Should().BeNull();
        }
Пример #15
0
        public void CourseSettings_should_have_default_ConsolidationExercise_when_whitespace()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.ce\":\"   \"}");

            // Then
            courseSettings.ConsolidationExercise.Should().BeNull();
        }
Пример #16
0
        public void CourseSettings_should_have_default_ConsolidationExercise_when_not_in_json()
        {
            // When
            var courseSettings = new CourseSettings(null);

            // Then
            courseSettings.ConsolidationExercise.Should().BeNull();
        }
Пример #17
0
        public void CourseSettings_should_take_ConsolidationExercise_from_json()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.ce\":\"Consolidation exercise\"}");

            // Then
            courseSettings.ConsolidationExercise.Should().Be("Consolidation exercise");
        }
Пример #18
0
        public void CourseSettings_should_have_default_ShowPercentage_when_wrong_type()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.sp\":\"Line Manager\"}");

            // Then
            courseSettings.ShowPercentage.Should().BeTrue();
        }
Пример #19
0
        public void CourseSettings_should_have_default_ShowPercentage_when_not_in_json()
        {
            // When
            var courseSettings = new CourseSettings(null);

            // Then
            courseSettings.ShowPercentage.Should().BeTrue();
        }
Пример #20
0
        public void CourseSettings_should_take_ShowLearnStatus_from_json()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.sl\":false}");

            // Then
            courseSettings.ShowLearnStatus.Should().BeFalse();
        }
Пример #21
0
        public void CourseSettings_should_take_ShowPercentage_from_json()
        {
            // When
            var courseSettings = new CourseSettings("{\"lm.sp\":false}");

            // Then
            courseSettings.ShowPercentage.Should().BeFalse();
        }
Пример #22
0
        public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
        {
            var sourceCode = file.ContentAsUtf8();
            var prelude    = GetPrelude(file.Directory);
            var fs         = new FileSystem(file.Directory);

            return(SlideParser.ParseCode(sourceCode, new SlideInfo(unitName, file, slideIndex), prelude, fs));
        }
Пример #23
0
 public BuildUpContext(DirectoryInfo dir, CourseSettings courseSettings, Lesson lesson, string slideTitle)
 {
     Dir            = dir;
     CourseSettings = courseSettings;
     Lesson         = lesson;
     SlideTitle     = slideTitle;
     Extractors     = new List <RegionsExtractor>();
 }
Пример #24
0
		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var quiz = file.DeserializeXml<Quiz>();
			BuildUp(quiz, file.Directory, settings);
			quiz.InitQuestionIndices();
			var slideInfo = new SlideInfo(unitName, file, slideIndex);
			return new QuizSlide(slideInfo, quiz);
		}
Пример #25
0
 public void OneTimeSetUp()
 {
     loader         = new UnitLoader(new XmlSlideLoader());
     courseSettings = new CourseSettings(CourseSettings.DefaultSettings);
     courseSettings.Scoring.Groups.Add("ScoringGroup1", new ScoringGroup
     {
         Id = "ScoringGroup1"
     });
 }
Пример #26
0
 public SlideLoadingContext(string courseId, Unit unit, CourseSettings courseSettings, DirectoryInfo courseDirectory, FileInfo slideFile)
 {
     CourseId        = courseId;
     Unit            = unit;
     UnitDirectory   = unit.Directory;
     CourseDirectory = courseDirectory;
     CourseSettings  = courseSettings;
     SlideFile       = slideFile;
 }
Пример #27
0
 public BuildUpContext(Unit unit, CourseSettings courseSettings, Lesson lesson, string courseId, string slideTitle)
 {
     Dir            = unit.Directory;
     CourseSettings = courseSettings;
     Unit           = unit;
     Lesson         = lesson;
     CourseId       = courseId;
     SlideTitle     = slideTitle;
     Extractors     = new List <RegionsExtractor>();
 }
Пример #28
0
 public SectionContent(
     string applicationName,
     string?applicationInfo,
     string customisationName,
     string sectionName,
     bool hasLearning,
     int diagAttempts,
     int diagLast,
     int diagAssessOutOf,
     string?diagAssessPath,
     string?plAssessPath,
     int attemptsPl,
     int plPasses,
     bool diagStatus,
     bool isAssessed,
     string?consolidationPath,
     string?courseSettings,
     bool includeCertification,
     DateTime?completed,
     int maxPostLearningAssessmentAttempts,
     int postLearningAssessmentPassThreshold,
     int diagnosticAssessmentCompletionThreshold,
     int tutorialsCompletionThreshold,
     bool otherSectionsExist,
     int?nextSectionId,
     string?password,
     bool passwordSubmitted
     )
 {
     CourseTitle                = $"{applicationName} - {customisationName}";
     CourseDescription          = applicationInfo;
     SectionName                = sectionName;
     HasLearning                = hasLearning;
     DiagnosticAttempts         = diagAttempts;
     SectionScore               = diagLast;
     MaxSectionScore            = diagAssessOutOf;
     DiagnosticAssessmentPath   = diagAssessPath;
     PostLearningAssessmentPath = plAssessPath;
     PostLearningAttempts       = attemptsPl;
     PostLearningPassed         = plPasses > 0;
     DiagnosticStatus           = diagStatus;
     IsAssessed           = isAssessed;
     ConsolidationPath    = consolidationPath;
     CourseSettings       = new CourseSettings(courseSettings);
     IncludeCertification = includeCertification;
     Completed            = completed;
     MaxPostLearningAssessmentAttempts       = maxPostLearningAssessmentAttempts;
     PostLearningAssessmentPassThreshold     = postLearningAssessmentPassThreshold;
     DiagnosticAssessmentCompletionThreshold = diagnosticAssessmentCompletionThreshold;
     TutorialsCompletionThreshold            = tutorialsCompletionThreshold;
     OtherSectionsExist = otherSectionsExist;
     NextSectionId      = nextSectionId;
     Password           = password;
     PasswordSubmitted  = passwordSubmitted;
 }
Пример #29
0
		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var quiz = file.DeserializeXml<Quiz>();
			int index = 1;
			foreach (var b in quiz.Blocks.OfType<AbstractQuestionBlock>())
			{
				b.QuestionIndex = index++;
			}
			var slideInfo = new SlideInfo(unitName, file, slideIndex);
			return new QuizSlide(slideInfo, quiz);
		}
Пример #30
0
		public Slide Load(FileInfo file, string unitName, int slideIndex, CourseSettings settings)
		{
			var lesson = file.DeserializeXml<Lesson>();
		    var dir = file.Directory;
			var context = new BuildUpContext(dir, settings, lesson);
			var blocks = lesson.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet<string>.Empty)).ToList();
			var slideInfo = new SlideInfo(unitName, file, slideIndex);
			if (blocks.OfType<ExerciseBlock>().Any())
				return new ExerciseSlide(blocks, slideInfo, lesson.Title, Guid.Parse(lesson.Id));
			return new Slide(blocks, slideInfo, lesson.Title, Guid.Parse(lesson.Id));
		}
Пример #31
0
        public SlideLoadingContext(string courseId, Unit unit, CourseSettings courseSettings, FileInfo slideFile, int slideIndex)
        {
            CourseId = courseId;

            Unit          = unit;
            UnitDirectory = unit.Directory;

            CourseSettings = courseSettings;
            SlideFile      = slideFile;
            SlideIndex     = slideIndex;
        }
Пример #32
0
        public void CourseSettings_should_have_default_settings_when_json_is_empty_list()
        {
            // Given
            var defaultSettings = new CourseSettings(null);

            // When
            var courseSettings = new CourseSettings("[]");

            // Then
            courseSettings.Should().BeEquivalentTo(defaultSettings);
        }
Пример #33
0
        public void CourseSettings_should_have_default_settings_when_json_is_malformed()
        {
            // Given
            var defaultSettings = new CourseSettings(null);

            // When
            var courseSettings = new CourseSettings("{\"lm.su\":\"Line Manager");

            // Then
            courseSettings.Should().BeEquivalentTo(defaultSettings);
        }
Пример #34
0
        public SlideBuildingContext(string courseId, Unit unit, CourseSettings courseSettings, DirectoryInfo courseDirectory, Slide slide)
        {
            CourseId = courseId;

            Unit            = unit;
            UnitDirectory   = unit.Directory;
            CourseDirectory = courseDirectory;
            CourseSettings  = courseSettings;
            Slide           = slide;
            Extractors      = new List <RegionsExtractor>();
        }
Пример #35
0
        public void OneTimeSetUp()
        {
            Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);

            loader         = new XmlSlideLoader();
            courseSettings = new CourseSettings(CourseSettings.DefaultSettings);
            courseSettings.Scoring.Groups.Add("ScoringGroup1", new ScoringGroup {
                Id = "ScoringGroup1"
            });
            unit = new Unit(UnitSettings.CreateByTitle("Unit title", courseSettings), new DirectoryInfo(testDataDirectory));
        }
Пример #36
0
 public void OneTimeSetUp()
 {
     Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
     videoAnnotationsClient = Mock.Of <IUlearnVideoAnnotationsClient>();
     slideRenderer          = new SlideRenderer(videoAnnotationsClient, null, null, null);
     loader         = new XmlSlideLoader();
     courseSettings = new CourseSettings(CourseSettings.DefaultSettings);
     courseSettings.Scoring.Groups.Add("ScoringGroup1", new ScoringGroup {
         Id = "ScoringGroup1"
     });
     unit = new Unit(UnitSettings.CreateByTitle("Unit title", courseSettings), new DirectoryInfo(testDataDirectory));
 }
Пример #37
0
		public static void BuildUp(Quiz quiz, DirectoryInfo slideDir, CourseSettings settings)
		{
			var context = new BuildUpContext(slideDir, settings, null);
			var blocks = quiz.Blocks.SelectMany(b => b.BuildUp(context, ImmutableHashSet<string>.Empty));
			quiz.Blocks = blocks.ToArray();
		}