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
a8317c87
Commit
a8317c87
authored
7 years ago
by
Joseph Weston
Browse files
Options
Downloads
Patches
Plain Diff
add endpoint for getting student signature images
parent
e41b9fea
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
zesje/api.py
+10
-0
10 additions, 0 deletions
zesje/api.py
zesje/resources/signature.py
+37
-0
37 additions, 0 deletions
zesje/resources/signature.py
zesje/resources/submissions.py
+3
-0
3 additions, 0 deletions
zesje/resources/submissions.py
with
50 additions
and
0 deletions
zesje/api.py
+
10
−
0
View file @
a8317c87
...
...
@@ -6,6 +6,7 @@ from .resources.exams import Exams, ExamConfig
from
.resources.pdfs
import
Pdfs
from
.resources.students
import
Students
from
.resources.submissions
import
Submissions
from
.resources
import
signature
api_bp
=
Blueprint
(
__name__
,
__name__
)
...
...
@@ -26,3 +27,12 @@ api.add_resource(Students, '/students')
api
.
add_resource
(
Submissions
,
'
/submissions/<int:exam_id>
'
,
'
/submissions/<int:exam_id>/<int:submission_id>
'
)
# Other resources that don't return JSON
# It is possible to get flask_restful to work with these, but not
# very idiomatic.
api_bp
.
add_url_rule
(
'
/images/signature/<int:exam_id>/<int:submission_id>
'
,
'
signature
'
,
signature
.
get
,
)
This diff is collapsed.
Click to expand it.
zesje/resources/signature.py
0 → 100644
+
37
−
0
View file @
a8317c87
from
flask
import
abort
,
Response
from
pony
import
orm
from
..helpers
import
yaml_helper
,
image_helper
from
..models
import
Exam
,
Submission
@orm.db_session
def
get
(
exam_id
,
submission_id
):
"""
get student signature for the given submission.
Parameters
----------
exam_id : int
submission_id : int
The copy number of the submission. This uniquely identifies
the submission *within a given exam*.
Returns
-------
Image (JPEG mimetype)
"""
# We could register an app-global error handler for this,
# but it would add more code then it removes.
exam
=
Exam
.
get
(
id
=
exam_id
)
if
not
exam
:
abort
(
404
)
sub
=
Submission
.
get
(
exam
=
exam
,
copy_number
=
submission_id
)
if
not
sub
:
abort
(
404
)
*
_
,
widgets
=
yaml_helper
.
parse
(
yaml_helper
.
read
(
sub
.
exam
.
yaml_path
))
first_page
=
next
(
p
.
path
for
p
in
sub
.
pages
if
'
page1
'
in
p
.
path
)
image
=
image_helper
.
get_widget_image
(
first_page
,
widgets
.
loc
[
'
studentnr
'
])
return
Response
(
image
,
200
,
mimetype
=
'
image/jpeg
'
)
This diff is collapsed.
Click to expand it.
zesje/resources/submissions.py
+
3
−
0
View file @
a8317c87
...
...
@@ -13,6 +13,9 @@ class Submissions(Resource):
Parameters
----------
exam_id : int
submission_id : int, optional
The copy number of the submission. This uniquely identifies
the submission *within a given exam*.
Returns
-------
...
...
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