try {
if ($this->action === 'scormcloud') {
- $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->entry->id);
+ $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->entry->id, true);
$body .= "<br><br>";
$body .= __('Le media peut être testé sur SCORM Cloud : <a href=":url">:url</a>', ['url' => $scormURL]);
}
{
try {
$compilepath = $this->entry->getFinalPath();
- $this->entry->compile($compilepath,$this->user);
+ $this->entry->compile($compilepath, $this->user);
$fname = $this->_fname();
$dest = Files::mkdir(storage_path('app/public/elearningpackage/download/')) . $fname;
try {
if ($this->action === 'scormcloud') {
- $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->entry->id);
+ $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->entry->id, true);
$body .= "<br><br>";
$body .= __('Le package peut être testé sur SCORM Cloud : <a href=":url">:url</a>', ['url' => $scormURL]);
}
try {
if ($this->action === 'scormcloud') {
- $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->entry->id);
+ $scormURL = ScormCloud::send($url, 'toolbox_' . $this->type . '_' . $this->entry->id, true);
$body .= "<br><br>";
$body .= __('Le package peut être testé sur SCORM Cloud : <a href=":url">:url</a>', ['url' => $scormURL]);
}
*/
public function compile($dest, $forceScorm = false, $user = null)
{
- /*
-
- $defaultModuleContent = ['content_title' => '', 'complete_when_opened' => false, 'mandatory' => true,
- 'quiz_id' => '', 'fb_id' => '', 'audio_id' => '', 'pdf_id' => '', 'video_id' => ''];
-
-
-
- $modules = [];
-
- foreach ($this->contents as $id => $content) {
- $m = $this->_compileModule($id, array_merge($defaultModuleContent, $content), $vdir, $user);
- if ($m !== false) {
- $modules[] = $m;
- }
- }
-
- $data = ['title' => $this->title, 'description' => $this->description, 'modules' => $modules];
-
- $vdir->file_put_contents('data.js', 'const DATA=' . json_encode($data) . ';');
- $vdir->file_put_contents('imsmanifest.xml', new Manifest($this->title, Version::SCORM_2004, $organization, 'PACKAGE_' . $this->id));
- $vdir->copyDirectory(resource_path('elearningpackage/dist/css'), 'css');
- $vdir->copyDirectory(resource_path('elearningpackage/dist/js'), 'js');
- $vdir->copyDirectory(resource_path('elearningpackage/dist/fonts'), 'fonts');
- $vdir->copy(resource_path('elearningpackage/index.html'), 'index.html');
- $vdir->sync(true);*/
-
$wdir = resource_path('quiz');
$vdir = new VirtualDirectory($dest);
return;
}
- var res=initScorm();
+ var res = initScorm();
initState();
setContents();
initEvents();
}
});
}
+
function initEvents() {
$(document).on('click', '[data-id]:not([data-lock="locked"])', function () {
openSubSCO($(this).data('id'));
if ($(next).is("#resultsscreen")) {
updateScore();
- console.log(showReview, checkScore())
var show = showReview === 'always' || (showReview === 'passed' && checkScore());
- console.log(showReview, checkScore(), show, score);
+
if (!show) {
$('#correction').hide();
} else {
resize();
gsap.fromTo($(next), {left: w + 50, opacity: 0}, {duration: 0.5, left: 0, opacity: 1});
gsap.fromTo($(prev), {left: 0, opacity: 1}, {
- duration: 0.5,
- left: -w - 50, opacity: 0, onComplete: function () {
+ duration: 0.5, left: -w - 50, opacity: 0, onComplete: function () {
$(prev).hide();
endTransition();
}
function completed() {
updateScore();
+ var passed = checkScore();
+ if (logAttempts) {
+ logAttempt(passed);
+ }
+
if (DATA.scorm) {
- setSCORMScore(score, $("section.question").length, 0);
- setScormValue('cmi.core.lesson_status', 'completed');
+ setScormValue('status', 'completed');
+ setScormValue('success_status', passed ? 'passed' : 'failed');
+ setSCORMScore(getNormalizedScore(true), 100, 0, getNormalizedScore());
setSCORMLocation({q: 1});
}
+ }
- var passed = checkScore();
- if (logAttempts) {
- logAttempt(passed);
+ function getNormalizedScore(pct) {
+ var s = score / countQuestions;
+ if (pct === undefined || pct === false) {
+ return s;
}
+ return Math.round(100 * s);
}
function logAttempt(passed) {
- var score = Math.round(100 * (score / countQuestions));
+ var score = getNormalizedScore(true);
if (isNaN(score)) {
score = 0;
}
score: score, passed: passed, questions: logQuestions,
};
- console.log(logdata);
-
-
$.ajax('https://toolbox.fluidbook.com/quiz/' + DATA.id + '/log', {
method: 'POST', data: logdata, crossDomain: true,
});
}
function checkScore() {
- var normalizedScore = score / countQuestions;
+ var normalizedScore = getNormalizedScore(false);
$('#results > h2').hide();
var passed;
$('#restart').hide();
'exit': 'cmi.exit',
};
-window.initScorm=function()
-{
+window.initScorm = function () {
if (SCORM_INITED) {
return;
}
};
window.setSCORMLocation = function (location) {
- return setScormValue('cmi.location', JSON.stringify(location));
+ return setScormValue('location', JSON.stringify(location));
};
-window.setSCORMScore = function (score, max, min) {
+window.setSCORMScore = function (score, max, min, scaled) {
if (min === undefined) {
min = 0;
}
- setScormValue('cmi.core.score.raw', score);
- setScormValue('cmi.core.score.min', min);
- setScormValue('cmi.core.score.max', max);
+ if (scaled !== undefined) {
+ setScormValue('cmi.score.scaled', scaled);
+ }
+ setScormValue('cmi.score.raw', score);
+ setScormValue('cmi.score.min', min);
+ setScormValue('cmi.score.max', max);
};
window.getScormValue = function (elementName) {
if (!SCORM_OK) {
if (cmi == '') {
return null;
}
- return result = SCORM.get(cmi);
+ return SCORM.get(cmi);
};
-window.setScormValue=function(elementName, value) {
+window.setScormValue = function (elementName, value) {
if (!SCORM_OK) {
return;
}
};
-window.scormMarkAsComplete=function() {
+window.scormMarkAsComplete = function () {
if (!SCORM_OK) {
return;
}
};
-window.finishScorm=function() {
+window.finishScorm = function () {
if (!SCORM_OK) {
return;
}