Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_k3git
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
Stefan Gomez
midterm_k3git
Commits
2e157fd0
Commit
2e157fd0
authored
Mar 06, 2023
by
Nate Brevin A. Que
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated str function of Assignment model, and views.pyto make the code cleaner.
parent
3ec21087
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
13 deletions
+30
-13
0002_remove_assignment_passing_score.py
...nments/migrations/0002_remove_assignment_passing_score.py
+17
-0
models.py
widget_k3git/assignments/models.py
+10
-2
views.py
widget_k3git/assignments/views.py
+3
-11
db.sqlite3
widget_k3git/db.sqlite3
+0
-0
No files found.
widget_k3git/assignments/migrations/0002_remove_assignment_passing_score.py
0 → 100644
View file @
2e157fd0
# Generated by Django 3.2 on 2023-03-06 11:36
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'assignment'
,
name
=
'passing_score'
,
),
]
widget_k3git/assignments/models.py
View file @
2e157fd0
...
...
@@ -15,7 +15,15 @@ class Assignment(models.Model):
description
=
models
.
TextField
()
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
)
perfect_score
=
models
.
IntegerField
()
passing_score
=
models
.
IntegerField
()
def
__str__
(
self
):
return
self
.
name
\ No newline at end of file
return
"""Assignment Name: {}<br>
Description: {}<br>
Perfect Score: {}<br>
Passing Score: {}<br>
Course/Section: {}<br>"""
.
format
(
self
.
name
,
self
.
description
,
self
.
perfect_score
,
self
.
passing_score
,
self
.
course
)
@
property
def
passing_score
(
self
):
return
round
(
self
.
perfect_score
*
6
/
10
)
\ No newline at end of file
widget_k3git/assignments/views.py
View file @
2e157fd0
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Course
,
Assignment
from
.models
import
Assignment
def
index
(
request
):
page_content
=
"""<H1>Widget's Assignments Page</H1>""
"
page_content
=
"<H1>Widget's Assignments Page</H1><ul>
"
for
assignment
in
Assignment
.
objects
.
all
():
page_content
+=
"""<ul>
<li>Assignment Name: {}<br>
<li>Description: {}<br>
<li>Perfect Score: {}<br>
<li>Passing Score: {}<br>
<li>Course/Section: {}<br>
</ul>"""
.
format
(
assignment
.
name
,
assignment
.
description
,
assignment
.
perfect_score
,
assignment
.
passing_score
,
assignment
.
course
)
page_content
+=
"<li>{}<br>"
.
format
(
assignment
)
return
HttpResponse
(
page_content
)
\ No newline at end of file
widget_k3git/db.sqlite3
View file @
2e157fd0
No preview for this file type
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