Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fixes and performance improvements
- Loading branch information
1 parent
165a83b
commit 637e3e4
Showing
69 changed files
with
6,051 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?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 plugin provides access to Moodle data in form of analytics and reports in real time. | ||
* | ||
* @package local_intelliboard | ||
* @copyright 2019 IntelliBoard, Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @website http://intelliboard.net/ | ||
*/ | ||
|
||
/** | ||
* Posts the launch petition HTML | ||
* | ||
* @param array $newparms Signed parameters | ||
* @param string $endpoint URL of the external tool | ||
* @param bool $debug Debug (true/false) | ||
* @return string | ||
* @throws coding_exception | ||
*/ | ||
function lti_post_launch_html($newparms, $endpoint, $debug=false) { | ||
$r = "<form action=\"" . $endpoint . | ||
"\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n"; | ||
|
||
// Contruct html for the launch parameters. | ||
foreach ($newparms as $key => $value) { | ||
$key = htmlspecialchars($key); | ||
$value = htmlspecialchars($value); | ||
if ( $key == "ext_submit" ) { | ||
$r .= "<input type=\"submit\""; | ||
} else { | ||
$r .= "<input type=\"hidden\" name=\"{$key}\""; | ||
} | ||
$r .= " value=\""; | ||
$r .= $value; | ||
$r .= "\"/>\n"; | ||
} | ||
|
||
if ( $debug ) { | ||
$r .= "<script language=\"javascript\"> \n"; | ||
$r .= " //<![CDATA[ \n"; | ||
$r .= "function basicltiDebugToggle() {\n"; | ||
$r .= " var ele = document.getElementById(\"basicltiDebug\");\n"; | ||
$r .= " if (ele.style.display == \"block\") {\n"; | ||
$r .= " ele.style.display = \"none\";\n"; | ||
$r .= " }\n"; | ||
$r .= " else {\n"; | ||
$r .= " ele.style.display = \"block\";\n"; | ||
$r .= " }\n"; | ||
$r .= "} \n"; | ||
$r .= " //]]> \n"; | ||
$r .= "</script>\n"; | ||
$r .= "<a id=\"displayText\" href=\"javascript:basicltiDebugToggle();\">"; | ||
$r .= get_string("toggle_debug_data", "lti")."</a>\n"; | ||
$r .= "<div id=\"basicltiDebug\" style=\"display:none\">\n"; | ||
$r .= "<b>".get_string("basiclti_endpoint", "lti")."</b><br/>\n"; | ||
$r .= $endpoint . "<br/>\n <br/>\n"; | ||
$r .= "<b>".get_string("basiclti_parameters", "lti")."</b><br/>\n"; | ||
foreach ($newparms as $key => $value) { | ||
$key = htmlspecialchars($key); | ||
$value = htmlspecialchars($value); | ||
$r .= "$key = $value<br/>\n"; | ||
} | ||
$r .= " <br/>\n"; | ||
$r .= "</div>\n"; | ||
} | ||
$r .= "</form>\n"; | ||
|
||
if ( ! $debug ) { | ||
$r .= " <script type=\"text/javascript\"> \n" . | ||
" //<![CDATA[ \n" . | ||
" document.ltiLaunchForm.submit(); \n" . | ||
" //]]> \n" . | ||
" </script> \n"; | ||
} | ||
return $r; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?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 plugin provides access to Moodle data in form of analytics and reports in real time. | ||
* | ||
* @package local_intelliboard | ||
* @copyright 2019 IntelliBoard, Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @website http://intelliboard.net/ | ||
*/ | ||
|
||
require_once('../../../config.php'); | ||
require_once($CFG->dirroot .'/local/intelliboard/locallib.php'); | ||
|
||
$courseid = optional_param('course_id', 0, PARAM_INT); | ||
|
||
require_login(); | ||
|
||
if(!get_config('local_intelliboard', 'enableattendance')){ | ||
throw new moodle_exception('invalidaccess', 'error'); | ||
} | ||
|
||
if($courseid) { | ||
$course =$DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST); | ||
$PAGE->set_course($course); | ||
$PAGE->set_context(context_course::instance($courseid)); | ||
$PAGE->navigation->find( | ||
'intelliboard_attendance', navigation_node::TYPE_CUSTOM | ||
)->make_active(); | ||
} else { | ||
$PAGE->set_context(context_system::instance()); | ||
} | ||
|
||
$PAGE->set_url(new moodle_url("/local/intelliboard/attendance/index.php")); | ||
$PAGE->set_title(get_string('attendance', 'local_intelliboard')); | ||
$PAGE->set_heading(get_string('attendance', 'local_intelliboard')); | ||
$PAGE->navbar->add(get_string('attendance', 'local_intelliboard')); | ||
|
||
$params = array( | ||
'mode'=> 1 | ||
); | ||
$intelliboard = intelliboard($params); | ||
|
||
echo $OUTPUT->header(); | ||
|
||
if(!isset($intelliboard) || !$intelliboard->token) { | ||
echo '<div class="alert alert-error alert-block fade in " role="alert">' . get_string('intelliboardaccess', 'local_intelliboard') . '</div>'; | ||
echo $OUTPUT->footer(); | ||
exit; | ||
} | ||
$contenturl = sprintf('launch.php?sesskey=%s&course_id=%s', sesskey(), $courseid); | ||
|
||
// Request the launch content with an iframe tag. | ||
echo "<iframe id='contentframe' style='min-height: 800px;' height='800px' width='100%' src='{$contenturl}' | ||
webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>"; | ||
|
||
// Output script to make the iframe tag be as large as possible. | ||
$resize = ' | ||
<script type="text/javascript"> | ||
//<![CDATA[ | ||
YUI().use("node", "event", function(Y) { | ||
var doc = Y.one("body"); | ||
var frame = Y.one("#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(e) { | ||
var viewportHeight = doc.get("winHeight"); | ||
if(lastHeight !== Math.min(doc.get("docHeight"), viewportHeight)){ | ||
frame.setStyle("height", viewportHeight - frame.getY() - padding + "px"); | ||
lastHeight = Math.min(doc.get("docHeight"), doc.get("winHeight")); | ||
} | ||
}; | ||
resize(); | ||
Y.on("windowresize", resize); | ||
}); | ||
//]] | ||
</script> | ||
'; | ||
|
||
echo $resize; | ||
|
||
echo $OUTPUT->footer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?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 plugin provides access to Moodle data in form of analytics and reports in real time. | ||
* | ||
* @package local_intelliboard | ||
* @copyright 2019 IntelliBoard, Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @website http://intelliboard.net/ | ||
*/ | ||
|
||
require_once("../../../config.php"); | ||
require_once($CFG->dirroot.'/local/intelliboard/attendance/attendancelib.php'); | ||
require_once($CFG->dirroot .'/local/intelliboard/locallib.php'); | ||
|
||
$sesskey = required_param('sesskey', PARAM_TEXT); | ||
$courseid = optional_param('course_id', 0, PARAM_INT); | ||
|
||
require_login(); | ||
|
||
if(!get_config('local_intelliboard', 'enableattendance') or $sesskey !== sesskey()){ | ||
throw new moodle_exception('invalidaccess', 'error'); | ||
} | ||
|
||
$params = array( | ||
'do'=>'learner', | ||
'mode'=> 1 | ||
); | ||
$intelliboard = intelliboard($params); | ||
|
||
if(!isset($intelliboard) || !$intelliboard->token) { | ||
echo sprintf( | ||
'<div class="alert alert-error alert-block fade in " role="alert">%s</div>', | ||
get_string('intelliboardaccess', 'local_intelliboard') | ||
); | ||
echo $OUTPUT->footer(); | ||
exit; | ||
} | ||
|
||
$context = context_system::instance(); | ||
|
||
$ltiservice = \local_intelliboard\tools\lti_tool::service(); | ||
list($endpoint, $parms) = $ltiservice->lti_get_launch_data( | ||
['course_id' => $courseid] | ||
); | ||
|
||
$content = lti_post_launch_html($parms, $endpoint); | ||
|
||
echo $content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?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 plugin provides access to Moodle data in form of analytics and reports in real time. | ||
* | ||
* @package local_intelliboard | ||
* @copyright 2019 IntelliBoard, Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @website http://intelliboard.net/ | ||
*/ | ||
|
||
namespace local_intelliboard\attendance; | ||
|
||
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]"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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 plugin provides access to Moodle data in form of analytics and reports in real time. | ||
* | ||
* @package local_intelliboard | ||
* @copyright 2019 IntelliBoard, Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @website http://intelliboard.net/ | ||
*/ | ||
|
||
namespace local_intelliboard\attendance; | ||
|
||
class OAuthException extends \Exception { | ||
// pass | ||
} |
Oops, something went wrong.