Merge branch 'lti' of git://github.com/scriby/moodle
This commit is contained in:
+1
-1
@@ -383,7 +383,7 @@ class plugin_manager {
|
||||
|
||||
'mod' => array(
|
||||
'assignment', 'chat', 'choice', 'data', 'feedback', 'folder',
|
||||
'forum', 'glossary', 'imscp', 'label', 'lesson', 'page',
|
||||
'forum', 'glossary', 'imscp', 'label', 'lesson', 'lti', 'page',
|
||||
'quiz', 'resource', 'scorm', 'survey', 'url', 'wiki', 'workshop'
|
||||
),
|
||||
|
||||
|
||||
@@ -0,0 +1,841 @@
|
||||
<?php
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
//
|
||||
// OAuth.php is distributed under the MIT License
|
||||
//
|
||||
// The MIT License
|
||||
//
|
||||
// Copyright (c) 2007 Andy Smith
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$oauth_last_computed_signature = false;
|
||||
|
||||
/* Generic exception class
|
||||
*/
|
||||
class OAuthException extends \Exception {
|
||||
// pass
|
||||
}
|
||||
|
||||
class OAuthConsumer {
|
||||
public $key;
|
||||
public $secret;
|
||||
|
||||
function __construct($key, $secret, $callback_url = null) {
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
$this->callback_url = $callback_url;
|
||||
}
|
||||
|
||||
function __toString() {
|
||||
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthToken {
|
||||
// access tokens and request tokens
|
||||
public $key;
|
||||
public $secret;
|
||||
|
||||
/**
|
||||
* key = the token
|
||||
* secret = the token secret
|
||||
*/
|
||||
function __construct($key, $secret) {
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* generates the basic string serialization of a token that a server
|
||||
* would respond to request_token and access_token calls with
|
||||
*/
|
||||
function to_string() {
|
||||
return "oauth_token=" .
|
||||
OAuthUtil::urlencode_rfc3986($this->key) .
|
||||
"&oauth_token_secret=" .
|
||||
OAuthUtil::urlencode_rfc3986($this->secret);
|
||||
}
|
||||
|
||||
function __toString() {
|
||||
return $this->to_string();
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthSignatureMethod {
|
||||
public function check_signature(&$request, $consumer, $token, $signature) {
|
||||
$built = $this->build_signature($request, $consumer, $token);
|
||||
return $built == $signature;
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
|
||||
function get_name() {
|
||||
return "HMAC-SHA1";
|
||||
}
|
||||
|
||||
public function build_signature($request, $consumer, $token) {
|
||||
global $oauth_last_computed_signature;
|
||||
$oauth_last_computed_signature = false;
|
||||
|
||||
$base_string = $request->get_signature_base_string();
|
||||
$request->base_string = $base_string;
|
||||
|
||||
$key_parts = array(
|
||||
$consumer->secret,
|
||||
($token) ? $token->secret : ""
|
||||
);
|
||||
|
||||
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
||||
$key = implode('&', $key_parts);
|
||||
|
||||
$computed_signature = base64_encode(hash_hmac('sha1', $base_string, $key, true));
|
||||
$oauth_last_computed_signature = $computed_signature;
|
||||
return $computed_signature;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
|
||||
public function get_name() {
|
||||
return "PLAINTEXT";
|
||||
}
|
||||
|
||||
public function build_signature($request, $consumer, $token) {
|
||||
$sig = array(
|
||||
OAuthUtil::urlencode_rfc3986($consumer->secret)
|
||||
);
|
||||
|
||||
if ($token) {
|
||||
array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
|
||||
} else {
|
||||
array_push($sig, '');
|
||||
}
|
||||
|
||||
$raw = implode("&", $sig);
|
||||
// for debug purposes
|
||||
$request->base_string = $raw;
|
||||
|
||||
return OAuthUtil::urlencode_rfc3986($raw);
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
|
||||
public function get_name() {
|
||||
return "RSA-SHA1";
|
||||
}
|
||||
|
||||
protected function fetch_public_cert(&$request) {
|
||||
// not implemented yet, ideas are:
|
||||
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
||||
// (2) fetch via http using a url provided by the requester
|
||||
// (3) some sort of specific discovery code based on request
|
||||
//
|
||||
// either way should return a string representation of the certificate
|
||||
throw Exception("fetch_public_cert not implemented");
|
||||
}
|
||||
|
||||
protected function fetch_private_cert(&$request) {
|
||||
// not implemented yet, ideas are:
|
||||
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
||||
//
|
||||
// either way should return a string representation of the certificate
|
||||
throw Exception("fetch_private_cert not implemented");
|
||||
}
|
||||
|
||||
public function build_signature(&$request, $consumer, $token) {
|
||||
$base_string = $request->get_signature_base_string();
|
||||
$request->base_string = $base_string;
|
||||
|
||||
// Fetch the private key cert based on the request
|
||||
$cert = $this->fetch_private_cert($request);
|
||||
|
||||
// Pull the private key ID from the certificate
|
||||
$privatekeyid = openssl_get_privatekey($cert);
|
||||
|
||||
// Sign using the key
|
||||
$ok = openssl_sign($base_string, $signature, $privatekeyid);
|
||||
|
||||
// Release the key resource
|
||||
openssl_free_key($privatekeyid);
|
||||
|
||||
return base64_encode($signature);
|
||||
}
|
||||
|
||||
public function check_signature(&$request, $consumer, $token, $signature) {
|
||||
$decoded_sig = base64_decode($signature);
|
||||
|
||||
$base_string = $request->get_signature_base_string();
|
||||
|
||||
// Fetch the public key cert based on the request
|
||||
$cert = $this->fetch_public_cert($request);
|
||||
|
||||
// Pull the public key ID from the certificate
|
||||
$publickeyid = openssl_get_publickey($cert);
|
||||
|
||||
// Check the computed signature against the one passed in the query
|
||||
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
|
||||
|
||||
// Release the key resource
|
||||
openssl_free_key($publickeyid);
|
||||
|
||||
return $ok == 1;
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthRequest {
|
||||
private $parameters;
|
||||
private $http_method;
|
||||
private $http_url;
|
||||
// for debug purposes
|
||||
public $base_string;
|
||||
public static $version = '1.0';
|
||||
public static $POST_INPUT = 'php://input';
|
||||
|
||||
function __construct($http_method, $http_url, $parameters = null) {
|
||||
@$parameters or $parameters = array();
|
||||
$this->parameters = $parameters;
|
||||
$this->http_method = $http_method;
|
||||
$this->http_url = $http_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* attempt to build up a request from what was passed to the server
|
||||
*/
|
||||
public static function from_request($http_method = null, $http_url = null, $parameters = null) {
|
||||
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http' : 'https';
|
||||
$port = "";
|
||||
if ($_SERVER['SERVER_PORT'] != "80" && $_SERVER['SERVER_PORT'] != "443" && strpos(':', $_SERVER['HTTP_HOST']) < 0) {
|
||||
$port = ':' . $_SERVER['SERVER_PORT'];
|
||||
}
|
||||
@$http_url or $http_url = $scheme .
|
||||
'://' . $_SERVER['HTTP_HOST'] .
|
||||
$port .
|
||||
$_SERVER['REQUEST_URI'];
|
||||
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
// We weren't handed any parameters, so let's find the ones relevant to
|
||||
// this request.
|
||||
// If you run XML-RPC or similar you should use this to provide your own
|
||||
// parsed parameter-list
|
||||
if (!$parameters) {
|
||||
// Find request headers
|
||||
$request_headers = OAuthUtil::get_headers();
|
||||
|
||||
// Parse the query-string to find GET parameters
|
||||
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
|
||||
|
||||
$ourpost = $_POST;
|
||||
// Deal with magic_quotes
|
||||
// http://www.php.net/manual/en/security.magicquotes.disabling.php
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$outpost = array();
|
||||
foreach ($_POST as $k => $v) {
|
||||
$v = stripslashes($v);
|
||||
$ourpost[$k] = $v;
|
||||
}
|
||||
}
|
||||
// Add POST Parameters if they exist
|
||||
$parameters = array_merge($parameters, $ourpost);
|
||||
|
||||
// We have a Authorization-header with OAuth data. Parse the header
|
||||
// and add those overriding any duplicates from GET or POST
|
||||
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
|
||||
$header_parameters = OAuthUtil::split_header($request_headers['Authorization']);
|
||||
$parameters = array_merge($parameters, $header_parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* pretty much a helper function to set up the request
|
||||
*/
|
||||
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = null) {
|
||||
@$parameters or $parameters = array();
|
||||
$defaults = array(
|
||||
"oauth_version" => self::$version,
|
||||
"oauth_nonce" => self::generate_nonce(),
|
||||
"oauth_timestamp" => self::generate_timestamp(),
|
||||
"oauth_consumer_key" => $consumer->key
|
||||
);
|
||||
if ($token) {
|
||||
$defaults['oauth_token'] = $token->key;
|
||||
}
|
||||
|
||||
$parameters = array_merge($defaults, $parameters);
|
||||
|
||||
// Parse the query-string to find and add GET parameters
|
||||
$parts = parse_url($http_url);
|
||||
if (isset($parts['query'])) {
|
||||
$qparms = OAuthUtil::parse_parameters($parts['query']);
|
||||
$parameters = array_merge($qparms, $parameters);
|
||||
}
|
||||
|
||||
return new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}
|
||||
|
||||
public function set_parameter($name, $value, $allow_duplicates = true) {
|
||||
if ($allow_duplicates && isset($this->parameters[$name])) {
|
||||
// We have already added parameter(s) with this name, so add to the list
|
||||
if (is_scalar($this->parameters[$name])) {
|
||||
// This is the first duplicate, so transform scalar (string)
|
||||
// into an array so we can add the duplicates
|
||||
$this->parameters[$name] = array($this->parameters[$name]);
|
||||
}
|
||||
|
||||
$this->parameters[$name][] = $value;
|
||||
} else {
|
||||
$this->parameters[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_parameter($name) {
|
||||
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
|
||||
}
|
||||
|
||||
public function get_parameters() {
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function unset_parameter($name) {
|
||||
unset($this->parameters[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The request parameters, sorted and concatenated into a normalized string.
|
||||
* @return string
|
||||
*/
|
||||
public function get_signable_parameters() {
|
||||
// Grab all parameters
|
||||
$params = $this->parameters;
|
||||
|
||||
// Remove oauth_signature if present
|
||||
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
|
||||
if (isset($params['oauth_signature'])) {
|
||||
unset($params['oauth_signature']);
|
||||
}
|
||||
|
||||
return OAuthUtil::build_http_query($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base string of this request
|
||||
*
|
||||
* The base string defined as the method, the url
|
||||
* and the parameters (normalized), each urlencoded
|
||||
* and the concated with &.
|
||||
*/
|
||||
public function get_signature_base_string() {
|
||||
$parts = array(
|
||||
$this->get_normalized_http_method(),
|
||||
$this->get_normalized_http_url(),
|
||||
$this->get_signable_parameters()
|
||||
);
|
||||
|
||||
$parts = OAuthUtil::urlencode_rfc3986($parts);
|
||||
|
||||
return implode('&', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* just uppercases the http method
|
||||
*/
|
||||
public function get_normalized_http_method() {
|
||||
return strtoupper($this->http_method);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the url and rebuilds it to be
|
||||
* scheme://host/path
|
||||
*/
|
||||
public function get_normalized_http_url() {
|
||||
$parts = parse_url($this->http_url);
|
||||
|
||||
$port = @$parts['port'];
|
||||
$scheme = $parts['scheme'];
|
||||
$host = $parts['host'];
|
||||
$path = @$parts['path'];
|
||||
|
||||
$port or $port = ($scheme == 'https') ? '443' : '80';
|
||||
|
||||
if (($scheme == 'https' && $port != '443') || ($scheme == 'http' && $port != '80')) {
|
||||
$host = "$host:$port";
|
||||
}
|
||||
return "$scheme://$host$path";
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a url usable for a GET request
|
||||
*/
|
||||
public function to_url() {
|
||||
$post_data = $this->to_postdata();
|
||||
$out = $this->get_normalized_http_url();
|
||||
if ($post_data) {
|
||||
$out .= '?'.$post_data;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* builds the data one would send in a POST request
|
||||
*/
|
||||
public function to_postdata() {
|
||||
return OAuthUtil::build_http_query($this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* builds the Authorization: header
|
||||
*/
|
||||
public function to_header() {
|
||||
$out = 'Authorization: OAuth realm=""';
|
||||
$total = array();
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (substr($k, 0, 5) != "oauth") {
|
||||
continue;
|
||||
}
|
||||
if (is_array($v)) {
|
||||
throw new OAuthException('Arrays not supported in headers');
|
||||
}
|
||||
$out .= ',' .
|
||||
OAuthUtil::urlencode_rfc3986($k) .
|
||||
'="' .
|
||||
OAuthUtil::urlencode_rfc3986($v) .
|
||||
'"';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->to_url();
|
||||
}
|
||||
|
||||
public function sign_request($signature_method, $consumer, $token) {
|
||||
$this->set_parameter("oauth_signature_method", $signature_method->get_name(), false);
|
||||
$signature = $this->build_signature($signature_method, $consumer, $token);
|
||||
$this->set_parameter("oauth_signature", $signature, false);
|
||||
}
|
||||
|
||||
public function build_signature($signature_method, $consumer, $token) {
|
||||
$signature = $signature_method->build_signature($this, $consumer, $token);
|
||||
return $signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* util function: current timestamp
|
||||
*/
|
||||
private static function generate_timestamp() {
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
* util function: current nonce
|
||||
*/
|
||||
private static function generate_nonce() {
|
||||
$mt = microtime();
|
||||
$rand = mt_rand();
|
||||
|
||||
return md5($mt.$rand); // md5s look nicer than numbers
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthServer {
|
||||
protected $timestamp_threshold = 300; // in seconds, five minutes
|
||||
protected $version = 1.0; // hi blaine
|
||||
protected $signature_methods = array();
|
||||
protected $data_store;
|
||||
|
||||
function __construct($data_store) {
|
||||
$this->data_store = $data_store;
|
||||
}
|
||||
|
||||
public function add_signature_method($signature_method) {
|
||||
$this->signature_methods[$signature_method->get_name()] = $signature_method;
|
||||
}
|
||||
|
||||
// high level functions
|
||||
|
||||
/**
|
||||
* process a request_token request
|
||||
* returns the request token on success
|
||||
*/
|
||||
public function fetch_request_token(&$request) {
|
||||
$this->get_version($request);
|
||||
|
||||
$consumer = $this->get_consumer($request);
|
||||
|
||||
// no token required for the initial token request
|
||||
$token = null;
|
||||
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
|
||||
$new_token = $this->data_store->new_request_token($consumer);
|
||||
|
||||
return $new_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* process an access_token request
|
||||
* returns the access token on success
|
||||
*/
|
||||
public function fetch_access_token(&$request) {
|
||||
$this->get_version($request);
|
||||
|
||||
$consumer = $this->get_consumer($request);
|
||||
|
||||
// requires authorized request token
|
||||
$token = $this->get_token($request, $consumer, "request");
|
||||
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
|
||||
$new_token = $this->data_store->new_access_token($token, $consumer);
|
||||
|
||||
return $new_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* verify an api call, checks all the parameters
|
||||
*/
|
||||
public function verify_request(&$request) {
|
||||
global $oauth_last_computed_signature;
|
||||
$oauth_last_computed_signature = false;
|
||||
$this->get_version($request);
|
||||
$consumer = $this->get_consumer($request);
|
||||
$token = $this->get_token($request, $consumer, "access");
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
return array(
|
||||
$consumer,
|
||||
$token
|
||||
);
|
||||
}
|
||||
|
||||
// Internals from here
|
||||
/**
|
||||
* version 1
|
||||
*/
|
||||
private function get_version(&$request) {
|
||||
$version = $request->get_parameter("oauth_version");
|
||||
if (!$version) {
|
||||
$version = 1.0;
|
||||
}
|
||||
if ($version && $version != $this->version) {
|
||||
throw new OAuthException("OAuth version '$version' not supported");
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* figure out the signature with some defaults
|
||||
*/
|
||||
private function get_signature_method(&$request) {
|
||||
$signature_method = @ $request->get_parameter("oauth_signature_method");
|
||||
if (!$signature_method) {
|
||||
$signature_method = "PLAINTEXT";
|
||||
}
|
||||
if (!in_array($signature_method, array_keys($this->signature_methods))) {
|
||||
throw new OAuthException("Signature method '$signature_method' not supported " .
|
||||
"try one of the following: " .
|
||||
implode(", ", array_keys($this->signature_methods)));
|
||||
}
|
||||
return $this->signature_methods[$signature_method];
|
||||
}
|
||||
|
||||
/**
|
||||
* try to find the consumer for the provided request's consumer key
|
||||
*/
|
||||
private function get_consumer(&$request) {
|
||||
$consumer_key = @ $request->get_parameter("oauth_consumer_key");
|
||||
if (!$consumer_key) {
|
||||
throw new OAuthException("Invalid consumer key");
|
||||
}
|
||||
|
||||
$consumer = $this->data_store->lookup_consumer($consumer_key);
|
||||
if (!$consumer) {
|
||||
throw new OAuthException("Invalid consumer");
|
||||
}
|
||||
|
||||
return $consumer;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to find the token for the provided request's token key
|
||||
*/
|
||||
private function get_token(&$request, $consumer, $token_type = "access") {
|
||||
$token_field = @ $request->get_parameter('oauth_token');
|
||||
if (!$token_field) {
|
||||
return false;
|
||||
}
|
||||
$token = $this->data_store->lookup_token($consumer, $token_type, $token_field);
|
||||
if (!$token) {
|
||||
throw new OAuthException("Invalid $token_type token: $token_field");
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* all-in-one function to check the signature on a request
|
||||
* should guess the signature method appropriately
|
||||
*/
|
||||
private function check_signature(&$request, $consumer, $token) {
|
||||
// this should probably be in a different method
|
||||
global $oauth_last_computed_signature;
|
||||
$oauth_last_computed_signature = false;
|
||||
|
||||
$timestamp = @ $request->get_parameter('oauth_timestamp');
|
||||
$nonce = @ $request->get_parameter('oauth_nonce');
|
||||
|
||||
$this->check_timestamp($timestamp);
|
||||
$this->check_nonce($consumer, $token, $nonce, $timestamp);
|
||||
|
||||
$signature_method = $this->get_signature_method($request);
|
||||
|
||||
$signature = $request->get_parameter('oauth_signature');
|
||||
$valid_sig = $signature_method->check_signature($request, $consumer, $token, $signature);
|
||||
|
||||
if (!$valid_sig) {
|
||||
$ex_text = "Invalid signature";
|
||||
if ($oauth_last_computed_signature) {
|
||||
$ex_text = $ex_text . " ours= $oauth_last_computed_signature yours=$signature";
|
||||
}
|
||||
throw new OAuthException($ex_text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check that the timestamp is new enough
|
||||
*/
|
||||
private function check_timestamp($timestamp) {
|
||||
// verify that timestamp is recentish
|
||||
$now = time();
|
||||
if ($now - $timestamp > $this->timestamp_threshold) {
|
||||
throw new OAuthException("Expired timestamp, yours $timestamp, ours $now");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check that the nonce is not repeated
|
||||
*/
|
||||
private function check_nonce($consumer, $token, $nonce, $timestamp) {
|
||||
// verify that the nonce is uniqueish
|
||||
$found = $this->data_store->lookup_nonce($consumer, $token, $nonce, $timestamp);
|
||||
if ($found) {
|
||||
throw new OAuthException("Nonce already used: $nonce");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OAuthDataStore {
|
||||
function lookup_consumer($consumer_key) {
|
||||
// implement me
|
||||
}
|
||||
|
||||
function lookup_token($consumer, $token_type, $token) {
|
||||
// implement me
|
||||
}
|
||||
|
||||
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
|
||||
// implement me
|
||||
}
|
||||
|
||||
function new_request_token($consumer) {
|
||||
// return a new token attached to this consumer
|
||||
}
|
||||
|
||||
function new_access_token($token, $consumer) {
|
||||
// return a new access token attached to this consumer
|
||||
// for the user associated with this token if the request token
|
||||
// is authorized
|
||||
// should also invalidate the request token
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OAuthUtil {
|
||||
public static function urlencode_rfc3986($input) {
|
||||
if (is_array($input)) {
|
||||
return array_map(array(
|
||||
'moodle\mod\lti\OAuthUtil',
|
||||
'urlencode_rfc3986'
|
||||
), $input);
|
||||
} else {
|
||||
if (is_scalar($input)) {
|
||||
return str_replace('+', ' ', str_replace('%7E', '~', rawurlencode($input)));
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This decode function isn't taking into consideration the above
|
||||
// modifications to the encoding process. However, this method doesn't
|
||||
// seem to be used anywhere so leaving it as is.
|
||||
public static function urldecode_rfc3986($string) {
|
||||
return urldecode($string);
|
||||
}
|
||||
|
||||
// Utility function for turning the Authorization: header into
|
||||
// parameters, has to do some unescaping
|
||||
// Can filter out any non-oauth parameters if needed (default behaviour)
|
||||
public static function split_header($header, $only_allow_oauth_parameters = true) {
|
||||
$pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
|
||||
$offset = 0;
|
||||
$params = array();
|
||||
while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
|
||||
$match = $matches[0];
|
||||
$header_name = $matches[2][0];
|
||||
$header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
|
||||
if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
|
||||
$params[$header_name] = self::urldecode_rfc3986($header_content);
|
||||
}
|
||||
$offset = $match[1] + strlen($match[0]);
|
||||
}
|
||||
|
||||
if (isset($params['realm'])) {
|
||||
unset($params['realm']);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
// helper to try to sort out headers for people who aren't running apache
|
||||
public static function get_headers() {
|
||||
if (function_exists('apache_request_headers')) {
|
||||
// we need this to get the actual Authorization: header
|
||||
// because apache tends to tell us it doesn't exist
|
||||
return apache_request_headers();
|
||||
}
|
||||
// otherwise we don't have apache and are just going to have to hope
|
||||
// that $_SERVER actually contains what we need
|
||||
$out = array();
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if (substr($key, 0, 5) == "HTTP_") {
|
||||
// this is chaos, basically it is just there to capitalize the first
|
||||
// letter of every word that is not an initial HTTP and strip HTTP
|
||||
// code from przemek
|
||||
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
|
||||
$out[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
// This function takes a input like a=b&a=c&d=e and returns the parsed
|
||||
// parameters like this
|
||||
// array('a' => array('b','c'), 'd' => 'e')
|
||||
public static function parse_parameters($input) {
|
||||
if (!isset($input) || !$input) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$pairs = explode('&', $input);
|
||||
|
||||
$parsed_parameters = array();
|
||||
foreach ($pairs as $pair) {
|
||||
$split = explode('=', $pair, 2);
|
||||
$parameter = self::urldecode_rfc3986($split[0]);
|
||||
$value = isset($split[1]) ? self::urldecode_rfc3986($split[1]) : '';
|
||||
|
||||
if (isset($parsed_parameters[$parameter])) {
|
||||
// We have already recieved parameter(s) with this name, so add to the list
|
||||
// of parameters with this name
|
||||
|
||||
if (is_scalar($parsed_parameters[$parameter])) {
|
||||
// This is the first duplicate, so transform scalar (string) into an array
|
||||
// so we can add the duplicates
|
||||
$parsed_parameters[$parameter] = array(
|
||||
$parsed_parameters[$parameter]
|
||||
);
|
||||
}
|
||||
|
||||
$parsed_parameters[$parameter][] = $value;
|
||||
} else {
|
||||
$parsed_parameters[$parameter] = $value;
|
||||
}
|
||||
}
|
||||
return $parsed_parameters;
|
||||
}
|
||||
|
||||
public static function build_http_query($params) {
|
||||
if (!$params) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Urlencode both keys and values
|
||||
$keys = self::urlencode_rfc3986(array_keys($params));
|
||||
$values = self::urlencode_rfc3986(array_values($params));
|
||||
$params = array_combine($keys, $values);
|
||||
|
||||
// Parameters are sorted by name, using lexicographical byte value ordering.
|
||||
// Ref: Spec: 9.1.1 (1)
|
||||
uksort($params, 'strcmp');
|
||||
|
||||
$pairs = array();
|
||||
foreach ($params as $parameter => $value) {
|
||||
if (is_array($value)) {
|
||||
// If two or more parameters share the same name, they are sorted by their value
|
||||
// Ref: Spec: 9.1.1 (1)
|
||||
natsort($value);
|
||||
foreach ($value as $duplicate_value) {
|
||||
$pairs[] = $parameter . '=' . $duplicate_value;
|
||||
}
|
||||
} else {
|
||||
$pairs[] = $parameter . '=' . $value;
|
||||
}
|
||||
}
|
||||
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
|
||||
// Each name-value pair is separated by an '&' character (ASCII code 38)
|
||||
return implode('&', $pairs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
//
|
||||
// OAuthBody.php is distributed under the MIT License
|
||||
//
|
||||
// The MIT License
|
||||
//
|
||||
// Copyright (c) 2007 Andy Smith
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/lti/OAuth.php');
|
||||
require_once($CFG->dirroot . '/mod/lti/TrivialStore.php');
|
||||
|
||||
function getOAuthKeyFromHeaders()
|
||||
{
|
||||
$request_headers = OAuthUtil::get_headers();
|
||||
// print_r($request_headers);
|
||||
|
||||
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
|
||||
$header_parameters = OAuthUtil::split_header($request_headers['Authorization']);
|
||||
|
||||
// echo("HEADER PARMS=\n");
|
||||
// print_r($header_parameters);
|
||||
return $header_parameters['oauth_consumer_key'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret, $body, $request_headers = null)
|
||||
{
|
||||
if($request_headers == null){
|
||||
$request_headers = OAuthUtil::get_headers();
|
||||
}
|
||||
|
||||
// Must reject application/x-www-form-urlencoded
|
||||
if ($request_headers['Content-type'] == 'application/x-www-form-urlencoded' ) {
|
||||
throw new Exception("OAuth request body signing must not use application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
|
||||
$header_parameters = OAuthUtil::split_header($request_headers['Authorization']);
|
||||
|
||||
// echo("HEADER PARMS=\n");
|
||||
// print_r($header_parameters);
|
||||
$oauth_body_hash = $header_parameters['oauth_body_hash'];
|
||||
// echo("OBH=".$oauth_body_hash."\n");
|
||||
}
|
||||
|
||||
if ( ! isset($oauth_body_hash) ) {
|
||||
throw new Exception("OAuth request body signing requires oauth_body_hash body");
|
||||
}
|
||||
|
||||
// Verify the message signature
|
||||
$store = new TrivialOAuthDataStore();
|
||||
$store->add_consumer($oauth_consumer_key, $oauth_consumer_secret);
|
||||
|
||||
$server = new OAuthServer($store);
|
||||
|
||||
$method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
$server->add_signature_method($method);
|
||||
$request = OAuthRequest::from_request();
|
||||
|
||||
try {
|
||||
$server->verify_request($request);
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
throw new Exception("OAuth signature failed: " . $message);
|
||||
}
|
||||
|
||||
$postdata = $body;
|
||||
// echo($postdata);
|
||||
|
||||
$hash = base64_encode(sha1($postdata, TRUE));
|
||||
|
||||
if ( $hash != $oauth_body_hash ) {
|
||||
throw new Exception("OAuth oauth_body_hash mismatch");
|
||||
}
|
||||
|
||||
return $postdata;
|
||||
}
|
||||
|
||||
function sendOAuthBodyPOST($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $body)
|
||||
{
|
||||
$hash = base64_encode(sha1($body, TRUE));
|
||||
|
||||
$parms = array('oauth_body_hash' => $hash);
|
||||
|
||||
$test_token = '';
|
||||
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
$test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL);
|
||||
|
||||
$acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms);
|
||||
$acc_req->sign_request($hmac_method, $test_consumer, $test_token);
|
||||
|
||||
$header = $acc_req->to_header();
|
||||
$header = $header . "\r\nContent-type: " . $content_type . "\r\n";
|
||||
|
||||
$params = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'content' => $body,
|
||||
'header' => $header
|
||||
));
|
||||
$ctx = stream_context_create($params);
|
||||
$fp = @fopen($endpoint, 'rb', false, $ctx);
|
||||
if (!$fp) {
|
||||
throw new Exception("Problem with $endpoint, $php_errormsg");
|
||||
}
|
||||
$response = @stream_get_contents($fp);
|
||||
if ($response === false) {
|
||||
throw new Exception("Problem reading data from $endpoint, $php_errormsg");
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains a Trivial memory-based store - no support for tokens
|
||||
*
|
||||
* @package lti
|
||||
* @copyright IMS Global Learning Consortium
|
||||
*
|
||||
* @author Charles Severance [email protected]
|
||||
*
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* A Trivial memory-based store - no support for tokens
|
||||
*/
|
||||
class TrivialOAuthDataStore extends OAuthDataStore {
|
||||
private $consumers = array();
|
||||
|
||||
function add_consumer($consumer_key, $consumer_secret) {
|
||||
$this->consumers[$consumer_key] = $consumer_secret;
|
||||
}
|
||||
|
||||
function lookup_consumer($consumer_key) {
|
||||
if ( strpos($consumer_key, "http://" ) === 0 ) {
|
||||
$consumer = new OAuthConsumer($consumer_key, "secret", null);
|
||||
return $consumer;
|
||||
}
|
||||
if ( $this->consumers[$consumer_key] ) {
|
||||
$consumer = new OAuthConsumer($consumer_key, $this->consumers[$consumer_key], null);
|
||||
return $consumer;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function lookup_token($consumer, $token_type, $token) {
|
||||
return new OAuthToken($consumer, "");
|
||||
}
|
||||
|
||||
// Return NULL if the nonce has not been used
|
||||
// Return $nonce if the nonce was previously used
|
||||
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
|
||||
// Should add some clever logic to keep nonces from
|
||||
// being reused - for no we are really trusting
|
||||
// that the timestamp will save us
|
||||
return null;
|
||||
}
|
||||
|
||||
function new_request_token($consumer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function new_access_token($token, $consumer) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage xml
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->dirroot . '/mod/lti/locallib.php');
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
|
||||
require_login($courseid, false);
|
||||
|
||||
$action = required_param('action', PARAM_TEXT);
|
||||
|
||||
$response = new stdClass();
|
||||
|
||||
switch ($action) {
|
||||
case 'find_tool_config':
|
||||
$toolurl = required_param('toolurl', PARAM_RAW);
|
||||
|
||||
$tool = lti_get_tool_by_url_match($toolurl, $courseid);
|
||||
|
||||
if (!empty($tool)) {
|
||||
$response->toolid = $tool->id;
|
||||
$response->toolname = htmlspecialchars($tool->name);
|
||||
$response->tooldomain = htmlspecialchars($tool->tooldomain);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
die;
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class moodle1_mod_lti_handler extends moodle1_mod_handler {
|
||||
|
||||
/** @var moodle1_file_manager */
|
||||
protected $fileman = null;
|
||||
|
||||
/** @var int cmid */
|
||||
protected $moduleid = null;
|
||||
|
||||
/**
|
||||
* Declare the paths in moodle.xml we are able to convert
|
||||
*
|
||||
* The method returns list of {@link convert_path} instances.
|
||||
* For each path returned, the corresponding conversion method must be
|
||||
* defined.
|
||||
*
|
||||
* Note that the path /MOODLE_BACKUP/COURSE/MODULES/MOD/LTI does not
|
||||
* actually exist in the file. The last element with the module name was
|
||||
* appended by the moodle1_converter class.
|
||||
*
|
||||
* @return array of {@link convert_path} instances
|
||||
*/
|
||||
public function get_paths() {
|
||||
|
||||
return array(
|
||||
new convert_path(
|
||||
'basiclti', '/MOODLE_BACKUP/COURSE/MODULES/MOD/LTI'
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/LTI
|
||||
* data available
|
||||
*/
|
||||
public function process_basiclti($data) {
|
||||
global $DB;
|
||||
|
||||
// get the course module id and context id
|
||||
$instanceid = $data['id'];
|
||||
$cminfo = $this->get_cminfo($instanceid);
|
||||
$this->moduleid = $cminfo['id'];
|
||||
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
|
||||
|
||||
// get a fresh new file manager for this instance
|
||||
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_lti');
|
||||
|
||||
// convert course files embedded into the intro
|
||||
$this->fileman->filearea = 'intro';
|
||||
$this->fileman->itemid = 0;
|
||||
$data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
|
||||
|
||||
// start writing assignment.xml
|
||||
$this->open_xml_writer("activities/lti_{$this->moduleid}/lti.xml");
|
||||
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
|
||||
'modulename' => 'lti', 'contextid' => $contextid));
|
||||
$this->xmlwriter->begin_tag('lti', array('id' => $instanceid));
|
||||
|
||||
$ignore_fields = array('id', 'modtype');
|
||||
if (!$DB->record_exists('lti_types', array('id' => $data['typeid']))) {
|
||||
$ntypeid = $DB->get_field('lti_types_config',
|
||||
'typeid',
|
||||
array('name' => 'toolurl', 'value' => $data['toolurl']),
|
||||
IGNORE_MULTIPLE);
|
||||
if ($ntypeid === false) {
|
||||
$ntypeid = $DB->get_field('lti_types_config',
|
||||
'typeid',
|
||||
array(),
|
||||
IGNORE_MULTIPLE);
|
||||
|
||||
}
|
||||
if ($ntypeid === false) {
|
||||
$ntypeid = 0;
|
||||
}
|
||||
$data['typeid'] = $ntypeid;
|
||||
}
|
||||
if (empty($data['servicesalt'])) {
|
||||
$data['servicesalt'] = uniqid('', true);
|
||||
}
|
||||
foreach ($data as $field => $value) {
|
||||
if (!in_array($field, $ignore_fields)) {
|
||||
$this->xmlwriter->full_tag($field, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is executed when we reach the closing </MOD> tag of our 'lti' path
|
||||
*/
|
||||
public function on_basiclti_end() {
|
||||
// finish writing basiclti.xml
|
||||
$this->xmlwriter->end_tag('lti');
|
||||
$this->xmlwriter->end_tag('activity');
|
||||
$this->close_xml_writer();
|
||||
|
||||
// write inforef.xml
|
||||
$this->open_xml_writer("activities/lti_{$this->moduleid}/inforef.xml");
|
||||
$this->xmlwriter->begin_tag('inforef');
|
||||
$this->xmlwriter->begin_tag('fileref');
|
||||
foreach ($this->fileman->get_fileids() as $fileid) {
|
||||
$this->write_xml('file', array('id' => $fileid));
|
||||
}
|
||||
$this->xmlwriter->end_tag('fileref');
|
||||
$this->xmlwriter->end_tag('inforef');
|
||||
$this->close_xml_writer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains the lti module backup class
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/lti/backup/moodle2/backup_lti_stepslib.php');
|
||||
|
||||
/**
|
||||
* lti backup task that provides all the settings and steps to perform one
|
||||
* complete backup of the module
|
||||
*/
|
||||
class backup_lti_activity_task extends backup_activity_task {
|
||||
|
||||
/**
|
||||
* Define (add) particular settings this activity can have
|
||||
*/
|
||||
protected function define_my_settings() {
|
||||
// No particular settings for this activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Define (add) particular steps this activity can have
|
||||
*/
|
||||
protected function define_my_steps() {
|
||||
// Choice only has one structure step
|
||||
$this->add_step(new backup_lti_activity_structure_step('lti_structure', 'lti.xml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Code the transformations to perform in the activity in
|
||||
* order to get transportable (encoded) links
|
||||
*/
|
||||
static public function encode_content_links($content) {
|
||||
global $CFG;
|
||||
|
||||
$base = preg_quote($CFG->wwwroot, "/");
|
||||
|
||||
// Link to the list of basiclti tools
|
||||
$search="/(".$base."\/mod\/lti\/index.php\?id\=)([0-9]+)/";
|
||||
$content= preg_replace($search, '$@LTIINDEX*$2@$', $content);
|
||||
|
||||
// Link to basiclti view by moduleid
|
||||
$search="/(".$base."\/mod\/lti\/view.php\?id\=)([0-9]+)/";
|
||||
$content= preg_replace($search, '$@LTIVIEWBYID*$2@$', $content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains all the backup steps that will be used
|
||||
* by the backup_lti_activity_task
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* Define the complete assignment structure for backup, with file and id annotations
|
||||
*/
|
||||
class backup_lti_activity_structure_step extends backup_activity_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
// To know if we are including userinfo
|
||||
$userinfo = $this->get_setting_value('userinfo');
|
||||
|
||||
// Define each element separated
|
||||
$basiclti = new backup_nested_element('lti', array('id'), array(
|
||||
'name',
|
||||
'intro',
|
||||
'introformat',
|
||||
'timecreated',
|
||||
'timemodified',
|
||||
'typeid',
|
||||
'toolurl',
|
||||
'preferheight',
|
||||
'launchcontainer',
|
||||
'instructorchoicesendname',
|
||||
'instructorchoicesendemailaddr',
|
||||
'instructorchoiceacceptgrades',
|
||||
'instructorchoiceallowroster',
|
||||
'instructorchoiceallowsetting',
|
||||
'grade',
|
||||
'instructorcustomparameters',
|
||||
'showtitle',
|
||||
'showdescription'
|
||||
)
|
||||
);
|
||||
|
||||
// Build the tree
|
||||
// (none)
|
||||
|
||||
// Define sources
|
||||
$basiclti->set_source_table('lti', array('id' => backup::VAR_ACTIVITYID));
|
||||
|
||||
// Define id annotations
|
||||
// (none)
|
||||
|
||||
// Define file annotations
|
||||
$basiclti->annotate_files('mod_lti', 'intro', null); // This file areas haven't itemid
|
||||
|
||||
// Return the root element (basiclti), wrapped into standard activity structure
|
||||
return $this->prepare_activity_structure($basiclti);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains the lti module restore class
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/mod/lti/backup/moodle2/restore_lti_stepslib.php'); // Because it exists (must)
|
||||
|
||||
/**
|
||||
* basiclti restore task that provides all the settings and steps to perform one
|
||||
* complete restore of the activity
|
||||
*/
|
||||
class restore_lti_activity_task extends restore_activity_task {
|
||||
|
||||
/**
|
||||
* Define (add) particular settings this activity can have
|
||||
*/
|
||||
protected function define_my_settings() {
|
||||
// No particular settings for this activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Define (add) particular steps this activity can have
|
||||
*/
|
||||
protected function define_my_steps() {
|
||||
// label only has one structure step
|
||||
$this->add_step(new restore_lti_activity_structure_step('lti_structure', 'lti.xml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the contents in the activity that must be
|
||||
* processed by the link decoder
|
||||
*/
|
||||
static public function define_decode_contents() {
|
||||
$contents = array();
|
||||
|
||||
$contents[] = new restore_decode_content('lti', array('intro'), 'lti');
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the decoding rules for links belonging
|
||||
* to the activity to be executed by the link decoder
|
||||
*/
|
||||
static public function define_decode_rules() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_decode_rule('LTIVIEWBYID', '/mod/lti/view.php?id=$1', 'course_module');
|
||||
$rules[] = new restore_decode_rule('LTIINDEX', '/mod/lti/index.php?id=$1', 'course');
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the restore log rules that will be applied
|
||||
* by the {@link restore_logs_processor} when restoring
|
||||
* basiclti logs. It must return one array
|
||||
* of {@link restore_log_rule} objects
|
||||
*/
|
||||
static public function define_restore_log_rules() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_log_rule('lti', 'add', 'view.php?id={course_module}', '{lti}');
|
||||
$rules[] = new restore_log_rule('lti', 'update', 'view.php?id={course_module}', '{lti}');
|
||||
$rules[] = new restore_log_rule('lti', 'view', 'view.php?id={course_module}', '{lti}');
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the restore log rules that will be applied
|
||||
* by the {@link restore_logs_processor} when restoring
|
||||
* course logs. It must return one array
|
||||
* of {@link restore_log_rule} objects
|
||||
*
|
||||
* Note this rules are applied when restoring course logs
|
||||
* by the restore final task, but are defined here at
|
||||
* activity level. All them are rules not linked to any module instance (cmid = 0)
|
||||
*/
|
||||
static public function define_restore_log_rules_for_course() {
|
||||
$rules = array();
|
||||
|
||||
$rules[] = new restore_log_rule('lti', 'view all', 'index.php?id={course}', null);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains all the restore steps that will be used
|
||||
* by the restore_lti_activity_task
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* Structure step to restore one basiclti activity
|
||||
*/
|
||||
class restore_lti_activity_structure_step extends restore_activity_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
$paths = array();
|
||||
$paths[] = new restore_path_element('lti', '/activity/lti');
|
||||
|
||||
// Return the paths wrapped into standard activity structure
|
||||
return $this->prepare_activity_structure($paths);
|
||||
}
|
||||
|
||||
protected function process_lti($data) {
|
||||
global $DB, $CFG;
|
||||
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
$data->course = $this->get_courseid();
|
||||
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
|
||||
$newitemid = lti_add_instance($data, null);
|
||||
|
||||
// insert the basiclti record
|
||||
//$newitemid = $DB->insert_record('lti', $data);
|
||||
// immediately after inserting "activity" record, call this
|
||||
$this->apply_activity_instance($newitemid);
|
||||
}
|
||||
|
||||
protected function after_execute() {
|
||||
global $DB;
|
||||
|
||||
$basicltis = $DB->get_records('lti');
|
||||
foreach ($basicltis as $basiclti) {
|
||||
if (!$DB->get_record('lti_types_config',
|
||||
array('typeid' => $basiclti->typeid, 'name' => 'toolurl', 'value' => $basiclti->toolurl))) {
|
||||
|
||||
$basiclti->typeid = 0;
|
||||
}
|
||||
|
||||
$basiclti->placementsecret = uniqid('', true);
|
||||
$basiclti->timeplacementsecret = time();
|
||||
|
||||
$DB->update_record('lti', $basiclti);
|
||||
}
|
||||
|
||||
// Add basiclti related files, no need to match by itemname (just internally handled context)
|
||||
$this->add_related_files('mod_lti', 'intro', null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains a library of javasxript functions for the lti module
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @author Charles Severance
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
function basicltiDebugToggle() {
|
||||
var ele = document.getElementById('basicltiDebug');
|
||||
if (ele.style.display == 'block') {
|
||||
ele.style.display = 'none';
|
||||
} else {
|
||||
ele.style.display = 'block';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains the capabilities used by the lti module
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
'mod/lti:view' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'guest' => CAP_ALLOW,
|
||||
'student' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/lti:grade' => array(
|
||||
'riskbitmask' => RISK_XSS,
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/lti:manage' => array(
|
||||
'riskbitmask' => RISK_XSS,
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/lti:addcoursetool' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/lti:requesttooladd' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/lti/db" VERSION="20111018" COMMENT="XMLDB file for Moodle mod/lti"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="lti" COMMENT="This table contains Basic LTI activities instances" NEXT="lti_types">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="course"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Course basiclti activity belongs to" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="name field for moodle instances" PREVIOUS="course" NEXT="intro"/>
|
||||
<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="General introduction of the basiclti activity" PREVIOUS="name" NEXT="introformat"/>
|
||||
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Format of the intro field (MOODLE, HTML, MARKDOWN...)" PREVIOUS="intro" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="introformat" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="typeid"/>
|
||||
<FIELD NAME="typeid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Basic LTI type" PREVIOUS="timemodified" NEXT="toolurl"/>
|
||||
<FIELD NAME="toolurl" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" COMMENT="Remote tool url" PREVIOUS="typeid" NEXT="securetoolurl"/>
|
||||
<FIELD NAME="securetoolurl" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="toolurl" NEXT="instructorchoicesendname"/>
|
||||
<FIELD NAME="instructorchoicesendname" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Send user's name" PREVIOUS="securetoolurl" NEXT="instructorchoicesendemailaddr"/>
|
||||
<FIELD NAME="instructorchoicesendemailaddr" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Send user's email" PREVIOUS="instructorchoicesendname" NEXT="instructorchoiceallowroster"/>
|
||||
<FIELD NAME="instructorchoiceallowroster" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Allow the roster to be retrieved" PREVIOUS="instructorchoicesendemailaddr" NEXT="instructorchoiceallowsetting"/>
|
||||
<FIELD NAME="instructorchoiceallowsetting" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Allow a tool to store a setting" PREVIOUS="instructorchoiceallowroster" NEXT="instructorcustomparameters"/>
|
||||
<FIELD NAME="instructorcustomparameters" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Additional custom parameters provided by the instructor" PREVIOUS="instructorchoiceallowsetting" NEXT="instructorchoiceacceptgrades"/>
|
||||
<FIELD NAME="instructorchoiceacceptgrades" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Accept grades from tool" PREVIOUS="instructorcustomparameters" NEXT="grade"/>
|
||||
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" DECIMALS="5" COMMENT="Grade scale" PREVIOUS="instructorchoiceacceptgrades" NEXT="launchcontainer"/>
|
||||
<FIELD NAME="launchcontainer" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="Launch external tool in a pop-up" PREVIOUS="grade" NEXT="resourcekey"/>
|
||||
<FIELD NAME="resourcekey" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="launchcontainer" NEXT="password"/>
|
||||
<FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="resourcekey" NEXT="debuglaunch"/>
|
||||
<FIELD NAME="debuglaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Enable the debug-style launch which pauses before auto-submit" PREVIOUS="password" NEXT="showtitle"/>
|
||||
<FIELD NAME="showtitle" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="debuglaunch" NEXT="showdescription"/>
|
||||
<FIELD NAME="showdescription" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showtitle" NEXT="servicesalt"/>
|
||||
<FIELD NAME="servicesalt" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false" PREVIOUS="showdescription" NEXT="icon"/>
|
||||
<FIELD NAME="icon" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="servicesalt" NEXT="secureicon"/>
|
||||
<FIELD NAME="secureicon" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="icon"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="lti_types" COMMENT="Basic LTI pre-configured activities" PREVIOUS="lti" NEXT="lti_types_config">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="basiclti Activity" SEQUENCE="false" COMMENT="Activity name" PREVIOUS="id" NEXT="baseurl"/>
|
||||
<FIELD NAME="baseurl" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="tooldomain"/>
|
||||
<FIELD NAME="tooldomain" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="baseurl" NEXT="state"/>
|
||||
<FIELD NAME="state" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="2" SEQUENCE="false" COMMENT="Active = 1, Pending = 2, Rejected = 3" PREVIOUS="tooldomain" NEXT="course"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="state" NEXT="coursevisible"/>
|
||||
<FIELD NAME="coursevisible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="course" NEXT="createdby"/>
|
||||
<FIELD NAME="createdby" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="coursevisible" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="createdby" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="timecreated"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="course" UNIQUE="false" FIELDS="course" NEXT="tooldomain"/>
|
||||
<INDEX NAME="tooldomain" UNIQUE="false" FIELDS="tooldomain" PREVIOUS="course"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="lti_types_config" COMMENT="Basic LTI types configuration" PREVIOUS="lti_types" NEXT="lti_submission">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="typeid"/>
|
||||
<FIELD NAME="typeid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Basic LTI type id" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" COMMENT="Basic LTI param" PREVIOUS="typeid" NEXT="value"/>
|
||||
<FIELD NAME="value" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Param value" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="typeid" UNIQUE="false" FIELDS="typeid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="lti_submission" COMMENT="Keeps track of individual submissions for LTI activities." PREVIOUS="lti_types_config">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="ltiid"/>
|
||||
<FIELD NAME="ltiid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="ID of the LTI tool instance" PREVIOUS="id" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="ltiid" NEXT="datesubmitted"/>
|
||||
<FIELD NAME="datesubmitted" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="userid" NEXT="dateupdated"/>
|
||||
<FIELD NAME="dateupdated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="datesubmitted" NEXT="gradepercent"/>
|
||||
<FIELD NAME="gradepercent" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="5" PREVIOUS="dateupdated" NEXT="originalgrade"/>
|
||||
<FIELD NAME="originalgrade" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="5" PREVIOUS="gradepercent" NEXT="launchid"/>
|
||||
<FIELD NAME="launchid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="originalgrade" NEXT="state"/>
|
||||
<FIELD NAME="state" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="launchid"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="ltiid" UNIQUE="false" FIELDS="ltiid"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file keeps track of upgrades to the lti module
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* xmldb_lti_upgrade is the function that upgrades
|
||||
* the lti module database when is needed
|
||||
*
|
||||
* This function is automaticly called when version number in
|
||||
* version.php changes.
|
||||
*
|
||||
* @param int $oldversion New old version number.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function xmldb_lti_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file defines de main basiclti configuration form
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @author Charles Severance
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
class mod_lti_edit_types_form extends moodleform{
|
||||
public function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add basiclti elements
|
||||
$mform->addElement('header', 'setup', get_string('tool_settings', 'lti'));
|
||||
|
||||
$mform->addElement('text', 'lti_typename', get_string('typename', 'lti'));
|
||||
$mform->setType('lti_typename', PARAM_INT);
|
||||
$mform->addHelpButton('lti_typename', 'typename', 'lti');
|
||||
$mform->addRule('lti_typename', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('text', 'lti_toolurl', get_string('toolurl', 'lti'), array('size'=>'64'));
|
||||
$mform->setType('lti_toolurl', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_toolurl', 'toolurl', 'lti');
|
||||
$mform->addRule('lti_toolurl', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('text', 'lti_resourcekey', get_string('resourcekey_admin', 'lti'));
|
||||
$mform->setType('lti_resourcekey', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_resourcekey', 'resourcekey_admin', 'lti');
|
||||
|
||||
$mform->addElement('passwordunmask', 'lti_password', get_string('password_admin', 'lti'));
|
||||
$mform->setType('lti_password', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_password', 'password_admin', 'lti');
|
||||
|
||||
$mform->addElement('textarea', 'lti_customparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
|
||||
$mform->setType('lti_customparameters', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_customparameters', 'custom', 'lti');
|
||||
|
||||
if (!empty($this->_customdata->isadmin)) {
|
||||
$mform->addElement('checkbox', 'lti_coursevisible', ' ', ' ' . get_string('show_in_course', 'lti'));
|
||||
$mform->addHelpButton('lti_coursevisible', 'show_in_course', 'lti');
|
||||
} else {
|
||||
$mform->addElement('hidden', 'lti_coursevisible', '1');
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'typeid');
|
||||
|
||||
$launchoptions=array();
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
|
||||
|
||||
$mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'lti'), $launchoptions);
|
||||
$mform->setDefault('lti_launchcontainer', LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
|
||||
$mform->addHelpButton('lti_launchcontainer', 'default_launch_container', 'lti');
|
||||
|
||||
// Add privacy preferences fieldset where users choose whether to send their data
|
||||
$mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
|
||||
|
||||
$options=array();
|
||||
$options[0] = get_string('never', 'lti');
|
||||
$options[1] = get_string('always', 'lti');
|
||||
$options[2] = get_string('delegate', 'lti');
|
||||
|
||||
$mform->addElement('select', 'lti_sendname', get_string('share_name_admin', 'lti'), $options);
|
||||
$mform->setDefault('lti_sendname', '2');
|
||||
$mform->addHelpButton('lti_sendname', 'share_name_admin', 'lti');
|
||||
|
||||
$mform->addElement('select', 'lti_sendemailaddr', get_string('share_email_admin', 'lti'), $options);
|
||||
$mform->setDefault('lti_sendemailaddr', '2');
|
||||
$mform->addHelpButton('lti_sendemailaddr', 'share_email_admin', 'lti');
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// LTI Extensions
|
||||
|
||||
// Add grading preferences fieldset where the tool is allowed to return grades
|
||||
$mform->addElement('select', 'lti_acceptgrades', get_string('accept_grades_admin', 'lti'), $options);
|
||||
$mform->setDefault('lti_acceptgrades', '2');
|
||||
$mform->addHelpButton('lti_acceptgrades', 'accept_grades_admin', 'lti');
|
||||
|
||||
// Add grading preferences fieldset where the tool is allowed to retrieve rosters
|
||||
$mform->addElement('select', 'lti_allowroster', get_string('share_roster_admin', 'lti'), $options);
|
||||
$mform->setDefault('lti_allowroster', '2');
|
||||
$mform->addHelpButton('lti_allowroster', 'share_roster_admin', 'lti');
|
||||
|
||||
$mform->addElement('checkbox', 'lti_forcessl', ' ', ' ' . get_string('force_ssl', 'lti'), $options);
|
||||
$mform->setDefault('lti_forcessl', '0');
|
||||
$mform->addHelpButton('lti_forcessl', 'force_ssl', 'lti');
|
||||
|
||||
if (!empty($this->_customdata->isadmin)) {
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add setup parameters fieldset
|
||||
$mform->addElement('header', 'setupoptions', get_string('miscellaneous', 'lti'));
|
||||
|
||||
// Adding option to change id that is placed in context_id
|
||||
$idoptions = array();
|
||||
$idoptions[0] = get_string('id', 'lti');
|
||||
$idoptions[1] = get_string('courseid', 'lti');
|
||||
|
||||
$mform->addElement('text', 'lti_organizationid', get_string('organizationid', 'lti'));
|
||||
$mform->setType('lti_organizationid', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_organizationid', 'organizationid', 'lti');
|
||||
|
||||
$mform->addElement('text', 'lti_organizationurl', get_string('organizationurl', 'lti'));
|
||||
$mform->setType('lti_organizationurl', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_organizationurl', 'organizationurl', 'lti');
|
||||
}
|
||||
|
||||
/* Suppress this for now - Chuck
|
||||
$mform->addElement('text', 'lti_organizationdescr', get_string('organizationdescr', 'lti'));
|
||||
$mform->setType('lti_organizationdescr', PARAM_TEXT);
|
||||
$mform->addHelpButton('lti_organizationdescr', 'organizationdescr', 'lti');
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add a hidden element to signal a tool fixing operation after a problematic backup - restore process
|
||||
//$mform->addElement('hidden', 'lti_fix');
|
||||
|
||||
$tab = optional_param('tab', '', PARAM_ALPHAEXT);
|
||||
$mform->addElement('hidden', 'tab', $tab);
|
||||
|
||||
$courseid = optional_param('course', 1, PARAM_INT);
|
||||
$mform->addElement('hidden', 'course', $courseid);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add standard buttons, common to all modules
|
||||
$this->add_action_buttons();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains submissions-specific code for the lti module
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
require_once($CFG->libdir.'/plagiarismlib.php');
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT); // Course module ID
|
||||
$l = optional_param('l', 0, PARAM_INT); // lti instance ID
|
||||
$mode = optional_param('mode', 'all', PARAM_ALPHA); // What mode are we in?
|
||||
$download = optional_param('download' , 'none', PARAM_ALPHA); //ZIP download asked for?
|
||||
|
||||
if ($l) { // Two ways to specify the module
|
||||
$lti = $DB->get_record('lti', array('id' => $l), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('lti', $lti->id, $lti->course, false, MUST_EXIST);
|
||||
|
||||
} else {
|
||||
$cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST);
|
||||
$lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
|
||||
require_login($course, false, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/lti:grade', $context);
|
||||
|
||||
$url = new moodle_url('/mod/lti/grade.php', array('id' => $cm->id));
|
||||
if ($mode !== 'all') {
|
||||
$url->param('mode', $mode);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
$module = array(
|
||||
'name' => 'mod_lti_submissions',
|
||||
'fullpath' => '/mod/lti/submissions.js',
|
||||
'requires' => array('base'),
|
||||
'strings' => array(),
|
||||
);
|
||||
|
||||
$PAGE->requires->js_init_call('M.mod_lti.submissions.init', array(), true, $module);
|
||||
|
||||
$PAGE->requires->yui2_lib('datatable');
|
||||
|
||||
$submissionquery = '
|
||||
SELECT s.id, u.firstname, u.lastname, u.id AS userid, s.datesubmitted, s.gradepercent
|
||||
FROM {lti_submission} s
|
||||
INNER JOIN {user} u ON s.userid = u.id
|
||||
WHERE s.ltiid = :ltiid
|
||||
ORDER BY s.datesubmitted DESC
|
||||
';
|
||||
|
||||
$submissions = $DB->get_records_sql($submissionquery, array('ltiid' => $lti->id));
|
||||
|
||||
$html = '
|
||||
<noscript>
|
||||
<!-- If javascript is disabled, we need to show the table using CSS.
|
||||
The table starts out hidden to avoid flickering as it loads -->
|
||||
<style type="text/css">
|
||||
#lti_submissions_table_container { display: block !important; }
|
||||
</style>
|
||||
</noscript>
|
||||
|
||||
<div id="lti_submissions_table_container" style="display:none">
|
||||
<table id="lti_submissions_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Date</th>
|
||||
<th>Grade</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!--table body-->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
|
||||
$rowtemplate = '
|
||||
<tr>
|
||||
<td>
|
||||
<!--firstname--> <!--lastname-->
|
||||
</td>
|
||||
<td>
|
||||
<!--datesubmitted-->
|
||||
</td>
|
||||
<td>
|
||||
<!--gradepercent-->
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
$rows = '';
|
||||
|
||||
foreach ($submissions as $submission) {
|
||||
$row = $rowtemplate;
|
||||
|
||||
foreach ($submission as $key => $value) {
|
||||
if ($key === 'datesubmitted') {
|
||||
$value = userdate($value);
|
||||
}
|
||||
|
||||
$row = str_replace('<!--' . $key . '-->', $value, $row);
|
||||
}
|
||||
|
||||
$rows .= $row;
|
||||
}
|
||||
|
||||
$table = str_replace('<!--table body-->', $rows, $html);
|
||||
|
||||
$title = 'Submissions for ' . $lti->name;
|
||||
|
||||
$PAGE->set_title(format_string($title , true));
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title );
|
||||
|
||||
echo $table;
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This page lists all the instances of lti in a particular course
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
|
||||
$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);
|
||||
|
||||
require_login($course);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
add_to_log($course->id, "lti", "view all", "index.php?id=$course->id", "");
|
||||
|
||||
$PAGE->set_url('/mod/lti/index.php', array('id' => $course->id));
|
||||
$pagetitle = strip_tags($course->shortname.': '.get_string("modulenamepluralformatted", "lti"));
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Print the main part of the page
|
||||
echo $OUTPUT->heading(get_string("modulenamepluralformatted", "lti"));
|
||||
|
||||
// Get all the appropriate data
|
||||
if (! $basicltis = get_all_instances_in_course("lti", $course)) {
|
||||
notice(get_string('noltis', 'lti'), "../../course/view.php?id=$course->id");
|
||||
die;
|
||||
}
|
||||
|
||||
// Print the list of instances (your module will probably extend this)
|
||||
$timenow = time();
|
||||
$strname = get_string("name");
|
||||
$strsectionname = get_string('sectionname', 'format_'.$course->format);
|
||||
$usesections = course_format_uses_sections($course->format);
|
||||
if ($usesections) {
|
||||
$sections = get_all_sections($course->id);
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->attributes['class'] = 'generaltable mod_index';
|
||||
|
||||
if ($usesections) {
|
||||
$table->head = array ($strsectionname, $strname);
|
||||
$table->align = array ("center", "left");
|
||||
} else {
|
||||
$table->head = array ($strname);
|
||||
}
|
||||
|
||||
foreach ($basicltis as $basiclti) {
|
||||
if (!$basiclti->visible) {
|
||||
//Show dimmed if the mod is hidden
|
||||
$link = "<a class=\"dimmed\" href=\"view.php?id=$basiclti->coursemodule\">$basiclti->name</a>";
|
||||
} else {
|
||||
//Show normal if the mod is visible
|
||||
$link = "<a href=\"view.php?id=$basiclti->coursemodule\">$basiclti->name</a>";
|
||||
}
|
||||
|
||||
if ($course->format == "weeks" or $course->format == "topics") {
|
||||
$table->data[] = array ($basiclti->section, $link);
|
||||
} else {
|
||||
$table->data[] = array ($link);
|
||||
}
|
||||
}
|
||||
|
||||
echo "<br />";
|
||||
|
||||
echo html_writer::table($table);
|
||||
|
||||
// Finish the page
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/edit_form.php');
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
|
||||
require_login($courseid, false);
|
||||
$url = new moodle_url('/mod/lti/instructor_edit_tool_type.php');
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('popup');
|
||||
|
||||
$action = optional_param('action', null, PARAM_TEXT);
|
||||
$typeid = optional_param('typeid', null, PARAM_INT);
|
||||
|
||||
require_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
|
||||
if (!empty($typeid)) {
|
||||
$type = lti_get_type($typeid);
|
||||
if ($type->course != $courseid) {
|
||||
throw new Exception('You do not have permissions to edit this tool type.');
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
||||
$data = data_submitted();
|
||||
|
||||
if (isset($data->submitbutton) && confirm_sesskey()) {
|
||||
$type = new stdClass();
|
||||
|
||||
if (!empty($typeid)) {
|
||||
$type->id = $typeid;
|
||||
$name = json_encode($data->lti_typename);
|
||||
|
||||
lti_update_type($type, $data);
|
||||
|
||||
$fromdb = lti_get_type($typeid);
|
||||
$json = json_encode($fromdb);
|
||||
|
||||
//Output script to update the calling window.
|
||||
$script = "
|
||||
<html>
|
||||
<script type=\"text/javascript\">
|
||||
window.opener.M.mod_lti.editor.updateToolType({$json});
|
||||
window.close();
|
||||
</script>
|
||||
</html>
|
||||
";
|
||||
|
||||
echo $script;
|
||||
die;
|
||||
} else {
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
$type->course = $COURSE->id;
|
||||
|
||||
$id = lti_add_type($type, $data);
|
||||
|
||||
$fromdb = lti_get_type($id);
|
||||
$json = json_encode($fromdb);
|
||||
|
||||
//Output script to update the calling window.
|
||||
$script = "
|
||||
<html>
|
||||
<script type=\"text/javascript\">
|
||||
window.opener.M.mod_lti.editor.addToolType({$json});
|
||||
window.close();
|
||||
</script>
|
||||
</html>
|
||||
";
|
||||
|
||||
echo $script;
|
||||
|
||||
die;
|
||||
}
|
||||
} else if (isset($data->cancel)) {
|
||||
$script = "
|
||||
<html>
|
||||
<script type=\"text/javascript\">
|
||||
window.close();
|
||||
</script>
|
||||
</html>
|
||||
";
|
||||
|
||||
echo $script;
|
||||
die;
|
||||
}
|
||||
|
||||
//Delete action is called via ajax
|
||||
if ($action == 'delete') {
|
||||
lti_delete_type($typeid);
|
||||
die;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
|
||||
|
||||
if ($action == 'add') {
|
||||
$form = new mod_lti_edit_types_form();
|
||||
$form->display();
|
||||
} else if ($action == 'edit') {
|
||||
$form = new mod_lti_edit_types_form();
|
||||
$type = lti_get_type_type_config($typeid);
|
||||
$form->set_data($type);
|
||||
$form->display();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,628 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains en_utf8 translation of the Basic LTI module
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
//Permissions
|
||||
$string['lti:view'] = 'View LTI activities';
|
||||
$string['lti:grade'] = 'Grade LTI activities';
|
||||
$string['lti:addcoursetool'] = 'Grade LTI activities';
|
||||
$string['lti:requesttooladd'] = 'Submit a tool to admins for configuration';
|
||||
|
||||
$string['accept'] = 'Accept';
|
||||
$string['activity'] = 'Activity';
|
||||
$string['addnewapp'] = 'Enable External Application';
|
||||
$string['addserver'] = 'Add new trusted server';
|
||||
$string['addtype'] = 'Add external tool configuration';
|
||||
$string['allow'] = 'Allow';
|
||||
$string['allowinstructorcustom'] = 'Allow instructors to add custom parameters';
|
||||
$string['share_roster_admin'] = 'Tool may access course roster';
|
||||
$string['allowsetting'] = 'Allow tool to store 8K of settings in Moodle';
|
||||
$string['always'] = 'Always';
|
||||
$string['lti'] = 'LTI';
|
||||
$string['basiclti'] = 'LTI';
|
||||
$string['basiclti_base_string'] = 'LTI OAuth Base String';
|
||||
$string['basiclti_in_new_window'] = 'Your activity has opened in a new window';
|
||||
$string['basiclti_endpoint'] = 'LTI Launch Endpoint';
|
||||
$string['basiclti_parameters'] = 'LTI Launch Parameters';
|
||||
$string['basicltiactivities'] = 'LTI Activities';
|
||||
$string['basicltifieldset'] = 'Custom example fieldset';
|
||||
$string['basicltiintro'] = 'Activity Description';
|
||||
$string['basicltiname'] = 'Activity Name';
|
||||
$string['basicltisettings'] = 'Basic Learning Tool Interoperability Settings';
|
||||
$string['comment'] = 'Comment';
|
||||
$string['configpassword'] = 'Default Remote Tool Password';
|
||||
$string['configpreferheight'] = 'Default preferred height';
|
||||
$string['configpreferwidget'] = 'Set widget as default launch';
|
||||
$string['configpreferwidth'] = 'Default preferred width';
|
||||
$string['configresourceurl'] = 'Default Resource URL';
|
||||
$string['configtoolurl'] = 'Default Remote Tool URL';
|
||||
$string['configtypes'] = 'Enable LTI Applications';
|
||||
$string['courseid'] = 'Course id number';
|
||||
$string['coursemisconf'] = 'Course is misconfigured';
|
||||
$string['curllibrarymissing'] = 'PHP Curl library must be installed to use LTI';
|
||||
$string['custom'] = 'Custom parameters';
|
||||
$string['custominstr'] = 'Custom parameters';
|
||||
$string['debuglaunch'] = 'Debug Option';
|
||||
$string['debuglaunchoff'] = 'Normal launch';
|
||||
$string['debuglaunchon'] = 'Debug launch';
|
||||
$string['donot'] = 'Do not send';
|
||||
$string['donotaccept'] = 'Do not accept';
|
||||
$string['donotallow'] = 'Do not allow';
|
||||
$string['enableemailnotification'] = 'Send notification emails';
|
||||
$string['enableemailnotification_help'] = 'If enabled, students will receive email notification when their tool submissions are graded.';
|
||||
$string['errormisconfig'] = 'Misconfigured tool. Please ask your Moodle administrator to fix the configuration of the tool.';
|
||||
$string['extensions'] = 'LTI Extension Services';
|
||||
$string['failedtoconnect'] = 'Moodle was unable to communicate with the \"$a\" system';
|
||||
$string['filterconfig'] = 'LTI administration';
|
||||
$string['filtername'] = 'LTI';
|
||||
$string['filter_basiclti_configlink'] = 'Configure your preferred sites and their passwords';
|
||||
$string['filter_basiclti_password'] = 'Password is mandatory';
|
||||
$string['fixexistingconf'] = 'Use an existing configuration for the misconfigured instance';
|
||||
$string['fixnew'] = 'New Configuration';
|
||||
$string['fixnewconf'] = 'Define a new configuration for the misconfigured instance';
|
||||
$string['fixold'] = 'Use Existing';
|
||||
$string['grading'] = 'Grade Routing';
|
||||
$string['id'] = 'id';
|
||||
$string['imsroleadmin'] = 'Instructor,Administrator';
|
||||
$string['imsroleinstructor'] = 'Instructor';
|
||||
$string['imsrolelearner'] = 'Learner';
|
||||
$string['invalidid'] = 'LTI ID was incorrect';
|
||||
$string['launch_in_moodle'] = 'Launch tool in moodle';
|
||||
$string['launch_in_popup'] = 'Launch tool in a pop-up';
|
||||
$string['launchinpopup'] = 'Launch Container';
|
||||
$string['launchoptions'] = 'Launch Options';
|
||||
$string['lti_errormsg'] = 'The tool returned the following error message: \"$a\"';
|
||||
$string['misconfiguredtools'] = 'Misconfigured tool instances were detected';
|
||||
$string['missingparameterserror'] = 'The page is misconfigured: \"$a\"';
|
||||
$string['module_class_type'] = 'Moodle module type';
|
||||
$string['modulename'] = 'External Tool';
|
||||
$string['modulenameplural'] = 'basicltis';
|
||||
$string['modulenamepluralformatted'] = 'LTI Instances';
|
||||
$string['never'] = 'Never';
|
||||
$string['noattempts'] = 'No attempts have been made on this tool instance';
|
||||
$string['noltis'] = 'There are no lti instances';
|
||||
$string['noservers'] = 'No servers found';
|
||||
$string['notypes'] = 'There are currently no LTI tools setup in Moodle. Click the Install link above to add some.';
|
||||
$string['noviewusers'] = 'No users were found with permissions to use this tool';
|
||||
$string['optionalsettings'] = 'Optional settings';
|
||||
$string['organization'] ='Organization details';
|
||||
$string['organizationdescr'] ='Organization Description';
|
||||
$string['organizationid'] ='Organization ID';
|
||||
$string['organizationurl'] ='Organization URL';
|
||||
$string['pagesize'] = 'Submissions shown per page';
|
||||
$string['password'] = 'Shared Secret';
|
||||
$string['password_admin'] = 'Shared Secret';
|
||||
$string['pluginadministration'] = 'LTI administration';
|
||||
$string['pluginname'] = 'LTI';
|
||||
$string['preferheight'] = 'Preferred Height';
|
||||
$string['preferwidget'] = 'Prefer Widget Launch';
|
||||
$string['preferwidth'] = 'Preferred Width';
|
||||
$string['press_to_submit'] = 'Press to launch this activity';
|
||||
$string['privacy'] = 'Privacy';
|
||||
$string['quickgrade'] = 'Allow quick grading';
|
||||
$string['quickgrade_help'] = 'If enabled, multiple tools can be graded on one page. Add grades and comments then click the "Save all my feedback" button to save all changes for that page.';
|
||||
$string['redirect'] = 'You will be redirected in few seconds. If you are not, press the button.';
|
||||
$string['resource'] = 'Resource';
|
||||
$string['resourcekey'] = 'Consumer Key';
|
||||
$string['resourcekey_admin'] = 'Consumer Key';
|
||||
$string['resourceurl'] = 'Resource URL';
|
||||
$string['saveallfeedback'] = 'Save all my feedback';
|
||||
$string['send'] = 'Send';
|
||||
$string['share_email_admin'] = 'Share launcher\'s email with tool';
|
||||
$string['share_name_admin'] = 'Share launcher\'s name with tool';
|
||||
$string['setdefault'] = 'Set a default value for the professor if delegating';
|
||||
$string['setupbox'] = 'LTI Tool Setup Box';
|
||||
$string['setupoptions'] = 'Setup Options';
|
||||
$string['size'] = 'Size parameters';
|
||||
$string['submission'] = 'Submission';
|
||||
$string['toggle_debug_data'] = 'Toggle Debug Data';
|
||||
$string['toolsetup'] = 'External Tool Configuration';
|
||||
$string['toolurl'] = 'Tool Base URL';
|
||||
$string['typename'] = 'Tool Name';
|
||||
$string['types'] = 'Types';
|
||||
$string['validurl'] = 'A valid URL must start with http(s)://';
|
||||
$string['viewsubmissions'] = 'View submissions and grading screen';
|
||||
|
||||
//New admin strings
|
||||
$string['show_in_course'] = 'Show tool type when creating tool instances';
|
||||
$string['delegate'] = 'Delegate to Instructor';
|
||||
$string['tool_settings'] = 'Tool Settings';
|
||||
$string['miscellaneous'] = 'Miscellaneous';
|
||||
$string['embed'] = 'Embed';
|
||||
$string['embed_no_blocks'] = 'Embed, without blocks';
|
||||
$string['new_window'] = 'New window';
|
||||
$string['default_launch_container'] = 'Default Launch Container';
|
||||
$string['active'] = 'Active';
|
||||
$string['pending'] = 'Pending';
|
||||
$string['rejected'] = 'Rejected';
|
||||
$string['baseurl'] = 'Base URL';
|
||||
$string['action'] = 'Action';
|
||||
$string['createdon'] = 'Created On';
|
||||
$string['accept'] = 'Accept';
|
||||
$string['update'] = 'Update';
|
||||
$string['delete'] = 'Delete';
|
||||
$string['reject'] = 'Reject';
|
||||
$string['external_tool_types'] = 'External Tool Types';
|
||||
$string['no_lti_configured'] = 'There are no active External Tools configured.';
|
||||
$string['no_lti_pending'] = 'There are no pending External Tools.';
|
||||
$string['no_lti_rejected'] = 'There are no rejected External Tools.';
|
||||
$string['accept_grades_admin'] = 'Accept grades from the tool';
|
||||
$string['force_ssl'] = 'Force SSL';
|
||||
$string['lti_administration'] = 'LTI Administration';
|
||||
|
||||
//New instructor strings
|
||||
$string['display_name'] = 'Display activity name when launched';
|
||||
$string['display_description'] = 'Display activity description when launched';
|
||||
$string['external_tool_type'] = 'External tool type';
|
||||
$string['launch_url'] = 'Launch URL';
|
||||
$string['secure_launch_url'] = 'Secure Launch URL';
|
||||
$string['share_name'] = 'Share launcher\'s name with the tool';
|
||||
$string['share_email'] = 'Share launcher\'s email with the tool';
|
||||
$string['accept_grades'] = 'Accept grades from the tool';
|
||||
$string['share_roster'] = 'Allow the tool to access this course\'s roster';
|
||||
$string['automatic'] = 'Automatic, based on Launch URL';
|
||||
$string['default'] = 'Default';
|
||||
|
||||
$string['edittype'] = 'Edit external tool configuration';
|
||||
$string['deletetype'] = 'Delete external tool configuration';
|
||||
$string['delete_confirmation'] = 'Are you sure you want to delete this external tool configuration?';
|
||||
$string['cannot_edit'] = 'You may not edit this tool configuration.';
|
||||
$string['cannot_delete'] = 'You may not delete this tool configuration.';
|
||||
$string['global_tool_types'] = 'Global tool types';
|
||||
$string['course_tool_types'] = 'Course tool types';
|
||||
|
||||
$string['using_tool_configuration'] = 'Using tool configuration: ';
|
||||
$string['domain_mismatch'] = 'Launch URL\'s domain does not match tool configuration.';
|
||||
$string['custom_config'] = 'Using custom tool configuration.';
|
||||
$string['tool_config_not_found'] = 'Tool configuration not found for this URL.';
|
||||
|
||||
$string['icon_url'] = 'Icon URL';
|
||||
$string['secure_icon_url'] = 'Secure Icon URL';
|
||||
|
||||
$string['return_to_course'] = 'Click <a href="{$a->link}" target="_top">here</a> to return to the course.';
|
||||
|
||||
$string['lti_launch_error'] = 'An error occured when launching the external tool: ';
|
||||
$string['lti_launch_error_unsigned_help'] = '
|
||||
<p>
|
||||
This error may be a result of a missing consumer key and shared secret for the tool provider.
|
||||
</p>
|
||||
<p>
|
||||
If you have a consumer key and shared secret, you may enter it when editing the external tool instance (make sure advanced options are visible).<br />
|
||||
Alternatively, you may create a course level tool provider configuration <a href="{$a->course_tool_editor}">here</a>.
|
||||
</p>
|
||||
';
|
||||
|
||||
$string['lti_launch_error_tool_request'] = '
|
||||
<p>
|
||||
To submit a request for an administrator to complete the tool configuration, click <a href="{$a->admin_request_url}" target="_top">here</a>.
|
||||
</p>
|
||||
';
|
||||
|
||||
$string['lti_tool_request_added'] = '
|
||||
Tool configuration request successfully submitted. You may need to contact an administrator to complete the tool configuration.
|
||||
';
|
||||
|
||||
$string['lti_tool_request_existing'] = '
|
||||
A tool configuration for the tool domain has already been submitted.
|
||||
';
|
||||
|
||||
//Instance help
|
||||
|
||||
$string['external_tool_type_help'] = '
|
||||
The main purpose of a tool configuration is to set up a secure communication channel between Moodle and the tool provider.
|
||||
It also provides an opportunity for configuration defaults and setting up additional services provided by the tool.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b>Automatic, based on Launch URL</b> - This setting should be used in almost all cases. Moodle will select the most appropriate tool configuration
|
||||
based on the Launch URL. Tools configured by both an administrator or within this course will be used.
|
||||
When the Launch URL is specified, Moodle will provide feedback on whether it recognizes it or not. If Moodle does not recognize the Launch URL,
|
||||
you may need to enter the tool configuration details manually.
|
||||
</li>
|
||||
<li>
|
||||
<b>A specific tool type</b> - By selecting a specific tool type, you can force Moodle to use that tool configuration when communicating with the
|
||||
external tool provider. If the Launch URL does not appear to belong to the tool provider, a warning will appear. In some cases, it is not necessary
|
||||
to enter a Launch URL when providing a specific tool type (if not launching to a particular resource within the tool provider).
|
||||
</li>
|
||||
<li>
|
||||
<b>Custom configuration</b> - To setup custom tool configuration on just this instance, show Advanced options, and enter the consumer key and
|
||||
shared secret yourself. If you do not have a consumer key and shared secret, you may be able to request them from the tool provider.
|
||||
Not all tools require a consumer key and shared secret, in which case the fields may be left blank.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<b>Tool type editing:</b><br />
|
||||
|
||||
Three icons are available after the External tool type dropdown list:
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b>Add</b> - Create a course level tool configuration. All External Tool instances in this course may use the tool configuration.
|
||||
</li>
|
||||
<li>
|
||||
<b>Edit</b> - Select a course level tool type from the dropdown, then click this icon. The details of the tool configuration may be edited.
|
||||
</li>
|
||||
<li>
|
||||
<b>Delete</b> - Remove the selected course level tool type.
|
||||
</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
$string['launch_url_help'] = '
|
||||
The Launch URL indicates the web address of the External Tool, and may contain additional information, such as the resource to show.
|
||||
If you are unsure what to enter for the Launch URL, please check with the tool provider for more information.
|
||||
|
||||
If you have selected a specific tool type, you may not need to enter a Launch URL. If the tool link is used to just launch
|
||||
into the tool provider\'s system, and not go to a specific resource, this will likely be the case.
|
||||
';
|
||||
|
||||
$string['secure_launch_url_help'] = '
|
||||
Similar to Launch URL, but used instead of the launch url if high security is required. Moodle will use the
|
||||
secure launch URL instead of the launch URL if the Moodle site is accessed through SSL, or if the tool configuration
|
||||
is set to always launch through SSL.
|
||||
|
||||
The Launch URL may also be set to an https address to force launching through SSL, and this field may be left blank.
|
||||
';
|
||||
|
||||
$string['icon_url_help'] = '
|
||||
The icon URL allows the icon that shows up in the course listing for this activity to be modified. Instead of using the default
|
||||
LTI icon, an icon which conveys the type of activity may be specified.
|
||||
';
|
||||
|
||||
$string['secure_icon_url_help'] = '
|
||||
Similar to the icon URL, but used if the user accessing Moodle securely through SSL. The main purpose for this field is to prevent
|
||||
the browser from warning the user if the underlying page was accessed over SSL, but requesting to show an unsecure image.
|
||||
';
|
||||
|
||||
$string['launchinpopup_help'] = '
|
||||
The launch container affects the display of the tool when launched from the course. Some launch containers provide more screen
|
||||
real estate to the tool, and others provide a more integrated feel with the Moodle environemnt.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b>Default</b> - Use the launch container specified by the tool configuration.
|
||||
</li>
|
||||
<li>
|
||||
<b>Embed</b> - The tool is displayed within the existing Moodle window, in a manner similar to most other Activity types.
|
||||
</li>
|
||||
<li>
|
||||
<b>Embed, without blocks</b> - The tool is displayed within the existing Moodle window, with just the neavigation controls
|
||||
at the top of the page.
|
||||
</li>
|
||||
<li>
|
||||
<b>New window</b> - The tool opens in a new window, occupying all the available space.
|
||||
Depending on the browser, it will open in a new tab or a popup window.
|
||||
It is possible that browsers will prevent the new window from opening.
|
||||
</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
$string['resourcekey_help'] = '
|
||||
For pre-configured tools, it is not necessary to enter a resource key here, as the consumer key will be
|
||||
provided as part of the configuration process.
|
||||
|
||||
This field should be entered if creating a link to a tool provider which is not already configured.
|
||||
If the tool provider is to be used more than once in this course, adding a course tool configuration is a good idea.
|
||||
|
||||
The consumer key can be thought of as a username used to authenticate access to the tool.
|
||||
It can be used by the tool provider to uniquely identify the Moodle site from which users launch into the tool.
|
||||
|
||||
The consumer key must be provided by the tool provider. The method of obtaining a consumer key varies between
|
||||
tool providers. It may be an automated process, or it may require a dialogue with the tool provider.
|
||||
|
||||
Tools which do not require secure communication from Moodle and do not provide additional services (such as grade reporting)
|
||||
may not require a resource key.
|
||||
';
|
||||
|
||||
$string['password_help'] = '
|
||||
For pre-configured tools, it is not necessary to enter a shared secret here, as the shared secret will be
|
||||
provided as part of the configuration process.
|
||||
|
||||
This field should be entered if creating a link to a tool provider which is not already configured.
|
||||
If the tool provider is to be used more than once in this course, adding a course tool configuration is a good idea.
|
||||
|
||||
The shared secret can be thought of as a password used to authenticate access to the tool. It should be provided
|
||||
along with the consumer key from the tool provider.
|
||||
|
||||
Tools which do not require secure communication from Moodle and do not provide additional services (such as grade reporting)
|
||||
may not require a shared secret.
|
||||
';
|
||||
|
||||
$string['custom_help'] = '
|
||||
Custom parameters are settings used by the tool provider. For example, a custom parameter may be used to display
|
||||
a specific resource from the provider.
|
||||
|
||||
It is safe to leave this field unchanged unless directed by the tool provider.
|
||||
';
|
||||
|
||||
$string['share_name_help'] = '
|
||||
Specify whether the full name of the user launching the tool should be shared with the tool provider.
|
||||
The tool provider may need launchers\' names to show meaningful information within the tool.
|
||||
|
||||
Note that this setting may be overriden in the tool configuration.
|
||||
';
|
||||
|
||||
$string['share_email_help'] = '
|
||||
Specify whether the e-mail address of the user launching the tool will be shared with the tool provider.
|
||||
The tool provider may need launcher\'s e-mail addresses to distinguish users with the same name, or send e-mails
|
||||
to users based on actions within the tool.
|
||||
|
||||
Note that this setting may be overriden in the tool configuration.
|
||||
';
|
||||
|
||||
$string['accept_grades_help'] = '
|
||||
Specify whether the tool provider can add, update, read, and delete grades associated only with this external tool instance.
|
||||
|
||||
Some tool providers support reporting grades back to Moodle based on actions taken within the tool, creating a more integrated
|
||||
experience.
|
||||
|
||||
Note that this setting may be overriden in the tool configuration.
|
||||
';
|
||||
|
||||
$string['share_roster_help'] = '
|
||||
Specify whether the tool can access the list of users enrolled in this course.
|
||||
|
||||
Note that this setting may be overriden in the tool configuration.
|
||||
';
|
||||
|
||||
$string['display_name_help'] = '
|
||||
If selected, the activity name (specified above) will display above the tool provider\'s content.
|
||||
|
||||
It is possible that the tool provider may also display the title. This option can prevent the activity title from
|
||||
being displayed twice.
|
||||
|
||||
The title is never displayed when the tool\'s launch container is in a new window.
|
||||
';
|
||||
|
||||
$string['display_description_help'] = '
|
||||
If selected, the activity description (specified above) will display above the tool provider\'s content.
|
||||
|
||||
The description may be used to provide additional instructions for launchers of the tool, but it is not required.
|
||||
|
||||
The description is never displayed when the tool\'s launch container is in a new window.
|
||||
';
|
||||
|
||||
//Admin help
|
||||
$string['typename_help'] = '
|
||||
The tool name is used to identify the tool provider within Moodle. The name entered will be visible
|
||||
to instructors when adding external tools within courses.
|
||||
';
|
||||
|
||||
$string['toolurl_help'] = '
|
||||
The tool base URL is used to match tool launch URLs to the correct tool configuration. Prefxing the URL with http(s) is optional.
|
||||
|
||||
Additionally, the base URL is used as the launch URL if a launch URL is not specified in the external tool instance.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<b>Base URL</b>
|
||||
</td>
|
||||
<td>
|
||||
<b>Matches</b>
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
tool.com
|
||||
</td>
|
||||
<td>
|
||||
tool.com, tool.com/quizzes, tool.com/quizzes/quiz.php?id=10, www.tool.com/quizzes
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
www.tool.com/quizzes
|
||||
</td>
|
||||
<td>
|
||||
tool.com/quizzes, tool.com/quizzes/take.php?id=10, www.tool.com/quizzes
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
quiz.tool.com
|
||||
</td>
|
||||
<td>
|
||||
quiz.tool.com, quiz.tool.com/take.php?id=10
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
If two different tool configurations are for the same domain, the most specific match will be used.
|
||||
';
|
||||
|
||||
$string['resourcekey_admin_help'] = '
|
||||
The consumer key can be thought of as a username used to authenticate access to the tool.
|
||||
It can be used by the tool provider to uniquely identify the Moodle site from which users launch into the tool.
|
||||
|
||||
The consumer key must be provided by the tool provider. The method of obtaining a consumer key varies between
|
||||
tool providers. It may be an automated process, or it may require a dialogue with the tool provider.
|
||||
|
||||
Tools which do not require secure communication from Moodle and do not provide additional services (such as grade reporting)
|
||||
may not require a resource key.
|
||||
';
|
||||
|
||||
$string['password_admin_help'] = '
|
||||
The shared secret can be thought of as a password used to authenticate access to the tool. It should be provided
|
||||
along with the consumer key from the tool provider.
|
||||
|
||||
Tools which do not require secure communication from Moodle and do not provide additional services (such as grade reporting)
|
||||
may not require a shared secret.
|
||||
';
|
||||
|
||||
$string['show_in_course_help'] = '
|
||||
If selected, this tool configuration will appear in the "External tool type" dropdown when instructors
|
||||
configure external tools within courses.
|
||||
|
||||
In most cases, this option does not need to be selected. Instructors can use this tool configuration
|
||||
based on the Launch URL matching the Tool base URL, which is the preferred method.
|
||||
|
||||
The only case in which this option should be selected is if the tool configuration is just intended for single sign on.
|
||||
For example, if all launches to the tool provider just take the user to a landing page instead of to a specific resource.
|
||||
';
|
||||
|
||||
$string['default_launch_container_help'] = '
|
||||
The launch container affects the display of the tool when launched from the course. Some launch containers provide more screen
|
||||
real estate to the tool, and others provide a more integrated feel with the Moodle environemnt.
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b>Default</b> - Use the launch container specified by the tool configuration.
|
||||
</li>
|
||||
<li>
|
||||
<b>Embed</b> - The tool is displayed within the existing Moodle window, in a manner similar to most other Activity types.
|
||||
</li>
|
||||
<li>
|
||||
<b>Embed, without blocks</b> - The tool is displayed within the existing Moodle window, with just the neavigation controls
|
||||
at the top of the page.
|
||||
</li>
|
||||
<li>
|
||||
<b>New window</b> - The tool opens in a new window, occupying all the available space.
|
||||
Depending on the browser, it will open in a new tab or a popup window.
|
||||
It is possible that browsers will prevent the new window from opening.
|
||||
</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
$string['share_name_admin_help'] = '
|
||||
Specify whether the full name of the user launching the tool should be shared with the tool provider.
|
||||
The tool provider may need launchers\' names to show meaningful information within the tool.
|
||||
';
|
||||
|
||||
$string['share_email_admin_help'] = '
|
||||
Specify whether the e-mail address of the user launching the tool will be shared with the tool provider.
|
||||
The tool provider may need launcher\'s e-mail addresses to distinguish users with the same name in the UI, or send e-mails
|
||||
to users based on actions within the tool.
|
||||
';
|
||||
|
||||
$string['accept_grades_admin_help'] = '
|
||||
Specify whether the tool provider can add, update, read, and delete grades associated with instances of this tool type.
|
||||
|
||||
Some tool providers support reporting grades back to Moodle based on actions taken within the tool, creating a more integrated
|
||||
experience.
|
||||
';
|
||||
|
||||
$string['share_roster_admin_help'] = '
|
||||
Specify whether the tool can access the list of users enrolled in courses from which this tool type is launched.
|
||||
';
|
||||
|
||||
$string['main_admin'] = 'General help';
|
||||
|
||||
$string['main_admin_help'] = '
|
||||
External tools allow Moodle users to seamlessly interact with learning resources hosted remotely. Through a special
|
||||
launch protocol, the remote tool will have access to some general information about the launching user. For example,
|
||||
the institution name, course id, user id, and other information such as the user\'s name or e-mail address.
|
||||
|
||||
Tool types listed on this page are separated into three categories:
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b>Active</b> - These tool providers have been approved and configured by an administrator. They can be used from within any
|
||||
course on this Moodle instance. If a consumer key and shared secret are entered, a trust relationship is established
|
||||
between this Moodle instance and the remote tool, providing a secure communication channel.
|
||||
</li>
|
||||
<li>
|
||||
<b>Pending</b> - These tool providers came in through a package import, but have not been configured by an administrator.
|
||||
Instructors may still use tools from these providers if they have a consumer key and shared secret, or if none is required.
|
||||
</li>
|
||||
<li>
|
||||
<b>Rejected</b> - These tools providers are flagged as ones which an administrator has no intention of making available to the entire
|
||||
Moodle instance. Instructors may still use tools from these providers if they have a consumer key and shared secret, or if none is required.
|
||||
</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
$string['modulename_help'] = '
|
||||
External tools allow Moodle users to interact with learning resources and activities on other web sites. For instance, an
|
||||
external tool could provide access to a new activity type or learning materials from a publisher.
|
||||
|
||||
To setup an external tool instance a tool provider which supports LTI (Learning Tools Interoperability) is required.
|
||||
If you find a tool provider which supports LTI, they should be able to provide instructions on how to configure the
|
||||
external tool instance. Additionally, tool types configured by a site administrator will also be available for use.
|
||||
|
||||
External tools differ from URL resources in a few ways:
|
||||
<ul>
|
||||
<li>
|
||||
<b>Context aware</b> - External tools have access to information about the user who launched the tool, such as
|
||||
insitution, course, name, and other information.
|
||||
</li>
|
||||
<li>
|
||||
<b>Deep integration</b> - External tools support reading, updating, and deleting grades associated with the activity instance. More integration points
|
||||
are planned for future releases.
|
||||
</li>
|
||||
<li>
|
||||
<b>Security</b> - External tool configurations create a trust relationship between Moodle and the tool provider, allowing secure communication
|
||||
between them.
|
||||
</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
$string['force_ssl_help'] = '
|
||||
Selecting this option forces all launches to this tool provider to use SSL.
|
||||
|
||||
In addition, all web service requests from the tool provider will use SSL.
|
||||
|
||||
If using this option, confirm that this Moodle site and the tool provider support SSL.
|
||||
';
|
||||
|
||||
$string['organizationid_help'] = '
|
||||
A unique identifier for this Moodle instance. Typically, the DNS name of the organization is used.
|
||||
|
||||
If this field is left blank, the host name of this Moodle site will be used as the default value.
|
||||
';
|
||||
|
||||
$string['organizationurl_help'] = '
|
||||
The base URL of this Moodle instance.
|
||||
|
||||
If this field is left blank, a default value will be used based on the site configuration.
|
||||
';
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains all necessary code to view a lti activity instance
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
|
||||
$cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST);
|
||||
$lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
|
||||
require_login($course);
|
||||
|
||||
add_to_log($course->id, "lti", "launch", "launch.php?id=$cm->id", "$lti->id");
|
||||
|
||||
$lti->cmid = $cm->id;
|
||||
lti_view($lti);
|
||||
|
||||
+411
@@ -0,0 +1,411 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains a library of functions and constants for the lti module
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* List of features supported in URL module
|
||||
* @param string $feature FEATURE_xx constant for requested feature
|
||||
* @return mixed True if module supports feature, false if not, null if doesn't know
|
||||
*/
|
||||
function lti_supports($feature) {
|
||||
switch($feature) {
|
||||
case FEATURE_GROUPS: return false;
|
||||
case FEATURE_GROUPINGS: return false;
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
case FEATURE_BACKUP_MOODLE2: return true;
|
||||
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an object containing all the necessary data,
|
||||
* (defined by the form in mod.html) this function
|
||||
* will create a new instance and return the id number
|
||||
* of the new instance.
|
||||
*
|
||||
* @param object $instance An object from the form in mod.html
|
||||
* @return int The id of the newly inserted basiclti record
|
||||
**/
|
||||
function lti_add_instance($lti, $mform) {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$lti->timecreated = time();
|
||||
$lti->timemodified = $lti->timecreated;
|
||||
$lti->servicesalt = uniqid('', true);
|
||||
|
||||
if (!isset($lti->grade)) {
|
||||
$lti->grade = 100; // TODO: Why is this harcoded here and default @ DB
|
||||
}
|
||||
|
||||
$lti->id = $DB->insert_record('lti', $lti);
|
||||
|
||||
if ($lti->instructorchoiceacceptgrades == LTI_SETTING_ALWAYS) {
|
||||
if (!isset($lti->cmidnumber)) {
|
||||
$lti->cmidnumber = '';
|
||||
}
|
||||
|
||||
lti_grade_item_update($lti);
|
||||
}
|
||||
|
||||
return $lti->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an object containing all the necessary data,
|
||||
* (defined by the form in mod.html) this function
|
||||
* will update an existing instance with new data.
|
||||
*
|
||||
* @param object $instance An object from the form in mod.html
|
||||
* @return boolean Success/Fail
|
||||
**/
|
||||
function lti_update_instance($lti, $mform) {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$lti->timemodified = time();
|
||||
$lti->id = $lti->instance;
|
||||
|
||||
if (!isset($lti->showtitle)) {
|
||||
$lti->showtitle = 0;
|
||||
}
|
||||
|
||||
if (!isset($lti->showdescription)) {
|
||||
$lti->showdescription = 0;
|
||||
}
|
||||
|
||||
if (!isset($lti->grade)) {
|
||||
$lti->grade = $DB->get_field('lti', 'grade', array('id' => $lti->id));
|
||||
}
|
||||
|
||||
if ($lti->instructorchoiceacceptgrades == LTI_SETTING_ALWAYS) {
|
||||
lti_grade_item_update($lti);
|
||||
} else {
|
||||
lti_grade_item_delete($lti);
|
||||
}
|
||||
|
||||
return $DB->update_record('lti', $lti);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an ID of an instance of this module,
|
||||
* this function will permanently delete the instance
|
||||
* and any data that depends on it.
|
||||
*
|
||||
* @param int $id Id of the module instance
|
||||
* @return boolean Success/Failure
|
||||
**/
|
||||
function lti_delete_instance($id) {
|
||||
global $DB;
|
||||
|
||||
if (! $basiclti = $DB->get_record("lti", array("id" => $id))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = true;
|
||||
|
||||
# Delete any dependent records here #
|
||||
lti_grade_item_delete($basiclti);
|
||||
|
||||
return $DB->delete_records("lti", array("id" => $basiclti->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a coursemodule object, this function returns the extra
|
||||
* information needed to print this activity in various places.
|
||||
* For this module we just need to support external urls as
|
||||
* activity icons
|
||||
*
|
||||
* @param cm_info $coursemodule
|
||||
* @return cached_cm_info info
|
||||
*/
|
||||
function lti_get_coursemodule_info($coursemodule) {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
if (!$lti = $DB->get_record('lti', array('id' => $coursemodule->instance),
|
||||
'icon, secureicon')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$info = new cached_cm_info();
|
||||
|
||||
// We want to use the right icon based on whether the
|
||||
// current page is being requested over http or https.
|
||||
if (lti_request_is_using_ssl() && !empty($lti->secureicon)) {
|
||||
$info->iconurl = new moodle_url($lti->secureicon);
|
||||
} else if (!empty($lti->icon)) {
|
||||
$info->iconurl = new moodle_url($lti->icon);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a small object with summary information about what a
|
||||
* user has done with a given particular instance of this module
|
||||
* Used for user activity reports.
|
||||
* $return->time = the time they did it
|
||||
* $return->info = a short text description
|
||||
*
|
||||
* @return null
|
||||
* @TODO: implement this moodle function (if needed)
|
||||
**/
|
||||
function lti_user_outline($course, $user, $mod, $basiclti) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a detailed representation of what a user has done with
|
||||
* a given particular instance of this module, for user activity reports.
|
||||
*
|
||||
* @return boolean
|
||||
* @TODO: implement this moodle function (if needed)
|
||||
**/
|
||||
function lti_user_complete($course, $user, $mod, $basiclti) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a course and a time, this module should find recent activity
|
||||
* that has occurred in basiclti activities and print it out.
|
||||
* Return true if there was output, or false is there was none.
|
||||
*
|
||||
* @uses $CFG
|
||||
* @return boolean
|
||||
* @TODO: implement this moodle function
|
||||
**/
|
||||
function lti_print_recent_activity($course, $isteacher, $timestart) {
|
||||
return false; // True if anything was printed, otherwise false
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to be run periodically according to the moodle cron
|
||||
* This function searches for things that need to be done, such
|
||||
* as sending out mail, toggling flags etc ...
|
||||
*
|
||||
* @uses $CFG
|
||||
* @return boolean
|
||||
**/
|
||||
function lti_cron () {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must return an array of grades for a given instance of this module,
|
||||
* indexed by user. It also returns a maximum allowed grade.
|
||||
*
|
||||
* Example:
|
||||
* $return->grades = array of grades;
|
||||
* $return->maxgrade = maximum allowed grade;
|
||||
*
|
||||
* return $return;
|
||||
*
|
||||
* @param int $basicltiid ID of an instance of this module
|
||||
* @return mixed Null or object with an array of grades and with the maximum grade
|
||||
*
|
||||
* @TODO: implement this moodle function (if needed)
|
||||
**/
|
||||
function lti_grades($basicltiid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must return an array of user records (all data) who are participants
|
||||
* for a given instance of basiclti. Must include every user involved
|
||||
* in the instance, independient of his role (student, teacher, admin...)
|
||||
* See other modules as example.
|
||||
*
|
||||
* @param int $basicltiid ID of an instance of this module
|
||||
* @return mixed boolean/array of students
|
||||
*
|
||||
* @TODO: implement this moodle function
|
||||
**/
|
||||
function lti_get_participants($basicltiid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns if a scale is being used by one basiclti
|
||||
* it it has support for grading and scales. Commented code should be
|
||||
* modified if necessary. See forum, glossary or journal modules
|
||||
* as reference.
|
||||
*
|
||||
* @param int $basicltiid ID of an instance of this module
|
||||
* @return mixed
|
||||
*
|
||||
* @TODO: implement this moodle function (if needed)
|
||||
**/
|
||||
function lti_scale_used ($basicltiid, $scaleid) {
|
||||
$return = false;
|
||||
|
||||
//$rec = get_record("basiclti","id","$basicltiid","scale","-$scaleid");
|
||||
//
|
||||
//if (!empty($rec) && !empty($scaleid)) {
|
||||
// $return = true;
|
||||
//}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if scale is being used by any instance of basiclti.
|
||||
* This function was added in 1.9
|
||||
*
|
||||
* This is used to find out if scale used anywhere
|
||||
* @param $scaleid int
|
||||
* @return boolean True if the scale is used by any basiclti
|
||||
*
|
||||
*/
|
||||
function lti_scale_used_anywhere($scaleid) {
|
||||
global $DB;
|
||||
|
||||
if ($scaleid and $DB->record_exists('lti', array('grade' => -$scaleid))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute post-install custom actions for the module
|
||||
* This function was added in 1.9
|
||||
*
|
||||
* @return boolean true if success, false on error
|
||||
*/
|
||||
function lti_install() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute post-uninstall custom actions for the module
|
||||
* This function was added in 1.9
|
||||
*
|
||||
* @return boolean true if success, false on error
|
||||
*/
|
||||
function lti_uninstall() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns available Basic LTI types
|
||||
*
|
||||
* @return array of basicLTI types
|
||||
*/
|
||||
function lti_get_lti_types() {
|
||||
global $DB;
|
||||
|
||||
return $DB->get_records('lti_types');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create grade item for given basiclti
|
||||
*
|
||||
* @param object $basiclti object with extra cmidnumber
|
||||
* @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
|
||||
* @return int 0 if ok, error code otherwise
|
||||
*/
|
||||
function lti_grade_item_update($basiclti, $grades=null) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
$params = array('itemname'=>$basiclti->name, 'idnumber'=>$basiclti->cmidnumber);
|
||||
|
||||
if ($basiclti->grade > 0) {
|
||||
$params['gradetype'] = GRADE_TYPE_VALUE;
|
||||
$params['grademax'] = $basiclti->grade;
|
||||
$params['grademin'] = 0;
|
||||
|
||||
} else if ($basiclti->grade < 0) {
|
||||
$params['gradetype'] = GRADE_TYPE_SCALE;
|
||||
$params['scaleid'] = -$basiclti->grade;
|
||||
|
||||
} else {
|
||||
$params['gradetype'] = GRADE_TYPE_TEXT; // allow text comments only
|
||||
}
|
||||
|
||||
if ($grades === 'reset') {
|
||||
$params['reset'] = true;
|
||||
$grades = null;
|
||||
}
|
||||
|
||||
return grade_update('mod/lti', $basiclti->course, 'mod', 'lti', $basiclti->id, 0, $grades, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete grade item for given basiclti
|
||||
*
|
||||
* @param object $basiclti object
|
||||
* @return object basiclti
|
||||
*/
|
||||
function lti_grade_item_delete($basiclti) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
return grade_update('mod/lti', $basiclti->course, 'mod', 'lti', $basiclti->id, 0, null, array('deleted'=>1));
|
||||
}
|
||||
|
||||
function lti_extend_settings_navigation($settings, $parentnode) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('mod/lti:grade', get_context_instance(CONTEXT_MODULE, $PAGE->cm->id))) {
|
||||
$keys = $parentnode->get_children_key_list();
|
||||
|
||||
$node = navigation_node::create('Submissions',
|
||||
new moodle_url('/mod/lti/grade.php', array('id'=>$PAGE->cm->id)),
|
||||
navigation_node::TYPE_SETTING, null, 'mod_lti_submissions');
|
||||
|
||||
$parentnode->add_node($node, $keys[1]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains some functions and classes used by the lti
|
||||
* module administration
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
/**
|
||||
*
|
||||
* @TODO: finish doc this class and it's functions
|
||||
*/
|
||||
class admin_setting_ltimodule_configlink extends admin_setting {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param string $name of setting
|
||||
* @param string $visiblename localised
|
||||
* @param string $description long localised info
|
||||
*/
|
||||
public function __construct($name, $visiblename, $description) {
|
||||
parent::__construct($name, $visiblename, $description, '');
|
||||
}
|
||||
|
||||
public function get_setting() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function write_setting($data) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public function output_html($data, $query='') {
|
||||
global $CFG;
|
||||
return format_admin_setting($this, "",
|
||||
'<div class="defaultsnext" >'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/lti/typessettings.php">'.get_string('filterconfig', 'lti').'</a>'.
|
||||
'</div>',
|
||||
$this->description, true, '', null, $query);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,350 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
(function(){
|
||||
var Y;
|
||||
|
||||
M.mod_lti = M.mod_lti || {};
|
||||
|
||||
M.mod_lti.editor = {
|
||||
init: function(yui3, settings){
|
||||
if(yui3){
|
||||
Y = yui3;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
this.settings = Y.JSON.parse(settings);
|
||||
|
||||
this.urlCache = {};
|
||||
|
||||
this.addOptGroups();
|
||||
|
||||
var updateToolMatches = function(){
|
||||
self.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
self.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
};
|
||||
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
typeSelector.on('change', function(e){
|
||||
updateToolMatches();
|
||||
|
||||
self.toggleEditButtons();
|
||||
});
|
||||
|
||||
this.createTypeEditorButtons();
|
||||
|
||||
this.toggleEditButtons();
|
||||
|
||||
var textAreas = new Y.NodeList([
|
||||
Y.one('#id_toolurl'),
|
||||
Y.one('#id_securetoolurl'),
|
||||
Y.one('#id_resourcekey'),
|
||||
Y.one('#id_password')
|
||||
]);
|
||||
|
||||
var debounce;
|
||||
textAreas.on('keyup', function(e){
|
||||
clearTimeout(debounce);
|
||||
|
||||
//If no more changes within 2 seconds, look up the matching tool URL
|
||||
debounce = setTimeout(function(){
|
||||
updateToolMatches();
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
updateToolMatches();
|
||||
},
|
||||
|
||||
clearToolCache: function(){
|
||||
this.urlCache = {};
|
||||
},
|
||||
|
||||
updateAutomaticToolMatch: function(field){
|
||||
var self = this;
|
||||
|
||||
var toolurl = field;
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
var id = field.get('id') + '_lti_automatch_tool';
|
||||
var automatchToolDisplay = Y.one('#' + id);
|
||||
|
||||
if(!automatchToolDisplay){
|
||||
automatchToolDisplay = Y.Node.create('<span />')
|
||||
.set('id', id)
|
||||
.setStyle('padding-left', '1em');
|
||||
|
||||
toolurl.insert(automatchToolDisplay, 'after');
|
||||
}
|
||||
|
||||
var url = toolurl.get('value');
|
||||
|
||||
//Hide the display if the url box is empty
|
||||
if(!url){
|
||||
automatchToolDisplay.setStyle('display', 'none');
|
||||
} else {
|
||||
automatchToolDisplay.set('innerHTML', '');
|
||||
automatchToolDisplay.setStyle('display', '');
|
||||
}
|
||||
|
||||
var selectedToolType = typeSelector.get('value');
|
||||
var selectedOption = typeSelector.one('option[value="' + selectedToolType + '"]');
|
||||
|
||||
//A specific tool type is selected (not "auto")
|
||||
if(selectedToolType > 0){
|
||||
//If the entered domain matches the domain of the tool configuration...
|
||||
var domainRegex = /(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i;
|
||||
var match = domainRegex.exec(url);
|
||||
if(match && match[1] && match[1].toLowerCase() === selectedOption.getAttribute('domain').toLowerCase()){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url + '" />' + M.str.lti.using_tool_configuration + selectedOption.get('text'));
|
||||
} else {
|
||||
//The entered URL does not match the domain of the tool configuration
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.warning_icon_url + '" />' + M.str.lti.domain_mismatch);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var key = Y.one('#id_resourcekey');
|
||||
var secret = Y.one('#id_password');
|
||||
|
||||
//We don't care what tool type this tool is associated with if it's manually configured'
|
||||
if(key.get('value') !== '' && secret.get('value') !== ''){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url + '" />' + M.str.lti.custom_config);
|
||||
} else {
|
||||
var continuation = function(toolInfo){
|
||||
if(toolInfo.toolname){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.green_check_icon_url + '" />' + M.str.lti.using_tool_configuration + toolInfo.toolname);
|
||||
} else {
|
||||
//Inform them custom configuration is in use
|
||||
if(key.get('value') === '' || secret.get('value') === ''){
|
||||
automatchToolDisplay.set('innerHTML', '<img style="vertical-align:text-bottom" src="' + self.settings.warning_icon_url + '" />' + M.str.lti.tool_config_not_found);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Cache urls which have already been checked to increaes performance
|
||||
if(self.urlCache[url]){
|
||||
continuation(self.urlCache[url]);
|
||||
} else {
|
||||
self.findToolByUrl(url, function(toolInfo){
|
||||
self.urlCache[url] = toolInfo;
|
||||
|
||||
continuation(toolInfo);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getSelectedToolTypeOption: function(){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
return typeSelector.one('option[value="' + typeSelector.get('value') + '"]');
|
||||
},
|
||||
|
||||
/**
|
||||
* Separate tool listing into option groups. Server-side select control
|
||||
* doesn't seem to support this.
|
||||
*/
|
||||
addOptGroups: function(){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
if(typeSelector.one('option[courseTool=1]')){
|
||||
//One ore more course tools exist
|
||||
|
||||
var globalGroup = Y.Node.create('<optgroup />')
|
||||
.set('id', 'global_tool_group')
|
||||
.set('label', M.str.lti.global_tool_types);
|
||||
|
||||
var courseGroup = Y.Node.create('<optgroup />')
|
||||
.set('id', 'course_tool_group')
|
||||
.set('label', M.str.lti.course_tool_types);
|
||||
|
||||
var globalOptions = typeSelector.all('option[globalTool=1]').remove().each(function(node){
|
||||
globalGroup.append(node);
|
||||
});
|
||||
|
||||
var courseOptions = typeSelector.all('option[courseTool=1]').remove().each(function(node){
|
||||
courseGroup.append(node);
|
||||
});
|
||||
|
||||
if(globalOptions.size() > 0){
|
||||
typeSelector.append(globalGroup);
|
||||
}
|
||||
|
||||
if(courseOptions.size() > 0){
|
||||
typeSelector.append(courseGroup);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds buttons for creating, editing, and deleting tool types.
|
||||
* Javascript is a requirement to edit course level tools at this point.
|
||||
*/
|
||||
createTypeEditorButtons: function(){
|
||||
var self = this;
|
||||
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
var createIcon = function(id, tooltip, iconUrl){
|
||||
return Y.Node.create('<a />')
|
||||
.set('id', id)
|
||||
.set('title', tooltip)
|
||||
.setStyle('margin-left', '.5em')
|
||||
.set('href', 'javascript:void(0);')
|
||||
.append(Y.Node.create('<img src="' + iconUrl + '" />'));
|
||||
}
|
||||
|
||||
var addIcon = createIcon('lti_add_tool_type', M.str.lti.addtype, this.settings.add_icon_url);
|
||||
var editIcon = createIcon('lti_edit_tool_type', M.str.lti.edittype, this.settings.edit_icon_url);
|
||||
var deleteIcon = createIcon('lti_delete_tool_type', M.str.lti.deletetype, this.settings.delete_icon_url);
|
||||
|
||||
editIcon.on('click', function(e){
|
||||
var toolTypeId = typeSelector.get('value');
|
||||
|
||||
if(self.getSelectedToolTypeOption().getAttribute('editable')){
|
||||
window.open(self.settings.instructor_tool_type_edit_url + '&action=edit&typeid=' + toolTypeId, 'edit_tool');
|
||||
} else {
|
||||
alert(M.str.lti.cannot_edit);
|
||||
}
|
||||
});
|
||||
|
||||
addIcon.on('click', function(e){
|
||||
window.open(self.settings.instructor_tool_type_edit_url + '&action=add', 'add_tool');
|
||||
});
|
||||
|
||||
deleteIcon.on('click', function(e){
|
||||
var toolTypeId = typeSelector.get('value');
|
||||
|
||||
if(self.getSelectedToolTypeOption().getAttribute('editable')){
|
||||
if(confirm(M.str.lti.delete_confirmation)){
|
||||
self.deleteTool(toolTypeId);
|
||||
}
|
||||
} else {
|
||||
alert(M.str.lti.cannot_delete);
|
||||
}
|
||||
});
|
||||
|
||||
typeSelector.insert(addIcon, 'after');
|
||||
addIcon.insert(editIcon, 'after');
|
||||
editIcon.insert(deleteIcon, 'after');
|
||||
},
|
||||
|
||||
toggleEditButtons: function(){
|
||||
var lti_edit_tool_type = Y.one('#lti_edit_tool_type');
|
||||
var lti_delete_tool_type = Y.one('#lti_delete_tool_type');
|
||||
|
||||
//Make the edit / delete icons look enabled / disabled.
|
||||
//Does not work in older browsers, but alerts will catch those cases.
|
||||
if(this.getSelectedToolTypeOption().getAttribute('editable')){
|
||||
lti_edit_tool_type.setStyle('opacity', '1');
|
||||
lti_delete_tool_type.setStyle('opacity', '1');
|
||||
} else {
|
||||
lti_edit_tool_type.setStyle('opacity', '.2');
|
||||
lti_delete_tool_type.setStyle('opacity', '.2');
|
||||
}
|
||||
},
|
||||
|
||||
addToolType: function(toolType){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
var course_tool_group = Y.one('#course_tool_group');
|
||||
|
||||
var option = Y.Node.create('<option />')
|
||||
.set('text', toolType.name)
|
||||
.set('value', toolType.id)
|
||||
.set('selected', 'selected')
|
||||
.setAttribute('editable', '1')
|
||||
.setAttribute('courseTool', '1')
|
||||
.setAttribute('domain', toolType.tooldomain);
|
||||
|
||||
if(course_tool_group){
|
||||
course_tool_group.append(option);
|
||||
} else {
|
||||
typeSelector.append(option);
|
||||
}
|
||||
|
||||
//Adding the new tool may affect which tool gets matched automatically
|
||||
this.clearToolCache();
|
||||
this.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
this.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
},
|
||||
|
||||
updateToolType: function(toolType){
|
||||
var typeSelector = Y.one('#id_typeid');
|
||||
|
||||
var option = typeSelector.one('option[value="' + toolType.id + '"]');
|
||||
option.set('text', toolType.name)
|
||||
.set('domain', toolType.tooldomain);
|
||||
|
||||
//Editing the tool may affect which tool gets matched automatically
|
||||
this.clearToolCache();
|
||||
this.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
this.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
},
|
||||
|
||||
deleteTool: function(toolTypeId){
|
||||
var self = this;
|
||||
|
||||
Y.io(self.settings.instructor_tool_type_edit_url + '&action=delete&typeid=' + toolTypeId, {
|
||||
on: {
|
||||
success: function(){
|
||||
self.getSelectedToolTypeOption().remove();
|
||||
|
||||
//Editing the tool may affect which tool gets matched automatically
|
||||
self.clearToolCache();
|
||||
self.updateAutomaticToolMatch(Y.one('#id_toolurl'));
|
||||
self.updateAutomaticToolMatch(Y.one('#id_securetoolurl'));
|
||||
},
|
||||
failure: function(){
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
findToolByUrl: function(url, callback){
|
||||
var self = this;
|
||||
|
||||
Y.io(self.settings.ajax_url, {
|
||||
data: {action: 'find_tool_config',
|
||||
course: self.settings.courseId,
|
||||
toolurl: url
|
||||
},
|
||||
|
||||
on: {
|
||||
success: function(transactionid, xhr){
|
||||
var response = xhr.response;
|
||||
|
||||
var toolInfo = Y.JSON.parse(response);
|
||||
|
||||
callback(toolInfo);
|
||||
},
|
||||
failure: function(){
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file defines the main lti configuration form
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
class mod_lti_mod_form extends moodleform_mod {
|
||||
|
||||
public function definition() {
|
||||
global $DB, $PAGE, $OUTPUT, $USER, $COURSE;
|
||||
|
||||
$this->typeid = 0;
|
||||
|
||||
$mform =& $this->_form;
|
||||
//-------------------------------------------------------------------------------
|
||||
// Adding the "general" fieldset, where all the common settings are shown
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
// Adding the standard "name" field
|
||||
$mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64'));
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
// Adding the optional "intro" and "introformat" pair of fields
|
||||
$this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
|
||||
$mform->setAdvanced('introeditor');
|
||||
|
||||
$mform->addElement('checkbox', 'showtitle', ' ', ' ' . get_string('display_name', 'lti'));
|
||||
$mform->setAdvanced('showtitle');
|
||||
$mform->addHelpButton('showtitle', 'display_name', 'lti');
|
||||
|
||||
$mform->addElement('checkbox', 'showdescription', ' ', ' ' . get_string('display_description', 'lti'));
|
||||
$mform->setAdvanced('showdescription');
|
||||
$mform->addHelpButton('showdescription', 'display_description', 'lti');
|
||||
|
||||
// Tool settings
|
||||
$tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array());
|
||||
$mform->addHelpButton('typeid', 'external_tool_type', 'lti');
|
||||
|
||||
foreach (lti_get_types_for_add_instance() as $id => $type) {
|
||||
if ($type->course == $COURSE->id) {
|
||||
$attributes = array( 'editable' => 1, 'courseTool' => 1, 'domain' => $type->tooldomain );
|
||||
} else if ($id != 0) {
|
||||
$attributes = array( 'globalTool' => 1, 'domain' => $type->tooldomain);
|
||||
} else {
|
||||
$attributes = array();
|
||||
}
|
||||
|
||||
$tooltypes->addOption($type->name, $id, $attributes);
|
||||
}
|
||||
|
||||
$mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size'=>'64'));
|
||||
$mform->setType('toolurl', PARAM_TEXT);
|
||||
$mform->addHelpButton('toolurl', 'launch_url', 'lti');
|
||||
|
||||
$mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), array('size'=>'64'));
|
||||
$mform->setType('securetoolurl', PARAM_TEXT);
|
||||
$mform->setAdvanced('securetoolurl');
|
||||
$mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti');
|
||||
|
||||
$launchoptions=array();
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti');
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
|
||||
$launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
|
||||
|
||||
$mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions);
|
||||
$mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT);
|
||||
$mform->addHelpButton('launchcontainer', 'launchinpopup', 'lti');
|
||||
|
||||
$mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti'));
|
||||
$mform->setType('resourcekey', PARAM_TEXT);
|
||||
$mform->setAdvanced('resourcekey');
|
||||
$mform->addHelpButton('resourcekey', 'resourcekey', 'lti');
|
||||
|
||||
$mform->addElement('passwordunmask', 'password', get_string('password', 'lti'));
|
||||
$mform->setType('password', PARAM_TEXT);
|
||||
$mform->setAdvanced('password');
|
||||
$mform->addHelpButton('password', 'password', 'lti');
|
||||
|
||||
$mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
|
||||
$mform->setType('instructorcustomparameters', PARAM_TEXT);
|
||||
$mform->setAdvanced('instructorcustomparameters');
|
||||
$mform->addHelpButton('instructorcustomparameters', 'custom', 'lti');
|
||||
|
||||
$mform->addElement('text', 'icon', get_string('icon_url', 'lti'), array('size'=>'64'));
|
||||
$mform->setType('icon', PARAM_TEXT);
|
||||
$mform->setAdvanced('icon');
|
||||
$mform->addHelpButton('icon', 'icon_url', 'lti');
|
||||
|
||||
$mform->addElement('text', 'secureicon', get_string('secure_icon_url', 'lti'), array('size'=>'64'));
|
||||
$mform->setType('secureicon', PARAM_TEXT);
|
||||
$mform->setAdvanced('secureicon');
|
||||
$mform->addHelpButton('secureicon', 'secure_icon_url', 'lti');
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add privacy preferences fieldset where users choose whether to send their data
|
||||
$mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
|
||||
|
||||
$mform->addElement('checkbox', 'instructorchoicesendname', ' ', ' ' . get_string('share_name', 'lti'));
|
||||
$mform->setDefault('instructorchoicesendname', '1');
|
||||
$mform->addHelpButton('instructorchoicesendname', 'share_name', 'lti');
|
||||
|
||||
$mform->addElement('checkbox', 'instructorchoicesendemailaddr', ' ', ' ' . get_string('share_email', 'lti'));
|
||||
$mform->setDefault('instructorchoicesendemailaddr', '1');
|
||||
$mform->addHelpButton('instructorchoicesendemailaddr', 'share_email', 'lti');
|
||||
|
||||
$mform->addElement('checkbox', 'instructorchoiceacceptgrades', ' ', ' ' . get_string('accept_grades', 'lti'));
|
||||
$mform->setDefault('instructorchoiceacceptgrades', '1');
|
||||
$mform->addHelpButton('instructorchoiceacceptgrades', 'accept_grades', 'lti');
|
||||
|
||||
$mform->addElement('checkbox', 'instructorchoiceallowroster', ' ', ' ' . get_string('share_roster', 'lti'));
|
||||
$mform->setDefault('instructorchoiceallowroster', '1');
|
||||
$mform->addHelpButton('instructorchoiceallowroster', 'share_roster', 'lti');
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
$debugoptions=array();
|
||||
$debugoptions[0] = get_string('debuglaunchoff', 'lti');
|
||||
$debugoptions[1] = get_string('debuglaunchon', 'lti');
|
||||
|
||||
$mform->addElement('select', 'debuglaunch', get_string('debuglaunch', 'lti'), $debugoptions);
|
||||
|
||||
if (isset($this->typeconfig['debuglaunch'])) {
|
||||
if ($this->typeconfig['debuglaunch'] == 0) {
|
||||
$mform->setDefault('debuglaunch', '0');
|
||||
} else if ($this->typeconfig['debuglaunch'] == 1) {
|
||||
$mform->setDefault('debuglaunch', '1');
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// add standard elements, common to all modules
|
||||
$this->standard_coursemodule_elements();
|
||||
$mform->setAdvanced('cmidnumber');
|
||||
//-------------------------------------------------------------------------------
|
||||
// add standard buttons, common to all modules
|
||||
$this->add_action_buttons();
|
||||
|
||||
$editurl = new moodle_url("/mod/lti/instructor_edit_tool_type.php?sesskey={$USER->sesskey}&course={$COURSE->id}");
|
||||
$ajaxurl = new moodle_url('/mod/lti/ajax.php');
|
||||
|
||||
$jsinfo = (object)array(
|
||||
'edit_icon_url' => (string)$OUTPUT->pix_url('t/edit'),
|
||||
'add_icon_url' => (string)$OUTPUT->pix_url('t/add'),
|
||||
'delete_icon_url' => (string)$OUTPUT->pix_url('t/delete'),
|
||||
'green_check_icon_url' => (string)$OUTPUT->pix_url('i/tick_green_small'),
|
||||
'warning_icon_url' => (string)$OUTPUT->pix_url('warning', 'lti'),
|
||||
'instructor_tool_type_edit_url' => $editurl->out(false),
|
||||
'ajax_url' => $ajaxurl->out(true),
|
||||
'courseId' => $COURSE->id
|
||||
);
|
||||
|
||||
$module = array(
|
||||
'name' => 'mod_lti_edit',
|
||||
'fullpath' => '/mod/lti/mod_form.js',
|
||||
'requires' => array('base', 'io', 'querystring-stringify-simple', 'node', 'event', 'json-parse'),
|
||||
'strings' => array(
|
||||
array('addtype', 'lti'),
|
||||
array('edittype', 'lti'),
|
||||
array('deletetype', 'lti'),
|
||||
array('delete_confirmation', 'lti'),
|
||||
array('cannot_edit', 'lti'),
|
||||
array('cannot_delete', 'lti'),
|
||||
array('global_tool_types', 'lti'),
|
||||
array('course_tool_types', 'lti'),
|
||||
array('using_tool_configuration', 'lti'),
|
||||
array('domain_mismatch', 'lti'),
|
||||
array('custom_config', 'lti'),
|
||||
array('tool_config_not_found', 'lti')
|
||||
),
|
||||
);
|
||||
|
||||
$PAGE->requires->js_init_call('M.mod_lti.editor.init', array(json_encode($jsinfo)), true, $module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make fields editable or non-editable depending on the administrator choices
|
||||
* @see moodleform_mod::definition_after_data()
|
||||
*/
|
||||
public function definition_after_data() {
|
||||
parent::definition_after_data();
|
||||
|
||||
//$mform =& $this->_form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function overwritten to change default values using
|
||||
* global configuration
|
||||
*
|
||||
* @param array $default_values passed by reference
|
||||
*/
|
||||
public function data_preprocessing(&$default_values) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$instanceid = required_param('instanceid', PARAM_INT);
|
||||
|
||||
$lti = $DB->get_record('lti', array('id' => $instanceid));
|
||||
$course = $DB->get_record('course', array('id' => $lti->course));
|
||||
|
||||
require_login($course);
|
||||
|
||||
require_capability('mod/lti:requesttooladd', get_context_instance(CONTEXT_COURSE, $lti->course));
|
||||
|
||||
$baseurl = lti_get_domain_from_url($lti->toolurl);
|
||||
|
||||
$url = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid));
|
||||
$PAGE->set_url($url);
|
||||
|
||||
$pagetitle = strip_tags($course->shortname);
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//Add a tool type if one does not exist already
|
||||
if (!lti_get_tool_by_url_match($lti->toolurl, $lti->course, LTI_TOOL_STATE_ANY)) {
|
||||
//There are no tools (active, pending, or rejected) for the launch URL. Create a new pending tool
|
||||
$tooltype = new stdClass();
|
||||
$toolconfig = new stdClass();
|
||||
|
||||
$toolconfig->lti_toolurl = lti_get_domain_from_url($lti->toolurl);
|
||||
$toolconfig->lti_typename = $toolconfig->lti_toolurl;
|
||||
|
||||
lti_add_type($tooltype, $toolconfig);
|
||||
|
||||
echo get_string('lti_tool_request_added', 'lti');
|
||||
} else {
|
||||
echo get_string('lti_tool_request_existing', 'lti');
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Handle the return back to Moodle from the tool provider
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$instanceid = required_param('instanceid', PARAM_INT);
|
||||
|
||||
$errormsg = optional_param('lti_errormsg', '', PARAM_RAW);
|
||||
$unsigned = optional_param('unsigned', '0', PARAM_INT);
|
||||
|
||||
$launchcontainer = optional_param('launch_container', LTI_LAUNCH_CONTAINER_WINDOW, PARAM_INT);
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $courseid));
|
||||
|
||||
require_login($course);
|
||||
|
||||
if (!empty($errormsg)) {
|
||||
$url = new moodle_url('/mod/lti/return.php', array('course' => $courseid));
|
||||
$PAGE->set_url($url);
|
||||
|
||||
$pagetitle = strip_tags($course->shortname);
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
//Avoid frame-in-frame action
|
||||
if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
|
||||
$PAGE->set_pagelayout('embedded');
|
||||
} else {
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo get_string('lti_launch_error', 'lti');
|
||||
|
||||
echo htmlspecialchars($errormsg);
|
||||
|
||||
$canaddtools = has_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
|
||||
if ($unsigned == 1 && $canaddtools) {
|
||||
echo '<br /><br />';
|
||||
|
||||
$links = new stdClass();
|
||||
$coursetooleditor = new moodle_url('/mod/lti/instructor_edit_tool_type.php', array('course' => $courseid, 'action' => 'add'));
|
||||
$links->course_tool_editor = $coursetooleditor->out(false);
|
||||
|
||||
$adminrequesturl = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $instanceid));
|
||||
$links->admin_request_url = $adminrequesturl->out(false);
|
||||
|
||||
echo get_string('lti_launch_error_unsigned_help', 'lti', $links);
|
||||
|
||||
echo get_string('lti_launch_error_tool_request', 'lti', $links);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
} else {
|
||||
$courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
|
||||
$url = $courseurl->out();
|
||||
|
||||
//Avoid frame-in-frame action
|
||||
if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
|
||||
//Output a page containing some script to break out of frames and redirect them
|
||||
|
||||
echo '<html><body>';
|
||||
|
||||
$script = "
|
||||
<script type=\"text/javascript\">
|
||||
//<![CDATA[
|
||||
if(window != top){
|
||||
top.location.href = '{$url}';
|
||||
}
|
||||
//]]
|
||||
</script>
|
||||
";
|
||||
|
||||
$clickhere = get_string('return_to_course', 'lti', (object)array('link' => $url));
|
||||
|
||||
$noscript = "
|
||||
<noscript>
|
||||
{$clickhere}
|
||||
</noscript>
|
||||
";
|
||||
|
||||
echo $script;
|
||||
echo $noscript;
|
||||
|
||||
echo '</body></html>';
|
||||
} else {
|
||||
//If no error, take them back to the course
|
||||
redirect($url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . "/../../config.php");
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/servicelib.php');
|
||||
|
||||
// TODO: Switch to core oauthlib once implemented - MDL-30149
|
||||
use moodle\mod\lti as lti;
|
||||
|
||||
$rawbody = file_get_contents("php://input");
|
||||
|
||||
foreach (getallheaders() as $name => $value) {
|
||||
if ($name === 'Authorization') {
|
||||
// TODO: Switch to core oauthlib once implemented - MDL-30149
|
||||
$oauthparams = lti\OAuthUtil::split_header($value);
|
||||
|
||||
$consumerkey = $oauthparams['oauth_consumer_key'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($consumerkey)) {
|
||||
throw new Exception('Consumer key is missing.');
|
||||
}
|
||||
|
||||
$sharedsecret = lti_verify_message($consumerkey, lti_get_shared_secrets_by_key($consumerkey), $rawbody);
|
||||
|
||||
if ($sharedsecret === false) {
|
||||
throw new Exception('Message signature not valid');
|
||||
}
|
||||
|
||||
$xml = new SimpleXMLElement($rawbody);
|
||||
|
||||
$body = $xml->imsx_POXBody;
|
||||
foreach ($body->children() as $child) {
|
||||
$messagetype = $child->getName();
|
||||
}
|
||||
|
||||
switch ($messagetype) {
|
||||
case 'replaceResultRequest':
|
||||
$parsed = lti_parse_grade_replace_message($xml);
|
||||
|
||||
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
|
||||
|
||||
lti_verify_sourcedid($ltiinstance, $parsed);
|
||||
|
||||
$gradestatus = lti_update_grade($ltiinstance, $parsed->userid, $parsed->launchid, $parsed->gradeval);
|
||||
|
||||
$responsexml = lti_get_response_xml(
|
||||
$gradestatus ? 'success' : 'error',
|
||||
'Grade replace response',
|
||||
$parsed->messageid,
|
||||
'replaceResultResponse'
|
||||
);
|
||||
|
||||
echo $responsexml->asXML();
|
||||
|
||||
break;
|
||||
|
||||
case 'readResultRequest':
|
||||
$parsed = lti_parse_grade_read_message($xml);
|
||||
|
||||
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
|
||||
|
||||
//Getting the grade requires the context is set
|
||||
$context = get_context_instance(CONTEXT_COURSE, $ltiinstance->course);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
lti_verify_sourcedid($ltiinstance, $parsed);
|
||||
|
||||
$grade = lti_read_grade($ltiinstance, $parsed->userid);
|
||||
|
||||
$responsexml = lti_get_response_xml(
|
||||
isset($grade) ? 'success' : 'error',
|
||||
'Result read',
|
||||
$parsed->messageid,
|
||||
'readResultResponse'
|
||||
);
|
||||
|
||||
$node = $responsexml->imsx_POXBody->readResultResponse;
|
||||
$node->addChild('result')->addChild('resultScore')->addChild('textString', isset($grade) ? $grade : '');
|
||||
|
||||
echo $responsexml->asXML();
|
||||
|
||||
break;
|
||||
|
||||
case 'deleteResultRequest':
|
||||
$parsed = lti_parse_grade_delete_message($xml);
|
||||
|
||||
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
|
||||
|
||||
lti_verify_sourcedid($ltiinstance, $parsed);
|
||||
|
||||
$gradestatus = lti_delete_grade($ltiinstance, $parsed->userid);
|
||||
|
||||
$responsexml = lti_get_response_xml(
|
||||
$gradestatus ? 'success' : 'error',
|
||||
'Grade delete request',
|
||||
$parsed->messageid,
|
||||
'deleteResultResponse'
|
||||
);
|
||||
|
||||
echo $responsexml->asXML();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
//Fire an event if we get a web service request which we don't support directly.
|
||||
//This will allow others to extend the LTI services, which I expect to be a common
|
||||
//use case, at least until the spec matures.
|
||||
$data = new stdClass();
|
||||
$data->body = $rawbody;
|
||||
$data->xml = $xml;
|
||||
$data->messagetype = $messagetype;
|
||||
$data->consumerkey = $consumerkey;
|
||||
$data->sharedsecret = $sharedsecret;
|
||||
|
||||
//If an event handler handles the web service, it should set this global to true
|
||||
//So this code knows whether to send an "operation not supported" or not.
|
||||
global $lti_web_service_handled;
|
||||
$lti_web_service_handled = false;
|
||||
|
||||
events_trigger('lti_unknown_service_api_call', $data);
|
||||
|
||||
if (!$lti_web_service_handled) {
|
||||
$responsexml = lti_get_response_xml(
|
||||
'unsupported',
|
||||
'unsupported',
|
||||
lti_parse_message_id($xml),
|
||||
$messagetype
|
||||
);
|
||||
|
||||
echo $responsexml->asXML();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//echo print_r(apache_request_headers(), true);
|
||||
|
||||
//echo '<br />';
|
||||
|
||||
//echo file_get_contents("php://input");
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->dirroot.'/mod/lti/OAuthBody.php');
|
||||
|
||||
// TODO: Switch to core oauthlib once implemented - MDL-30149
|
||||
use moodle\mod\lti as lti;
|
||||
|
||||
define('LTI_ITEM_TYPE', 'mod');
|
||||
define('LTI_ITEM_MODULE', 'lti');
|
||||
define('LTI_SOURCE', 'mod/lti');
|
||||
|
||||
function lti_get_response_xml($codemajor, $description, $messageref, $messagetype) {
|
||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><imsx_POXEnvelopeResponse />');
|
||||
$xml->addAttribute('xmlns', 'http://www.imsglobal.org/lis/oms1p0/pox');
|
||||
|
||||
$headerinfo = $xml->addChild('imsx_POXHeader')->addChild('imsx_POXResponseHeaderInfo');
|
||||
|
||||
$headerinfo->addChild('imsx_version', 'V1.0');
|
||||
$headerinfo->addChild('imsx_messageIdentifier', (string)mt_rand());
|
||||
|
||||
$statusinfo = $headerinfo->addChild('imsx_statusInfo');
|
||||
$statusinfo->addchild('imsx_codeMajor', $codemajor);
|
||||
$statusinfo->addChild('imsx_severity', 'status');
|
||||
$statusinfo->addChild('imsx_description', $description);
|
||||
$statusinfo->addChild('imsx_messageRefIdentifier', $messageref);
|
||||
|
||||
$xml->addChild('imsx_POXBody')->addChild($messagetype);
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function lti_parse_message_id($xml) {
|
||||
$node = $xml->imsx_POXHeader->imsx_POXRequestHeaderInfo->imsx_messageIdentifier;
|
||||
$messageid = (string)$node;
|
||||
|
||||
return $messageid;
|
||||
}
|
||||
|
||||
function lti_parse_grade_replace_message($xml) {
|
||||
$node = $xml->imsx_POXBody->replaceResultRequest->resultRecord->sourcedGUID->sourcedId;
|
||||
$resultjson = json_decode((string)$node);
|
||||
|
||||
$node = $xml->imsx_POXBody->replaceResultRequest->resultRecord->result->resultScore->textString;
|
||||
$grade = floatval((string)$node);
|
||||
|
||||
$parsed = new stdClass();
|
||||
$parsed->gradeval = $grade * 100;
|
||||
|
||||
$parsed->instanceid = $resultjson->data->instanceid;
|
||||
$parsed->userid = $resultjson->data->userid;
|
||||
$parsed->launchid = $resultjson->data->launchid;
|
||||
$parsed->sourcedidhash = $resultjson->hash;
|
||||
|
||||
$parsed->messageid = lti_parse_message_id($xml);
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
function lti_parse_grade_read_message($xml) {
|
||||
$node = $xml->imsx_POXBody->readResultRequest->resultRecord->sourcedGUID->sourcedId;
|
||||
$resultjson = json_decode((string)$node);
|
||||
|
||||
$parsed = new stdClass();
|
||||
$parsed->instanceid = $resultjson->data->instanceid;
|
||||
$parsed->userid = $resultjson->data->userid;
|
||||
$parsed->launchid = $resultjson->data->launchid;
|
||||
$parsed->sourcedidhash = $resultjson->hash;
|
||||
|
||||
$parsed->messageid = lti_parse_message_id($xml);
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
function lti_parse_grade_delete_message($xml) {
|
||||
$node = $xml->imsx_POXBody->deleteResultRequest->resultRecord->sourcedGUID->sourcedId;
|
||||
$resultjson = json_decode((string)$node);
|
||||
|
||||
$parsed = new stdClass();
|
||||
$parsed->instanceid = $resultjson->data->instanceid;
|
||||
$parsed->userid = $resultjson->data->userid;
|
||||
$parsed->launchid = $resultjson->data->launchid;
|
||||
$parsed->sourcedidhash = $resultjson->hash;
|
||||
|
||||
$parsed->messageid = lti_parse_message_id($xml);
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
function lti_update_grade($ltiinstance, $userid, $launchid, $gradeval) {
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
$params = array();
|
||||
$params['itemname'] = $ltiinstance->name;
|
||||
|
||||
$grade = new stdClass();
|
||||
$grade->userid = $userid;
|
||||
$grade->rawgrade = $gradeval;
|
||||
|
||||
$status = grade_update(LTI_SOURCE, $ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, 0, $grade, $params);
|
||||
|
||||
$record = $DB->get_record('lti_submission', array('ltiid' => $ltiinstance->id, 'userid' => $userid, 'launchid' => $launchid), 'id');
|
||||
if ($record) {
|
||||
$id = $record->id;
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
|
||||
if (!empty($id)) {
|
||||
$DB->update_record('lti_submission', array(
|
||||
'id' => $id,
|
||||
'dateupdated' => time(),
|
||||
'gradepercent' => $gradeval,
|
||||
'state' => 2
|
||||
));
|
||||
} else {
|
||||
$DB->insert_record('lti_submission', array(
|
||||
'ltiid' => $ltiinstance->id,
|
||||
'userid' => $userid,
|
||||
'datesubmitted' => time(),
|
||||
'dateupdated' => time(),
|
||||
'gradepercent' => $gradeval,
|
||||
'originalgrade' => $gradeval,
|
||||
'launchid' => $launchid,
|
||||
'state' => 1
|
||||
));
|
||||
}
|
||||
|
||||
return $status == GRADE_UPDATE_OK;
|
||||
}
|
||||
|
||||
function lti_read_grade($ltiinstance, $userid) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
$grades = grade_get_grades($ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, $userid);
|
||||
|
||||
if (isset($grades) && isset($grades->items[0]) && is_array($grades->items[0]->grades)) {
|
||||
foreach ($grades->items[0]->grades as $agrade) {
|
||||
$grade = $agrade->grade;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($grade)) {
|
||||
return $grade;
|
||||
}
|
||||
}
|
||||
|
||||
function lti_delete_grade($ltiinstance, $userid) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/gradelib.php');
|
||||
|
||||
$grade = new stdClass();
|
||||
$grade->userid = $userid;
|
||||
$grade->rawgrade = null;
|
||||
|
||||
$status = grade_update(LTI_SOURCE, $ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, 0, $grade, array('deleted'=>1));
|
||||
|
||||
return $status == GRADE_UPDATE_OK || $status == GRADE_UPDATE_ITEM_DELETED; //grade_update seems to return ok now, but could reasonably return deleted in the future
|
||||
}
|
||||
|
||||
function lti_verify_message($key, $sharedsecrets, $body, $headers = null) {
|
||||
foreach ($sharedsecrets as $secret) {
|
||||
$signaturefailed = false;
|
||||
|
||||
try {
|
||||
// TODO: Switch to core oauthlib once implemented - MDL-30149
|
||||
lti\handleOAuthBodyPOST($key, $secret, $body, $headers);
|
||||
} catch (Exception $e) {
|
||||
$signaturefailed = true;
|
||||
}
|
||||
|
||||
if (!$signaturefailed) {
|
||||
return $secret;//Return the secret used to sign the message)
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function lti_verify_sourcedid($ltiinstance, $parsed) {
|
||||
$sourceid = lti_build_sourcedid($parsed->instanceid, $parsed->userid, $parsed->launchid, $ltiinstance->servicesalt);
|
||||
|
||||
if ($sourceid->hash != $parsed->sourcedidhash) {
|
||||
throw new Exception('SourcedId hash not valid');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file defines the global lti administration form
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$configuredtoolshtml = '';
|
||||
$pendingtoolshtml = '';
|
||||
$rejectedtoolshtml = '';
|
||||
|
||||
$active = get_string('active', 'lti');
|
||||
$pending = get_string('pending', 'lti');
|
||||
$rejected = get_string('rejected', 'lti');
|
||||
$typename = get_string('typename', 'lti');
|
||||
$baseurl = get_string('baseurl', 'lti');
|
||||
$action = get_string('action', 'lti');
|
||||
$createdon = get_string('createdon', 'lti');
|
||||
|
||||
$types = lti_filter_get_types(get_site()->id);
|
||||
|
||||
$configuredtools = array_filter($types, function($value) {
|
||||
return $value->state == LTI_TOOL_STATE_CONFIGURED;
|
||||
});
|
||||
|
||||
$configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');
|
||||
|
||||
$pendingtools = array_filter($types, function($value) {
|
||||
return $value->state == LTI_TOOL_STATE_PENDING;
|
||||
});
|
||||
|
||||
$pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');
|
||||
|
||||
$rejectedtools = array_filter($types, function($value) {
|
||||
return $value->state == LTI_TOOL_STATE_REJECTED;
|
||||
});
|
||||
|
||||
$rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');
|
||||
|
||||
$tab = optional_param('tab', '', PARAM_ALPHAEXT);
|
||||
$activeselected = '';
|
||||
$pendingselected = '';
|
||||
$rejectedselected = '';
|
||||
switch ($tab) {
|
||||
case 'lti_pending':
|
||||
$pendingselected = 'class="selected"';
|
||||
break;
|
||||
case 'lti_rejected':
|
||||
$rejectedselected = 'class="selected"';
|
||||
break;
|
||||
default:
|
||||
$activeselected = 'class="selected"';
|
||||
break;
|
||||
}
|
||||
|
||||
$template = "
|
||||
<div id=\"lti_tabs\" class=\"yui-navset\">
|
||||
<ul id=\"lti_tab_heading\" class=\"yui-nav\" style=\"display:none\">
|
||||
<li {$activeselected}>
|
||||
<a href=\"#tab1\">
|
||||
<em>$active</em>
|
||||
</a>
|
||||
</li>
|
||||
<li {$pendingselected}>
|
||||
<a href=\"#tab2\">
|
||||
<em>$pending</em>
|
||||
</a>
|
||||
</li>
|
||||
<li {$rejectedselected}>
|
||||
<a href=\"#tab3\">
|
||||
<em>$rejected</em>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class=\"yui-content\">
|
||||
<div>
|
||||
$configuredtoolshtml
|
||||
</div>
|
||||
<div>
|
||||
$pendingtoolshtml
|
||||
</div>
|
||||
<div>
|
||||
$rejectedtoolshtml
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type=\"text/javascript\">
|
||||
//<![CDATA[
|
||||
(function(){
|
||||
//If javascript is disabled, they will just see the three tabs one after another
|
||||
var lti_tab_heading = document.getElementById('lti_tab_heading');
|
||||
lti_tab_heading.style.display = '';
|
||||
|
||||
new YAHOO.widget.TabView('lti_tabs');
|
||||
|
||||
var setupTools = function(id, sort){
|
||||
var lti_tools = YAHOO.util.Dom.get(id + '_tools');
|
||||
|
||||
if(lti_tools){
|
||||
var dataSource = new YAHOO.util.DataSource(lti_tools);
|
||||
|
||||
var configuredColumns = [
|
||||
{key:'name', label:'$typename', sortable:true},
|
||||
{key:'baseURL', label:'$baseurl', sortable:true},
|
||||
{key:'timecreated', label:'$createdon', sortable:true, formatter:YAHOO.widget.DataTable.formatDate},
|
||||
{key:'action', label:'$action'}
|
||||
];
|
||||
|
||||
dataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
|
||||
dataSource.responseSchema = {
|
||||
fields: [
|
||||
{key:'name'},
|
||||
{key:'baseURL'},
|
||||
{key:'timecreated', parser:'date'},
|
||||
{key:'action'}
|
||||
]
|
||||
};
|
||||
|
||||
new YAHOO.widget.DataTable(id + '_container', configuredColumns, dataSource,
|
||||
{
|
||||
sortedBy: sort
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
setupTools('lti_configured', {key:'name', dir:'asc'});
|
||||
setupTools('lti_pending', {key:'timecreated', dir:'desc'});
|
||||
setupTools('lti_rejected', {key:'timecreated', dir:'desc'});
|
||||
})();
|
||||
//]]
|
||||
</script>
|
||||
";
|
||||
global $PAGE; // TODO: Move to YUI3 ASAP
|
||||
$PAGE->requires->yui2_lib('tabview');
|
||||
$PAGE->requires->yui2_lib('datatable');
|
||||
|
||||
$settings->add(new admin_setting_heading('lti_types', get_string('external_tool_types', 'lti') . $OUTPUT->help_icon('main_admin', 'lti'), $template));
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains unit tests for (some of) lti/locallib.php
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Charles Severance [email protected]
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/lti/locallib.php');
|
||||
require_once($CFG->dirroot . '/mod/lti/servicelib.php');
|
||||
|
||||
class lti_locallib_test extends UnitTestCase {
|
||||
public static $includecoverage = array('mod/lti/locallib.php');
|
||||
|
||||
public function test_split_custom_parameters() {
|
||||
$this->assertEqual(lti_split_custom_parameters("x=1\ny=2"),
|
||||
array('custom_x' => '1', 'custom_y'=> '2'));
|
||||
|
||||
$this->assertEqual(lti_split_custom_parameters('x=1;y=2'),
|
||||
array('custom_x' => '1', 'custom_y'=> '2'));
|
||||
|
||||
$this->assertEqual(lti_split_custom_parameters('Review:Chapter=1.2.56'),
|
||||
array('custom_review_chapter' => '1.2.56'));
|
||||
|
||||
$this->assertEqual(lti_split_custom_parameters('Complex!@#$^*(){}[]KEY=Complex!@#$^*(){}[]Value'),
|
||||
array('custom_complex____________key' => 'Complex!@#$^*(){}[]Value'));
|
||||
}
|
||||
|
||||
public function test_sign_parameters() {
|
||||
$correct = array ( 'context_id' => '12345', 'context_label' => 'SI124', 'context_title' => 'Social Computing', 'ext_submit' => 'Click Me', 'lti_message_type' => 'basic-lti-launch-request', 'lti_version' => 'LTI-1p0', 'oauth_consumer_key' => 'lmsng.school.edu', 'oauth_nonce' => '47458148e33a8f9dafb888c3684cf476', 'oauth_signature' => 'qWgaBIezihCbeHgcwUy14tZcyDQ=', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => '1307141660', 'oauth_version' => '1.0', 'resource_link_id' => '123', 'resource_link_title' => 'Weekly Blog', 'roles' => 'Learner', 'tool_consumer_instance_guid' => 'lmsng.school.edu', 'user_id' => '789');
|
||||
|
||||
$requestparams = array('resource_link_id' => '123', 'resource_link_title' => 'Weekly Blog', 'user_id' => '789', 'roles' => 'Learner', 'context_id' => '12345', 'context_label' => 'SI124', 'context_title' => 'Social Computing');
|
||||
|
||||
$parms = lti_sign_parameters($requestparams, 'http://www.imsglobal.org/developer/LTI/tool.php', 'POST',
|
||||
'lmsng.school.edu', 'secret', 'Click Me', 'lmsng.school.edu' /*, $org_desc*/);
|
||||
$this->assertTrue(isset($parms['oauth_nonce']));
|
||||
$this->assertTrue(isset($parms['oauth_signature']));
|
||||
$this->assertTrue(isset($parms['oauth_timestamp']));
|
||||
|
||||
// Those things that are hard to mock
|
||||
$correct['oauth_nonce'] = $parms['oauth_nonce'];
|
||||
$correct['oauth_signature'] = $parms['oauth_signature'];
|
||||
$correct['oauth_timestamp'] = $parms['oauth_timestamp'];
|
||||
ksort($parms);
|
||||
ksort($correct);
|
||||
$this->assertEqual($parms, $correct);
|
||||
}
|
||||
|
||||
public function test_parse_grade_replace_message() {
|
||||
$message = '
|
||||
<imsx_POXEnvelopeRequest xmlns = "http://www.imsglobal.org/lis/oms1p0/pox">
|
||||
<imsx_POXHeader>
|
||||
<imsx_POXRequestHeaderInfo>
|
||||
<imsx_version>V1.0</imsx_version>
|
||||
<imsx_messageIdentifier>999998123</imsx_messageIdentifier>
|
||||
</imsx_POXRequestHeaderInfo>
|
||||
</imsx_POXHeader>
|
||||
<imsx_POXBody>
|
||||
<replaceResultRequest>
|
||||
<resultRecord>
|
||||
<sourcedGUID>
|
||||
<sourcedId>{"data":{"instanceid":"2","userid":"2"},"hash":"0b5078feab59b9938c333ceaae21d8e003a7b295e43cdf55338445254421076b"}</sourcedId>
|
||||
</sourcedGUID>
|
||||
<result>
|
||||
<resultScore>
|
||||
<language>en-us</language>
|
||||
<textString>0.92</textString>
|
||||
</resultScore>
|
||||
</result>
|
||||
</resultRecord>
|
||||
</replaceResultRequest>
|
||||
</imsx_POXBody>
|
||||
</imsx_POXEnvelopeRequest>
|
||||
';
|
||||
|
||||
$parsed = lti_parse_grade_replace_message(new SimpleXMLElement($message));
|
||||
|
||||
$this->assertEqual($parsed->userid, '2');
|
||||
$this->assertEqual($parsed->instanceid, '2');
|
||||
$this->assertEqual($parsed->sourcedidhash, '0b5078feab59b9938c333ceaae21d8e003a7b295e43cdf55338445254421076b');
|
||||
|
||||
$ltiinstance = (object)array('servicesalt' => '4e5fcc06de1d58.44963230');
|
||||
|
||||
lti_verify_sourcedid($ltiinstance, $parsed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
.path-mod-lti .ltiframe {position: relative;width: 100%;height: 100%;}
|
||||
|
||||
/** General Styles **/
|
||||
.path-mod-lti .userpicture,
|
||||
.path-mod-lti .picture.user,
|
||||
.path-mod-lti .picture.teacher {width:35px;height: 35px;vertical-align:top;}
|
||||
.path-mod-lti .feedback .files,
|
||||
.path-mod-lti .feedback .grade,
|
||||
.path-mod-lti .feedback .outcome,
|
||||
.path-mod-lti .feedback .finalgrade {float: right;}
|
||||
.path-mod-lti .feedback .disabledfeedback {width: 500px;height: 250px;}
|
||||
.path-mod-lti .feedback .from {float: left;}
|
||||
.path-mod-lti .files img {margin-right: 4px;}
|
||||
.path-mod-lti .files a {white-space:nowrap;}
|
||||
.path-mod-lti .late {color: red;}
|
||||
.path-mod-lti .message {text-align: center;}
|
||||
|
||||
/** Styles for submissions.php **/
|
||||
#page-mod-lti-submissions fieldset.felement {margin-left: 16%;}
|
||||
#page-mod-lti-submissions form#options div {text-align:right;margin-left:auto;margin-right:20px;}
|
||||
#page-mod-lti-submissions .header .commands {display: inline;}
|
||||
#page-mod-lti-submissions .picture {width: 35px;}
|
||||
#page-mod-lti-submissions .fullname,
|
||||
#page-mod-lti-submissions .timemodified,
|
||||
#page-mod-lti-submissions .timemarked {text-align: left;}
|
||||
#page-mod-lti-submissions .submissions .grade,
|
||||
#page-mod-lti-submissions .submissions .outcome,
|
||||
#page-mod-lti-submissions .submissions .finalgrade {text-align: right;}
|
||||
#page-mod-lti-submissions .qgprefs #optiontable {text-align:right;margin-left:auto;}
|
||||
|
||||
/* Styles for admin */
|
||||
.path-admin-mod-lti .mform .fitem .fitemtitle { min-width:18em;padding-right:1em } /* Prevent setting titles from wrapping */
|
||||
|
||||
/* Styles for instructor_edit_tool_type.php */
|
||||
#page-mod-lti-instructor_edit_tool_type .mform .fitem .fitemtitle { min-width:18em;padding-right:1em } /* Prevent setting titles from wrapping */
|
||||
@@ -0,0 +1,73 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* MRTODO: Brief description of this file
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2011 onwards MRTODO
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
(function(){
|
||||
var Y;
|
||||
|
||||
M.mod_lti = M.mod_lti || {};
|
||||
|
||||
M.mod_lti.submissions = {
|
||||
init: function(yui3){
|
||||
if(yui3){
|
||||
Y = yui3;
|
||||
}
|
||||
|
||||
this.setupTable();
|
||||
},
|
||||
|
||||
setupTable: function(){
|
||||
var lti_submissions_table = YAHOO.util.Dom.get('lti_submissions_table');
|
||||
|
||||
var dataSource = new YAHOO.util.DataSource(lti_submissions_table);
|
||||
|
||||
var configuredColumns = [
|
||||
{ key: "user", label: "User", sortable:true },
|
||||
{ key: "date", label: "Submission Date", sortable:true, formatter: 'date' },
|
||||
{ key: "grade",
|
||||
label: "Grade",
|
||||
sortable:true,
|
||||
formatter: function(cell, record, column, data){
|
||||
cell.innerHTML = parseFloat(data).toFixed(1) + '%';
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
dataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
|
||||
dataSource.responseSchema = {
|
||||
fields: [
|
||||
{ key: "user" },
|
||||
{ key: "date", parser: "date" },
|
||||
{ key: "grade", parser: "number" },
|
||||
]
|
||||
};
|
||||
|
||||
new YAHOO.widget.DataTable("lti_submissions_table_container", configuredColumns, dataSource,
|
||||
{
|
||||
sortedBy: {key:"date", dir:"desc"}
|
||||
}
|
||||
);
|
||||
|
||||
Y.one('#lti_submissions_table_container').setStyle('display', '');
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains the script used to clone Moodle admin setting page.
|
||||
* It is used to create a new form used to pre-configure lti activities
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/edit_form.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$section = 'modsettinglti';
|
||||
$return = optional_param('return', '', PARAM_ALPHA);
|
||||
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
|
||||
$action = optional_param('action', null, PARAM_ACTION);
|
||||
$id = optional_param('id', null, PARAM_INT);
|
||||
$useexisting = optional_param('useexisting', null, PARAM_INT);
|
||||
$definenew = optional_param('definenew', null, PARAM_INT);
|
||||
|
||||
// no guest autologin
|
||||
require_login(0, false);
|
||||
$url = new moodle_url('/mod/lti/typesettings.php');
|
||||
$PAGE->set_url($url);
|
||||
|
||||
admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page
|
||||
|
||||
$tab = optional_param('tab', '', PARAM_ALPHAEXT);
|
||||
$redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";
|
||||
|
||||
// WRITING SUBMITTED DATA (IF ANY)
|
||||
|
||||
$statusmsg = '';
|
||||
$errormsg = '';
|
||||
$focus = '';
|
||||
|
||||
$data = data_submitted();
|
||||
|
||||
// Any posted data & any action
|
||||
if (!empty($data) || !empty($action)) {
|
||||
require_sesskey();
|
||||
}
|
||||
|
||||
if (isset($data->submitbutton)) {
|
||||
$type = new stdClass();
|
||||
|
||||
if (isset($id)) {
|
||||
$type->id = $id;
|
||||
|
||||
lti_update_type($type, $data);
|
||||
|
||||
redirect($redirect);
|
||||
} else {
|
||||
$type->state = LTI_TOOL_STATE_CONFIGURED;
|
||||
|
||||
lti_add_type($type, $data);
|
||||
|
||||
redirect($redirect);
|
||||
}
|
||||
|
||||
} else if (isset($data->cancel)) {
|
||||
redirect($redirect);
|
||||
|
||||
} else if ($action == 'accept') {
|
||||
lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);
|
||||
redirect($redirect);
|
||||
|
||||
} else if ($action == 'reject') {
|
||||
lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);
|
||||
redirect($redirect);
|
||||
|
||||
} else if ($action == 'delete') {
|
||||
lti_delete_type($id);
|
||||
redirect($redirect);
|
||||
}
|
||||
|
||||
// print header stuff
|
||||
$PAGE->set_focuscontrol($focus);
|
||||
if (empty($SITE->fullname)) {
|
||||
$PAGE->set_title($settingspage->visiblename);
|
||||
$PAGE->set_heading($settingspage->visiblename);
|
||||
|
||||
$PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->box(get_string('configintrosite', 'admin'));
|
||||
|
||||
if ($errormsg !== '') {
|
||||
echo $OUTPUT->notification($errormsg);
|
||||
|
||||
} else if ($statusmsg !== '') {
|
||||
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
echo '<form action="typesettings.php" method="post" id="'.$id.'" >';
|
||||
echo '<div class="settingsform clearfix">';
|
||||
echo html_writer::input_hidden_params($PAGE->url);
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
|
||||
echo $settingspage->output_html();
|
||||
|
||||
echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
|
||||
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
} else {
|
||||
if ($PAGE->user_allowed_editing()) {
|
||||
$url = clone($PAGE->url);
|
||||
if ($PAGE->user_is_editing()) {
|
||||
$caption = get_string('blockseditoff');
|
||||
$url->param('adminedit', 'off');
|
||||
} else {
|
||||
$caption = get_string('blocksediton');
|
||||
$url->param('adminedit', 'on');
|
||||
}
|
||||
$buttons = $OUTPUT->single_button($url, $caption, 'get');
|
||||
}
|
||||
|
||||
$PAGE->set_title("$SITE->shortname: " . get_string('toolsetup', 'lti'));
|
||||
|
||||
$PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($errormsg !== '') {
|
||||
echo $OUTPUT->notification($errormsg);
|
||||
|
||||
} else if ($statusmsg !== '') {
|
||||
echo $OUTPUT->notification($statusmsg, 'notifysuccess');
|
||||
}
|
||||
|
||||
echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
if ($action == 'add') {
|
||||
$form = new mod_lti_edit_types_form(null, (object)array('isadmin' => true));
|
||||
$form->display();
|
||||
} else if ($action == 'update') {
|
||||
$form = new mod_lti_edit_types_form('typessettings.php?id='.$id, (object)array('isadmin' => true));
|
||||
$type = lti_get_type_type_config($id);
|
||||
$form->set_data($type);
|
||||
$form->display();
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file defines the version of lti
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$module->version = 2011111400;;
|
||||
$module->requires = 2011110200; // Requires this Moodle version
|
||||
$module->cron = 0;
|
||||
$module->component = 'mod_lti';
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// This file is part of BasicLTI4Moodle
|
||||
//
|
||||
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
|
||||
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
|
||||
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
|
||||
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
|
||||
// are already supporting or going to support BasicLTI. This project Implements the consumer
|
||||
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
|
||||
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
|
||||
// at the GESSI research group at UPC.
|
||||
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
|
||||
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
|
||||
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
|
||||
//
|
||||
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
|
||||
// of the Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
|
||||
|
||||
/**
|
||||
* This file contains all necessary code to view a lti activity instance
|
||||
*
|
||||
* @package mod
|
||||
* @subpackage lti
|
||||
* @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
|
||||
* [email protected]
|
||||
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
|
||||
* @author Marc Alier
|
||||
* @author Jordi Piguillem
|
||||
* @author Nikolas Galanis
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/lti/locallib.php');
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
|
||||
$l = optional_param('l', 0, PARAM_INT); // lti ID
|
||||
|
||||
if ($l) { // Two ways to specify the module
|
||||
$lti = $DB->get_record('lti', array('id' => $l), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('lti', $lti->id, $lti->course, false, MUST_EXIST);
|
||||
|
||||
} else {
|
||||
$cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST);
|
||||
$lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
}
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
|
||||
$tool = lti_get_tool_by_url_match($lti->toolurl);
|
||||
if ($tool) {
|
||||
$toolconfig = lti_get_type_config($tool->id);
|
||||
} else {
|
||||
$toolconfig = array();
|
||||
}
|
||||
|
||||
$PAGE->set_cm($cm, $course); // set's up global $COURSE
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$url = new moodle_url('/mod/lti/view.php', array('id'=>$cm->id));
|
||||
$PAGE->set_url($url);
|
||||
|
||||
$launchcontainer = lti_get_launch_container($lti, $toolconfig);
|
||||
|
||||
if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
|
||||
$PAGE->set_pagelayout('frametop'); //Most frametops don't include footer, and pre-post blocks
|
||||
$PAGE->blocks->show_only_fake_blocks(); //Disable blocks for layouts which do include pre-post blocks
|
||||
} else if ($launchcontainer == LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW) {
|
||||
redirect('launch.php?id=' . $cm->id);
|
||||
} else {
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
add_to_log($course->id, "lti", "view", "view.php?id=$cm->id", "$lti->id");
|
||||
|
||||
$pagetitle = strip_tags($course->shortname.': '.format_string($lti->name));
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
// Print the page header
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($lti->showtitle) {
|
||||
// Print the main part of the page
|
||||
echo $OUTPUT->heading(format_string($lti->name));
|
||||
}
|
||||
|
||||
if ($lti->showdescription && $lti->intro) {
|
||||
echo $OUTPUT->box($lti->intro, 'generalbox description', 'intro');
|
||||
}
|
||||
|
||||
if ( $launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW ) {
|
||||
echo "<script language=\"javascript\">//<![CDATA[\n";
|
||||
echo "window.open('launch.php?id=".$cm->id."','lti');";
|
||||
echo "//]]\n";
|
||||
echo "</script>\n";
|
||||
echo "<p>".get_string("basiclti_in_new_window", "lti")."</p>\n";
|
||||
} else {
|
||||
// Request the launch content with an object tag
|
||||
echo '<object id="contentframe" height="600px" width="100%" type="text/html" data="launch.php?id='.$cm->id.'"></object>';
|
||||
|
||||
//Output script to make the object tag be as large as possible
|
||||
$resize = '
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
(function(){
|
||||
//Take scrollbars off the outer document to prevent double scroll bar effect
|
||||
document.body.style.overflow = "hidden";
|
||||
|
||||
var dom = YAHOO.util.Dom;
|
||||
var frame = document.getElementById("contentframe");
|
||||
|
||||
var padding = 15; //The bottom of the iframe wasn\'t visible on some themes. Probably because of border widths, etc.
|
||||
|
||||
var lastHeight;
|
||||
|
||||
var resize = function(){
|
||||
var viewportHeight = dom.getViewportHeight();
|
||||
|
||||
if(lastHeight !== Math.min(dom.getDocumentHeight(), viewportHeight)){
|
||||
|
||||
frame.style.height = viewportHeight - dom.getY(frame) - padding + "px";
|
||||
|
||||
lastHeight = Math.min(dom.getDocumentHeight(), dom.getViewportHeight());
|
||||
}
|
||||
};
|
||||
|
||||
resize();
|
||||
|
||||
setInterval(resize, 250);
|
||||
})();
|
||||
//]]
|
||||
</script>
|
||||
';
|
||||
|
||||
echo $resize;
|
||||
}
|
||||
|
||||
// Finish the page
|
||||
echo $OUTPUT->footer();
|
||||
Reference in New Issue
Block a user