Commit 31f51df3 authored by Ciella's avatar Ciella

Merge branch 'assignmentsv2'

parents e04995f1 2dfd98ab
from django.db import models from django.db import models
from django.urls import reverse
# Create your models here. # Create your models here.
class Course(models.Model): class Course(models.Model):
...@@ -6,8 +7,11 @@ class Course(models.Model): ...@@ -6,8 +7,11 @@ class Course(models.Model):
title = models.CharField(max_length=255) title = models.CharField(max_length=255)
section = models.CharField(max_length=3) section = models.CharField(max_length=3)
def format_course(self):
return '{} {} - {}'.format(self.code, self.title, self.section)
def __str__(self): def __str__(self):
return '{} {}'.format(self.code, self.section) return '{}-{}'.format(self.code, self.section)
class Assignment(models.Model): class Assignment(models.Model):
...@@ -21,5 +25,11 @@ class Assignment(models.Model): ...@@ -21,5 +25,11 @@ class Assignment(models.Model):
self.passing_score = int((self.perfect_score)*(0.60)) self.passing_score = int((self.perfect_score)*(0.60))
super(Assignment, self).save(*args, **kwargs) super(Assignment, self).save(*args, **kwargs)
def format_assignment(self):
return '{}'.format(self.name)
def __str__(self): def __str__(self):
return '{} {}: {}'.format(self.course.code, self.course.section, self.name) return '{} {}: {}'.format(self.course.code, self.course.section, self.name)
\ No newline at end of file
def get_absolute_url(self):
return reverse('assignments:assignment-details', kwargs={'pk': self.pk})
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}
Add Assignment
{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br><br>
<img src="{% static 'assignments_icon.png'%}" class="img-fluid" width="100" height="100">
<br><br>
<h2>Assignments</h2>
<h4 class="display-6" style="font-size:20px">Add New Assignment</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">Add a new assignment:</h1>
</div>
<br>
<div class="row"></div>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="row">
<div class="col-5" style="text-align:right">
<h5 class="display-3" style="font-size:25px">{{ field.label }}:</h4>
</div>
<div class="col-7" style="text-align:left">
{{ field }}
</div>
</div>
<br>
{% endfor %}
<input type="submit" class="btn btn-dark" value="Save New Assignment" style="background-color:#052c65">
</form>
<br><br>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}
{{ object }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br>
<br>
<img src="{% static 'assignments_icon.png'%}" class="img-fluid" width="100" height="100">
<br>
<br>
<h2>Assignments</h2>
<h4 class="display-6" style="font-size:20px">Assignment Details</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">{{ object.name }}</h1>
</div>
<br>
<div class="row p-2" style="background-color:#e3e4e6">
<h5 class="display-3" style="font-size:25px">{{ object.course.format_course }}</h5>
</div>
<br>
<div class="row">
<div class="col-5" style="text-align:right">
<h4 style="font-size:25px">Description: </h4>
</div>
<div class="col-7" style="text-align:left">
<h5 class="display-3" style="font-size:25px">{{ object.description }}</h5>
</div>
</div>
<div class="row">
<div class="col-5" style="text-align:right">
<h4 style="font-size:25px">Perfect Score: </h4>
<h4 style="font-size:25px">Passing Score: </h4>
</div>
<div class="col-7" style="text-align:left">
<h5 class="display-3" style="font-size:25px">{{ object.perfect_score }}</h5>
<h5 class="display-3" style="font-size:25px">{{ object.passing_score }}</h5>
</div>
</div>
<br><br>
<button type="button" class="btn" style="background-color:#e3e4e6">
<a href="/assignments/{{object.pk}}/edit" class="link-dark">Edit Assignment</a>
</button> &nbsp; &nbsp;
<button type="button" class="btn" style="background-color:#052c65">
<a href="/assignments/" class="link-light">[Temp] Back to Calendar</a>
</button>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}
Edit Assignment
{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br><br>
<img src="{% static 'assignments_icon.png'%}" class="img-fluid" width="100" height="100">
<br><br>
<h2>Assignments</h2>
<h4 class="display-6" style="font-size:20px">Edit Assignment</h4>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3" style="font-size:50px; color:#052c65">Edit Assignment</h1>
</div>
<br>
<div class="row"></div>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="row">
<div class="col-5" style="text-align:right">
<h5 class="display-3" style="font-size:25px">{{ field.label }}:</h4>
</div>
<div class="col-7" style="text-align:left">
{{ field }}
</div>
</div>
<br>
{% endfor %}
<input type="submit" class="btn btn-dark" value="Save Changes to Assignment" style="background-color:#052c65">
</form>
<br><br>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}
Widget's Assignments
{% endblock %}
{% block content %}
<div class="row">
<div class="col-3 text-center text-white" style="background-color:#052c65">
<br><br>
<img src="{% static 'assignments_icon.png'%}" class="img-fluid" width="100" height="100">
<br><br>
<h2>Assignments</h2>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p>© Jenica e-Sports</p>
</div>
<div class="col-9 text-center">
<div class="row p-5 text-center" style="background-color:#e3e4e6">
<h1 class="display-3"style="font-size:60px; color:#052c65">Widget's Assignments</h1>
</div>
<br>
<br>
{% for task in tasks %}
<a href="{{ task.get_absolute_url }}" class="link-dark; display-3" style="font-size:18px; color:#052c65">
{{ task.format_assignment }}</a>
<br>
{% endfor %}
<br><br>
<button type="button" class="btn" style="background-color:#e3e4e6">
<a href="/assignments/add/" class="link-dark">New Assignment</a>
</button>
<br>
<br>
<br>
<div class="text-center">
<button type="button" class="btn" style="background-color:#052c65">
<a href="/dashboard/" class="link-light">Dashboard</a>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#334277">
<a href="/announcements/" class="link-light">Announcements</a>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#425086">
<a href="/forum/" class="link-light">Forum</a>
</button> &nbsp;
<button type="button" class="btn" style="background-color:#515e96">
<a href="/calendar/" class="link-light">Calendar</a>
</button>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import assignments_view, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', assignments_view, name='assignments'),
path('<int:pk>/details/', AssignmentDetailView.as_view(), name='assignment-details'),
path('add/', AssignmentCreateView.as_view(), name='assignment-add'),
path('<int:pk>/edit/', AssignmentUpdateView.as_view(), name='assignment-edit'),
] ]
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.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment from .models import Assignment
# Create your views here.
def index(request):
return_string = '<p>Widget\'s Assignments Page<br>'
for work in Assignment.objects.all(): def assignments_view(request):
work_string = '<br>Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {}-{}<br>'.format( tasks = Assignment.objects.all()
work.name, work.description, work.perfect_score, work.passing_score, work.course.code, work.course.title, work.course.section) context = {'tasks' : tasks}
return_string += work_string return render(request, 'assignments/assignments.html', context)
return_string += '</p>'
html_string = '<html><body>{}</body></html>'.format(return_string) class AssignmentDetailView(DetailView):
model = Assignment
return HttpResponse(html_string) template_name = 'assignments/assignment-details.html'
\ No newline at end of file
class AssignmentCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-add.html'
class AssignmentUpdateView(UpdateView):
model = Assignment
fields = '__all__'
template_name = 'assignments/assignment-edit.html'
\ 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