Submit & Review: Emails not sent to students

Submit & Review: Emails not sent to students

by Joel Pheasant -
Number of replies: 4
We have the Submit & Review mod installed that allows you to send an assignment back to a student along with the grade and comments.  One of the options when setting up this assignment type allows you to indicate whether you would like notifications sent to the students.  I'm assuming this means that they would be notified when feedback/grade is entered by the teacher.  However, whenever we provide feedback, nothing seems to be sent to the student.  Has anyone else run into this problem or am I misunderstanding the functionality?

Thanks,
Joel
Average of ratings: -
In reply to Joel Pheasant

Re: Submit & Review: Emails not sent to students

by Gustav W Delius -
I have had a look at the code. The emailing functionality is simply commented out. I guess it was never fully implemented.
In reply to Gustav W Delius

Re: Submit & Review: Emails not sent to students

by Sunada _ -
Is this functionality going to be implemented at any point soon? It's actually a pretty important feature for us! Without it, it means the teacher has comb through everything to see if there's a new posting every day.
In reply to Gustav W Delius

Re: Submit & Review: Emails not sent to students

by Joel Pheasant -
Ok, I finally got a chance to work on this.  It looks as though they commented it out and left it incomplete.  After uncommenting it (and sending several emails to the wrong person), I realized that the commented code was just a copy of the code to send a message to the instructor when an assignment submitted.  It was not code to send a message to the student when the assignment was graded.  Once I realized that, here are the changes I made:

In mod/assignment/type/uploadreview/assignment.class.php, change the email_students() function to the following:

function email_students($submission) {
        /// Alerts students by email of assignments that recieve a new response
//    Email students when uploaded & when grade changed?  Currently only set to upload on comments and grades
        global $CFG;

        if (empty($this->assignment->var1)) {          // No need to do anything
            return;
        }

        $user = get_record('user', 'id', $submission->userid);

        if (groupmode($this->course, $this->cm) == SEPARATEGROUPS) {  
// Separate groups are being used
// Try to find a group
            if (!$group = user_group($this->course->id, $user->id)) {            
// Not in a group, never mind
                $group->id = 0;                                            
            }
            $teachers = get_group_teachers($this->course->id, $group->id);       
// Works even if not in group
       } else {
            $teachers = get_course_teachers($this->course->id);
        }

        if ($teachers) {
            $strassignments = get_string('modulenameplural', 'assignment');
            $strassignment  = get_string('modulename', 'assignment');
            $strsubmitted  = get_string('submitted', 'assignment');

            foreach ($teachers as $teacher) {
                unset($info);
                $info->teacher = fullname($teacher);
                $info->assignment = format_string($this->assignment->name,true);
                $info->url = $CFG->wwwroot.'/mod/assignment/view.php?id='.$this->cm->id;

                $postsubject = $strsubmitted.': '.$info->username.' -> '.$this->assignment->name;
                $posttext = $this->email_studentfeedback_text($info);
                $posthtml = ($teacher->mailformat == 1) ? $this->email_studentfeedback_html($info) : '';

                @email_to_user($user, $teacher, $postsubject, $posttext, $posthtml);  // If it fails, oh well, too

bad.
            }
        }
    }


Then, In mod/assignment/lib.php, add the following two functions:

    function email_studentfeedback_text($info) {
        $posttext  = $this->course->shortname.' -> '.$this->strassignments.' -> '.
                     format_string($this->assignment->name, true)."\n";
        $posttext .= '---------------------------------------------------------------------'."\n";
        $posttext .= get_string("assignmentmail", "assignment", $info)."\n";
        $posttext .= '---------------------------------------------------------------------'."\n";
        return $posttext;
    }


    function email_studentfeedback_html($info) {
        global $CFG;
        $posthtml  = '<p><font face="sans-serif">'.
                     '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$this->course->id.'">'.$this->course-

>shortname.'</a> ->'.
                     '<a href="'.$CFG->wwwroot.'/mod/assignment/index.php?id='.$this->course->id.'">'.$this-

>strassignments.'</a> ->'.
                     '<a href="'.$CFG->wwwroot.'/mod/assignment/view.php?id='.$this->cm->id.'">'.format_string($this-

>assignment->name,true).'</a></font></p>';
        $posthtml .= '<hr /><font face="sans-serif">';
        $posthtml .= '<p>'.get_string('assignmentmailhtml', 'assignment', $info).'</p>';
        $posthtml .= '</font><hr />';
        return $posthtml;
    }


I also changed it so that it would send the email when the teachers saved the grade instead of when they uploaded a response file.  To do this, in mod/assignment/type/uploadreview/assignment.class.php, function response_upload(), make the following change:

FROM:

if (update_record("assignment_submissions", $submission)) {
     $this->email_students($submission);       
//print_heading(get_string('uploadedfile'));
} else {
     notify(get_string("uploadfailnoupdate", "assignment"));
}

TO:
if (!update_record("assignment_submissions", $submission)) {
     notify(get_string("uploadfailnoupdate", "assignment"));
//print_heading(get_string('uploadedfile'));
} //else {
//                         $this->email_students($submission);       
//            

and in process_feedback(), this needs to be adjusted:

FROM:
if (! update_record('assignment_submissions', $newsubmission)) {
   return false;
}       

TO:
if (! update_record('assignment_submissions', $newsubmission)) {
   return false;
} else
   $this->email_students($newsubmission);       


I'm not sure if this is all clear, so feel free to drop me a note if it is confusing or if you notice something that won't work.
In reply to Joel Pheasant

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.