Commit a070ad2e authored by Adrià Labay's avatar Adrià Labay
Browse files

do not send emails to students with unvalidated submissions

parent 09af8138
...@@ -36,7 +36,7 @@ class StudentControls extends React.Component { ...@@ -36,7 +36,7 @@ class StudentControls extends React.Component {
.then(submissions => { .then(submissions => {
// Need to de-duplicate, as some students // Need to de-duplicate, as some students
const students = withoutDuplicates( const students = withoutDuplicates(
submissions.map(s => s.student).filter(s => s !== null), submissions.reduce((acc, sub) => sub.validated && sub.student ? acc.concat(sub.student) : acc, []),
student => student.id student => student.id
) )
this.setState({ students }) this.setState({ students })
......
...@@ -213,7 +213,7 @@ class Email(Resource): ...@@ -213,7 +213,7 @@ class Email(Resource):
404, 404,
message="Exam does not exist" message="Exam does not exist"
) )
student_ids = [sub.student_id for sub in exam.submissions if sub.student_id] student_ids = [sub.student_id for sub in exam.submissions if sub.student_id and sub.validated]
failed_to_build = list() failed_to_build = list()
to_send = dict() to_send = dict()
......
...@@ -15,6 +15,7 @@ def sub_to_data(sub): ...@@ -15,6 +15,7 @@ def sub_to_data(sub):
'lastName': sub.student.last_name, 'lastName': sub.student.last_name,
'email': sub.student.email 'email': sub.student.email
} if sub.student else None, } if sub.student else None,
'validated': sub.validated,
'problems': [ 'problems': [
{ {
'id': sol.problem.id, 'id': sol.problem.id,
......
...@@ -39,7 +39,10 @@ def solution_pdf(exam_id, student_id, anonymous=False): ...@@ -39,7 +39,10 @@ def solution_pdf(exam_id, student_id, anonymous=False):
""" """
sub = Submission.query.filter(Submission.exam_id == exam_id, sub = Submission.query.filter(Submission.exam_id == exam_id,
Submission.student_id == student_id, Submission.student_id == student_id,
Submission.validated).one() Submission.validated).one_or_none()
if sub is None:
raise RuntimeError('Student did not make a submission for this exam')
pages = sorted((page for copy in sub.copies for page in copy.pages), key=(lambda p: (p.copy.number, p.number))) pages = sorted((page for copy in sub.copies for page in copy.pages), key=(lambda p: (p.copy.number, p.number)))
page_size = current_app.config['PAGE_FORMATS'][current_app.config['PAGE_FORMAT']] page_size = current_app.config['PAGE_FORMATS'][current_app.config['PAGE_FORMAT']]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment