chore: version inicial del codigo fuente del LMS Estafeta

This commit is contained in:
2026-10-02 20:33:12 -06:00
commit c8bb6b97b9
1572 changed files with 457520 additions and 0 deletions
+390
View File
@@ -0,0 +1,390 @@
<?php
/*
VS SCORM 1.2 RTE - api.php
Rev 2010-04-30-01
Copyright (C) 2009, Addison Robson LLC
This program 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 2
of the License, or (at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// read database login information and connect
//require_once "../config.php";
//session_name($CFG->sessionname);
//session_start();
// essential functions
require_once "subs.php";
require_once('mencrypt.php');
// input data
$SCOInstanceID = urldecode($_GET['SCOInstanceID']);
$SCOInstanceID = str_replace (' ','+', $SCOInstanceID );
$SCOInstanceID = $desencriptar( $SCOInstanceID );
$urlencrypt = urldecode($_GET['url']);
$urlencrypt = str_replace (' ','+', $urlencrypt );
$scourl = $desencriptar( $urlencrypt );
dbConnect();
// initialize data elements in the database if they're not already set, and
// dynamically create the javascript code to initialize the local cache
$initializeCache = initializeSCO();
?>
<script language="javascript">
var API = new Object();
// ------------------------------------------
// Status Flags
// ------------------------------------------
var flagFinished = false;
var flagInitialized = false;
// ------------------------------------------
// SCO Data Cache - Initialization
// ------------------------------------------
<?php print $initializeCache; ?>
// ------------------------------------------
// SCORM RTE Functions - Initialization
// ------------------------------------------
function LMSInitialize(dummyString) {
// already initialized or already finished
if ((flagInitialized) || (flagFinished)) { return "false"; }
// set initialization flag
flagInitialized = true;
if(cache['cmi.core.lesson_status'] = 'completed') {
flagFinished = true;
}
if(cache['cmi.core.score.raw'] = '100') {
flagFinished = true;
}
// return success value
return "true";
}
// ------------------------------------------
// SCORM RTE Functions - Getting and Setting Values
// ------------------------------------------
function LMSGetValue(varname) {
// not initialized or already finished
if ((!flagInitialized) ) { return "false"; }
// otherwise, return the requested data
return cache[varname];
}
function LMSSetValue(varname, varvalue) {
// not initialized or already finished
if ((!flagInitialized) ) { return "false"; }
// otherwise, set the requested data, and return success value
cache[varname] = varvalue;
//LMSCommit('');
return "true";
}
// ------------------------------------------
// SCORM RTE Functions - Saving the Cache to the Database
// ------------------------------------------
function LMSCommit(dummyString) {
// not initialized or already finished
if ((!flagInitialized) || (flagFinished)) { return "false"; }
// code to prevent caching
var d = new Date();
var data = new Object();
data['cmi.core.lesson_location'] = cache['cmi.core.lesson_location'];
data['cmi.core.lesson_status'] = cache['cmi.core.lesson_status'];
data['cmi.core.exit'] = cache['cmi.core.exit'];
data['cmi.core.score.raw'] = cache['cmi.core.score.raw'];
data['cmi.suspend_data'] = cache['cmi.suspend_data'];
data['cmi.core.session_time'] = cache['cmi.core.session_time'];
var elr = "";
$.ajax({
url: 'commit.php',
type: 'POST',
data: {
SCOInstanceID: <?php print $SCOInstanceID; ?>,
data: JSON.stringify(data),
code: d.getTime()
}
})
.done(function() {
elr = "true";
})
.fail(function() {
console.log('Problem with AJAX Request in LMSCommit()');
elr = "false";
})
.always(function() {
return elr;
});
}
// ------------------------------------------
// SCORM RTE Functions - Closing The Session
// ------------------------------------------
function LMSFinish(dummyString) {
// not initialized or already finished
if ((!flagInitialized) || (flagFinished)) { return "false"; }
var d = new Date();
// commit cached values to the database
//LMSCommit('');
var data = new Object();
data['cmi.core.lesson_location'] = cache['cmi.core.lesson_location'];
data['cmi.core.lesson_status'] = cache['cmi.core.lesson_status'];
data['cmi.core.exit'] = cache['cmi.core.exit'];
data['cmi.core.score.raw'] = cache['cmi.core.score.raw'];
data['cmi.suspend_data'] = cache['cmi.suspend_data'];
data['cmi.core.session_time'] = cache['cmi.core.session_time'];
// commit cached values to the database
// code to prevent caching
var computeTimeString = computeTime();
var elr = "";
$.ajax({
url: 'finish.php',
type: 'POST',
data: {
SCOInstanceID: <?php print $SCOInstanceID; ?>,
code: d.getTime(),
computeTimeString: computeTimeString,
data: JSON.stringify(data)
},
})
.done(function() {
elr = "true";
})
.fail(function() {
alert('Problem with AJAX Request in LMSFinish()');
elr = "";
})
.always(function() {
flagFinished = true;
return elr;
});
}
// ------------------------------------------
// SCORM RTE Functions - Error Handling
// ------------------------------------------
function LMSGetLastError() {
return 0;
}
function LMSGetDiagnostic(errorCode) {
return "diagnostic string";
}
function LMSGetErrorString(errorCode) {
return "error string";
}
// ------------------------------------------
// AJAX Request Handling
// ------------------------------------------
function createRequest() {
var request;
try {
request = new XMLHttpRequest();
} catch (tryIE) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (tryOlderIE) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
alert("Error creating XMLHttpRequest");
}
}
}
return request;
}
// ------------------------------------------
// URL Encoding
// ------------------------------------------
function urlencode(str) {
var histogram = {},
unicodeStr = '',
hexEscStr = '';
var ret = (str + '').toString();
var replacer = function(search, replace, str) {
var tmp_arr = [];
tmp_arr = str.split(search);
return tmp_arr.join(replace);
};
// The histogram is identical to the one in urldecode.
histogram["'"] = '%27';
histogram['('] = '%28';
histogram[')'] = '%29';
histogram['*'] = '%2A';
histogram['~'] = '%7E';
histogram['!'] = '%21';
histogram['%20'] = '+';
histogram['\u00DC'] = '%DC';
histogram['\u00FC'] = '%FC';
histogram['\u00C4'] = '%D4';
histogram['\u00E4'] = '%E4';
histogram['\u00D6'] = '%D6';
histogram['\u00F6'] = '%F6';
histogram['\u00DF'] = '%DF';
histogram['\u20AC'] = '%80';
histogram['\u0081'] = '%81';
histogram['\u201A'] = '%82';
histogram['\u0192'] = '%83';
histogram['\u201E'] = '%84';
histogram['\u2026'] = '%85';
histogram['\u2020'] = '%86';
histogram['\u2021'] = '%87';
histogram['\u02C6'] = '%88';
histogram['\u2030'] = '%89';
histogram['\u0160'] = '%8A';
histogram['\u2039'] = '%8B';
histogram['\u0152'] = '%8C';
histogram['\u008D'] = '%8D';
histogram['\u017D'] = '%8E';
histogram['\u008F'] = '%8F';
histogram['\u0090'] = '%90';
histogram['\u2018'] = '%91';
histogram['\u2019'] = '%92';
histogram['\u201C'] = '%93';
histogram['\u201D'] = '%94';
histogram['\u2022'] = '%95';
histogram['\u2013'] = '%96';
histogram['\u2014'] = '%97';
histogram['\u02DC'] = '%98';
histogram['\u2122'] = '%99';
histogram['\u0161'] = '%9A';
histogram['\u203A'] = '%9B';
histogram['\u0153'] = '%9C';
histogram['\u009D'] = '%9D';
histogram['\u017E'] = '%9E';
histogram['\u0178'] = '%9F';
// Begin with encodeURIComponent, which most resembles PHP's encoding functions
ret = encodeURIComponent(ret);
for (unicodeStr in histogram) {
hexEscStr = histogram[unicodeStr];
ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
}
// Uppercase for full PHP compatibility
return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
return "%" + m2.toUpperCase();
});
}
API.LMSInitialize = LMSInitialize;
API.LMSGetValue = LMSGetValue;
API.LMSSetValue = LMSSetValue;
API.LMSCommit = LMSCommit;
API.LMSFinish = LMSFinish;
API.LMSGetLastError = LMSGetLastError;
API.LMSGetErrorString = LMSGetErrorString;
var startDate = 0;
function resizeIframe(iframe) {
var padding = 50;
if( $("#navsco").length > 0 ){
var navbar360 = $("#navsco").outerHeight();
}else{
var navbar360 = 0;
}
padding = padding + navbar360;
if (iframe.contentWindow.document.body.scrollHeight < (window.innerHeight - padding))
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
else
iframe.height = (window.innerHeight + padding) + "px";
}
/**
* Descripción: Inica el conteo del tiempo en el sco
* @return
* @method startTimer
* @return
*/
function startTimer() {
startDate = new Date().getTime();
}
/**
* Descripción: calucla el tiempo que el usuario permance en el sco
* @method computeTime
* @return formattedTime
*/
function computeTime() {
var formattedTime = "00:00:00.0";
if (startDate != 0) {
var currentDate = new Date().getTime();
var elapsedSeconds = ((currentDate - startDate) / 1000);
formattedTime = convertTotalSeconds(elapsedSeconds);
}
return formattedTime;
}
/**
* Descripción: convierte el tiempo en segundos
* @method convertTotalSeconds
* @param ts de tipo time
* @return rtnVal
*/
function convertTotalSeconds(ts) {
var Sec = (ts % 60);
ts -= Sec;
var tmp = (ts % 3600);
ts -= tmp;
if ((ts % 3600) != 0) var Hour = "00";
else var Hour = "" + (ts / 3600);
if ((tmp % 60) != 0) var Min = "00";
else var Min = "" + (tmp / 60);
Sec = "" + Sec
Sec = Sec.substring(0, Sec.indexOf("."))
if (Hour.length < 2) Hour = "0" + Hour;
if (Min.length < 2) Min = "0" + Min;
if (Sec.length < 2) Sec = "0" + Sec;
var rtnVal = Hour + ":" + Min + ":" + Sec;
return rtnVal;
}
</script>
<?php
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
echo '<iframe onload="resizeIframe(this)"
onresize="resizeIframe(this)" frameborder="0" allowfullscreen src="'.$scourl.'?nocache='.generateRandomString(). '"
class="w-100 h-100 position-absolute scormiframe" id="scormiframe360" style="top:0; left:0">
</iframe>';
echo '
<script type="text/javascript">
startTimer();
window.onresize = function() {
//resizeIframe(document.getElementById("scormiframe360"));
}
</script>';
?>