Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_princessgabi
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
Ysabella Panghulan
midterm_princessgabi
Commits
d575aa7e
Commit
d575aa7e
authored
Mar 04, 2023
by
Caryn Lopez-Go
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial Assignments commit
parent
db2ef254
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
0 deletions
+77
-0
__init__.py
widget_princessgabi/Assignments/__init__.py
+0
-0
admin.py
widget_princessgabi/Assignments/admin.py
+26
-0
apps.py
widget_princessgabi/Assignments/apps.py
+6
-0
__init__.py
widget_princessgabi/Assignments/migrations/__init__.py
+0
-0
models.py
widget_princessgabi/Assignments/models.py
+20
-0
tests.py
widget_princessgabi/Assignments/tests.py
+3
-0
views.py
widget_princessgabi/Assignments/views.py
+22
-0
No files found.
widget_princessgabi/Assignments/__init__.py
0 → 100644
View file @
d575aa7e
widget_princessgabi/Assignments/admin.py
0 → 100644
View file @
d575aa7e
from
django.contrib
import
admin
from
.models
import
Assignment
,
Course
# Register your models here.
class
AssignmentInLine
(
admin
.
TabularInline
):
model
=
Assignment
class
CourseAdmin
(
admin
.
ModelAdmin
):
model
=
Course
list_display
=
(
'code'
,
'title'
,
'section'
)
search_fields
=
(
'code'
,
'title'
,
'section'
)
inlines
=
[
AssignmentInLine
]
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'name'
,
'description'
,
'course'
,
'perfect_score'
,
'passing_score'
)
def
get_name
(
self
,
obj
):
return
obj
.
assignment
.
name
get_name
.
short_description
=
'name'
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
admin
.
site
.
register
(
Course
,
CourseAdmin
)
widget_princessgabi/Assignments/apps.py
0 → 100644
View file @
d575aa7e
from
django.apps
import
AppConfig
class
AssignmentsConfig
(
AppConfig
):
default_auto_field
=
'django.db.models.BigAutoField'
name
=
'Assignments'
widget_princessgabi/Assignments/migrations/__init__.py
0 → 100644
View file @
d575aa7e
widget_princessgabi/Assignments/models.py
0 → 100644
View file @
d575aa7e
from
django.db
import
models
# Create your models here.
class
Course
(
models
.
Model
):
code
=
models
.
CharField
(
max_length
=
10
)
title
=
models
.
CharField
(
max_length
=
50
)
section
=
models
.
CharField
(
max_length
=
3
)
def
__str__
(
self
):
return
self
.
code
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
description
=
models
.
TextField
(
max_length
=
500
)
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
)
perfect_score
=
models
.
PositiveIntegerField
(
default
=
0
)
passing_score
=
models
.
PositiveIntegerField
(
default
=
perfect_score
*
.6
)
def
__str__
(
self
):
return
self
.
name
\ No newline at end of file
widget_princessgabi/Assignments/tests.py
0 → 100644
View file @
d575aa7e
from
django.test
import
TestCase
# Create your tests here.
widget_princessgabi/Assignments/views.py
0 → 100644
View file @
d575aa7e
from
django.http
import
HttpResponse
from
.models
import
Assignment
,
Course
# Create your views here.
def
assignments
(
request
):
homeworks
=
Assignment
.
objects
.
all
()
display
=
'Widget
\'
s Assignments Page<br><br>'
for
homework
in
homeworks
:
assignment_name
=
homework
.
name
assignment_description
=
homework
.
description
assignment_perfect_score
=
homework
.
perfect_score
assignment_passing_score
=
homework
.
passing_score
course_code
=
homework
.
course
.
code
course_title
=
homework
.
course
.
title
course_section
=
homework
.
course
.
section
display
+=
'Assignment Name: '
+
assignment_name
+
'<br>'
display
+=
'Description: '
+
assignment_description
+
'<br>'
display
+=
'Perfect Score: '
+
assignment_perfect_score
+
'<br>'
display
+=
'Passing Score: '
+
assignment_passing_score
+
'<br>'
display
+=
'Course/Section: '
+
course_code
+
' '
+
course_title
+
'-'
+
course_section
+
'<br><br>'
return
HttpResponse
(
display
)
\ 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