Commit c9fbd818 authored by Brescia Amandy's avatar Brescia Amandy

Edited Assignment page view to display assignment details

parent 8d03446f
...@@ -4,7 +4,7 @@ from django.db import models ...@@ -4,7 +4,7 @@ from django.db import models
class Course(models.Model): class Course(models.Model):
code = models.CharField(max_length=10) code = models.CharField(max_length=10)
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
section = models.CharField(max_length=3, blank=True) section = models.CharField(max_length=3)
def __str__(self): def __str__(self):
return self.code return self.code
...@@ -13,7 +13,7 @@ class Assignment(models.Model): ...@@ -13,7 +13,7 @@ class Assignment(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
description = models.TextField(blank=True) description = models.TextField(blank=True)
course = models.ForeignKey(Course, on_delete=models.CASCADE) course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.IntegerField(blank=True, default=0) perfect_score = models.IntegerField(default=0)
@property @property
def passing_score(self): def passing_score(self):
......
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Assignment, Course
def assignments(request): def assignments(request):
return HttpResponse('Hello World! This came from the index view') return_string = "Widget's Assignments Page<br><br>"
for assignment, course in zip(Assignment.objects.all(), Course.objects.all()):
return_string += 'Assignment: {}<br>'.format(assignment.name)
return_string += 'Description: {}<br>'.format(assignment.description)
return_string += 'Perfect Score: {}<br>'.format(assignment.perfect_score)
return_string += 'Passing Score: {}<br>'.format(assignment.passing_score)
return_string += 'Course/Section: {} {}-{}'.format(course.code, course.title, course.section)
return HttpResponse(return_string)
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