Commit 5768c03f authored by John Raymon C Yu's avatar John Raymon C Yu

Yu / Assignments

parent 946e836b
from django.contrib import admin
# Register your models here.
from .models import Assignment
from .models import Assignment, Course
admin.site.register(Assignment)
\ No newline at end of file
admin.site.register(Assignment)
admin.site.register(Course)
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-04-04 18:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('course_code', models.CharField(max_length=10)),
('course_title', models.CharField(max_length=100)),
('course_section', models.CharField(max_length=3)),
],
),
migrations.AddField(
model_name='assignment',
name='assignment_passing_score',
field=models.IntegerField(default=0),
preserve_default=False,
),
migrations.AlterField(
model_name='assignment',
name='assignment_max_points',
field=models.IntegerField(blank=True),
),
migrations.AddField(
model_name='assignment',
name='assignment_course',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
]
# Generated by Django 4.0.3 on 2022-04-04 18:32
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_course_assignment_assignment_passing_score_and_more'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_passing_score',
field=models.IntegerField(verbose_name=0),
),
]
# Generated by Django 4.0.3 on 2022-04-04 18:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0003_alter_assignment_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_max_points',
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name='assignment',
name='assignment_passing_score',
field=models.IntegerField(default=0),
),
]
# Generated by Django 4.0.3 on 2022-04-04 19:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0004_alter_assignment_assignment_max_points_and_more'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_passing_score',
field=models.FloatField(default=0, editable=False),
),
]
# Generated by Django 4.0.3 on 2022-04-04 19:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0005_alter_assignment_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_passing_score',
field=models.IntegerField(default=0),
),
]
# Generated by Django 4.0.3 on 2022-04-05 12:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0006_alter_assignment_assignment_passing_score'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_passing_score',
field=models.IntegerField(default=0, editable=False),
),
]
from pydoc import visiblename
from django.db import models
# Create your models here.
class Assignment(models.Model):
original_max_points = 0
assignment_name = models.CharField(max_length=100)
assignment_description = models.CharField(max_length=1000)
assignment_max_points = models.IntegerField()
assignment_max_points = models.IntegerField(default=0)
assignment_passing_score = models.IntegerField(editable=False)
assignment_course = models.ForeignKey('Course', on_delete=models.CASCADE, blank=True, null= True)
def __str__(self):
return self.assignment_name
def save(self, *args, **kwargs):
self.assignment_passing_score = int(self.assignment_max_points*60/100)
print("Passing score: " + str(self.assignment_passing_score)) #Debug
super(Assignment, self).save(*args,**kwargs)
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=100)
course_section = models.CharField(max_length=3)
def __str__(self):
return self.course_code
<p>
<h2>COURSE ASSIGNMENTS:</h2>
{% for assignment in assignments %}
<p><b>Assignment Name: {{assignment.assignment_name}}</b></p>
<p>Description: {{assignment.assignment_description}}</p>
<p>Perfect Score: {{assignment.assignment_max_points}}</p>
<p>Passing Score: {{assignment.assignment_passing_score}}</p>
<p>Course/Section: {{assignment.assignment_course.course_code}} {{assignment.assignment_course.course_title}} {{assignment.assignment_course.course_section}}</p>
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
from django.urls import path
from . import views
urlpatterns = [
......
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
# Create your views here.
def show_assignments_page(request):
return HttpResponse("This is the Assignments page!")
assignments = Assignment.objects.all()
return render(request, 'assignment_listing.html', {'assignments': assignments})
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