Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
Overview
Overview
Details
Activity
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
edx
edx-ora2
Commits
c9189427
Commit
c9189427
authored
Mar 24, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using LIMIT in a subquery
parent
e16ddb4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
apps/openassessment/assessment/peer_api.py
+15
-5
No files found.
apps/openassessment/assessment/peer_api.py
View file @
c9189427
...
...
@@ -100,16 +100,26 @@ def get_score(submission_uuid, requirements):
return
None
workflow
=
PeerWorkflow
.
objects
.
get
(
submission_uuid
=
submission_uuid
)
assessments
=
Assessment
.
objects
.
filter
(
submission_uuid
=
submission_uuid
,
score_type
=
PEER_TYPE
)[:
requirements
[
"must_be_graded_by"
]]
items
=
workflow
.
graded_by
.
filter
(
assessment__in
=
assessments
)
items
=
workflow
.
graded_by
.
filter
(
assessment__submission_uuid
=
submission_uuid
,
assessment__score_type
=
PEER_TYPE
)
.
order_by
(
'assessment'
)
submission_finished
=
items
.
count
()
>=
requirements
[
"must_be_graded_by"
]
if
not
submission_finished
:
return
None
items
.
update
(
scored
=
True
)
# Unfortunately, we cannot use update() after taking a slice,
# so we need to update the and save the items individually.
# One might be tempted to first query for the first n assessments,
# then select items that have those assessments.
# However, this generates a SQL query with a LIMIT in a subquery,
# which is not supported by some versions of MySQL.
# Although this approach generates more database queries, the number is likely to
# be relatively small (at least 1 and very likely less than 5).
for
scored_item
in
items
[:
requirements
[
"must_be_graded_by"
]]:
scored_item
.
scored
=
True
scored_item
.
save
()
workflow
.
completed_at
=
timezone
.
now
()
workflow
.
save
()
...
...
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