Some courses won't work outside of an LMS. That's annoying when you just want to review a course, so drop this in to provide a fake SCORM API implementation - getAPI
should then pick up this fake API.
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
function str2seq(str:String):String { | |
var seq:String = "", byte:String, len:Number = str.length, i:Number = 0; | |
for (; i<len; i++) { | |
byte = parseInt(ord(str.charAt(i)), 10).toString(2); | |
seq += "00000000".substr(0, 8-byte.length) + byte; | |
} | |
return seq; | |
} | |
function seq2str(seq:String):String { |
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
<?php | |
function list_dir($resource) { | |
$files = array(); | |
$scan = glob(rtrim($resource, '/') . '/*'); | |
if (is_file($resource)) { | |
array_push($files, $resource); | |
} | |
if (is_dir($resource)) { | |
foreach ($scan as $path) { |
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
<?php | |
class document { | |
public static function getElementsByClassName($name) { | |
global $xpath; | |
$nodes = array(); | |
$elements = $xpath->query(sprintf("//div[contains(@class, '%s')]", $name)); | |
foreach ($elements as $e) { | |
array_push($nodes, $e); | |
} |
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
function getQueryParam(param) { | |
if (!this.params) { | |
this.params = (function (query) { | |
var obj = {}; | |
if (query) { | |
var i = query.length, keyValuePair; | |
while (i--) { | |
keyValuePair = query[i].split('='); | |
if (keyValuePair[0] && keyValuePair[1]) { | |
obj[keyValuePair[0]] = keyValuePair[1]; |
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
function extend(a, b) { | |
var c = {}, attr; | |
for (attr in a) { | |
if (Object.prototype.hasOwnProperty.call(a, attr)) { | |
c[attr] = a[attr]; | |
} | |
} | |
for (attr in b) { | |
if (Object.prototype.hasOwnProperty.call(b, attr)) { | |
c[attr] = b[attr]; |
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
# Convert string to a timestamp. | |
# str_to_time("01:20") = 80 | |
str_to_time = (str) -> | |
str.replace /^([0-9]{1,2}):([0-9]{2})$/, (t, m, s) -> (m* 60) + parseFloat(s) |
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
<?php | |
function async_request($url) { | |
$request = parse_url($url); | |
if (!isset($request['port'])) { | |
$request['port'] = 80; | |
} | |
$fp = @fsockopen($request['host'], $request['port'], $errno, $errstr, 30); | |
if ($fp) { | |
fwrite($fp, implode("\r\n", array( |
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
<?php | |
/******************************************************************************* | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php [L,QSA] | |
*******************************************************************************/ |
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
<?php | |
define('APP_ROOT', pathinfo(implode('/', array_slice(explode('/', $_SERVER['PHP_SELF']), 1, 2)), PATHINFO_DIRNAME)); | |
define('DOCUMENT_ROOT', str_replace('/.', '', sprintf('%s/%s', $_SERVER['DOCUMENT_ROOT'], APP_ROOT))); | |
define('SERVER_NAME', preg_replace('#^www\.#', '', $_SERVER['SERVER_NAME'])); | |
define('SERVER_URL', sprintf('http://%s/%s', SERVER_NAME, APP_ROOT)); | |
function utime() { | |
list($usec, $sec) = explode(' ', microtime()); | |
return ((float)$usec + (float)$sec); |