Commit 9262b0ec authored by kylemendozaa's avatar kylemendozaa

updated assignments view

parent 5224c323
# Generated by Django 4.0.3 on 2022-04-05 15:09
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_course_assignment_passing_score_and_more'),
]
operations = [
migrations.RenameField(
model_name='course',
old_name='course_section',
new_name='section',
),
]
...@@ -3,7 +3,7 @@ from django.db import models ...@@ -3,7 +3,7 @@ from django.db import models
class Course(models.Model): class Course(models.Model):
course_code = models.CharField(max_length=10) course_code = models.CharField(max_length=10)
course_title = models.CharField(max_length=50) course_title = models.CharField(max_length=50)
course_section = models.CharField(max_length=3) section = models.CharField(max_length=3)
class Assignment(models.Model): class Assignment(models.Model):
name = models.CharField(max_length=30) name = models.CharField(max_length=30)
...@@ -15,3 +15,14 @@ class Assignment(models.Model): ...@@ -15,3 +15,14 @@ class Assignment(models.Model):
def save(self): def save(self):
self.passing_score = int(0.6*self.max_points) self.passing_score = int(0.6*self.max_points)
super(Assignment, self).save() super(Assignment, self).save()
def getAssignment(self):
return 'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {} {}<br>'.format(
self.name,
self.description,
self.max_points,
self.passing_score,
self.course.course_code,
self.course.course_title,
self.course.section,
)
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Assignment
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse("This is the Assignments page!") formatted_assignments = "ASSIGNMENTS:<br>"
for assignment in Assignment.objects.all():
formatted_assignments += assignment.getAssignment() + "<br>"
return HttpResponse(formatted_assignments)
No preview for this file type
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