Commit f25d2926 authored by John Raymon C Yu's avatar John Raymon C Yu

Yu edited assignments and homepage

parent 41001228
from django import forms
from assignments.models import Course
class IndexCardForm(forms.Form):
name = forms.CharField(label='Full Name', max_length=100)
section = forms.CharField(label='CSCI40 Section', max_length=5)
age = forms.IntegerField(label='Current Age')
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-05-18 13:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0009_alter_assignment_assignment_passing_score'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='assignment_id',
field=models.IntegerField(default=0),
),
]
# Generated by Django 4.0.3 on 2022-05-19 05:26
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0010_assignment_assignment_id'),
]
operations = [
migrations.AddField(
model_name='assignment',
name='assignment_image',
field=models.ImageField(blank=True, default='imgNotFound.png', null=True, upload_to=''),
),
]
# Generated by Django 4.0.3 on 2022-05-19 06:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0011_assignment_assignment_image'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_image',
field=models.ImageField(blank=True, default='assignments\\imgNotFound.png', null=True, upload_to=''),
),
]
# Generated by Django 4.0.3 on 2022-05-19 06:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0012_alter_assignment_assignment_image'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='assignment_image',
field=models.ImageField(blank=True, default='imgNotFound.png', null=True, upload_to=''),
),
]
...@@ -5,12 +5,14 @@ from django.db import models ...@@ -5,12 +5,14 @@ from django.db import models
class Assignment(models.Model): class Assignment(models.Model):
original_max_points = 0 original_max_points = 0
assignment_id = models.IntegerField(default=0)
assignment_name = models.CharField(max_length=100) assignment_name = models.CharField(max_length=100)
assignment_description = models.CharField(max_length=1000) assignment_description = models.CharField(max_length=1000)
assignment_max_points = models.IntegerField(default=0) assignment_max_points = models.IntegerField(default=0)
assignment_passing_score = models.IntegerField(editable=True) assignment_passing_score = models.IntegerField(editable=True)
assignment_course = models.ForeignKey('Course', on_delete=models.CASCADE, blank=True, null= True) assignment_course = models.ForeignKey('Course', on_delete=models.CASCADE, blank=True, null= True)
assignment_image = models.ImageField(default="imgNotFound.png", null=True, blank=True)
def __str__(self): def __str__(self):
return self.assignment_name return self.assignment_name
...@@ -25,5 +27,6 @@ class Course(models.Model): ...@@ -25,5 +27,6 @@ class Course(models.Model):
course_title = models.CharField(max_length=100) course_title = models.CharField(max_length=100)
course_section = models.CharField(max_length=3) course_section = models.CharField(max_length=3)
def __str__(self): def __str__(self):
return self.course_code return self.course_code
{% load static %}
<p>
<h2>{{assignments.assignment_course.course_code}} {{assignments.assignment_course.course_title}} {{assignments.assignment_course.course_section}}</h2>
<p>Name: {{ assignments.assignment_name }} </p>
<p>Description: {{ assignments.assignment_description }}</p>
<p>Perfect Score: {{ assignments.assignment_max_points }}</p>
<p>Passing Score: {{ assignments.assignment_passing_score }}</p>
</p>
<br>
<img src="{{ assignments.assignment_image.url }}" width="20%">
<p>
{% if assignments %}
<ul>
{% for assignment in assignments %}
{% if assignment.assignment_course == course %}
<li>
<a href="{% url 'assignment:ShowAssignmentDetails' assignment.assignment_id %}">
○ {{assignment.assignment_name}}
</a>
</li>
{% else %}
{% endif %}
{% endfor %}
</ul>
{% else %}
<p>○ No Assignments registered</p>
{% endif %}
</p>
\ No newline at end of file
<p> <p>
<h2>ASSIGNMENTS: </h2> <h2>Assignments Per Course: </h2>
{% for course in course %}
<p>{{course_code}} {{course_title}} {{course_section}}</p>
{% include "assignment_Assignment.html" with courseVariable=course %}
{% for assignment in assignments %} {% for assignment in assignments %}
<p><b>Assignment Name: {{assignment.assignment_name}}</b></p> <p><b>Assignment Name: {{assignment.assignment_name}}</b></p>
<p>Description: {{assignment.assignment_description}}</p> <p>Description: {{assignment.assignment_description}}</p>
......
{% load static %}
<p>
<h2>Assignments Per Course: </h2>
{% if course %}
<ol>
{% for course in course %}
<li>
<p>{{course.course_code}} {{course.course_title}} {{course.course_section}}</p>
{% include "assignment_Assignment_Link.html" with course=course %}
</li>
{% endfor %}
</ol>
{% else %}
<p>No courses registered.</p>
{% endif %}
</p>
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
from django.conf import settings
from django.conf.urls.static import static
app_name = "assignment"
urlpatterns = [ urlpatterns = [
path('', views.show_assignments_page, name='Show Assignment Page') path('', views.show_courses_page, name='ShowCoursesPage'),
path("assignment/<int:assignment_id>/details/", views.show_assignment_details, name='ShowAssignmentDetails')
] ]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course from .models import Assignment, Course
from django.shortcuts import render
from django.http import Http404
# Create your views here. # Create your views here.
def show_assignments_page(request):
assignments = Assignment.objects.all() course = Course.objects.order_by("course_code")
return render(request, 'assignment_listing.html', {'assignments': assignments})
def show_courses_page(request):
context = {
"course": course,
"assignments": Assignment.objects.all()
}
return render(request, 'assignment_Courses_Ordered.html', context)
def show_assignment_details(request, assignment_id):
try:
assignment = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
context = {
"assignments": assignment
}
return render(request, "assignment_Assignment_Details.html", context)
...@@ -131,7 +131,7 @@ STATICFILES_DIRS = [ ...@@ -131,7 +131,7 @@ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static') os.path.join(BASE_DIR, 'static')
] ]
MEDIA_ROOT = os.path.join(BASE_DIR, 'homepage/static/homepage/images') MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
......
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