Commit db3358f3 authored by Katrina Bernice Tan's avatar Katrina Bernice Tan

Merge branch 'tan/assignments' into 'master'

Added templates for Assignments

See merge request !16
parents f25eabb6 62ef8c1a
File deleted
*{
border: 0;
margin: 0;
color: #624741;
}
body {
font-family: 'Inter', sans-serif;
background-color: #F9F5F0;
}
#header h1 {
color: #F9F5F0;
padding: 1em;
text-align: right;
font-size: 15px;
font-weight: 300;
background-color: #624741
}
#courses h1{
padding: 1.2em 1em;
color: #624741;
font-size: 70px;
font-family: 'Inter', sans-serif;
}
ul{
padding: 0;
}
li {
list-style-position: inside;
padding-top: 14px;
}
.block{
padding: 1em;
border: 0.5px;
border-style: solid;
}
.block h2{
padding: 0.2em;
border-bottom: 1px #624741;
border-style: solid;
font-size: 24px;
}
.wrapper{
display:grid;
grid-template-columns:repeat(3, 1fr);
grid-auto-rows: minimax(100px, auto);
}
a:hover{
color: #e89a64;
}
#details{
padding: 5em;
}
#details h5{
font-size: 20px;
font-weight: 500;
}
#details h3{
font-size: 80px;
padding-bottom: 2em;
}
#details h4{
font-size: 20px;
font-weight: 500;
}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block styles %} <link rel = "stylesheet" href="{% static 'css/index.css' %}"> {% endblock %}
{% block title %} {{object.course}} {% endblock title%}
{% block content %}
<div id = "header">
<h1> Course: {{object.course}} </h1>
</div>
<div id = "details">
<img src="{%static 'images/jokebear.png'%}">
<h5> Assignment Name: </h5>
<h3>{{object.name}} </h3>
<h4> <b>Assignment Description:</b> {{object.description}} </h4>
<h4> <b>Perfect Score:</b> {{object.max_points}} </h4>
<h4> <b>Passing Score:</b> {{object.passing_score}} </h4>
{%endblock content%}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{ % block styles %}
{ % endblock styles %}
{% block title %} Assignments {% endblock title%}
{% block content %}
<div id = "header">
</div>
<div id = "courses">
<ul>
<div class = "wrapper">
{% for a in assignments %}
<div class = "block">
<h2> {{a.course}} </h2>
<li>
<a href="/assignment/{{ a.pk }}/details"> {{a.name}} </a>
</li>
</div>
{%endfor%}
</div>
</ul>
</div>
{%endblock content%}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link rel = "stylesheet" href="{% static 'css/index.css' %}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@200;500;900&display=swap" rel="stylesheet">
{% endblock %}
{% block title %} Assignments {% endblock title%}
{% block content %}
<div id = "header">
<h1> Assignments per course </h1>
</div>
<div id = "courses">
<h1> List of courses: </h1>
</div>
{% include "Assignments/assignment_list.html" with assignments=assignment %}
{%endblock content%}
\ No newline at end of file
from django.urls import path
from . import views
from .views import MainView, AssignmentListView, AssignmentDetailView
urlpatterns = [
path('', views.index, name='index')
path('', MainView.as_view(), name='assignments'),
path('assignments', AssignmentListView.as_view(), name='assignment-list'),
]
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 django.views.generic.list import ListView
from .models import Assignment, Course
def index(request):
class MainView(View):
def get(self, request):
course = Course.objects.all().order_by('course_code')
assignment = Assignment.objects.all().order_by('course')
return render(request, 'assignments.html',{
'course': course,
'assignment': assignment,
})
print = "ASSIGNMENTS: "
assignments = Assignment.objects.all()
for i in assignments:
print += f"<br /> Assignment name: {i.name} <br /> Description: {i.description} <br /> Perfect score: {i.max_points} <br /> Passing score: {i.passing_score} <br /> Course/Section: {i.course} <br />"
return HttpResponse(print)
class AssignmentListView(ListView):
model = Assignment
class AssignmentDetailView(DetailView):
model = Assignment
......@@ -17,6 +17,7 @@ from django.contrib import admin
from django.urls import path, include
import Announcements.views as Announcements_views
import Forum.views as Forum_views
from Assignments.views import AssignmentDetailView
urlpatterns = [
path('admin/', admin.site.urls),
......@@ -26,4 +27,7 @@ urlpatterns = [
path('announcements/', include('Announcements.urls', namespace="Announcements")),
path('announcements/<int:announcement_id>/details', Announcements_views.details, name='announcement_details'),
path('assignments/', include('Assignments.urls', namespace="Assignments")),
path('assignment/<int:pk>/details', AssignmentDetailView.as_view(), name ='assignment-detail'),
]
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