Exemple #1
0
function gradeUpdateJson($newdata = false)
{
    global $CFG, $PDOX, $LINK;
    if ($newdata == false) {
        return;
    }
    if (is_string($newdata)) {
        $newdata = json_decode($newdata, true);
    }
    $LTI = LTIX::requireData(array(LTIX::LINK));
    $row = gradeLoad();
    $data = array();
    if ($row !== false && isset($row['json'])) {
        $data = json_decode($row['json'], true);
    }
    $changed = false;
    foreach ($newdata as $k => $v) {
        if (!isset($data[$k]) || $data[$k] != $v) {
            $data[$k] = $v;
            $changed = true;
        }
    }
    if ($changed === false) {
        return;
    }
    $jstr = json_encode($data);
    $stmt = $PDOX->queryDie("UPDATE {$CFG->dbprefix}lti_result SET json = :json, updated_at = NOW()\n            WHERE result_id = :RID", array(':json' => $jstr, ':RID' => $LINK->result_id));
}
Exemple #2
0
use \Tsugi\Core\Settings;
use \Tsugi\UI\SettingsForm;

// Sanity checks
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;

if ( SettingsForm::handleSettingsPost() ) {
    header( 'Location: '.addSession('index.php?howdysuppress=1') ) ;
    return;
}

$oldsettings = Settings::linkGetAll();

// Get the current user's grade data
$row = gradeLoad();
$OLDCODE = false;
$json = array();
$editor = 1;
if ( $row !== false && isset($row['json'])) {
    $json = json_decode($row['json'], true);
    if ( isset($json["code"]) ) $OLDCODE = $json["code"];
    if ( isset($json["editor"]) ) $editor = $json["editor"];
}

if ( isset($_GET['editor']) && ( $_GET['editor'] == '1' || $_GET['editor'] == '0' ) ) {
    $neweditor = $_GET['editor']+0;
    if ( $editor != $neweditor ) {
        gradeUpdateJson(array("editor" => $neweditor));
        $json['editor'] = $neweditor;
        $editor = $neweditor;
Exemple #3
0
<?php

require_once "../../config.php";
require_once $CFG->dirroot . "/pdo.php";
require_once $CFG->dirroot . "/lib/lms_lib.php";
require_once $CFG->dirroot . "/core/gradebook/lib.php";
session_start();
// Get the user's grade data also checks session
$row = gradeLoad($_REQUEST['user_id']);
// View
$OUTPUT->header();
$OUTPUT->bodyStart();
$OUTPUT->flashMessages();
// Show the basic info for this user
gradeShowInfo($row);
// Unique detail
echo "<p>Submission:</p>\n";
$json = json_decode($row['json']);
if (is_object($json) && isset($json->code)) {
    echo "<pre>\n";
    echo htmlent_utf8($json->code);
    echo "\n";
    echo "</pre>\n";
}
$OUTPUT->footer();