Example #1
0
 /**
  * Retrieve an array of all of the link level settings
  *
  * If there are no settings, return an empty array.  
  *
  * This routine also looks for legacy custom fields and treats
  * them as defaults for settings if the corresponding key is not
  * already present in settings.  This will slowly convert LTI 
  * 1.x custom parameters under the control of the LMS to LTI 2.x 
  * style settings under control of our local tools.
  */
 public static function linkGetAll()
 {
     global $CFG, $PDOX, $LINK;
     if (!isset($_SESSION['lti'])) {
         return array();
     }
     if (isset($_SESSION['lti']['link_settings_merge'])) {
         return $_SESSION['lti']['link_settings_merge'];
     }
     $legacy_fields = array('dologin', 'close', 'due', 'timezone', 'penalty_time', 'penalty_cost');
     $defaults = array();
     foreach ($legacy_fields as $k) {
         $value = LTIX::customGet($k);
         $defaults[$k] = $value;
     }
     if (isset($_SESSION['lti']['link_settings'])) {
         $json = $_SESSION['lti']['link_settings'];
         if (strlen($json) < 0) {
             return $defaults;
         }
         $retval = json_decode($json, true);
         // No objects
         $retval = array_merge($defaults, $retval);
         $_SESSION['lti']['link_settings_array'] = $retval;
         return $retval;
     }
     // Not in session - retrieve from the database
     // We cannot assume the $LINK is fully set up yet...
     if (!isset($_SESSION['lti']['link_id'])) {
         return $defaults;
     }
     $row = $PDOX->rowDie("SELECT settings FROM {$CFG->dbprefix}lti_link WHERE link_id = :LID", array(":LID" => $_SESSION['lti']['link_id']));
     if ($row === false) {
         return $defaults;
     }
     $json = $row['settings'];
     if ($json === null) {
         return $defaults;
     }
     $retval = json_decode($json, true);
     // No objects
     $retval = array_merge($defaults, $retval);
     // Store in session for later
     $_SESSION['lti']['link_settings'] = $json;
     $_SESSION['lti']['link_settings_array'] = $retval;
     return $retval;
 }
Example #2
0
count = 0
for line in fh:
    print line.strip()
    count = count + 1

print count,"Lines"';
$CHECKS = false;
$EX = false;

// Check which exercise we are supposed to do - settings, then custom, then 
// GET
if ( isset($oldsettings['exercise']) && $oldsettings['exercise'] != '0' ) {
    $ex = $oldsettings['exercise'];
} else {
    $ex = LTIX::customGet('exercise');
}
if ( $ex === false && isset($_REQUEST["exercise"]) ) {
    $ex = $_REQUEST["exercise"];
}
if ( $ex !== false && $ex != "code" ) {
    if ( isset($EXERCISES[$ex]) ) $EX = $EXERCISES[$ex];
    if ( $EX !== false ) {
        $CODE = '';
        $QTEXT = $EX["qtext"];
        $DESIRED = $EX["desired"];
        $DESIRED2 = isset($EX["desired2"]) ? $EX["desired2"] : '';
        $DESIRED = rtrim($DESIRED);
        $DESIRED2 = rtrim($DESIRED2);
        if ( isset($EX["code"]) ) $CODE = $EX["code"];
        if ( isset($EX["checks"]) ) $CHECKS = json_encode($EX["checks"]);