Commit 336e20c1 authored by Christianneil Emmanuel Ocampo's avatar Christianneil Emmanuel Ocampo

Fixed merge conflicts with master branch

parents d1015648 01434ef2
from django.contrib import admin
from .models import Course, Assignment
class CourseAdmin(admin.ModelAdmin):
model = Course
search_fields = ('code', 'title', 'section')
list_display = ('code', 'title', 'section')
class AssignmentAdmin(admin.ModelAdmin):
model = Assignment
search_fields = ('name', 'description', 'course')
list_display = ('name', 'course')
admin.site.register(Course, CourseAdmin)
admin.site.register(Assignment, AssignmentAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AssignmentsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'assignments'
# Generated by Django 4.1.7 on 2023-03-05 15:36
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=255)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('description', models.TextField()),
('perfect_score', models.IntegerField()),
('passing_score', models.IntegerField(editable=False)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 16:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(default=1, editable=False),
),
migrations.AlterField(
model_name='assignment',
name='perfect_score',
field=models.IntegerField(default=100),
),
]
# Generated by Django 4.1.7 on 2023-03-05 16:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assignments', '0002_alter_assignment_passing_score_and_more'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='passing_score',
field=models.IntegerField(editable=False),
),
migrations.AlterField(
model_name='assignment',
name='perfect_score',
field=models.IntegerField(),
),
]
from django.db import models
# Create your models here.
class Course(models.Model):
code = models.CharField(max_length=10)
title = models.CharField(max_length=255)
section = models.CharField(max_length=3)
def __str__(self):
return '{} {}'.format(self.code, self.section)
class Assignment(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
course = models.ForeignKey(Course, on_delete=models.CASCADE)
perfect_score = models.IntegerField()
passing_score = models.IntegerField(editable=False)
def save(self, *args, **kwargs):
self.passing_score = int((self.perfect_score)*(0.60))
super(Assignment, self).save(*args, **kwargs)
def __str__(self):
return '{} {}: {}'.format(self.course.code, self.course.section, self.name)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = 'assignments'
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Assignment
# Create your views here.
def index(request):
return_string = '<p>Widget\'s Assignments Page<br>'
for work in Assignment.objects.all():
work_string = '<br>Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>Course/Section: {} {}-{}<br>'.format(
work.name, work.description, work.perfect_score, work.passing_score, work.course.code, work.course.title, work.course.section)
return_string += work_string
return_string += '</p>'
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(html_string)
\ No newline at end of file
......@@ -44,7 +44,7 @@ INSTALLED_APPS = [
'dashboard',
#for announcement board
#for forum
#for assignments
'assignments',
'widget_calendar',
]
......
......@@ -22,5 +22,6 @@ urlpatterns = [
#for announcement board
#for forum
#for assignments
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('widget_calendar/', include('widget_calendar.urls', namespace="widget_calendar")),
path('assignments/', include('assignments.urls', namespace='assignments')),
]
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