[Answer]-Database design under Django

1đź‘Ť

âś…

Perhaps the way to go about it is to have a separate class for assignment, something like this.

class Assignment(models.Model):
    ASSIGNMENT_TYPES = (
        ('essay', "Essay"),
        ...
    )
    ASSIGNMENT_GRADES = (
        ('a+', "A+"),
        ('a', "A"),
        ...
    )
    student = models.ForeignKey("Student")
    course = models.ForeignKey("Course")
    assignment_type = models.CharField(choices=ASSIGNMENT_TYPES, max_length=15, default='essay')
    progress = models.IntegerField()
    grade = models.CharField(choices=ASSIGNMENT_GRADES, max_length=3, default="a+")

This way you have one assignment connected to one student and one course. It can be modified relatively easy if you have multiple students per one assignment, by adding another class (for example StudentGroup) and including it in the model.

Hope that this helps 🙂

👤user1851738

0đź‘Ť

Create a model called “Assessments”, which has a foreign key to Course. In addition ,create a field called “Assessment Type”, another called “Assessment Result” and a final one called “Assesment Date”. Should look like this:

ASSESSMENTS = (('E','Essay'),('P','Presentation'))

class Assessment(models.MOdel):
    course = models.ForeignKey('Course')
    assessment = models.CharField(choices=ASESSMENTS)
    result = models.CharField(max_length=250)
    taken_on = models.DateField()
    overall_result = models.BooleanField()
    is_complete = models.BooleanField()

Each time there is an exam, you fill in a record in this table for each assessment taken. You can use the overall result as a flag to see if the student has passed or failed, and the is_complete to see if there are any exams pending for a course.

👤Burhan Khalid

0đź‘Ť

You should look at models.py file of classcomm,
a content management system written in Django for delivering and managing Courses on the Web.

It has following Models

  1. Department
  2. Course
  3. Instructor
  4. Mentor
  5. Enrollment
  6. Assignment
  7. DueDateOverride
  8. Submission
  9. Grade
  10. ExtraCredit
  11. Information
  12. Resource
  13. Announcement

You may not need such a complex relationship for you case, but it’s wort looking into it’s models design.

You can find more details on homepage of this project.

👤pankaj28843

Leave a comment