Commit 353dc104 authored by Brescia Amandy's avatar Brescia Amandy

Created models for the Assignments app

parent 0fe4e519
# Generated by Django 3.0 on 2023-03-05 12:46
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.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=255)),
('section', models.CharField(blank=True, max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('description', models.TextField(blank=True)),
('perfect_score', models.IntegerField(blank=True, default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.Course')),
],
),
]
from django.db import models from django.db import models
# Create your models here.
class Course(models.Model):
code = models.CharField(max_length=10)
title = models.CharField(max_length=255)
section = models.CharField(max_length=3, blank=True)
def __str__(self):
return self.code
class Assignment(models.Model):
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.IntegerField(blank=True, default=0)
@property
def passing_score(self):
passing_score = self.perfect_score * 0.60
return passing_score
def __str__(self):
return self.name
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