Commit 5dbd99c4 authored by Jose Leonardo J. Sacamos III's avatar Jose Leonardo J. Sacamos III

Merge branch 'sacamos/assignments'

parents 2e73b8d0 a279403b
# Generated by Django 4.0.3 on 2022-05-22 08:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0004_remove_assignment_passing_score'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='hw_picture',
field=models.ImageField(default='default.jpg', upload_to='assignments'),
),
]
# Generated by Django 4.0.3 on 2022-05-22 08:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('assignments', '0005_assignment_hw_picture'),
]
operations = [
migrations.RenameField(
model_name='assignment',
old_name='hw_picture',
new_name='hwPicture',
),
]
...@@ -19,10 +19,12 @@ class Assignment(models.Model): ...@@ -19,10 +19,12 @@ class Assignment(models.Model):
description = models.CharField(max_length=1000) description = models.CharField(max_length=1000)
max_points = models.IntegerField(default=0) max_points = models.IntegerField(default=0)
course = models.ForeignKey(Course,on_delete=models.CASCADE,default=None,null=True,blank=True) course = models.ForeignKey(Course,on_delete=models.CASCADE,default=None,null=True,blank=True)
hwPicture = models.ImageField(upload_to="assignments", default="default.jpg")
def passing_score(self): def passing_score(self):
return int(self.max_points*0.6) return int(self.max_points*0.6)
def __str__(self): def __str__(self):
return '{}'.format(self.name) return '{}'.format(self.name)
h1 {
text-align: center;
color:rgb(3, 4, 94);
text-shadow:2px 2px 5px rgb(101, 15, 158);
font-family: "Brush Script MT", "Brush Script Std", cursive;
font-size: 50px;
}
h2 {
color:rgb(0, 94, 216);
font-size: 20px;
font-family: "Arial Narrow", sans-serif;
}
body {
background-color: rgb(202, 240, 248);
}
p {
color:rgb(0, 180, 216);
font-size: 25px;
font-family: "New Century Schoolbook", "TeX Gyre Schola", serif;
}
a {
color:rgb(0, 119, 182);
font-size: 20px;
font-family: "Arial Narrow", sans-serif;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Assignment no. {{ assignment_id }}{% endblock %}
{% block content %}
<p>Course Code, Title, and Section: {{ taskWork.course.course_code }}, {{ taskWork.course.course_title }}, - Section: {{ taskWork.course.section }}
<br/>
<br />Assignment Name: {{ taskWork.name }}
<br />Assignment Description: {{ taskWork.description }}
<br />Perfect Score: {{ taskWork.max_points }}
<br />Passing Score: {{ taskWork.passing_score }}
{% load static %}
<br /><br /><br /><img src="{{ taskWork.hwPicture.url }}" alt="{{taskWork.name}}" style="width:50%">
</p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Assignments{% endblock %}
{% block content %}
<h1>Assignments Per Course.</h1>
<p>List of Courses:</p>
{% if assignmentList %}
<ul>
{% for taskWork in assignmentList %}
<li>{{ taskWork.course.course_code }}, {{ taskWork.course.course_title }}, - Section: {{ taskWork.course.section }}</li>
<ul>
<li><a href="{{ taskWork.id }}/details/">{{ taskWork.name }}</a></li>
</ul>
{% endfor %}
</ul>
{% else %}
<p>No users are available</p>
{% endif %}
{% endblock %}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=device-width, initial-scale-1.0">
<link rel="stylesheet" href="{% static 'assignments/style.css' %}">
<title>{% block title %}Woah a page{% endblock %}</title>
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
\ No newline at end of file
...@@ -3,5 +3,7 @@ from django.urls import path ...@@ -3,5 +3,7 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='announcementIndex') path('', views.index, name='announcementIndex'),
# assignments/1/details
path("<int:assignment_id>/details/", views.details, name="details")
] ]
\ No newline at end of file
from django.http import HttpResponse from django.http import HttpResponse, Http404
from django.shortcuts import render
from .models import Course, Assignment from .models import Course, Assignment
assignmentList = Assignment.objects.all() assignmentList = Assignment.objects.order_by("course")
displayText = "Assignments: "
for i in assignmentList: # Create your views here.
eachAssignment = '<br />Assignment Name: {}<br />Description: {}<br />Perfect Score: {}<br />Passing Score: {}<br />Course/Section {} {} {}<br />'.format(i.name, i.description, i.max_points, i.passing_score(), i.course.course_code, i.course.course_title, i.course.section) def index(request):
#return HttpResponse(displayText)
displayText += eachAssignment context = {
"assignmentList": assignmentList,
}
return render(request, "assignments/index.html", context)
def details(request, assignment_id):
#return HttpResponse("This is assignment # %s." % assignment_id)
# Create your views here. try:
def index(request): taskWork = Assignment.objects.get(pk=assignment_id)
return HttpResponse(displayText) except Assignment.DoesNotExist:
\ No newline at end of file raise Http404("Assignment does not exist!")
for assignmentWork in assignmentList:
if assignmentWork.id == assignment_id:
taskWork = assignmentWork
break
context = {
"taskWork": taskWork,
"assignment_id": assignment_id
}
return render(request, "assignments/details.html", context)
\ 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