Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
Jan Maximilian Michal
grady
Commits
e7e725f2
There was a problem fetching the pipeline summary.
Verified
Commit
e7e725f2
authored
7 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Fixes
#94
thanks for the testcase. Added documentation and logging
parent
e2cf5bb3
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!49
Bug assignment for same submission
Pipeline
#
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/models.py
+31
-8
31 additions, 8 deletions
core/models.py
core/tests/test_subscription_assignment_service.py
+4
-4
4 additions, 4 deletions
core/tests/test_subscription_assignment_service.py
with
35 additions
and
12 deletions
core/models.py
+
31
−
8
View file @
e7e725f2
...
@@ -501,17 +501,31 @@ class SubmissionSubscription(models.Model):
...
@@ -501,17 +501,31 @@ class SubmissionSubscription(models.Model):
'
feedback_stage
'
)
'
feedback_stage
'
)
def
_get_submission_base_query
(
self
)
->
QuerySet
:
def
_get_submission_base_query
(
self
)
->
QuerySet
:
"""
Get all submissions that are filtered by the query key and type,
e.g. all submissions of one student or submission type.
"""
if
self
.
query_type
==
self
.
RANDOM
:
if
self
.
query_type
==
self
.
RANDOM
:
return
Submission
.
objects
.
all
()
return
Submission
.
objects
.
all
()
return
Submission
.
objects
.
filter
(
return
Submission
.
objects
.
filter
(
**
{
self
.
type_query_mapper
[
self
.
query_type
]:
self
.
query_key
})
**
{
self
.
type_query_mapper
[
self
.
query_type
]:
self
.
query_key
})
def
_get_submissions_that_do_not_have_final_feedback
(
self
):
def
_get_submissions_that_do_not_have_final_feedback
(
self
)
->
QuerySet
:
"""
There are a number of conditions to check for each submission
1. The submission does not have final feedback
2. The submission was not shown to this user before
3. The submission is not currently assigned to somebody else
Returns:
QuerySet -- a list of all submissions ready for consumption
"""
return
self
.
_get_submission_base_query
().
exclude
(
return
self
.
_get_submission_base_query
().
exclude
(
Q
(
feedback__isnull
=
False
)
&
Q
(
feedback__is_final
=
True
)
Q
(
feedback__isnull
=
False
)
&
Q
(
feedback__is_final
=
True
)
).
exclude
(
).
exclude
(
Q
(
assignments__subscription__owner
=
self
.
owner
)
Q
(
assignments__subscription__owner
=
self
.
owner
)
).
exclude
(
assignments__is_done
=
False
).
annotate
(
).
annotate
(
done_assignments_count
=
Count
(
done_assignments_count
=
Count
(
Case
(
When
(
assignments__is_done
=
True
,
then
=
Value
(
1
)),
Case
(
When
(
assignments__is_done
=
True
,
then
=
Value
(
1
)),
...
@@ -519,7 +533,16 @@ class SubmissionSubscription(models.Model):
...
@@ -519,7 +533,16 @@ class SubmissionSubscription(models.Model):
)
)
)
)
def
_get_available_submissions_in_subscription_stage
(
self
):
def
_get_available_submissions_in_subscription_stage
(
self
)
->
QuerySet
:
"""
Another filter this time it returns all the submissions that
are valid in this stage. That means all previous stages have been
completed.
Raises:
SubscriptionEnded -- if the subscription will not yield
subscriptions in the future
SubscriptionTemporarilyEnded -- wait until new become available
"""
candidates
=
self
.
_get_submissions_that_do_not_have_final_feedback
()
candidates
=
self
.
_get_submissions_that_do_not_have_final_feedback
()
if
candidates
.
count
()
==
0
:
if
candidates
.
count
()
==
0
:
...
@@ -528,20 +551,20 @@ class SubmissionSubscription(models.Model):
...
@@ -528,20 +551,20 @@ class SubmissionSubscription(models.Model):
done_assignments_count
=
self
.
assignment_count_on_stage
[
self
.
feedback_stage
]
# noqa
done_assignments_count
=
self
.
assignment_count_on_stage
[
self
.
feedback_stage
]
# noqa
stage_candiates
=
candidates
.
filter
(
stage_candiates
=
candidates
.
filter
(
done_assignments_count
=
done_assignments_count
done_assignments_count
=
done_assignments_count
,
)
)
if
stage_candiates
.
count
()
==
0
:
if
stage_candiates
.
count
()
==
0
:
raise
SubscriptionTemporarilyEnded
(
raise
SubscriptionTemporarilyEnded
(
'
Currently unavailabe. Please check for more soon.
'
'
Currently unavailab
l
e. Please check for more soon.
'
'
Submissions remaining: %s
'
%
stage_candiates
.
count
())
'
Submissions remaining: %s
'
%
stage_candiates
.
count
())
return
stage_candiates
return
stage_candiates
def
get_remaining_not_final
(
self
):
def
get_remaining_not_final
(
self
)
->
int
:
return
self
.
_get_submissions_that_do_not_have_final_feedback
().
count
()
return
self
.
_get_submissions_that_do_not_have_final_feedback
().
count
()
def
get_available_in_stage
(
self
):
def
get_available_in_stage
(
self
)
->
int
:
try
:
try
:
return
self
.
_get_available_submissions_in_subscription_stage
().
count
()
# noqa
return
self
.
_get_available_submissions_in_subscription_stage
().
count
()
# noqa
except
(
SubscriptionTemporarilyEnded
,
SubscriptionEnded
)
as
err
:
except
(
SubscriptionTemporarilyEnded
,
SubscriptionEnded
)
as
err
:
...
@@ -554,6 +577,7 @@ class SubmissionSubscription(models.Model):
...
@@ -554,6 +577,7 @@ class SubmissionSubscription(models.Model):
raise
NotMoreThanTwoOpenAssignmentsAllowed
(
raise
NotMoreThanTwoOpenAssignmentsAllowed
(
'
Not more than 2 active assignments allowed.
'
)
'
Not more than 2 active assignments allowed.
'
)
log
.
info
(
f
'
{
self
.
owner
}
is assignment to
{
task
}
.
'
)
return
TutorSubmissionAssignment
.
objects
.
get_or_create
(
return
TutorSubmissionAssignment
.
objects
.
get_or_create
(
subscription
=
self
,
subscription
=
self
,
submission
=
task
)[
0
]
submission
=
task
)[
0
]
...
@@ -618,8 +642,7 @@ class TutorSubmissionAssignment(models.Model):
...
@@ -618,8 +642,7 @@ class TutorSubmissionAssignment(models.Model):
class
FeedbackComment
(
models
.
Model
):
class
FeedbackComment
(
models
.
Model
):
"""
This Class contains the Feedback for a specific line of a Submission
"""
"""
This Class contains the Feedback for a specific line of a Submission
"""
text
=
models
.
TextField
()
text
=
models
.
TextField
()
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
)
...
...
This diff is collapsed.
Click to expand it.
core/tests/test_subscription_assignment_service.py
+
4
−
4
View file @
e7e725f2
...
@@ -262,10 +262,10 @@ class TestApiEndpoints(APITestCase):
...
@@ -262,10 +262,10 @@ class TestApiEndpoints(APITestCase):
{
'
query_type
'
:
'
random
'
}).
data
{
'
query_type
'
:
'
random
'
}).
data
assignment_fst_tutor
=
client
.
post
(
assignment_fst_tutor
=
client
.
post
(
'
/api/assignment/
'
,
{
'
/api/assignment/
'
,
{
'
subscription
'
:
subscription
[
'
pk
'
]
'
subscription
'
:
subscription
[
'
pk
'
]
}
}
).
data
).
data
client
.
force_authenticate
(
user
=
self
.
data
[
'
tutors
'
][
1
])
client
.
force_authenticate
(
user
=
self
.
data
[
'
tutors
'
][
1
])
...
...
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