Commit 1e102883 authored by jmAmador's avatar jmAmador

fixed passing score function in the Assignments model

parent 9ce131b5
...@@ -19,11 +19,12 @@ class Assignment(models.Model): ...@@ -19,11 +19,12 @@ class Assignment(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
description = models.CharField(max_length=10000) description = models.CharField(max_length=10000)
course = models.CharField(max_length=10000) course = models.CharField(max_length=10000)
perfect_score = models.FloatField() perfect_score = models.IntegerField()
course_stuff = models.ForeignKey(Course, on_delete=models.CASCADE) course_stuff = models.ForeignKey(Course, on_delete=models.CASCADE)
def passing_score(self, perfect_score): def passing_score(self):
return perfect_score * 0.6 return '{}'.format(int(self.perfect_score*0.6))
def __str__(self): def __str__(self):
return '{}: {}'.format(self.name, self.course) return '{}: {}'.format(self.name, self.course)
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
{% block title %} {{object.title}} {% endblock %} {% block title %} {{object.title}} {% endblock %}
{% block content %} {% block content %}
<h1>{{ object.name }}</h1> <h1>{{ object.name }}</h1>
<p>{{ object.course_stuff }}</p> <p><b>{{ object.course_stuff }}</b></p>
<p>Description: {{ object.description }}</p> <p><b>Description:</b> {{ object.description }}</p>
<p>Perfect Score: {{ object.perfect_score }}</p> <p><b>Perfect Score:</b> {{ object.perfect_score }}</p>
<p>Passing Score: {{ object.passing_score }}</p> <p><b>Passing Score:</b> {{ object.passing_score }}</p>
<form action='edit' method="get" enctype="multipart/form-data"> <form action='edit' method="get" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
{%endfor%} {%endfor%}
<br> <br>
<form action="/assignments/add" method="get" enctype="multipart/form-data"> <form action="/assignments/add" method="get" enctype="multipart/form-data">
{% csrf_token %}
<input type="submit" value="New Assignment"> <input type="submit" value="New Assignment">
</form> </form>
<a href="/dashboard">Dashboard</a> <a href="/dashboard">Dashboard</a>
......
from django.urls import path from django.urls import path
from .views import index, assignments_view, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView from .views import assignments_view, AssignmentDetailView, AssignmentCreateView, AssignmentUpdateView
urlpatterns = [ urlpatterns = [
path('', assignments_view, name='assignments_page'), path('', assignments_view, name='assignments_page'),
......
No preview for this file type
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