fnp
/
edumed.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
multi answer mode for choice questions
[edumed.git]
/
wtem
/
management
/
commands
/
wtem_send_results.py
diff --git
a/wtem/management/commands/wtem_send_results.py
b/wtem/management/commands/wtem_send_results.py
index
d2dc147
..
f3f9917
100644
(file)
--- a/
wtem/management/commands/wtem_send_results.py
+++ b/
wtem/management/commands/wtem_send_results.py
@@
-7,14
+7,13
@@
from wtem.management.commands import send_mail
from django.utils import translation
from django.template.loader import render_to_string
from django.utils import translation
from django.template.loader import render_to_string
-from contact.models import Contact
from wtem.models import Submission
def get_submissions():
return sorted(Submission.objects.exclude(answers=None).all(), key=lambda s: -s.final_result)
from wtem.models import Submission
def get_submissions():
return sorted(Submission.objects.exclude(answers=None).all(), key=lambda s: -s.final_result)
-minimum =
52
+minimum =
34
class Command(BaseCommand):
class Command(BaseCommand):
@@
-37,9
+36,13
@@
class Command(BaseCommand):
action='store',
dest='only_to',
default=None,
action='store',
dest='only_to',
default=None,
- help='Send email
s only to listed addresse
s'),
+ help='Send email
only to one addres
s'),
)
)
+ def __init__(self):
+ super(Command, self).__init__()
+ self.sent = self.failed = None
+
def handle(self, *args, **options):
translation.activate('pl')
for target in ['to_teachers', 'to_students']:
def handle(self, *args, **options):
translation.activate('pl')
for target in ['to_teachers', 'to_students']:
@@
-50,7
+53,7
@@
class Command(BaseCommand):
def handle_to_students(self, *args, **options):
self.stdout.write('>>> Sending results to students')
def handle_to_students(self, *args, **options):
self.stdout.write('>>> Sending results to students')
- subject = 'Wyniki I
I etapu Wielkiego Turnieju Edukacji Medialn
ej'
+ subject = 'Wyniki I
etapu Olimpiady Cyfrow
ej'
for submission in get_submissions():
if options['only_to'] and submission.email != options['only_to']:
for submission in get_submissions():
if options['only_to'] and submission.email != options['only_to']:
@@
-67,20
+70,18
@@
class Command(BaseCommand):
def handle_to_teachers(self, *args, **options):
self.stdout.write('>>> Sending results to teachers')
def handle_to_teachers(self, *args, **options):
self.stdout.write('>>> Sending results to teachers')
- subject = 'Wyniki II etapu Wielkiego Turnieju Edukacji Medialnej'
- failed = sent = 0
+ subject = 'Wyniki I etapu Olimpiady Cyfrowej'
submissions_by_contact = dict()
for submission in get_submissions():
if options['only_to'] and submission.contact.contact != options['only_to']:
continue
submissions_by_contact = dict()
for submission in get_submissions():
if options['only_to'] and submission.contact.contact != options['only_to']:
continue
- submissions_by_contact.setdefault(submission.contact.
id
, []).append(submission)
+ submissions_by_contact.setdefault(submission.contact.
contact
, []).append(submission)
- for contact_id, submissions in submissions_by_contact.items():
- contact = Contact.objects.get(id=contact_id)
+ for contact_email, submissions in submissions_by_contact.items():
message = render_to_string('wtem/results_teacher.txt', dict(submissions=submissions))
message = render_to_string('wtem/results_teacher.txt', dict(submissions=submissions))
- self.send_message(message, subject, contact
.contact
)
+ self.send_message(message, subject, contact
_email
)
self.sum_up()
self.sum_up()