Commit 46151edc authored by Paul Angelo Sy's avatar Paul Angelo Sy

Converted Assignments to HTML Formatting

parent f092fc15
<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 ...@@ -3,5 +3,6 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name="assignments") path('', views.index, name="assignments"),
path("<str:name>/", views.detail, name = "details"),
] ]
from django.http import HttpResponse from django.http import HttpResponse
from assignments.models import Assignment, Course from assignments.models import Assignment, Course
from django.shortcuts import render
from django.template import loader
# Create your views here. # Create your views here.
def index(request): def index(request):
assignmentOutput = "Assignments: <br/><br/>" course_list = Course.objects.order_by("course_code")
for n in Assignment.objects.all(): assignment_list = Assignment.objects.all()
assignmentOutput += ("Assignment Name: " + str(n.name) + "<br/>") template = loader.get_template("assignments/index.html")
assignmentOutput += ("Description: " + n.description + "<br/>") context = {
assignmentOutput += ("Perfect Score: " + str(n.max_points) + "<br/>") "course_list": course_list,
assignmentOutput += ("Passing Score: " + str(n.passing_score) + "<br/>") "assignment_list": assignment_list
assignmentOutput += ("Course/Section: " + Course.objects.get(course_code = n.course_code).course_code + " ") }
assignmentOutput += (Course.objects.get(course_code = n.course_code).course_title + " ") return HttpResponse(template.render(context, request))
assignmentOutput += (Course.objects.get(course_code = n.course_code).section + "<br/><br/>")
return HttpResponse(assignmentOutput) 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