Exemplo n.º 1
0
function feedback_email_teachers($cm, $feedback, $course, $userid)
{
    global $CFG;
    if ($feedback->email_notification == 0) {
        // No need to do anything
        return;
    }
    $user = get_record('user', 'id', $userid);
    if (groupmode($course, $cm) == SEPARATEGROUPS) {
        // Separate groups are being used
        if (!($group = user_group($course->id, $user->id))) {
            // Try to find a group
            $group->id = 0;
            // Not in a group, never mind
        }
        $teachers = get_group_teachers($course->id, $group->id);
        // Works even if not in group
    } else {
        $teachers = get_course_teachers($course->id);
    }
    if ($teachers) {
        $strfeedbacks = get_string('modulenameplural', 'feedback');
        $strfeedback = get_string('modulename', 'feedback');
        $strcompleted = get_string('completed', 'feedback');
        foreach ($teachers as $teacher) {
            unset($info);
            $info->username = fullname($user);
            $info->feedback = format_string($feedback->name, true);
            $info->url = $CFG->wwwroot . '/mod/feedback/show_entries.php?id=' . $cm->id . '&userid=' . $userid;
            $postsubject = $strcompleted . ': ' . $info->username . ' -> ' . $feedback->name;
            $posttext = feedback_email_teachers_text($info, $course);
            $posthtml = $teacher->mailformat == 1 ? feedback_email_teachers_html($info, $course, $cm) : '';
            @email_to_user($teacher, $user, $postsubject, $posttext, $posthtml);
        }
    }
}
    }
}
require_login($course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/certificate:view', $context);
// log update
add_to_log($course->id, "certificate", "view", "view.php?id={$cm->id}", $certificate->id, $cm->id);
// Get teacher name of group
if (groupmode($course, null) == SEPARATEGROUPS) {
    // Separate groups are being used
    if (!($group = user_group($course->id, $USER->id))) {
        // Try to find a group
        $group->id = 0;
        // Not in a group, never mind
    }
    $teachers = get_group_teachers($course->id, $group->id);
    // Works even if not in group
} else {
    $teachers = get_course_teachers($course->id);
}
//Creating pages
$generate = false;
$unenrolment = false;
$type = $certificate->certificatetype;
$certificateid = $certificate->id;
$certrecord = certificate_get_issue($course, $USER, $certificateid);
if ($certificate->printgrade > 1) {
    $modinfo = certificate_mod_grade($course, $certificate->printgrade);
}
//Review certificate
if ($certrecord and !isset($_GET['certificate'])) {
function certificate_email_teachers($certificate)
{
    global $course, $USER, $CFG;
    if ($certificate->emailteachers == 0) {
        // No need to do anything
        return;
    }
    $certrecord = certificate_get_issue($course, $USER, $certificate->id);
    $student = $certrecord->studentname;
    $cm = get_coursemodule_from_instance("certificate", $certificate->id, $course->id);
    if (groupmode($course, $cm) == SEPARATEGROUPS) {
        // Separate groups are being used
        if (!($group = user_group($course->id, $user->id))) {
            // Try to find a group
            $group->id = 0;
            // Not in a group, never mind
        }
        $teachers = get_group_teachers($course->id, $group->id);
        // Works even if not in group
    } else {
        $teachers = get_course_teachers($course->id);
    }
    if ($teachers) {
        $strcertificates = get_string('modulenameplural', 'certificate');
        $strcertificate = get_string('modulename', 'certificate');
        $strawarded = get_string('awarded', 'certificate');
        foreach ($teachers as $teacher) {
            unset($info);
            $info->student = $student;
            $info->course = format_string($course->fullname, true);
            $info->certificate = format_string($certificate->name, true);
            $info->url = $CFG->wwwroot . '/mod/certificate/report.php?id=' . $cm->id;
            $from = $student;
            $postsubject = $strawarded . ': ' . $info->student . ' -> ' . $certificate->name;
            $posttext = certificate_email_teachers_text($info);
            $posthtml = certificate_email_teachers_html($info);
            $posthtml = $teacher->mailformat == 1 ? certificate_email_teachers_html($info) : '';
            @email_to_user($teacher, $from, $postsubject, $posttext, $posthtml);
            // If it fails, oh well, too bad.
            set_field("certificate_issues", "mailed", "1", "certificateid", $certificate->id, "userid", $USER->id);
        }
    }
}
 /**
  * Alerts teachers by email of new or changed assignments that need grading
  *
  * First checks whether the option to email teachers is set for this assignment.
  * Sends an email to ALL teachers in the course (or in the group if using separate groups).
  * Uses the methods email_teachers_text() and email_teachers_html() to construct the content.
  * @param $submission object The submission that has changed
  */
 function email_teachers($submission)
 {
     global $CFG;
     if (empty($this->emailteachers)) {
         // 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
         if ($groups = user_group($this->course->id, $user->id)) {
             // Try to find groups
             $teachers = array();
             foreach ($groups as $group) {
                 $teachers = array_merge($teachers, get_group_teachers($this->course->id, $group->id));
             }
         } else {
             $teachers = get_group_teachers($this->course->id, 0);
             // Works even if not in group
         }
     } else {
         $teachers = get_course_teachers($this->course->id);
     }
     if ($teachers) {
         $strwebquestscorms = get_string('modulenameplural', 'webquestscorm');
         $strwebquestscorm = get_string('modulename', 'webquestscorm');
         $strsubmitted = get_string('submitted', 'webquestscorm');
         foreach ($teachers as $teacher) {
             unset($info);
             $info->username = fullname($user);
             $info->webquestscorm = format_string($this->wqname, true);
             $info->url = $CFG->wwwroot . '/mod/webquestscorm/editsubmissions.php?cmid=' . $this->cm->id . '&element=uploadedTasks&subelement=all';
             $postsubject = $strsubmitted . ': ' . $info->username . ' -> ' . $this->wqname;
             $posttext = $this->email_teachers_text($this->course->shortname, $this->wqname, $strwebquestscorms, $info);
             $posthtml = $teacher->mailformat == 1 ? $this->email_teachers_html($this->course->id, $this->course->shortname, $this->wqname, $strwebquestscorms, $this->cm->id, $info) : '';
             @email_to_user($teacher, $user, $postsubject, $posttext, $posthtml);
             // If it fails, oh well, too bad.
         }
     }
 }