fnp
/
edumed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
exercises with scoring
[edumed.git]
/
wtem
/
management
/
commands
/
wtem_assign_submissions.py
diff --git
a/wtem/management/commands/wtem_assign_submissions.py
b/wtem/management/commands/wtem_assign_submissions.py
index
6d33ec8
..
7ff1af2
100644
(file)
--- a/
wtem/management/commands/wtem_assign_submissions.py
+++ b/
wtem/management/commands/wtem_assign_submissions.py
@@
-16,24
+16,31
@@
class Command(BaseCommand):
dest='attachments_only',
default=False,
help='Take into account only submissions with attachments'),
dest='attachments_only',
default=False,
help='Take into account only submissions with attachments'),
+ make_option('--without-attachments-only',
+ action='store_true',
+ dest='no_attachments_only',
+ default=False,
+ help='Take into account only submissions without attachments'),
)
def handle(self, *args, **options):
)
def handle(self, *args, **options):
- how_many = int(args[0])
- examiner_names = args[1:]
+ limit_from = int(args[0])
+ limit_to = int(args[1])
+ examiner_names = args[2:]
users = User.objects.filter(username__in = examiner_names)
submissions_query = Submission.objects.annotate(examiners_count = Count('examiners'))
users = User.objects.filter(username__in = examiner_names)
submissions_query = Submission.objects.annotate(examiners_count = Count('examiners'))
- submissions = submissions_query \
- .filter(examiners_count__lt=2).exclude(answers = None)
+ submissions = submissions_query.exclude(answers = None)
+ with_attachment_ids = Attachment.objects.values_list('submission_id', flat=True).all()
if options['attachments_only']:
if options['attachments_only']:
- with_attachment_ids = Attachment.objects.values_list('submission_id', flat=True).all()
submissions = submissions.filter(id__in = with_attachment_ids)
submissions = submissions.filter(id__in = with_attachment_ids)
+ if options['no_attachments_only']:
+ submissions = submissions.exclude(id__in = with_attachment_ids)
- for submission in submissions
[0:how_many
]:
+ for submission in submissions
.order_by('id')[limit_from:limit_to
]:
submission.examiners.add(*users)
submission.save()
self.stdout.write('added to %s:%s' % (submission.id, submission.email))
submission.examiners.add(*users)
submission.save()
self.stdout.write('added to %s:%s' % (submission.id, submission.email))