Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_nicsbabes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nics De Vega
midterm_nicsbabes
Commits
1078dc81
Commit
1078dc81
authored
May 11, 2023
by
Gabriel Geraldo
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'assignmentsv2'
parents
50c5d084
aeb3a963
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
109 additions
and
17 deletions
+109
-17
models.py
widget_nicsbabes/assignments/models.py
+5
-1
assignment-add.html
...bes/assignments/templates/assignments/assignment-add.html
+13
-0
assignment-details.html
...assignments/templates/assignments/assignment-details.html
+22
-0
assignment-edit.html
...es/assignments/templates/assignments/assignment-edit.html
+13
-0
assignments.html
...sbabes/assignments/templates/assignments/assignments.html
+33
-0
urls.py
widget_nicsbabes/assignments/urls.py
+5
-1
views.py
widget_nicsbabes/assignments/views.py
+18
-15
No files found.
widget_nicsbabes/assignments/models.py
View file @
1078dc81
from
django.db
import
models
from
django.urls
import
reverse
class
Course
(
models
.
Model
):
...
...
@@ -7,7 +8,7 @@ class Course(models.Model):
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
'{}
'
.
format
(
self
.
code
)
return
'{}
- {}'
.
format
(
self
.
code
,
self
.
section
)
class
Assignment
(
models
.
Model
):
...
...
@@ -21,3 +22,6 @@ class Assignment(models.Model):
def
passing_score
(
self
):
return
(
self
.
perfect_score
*
60
)
//
100
def
get_absolute_url
(
self
):
return
reverse
(
'assignments:assignment-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
widget_nicsbabes/assignments/templates/assignments/assignment-add.html
0 → 100644
View file @
1078dc81
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Assignment {% endblock %}
{% block content %}
<h1>
Add Assignment:
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{form.as_p}}
<input
type=
"submit"
value=
"Save New Assignment"
>
</form>
<br>
{% endblock %}
widget_nicsbabes/assignments/templates/assignments/assignment-details.html
0 → 100644
View file @
1078dc81
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.name }} {% endblock %}
{% block content %}
<div
style=
"text-transform:uppercase;"
>
<h1>
{{ object.name }}
</h1>
</div>
<h2>
{{ object.course.code }} {{ object.course.title }}-{{ object.course.section }}
</h2>
<div>
Description: {{ object.description }}
<br>
Perfect Score: {{ object.perfect_score }}
<br>
Passing Score: {{ object.passing_score }}
<br>
</div>
<br>
<a
href=
"edit"
>
<button
type=
"button"
><p>
Edit Assignment
</p></button>
</a>
{% endblock %}
widget_nicsbabes/assignments/templates/assignments/assignment-edit.html
0 → 100644
View file @
1078dc81
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Assignment {% endblock %}
{% block content %}
<h1>
Edit Assignment:
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{form.as_p}}
<input
type=
"submit"
value=
"Save Changes to Assignment"
>
</form>
<br>
{% endblock %}
widget_nicsbabes/assignments/templates/assignments/assignments.html
0 → 100644
View file @
1078dc81
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Assignments{% endblock %}
{% block content %}
<i><h1>
Welcome to Widget's Assignments!
</h1></i>
{% for assignments in assignments %}
<p><strong>
<a
href=
"{{ assignments.get_absolute_url }}"
>
<li>
{{ assignments.name }}
</li>
</a>
</strong></p>
{% endfor %}
<br><br>
<a
href=
"add"
>
<button
type=
"button"
><p>
New Assignment
</p></button>
</a>
<br><br><br>
{# the links to other html files #}
<div
class =
links
>
<a
href=
"../dashboard/"
>
Dashboard
</a><br>
<a
href=
"../announcements/"
>
Announcements
</a><br>
<a
href=
"../forum/"
>
Forum
</a><br>
<a
href=
"../calendar/"
>
Calendar
</a><br>
</div>
{% endblock %}
widget_nicsbabes/assignments/urls.py
View file @
1078dc81
from
django.urls
import
path
from
.views
import
index
from
.views
import
*
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'<int:pk>/details'
,
AssignmentsDetailView
.
as_view
(),
name
=
'assignment-details'
),
path
(
'<int:pk>/edit'
,
AssignmentsUpdateView
.
as_view
(),
name
=
'assignment-edit'
),
path
(
'add'
,
AssignmentsCreateView
.
as_view
(),
name
=
'assignment-add'
),
]
# This might be needed, depending on your Django version
app_name
=
"assignments"
widget_nicsbabes/assignments/views.py
View file @
1078dc81
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic
import
ListView
,
DetailView
,
CreateView
,
UpdateView
from
.models
import
Assignment
,
Course
def
index
(
request
):
assignments
=
Assignment
.
objects
.
all
()
args
=
{
'assignments'
:
assignments
}
return
render
(
request
,
'assignments/assignments.html'
,
args
)
return_string
=
'<body>'
for
assignment
in
Assignment
.
objects
.
all
():
class
AssignmentsView
(
ListView
):
model
=
Assignment
template_name
=
'assignments/assignments.html'
assignment_details
=
'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br> Passing Score: {}<br>Course/Section: {} {}-{}<br>'
.
format
(
assignment
.
name
,
assignment
.
description
,
assignment
.
perfect_score
,
assignment
.
passing_score
(),
assignment
.
course
.
code
,
assignment
.
course
.
title
,
assignment
.
course
.
section
)
class
AssignmentsDetailView
(
DetailView
):
model
=
Assignment
template_name
=
'assignments/assignment-details.html'
return_string
+=
assignment_details
+
'<br>'
class
AssignmentsUpdateView
(
UpdateView
):
model
=
Assignment
fields
=
"__all__"
template_name
=
'assignments/assignment-edit.html'
html_string
=
'<html>{}</html>'
.
format
(
return_string
)
return
HttpResponse
(
'Widget
\'
s Assignments Page<br><br>'
+
html_string
)
class
AssignmentsCreateView
(
CreateView
):
model
=
Assignment
fields
=
"__all__"
template_name
=
'assignments/assignment-add.html'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment