Fixed main assignments page and added assignments details

parent 3b3966f1
......@@ -27,16 +27,6 @@ class Assignment(models.Model):
@property
def passing_score(self):
return self.max_points * 0.60
@property
def assignment_info(self):
assignment = '<br>Assignment Name: {}'.format(self.name)
assignment += '<br>Description: {}'.format(self.description)
assignment += '<br>Perfect Score: {}'.format(self.max_points)
assignment += '<br>Passing Score: {}'.format(self.passing_score)
assignment += '<br>Course/Section: {}<br>'.format(self.course.course_info)
return assignment
def __str__(self):
return '{} - {}'.format(self.name, self.course.course_shorthand)
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block styles &}
<link rel="stylesheet" href="{% static 'assignments_stylesheet.css' %}">
{& endblock &}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/assignments_stylesheet.css' %}">
{% endblock %}
{& block header &}Assignments Per Course{& endblock %}
{% block app_header %}Assignments Per Course{% endblock %}
{& block body &}
This is {{ course_code }}
{% endblock &}
\ No newline at end of file
{% block content %}
<ul>
{% for c in course_list %}
<li><p class="course_section">{{ c.course_code }} {{ c.course_title }} {{ c.section }}</p>
<ul class="course_assignments">
{% for a in assignment_list %}
{% if a.course.course_code == c.course_code %}
{% if a.course.section == c.section %}
<li><a href="{% url 'assignments:assignment-detail' pk=a.pk %}">{{ a.name }}</a></li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/assignments_stylesheet.css' %}">
{% endblock %}
{% block content %}
<p class="course">{{ object.course.course_code }} {{ object.course.course_title }} {{ object.course.section }}</p>
<p class="title">{{ object.name }}</p>
<p class="desc">{{ object.description }}</p>
<p class="score">Perfect Score: {{ object.max_points }}</p>
<p class="score">Passing Score: {{ object.passing_score }}</p>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import AssignmentsPageView, AssignmentDetailView
urlpatterns = [
path('', index, name="index"),
path('', AssignmentsPageView.as_view(), name='index'),
path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-detail'),
]
app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
from django.views.generic.detail import DetailView
from .models import Assignment
from .models import Assignment, Course
# Create your views here.
def index(request):
def assignment_list():
final_list = ''
for a in range(len(Assignment.objects.all())):
final_list += '{}'.format(Assignment.objects.get(pk=a+1).assignment_info)
return final_list
class AssignmentsPageView(View):
def get(self, request):
return render(request, 'assignments/assignment.html', {
'course_list': Course.objects.all(),
'assignment_list': Assignment.objects.all()
})
html = f'''
<html>
<body>
<header><h1>ASSIGNMENTS:</h1><header>
<main>
<p>{assignment_list()}</p>
</main>
</body>
</html>
'''
return render(request, 'assignments/assignment.html', {'course_code': 'CSCI 40'})
\ No newline at end of file
class AssignmentDetailView(DetailView):
model = Assignment
\ No newline at end of file
No preview for this file type
body {
font-family: Tahoma, sans-serif;
}
header {
font-size: 25px;
font-weight: bold;
}
.course_section {
font-weight: bold;
}
.course, .title {
font-weight: bold;
}
\ 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