本文整理匯總了PHP中Tsugi\Core\LTIX::sessionGet方法的典型用法代碼示例。如果您正苦於以下問題:PHP LTIX::sessionGet方法的具體用法?PHP LTIX::sessionGet怎麽用?PHP LTIX::sessionGet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tsugi\Core\LTIX
的用法示例。
在下文中一共展示了LTIX::sessionGet方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: linkSetAll
/**
* Set all of the the link-level settings.
*
* @param $keyvals An array of key/value pairs that is serialized
* in JSON and stored. If this is an empty array, this effectively
* empties out all the settings.
*/
public static function linkSetAll($keyvals)
{
global $CFG, $PDOX, $LINK;
global $settingsDebugArray;
$settingsDebugArray = array();
$json = json_encode($keyvals);
$q = $PDOX->queryDie("UPDATE {$CFG->dbprefix}lti_link \n SET settings = :SET WHERE link_id = :LID", array(":SET" => $json, ":LID" => $LINK->id));
$settingsDebugArray[] = array(count($keyvals) . " settings updated link_id=" . $LINK->id);
if (isset($_SESSION['lti'])) {
$_SESSION['lti']['link_settings'] = $json;
unset($_SESSION['lti']['link_settings_merge']);
}
$settings_url = LTIX::sessionGet('link_settings_url', false);
if ($settings_url === false) {
return;
}
$settingsDebugArray[] = array("Sending settings to " . $settings_url);
$retval = LTIX::settingsSend($keyvals, $settings_url, $settingsDebugArray);
}
示例2: doAnalytics
function doAnalytics()
{
global $CFG;
if ($CFG->universal_analytics) {
?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<?php
echo $CFG->universal_analytics;
?>
', 'auto');
ga('send', 'pageview');
</script>
<?php
}
if ($CFG->analytics_key) {
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php
echo $CFG->analytics_key;
?>
']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
// ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<?php
if (LTIX::sessionGet('key_key')) {
echo "_gaq.push(['_setCustomVar', 1, 'consumer_key', '" . $_SESSION['lti']['key_key'] . "', 2]);\n";
}
if (LTIX::sessionGet('context_id')) {
echo "_gaq.push(['_setCustomVar', 2, 'context_id', '" . $_SESSION['lti']['context_id'] . "', 2]);\n";
}
if (LTIX::sessionGet('context_title')) {
echo "_gaq.push(['_setCustomVar', 3, 'context_title', '" . $_SESSION['lti']['context_title'] . "', 2]);\n";
}
echo "</script>\n";
}
// if analytics is on...
}
示例3: array
<?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";
use Tsugi\Core\LTIX;
use Tsugi\Util\LTI;
use Tsugi\Util\Caliper;
// Retrieve the launch data if present
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;
$displayname = $USER->displayname;
if (isset($_POST['caliper'])) {
$caliper = Caliper::sensorCanvasPageView(LTIX::sessionGet('user_key'), $CFG->wwwroot, "samples/grade/index.php");
$_SESSION['caliper'] = $caliper;
$debug_log = array();
$retval = LTIX::caliperSend($caliper, 'application/json', $debug_log);
/*
echo("<pre>\n");
var_dump($caliper);
echo("</pre>\n");
die();
*/
if ($retval) {
$_SESSION['success'] = "Caliper sent.";
} else {
$_SESSION['error'] = "Caliper attempt failed.";
}
$_SESSION['debuglog'] = $debug_log;
header('Location: ' . addSession('index.php'));
示例4: gradeSend
/**
* Send a grade and update our local copy
*
* Call the right LTI service to send a new grade up to the server.
* update our local cached copy of the server_grade and the date
* retrieved. This routine pulls the key and secret from the LTIX
* session to avoid crossing cross tennant boundaries.
*
* @param $grade A new grade - floating point number between 0.0 and 1.0
* @param $row An optional array with the data that has the result_id, sourcedid,
* and service (url) if this is not present, the data is pulled from the LTI
* session for the current user/link combination.
* @param $debug_log An (optional) array (by reference) that returns the
* steps that were taken.
* Each entry is an array with the [0] element a message and an optional [1]
* element as some detail (i.e. like a POST body)
*
* @return mixed If this works it returns true. If not, you get
* a string with an error.
*
*/
public function gradeSend($grade, $row = false, &$debug_log = false)
{
global $CFG, $USER;
global $LastPOXGradeResponse;
$LastPOXGradeResponse = false;
$PDOX = LTIX::getConnection();
// Secret and key from session to avoid crossing tenant boundaries
$key_key = LTIX::sessionGet('key_key');
$secret = LTIX::sessionGet('secret');
if ($row !== false) {
$result_url = isset($row['result_url']) ? $row['result_url'] : false;
$sourcedid = isset($row['sourcedid']) ? $row['sourcedid'] : false;
$service = isset($row['service']) ? $row['service'] : false;
// Fall back to session if it is missing
if ($service === false) {
$service = LTIX::sessionGet('service');
}
$result_id = isset($row['result_id']) ? $row['result_id'] : false;
} else {
$result_url = LTIX::sessionGet('result_url');
$sourcedid = LTIX::sessionGet('sourcedid');
$service = LTIX::sessionGet('service');
$result_id = LTIX::sessionGet('result_id');
}
// Update result in the database and in the LTI session area and
// our local copy
$_SESSION['lti']['grade'] = $grade;
$this->grade = $grade;
// Update the local copy of the grade in the lti_result table
if ($PDOX !== false && $result_id !== false) {
$stmt = $PDOX->queryReturnError("UPDATE {$CFG->dbprefix}lti_result SET grade = :grade,\n updated_at = NOW() WHERE result_id = :RID", array(':grade' => $grade, ':RID' => $result_id));
if ($stmt->success) {
$msg = "Grade updated result_id=" . $result_id . " grade={$grade}";
} else {
$msg = "Grade NOT updated result_id=" . $result_id . " grade={$grade}";
}
error_log($msg);
if (is_array($debug_log)) {
$debug_log[] = array($msg);
}
}
if ($key_key == false || $secret === false || $sourcedid === false || $service === false || !isset($USER)) {
error_log("Result::gradeSend stored data locally");
return false;
}
// TODO: Fix this
$comment = "";
if (strlen($result_url) > 0) {
$status = LTI::sendJSONGrade($grade, $comment, $result_url, $key_key, $secret, $debug_log);
} else {
$status = LTI::sendPOXGrade($grade, $sourcedid, $service, $key_key, $secret, $debug_log);
}
if ($status === true) {
$msg = 'Grade sent ' . $grade . ' to ' . $sourcedid . ' by ' . $USER->id;
if (is_array($debug_log)) {
$debug_log[] = array($msg);
}
error_log($msg);
} else {
$msg = 'Grade failure ' . $grade . ' to ' . $sourcedid . ' by ' . $USER->id;
if (is_array($debug_log)) {
$debug_log[] = array($msg);
}
error_log($msg);
return $status;
}
return $status;
}
示例5: doAnalytics
function doAnalytics()
{
global $CFG;
if ($CFG->analytics_key) {
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php
echo $CFG->analytics_key;
?>
']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
// ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
<?php
if (LTIX::sessionGet('key_key')) {
echo "_gaq.push(['_setCustomVar', 1, 'consumer_key', '" . $_SESSION['lti']['key_key'] . "', 2]);\n";
}
if (LTIX::sessionGet('context_id')) {
echo "_gaq.push(['_setCustomVar', 2, 'context_id', '" . $_SESSION['lti']['context_id'] . "', 2]);\n";
}
if (LTIX::sessionGet('context_title')) {
echo "_gaq.push(['_setCustomVar', 3, 'context_title', '" . $_SESSION['lti']['context_title'] . "', 2]);\n";
}
echo "</script>\n";
}
// if analytics is on...
}