当前位置: 首页>>代码示例>>C#>>正文


C# Course.GetUnits方法代码示例

本文整理汇总了C#中Course.GetUnits方法的典型用法代码示例。如果您正苦于以下问题:C# Course.GetUnits方法的具体用法?C# Course.GetUnits怎么用?C# Course.GetUnits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Course的用法示例。


在下文中一共展示了Course.GetUnits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PatchInstructorsNotes

		private void PatchInstructorsNotes(EdxCourse edxCourse, Course ulearnCourse, string olxPath)
		{
			var ulearnUnits = ulearnCourse.GetUnits().ToList();
			foreach (var chapter in edxCourse.CourseWithChapters.Chapters)
			{
				var chapterNote = ulearnCourse.InstructorNotes.FirstOrDefault(x => x.UnitName == chapter.DisplayName);
				if (chapterNote == null)
					continue;
				var unitIndex = ulearnUnits.IndexOf(chapterNote.UnitName);
				var displayName = "Заметки преподавателю";
				var sequentialId = string.Format("{0}-{1}-{2}", ulearnCourse.Id, unitIndex, "note-seq");
				var verticalId = string.Format("{0}-{1}-{2}", ulearnCourse.Id, unitIndex, "note-vert");
				var mdBlockId = string.Format("{0}-{1}-{2}", ulearnCourse.Id, unitIndex, "note-md");
				var sequentialNote = new Sequential(sequentialId, displayName,
					new[]
					{
						new Vertical(verticalId, displayName, new[] { new MdBlock(chapterNote.Markdown).ToEdxComponent(mdBlockId, displayName, ulearnCourse.GetDirectoryByUnitName(chapterNote.UnitName)) })
					}) { VisibleToStaffOnly = true };
				if (!File.Exists(string.Format("{0}/sequential/{1}.xml", olxPath, sequentialNote.UrlName)))
				{
					var sequentials = chapter.Sequentials.ToList();
					sequentials.Add(sequentialNote);
					new Chapter(chapter.UrlName, chapter.DisplayName, chapter.Start, sequentials.ToArray()).Save(olxPath);
				}
				sequentialNote.Save(olxPath);
			}
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:27,代码来源:ULearnPatchOptions.cs

示例2: CourseToChapters

		private static Chapter[] CourseToChapters(Course course, Config config, string exerciseUrl, string solutionsUrl, Dictionary<string, string> videoGuids)
		{
			var units = course.GetUnits().ToList();
			return Enumerable
				.Range(0, units.Count)
				.Select(x => new Chapter(string.Format("{0}-{1}", course.Id, x), units[x], UnitToSequentials(course, config, units, x, exerciseUrl, solutionsUrl, videoGuids)))
				.ToArray();
		}
开发者ID:fakefeik,项目名称:uLearn,代码行数:8,代码来源:Converter.cs

示例3: UserCourseModel

		public UserCourseModel(Course course, ApplicationUser user, ULearnDb db)
		{
			Course = course;
			User = user;

			var visits = db.Visits.Where(v => v.UserId == user.Id && v.CourseId == course.Id).GroupBy(v => v.SlideId).ToDictionary(g => g.Key, g => g.FirstOrDefault());
			var unitResults = new Dictionary<string, UserCourseUnitModel>();
			foreach (var slide in Course.Slides)
			{
				var unit = slide.Info.UnitName;
				if (!unitResults.ContainsKey(unit))
					unitResults.Add(unit, new UserCourseUnitModel
					{
						UnitName = unit,
						SlideVisits = new ProgressModel(),
						Exercises = new ProgressModel(),
						Quizes = new ProgressModel(),
						Total = new ProgressModel()
					});

				var res = unitResults[unit];
				var isVisited = visits.ContainsKey(slide.Id);
				var isPassed = isVisited && visits[slide.Id].IsPassed;
				var score = isPassed ? visits[slide.Id].Score : 0;

				res.SlideVisits.Total++;
				res.Total.Total += slide.MaxScore;
				res.Total.Earned += score;

				if (isVisited)
					res.SlideVisits.Earned++;

				if (slide is ExerciseSlide)
				{
					res.Exercises.Total += slide.MaxScore;
					res.Exercises.Earned += score;
				}

				if (slide is QuizSlide)
				{
					res.Quizes.Total += slide.MaxScore;
					res.Quizes.Earned += score;
				}
			}

			Units = course.GetUnits().Select(unitName => unitResults[unitName]).ToArray();
			Total = new UserCourseUnitModel
			{
				Total = new ProgressModel(),
				Exercises = new ProgressModel(),
				SlideVisits = new ProgressModel(),
				Quizes = new ProgressModel()
			};
			foreach (var result in Units)
			{
				Total.Total.Add(result.Total);
				Total.Exercises.Add(result.Exercises);
				Total.SlideVisits.Add(result.SlideVisits);
				Total.Quizes.Add(result.Quizes);
			}
		}
开发者ID:andgein,项目名称:uLearn,代码行数:61,代码来源:UserCourseModel.cs


注:本文中的Course.GetUnits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。