Add template and urls for assignments app

parent a7b37d69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Assignments</title>
</head>
<body>
<h1>Assignments Per Course</h1>
<h2>List of Courses:</h3>
{% if assignment_list %}
<ul>
{% for course in course_list %}
<li>{{course.course_code}} | {{course.course_title}} - {{course.section}}</li>
{% for assignment in assignment_list %}
{% if assignment.course.course_code == course.course_code %}
<ul>
<li><a href="/assignments/{{assignment.id}}/details">{{assignment.name}}</a></li>
</ul>
{% endif %}
{% endfor %}
<br>
{% endfor %}
</ul>
{% else %}
<p>There are no assignments under any course.</p>
{% endif %}
</body>
</html>
\ No newline at end of file
...@@ -3,5 +3,6 @@ from django.urls import path ...@@ -3,5 +3,6 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name="indexAssignments") path('', views.index, name="indexAssignments"),
path('<int:assignment_id>/details', views.detail, name="detail")
] ]
\ No newline at end of file
from ast import Assign
from django.http import HttpResponse from django.http import HttpResponse
from .models import Assignment from django.shortcuts import render
from .models import Assignment, Course
# Create your views here. # Create your views here.
def index(request): def index(request):
display_output = "<u><b>ASSIGNMENTS</u></b>: <br>" course_list = Course.objects.order_by("course_code")
assignment_list = Assignment.objects.order_by("name")
for object in Assignment.objects.all(): context = {
display_output += ''' "assignment_list": assignment_list,
Assignment Name: <b>{name}</b><br> "course_list": course_list,
Description: {description}<br> }
Perfect Score: {max_points}<br>
Passing Score: {passing_score}<br> return render(request, "assignments/index.html", context)
Course/Section: {course_code} | {course_title} - {section}<br><br>
'''.format(name = object.name,
description = object.description,
max_points = object.max_points,
passing_score = object.passing_score,
course_code = object.course.course_code,
course_title = object.course.course_title,
section = object.course.section)
return HttpResponse(display_output) def detail(request, assignment_id):
output = "These are the details for assignment #%s." % assignment_id
return HttpResponse(output)
\ No newline at end of file
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