Fixed main assignments page and added assignments details

parent 3b3966f1
...@@ -27,16 +27,6 @@ class Assignment(models.Model): ...@@ -27,16 +27,6 @@ class Assignment(models.Model):
@property @property
def passing_score(self): def passing_score(self):
return self.max_points * 0.60 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): def __str__(self):
return '{} - {}'.format(self.name, self.course.course_shorthand) return '{} - {}'.format(self.name, self.course.course_shorthand)
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block styles &} {% block styles %}
<link rel="stylesheet" href="{% static 'assignments_stylesheet.css' %}"> <link rel="stylesheet" href="{% static 'css/assignments_stylesheet.css' %}">
{& endblock &} {% endblock %}
{& block header &}Assignments Per Course{& endblock %} {% block app_header %}Assignments Per Course{% endblock %}
{& block body &} {% block content %}
This is {{ course_code }} <ul>
{% endblock &} {% for c in course_list %}
\ No newline at end of file <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 django.urls import path
from .views import index from .views import AssignmentsPageView, AssignmentDetailView
urlpatterns = [ urlpatterns = [
path('', index, name="index"), path('', AssignmentsPageView.as_view(), name='index'),
path('<int:pk>/details', AssignmentDetailView.as_view(), name='assignment-detail'),
] ]
app_name = "assignments" app_name = "assignments"
\ No newline at end of file
from django.shortcuts import render 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. # Create your views here.
def index(request): class AssignmentsPageView(View):
def assignment_list(): def get(self, request):
final_list = '' return render(request, 'assignments/assignment.html', {
for a in range(len(Assignment.objects.all())): 'course_list': Course.objects.all(),
final_list += '{}'.format(Assignment.objects.get(pk=a+1).assignment_info) 'assignment_list': Assignment.objects.all()
})
return final_list
html = f''' class AssignmentDetailView(DetailView):
<html> model = Assignment
<body> \ No newline at end of file
<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
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