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
31492728
Commit
31492728
authored
6 years ago
by
Anton Akhmerov
Browse files
Options
Downloads
Patches
Plain Diff
tell which submissions miss pages
parent
d45267cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zesje/resources/submissions.py
+48
-46
48 additions, 46 deletions
zesje/resources/submissions.py
with
48 additions
and
46 deletions
zesje/resources/submissions.py
+
48
−
46
View file @
31492728
import
re
from
flask_restful
import
Resource
,
reqparse
from
pony
import
orm
from
..models
import
Exam
,
Submission
,
Student
page_match
=
re
.
compile
(
r
'
.*page(\d+).jpg
'
).
match
def
page_nr
(
path
):
return
int
(
page_match
(
path
).
group
(
1
))
def
sub_to_data
(
sub
,
all_pages
):
"""
Transform a submission into a data structure frontend expects.
"""
return
{
'
id
'
:
sub
.
copy_number
,
'
student
'
:
{
'
id
'
:
sub
.
student
.
id
,
'
firstName
'
:
sub
.
student
.
first_name
,
'
lastName
'
:
sub
.
student
.
last_name
,
'
email
'
:
sub
.
student
.
email
}
if
sub
.
student
else
None
,
'
validated
'
:
sub
.
signature_validated
,
'
problems
'
:
[
{
'
id
'
:
sol
.
problem
.
id
,
'
graded_by
'
:
sol
.
graded_by
,
'
graded_at
'
:
sol
.
graded_at
.
isoformat
()
if
sol
.
graded_at
else
None
,
'
feedback
'
:
[
fb
.
id
for
fb
in
sol
.
feedback
],
'
remark
'
:
sol
.
remarks
}
for
sol
in
sub
.
solutions
.
order_by
(
lambda
s
:
s
.
problem
.
id
)
],
'
missing_pages
'
:
sorted
(
all_pages
-
set
(
page_nr
(
i
)
for
i
in
sub
.
pages
.
path
)),
}
class
Submissions
(
Resource
):
"""
Getting a list of submissions, and assigning students to them.
"""
...
...
@@ -26,62 +63,27 @@ class Submissions(Resource):
Student that completed this submission, null if not assigned.
validated: bool
True if the assigned student has been validated by a human.
problems: list of problems
missing_pages: list of int
pages that are missing from submission
"""
# This makes sure we raise ObjectNotFound if the exam does not exist
exam
=
Exam
[
exam_id
]
all_pages
=
set
(
page_nr
(
i
)
for
i
in
exam
.
submissions
.
pages
.
path
)
if
submission_id
is
not
None
:
sub
=
Submission
.
get
(
exam
=
exam
,
copy_number
=
submission_id
)
if
not
sub
:
raise
orm
.
core
.
ObjectNotFound
(
Submission
)
return
{
'
id
'
:
sub
.
copy_number
,
'
student
'
:
{
'
id
'
:
sub
.
student
.
id
,
'
firstName
'
:
sub
.
student
.
first_name
,
'
lastName
'
:
sub
.
student
.
last_name
,
'
email
'
:
sub
.
student
.
email
}
if
sub
.
student
else
None
,
'
validated
'
:
sub
.
signature_validated
,
'
problems
'
:
[
{
'
id
'
:
sol
.
problem
.
id
,
'
graded_by
'
:
sol
.
graded_by
,
'
graded_at
'
:
sol
.
graded_at
.
isoformat
()
if
sol
.
graded_at
else
None
,
'
feedback
'
:
[
fb
.
id
for
fb
in
sol
.
feedback
],
'
remark
'
:
sol
.
remarks
}
for
sol
in
sub
.
solutions
.
order_by
(
lambda
s
:
s
.
problem
.
id
)
]
}
return
sub_to_data
(
sub
,
all_pages
)
return
[
{
'
id
'
:
sub
.
copy_number
,
'
student
'
:
{
'
id
'
:
sub
.
student
.
id
,
'
firstName
'
:
sub
.
student
.
first_name
,
'
lastName
'
:
sub
.
student
.
last_name
,
'
email
'
:
sub
.
student
.
email
}
if
sub
.
student
else
None
,
'
validated
'
:
sub
.
signature_validated
,
'
problems
'
:
[
{
'
id
'
:
sol
.
problem
.
id
,
'
graded_by
'
:
sol
.
graded_by
,
'
graded_at
'
:
sol
.
graded_at
.
isoformat
()
if
sol
.
graded_at
else
None
,
'
feedback
'
:
[
fb
.
id
for
fb
in
sol
.
feedback
],
'
remark
'
:
sol
.
remarks
}
for
sol
in
sub
.
solutions
.
order_by
(
lambda
s
:
s
.
problem
.
id
)
]
}
for
sub
in
Submission
.
select
(
lambda
s
:
s
.
exam
==
exam
).
order_by
(
lambda
s
:
s
.
copy_number
)
sub_to_data
(
sub
,
all_pages
)
for
sub
in
(
Submission
.
select
(
lambda
s
:
s
.
exam
==
exam
)
.
order_by
(
lambda
s
:
s
.
copy_number
))
]
put_parser
=
reqparse
.
RequestParser
()
...
...
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