当前位置: 首页>>代码示例>>PHP>>正文


PHP Core\LTIX类代码示例

本文整理汇总了PHP中Tsugi\Core\LTIX的典型用法代码示例。如果您正苦于以下问题:PHP LTIX类的具体用法?PHP LTIX怎么用?PHP LTIX使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LTIX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gradeTable

 public static function gradeTable($GRADE_DETAIL_CLASS)
 {
     global $CFG, $OUTPUT, $USER, $LINK;
     // Require CONTEXT, USER, and LINK
     $LAUNCH = LTIX::requireData();
     if (!$USER->instructor) {
         die("Requires instructor role");
     }
     $p = $CFG->dbprefix;
     // Get basic grade data
     $query_parms = array(":LID" => $LINK->id);
     $orderfields = array("R.updated_at", "displayname", "email", "grade");
     $searchfields = $orderfields;
     $sql = "SELECT R.user_id AS user_id, displayname, email,\n                grade, note, R.updated_at AS updated_at\n            FROM {$p}lti_result AS R\n            JOIN {$p}lti_user AS U ON R.user_id = U.user_id\n            WHERE R.link_id = :LID";
     // View
     $OUTPUT->header();
     $OUTPUT->bodyStart();
     $OUTPUT->flashMessages();
     $OUTPUT->welcomeUserCourse();
     if (isset($GRADE_DETAIL_CLASS) && is_object($GRADE_DETAIL_CLASS)) {
         $detail = $GRADE_DETAIL_CLASS;
     } else {
         $detail = false;
     }
     Table::pagedAuto($sql, $query_parms, $searchfields, $orderfields, "grade-detail.php");
     // Since this is in a popup, put out a done button
     $OUTPUT->closeButton();
     $OUTPUT->footer();
 }
开发者ID:csev,项目名称:tsugi-php,代码行数:29,代码来源:UI.php

示例2: gradeUpdateJson

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));
}
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:28,代码来源:lib.php

示例3: serveContent

 public static function serveContent()
 {
     global $CFG, $CONTEXT, $PDOX;
     // Sanity checks
     $LAUNCH = LTIX::requireData(LTIX::CONTEXT);
     $id = $_REQUEST['id'];
     if (strlen($id) < 1) {
         die("File not found");
     }
     $p = $CFG->dbprefix;
     $stmt = $PDOX->prepare("SELECT contenttype, content, file_name FROM {$p}blob_file\n                    WHERE file_id = :ID AND context_id = :CID");
     $stmt->execute(array(":ID" => $id, ":CID" => $CONTEXT->id));
     $row = $stmt->fetch(\PDO::FETCH_ASSOC);
     if ($row === false) {
         error_log('File not loaded: ' . $id);
         die("File not loaded");
     }
     if (!BlobUtil::safeFileSuffix($row['file_name'])) {
         error_log('Unsafe file suffix: ' . $row['file_name']);
         die('Unsafe file suffix');
     }
     $mimetype = $row['contenttype'];
     // die($mimetype);
     if (strlen($mimetype) > 0) {
         header('Content-Type: ' . $mimetype);
     }
     // header('Content-Disposition: attachment; filename="'.$fn.'"');
     // header('Content-Type: text/data');
     echo $row['content'];
 }
开发者ID:csev,项目名称:tsugi-php,代码行数:30,代码来源:Access.php

示例4: linkGetAll

 /**
  * 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;
 }
开发者ID:csev,项目名称:tsugi-php,代码行数:58,代码来源:Settings.php

示例5: webauto_test_passed

function webauto_test_passed($grade, $url)
{
    global $USER, $OUTPUT;
    success_out("Test passed - congratulations");
    if ($USER->displayname === false || !isset($_SESSION['lti'])) {
        line_out('Not setup to return a grade..');
        return false;
    }
    $LTI = $_SESSION['lti'];
    $old_grade = isset($LTI['grade']) ? $LTI['grade'] : 0.0;
    if ($grade < $old_grade) {
        line_out('New grade is not higher than your previous grade=' . $old_grade);
        line_out('Sending your previous high score');
        $grade = $old_grade;
    }
    gradeUpdateJson(json_encode(array("url" => $url)));
    $debug_log = array();
    $retval = LTIX::gradeSend($grade, false, $debug_log);
    $OUTPUT->dumpDebugArray($debug_log);
    if ($retval == true) {
        $success = "Grade sent to server (" . $grade . ")";
    } else {
        if (is_string($retval)) {
            $failure = "Grade not sent: " . $retval;
        } else {
            echo "<pre>\n";
            var_dump($retval);
            echo "</pre>\n";
            $failure = "Internal error";
        }
    }
    if (strlen($success) > 0) {
        success_out($success);
        error_log($success);
    } else {
        if (strlen($failure) > 0) {
            error_out($failure);
            error_log($failure);
        } else {
            error_log("No status");
        }
    }
    return true;
}
开发者ID:ixtel,项目名称:tsugi,代码行数:44,代码来源:webauto.php

示例6: isset

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"]);
开发者ID:JANQLIANGTSAI,项目名称:tsugi,代码行数:30,代码来源:index.php

示例7: die

require_once "names.php";
require_once "locations.php";
use Tsugi\Core\LTIX;
use Tsugi\Util\LTI;
use Tsugi\Util\Net;
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;
if (!$USER->instructor) {
    die('Must be instructor');
}
$sanity = array('urllib' => 'You should use urllib to retrieve the data from the API', 'urlencode' => 'You should use urlencode add parameters to the API url', 'json' => 'You should use the json library to parse the API data');
echo "<pre>\n";
echo "Running test...\n";
// Run though all the locations
// var_dump($LOCATIONS);
$url = LTIX::curPageUrlScript();
$i = 500;
foreach ($LOCATIONS as $key => $location) {
    // echo(htmlentities($location)."\n");
    $api_url = str_replace('geo_test.php', 'data/geojson', $url);
    $sample_url = $api_url . '?sensor=false&address=' . urlencode($location);
    $sample_data = Net::doGet($sample_url);
    $sample_count = strlen($sample_data);
    $response = Net::getLastHttpResponse();
    $sample_json = json_decode($sample_data);
    if ($response != 200 || $sample_json == null || !isset($sample_json->results[0])) {
        echo "*** Bad response={$response} url={$sample_url} json_error=" . json_last_error_msg() . "\n";
        echo jsonIndent($sample_data);
        continue;
    }
    // echo("<pre>\n");echo(jsonIndent(json_encode($sample_json)));echo("</pre>\n");
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:geo_test.php

示例8: unset

    }
    unset($_SESSION['peer_submit_id']);
    $submit_id = $_POST['submit_id'] + 0;
    $stmt = $PDOX->queryReturnError("INSERT INTO {$p}peer_grade\n            (submit_id, user_id, points, note, created_at, updated_at)\n            VALUES ( :SID, :UID, :POINTS, :NOTE, NOW(), NOW())\n            ON DUPLICATE KEY UPDATE points = :POINTS, note = :NOTE, updated_at = NOW()", array(':SID' => $submit_id, ':UID' => $USER->id, ':POINTS' => $points, ':NOTE' => $_POST['note']));
    Cache::clear('peer_grade');
    if (!$stmt->success) {
        $_SESSION['error'] = $stmt->errorImplode;
        header('Location: ' . addSession($url_goback));
        return;
    }
    // Attempt to update the user's grade, may take a second..
    $grade = computeGrade($assn_id, $assn_json, $user_id);
    $_SESSION['success'] = 'Grade submitted';
    if ($grade > 0) {
        $result = lookupResult($LTI, $user_id);
        $status = LTIX::gradeSend($grade, $result);
        // This is the slow bit
        if ($status === true) {
            $_SESSION['success'] = 'Grade submitted to server';
        } else {
            error_log("Problem sending grade " . $status);
        }
    }
    header('Location: ' . addSession($url_goback));
    return;
}
unset($_SESSION['peer_submit_id']);
$submit_id = false;
$submit_json = null;
if ($user_id === false) {
    // Load the the 10 oldest ungraded submissions
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:grade.php

示例9: flush

 if ($status === true) {
     echo 'Grade submitted to server' . "<br/>\n";
     $success++;
 } else {
     echo '<pre class="alert alert-danger">' . "\n";
     $msg = "result_id=" . $row['result_id'] . "\n" . "grade=" . $row['grade'] . " server_grade=" . $row['server_grade'] . "\n" . "error=" . $status;
     echo_log("Problem Sending Grade: " . session_id() . "\n" . $msg . "\n" . "result_url=" . $row['reult_url'] . " service_key=" . $row['service_key'] . " sourcedid=" . $row['sourcedid']);
     echo "</pre>\n";
     $OUTPUT->togglePre("Error retrieving new grade at " . $count, $LastPOXGradeResponse);
     flush();
     echo "Problem sending grade " . $status . "<br/>\n";
     $fail++;
     continue;
 }
 // Check to see if the grade we sent is really there - Also updates our local table
 $server_grade = LTIX::gradeGet($row);
 if (is_string($server_grade)) {
     echo '<pre class="alert alert-danger">' . "\n";
     $msg = "result_id=" . $row['result_id'] . "\n" . "grade=" . $row['grade'] . " updated=" . $row['updated_at'] . "\n" . "server_grade=" . $row['server_grade'] . " retrieved=" . $row['retrieved_at'] . "\n" . "error=" . $server_grade;
     echo_log("Problem Updating Grade: " . session_id() . "\n" . $msg . "\n" . "result_url=" . $row['reult_url'] . " service_key=" . $row['service_key'] . " sourcedid=" . $row['sourcedid']);
     echo "</pre>\n";
     error_log("Error re-retrieving grade: " . session_id() . ' result_id=' . $row['result_id'] . "result_url=" . $row['reult_url'] . ' sourcedid=' + $row['sourcedid'] + ' service_key=' + $row['service_key']);
     $OUTPUT->togglePre("Error retrieving new grade at " . $count, $LastPOXGradeResponse);
     flush();
     $fail++;
     continue;
 } else {
     if ($server_grade != $row['grade']) {
     } else {
     }
 }
开发者ID:ixtel,项目名称:tsugi,代码行数:31,代码来源:maint.php

示例10: unset

headerJson();
// Nothing for us to do
if (!isset($_GET[session_name()])) {
    echo json_encode(array("error" => "No session"));
    return;
}
if (isset($_COOKIE[session_name()])) {
    echo json_encode(array("status" => 'done'));
    return;
}
if (!isset($_GET['top'])) {
    echo json_encode(array("error" => "Need top= parameter"));
    return;
}
// Grab the session
$LTI = LTIX::requireData(LTIX::USER);
// This has already been set by someone so nothing to do
if (isset($_COOKIE['TSUGI_TOP_SESSION'])) {
    unset($_SESSION['TOP_CHECK']);
    // No point in further checks
    echo json_encode(array("top_session" => $_COOKIE['TSUGI_TOP_SESSION']));
    return;
}
// We are not the top frame
if ($_GET['top'] != 'true') {
    unset($_SESSION['TOP_CHECK']);
}
// No more checks are needed
if (!isset($_SESSION['TOP_CHECK']) || $_SESSION['TOP_CHECK'] < 1) {
    echo json_encode(array("status" => 'done'));
    return;
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:topstatus.php

示例11: lmsDie

// Sanity checks
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;
$OUTPUT->header();
$OUTPUT->bodyStart();
$OUTPUT->flashMessages();
$OUTPUT->welcomeUserCourse();
if (!$USER->instructor) {
    echo "<p>This tool must be launched by the instructor</p>";
    $OUTPUT->footer();
    exit;
}
// See https://canvas.instructure.com/doc/api/file.link_selection_tools.html
// Needed return values
$content_return_types = LTIX::postGet("ext_content_return_types", false);
$content_return_url = LTIX::postGet("ext_content_return_url", false);
if (strlen($content_return_url) < 1) {
    lmsDie("Missing ext_content_return_url");
}
if (strpos($content_return_types, "lti_launch_url") === false) {
    lmsDie("This tool requires ext_content_return_types=lti_launch_url");
}
// Scan the tools folders for registration settings
$tools = findFiles("register.php", "../");
if (count($tools) < 1) {
    lmsDie("No register.php files found...<br/>\n");
}
echo "<ul>\n";
$toolcount = 0;
foreach ($tools as $tool) {
    $path = str_replace("../", "", $tool);
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:canvas-content-item.php

示例12: jsonError

    $assn_json = json_decode($row['json']);
    $assn_id = $row['assn_id'];
}
if ($assn_id == false) {
    jsonError('This assignment is not yet set up');
    return;
}
// Compute the user's grade
$grade = computeGrade($assn_id, $assn_json, $user_id);
if ($grade <= 0) {
    jsonError('Nothing to grade for this user', $row);
    return;
}
// Lookup the result row if we are grading the non-current user
$result = false;
if ($user_id != $USER->id) {
    $result = lookupResult($LTI, $user_id);
}
// Send the grade
$debug_log = array();
$status = LTIX::gradeSend($grade, $result, $debug_log);
// This is the slow bit
if ($status === true) {
    if ($user_id != $USER->id) {
        jsonOutput(array("status" => $status, "debug" => $debug_log));
    } else {
        jsonOutput(array("status" => $status, "grade" => $grade, "debug" => $debug_log));
    }
} else {
    jsonError($status, $debug_log);
}
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:update_grade.php

示例13: isset

     echo "<h1>" . htmlent_utf8($title) . "</h1>\n";
     echo "<p>" . htmlent_utf8($text) . "</p>\n";
     $script = isset($REGISTER_LTI2['script']) ? $REGISTER_LTI2['script'] : "index.php";
     $path = $CFG->wwwroot . '/' . str_replace("register.php", $script, $path);
     // Title is for the href and text is for display
     $json = LTI::getLtiLinkJSON($path, $title, $title, false, $fa_icon);
     $retval = json_encode($json);
     $parms = array();
     $parms["lti_message_type"] = "ContentItemSelection";
     $parms["lti_version"] = "LTI-1p0";
     $parms["content_items"] = $retval;
     $data = LTIX::postGet('data');
     if ($data) {
         $parms['data'] = $data;
     }
     $parms = LTIX::signParameters($parms, $result_url, "POST", "Install Tool");
     $endform = '<a href="index.php" class="btn btn-warning">Back to Store</a>';
     $content = LTI::postLaunchHTML($parms, $result_url, true, false, $endform);
     echo $content;
 } else {
     echo '<div style="border: 2px, solid, red;" class="card">';
     if ($fa_icon) {
         echo '<a href="index.php?install=' . urlencode($tool) . '">';
         echo '<i class="fa ' . $fa_icon . ' fa-2x" style="color: #1894C7; float:right; margin: 2px"></i>';
         echo '</a>';
     }
     echo '<p><strong>' . htmlent_utf8($title) . "</strong></p>";
     echo '<p>' . htmlent_utf8($text) . "</p>\n";
     echo '<center><a href="index.php?install=' . urlencode($tool) . '" class="btn btn-default" role="button">Details</a></center>';
     echo "</div>\n";
 }
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:index.php

示例14: dataUrl

function dataUrl($file)
{
    global $GLOBAL_PYTHON_DATA_URL;
    if (is_string($GLOBAL_PYTHON_DATA_URL)) {
        return $GLOBAL_PYTHON_DATA_URL . $file;
    }
    $url = LTIX::curPageUrlScript();
    $retval = str_replace('index.php', 'data/' . $file, $url);
    return $retval;
}
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:10,代码来源:data_util.php

示例15: header

        header('Location: ' . addSession('student.php?user_id=' . $user_id));
    }
    return;
}
// Compute grade
$computed_grade = computeGrade($assn_id, $assn_json, $user_id);
// Does not cache
if (isset($_POST['resendSubmit'])) {
    $result = lookupResult($LTI, $user_id);
    // Does not cache
    // Force a resend
    $_SESSION['lti']['grade'] = -1;
    // Force a resend
    $result['grade'] = -1;
    $debug_log = array();
    $status = LTIX::gradeSend($computed_grade, $result, $debug_log);
    // This is the slow bit
    if ($status === true) {
        $_SESSION['success'] = 'Grade submitted to server';
    } else {
        error_log("Problem sending grade " . $status);
        $_SESSION['error'] = 'Error: ' . $status;
    }
    $_SESSION['debug_log'] = $debug_log;
    header('Location: ' . addSession('student.php?user_id=' . $user_id));
    return;
}
// Retrieve our grades...
$grades_received = retrieveSubmissionGrades($submit_id);
// Handle incoming post to delete a grade entry
if (isset($_POST['grade_id']) && isset($_POST['deleteGrade'])) {
开发者ID:shaamimahmed,项目名称:tsugi,代码行数:31,代码来源:student.php


注:本文中的Tsugi\Core\LTIX类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。