Commit dcd7f9c9 authored by Paul Angelo Sy's avatar Paul Angelo Sy

Changed how passing_score was implemented

parent 6ed2e0c2
# Generated by Django 3.2.12 on 2022-04-01 11:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0016_assignment_max_points'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0),
),
]
...@@ -14,11 +14,12 @@ class Assignment(models.Model): ...@@ -14,11 +14,12 @@ class Assignment(models.Model):
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(default=0) max_points = models.IntegerField(default=0)
passing_score = models.IntegerField(default = 0, editable =False)
course_code = models.ForeignKey(Course, on_delete=models.CASCADE, null = True, blank = True) course_code = models.ForeignKey(Course, on_delete=models.CASCADE, null = True, blank = True)
@property def save(self):
def get_passing(self): self.passing_score = int(self.max_points * 0.6)
return int(self.max_points * 0.6) return super(Assignment, self).save()
def __str__(self): def __str__(self):
return str(self.name) return str(self.name)
...@@ -11,7 +11,7 @@ def index(request): ...@@ -11,7 +11,7 @@ def index(request):
assignmentOutput += ("Assignment Name: " + str(n.name) + "<br/>") assignmentOutput += ("Assignment Name: " + str(n.name) + "<br/>")
assignmentOutput += ("Description: " + n.description + "<br/>") assignmentOutput += ("Description: " + n.description + "<br/>")
assignmentOutput += ("Perfect Score: " + str(n.max_points) + "<br/>") assignmentOutput += ("Perfect Score: " + str(n.max_points) + "<br/>")
assignmentOutput += ("Passing Score: " + str(n.get_passing) + "<br/>") assignmentOutput += ("Passing Score: " + str(n.passing_score) + "<br/>")
assignmentOutput += ("Course/Section: " + Course.objects.get(course_code = n.course_code).course_code + " ") assignmentOutput += ("Course/Section: " + Course.objects.get(course_code = n.course_code).course_code + " ")
assignmentOutput += (Course.objects.get(course_code = n.course_code).course_title + " ") assignmentOutput += (Course.objects.get(course_code = n.course_code).course_title + " ")
assignmentOutput += (Course.objects.get(course_code = n.course_code).section + "<br/><br/>") assignmentOutput += (Course.objects.get(course_code = n.course_code).section + "<br/><br/>")
......
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