Commit a69ffe15 authored by Paul Angelo Sy's avatar Paul Angelo Sy

Converted Assignments to HTML formatting

parents 800c4172 46151edc
<h1> Assignments Per Course </h1>
{% if course_list %}
{% for course in course_list %}
<li> {{course}} {{course.course_title}} {{course.section}}
{% for assignment in assignment_list %}
{% if assignment.course_code == course %}
<ul>
<li> <a href="/assignments/{{assignment.name}}/">{{assignment.name}}</a></li>
</ul>
{% endif %}
{% endfor %}
</li>
{% endfor %}
{% else %}
<p>No assignments are available </p>
{% endif %}
......@@ -3,5 +3,6 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name="assignments")
path('', views.index, name="assignments"),
path("<str:name>/", views.detail, name = "details"),
]
from django.http import HttpResponse
from assignments.models import Assignment, Course
from django.shortcuts import render
from django.template import loader
# Create your views here.
def index(request):
assignmentOutput = "Assignments: <br/><br/>"
for n in Assignment.objects.all():
assignmentOutput += ("Assignment Name: " + str(n.name) + "<br/>")
assignmentOutput += ("Description: " + n.description + "<br/>")
assignmentOutput += ("Perfect Score: " + str(n.max_points) + "<br/>")
assignmentOutput += ("Passing Score: " + str(n.passing_score) + "<br/>")
assignmentOutput += ("Course/Section: " + Course.objects.get(course_code = n.course_code).course_code + " ")
assignmentOutput += (Course.objects.get(course_code = n.course_code).course_title + " ")
assignmentOutput += (Course.objects.get(course_code = n.course_code).section + "<br/><br/>")
return HttpResponse(assignmentOutput)
course_list = Course.objects.order_by("course_code")
assignment_list = Assignment.objects.all()
template = loader.get_template("assignments/index.html")
context = {
"course_list": course_list,
"assignment_list": assignment_list
}
return HttpResponse(template.render(context, request))
def detail(request, name):
output = (str(Assignment.objects.get(name = name).course_code) + " ")
output += (str(Course.objects.get(course_code = Assignment.objects.get(name = name).course_code).course_title) + " ")
output += (str(Course.objects.get(course_code = Assignment.objects.get(name = name).course_code).section) + " ")
return HttpResponse(output)
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