Commit 9c40c713 authored by Deokhyun Lee's avatar Deokhyun Lee

calculating 60 percent of passing_score is implemented.

parent b24cab4e
# Generated by Django 4.1.7 on 2023-03-05 15:53
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=100)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignments',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.CharField(max_length=1000)),
('perfect_score', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
......@@ -7,6 +7,9 @@ class Course(models.Model):
title = models.CharField(max_length = 100)
section = models.CharField(max_length = 3)
def __str__(self):
return self.code + " - " + self.title
# Assignments
# name; description; course; perfect_score; passing_score
class Assignment(models.Model):
......@@ -15,8 +18,17 @@ class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete = models.CASCADE)
perfect_score = models.IntegerField(default = 0)
passing_score = models.IntegerField(default = 0)
# calculates a passing score based on perfect score with 60%
def __str__(self):
return self.name
# calculates a passing score of 60%
@property
def passing_score_calculated(self, value):
self.passing_score = int(value * 0.6)
def passing_score_calculated(self):
return int(self.passing_score * 0.6)
def save(self, *args, **kwarg):
# passing_score will be updated after save()
self.passing_score = self.passing_score_calculated
super(Assignment, self).save(*args, **kwarg)
\ No newline at end of file
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