From: skodak Date: Wed, 20 Feb 2008 17:50:32 +0000 (+0000) Subject: MDL-6591 Optional assignment graded email notification - based on patch by Gary Ander... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2dc5d980ad924ee7533e19ee14588a5c0ea931f3;p=moodle.git MDL-6591 Optional assignment graded email notification - based on patch by Gary Anderson; merged from MOODLE_19_STABLE --- diff --git a/lang/en_utf8/assignment.php b/lang/en_utf8/assignment.php index 01286a4191..d24529d9df 100644 --- a/lang/en_utf8/assignment.php +++ b/lang/en_utf8/assignment.php @@ -37,6 +37,7 @@ $string['duedateno'] = 'No due date'; $string['early'] = '$a early'; $string['editmysubmission'] = 'Edit my submission'; $string['emailstudents'] = 'Email alerts to students'; +$string['emailnotification'] = 'Send notification email'; $string['emailteachermail'] = '$a->username has updated their assignment submission for \'$a->assignment\' diff --git a/lang/en_utf8/help/assignment/emailnotification.html b/lang/en_utf8/help/assignment/emailnotification.html new file mode 100644 index 0000000000..1b913fa4cf --- /dev/null +++ b/lang/en_utf8/help/assignment/emailnotification.html @@ -0,0 +1,6 @@ +

Send notification email

+ +

Do you want to nofify students about received grades and feedback via email?

+ +

Your preference is saved and will apply to all assignments in all courses.

+ diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 79b790ddbf..e8716fceb6 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -491,6 +491,13 @@ class assignment_base { //make user global so we can use the id global $USER; + $mailinfo = optional_param('mailinfo', null, PARAM_BOOL); + if (is_null($mailinfo)) { + $mailinfo = get_user_preferences('assignment_mailinfo', 0); + } else { + set_user_preference('assignment_mailinfo', $mailinfo); + } + switch ($mode) { case 'grade': // We are in a popup window grading if ($submission = $this->process_feedback()) { @@ -512,6 +519,8 @@ class assignment_base { case 'fastgrade': ///do the fast grading stuff - this process should work for all 3 subclasses + + $mailinfo = get_user_preferences('assignment_mailinfoqg', 1); $grading = false; $commenting = false; $col = false; @@ -528,6 +537,7 @@ class assignment_base { $this->display_submissions(); break; } + foreach ($_POST[$col] as $id => $unusedvalue){ $id = (int)$id; //clean parameter name @@ -564,7 +574,10 @@ class assignment_base { } $submission->teacher = $USER->id; - $submission->mailed = $updatedb?0:$submission->mailed;//only change if it's an update + if ($updatedb) { + $submission->mailed = (int)(!$mailinfo); + } + $submission->timemarked = time(); //if it is not an update, we don't change the last modified time etc. @@ -921,7 +934,11 @@ class assignment_base { } } + $lastmailinfo = get_user_preferences('assignment_mailinfo', 1) ? 'checked="checked"' : ''; + ///Print Buttons in Single View + echo ''; + echo ''; echo '
'; echo ''; echo ''; @@ -993,7 +1010,8 @@ class assignment_base { $perpage = optional_param('perpage', 10, PARAM_INT); $perpage = ($perpage <= 0) ? 10 : $perpage ; set_user_preference('assignment_perpage', $perpage); - set_user_preference('assignment_quickgrade', optional_param('quickgrade',0, PARAM_BOOL)); + set_user_preference('assignment_quickgrade', optional_param('quickgrade', 0, PARAM_BOOL)); + set_user_preference('assignment_mailinfoqg', optional_param('mailinfoqg', 0, PARAM_BOOL)); } /* next we get perpage and quickgrade (allow quick grade) params @@ -1291,7 +1309,6 @@ class assignment_base { echo ''; echo ''; echo '
'; - //echo '
'; } $table->print_html(); /// Print the whole table @@ -1303,22 +1320,20 @@ class assignment_base { /// End of fast grading form /// Mini form for setting user preference - echo '
'; - echo '
'; - echo '
'; - echo ''; - echo ''; - echo '
'; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; - echo ''; - echo ''; + echo ''; echo ''; - echo ''; - echo ''; + echo '
'; echo ''; - echo ':'; echo ''; helpbutton('pagesize', get_string('pagesize','assignment'), 'assignment'); echo '
'; + echo '
'; print_string('quickgrade','assignment'); - echo ':'; if ($quickgrade){ echo ''; @@ -1327,12 +1342,16 @@ class assignment_base { } helpbutton('quickgrade', get_string('quickgrade', 'assignment'), 'assignment').'

'; echo '
'; + echo '
'; + $lastmailinfoqg = get_user_preferences('assignment_mailinfoqg', 1) ? 'checked="checked"' : ''; + echo ''; + echo ''; + helpbutton('emailnotification', get_string('emailnotification', 'assignment'), 'assignment').'

'; + echo '
'; echo ''; echo '
'; - echo '
'; - echo ''; + echo '
'; ///End of mini form print_footer($this->course); } @@ -1377,7 +1396,12 @@ class assignment_base { $submission->submissioncomment = $feedback->submissioncomment; $submission->format = $feedback->format; $submission->teacher = $USER->id; - $submission->mailed = 0; // Make sure mail goes out (again, even) + $mailinfo = get_user_preferences('assignment_mailinfo', 0); + if (!$mailinfo) { + $submission->mailed = 1; // treat as already mailed + } else { + $submission->mailed = 0; // Make sure mail goes out (again, even) + } $submission->timemarked = time(); unset($submission->data1); // Don't need to update this. diff --git a/mod/assignment/styles.php b/mod/assignment/styles.php index 7b9153637d..17b9ad761a 100644 --- a/mod/assignment/styles.php +++ b/mod/assignment/styles.php @@ -159,3 +159,8 @@ text-align: center; vertical-align: top; } + +#mod-assignment-submissions .qgprefs #optiontable { + text-align:right; + margin-left:auto; +} diff --git a/mod/assignment/type/offline/assignment.class.php b/mod/assignment/type/offline/assignment.class.php index d35ce7a69a..49c32a730d 100644 --- a/mod/assignment/type/offline/assignment.class.php +++ b/mod/assignment/type/offline/assignment.class.php @@ -70,7 +70,12 @@ class assignment_offline extends assignment_base { $submission->submissioncomment = $feedback->submissioncomment; $submission->format = $feedback->format; $submission->teacher = $USER->id; - $submission->mailed = 0; // Make sure mail goes out (again, even) + $mailinfo = get_user_preferences('assignment_mailinfo', 0); + if (!$mailinfo) { + $submission->mailed = 1; // treat as already mailed + } else { + $submission->mailed = 0; // Make sure mail goes out (again, even) + } $submission->timemarked = time(); unset($submission->data1); // Don't need to update this.