How would I appropriately design a ViewModel to edit attendance for different Courses with varying amounts of days of attendance?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 07:14:00

问题


I have models for Students, Courses, Enrollment, and Attendance. Each course has a different number of days of attendance and I need to be able to edit attendance for those days.

I use the following models:

public class Student
{
    public int StudentID { get; set; }
    public string LastName { get; set; }
    public string FirstMidName { get; set; }
    public virtual ICollection<Enrollment> Enrollments { get; set; } // To keep track of what classes in which the student is enrolled
}

public class Course
{
    public int CourseID { get; set; }
    public string Title { get; set; }
    public int InstructorID { get; set; }
    public virtual Instructor Instructor { get; set; }
    public int AttendingDays { get; set; } // Total number of days for attendance
    public virtual ICollection<Enrollment> Enrollments { get; set; }
}

public class Enrollment
{
    public int EnrollmentID { get; set; }
    public int CourseID { get; set; }
    public int StudentID { get; set; }
    public virtual Course Course { get; set; }
    public virtual Student Student { get; set; }
}

public class Attendance
{
    public int AttendanceID { get; set; }
    public int CourseID { get; set; }
    public int StudentID { get; set; }
    public int AttendanceDay { get; set; }
    public bool Present { get; set; }
    public virtual Course Course { get; set; }
    public virtual Student Student { get; set; }
}

How would I go about building a ViewModel that would let me edit the Attendance Table appropriately adjusting the number of days of attendance for the specified class depending on the AttendingDays int from the Course class.

i.e. If Class X has an AttendingDays value of 10, I need 10 rows of attendance dates that I can go down and fill a checkox for present/absent for each student - while Class Y only has 3 AttendingDays, etc. . .

So a sample row from the attendance table would read something like: ID 25: For Course X, Student X on day 3 was present. ID26: For Course X, Student X on day 4 was absent, etc. . .

What is the most efficient way to approach this?

UPDATE:

Now I create Attendance database entries where the student is marked as Present = false for every possible day of attendance once they are added to a class.

How would my ViewModel work now that I know I will always have the appropriate attendance days already in creation for each student?

I would need to generate a page that displays a row for every Student contained within a Course (this information is contained within the Enrollment table). Each Student's row would contain checkboxes for each day of attendance (so there would be a grid of checkboxes going across the screen with student names listed on the left and the number representing the day of attendance across the top).

edit:

Would this be something jqGrid would be useful?

来源:https://stackoverflow.com/questions/10317018/how-would-i-appropriately-design-a-viewmodel-to-edit-attendance-for-different-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!