Example #1
0
require_once "../../config.php";
require_once $CFG->dirroot . "/pdo.php";
require_once $CFG->dirroot . "/lib/lms_lib.php";
use Tsugi\Core\Settings;
use Tsugi\Core\LTIX;
use Tsugi\UI\SettingsForm;
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;
if (SettingsForm::handleSettingsPost()) {
    header('Location: ' . addSession('index.php'));
    return;
}
// All the assignments we support
$assignments = array('single_mysql.php' => 'Single Table MySQL (Users)', 'single_lite.php' => 'Single Table SQLITE (Users)', 'count_lite.php' => 'Email Counter SQLITE', 'many_one_lite.php' => 'Many-to-One SQLITE (Tracks)', 'many_many_mysql.php' => 'Many-to-Many MySQL (Courses)', 'many_many_lite.php' => 'Many-to-Many SQLITE (Courses)');
$oldsettings = Settings::linkGetAll();
$assn = Settings::linkGet('exercise');
// Get any due date information
$dueDate = SettingsForm::getDueDate();
// Let the assignment handle the POST
if (count($_POST) > 0 && $assn && isset($assignments[$assn])) {
    include $assn;
    return;
}
// View
$OUTPUT->header();
$OUTPUT->bodyStart();
// Settings button and dialog
echo '<span style="position: fixed; right: 10px; top: 5px;">';
if ($USER->instructor) {
    echo '<a href="grades.php" target="_blank"><button class="btn btn-info">Grade detail</button></a> ' . "\n";
Example #2
0
 /**
  * Handle a settings text box
  */
 public static function text($name, $title = false)
 {
     global $USER;
     $oldsettings = Settings::linkGetAll();
     $configured = isset($oldsettings[$name]) ? $oldsettings[$name] : false;
     if ($title === false) {
         $title = $name;
     }
     if (!$USER->instructor) {
         if ($configured === false) {
             echo '<p>Setting ' . htmlent_utf8($name) . ' is not set</p>';
         } else {
             echo '<p>' . htmlent_utf8(ucwords($name)) . ' is set to ' . htmlent_utf8($configured) . '</p>';
         }
         return;
     }
     // Instructor view
     echo '<label style="width:100%;" for="' . $name . '">' . htmlent_utf8($title) . "\n";
     echo '<input type="text" class="form-control" style="width:100%;" name="' . $name . '"';
     echo 'value="' . htmlent_utf8($configured) . '"></label>' . "\n";
 }
Example #3
0
 /**
  * Handle a settings text box
  */
 public static function text($name)
 {
     global $USER;
     $oldsettings = Settings::linkGetAll();
     $configured = isset($oldsettings[$name]) ? $oldsettings[$name] : false;
     if (!$USER->instructor) {
         if ($configured === false) {
             echo '<p>Setting ' . htmlent_utf8($name) . ' is not set</p>';
         } else {
             echo '<p>' . htmlent_utf8(ucwords($name)) . ' is set to ' . htmlent_utf8($configured) . '</p>';
         }
         return;
     }
     // Instructor view
     echo '<input type="text" size="80" name="' . $name . '"';
     echo 'value="' . htmlent_utf8($configured) . '">' . "\n";
 }