Commit 7318a5e8 authored by justin's avatar justin

Fixed formatting and variable names, fixed import in models.py

parent 1dfeae68
from django.db import models from django.db import models
# Create your models here.
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 = 50) title = models.CharField(max_length=50)
section = models.CharField(max_length = 3) section = models.CharField(max_length=3)
def __str__(self): def __str__(self):
return self.code return self.code
class Assignment(models.Model): class Assignment(models.Model):
name = models.CharField(max_length = 100) name = models.CharField(max_length=100)
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(default = 0) perfect_score = models.IntegerField(default=0)
@property @property
def passing_score(self): def passing_score(self):
if (self.perfect_score != None): if self.perfect_score != None:
return self.perfect_score * 0.60 return self.perfect_score * 0.60
def __str__(self): def __str__(self):
......
from django.shortcuts import HttpResponse from django.http import HttpResponse
from .models import Assignment, Course from .models import Assignment, Course
# Create your views here.
def assign(request):
def assignments(request):
assignments = Assignment.objects.all() assignments = Assignment.objects.all()
response = "Widget's Assignments Page <br><br>" response = "Widget's Assignments Page <br><br>"
for assignment in assignments: for assignment in assignments:
AName = "Asssignment Name: " + assignment.name + "<br>" name = "Asssignment Name: " + assignment.name + "<br>"
ADesc = "Description: " + assignment.description + "<br>" desc = "Description: " + assignment.description + "<br>"
APeScore = "Perfect Score: " + str(assignment.perfect_score) + "<br>" perfect = "Perfect Score: " + str(assignment.perfect_score) + "<br>"
APaScore = "Passing Score: " + str(assignment.passing_score) +"<br>" passing = "Passing Score: " + str(assignment.passing_score) + "<br>"
Coursec = "Course/Section: " + assignment.course.code + " " + assignment.course.title + "-" + assignment.course.section courseSection = (
"Course/Section: "
+ assignment.course.code
+ " "
+ assignment.course.title
+ "-"
+ assignment.course.section
)
response += AName + ADesc + APeScore + APaScore + Coursec +"<br><br>" response += name + desc + perfect + passing + courseSection + "<br><br>"
return HttpResponse(response) return HttpResponse(response)
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