Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_father when can i be on my own i have the hello world to see
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
father when can i be on my own i have the hello world to see
widget_father when can i be on my own i have the hello world to see
Commits
6d5191dd
Verified
Commit
6d5191dd
authored
Mar 22, 2022
by
Angelo Esteban
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Course model under Assignments app, view displays all assignments
parent
fb84ff44
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
92 additions
and
6 deletions
+92
-6
admin.py
assignments/admin.py
+2
-0
0003_course.py
assignments/migrations/0003_course.py
+22
-0
0004_assignment_course_assignment_passing_score.py
...ations/0004_assignment_course_assignment_passing_score.py
+24
-0
models.py
assignments/models.py
+17
-0
assignments_template.html
assignments/templates/assignments_template.html
+18
-0
urls.py
assignments/urls.py
+2
-2
views.py
assignments/views.py
+7
-4
No files found.
assignments/admin.py
View file @
6d5191dd
from
django.contrib
import
admin
from
django.contrib
import
admin
from
.models
import
Assignment
from
.models
import
Assignment
from
.models
import
Course
admin
.
site
.
register
(
Assignment
)
admin
.
site
.
register
(
Assignment
)
admin
.
site
.
register
(
Course
)
assignments/migrations/0003_course.py
0 → 100644
View file @
6d5191dd
# Generated by Django 4.0.3 on 2022-03-22 14:15
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0002_alter_assignment_max_points'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Course'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'course_code'
,
models
.
CharField
(
max_length
=
10
)),
(
'course_title'
,
models
.
CharField
(
max_length
=
120
)),
(
'section'
,
models
.
CharField
(
max_length
=
3
)),
],
),
]
assignments/migrations/0004_assignment_course_assignment_passing_score.py
0 → 100644
View file @
6d5191dd
# Generated by Django 4.0.3 on 2022-03-22 14:16
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0003_course'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'assignments.course'
),
),
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'passing_score'
,
field
=
models
.
IntegerField
(
default
=
6
),
),
]
assignments/models.py
View file @
6d5191dd
...
@@ -5,3 +5,20 @@ class Assignment(models.Model):
...
@@ -5,3 +5,20 @@ class Assignment(models.Model):
name
=
models
.
CharField
(
max_length
=
120
)
name
=
models
.
CharField
(
max_length
=
120
)
description
=
models
.
TextField
(
blank
=
True
)
description
=
models
.
TextField
(
blank
=
True
)
max_points
=
models
.
IntegerField
(
default
=
10
)
max_points
=
models
.
IntegerField
(
default
=
10
)
passing_score
=
models
.
IntegerField
(
default
=
6
)
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
passing_score
=
int
(
0.6
*
self
.
max_points
)
super
(
Assignment
,
self
)
.
save
()
course
=
models
.
ForeignKey
(
'Course'
,
on_delete
=
models
.
CASCADE
,
null
=
True
,
)
class
Course
(
models
.
Model
):
course_code
=
models
.
CharField
(
max_length
=
10
)
course_title
=
models
.
CharField
(
max_length
=
120
)
section
=
models
.
CharField
(
max_length
=
3
)
assignments/templates/assignments_template.html
0 → 100644
View file @
6d5191dd
<html>
<head>
<title>
Assignments
</title>
</head>
<body>
ASSIGNMENTS:
<br>
{% for assignment in all_assignments %}
Assignment Name: {{ assignment.name }}
<br>
Description: {% if assignment.description != None and assignment.description != '' %}{{ assignment.description }}{% else %}No description provided.{% endif %}
<br>
Perfect Score: {{ assignment.max_points }}
<br>
Passing Score: {{ assignment.passing_score }}
<br>
Course/Section: {{ assignment.course.course_code }} {{ assignment.course.course_title }} {{ assignment.course.section }}
<br><br>
{% endfor %}
</body>
</html>
\ No newline at end of file
assignments/urls.py
View file @
6d5191dd
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
from
.views
import
assignments_view
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index
'
),
path
(
''
,
assignments_view
,
name
=
'assignments_view
'
),
]
]
app_name
=
"assignments"
app_name
=
"assignments"
assignments/views.py
View file @
6d5191dd
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Assignment
def
index
(
request
):
def
assignments_view
(
request
):
return
HttpResponse
(
"This is the Assignments page!"
)
objects_set
=
{
"all_assignments"
:
[
obj
for
obj
in
Assignment
.
objects
.
all
()]
}
return
render
(
request
,
"assignments_template.html"
,
objects_set
)
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