Commit e02b3d58 authored by Joerell Frank Yee Lao's avatar Joerell Frank Yee Lao

Added the codes needed to include passing score in the assignment model. Added...

Added the codes needed to include passing score in the assignment model. Added the codes needed for views.py
parent dfc9bdd1
# Generated by Django 3.2.12 on 2022-04-05 06:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0005_assignment_course'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=0),
),
]
from django.db import models
# Create your models here.
class Course(models.Model):
course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=500)
section = models.CharField(max_length=3)
def __str__(self):
return self.course_title
class Assignment(models.Model):
course = models.ForeignKey(Course, on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=50)
description = models.CharField(max_length=500)
max_points = models.IntegerField(default=0)
passing_score = models.IntegerField(default=0)
def __str__(self):
return self.name
from django.http import HttpResponse
from django.shortcuts import render
from .models import Course, Assignment
# Create your views here.
def index(request):
return HttpResponse("This is the Assignments page!")
message = 'ASSIGNMENTS:<br/>'
course = Course.objects.all()
assignment = Assignment.objects.all()
for i in course:
for j in assignment:
if i.course_code == j.course.course_code:
j.passing_score = j.max_points*0.6
j.save()
message += f'Assignment Name: {j.name} <br/> Decription: {j.description} <br/> Perfect Score: {j.max_points} <br/> Passing Score: {j.passing_score} <br/>'
message += f'Course/Section: {i.course_code} {i.course_title} {i.section} <br/>'
message += '<br/>'
return HttpResponse(message)
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