Added Course model and added passing_score field on Assignment model

parent 051a1c1b
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=50)
section = models.CharField(max_length=3)
def __str__(self):
return self.course_code
class Assignment(models.Model): class Assignment(models.Model):
course_code = models.ForeignKey(Course, on_delete=models.CASCADE)
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
description = models.CharField(max_length=500) description = models.CharField(max_length=500)
max_points = models.IntegerField() max_points = models.IntegerField(default=0)
passing_score = models.IntegerField(default=0, editable=False)
def __str__(self): def __str__(self):
return self.name return self.name
def save(self):
self.passing_score = int(self.max_points*0.6)
return super(Assignment, self).save()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment