本文整理汇总了PHP中LearnositySdk\Request\Init::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Init::generate方法的具体用法?PHP Init::generate怎么用?PHP Init::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LearnositySdk\Request\Init
的用法示例。
在下文中一共展示了Init::generate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
include_once '../../config.php';
use LearnositySdk\Request\Init;
use LearnositySdk\Utils\Uuid;
$security = array('consumer_key' => $consumer_key, 'domain' => $domain);
// Decide which items your want to print
$items = array('printing-mcq', 'printing-mcq-multi', 'printing-token', 'printing-fillintheblank');
$sessionid = Uuid::generate();
// Load the assessment in `local_practice` (you won't want to submit actual responses)
// and using the `inline` rendering type
$request = array('user_id' => $studentid, 'session_id' => $sessionid, 'state' => 'preview', 'rendering_type' => 'inline', 'type' => 'local_practice', 'items' => $items, 'config' => array('fontsize' => 'xlarge', 'renderSubmitButton' => false, 'questionsApiVersion' => 'v2'));
$Init = new Init('items', $security, $consumer_secret, $request);
$signedRequest = $Init->generate();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<div class="print-container">
<div>
<h2>MCQ</h2>
<span class="learnosity-item" data-reference="printing-mcq"></span>
</div>
<div class="page-break">
<h2>MCQ Multi</h2>
<span class="learnosity-item" data-reference="printing-mcq-multi"></span>
</div>
示例2: explode
<?php
require_once __DIR__ . '/src/bootstrap.php';
use LearnositySdk\Request\Init;
$currentUser = explode(',', $_COOKIE['lrnuser']);
$service = 'items';
$security = ['consumer_key' => 'yis0TYCu7U9V4o7M', 'domain' => $_SERVER['SERVER_NAME'], 'user_id' => 'open_web_demo'];
$secret = '74c5fd430cf1242a527f6223aebd42d30464be22';
$request = ["reports" => [['id' => 'sessions-list', 'type' => 'sessions-list', 'limit' => 10, 'display_user' => true, 'activities' => [['id' => '0d2e0df2-285d-4507-86e5-3ca8de0f3fc2', 'name' => 'Movie Trivia']], 'render' => false], ["id" => "lastscore-bar-1", "type" => "lastscore-single", "ui" => "pie", "user_id" => $currentUser[0], "activity_id" => "56d23693-df43-486a-882b-d7ccd010ada2"], ['id' => 'progress-by-tag', 'type' => 'progress-by-tag', 'user_id' => $currentUser[0], 'ui' => 'table', 'hierarchy_reference' => 'Movie Genre'], ["id" => "report-demo", "type" => "sessions-summary", "user_id" => $currentUser[0], "session_ids" => [$currentUser[1]]]]];
// Instantiate the SDK Init class with your security and request data=>
$Init = new Init($service, $security, $secret, $request);
// Call the generate() method to retrieve a JavaScript object
$initOptions = $Init->generate();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Movie Trivia Reporting</title>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/LeaderBoard.js"></script>
<script src="//reports.learnosity.com"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
示例3: request
/**
* Makes a single request to the data api
*
* @param string $endpoint URL to send the request
* @param array $securityPacket Security details
* @param string $secret Private key
* @param array $requestPacket Request packet
* @param string $action Action for the request
* @return Remote Instance of the Remote class
*/
public function request($endpoint, $securityPacket, $secret, $requestPacket = null, $action = null)
{
$init = new Init('data', $securityPacket, $secret, $requestPacket, $action);
$params = $init->generate();
return $this->remote->post($endpoint, $params, $this->remoteOptions);
}
示例4: explode
<?php
require_once __DIR__ . '/src/bootstrap.php';
use LearnositySdk\Request\Init;
$currentUser = explode(',', $_COOKIE['lrnuser']);
$service = 'items';
$security = ['consumer_key' => 'yis0TYCu7U9V4o7M', 'domain' => 'localhost', 'user_id' => 'demo_student'];
$secret = '74c5fd430cf1242a527f6223aebd42d30464be22';
$request = ['activity_id' => '56d23693-df43-486a-882b-d7ccd010ada2', 'user_id' => $currentUser[0], 'session_id' => $currentUser[1], 'type' => 'submit_practice', 'name' => 'Movie Trivia', 'course_id' => 'bootcamp-july', 'state' => 'resume', 'rendering_type' => 'assess', 'items' => ['bootjuly_jh_1', 'bootjuly_as_2', 'bootjuly_as_3', 'bootjuly_jh_4a', 'bootjuly_jh_4b', 'bootjuly_as_5', 'bootjuly_bm_6', 'bootjuly_bm_7', 'bootjuly_bm_8', 'bootjuly_as_9', 'bootjuly_bm_10'], 'config' => ['ui_style' => 'main', 'time' => ['max_time' => 1500, 'limit_type' => 'soft', 'show_pause' => true, 'show_time' => true, 'countdown' => 10], 'navigation' => ['auto_save' => true, 'toc' => ['show_itemcount' => true], 'show_save' => true, 'show_submit' => true, 'skip_submit_confirmation' => false, 'show_title' => true, 'show_progress' => true, 'show_fullscreencontrol' => true, 'show_intro' => true, 'show_outro' => true, 'show_prev' => true, 'show_next' => true, 'show_itemcount' => false, 'warning_on_change' => false, 'scrolling_indicator' => false, 'scroll_to_top' => true, 'scroll_to_test' => false, 'transition' => 'fade', 'transition_speed' => 400, 'show_calculator' => false, 'show_accessibility' => ['show_colourscheme' => false, 'show_fontsize' => false, 'show_zoom' => false], 'show_answermasking' => false, 'exit_securebrowser' => true, 'show_acknowledgements' => false], 'configuration' => ['fontsize' => 'normal', 'dynamic' => false, 'idle_timeout' => false, 'events' => false, 'preload_audio_player' => false, 'submit_criteria' => false, 'onsubmit_redirect_url' => 'report.php'], 'questions_api_init_options' => ['captureOnResumeError' => true], 'administration' => false, 'title' => 'Movie Trivia']];
// Instantiate the SDK Init class with your security and request data:
$Init = new Init($service, $security, $secret, $request);
// Call the generate() method to retrieve a JavaScript object
$request = $Init->generate();
?>
<html>
<head>
<script src="//items.learnosity.com"></script>
</head>
<body>
<script>
function getUser(name) {
var users = [];
if (localStorage.getItem('users')) {
// Get users from localStorage
users = JSON.parse(localStorage.getItem('users'));
}
for (var i in users) {
示例5: Init
<?php
header("Content-type: application/json");
//external config for key/secret etc.
include_once '../../../config.php';
//use SDK
use LearnositySdk\Request\Init;
use LearnositySdk\Utils\Uuid;
//domain must be whitelisted
$domain = $_POST['domain'];
//security object, with domain taking from requester
$security = ['user_id' => $_POST['request']['user_id'], 'domain' => $domain, 'consumer_key' => $consumer_key];
//initialize Items API with provided request object
$init = new Init('items', $security, $consumer_secret, $_POST['request']);
echo $init->generate();
示例6: array
include_once 'includes/header.php';
use LearnositySdk\Request\Init;
// Which activity do you want to load?
$activityRef = 'gallery_1';
if (isset($_GET['activity_reference'])) {
$activityRef = $_GET['activity_reference'];
}
include './includes/itemsRequest.php';
$security = array('consumer_key' => $consumer_key, 'user_id' => $teacherid, 'domain' => $domain);
// Use the `users` query string var, otherwise go with the application default student name
$users = strlen($_GET['users']) ? explode(',', $_GET['users']) : [$studentid];
$request = array('reports' => array(array('id' => 'activitystatus-1', 'render' => false, 'type' => 'live-activitystatus-by-user', 'activity' => array('id' => 'itemsinlinedemo'), 'users' => array_map(function ($user) use($consumer_secret) {
return array('id' => $user, 'hash' => hash('sha256', $user . $consumer_secret));
}, $users))));
$init = new Init('reports', $security, $consumer_secret, $request);
$reportsRequest = $init->generate();
?>
<div class="jumbotron section">
<div class="toolbar">
<ul class="list-inline">
<li data-toggle="tooltip" data-original-title="Toggle product overview box"><a href="#"><span class="glyphicon glyphicon-chevron-up jumbotron-toggle"></span></a></li>
</ul>
</div>
<div class="overview">
<h1>Items API & Reports API – Gallery Report</h1>
<p>Demonstrates how you can combine Items API and Reports API to create a custom report with live updates.</p>
<ul>
<li><a href="./">Student View</a></li>
<li>Teacher View</li>
</ul>
示例7: array
| Main use case right now is to sign an 'items' packet from the Author
| API for previewing.
|
*/
include_once 'config.php';
use LearnositySdk\Request\Init;
use LearnositySdk\Utils\Uuid;
$security = array("consumer_key" => $consumer_key, "domain" => $domain);
$service = null;
$sign_type = isset($_POST['sign_type']) ? $_POST['sign_type'] : null;
$show_modal = false;
switch ($sign_type) {
case 'items-inline':
$service = 'items';
$content = $_POST['content'];
$show_modal = true;
$request = array('user_id' => $studentid, 'rendering_type' => 'inline', 'name' => 'Items API demo - Inline Activity.', 'state' => 'initial', 'activity_id' => 'itemsinlinedemo', 'session_id' => Uuid::generate(), 'course_id' => $courseid, 'items' => $_POST['item_references'], 'type' => 'submit_practice', 'config' => array('renderSubmitButton' => false, 'questionsApiVersion' => 'v2'));
break;
default:
// No default
break;
}
if (!is_null($service)) {
$Init = new Init($service, $security, $consumer_secret, $request);
$output = $Init->generate();
if ($show_modal) {
include_once 'views/modals/' . $sign_type . '.php';
} else {
echo $output;
}
}
示例8: array
<?php
use LearnositySdk\Request\Init;
use LearnositySdk\Request\DataApi;
use LearnositySdk\Utils\Uuid;
$security = array('consumer_key' => $consumer_key, 'domain' => $domain);
/*
* The only reason we're using the Data API here is to
* retrieve the item references necessary to create a
* DOM node (to load an item into).
* This call would ideally be cached by the host page.
*/
$dataApi = new DataApi();
$response = $dataApi->request($url_data . '/latest/itembank/activities', $security, $consumer_secret, ['references' => [$activityRef]]);
if (!$response->getError()['code']) {
$activity = json_decode($response->getBody(), true)['data'];
$items = $activity[0]['data']['items'];
}
// Setup your request object as usual
$request = array('user_id' => $studentid, 'name' => 'Items API demo - Inline Activity.', 'state' => 'initial', 'activity_id' => 'itemsinlinedemo', 'session_id' => Uuid::generate(), 'course_id' => 'demo', 'type' => 'submit_practice', 'rendering_type' => 'inline', 'activity_template_id' => $activityRef);
$init = new Init('items', $security, $consumer_secret, $request);
$itemsRequest = $init->generate();