docs: def inform_student(submission, request, state):
      '''
      Create an email message for the student,
      based on the given submission state.
  
      Sending eMails on validation completion does
      not work, since this may have been triggered
      by the admin.
      '''
      details_url = request.build_absolute_uri(reverse('details', args=(submission.pk,)))
  
      if state == submission.TEST_VALIDITY_FAILED:
          subject = STUDENT_FAILED_SUB
          message = STUDENT_FAILED_MSG
          message = message % (submission.assignment,
                               submission.assignment.course,
                               details_url)
  
      elif state == submission.CLOSED:
          if submission.assignment.is_graded():
              subject = STUDENT_GRADED_SUB
              message = STUDENT_GRADED_MSG
          else:
              subject = STUDENT_PASSED_SUB
              message = STUDENT_PASSED_MSG
          message = message % (submission.assignment,
                               submission.assignment.course,
                               details_url)
      else:
          return
  
      subject = "[%s] %s" % (submission.assignment.course, subject)
      from_email = submission.assignment.course.owner.email
      recipients = submission.authors.values_list(
          'email', flat=True).distinct().order_by('email')
      # send student email with BCC to course owner.
      # TODO: This might be configurable later
      # email = EmailMessage(subject, message, from_email, recipients,
      # [self.assignment.course.owner.email])
      email = EmailMessage(subject, message, from_email, recipients)
      email.send(fail_silently=True)