Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
zesje
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Réouven ASSOULY
zesje
Commits
698c95b7
Commit
698c95b7
authored
7 years ago
by
Joseph Weston
Browse files
Options
Downloads
Patches
Plain Diff
add 'Submissions' resource for getting list of submissions
parent
f6f635d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
zesje/api.py
+4
-0
4 additions, 0 deletions
zesje/api.py
zesje/resources/submissions.py
+47
-0
47 additions, 0 deletions
zesje/resources/submissions.py
with
51 additions
and
0 deletions
zesje/api.py
+
4
−
0
View file @
698c95b7
...
...
@@ -5,6 +5,7 @@ from .resources.graders import Graders
from
.resources.exams
import
Exams
,
ExamConfig
from
.resources.pdfs
import
Pdfs
from
.resources.students
import
Students
from
.resources.submissions
import
Submissions
api_bp
=
Blueprint
(
__name__
,
__name__
)
...
...
@@ -22,3 +23,6 @@ api.add_resource(Exams, '/exams')
api
.
add_resource
(
ExamConfig
,
'
/exams/<int:exam_id>
'
)
api
.
add_resource
(
Pdfs
,
'
/pdfs/<int:exam_id>
'
)
api
.
add_resource
(
Students
,
'
/students
'
)
api
.
add_resource
(
Submissions
,
'
/submissions/<int:exam_id>
'
,
'
/submissions/<int:exam_id>/<int:copy_number>
'
)
This diff is collapsed.
Click to expand it.
zesje/resources/submissions.py
0 → 100644
+
47
−
0
View file @
698c95b7
from
flask_restful
import
Resource
from
pony
import
orm
from
..models
import
Exam
,
Submission
class
Submissions
(
Resource
):
"""
Getting a list of submissions, and assigning students to them.
"""
@orm.db_session
def
get
(
self
,
exam_id
,
copy_number
=
None
):
"""
get submissions for the given exam
Parameters
----------
exam_id : int
Returns
-------
If
'
copy_number
'
not provided provides a single instance of
(otherwise a list of):
copy_number: int
student_id: int or null
Student that completed this submission, null if not assigned.
validated: bool
True if the assigned student has been validated by a human.
"""
# This makes sure we raise ObjectNotFound if the exam does not exist
exam
=
Exam
[
exam_id
]
if
copy_number
is
not
None
:
s
=
Submission
.
get
(
exam
=
exam
,
copy_number
=
copy_number
)
if
not
s
:
raise
orm
.
core
.
ObjectNotFound
(
Submission
)
return
{
'
copy_number
'
:
s
.
copy_number
,
'
student_id
'
:
s
.
student
.
id
if
s
.
student
else
None
,
'
validated
'
:
s
.
signature_validated
,
}
return
[
{
'
copy_number
'
:
s
.
copy_number
,
'
student
'
:
s
.
student
.
id
if
s
.
student
else
None
,
'
validated
'
:
s
.
signature_validated
,
}
for
s
in
Submission
.
select
(
lambda
s
:
s
.
exam
==
exam
)
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment