Example #1
0
function send_reminder($person)
{
    global $ini;
    $toEmail = $person['email'];
    if (!empty($ini['OVERRIDE_RECIPIENT'])) {
        $toEmail = $ini['OVERRIDE_RECIPIENT'];
    }
    if (!strlen($person['email'])) {
        if (!empty($ini['VERBOSE'])) {
            echo $person['first_name'] . ' ' . $person['last_name'] . " has no email address - skipping \n";
        }
        return;
    }
    $content = replace_keywords($ini['EMAIL_BODY'], $person);
    $html = nl2br($content);
    $message = Emailer::newMessage()->setSubject(replace_keywords($ini['SUBJECT'], $person))->setFrom(array($ini['FROM_ADDRESS'] => $ini['FROM_NAME']))->setTo(array($toEmail => $person['first_name'] . ' ' . $person['last_name']))->setBody($content)->addPart($html, 'text/html');
    if (!empty($person['cc'])) {
        $cc_names = explode(';', $person['cc_name']);
        foreach (explode(';', $person['cc']) as $i => $cc) {
            if (!empty($ini['OVERRIDE_RECIPIENT'])) {
                $message->addCC($ini['OVERRIDE_RECIPIENT'], $cc_names[$i]);
            } else {
                $message->addCC($cc, $cc_names[$i]);
            }
        }
    }
    $res = Emailer::send($message);
    if (!$res) {
        echo "Failed to send to {$toEmail} \n";
    } else {
        if (!empty($ini['VERBOSE'])) {
            echo "Sent reminder to " . $person['first_name'] . ' ' . $person['last_name'];
            if (!empty($person['cc'])) {
                echo " CC to " . $person['cc'];
            }
            echo "\n";
        }
    }
}
 $score = 0;
 // Print Quiz Attempt Review
 foreach ($attemptobj->get_question_ids($page) as $id) {
     $cnt++;
     $score += $attemptobj->get_question_score($id);
     $actual = $attemptobj->get_actual_id($id, false, $attemptobj->attempt_url($id, $page));
     $question = $DB->get_record('question', array('id' => $actual));
     $responses = get_question_actual_response($attemptobj->get_question($id), $attemptobj->get_question_state($id));
     echo "<tr class='odd'><td colspan='3'>Question: " . $cnt . "</td></tr>";
     echo "<tr>";
     // Question
     echo "<td>" . replace_keywords($attemptid, $question->questiontext) . "</td>";
     echo "<td>";
     // Answer
     foreach ($responses as $r) {
         echo replace_keywords($attemptid, $r);
     }
     echo "</td>";
     // Score
     echo "<td>" . $attemptobj->get_question_score($id) . "</td>";
     echo "</tr>";
 }
 echo "</tbody>";
 echo "<tfoot>";
 echo "<tr>";
 echo "<td colspan='2'>";
 echo "<a href='{$CFG->wwwroot}/'><font color='black'>Return to Main</font></a> | ";
 echo "<a href='{$CFG->wwwroot}/question/grades.php?courseid=" . $attemptobj->get_courseid() . "'>Return to Grades</a>";
 echo "</td>";
 echo "<td>{$score} / {$quiz->sumgrades}</td>";
 echo "</tr>";