コード例 #1
0
ファイル: index.php プロジェクト: shaamimahmed/tsugi
use Tsugi\Core\LTIX;
use Tsugi\Core\Settings;
use Tsugi\UI\SettingsForm;
// Retrieve the launch data if present
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;
$displayname = $USER->displayname;
// Handle the incoming post saving the settings form
if (SettingsForm::handleSettingsPost()) {
    $_SESSION['debug_log'] = Settings::getDebugArray();
    header('Location: ' . addSession('index.php'));
    return;
}
// Handle our own manual set of the manual_key setting
if (isset($_POST['manual_key'])) {
    Settings::linkSet('manual_key', $_POST['manual_key']);
    $_SESSION['debug_log'] = Settings::getDebugArray();
    $_SESSION['success'] = "Setting updated";
    header('Location: ' . addSession('index.php'));
    return;
}
// Start of the output
$OUTPUT->header();
// Start of the view
$OUTPUT->bodyStart();
$OUTPUT->flashMessages();
// Place the settings button in the upper right.
if ($USER->instructor) {
    SettingsForm::button(true);
}
// Put out the hidden settings form using predefined UI routines
コード例 #2
0
ファイル: index.php プロジェクト: ixtel/tsugi
<?php

require_once "../../config.php";
require_once $CFG->dirroot . "/pdo.php";
require_once $CFG->dirroot . "/lib/lms_lib.php";
// The Tsugi PHP API Documentation is available at:
// http://do1.dr-chuck.com/tsugi/phpdoc/namespaces/Tsugi.html
use Tsugi\Core\Settings;
use Tsugi\Core\LTIX;
// No parameter means we require CONTEXT, USER, and LINK
$LTI = LTIX::requireData();
// Model
$p = $CFG->dbprefix;
$old_code = Settings::linkGet('code', '');
if (isset($_POST['code']) && isset($_POST['set']) && $USER->instructor) {
    Settings::linkSet('code', $_POST['code']);
    $_SESSION['success'] = 'Code updated';
    header('Location: ' . addSession('index.php'));
    return;
} else {
    if (isset($_POST['clear']) && $USER->instructor) {
        $rows = $PDOX->queryDie("DELETE FROM {$p}attend WHERE link_id = :LI", array(':LI' => $LINK->id));
        $_SESSION['success'] = 'Data cleared';
        header('Location: ' . addSession('index.php'));
        return;
    } else {
        if (isset($_POST['code'])) {
            // Student
            if ($old_code == $_POST['code']) {
                $PDOX->queryDie("INSERT INTO {$p}attend\n            (link_id, user_id, ipaddr, attend, updated_at)\n            VALUES ( :LI, :UI, :IP, NOW(), NOW() )\n            ON DUPLICATE KEY UPDATE updated_at = NOW()", array(':LI' => $LINK->id, ':UI' => $USER->id, ':IP' => $_SERVER["REMOTE_ADDR"]));
                $_SESSION['success'] = _('Attendance Recorded...');