Commit e46ee65e authored by Rajo Christian Cadorna's avatar Rajo Christian Cadorna

Merge cadorna/assignments into master

parents 96f3f21d 67b8f287
<!DOCTYPE html>
<html lang="en">
<body>
<h1>Assignments:</h1>
{% for assignment in assignments %}
Assignment Name: {{assignment.name}} <br>
Description: {{assignment.description}} <br>
Perfect Score: {{assignment.max_points}} <br>
Passing Score: {{assignment.passing_score}} <br>
Course/Section: {{assignment.course.course_code}} | {{assignment.course.course_title}} | {{assignment.course.section}}
<br><br>
{% endfor %}
</body>
</html>
{% extends "assignments/base.html" %}
{% block content %}
<h3>{{assignment.course.course_code}} | {{assignment.course.course_title}} | {{assignment.course.section}}</h3>
<hr>
<img src= {{assignment.assignment_imageUrl}}>
<h2>{{assignment.name}}</h2>
Description: {{assignment.description}} <br>
Perfect Score: {{assignment.max_points}} <br>
Passing Score: {{assignment.passing_score}} <br>
{% endblock %}
{% extends "assignments/base.html" %}
{% block content %}
<h1>New Assignment</h1>
<hr>
<form action="./" method="post">
{% csrf_token %}
<label for="name">Name:</label><br>
<input type="text" name="name" id="name" style="width:400px"><br>
<label for="description">Description:</label><br>
<textarea name="description" id="description" style="width:400px; height:200px;"></textarea><br>
<label for="max_points">Max Points:</label><br>
<input type="number" name="max_points" id="max_points"><br>
<label for="course">Course:</label><br>
<select name="course" id="course">
{% for course in course_list %}
<option value="{{course}}">{{course.course_title}}</option>
{% endfor %}
</select><br>
<label for="Image">Image:</label><br>
<input type="text" name="assignment_imageUrl" id="assignment_imageUrl"><br><br>
<input type="submit" value="Submit">
</form>
<h5><a href ="{% url 'assignments/index'%}">Back to Assignments</h5>
{% endblock %}
{% extends "assignments/base.html" %}
{% block content %}
<h3>{{object.course.course_code}} | {{object.course.course_title}} | {{object.course.section}}</h3>
<hr>
<img src= {{object.assignment_imageUrl}}>
<h2>{{object.name}}</h2>
Description: {{object.description}} <br>
Perfect Score: {{object.max_points}} <br>
Passing Score: {{object.passing_score}} <br>
{% endblock %}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% static 'assignments/style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'assignments/style.css' %}">
<title></title> <title>{% block title %}Assignments{% endblock %}</title>
</head> </head>
<body> <body>
{% block content %} {% block content %}
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<ul> <ul>
{% for assignment in assignments %} {% for assignment in assignments %}
{% if assignment.course.course_code == course.course_code %} {% if assignment.course.course_code == course.course_code %}
<li><a href ="{% url 'assignment' assignment.id%}">{{assignment.name}}</a></li> <li><a href ="{% url 'assignment-detail' assignment.id%}">{{assignment.name}}</a></li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
...@@ -19,5 +19,6 @@ ...@@ -19,5 +19,6 @@
{% else %} {% else %}
<p>No courses currently enrolled.</p> <p>No courses currently enrolled.</p>
{% endif %} {% endif %}
<h5><a href ="{% url 'assignment-add'%}">Create New Assignment</h5>
{% endblock %} {% endblock %}
from django.urls import path from django.urls import path
from . import views from .views import HomePageView, AssignmentDetailView
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('', HomePageView.as_view(), name='assignments/index'),
path("<int:assignment_id>/details/", views.assignments, name='assignment') path('assignment/<int:pk>/details/', AssignmentDetailView.as_view(), name='assignment-detail')
] ]
from django.http import HttpResponse from django.http import HttpResponse
from . models import Assignment, Course from . models import Assignment, Course
from django.shortcuts import render from django.shortcuts import render
from django.views import View
from django.views.generic.detail import DetailView
# Create your views here. # Create your views here.
def index(request): class HomePageView(View):
Assignments = Assignment.objects.all() def get(self, request):
Courses = Course.objects.all() assignments = Assignment.objects.all()
course_list = Course.objects.order_by("course_code") course_list = Course.objects.order_by("course_code")
context ={ context ={
'assignments':Assignments, 'assignments':assignments,
'courses':Courses,
'course_list':course_list 'course_list':course_list
} }
return render(request, "assignments/view.html", context) return render(request, "assignments/index.html", context)
def assignments(request, assignment_id): class AssignmentDetailView(DetailView):
course_list = Course.objects.order_by("course_code") model = Assignment
try:
assignment = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist")
return render(request, "assignments/assignment.html",{"assignment": assignment, 'course_list':course_list})
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