From: W. Trevor King Date: Tue, 24 Apr 2012 21:14:05 +0000 (-0400) Subject: Reject attempted submissions for unsubmittable assignments in mailpipe. X-Git-Tag: v0.2~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ac815c28ba7faf056e4a57828e01091fb7c0586e;p=pygrader.git Reject attempted submissions for unsubmittable assignments in mailpipe. This implements the expected behaviour for the option created by: commit 80639ff31b3bc6780659f526d518526cf63fcaec Author: W. Trevor King Date: Tue Apr 24 16:48:56 2012 -0400 Add Assignment.submittable attribute to configure student submission. --- diff --git a/pygrader/mailpipe.py b/pygrader/mailpipe.py index 05a01fc..10f4846 100644 --- a/pygrader/mailpipe.py +++ b/pygrader/mailpipe.py @@ -234,6 +234,74 @@ def mailpipe(basedir, course, stream=None, mailbox=None, input_=None, --===============...==-- + Response to a submission on an unsubmittable assignment: + + >>> server = SMTPServer( + ... ('localhost', 1025), None, process=process, count=1) + >>> del message['Subject'] + >>> message['Subject'] = 'attendance 1 submission' + >>> messages = [message] + >>> ms = MessageSender(address=('localhost', 1025), messages=messages) + >>> loop() # doctest: +REPORT_UDIFF, +ELLIPSIS + respond with: + Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="===============...==" + MIME-Version: 1.0 + Content-Disposition: inline + Date: ... + From: Robot101 + Reply-to: Robot101 + To: Bilbo Baggins + Subject: received invalid Attendance 1 submission + + --===============...== + Content-Type: multipart/mixed; boundary="===============...==" + MIME-Version: 1.0 + + --===============...== + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Content-Disposition: inline + + Billy, + + We received your submission for Attendance 1, but you are not allowed + to submit that assignment via email. + + Yours, + phys-101 robot + --===============...== + Content-Type: message/rfc822 + MIME-Version: 1.0 + + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Content-Disposition: inline + From: Billy B + To: phys101 + Return-Path: + Received: from smtp.mail.uu.edu (localhost.localdomain [127.0.0.1]) by smtp.mail.uu.edu (Postfix) with SMTP id 68CB45C8453 for ; Mon, 10 Oct 2011 12:50:46 -0400 (EDT) + Received: from smtp.home.net (smtp.home.net [123.456.123.456]) by smtp.mail.uu.edu (Postfix) with ESMTP id 5BA225C83EF for ; Mon, 09 Oct 2011 11:50:46 -0400 (EDT) + Message-ID: + Subject: attendance 1 submission + + The answer is 42. + --===============...==-- + --===============...== + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Content-Description: OpenPGP digital signature + Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii" + + -----BEGIN PGP SIGNATURE----- + Version: GnuPG v2.0.17 (GNU/Linux) + + ... + -----END PGP SIGNATURE----- + + --===============...==-- + Response to a bad subject: >>> server = SMTPServer( @@ -483,6 +551,20 @@ def _parse_message(course, msg, respond=None, use_color=None): respond(response) return None + if not assignment.submittable: + response_subject = 'received invalid {} submission'.format( + assignment.name) + response_text = ( + '{},\n\n' + 'We received your submission for {}, but you are not allowed\n' + 'to submit that assignment via email.\n\n' + 'Yours,\n{}').format( + person.alias(), assignment.name, course.robot.alias()) + response = _construct_response( + author=course.robot, targets=[person], + subject=response_subject, text=response_text, original=msg) + respond(response) + if respond: response_subject = 'received {} submission'.format(assignment.name) response_text = (