Beispiel #1
0
 public static function send($to, $subject, $message, $id, $token)
 {
     global $CFG;
     if (!isset($CFG->maildomain) || $CFG->maildomain === false) {
         return;
     }
     if (isset($CFG->maileol) && isset($CFG->wwwroot) && isset($CFG->maildomain)) {
         // All good
     } else {
         die_with_error_log("Incomplete mail configuration in mailSend");
     }
     if (strlen($to) < 1 || strlen($subject) < 1 || strlen($id) < 1 || strlen($token) < 1) {
         return false;
     }
     $EOL = $CFG->maileol;
     $maildomain = $CFG->maildomain;
     $manage = $CFG->wwwroot . "/profile.php";
     $unsubscribe_url = Output::getUtilUrl("/unsubscribe.php?id={$id}&token={$token}");
     $msg = $message;
     if (substr($msg, -1) != "\n") {
         $msg .= "\n";
     }
     // $msg .= "\nYou can manage your mail preferences at $manage \n";
     // TODO: Make unsubscribe work
     // echo $msg;
     $headers = "From: no-reply@{$maildomain}" . $EOL . "Return-Path: <bounced-{$id}-{$token}@{$maildomain}>" . $EOL . "List-Unsubscribe: <{$unsubscribe_url}>" . $EOL . 'X-Mailer: PHP/' . phpversion();
     error_log("Mail to: {$to} {$subject}");
     // echo $headers;
     return mail($to, $subject, $msg, $headers);
 }
Beispiel #2
0
 /**
  * Dump out the internal data structures associated with the
  * current launch.  Best if used within a pre tag.
  */
 public function var_dump()
 {
     var_dump($this);
     echo "\n<hr/>\n";
     echo "Session data (low level):\n";
     if (!isset($_SESSION)) {
         echo "Not set\n";
     } else {
         echo Output::safe_var_dump($_SESSION);
     }
 }
Beispiel #3
0
 public static function getAccessUrlForBlob($blob_id, $serv_file = false)
 {
     global $CFG;
     if ($serv_file !== false) {
         return $serv_file . '?id=' . $blob_id;
     }
     $url = Output::getUtilUrl('/blob_serve.php?id=' . $blob_id);
     return $url;
 }
Beispiel #4
0
 /**
  * Send a grade applying the due date logic and only increasing grades
  *
  * Puts messages in the session for a redirect.
  *
  * @param $gradetosend - The grade in the range 0.0 .. 1.0
  * @param $oldgrade - The previous grade in the range 0.0 .. 1.0 (optional)
  * @param $dueDate - The due date for this assignment
  */
 public function gradeSendDueDate($gradetosend, $oldgrade = false, $dueDate = false)
 {
     if ($gradetosend == 1.0) {
         $scorestr = "Your answer is correct, score saved.";
     } else {
         $scorestr = "Your score of " . $gradetosend * 100.0 . "% has been saved.";
     }
     if ($dueDate && $dueDate->penalty > 0) {
         $gradetosend = $gradetosend * (1.0 - $dueDate->penalty);
         $scorestr = "Effective Score = " . $gradetosend * 100.0 . "% after " . $dueDate->penalty * 100.0 . " percent late penalty";
     }
     if ($oldgrade && $oldgrade > $gradetosend) {
         $scorestr = "New score of " . $gradetosend * 100.0 . "% is < than previous grade of " . $oldgrade * 100.0 . "%, previous grade kept";
         $gradetosend = $oldgrade;
     }
     // Use LTIX to store the grade in out database send the grade back to the LMS.
     $debug_log = array();
     $retval = $this->gradeSend($gradetosend, false, $debug_log);
     $_SESSION['debug_log'] = $debug_log;
     if ($retval === true) {
         $_SESSION['success'] = $scorestr;
     } else {
         if ($retval === false) {
             // Stored locally
             $_SESSION['success'] = $scorestr;
         } else {
             if (is_string($retval)) {
                 $_SESSION['error'] = "Grade not sent: " . $retval;
             } else {
                 $svd = Output::safe_var_dump($retval);
                 error_log("Grade sending error:" . $svd);
                 $_SESSION['error'] = "Grade sending error: " . substr($svd, 0, 100);
             }
         }
     }
 }
Beispiel #5
0
<?php

require_once "../../../../config.php";
require_once $CFG->vendorinclude . "/lms_lib.php";
use Tsugi\Core\LTIX;
use Tsugi\UI\Output;
Output::headerJson();
// Nothing for us to do
if (!isset($_GET[session_name()])) {
    echo json_encode(array("error" => "No session"));
    return;
}
if (isset($_COOKIE[session_name()])) {
    echo json_encode(array("status" => 'done'));
    return;
}
if (!isset($_GET['top'])) {
    echo json_encode(array("error" => "Need top= parameter"));
    return;
}
// Grab the session
$LAUNCH = LTIX::requireData(LTIX::USER);
// This has already been set by someone so nothing to do
if (isset($_COOKIE['TSUGI_TOP_SESSION'])) {
    unset($_SESSION['TOP_CHECK']);
    // No point in further checks
    echo json_encode(array("top_session" => $_COOKIE['TSUGI_TOP_SESSION']));
    return;
}
// We are not the top frame
if ($_GET['top'] != 'true') {
Beispiel #6
0
 /**
  * getLaunchData - Get the launch data for am LTI ContentItem launch
  */
 public static function getLaunchUrl($endpoint, $debug = false)
 {
     $launchurl = Output::getUtilUrl('/launch.php?debug=');
     $launchurl .= $debug ? '1' : '0';
     $launchurl .= '&endpoint=';
     $launchurl .= urlencode($endpoint);
     return $launchurl;
 }
Beispiel #7
0
<?php

if (isset($_GET[session_name()])) {
    $cookie = false;
} else {
    define('COOKIE_SESSION', true);
    $cookie = true;
}
require_once "../../../../config.php";
\Tsugi\UI\Output::handleHeartBeat($cookie);