Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_gitgud
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
Neal Luigi D. Rodriguez
midterm_gitgud
Commits
4b598ba0
Commit
4b598ba0
authored
May 15, 2023
by
Neal Luigi D. Rodriguez
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Assignmentsv2'
parents
f92324d6
0182df76
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
15 deletions
+109
-15
forms.py
widget_gitgud/Assignments/forms.py
+14
-0
models.py
widget_gitgud/Assignments/models.py
+7
-0
assignment-add.html
...gud/Assignments/templates/Assignments/assignment-add.html
+11
-0
assignment-details.html
...Assignments/templates/Assignments/assignment-details.html
+17
-0
assignment-edit.html
...ud/Assignments/templates/Assignments/assignment-edit.html
+11
-0
assignments.html
...gitgud/Assignments/templates/Assignments/assignments.html
+23
-0
urls.py
widget_gitgud/Assignments/urls.py
+7
-2
views.py
widget_gitgud/Assignments/views.py
+19
-13
No files found.
widget_gitgud/Assignments/forms.py
0 → 100644
View file @
4b598ba0
from
django
import
forms
from
.models
import
Course
,
Assignment
class
CourseForm
(
forms
.
ModelForm
):
class
meta
:
model
=
Course
fields
=
[
'code'
,
'title'
,
'section'
]
class
AssignmentForm
(
forms
.
ModelForm
):
class
meta
:
model
=
Assignment
fields
=
[
'name'
,
'description'
,
'course'
,
'perfect_score'
]
\ No newline at end of file
widget_gitgud/Assignments/models.py
View file @
4b598ba0
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
# Create your models here.
# Create your models here.
class
Course
(
models
.
Model
):
class
Course
(
models
.
Model
):
...
@@ -18,6 +19,12 @@ class Assignment(models.Model):
...
@@ -18,6 +19,12 @@ class Assignment(models.Model):
)
)
perfect_score
=
models
.
IntegerField
()
perfect_score
=
models
.
IntegerField
()
def
get_absolute_url
(
self
):
return
reverse
(
'Assignments:assignment-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_course_details
(
self
):
return
'{} {}-{}'
.
format
(
self
.
course
.
code
,
self
.
course
.
title
,
self
.
course
.
section
)
@
property
@
property
def
passing_score
(
self
):
def
passing_score
(
self
):
return
int
(
self
.
perfect_score
*
0.60
)
return
int
(
self
.
perfect_score
*
0.60
)
\ No newline at end of file
widget_gitgud/Assignments/templates/Assignments/assignment-add.html
0 → 100644
View file @
4b598ba0
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Assignment {% endblock %}
{% block content %}
<h1>
Add a New Assignment
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save New Assignment"
>
</form>
{% endblock %}
\ No newline at end of file
widget_gitgud/Assignments/templates/Assignments/assignment-details.html
0 → 100644
View file @
4b598ba0
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.name }}{% endblock %}
{% block content %}
<h1>
{{ object.name }}
</h1>
<h2>
{{ object.get_course_details }}
</h2>
<ul>
<li>
Description: {{ object.description }}
</li>
<li>
Perfect Score: {{ object.perfect_score }}
</li>
<li>
Passing Score: {{ object.passing_score }}
</li>
</ul>
<button
onclick=
"window.location.href='../../../Assignments/{{object.id}}/edit/';"
>
Edit Assignment
</button>
{% endblock %}
\ No newline at end of file
widget_gitgud/Assignments/templates/Assignments/assignment-edit.html
0 → 100644
View file @
4b598ba0
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Assignment {% endblock %}
{% block content %}
<h1>
Edit Assignment
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Assignment"
>
</form>
{% endblock %}
\ No newline at end of file
widget_gitgud/Assignments/templates/Assignments/assignments.html
0 → 100644
View file @
4b598ba0
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget's Assignments {% endblock %}
{% block content %}
<h1>
Welcome to Widget's Assignments
</h1>
<ul>
{% for object in assignments %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.name }}
</a>
</li>
{% endfor %}
</ul>
<button
onclick=
"window.location.href='../../Assignments/add/';"
>
New Assignment
</button>
<p>
<a
href=
"http://127.0.0.1:8000/Dashboard/"
>
Dashboard
</a><br>
<a
href=
"http://127.0.0.1:8000/Announcement/"
>
Announcements
</a><br>
<a
href=
"http://127.0.0.1:8000/Forum/"
>
Forum
</a><br>
<a
href=
"http://127.0.0.1:8000/Calendar/"
>
Calendar
</a>
</p>
{% endblock %}
\ No newline at end of file
widget_gitgud/Assignments/urls.py
View file @
4b598ba0
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
from
.views
import
(
AssignmentView
,
AssignmentsDetailView
,
AssignmentsCreateView
,
AssignmentsUpdateView
)
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
"index"
)
path
(
'assignments/'
,
AssignmentView
,
name
=
"index"
),
path
(
'<pk>/details/'
,
AssignmentsDetailView
.
as_view
(),
name
=
'assignment-details'
),
path
(
'add/'
,
AssignmentsCreateView
.
as_view
(),
name
=
'assignment-add'
),
path
(
'<pk>/edit/'
,
AssignmentsUpdateView
.
as_view
(),
name
=
'assignment-edit'
)
]
]
app_name
=
"Assignments"
app_name
=
"Assignments"
\ No newline at end of file
widget_gitgud/Assignments/views.py
View file @
4b598ba0
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Assignment
,
Course
from
.models
import
Assignment
,
Course
# Create your views here.
# Create your views here.
def
index
(
request
):
def
AssignmentView
(
request
):
head_string
=
"<h1>Widget's Assignment Page</h1>"
assignments
=
Assignment
.
objects
.
all
()
body_string
=
""
context
=
{
'assignments'
:
assignments
}
for
assignment
in
Assignment
.
objects
.
all
():
return
render
(
request
,
'Assignments/assignments.html'
,
context
)
body_string
+=
'<p>Assignment Name: {}</br>'
.
format
(
assignment
.
name
)
body_string
+=
'Description: {}</br>'
.
format
(
assignment
.
description
)
class
AssignmentsDetailView
(
DetailView
):
body_string
+=
'Perfect Score: {}</br>'
.
format
(
assignment
.
perfect_score
)
model
=
Assignment
body_string
+=
'Passing Score: {}</br>'
.
format
(
assignment
.
passing_score
)
template_name
=
'Assignments/assignment-details.html'
body_string
+=
'Course/Section: {} {}-{}</br>'
.
format
(
assignment
.
course
.
code
,
assignment
.
course
.
title
,
assignment
.
course
.
section
)
body_string
+=
"</p>"
class
AssignmentsCreateView
(
CreateView
):
html_string
=
'<html><head>{}</head><body>{}</body></html>'
.
format
(
head_string
,
body_string
)
model
=
Assignment
fields
=
'__all__'
template_name
=
'Assignments/assignment-add.html'
return
HttpResponse
(
html_string
)
class
AssignmentsUpdateView
(
UpdateView
):
\ No newline at end of file
model
=
Assignment
fields
=
'__all__'
template_name
=
'Assignments/assignment-edit.html'
\ No newline at end of file
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