Commit 6e6c8657 authored by Albert Gagalac's avatar Albert Gagalac

Implemented views for Assignments + minor fixes to models.py related to passing_score

parent 2219c3fa
# Generated by Django 4.1.7 on 2023-03-05 07:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("assignments", "0004_remove_assignment_passing_score"),
]
operations = [
migrations.AddField(
model_name="assignment",
name="passing_score",
field=models.PositiveIntegerField(default=0),
),
]
# Generated by Django 4.1.7 on 2023-03-05 10:23
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("assignments", "0005_assignment_passing_score"),
]
operations = [
migrations.RemoveField(
model_name="assignment",
name="passing_score",
),
]
......@@ -13,7 +13,8 @@ class Course(models.Model):
message='Only letters are allowed')])
def __str__(self):
return "%s %s" % (self.code, self.section)
return "%s %s %s" % (self.code, self.title, self.section)
class Assignment(models.Model):
......@@ -26,13 +27,13 @@ class Assignment(models.Model):
def __str__(self):
return self.name
#@property
def pass_score(self):
passing_score = self.perfect_score * (60/100)
return passing_score
def get_passing_score(self):
pass_score = self.perfect_score * (60/100)
return pass_score
@property
def passing_score(self):
return self.get_passing_score()
# def pass_score(self,*args, **kwargs):
# self.passing_score = self.perfect_score * (60/100)
# super(Assignment, self).save(*args, **kwargs)
\ No newline at end of file
<p>
{{"Widget's Assignments Page"}}
</p><br>
{% for data in assignment %}
<p>Assignment name: {{data.name}}</p>
<p>Description: {{data.description}}</p>
<p>Perfect Score: {{data.perfect_score}}</p>
<p>Passing Score: {{data.passing_score}}</p>
<p>Course/Section: {{data.course}}</p>
<br>
{% endfor %}
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment, Course
def pageview(request):
return HttpResponse()
num_assignment = Assignment.objects.all()
num_course = Course.objects.all()
return render(request, 'assignments/assignments.html', {'assignment': num_assignment, 'course': num_course})
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