Commit 1cc16eb5 authored by Joan Denise Nocos's avatar Joan Denise Nocos

feat: added index and details templates to assignments app

parent 75ba0626
{% extends "base.html" %}
{% block page-title %}Assignment {{ assignment_id }} Details{% endblock %}
{% block content %}
<h1>{{ course.course_code }} {{ course.course_title }} {{ course.section }}</h1>
<p>{{ assignment.name }}</p>
<p>{{ assignment.description }}</p>
<p>{{ assignment.max_points }}</p>
<p>{{ assignment.passing_score }}</p>
<p>Image Placeholder</p>
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% block page-title %}Assignments{% endblock %}
{% block content %}
<h1>Assignments Per Course</h1>
<h2>List of Courses:</h2>
{% if course_list %}
<ul>
{% for course in course_list %}
<p>{{ course.course_code }} {{ course.course_title }} {{ course.section }}</p>
<ul>
{% for assignment in assignment_list %}
{% if assignment.course == course.id %}
<li><a href="{% url 'assignments:details' assignment.id %}">{{ assignment.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
</ul>
{% else %}
<p>No course available.</p>
{% endif %}
{% endblock %}
......@@ -2,6 +2,7 @@ from django.urls import path
from . import views
app_name = "assignments"
urlpatterns = [
# assignments/
path('', views.index, name='index'),
......
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from django.shortcuts import render
from assignments.models import Assignment, Course
# Create your views here.
def index(request):
assignments_view = "ASSIGNMENTS: <br>"
schoolwork = Assignment.objects.all()
for assignment in schoolwork:
score = assignment.max_points
assignment.passing_score = (score*60) // 100
assignments_view += "Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {} {}<br><br>".\
format(assignment.name,
assignment.description,
assignment.max_points,
assignment.passing_score,
assignment.course.course_code,
assignment.course.course_title,
assignment.course.section)
return HttpResponse(assignments_view)
course_list = Course.objects.order_by("course_code")
assignment_list = Assignment.objects.all()
context = {
"course_list" : course_list,
"assignment_list" : assignment_list,
}
return render(request, "assignments/index.html", context)
def details(request, assignment_id):
response = "Assignment ID: %s."
return HttpResponse(response % assignment_id)
\ No newline at end of file
try:
assignment = Article.objects.get(pk=assignment_id)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
context = {
"assignment" : assignment,
"course" : assignment.course,
}
return render(request, "assignments/details.html", context)
\ 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