コード例 #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
ファイル: BuildUpContext.cs プロジェクト: kontur-edu/uLearn
		public BuildUpContext(DirectoryInfo dir, CourseSettings courseSettings, Lesson lesson)
		{
			Dir = dir;
			CourseSettings = courseSettings;
			Lesson = lesson;
			Extractors = new List<RegionsExtractor>();
		}
コード例 #3
0
ファイル: CSharpSlideLoader.cs プロジェクト: andgein/uLearn
		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
ファイル: BuildUpContext.cs プロジェクト: andgein/uLearn
		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
ファイル: BuildUpContext.cs プロジェクト: epeshk/uLearn
 public BuildUpContext(DirectoryInfo dir, CourseSettings courseSettings, Lesson lesson, string slideTitle)
 {
     Dir            = dir;
     CourseSettings = courseSettings;
     Lesson         = lesson;
     SlideTitle     = slideTitle;
     Extractors     = new List <RegionsExtractor>();
 }
コード例 #24
0
ファイル: QuizSlideLoader.cs プロジェクト: kontur-edu/uLearn
		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
ファイル: UnitLoaderTests.cs プロジェクト: PhonkX/uLearn
 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
ファイル: BuildUpContext.cs プロジェクト: atnartur/Ulearn
 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
ファイル: QuizSlideLoader.cs プロジェクト: andgein/uLearn
		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
ファイル: SlideLoadingContext.cs プロジェクト: PhonkX/uLearn
        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
ファイル: QuizSlideLoader.cs プロジェクト: kontur-edu/uLearn
		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();
		}