本文整理汇总了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);
}
}
示例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();
}
示例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);
}
}