Commit 9b8480f2 authored by justin's avatar justin

Merge remote-tracking branch 'origin/assignment_wip'

parents 1e4cf00e cd4ff487
from django.contrib import admin
from .models import Assignment, Course
# Register your models here.
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
list_display = ("name", "description", "course", "perfect_score", "passing_score")
class CourseAdmin(admin.ModelAdmin):
model = Course
list_display = ("code", "title", "section")
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(Course, CourseAdmin)
\ No newline at end of file
from django.db import models
# Create your models here.
class Course(models.Model):
code = models.CharField(max_length=10)
title = models.CharField(max_length=50)
section = models.CharField(max_length=3)
def __str__(self):
return self.code
class Assignment(models.Model):
name = models.CharField(max_length=100)
description = models.TextField(blank=True)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.IntegerField(default=0)
@property
def passing_score(self):
if self.perfect_score != None:
return self.perfect_score * 0.60
def __str__(self):
return self.name
from django.urls import path
from . import views
urlpatterns = [
path("", views.assignments, name="assignments"),
]
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
# Create your views here.
def assignments(request):
assignments = Assignment.objects.all()
response = "Widget's Assignments Page <br><br>"
for assignment in assignments:
name = "Asssignment Name: " + assignment.name + "<br>"
desc = "Description: " + assignment.description + "<br>"
perfect = "Perfect Score: " + str(assignment.perfect_score) + "<br>"
passing = "Passing Score: " + str(assignment.passing_score) + "<br>"
courseSection = (
"Course/Section: "
+ assignment.course.code
+ " "
+ assignment.course.title
+ "-"
+ assignment.course.section
)
response += name + desc + perfect + passing + courseSection + "<br><br>"
return HttpResponse(response)
......@@ -21,4 +21,5 @@ urlpatterns = [
path("dashboard/", include("dashboard.urls")),
path("calendar/", include("calendar_app.urls", namespace="calendar_app")),
path("forum/", include("forum.urls")),
path("assignments/", include("assignments.urls")),
]
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