started creating module ui, workign on assignments

This commit is contained in:
2023-01-23 20:42:12 -07:00
parent 4da93ca348
commit fae06907be
11 changed files with 256 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
public interface IModuleManager
{
IEnumerable<CourseModule> Modules { get; }
public void AddModule(CourseModule newModule);
public void AddAssignment(int moduleIndex, LocalAssignment assignment);
}

View File

@@ -0,0 +1,22 @@
public class ModuleManager : IModuleManager
{
public IEnumerable<CourseModule> Modules { get; internal set; } = new CourseModule[] { };
public void AddAssignment(int moduleIndex, LocalAssignment assignment)
{
var newAssignments = Modules.ElementAt(moduleIndex).Assignments.Append(assignment);
var newModule = Modules.ElementAt(moduleIndex) with { Assignments = newAssignments };
if (newModule == null)
throw new Exception($"cannot get module at index {moduleIndex}");
Modules = Modules
.Take(moduleIndex)
.Append(newModule)
.Concat(Modules.Skip(moduleIndex + 1));
}
public void AddModule(CourseModule newModule)
{
Modules = Modules.Append(newModule);
}
}

View File

@@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
public record CourseModule(
[property: Required]
[property: StringLength(50, ErrorMessage = "Name too long (50 character limit).")]
string Name,
IEnumerable<LocalAssignment>? Assignments
)
{
public IEnumerable<LocalAssignment> Assignments = Assignments ?? new LocalAssignment[] { };
}

View File

@@ -0,0 +1,31 @@
public record RubricItem(
int Points,
string Label
);
public enum SubmissionType
{
online_quiz,
none,
on_paper,
discussion_topic,
external_tool,
online_upload,
online_text_entry,
online_url,
media_recording,
student_annotation,
}
public record LocalAssignment
{
public string name { get; init; } = "";
public string description { get; init; } = "";
public bool published { get; init; }
public bool lock_at_due_date { get; init; }
public IEnumerable<RubricItem> rubric { get; init; } = new RubricItem[] { };
public DateTime? lock_at { get; init; }
public DateTime due_at { get; init; }
public int points_possible { get; init; }
public IEnumerable<SubmissionType> submission_types { get; init; } = new SubmissionType[] { };
}