Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Alipins
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
Angelico Ruiz T. Teaño
widget_Alipins
Commits
1da508fa
Commit
1da508fa
authored
Apr 02, 2022
by
Angelico Ruiz T. Teaño
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'teano/assignments'
parents
85df01f9
778a96ee
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
5 deletions
+95
-5
admin.py
widget_alipins/assignments/admin.py
+9
-3
0003_assignment_passing_score.py
...s/assignments/migrations/0003_assignment_passing_score.py
+18
-0
0004_course_assignment_course.py
...s/assignments/migrations/0004_course_assignment_course.py
+28
-0
models.py
widget_alipins/assignments/models.py
+17
-1
views.py
widget_alipins/assignments/views.py
+23
-1
No files found.
widget_alipins/assignments/admin.py
View file @
1da508fa
from
django.contrib
import
admin
from
django.contrib
import
admin
# Register your models here.
# Register your models here.
from
.models
import
Assignment
from
.models
import
Assignment
,
Course
class
CourseAdmin
(
admin
.
ModelAdmin
):
model
=
Course
search_fields
=
[
'course_code'
,
'course_title'
,
'section'
]
list_display
=
(
'course_code'
,
'course_title'
,
'section'
)
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
model
=
Assignment
model
=
Assignment
search_fields
=
[
'name'
,
'description'
]
search_fields
=
[
'name'
,
'description'
,
'course'
]
list_display
=
(
'name'
,
'description'
,
'
max_points
'
)
list_display
=
(
'name'
,
'description'
,
'
passing_score'
,
'max_points'
,
'course
'
)
admin
.
site
.
register
(
Course
,
CourseAdmin
)
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
\ No newline at end of file
widget_alipins/assignments/migrations/0003_assignment_passing_score.py
0 → 100644
View file @
1da508fa
# Generated by Django 4.0.3 on 2022-04-02 09:34
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0002_alter_assignment_description'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'passing_score'
,
field
=
models
.
IntegerField
(
default
=
0
,
editable
=
False
),
),
]
widget_alipins/assignments/migrations/0004_course_assignment_course.py
0 → 100644
View file @
1da508fa
# Generated by Django 4.0.3 on 2022-04-02 10:51
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assignments'
,
'0003_assignment_passing_score'
),
]
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
=
50
)),
(
'section'
,
models
.
CharField
(
max_length
=
3
)),
],
),
migrations
.
AddField
(
model_name
=
'assignment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
default
=
1
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'assignments.course'
),
),
]
widget_alipins/assignments/models.py
View file @
1da508fa
from
django.db
import
models
from
django.db
import
models
# Create your models here.
# Create your models here.
class
Course
(
models
.
Model
):
course_code
=
models
.
CharField
(
max_length
=
10
)
course_title
=
models
.
CharField
(
max_length
=
50
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
self
.
course_code
class
Assignment
(
models
.
Model
):
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
description
=
models
.
TextField
(
max_length
=
1500
)
description
=
models
.
TextField
(
max_length
=
1500
)
max_points
=
models
.
IntegerField
(
default
=
0
)
max_points
=
models
.
IntegerField
(
default
=
0
)
passing_score
=
models
.
IntegerField
(
default
=
0
,
editable
=
False
)
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
# Overrides save method to update passing_score value to 60% of max_points
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
passing_score
=
int
(
self
.
max_points
*
0.6
)
return
super
()
.
save
(
*
args
,
**
kwargs
)
\ No newline at end of file
widget_alipins/assignments/views.py
View file @
1da508fa
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Assignment
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
"This is the Assignments page!"
)
return
HttpResponse
(
display_assignments
(
Assignment
.
objects
.
all
()))
\ No newline at end of file
def
display_assignments
(
data_set_assignment
):
display_output
=
"ASSIGNMENTS: <br>"
for
object
in
data_set_assignment
:
display_output
+=
'''
Assignment Name: {name}<br>
Description: {description}<br>
Perfect Score: {max_points}<br>
Passing Score: {passing_score}<br>
Course/Section: {course_code} | {course_title} - {section}<br><br>
'''
.
format
(
name
=
object
.
name
,
description
=
object
.
description
,
max_points
=
object
.
max_points
,
passing_score
=
object
.
passing_score
,
course_code
=
object
.
course
.
course_code
,
course_title
=
object
.
course
.
course_title
,
section
=
object
.
course
.
section
)
return
display_output
\ 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