Ejemplo n.º 1
0
function mailDeleteSubmit($user_id, $assn_json, $note)
{
    global $CFG, $PDOX;
    if (!isset($CFG->maildomain) || $CFG->maildomain === false) {
        return false;
    }
    $LTI = LTIX::requireData();
    $user_row = loadUserInfoBypass($user_id);
    if ($user_row === false) {
        return false;
    }
    $to = $user_row['email'];
    if (strlen($to) < 1 || strpos($to, '@') === false) {
        return false;
    }
    $name = $user_row['displayname'];
    $token = computeMailCheck($user_id);
    $subject = 'From ' . $CFG->servicename . ', Your Peer Graded Entry Has Been Reset';
    $E = "\n";
    if (isset($CFG->maileol)) {
        $E = $CFG->maileol;
    }
    $message = "This is an automated message.  Your peer-graded entry has been reset.{$E}{$E}";
    if (isset($LTI['context_title'])) {
        $message .= 'Course Title: ' . $LTI['context_title'] . $E;
    }
    if (isset($LTI['link_title'])) {
        $message .= 'Assignment: ' . $LTI['link_title'] . $E;
    }
    if (isset($LTI['user_displayname'])) {
        $message .= 'Staff member doing reset: ' . $LTI['user_displayname'] . $E;
    }
    $fixnote = trim($note);
    if (strlen($fixnote) > 0) {
        if ($E != "\n") {
            $fixnote = str_replace("\n", $E, $fixnote);
        }
        $message .= "Notes regarding this action:" . $E . $fixnote . $E;
    }
    $message .= "{$E}You may now re-submit your peer-graded assignment.{$E}";
    $stmt = $PDOX->queryDie("INSERT INTO {$CFG->dbprefix}mail_sent\n            (context_id, link_id, user_to, user_from, subject, body, created_at)\n            VALUES ( :CID, :LID, :UTO, :UFR, :SUB, :BOD, NOW() )", array(":CID" => $LTI['context_id'], ":LID" => $LTI['link_id'], ":UTO" => $user_id, ":UFR" => $LTI['user_id'], ":SUB" => $subject, ":BOD" => $message));
    // echo $to, $subject, $message, $user_id, $token;
    $retval = mailSend($to, $subject, $message, $user_id, $token);
    return $retval;
}
Ejemplo n.º 2
0
} else {
    if ($USER->instructor && isset($_GET['link_id'])) {
        $query_parms = array(":LID" => $link_id, ":CID" => $CONTEXT->id);
        $searchfields = array("R.user_id", "displayname", "grade", "R.updated_at", "server_grade", "retrieved_at");
        $class_sql = "SELECT R.user_id AS user_id, displayname, grade,\n            R.updated_at as updated_at, server_grade, retrieved_at\n        FROM {$p}lti_result AS R JOIN {$p}lti_link as L\n            ON R.link_id = L.link_id\n        JOIN {$p}lti_user as U\n            ON R.user_id = U.user_id\n        WHERE R.link_id = :LID AND L.context_id = :CID AND R.grade IS NOT NULL";
    } else {
        // Gets grades for the current or specified
        $user_id = $USER->id;
        if ($USER->instructor && isset($_GET['user_id'])) {
            $user_id = $_GET['user_id'] + 0;
        }
        // http://stackoverflow.com/questions/5602907/calculate-difference-between-two-datetimes
        $query_parms = array(":UID" => $user_id, ":CID" => $CONTEXT->id);
        $searchfields = array("L.title", "R.grade", "R.note", "R.updated_at", "retrieved_at");
        $user_sql = "SELECT R.result_id AS result_id, L.title as title, R.grade AS grade, R.note AS note,\n            R.updated_at as updated_at, server_grade, retrieved_at, sourcedid, service_key as service,\n            TIMESTAMPDIFF(SECOND,retrieved_at,NOW()) as diff_in_seconds, NOW() AS time_now\n        FROM {$p}lti_result AS R\n        JOIN {$p}lti_link as L ON R.link_id = L.link_id\n        JOIN {$p}lti_service AS S ON R.service_id = S.service_id\n        WHERE R.user_id = :UID AND L.context_id = :CID AND R.grade IS NOT NULL";
        $user_info = loadUserInfoBypass($user_id);
    }
}
if ($USER->instructor) {
    $lstmt = $PDOX->queryDie("SELECT DISTINCT L.title as title, L.link_id AS link_id\n        FROM {$p}lti_link AS L JOIN {$p}lti_result as R\n            ON L.link_id = R.link_id AND R.grade IS NOT NULL\n        WHERE L.context_id = :CID", array(":CID" => $CONTEXT->id));
    $links = $lstmt->fetchAll();
}
// View
$OUTPUT->header();
$OUTPUT->bodyStart();
$OUTPUT->flashMessages();
if ($USER->instructor) {
    ?>
  <a href="index.php?viewall=yes" class="btn btn-default">Class Summary</a>
  <a href="index.php" class="btn btn-default">My Grades</a>
<?php 
Ejemplo n.º 3
0
if ($row !== false) {
    $assn_json = json_decode($row['json']);
    $assn_id = $row['assn_id'];
}
if ($assn_id === false) {
    $_SESSION['error'] = "This assignment is not yet set up.";
    header('Location: ' . addSession('index.php'));
    return;
}
$submit_id = false;
$submit_row = loadSubmission($assn_id, $user_id);
if ($submit_row !== false) {
    $submit_id = $submit_row['submit_id'] + 0;
}
// Load user info
$user_row = loadUserInfoBypass($user_id);
if ($user_row == false) {
    $_SESSION['error'] = "Could not load student data.";
    header('Location: ' . addSession('index.php'));
    return;
}
// Handle incoming post to delete the entire submission
if (isset($_POST['deleteSubmit'])) {
    if ($submit_id == false) {
        $_SESSION['error'] = "Could not load submission.";
        header('Location: ' . addSession('index.php'));
        return;
    }
    $note = isset($_POST['deleteNote']) ? $_POST['deleteNote'] : '';
    $retval = mailDeleteSubmit($user_id, $assn_json, $note);
    $stmt = $PDOX->queryDie("DELETE FROM {$p}peer_submit\n            WHERE submit_id = :SID", array(':SID' => $submit_id));