Commit 670e2b25 authored by Marco Anton O. Paeldon's avatar Marco Anton O. Paeldon

Merge remote-tracking branch 'origin/assignments_appv2'

parents 911d7306 1e102883
......@@ -39,8 +39,13 @@ This project was accomplished truthfully only by the people whose names are list
>>>>>>> calendarv2
# members’ signatures in the form (sgd) your complete name, date
<<<<<<< HEAD
John Michael T. Amador (sgd) February 28, 2023
Alvin Joshua M. Andrada (sgd) May 14, 2023
=======
John Michael T. Amador (sgd) May 9, 2023
Alvin Joshua M. Andrada (sgd) March 2, 2023
>>>>>>> origin/assignments_appv2
Brendan Gabrielle M. Fausto (sgd) March 6, 2023
Marco Anton O. Paeldon (sgd) March 6, 2023
Ron Lawrence C. Rodillas (sgd) March 5, 2023
......@@ -14,6 +14,7 @@ class Course(models.Model):
def get_absolute_url(self):
return reverse('course_detail', args=[str(self.section)])
class Assignment(models.Model):
name = models.CharField(max_length=100)
description = models.CharField(max_length=10000)
......@@ -21,8 +22,11 @@ class Assignment(models.Model):
perfect_score = models.IntegerField()
course_stuff = models.ForeignKey(Course, on_delete=models.CASCADE)
def passing_score(self):
return '{}'.format(int(self.perfect_score*0.6))
def __str__(self):
return '{}: {}'.format(self.name, self.course)
def get_absolute_url(self):
return reverse('perfect_score_detail', args=[str(self.perfect_score)])
return reverse('Assignments:assignment-details', kwargs={'pk': self.pk})
<form method="POST" enctype="multipart/form-data">
<!-- Security token -->
{% csrf_token %}
<!-- Using the formset -->
{{ form.as_p }}
<input type="submit" value="Save New Assignment">
</form>
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} {{object.title}} {% endblock %}
{% block content %}
<h1>{{ object.name }}</h1>
<p><b>{{ object.course_stuff }}</b></p>
<p><b>Description:</b> {{ object.description }}</p>
<p><b>Perfect Score:</b> {{ object.perfect_score }}</p>
<p><b>Passing Score:</b> {{ object.passing_score }}</p>
<form action='edit' method="get" enctype="multipart/form-data">
{% csrf_token %}
<input type="submit" value="Edit Assignment">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Edit Assignment{% endblock %}
{% block content %}
<form method="post" enctype="multipart/form-data">
<!-- Security token -->
{% csrf_token %}
<!-- Using the formset -->
{{ form.as_p }}
<input type="submit" value="Save Changes to Assignment">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Assignments{% endblock %}
{% block content %}
<h1>Welcome to Widget's Assignments!</h1>
{%for object in assignment%}
<a href="{{ object.get_absolute_url }}">{{ object.name }}</a>
<br>
{%endfor%}
<br>
<form action="/assignments/add" method="get" enctype="multipart/form-data">
{% csrf_token %}
<input type="submit" value="New Assignment">
</form>
<a href="/dashboard">Dashboard</a>
<br>
<a href="/announcements">Announcements</a>
<br>
<a href="/forum">Forum</a>
<br>
<a href="/calendar">Calendar</a>
<br>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import assignments_view, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView
urlpatterns = [
path('', index, name='index'),
path('', assignments_view, name='assignments_page'),
path('<int:pk>/details/', AssignmentDetailView.as_view(), name='assignment-details'),
path('add', AssignmentCreateView.as_view(), name='assignment-add'),
path('<int:pk>/details/edit', AssignmentUpdateView.as_view(), name='assignment-edit'),
]
# This might be needed, depending on your Django version
app_name = "Assignments"
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic import CreateView, UpdateView
from django.views.generic.detail import DetailView
from .models import Assignment
# Create your view here.
......@@ -16,4 +19,31 @@ def index(request):
overall_assignments += "Course/Section: %s" %assignment.course_stuff
overall_assignments += "</body></html>"
return HttpResponse(overall_assignments)
\ No newline at end of file
return HttpResponse(overall_assignments)
def assignments_view(request):
assignment = Assignment.objects.all()
return render(request, 'Assignments/assignments.html', {'assignment': assignment})
class AssignmentDetailView(DetailView):
model = Assignment
template_name = 'Assignments/assignment-details.html'
class AssignmentCreateView(CreateView):
model = Assignment
fields = '__all__'
template_name = 'Assignments/assignment-add.html'
class AssignmentUpdateView(UpdateView):
# specify the model you want to use
model = Assignment
fields = '__all__'
# specify the fields
# can specify success url
# url to redirect after successfully
# updating details
template_name = 'Assignments/assignment-edit.html'
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<title>{% block title %}{% endblock %}</title>
{% block styles %}{% endblock %}
<link rel="stylesheet" href="style.css">
<title>{% block title %}My amazing site{% endblock %}</title>
{% block styles %}{% endblock %}
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>
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