]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-6591 Optional assignment graded email notification - based on patch by Gary Ander...
authorskodak <skodak>
Wed, 20 Feb 2008 17:50:32 +0000 (17:50 +0000)
committerskodak <skodak>
Wed, 20 Feb 2008 17:50:32 +0000 (17:50 +0000)
lang/en_utf8/assignment.php
lang/en_utf8/help/assignment/emailnotification.html [new file with mode: 0644]
mod/assignment/lib.php
mod/assignment/styles.php
mod/assignment/type/offline/assignment.class.php

index 01286a4191439bf1498c2b6363cae01d8347fd02..d24529d9df3fff01d22004e74cb929058e1e40bb 100644 (file)
@@ -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 (file)
index 0000000..1b913fa
--- /dev/null
@@ -0,0 +1,6 @@
+<h1>Send notification email</h1>
+
+<p>Do you want to nofify students about received grades and feedback via email?</p>
+
+<p>Your preference is saved and will apply to all assignments in all courses.</p>
+
index 79b790ddbf9bf409a77c18bfa86cfb76dd0bcfe3..e8716fceb65f4a65f27c40b62a2d2ae6c7b50da6 100644 (file)
@@ -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 '<input type="hidden" name="mailinfo" value="0" />';
+        echo '<input type="checkbox" id="mailinfo" name="mailinfo" value="1" '.$lastmailinfo.' /><label for="mailinfo">'.get_string('emailnotification','assignment').'</label>';
         echo '<div class="buttons">';
         echo '<input type="submit" name="submit" value="'.get_string('savechanges').'" onclick = "document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex" />';
         echo '<input type="submit" name="cancel" value="'.get_string('cancel').'" />';
@@ -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 '<input type="hidden" name="mode" value="fastgrade" />';
             echo '<input type="hidden" name="page" value="'.$page.'" />';
             echo '</div>';
-            //echo '<div style="text-align:center"><input type="submit" name="fastg" value="'.get_string('saveallfeedback', 'assignment').'" /></div>';
         }
 
         $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 '<br />';
-        echo '<form id="options" action="submissions.php?id='.$this->cm->id.'" method="post">';
-        echo '<div>';
-        echo '<input type="hidden" id="updatepref" name="updatepref" value="1" />';
-        echo '<table id="optiontable" align="right">';
-        echo '<tr align="right"><td>';
+        echo '<div class="qgprefs">';
+        echo '<form id="options" action="submissions.php?id='.$this->cm->id.'" method="post"><div>';
+        echo '<input type="hidden" name="updatepref" value="1" />';
+        echo '<table id="optiontable">';
+        echo '<tr><td>';
         echo '<label for="perpage">'.get_string('pagesize','assignment').'</label>';
-        echo ':</td>';
+        echo '</td>';
         echo '<td>';
         echo '<input type="text" id="perpage" name="perpage" size="1" value="'.$perpage.'" />';
         helpbutton('pagesize', get_string('pagesize','assignment'), 'assignment');
         echo '</td></tr>';
-        echo '<tr align="right">';
-        echo '<td>';
+        echo '<tr><td>';
         print_string('quickgrade','assignment');
-        echo ':</td>';
+        echo '</td>';
         echo '<td>';
         if ($quickgrade){
             echo '<input type="checkbox" name="quickgrade" value="1" checked="checked" />';
@@ -1327,12 +1342,16 @@ class assignment_base {
         }
         helpbutton('quickgrade', get_string('quickgrade', 'assignment'), 'assignment').'</p></div>';
         echo '</td></tr>';
-        echo '<tr>';
-        echo '<td colspan="2" align="right">';
+        echo '<tr><td>';
+        $lastmailinfoqg = get_user_preferences('assignment_mailinfoqg', 1) ? 'checked="checked"' : '';
+        echo '<label for="mailinfoqg">'.get_string('emailnotification','assignment').'</label></td><td>';
+        echo '<input type="checkbox" id="mailinfoqg" name="mailinfoqg" value="1" '.$lastmailinfoqg.' />';
+        helpbutton('emailnotification', get_string('emailnotification', 'assignment'), 'assignment').'</p></div>';
+        echo '</td></tr>';
+        echo '<tr><td colspan="2">';
         echo '<input type="submit" value="'.get_string('savepreferences').'" />';
         echo '</td></tr></table>';
-        echo '</div>';
-        echo '</form>';
+        echo '</div></form></div>';
         ///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.
index 7b9153637d3156265eda98da0a287189d0d55d74..17b9ad761a65cbb4e66a5a3bd41199d17917ca61 100644 (file)
   text-align: center;
   vertical-align: top;
 }
+
+#mod-assignment-submissions .qgprefs #optiontable {
+    text-align:right;
+    margin-left:auto;
+}
index d35ce7a69af331f2bcb19e49cf5ab2a3e84cdd0b..49c32a730d98e8f18d97ffa28f15224733277771 100644 (file)
@@ -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.