--- /tmp/yfJp06_locallib.php
+++ /home/www/moodle26/mod/assign/locallib.php
@@ -1569,8 +1569,8 @@
 
         // Collect all submissions from the past 24 hours that require mailing.
         // Submissions are excluded if the assignment is hidden in the gradebook.
-        $sql = 'SELECT g.id as gradeid, a.course, a.name, a.blindmarking, a.revealidentities,
-                       g.*, g.timemodified as lastmodified
+        $sql = 'SELECT g.id as gradeid, a.course, a.name, a.blindmarking, a.revealidentities, a.markingworkflow,
+                       g.*, g.timemodified as lastmodified, uf.workflowstate
                  FROM {assign} a
                  JOIN {assign_grades} g ON g.assignment = a.id
             LEFT JOIN {assign_user_flags} uf ON uf.assignment = a.id AND uf.userid = g.userid
@@ -1675,6 +1675,14 @@
                 // Hold mail notification for hidden assignments until later.
                 continue;
             }
+            
+            // Skip assignments that have workflow enabled and the grade isn't released
+            if ($submission->markingworkflow
+            	&& (empty($submission->workflowstate)
+            	|| $submission->workflowstate != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED)) {
+            	continue;
+            }
+            
 
             // Need to send this to the student.
             $messagetype = 'feedbackavailable';
