Git Product home page Git Product logo

simplify-scorm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplify-scorm's Issues

SCORM 1.2 - bug in function getCMIValue

Hi @gabrieldoty,

First off, cheers for this amazing package. You are genius!!

I wanted to point out a bug I have been getting from some SCORM packages that are running this code.

The following line in scormAPI.js

if (!refObject.hasOwnProperty(structure[i])) {

I get cannot read hasOwnPropery of undefined. Turns out, some SCORM packages would request to get value of random objective or interactions if there is no value with that ID.

I suggest the following fixes:
Change L295 to:
if (typeof refObject === 'object' && !refObject.hasOwnProperty(structure[i])) {

and change L300 -

refObject = refObject[structure[i]];
to:
refObject = typeof refObject === 'object' ? refObject[structure[i]] : undefined;

This seems to work for nearly all the 50+ packages I have tested so far.

Again, awesome work on this and cheers!!!!

Console logs

I'd like to see a pull request to remove console logs.

interactions was not working ,What was the wrong over here?

stdClass Object
(
    [completion_status] => incomplete
    [completion_threshold] => 
    [credit] => credit
    [entry] => 
    [exit] => suspend
    [launch_data] => 
    [student_id] => 123456789
    [student_name] => Ramesh Bharwad
    [location] => {"curPage":5,"completed":[0,1,2,3]}
    [max_time_allowed] => 
    [mode] => normal
    [progress_measure] => 
    [scaled_passing_score] => 
    [session_time] => PT16.91S
    [success_status] => unknown
    [suspend_data] => [["RokUsTwQ58","IQjIr4yheT","emusyAUc4f","v44THuNrq1","693395e7-a187-4ac6-877a-d2278b52889d","b4f42983-15bc-4f3f-b526-a7e8d982a477","0b02dcb3-1490-4426-b4e5-ae934f1339b2","5467e982-be88-46af-ba75-4d2ffc9539b1","7d73f654-9e04-4a6d-adf2-631a0787750c","a|0|1|2|3|4|5|6|7|8","completed","a|A","b|T","o|B|C","started","result","a|E|F|B","score","totalAnsweredCorrectly","totalAnsweredIncorrectly","totalAnswered","a|H|I|J|K","n|K","n|1","n|4","n|5","o|L|M|N|O|P","o|G|C|Q|C","answer","submitted","answeredCorrectly","a|S|T|U","brightest","blackest","Pontus","a|W|X|Y","dfd","dfgd","o|Z|a|b|b","b|F","o|V|c|C|d","dfgdf","o|V|f|C|d","270e9ee7-7156-4e26-ba05-953d2ba0aa26","o|V|h|C|d","response","a|B|j|H","droppable-destination-0513cb83-a810-4881-85b4-07d23dafb060","droppable-destination-d37ef74a-e471-425c-a447-ea47ae033537","a|l|m","draggable-0513cb83-a810-4881-85b4-07d23dafb060","draggable-d37ef74a-e471-425c-a447-ea47ae033537","o|n|o|p","o|k|C|q|N","o|V|r|C|C","hjjh","o|V|t|C|d","o|9|D|D|D|R|e|g|i|s|u"],"v"]
    [time_limit_action] => continue,no message
    [total_time] => 0
    [comments_from_learner] => stdClass Object
        (
            [childArray] => Array
                (
                )

        )

    [comments_from_lms] => stdClass Object
        (
            [childArray] => Array
                (
                )

        )

    [interactions] => stdClass Object
        (
            [childArray] => Array
                (
                )

        )

    [learner_preference] => stdClass Object
        (
            [audio_level] => 1
            [language] => 
            [delivery_speed] => 1
            [audio_captioning] => 0
        )

    [objectives] => stdClass Object
        (
            [childArray] => Array
                (
                )

        )

    [score] => stdClass Object
        (
            [scaled] => 0.2
            [raw] => 20
            [min] => 0
            [max] => 100
        )

)

SCORM API not found by the content

Hi There,

I'm trying to use the simplify-scorm lib that you built - thanks for this great work btw!

My scom launcher page that load the scormAPI.js file opens the scorm content in a new window (child window) using window.open(). The scorm content in this child window is not able to find the scormAPI in the parent window.

Could you please tell me how i could achieve this?

Thank you very much!

Trouble defining API handle

Hi,

I previously implemented a SCORM course successfully using this library. (Thanks!) Now I am trying to implement another, but I have not been successful in getting the package to identify the API handle. I can confirm it's added to the window BEFORE the course is initialized.

Unfortunately, the file that executes the course is in minified javascript (which, as you know, is hard to follow). If I 'prettify' it in Chrome dev tools, I can set breakpoints and confirm the API is on the window, but the code that looks for it is really cryptic.

There are references to Spark API (and a Spark API class) in the code. Any idea what I might be missing?

GetLastError function does not return the right error code

Hi, I noticed a couple issues with GetLastError implementation when I was playing around with this library. Although, let me know if this is intentional and I misunderstood the SCORM spec in some way.


First issue is specific to SCORM 1.2:

  1. Call Initialize()
  2. Call SetValue("cmi.core.student_name", "asd") (or any other read only value) -> 403 error as expected
  3. Call GetLastError() -> error code 0 returned

I believe this is because there is a check missing for lastErrorCode != 0, which 2004 implementation has, here: https://github.com/gabrieldoty/simplify-scorm/blob/master/src/scormAPI.js#L223C16-L223C16


Second issue happens in both 1.2 and 2004:

  1. Do NOT call Initialize()
  2. Call SetValue("cmi.core.student_name", "asd") (or any other value, it doesn't matter) -> 301 error as expected
  3. Call GetLastError() -> error code 0 returned

I haven't dug around in the code as to why this happens.

There is any possibilities to return an error ?

Hi,
I am writting a simplified version of an LMS and I want to store the data send to the commit in a database. But in case there is an error I need to say it to the player/document/SCO (whatever you call it) and I have been searching through the source code without finding anything to do this because the callback function (in the processListeners function) return value is completely ignored and because of this if I try to raise an error through the throw new Exception or the throwSCORMError it will be ignored as well.
Any way to do it without touching the source code ?

Publish to npm

Installing via npm is still giving 0.0.1. This ticket is to make a new publish to npm.

Compatibility with rise 360

Hi,

Can someone advise, if this is compatible with the scorm packages published with Rise 360?

Thanks
Sai

Scorm 2004

Hi,

First, thank you very much for this scorm 1.2 run time implementation! It works really well and really simple to include to an existing LMS.

I would like to know if you worked on a version that works with the scorm 2004 version?

By the way, did you make all of the code by your own or have you been inspired by other code? It could help me to build a run time for scorm 2004.

Thank you in advance for your answer,
Greg

lastErrorCode initial value

Hello, (me again :D)

Just a little change to make to your lib,

You should change the line 19

from _self.lastErrorCode = null;
to _self.lastErrorCode = '0';

as the "No error" code is 0 from the runtime reference.

There is some software that ask for the last error code during the initialization state and throw an error if the initial lastErrorCode is null. It might be helpful for you if you're still using your library :)

I didnt make a fork as I am not used to contribute and I don't really have time to check how to do that so I prefer to let you know the issue.

Thank again for sharing this code... Works great !

Greg

Scorm Proxy

Hello everyone!

I've created a player for SCORM and embedded it into my system. My system is developed in PHP with Laravel and is hosted at myhost.com/player.php. The issue I'm facing is that I've hosted the unpacked SCORM package files in an S3 bucket on Amazon and created a link through CloudFront. When I try to access the SCORM content in the player by pointing to the CloudFront link, several security errors occur. Is there any way to fix this? I've been thinking about implementing a proxy for SCORM and dynamically loading the files. Is there already a solution for this?

Thank you very much!

setting initial values

Hi there!

First of all thanks very much for this library, it's super super helpful.

Second, I was wondering if you could expand upon the explanation in the docs of how to set the initial values in API.cmi.

Right now I'm pulling in the API code, then doing my sets on window.API.cmi, then allowing my content to init and call LMSInitialize. What I'm finding is the sets for read-only values flow through your setter implementation, which calls API.throwSCORMError, which results in the values not getting set, and in the content encountering the error code when it init's, and everything comes crashing down from there.

That's exactly what I would expect if I was a piece of content trying to do this, but acting as the "LMS" in this case it seems like something I'm supposed to be able to do? I feel like I must be missing something super-obvious here, so I apologize in advance if that's the case.

Thanks again!

Cannot read property 'charAt' of undefined

After upload the attached scrom content, fail to open the content. Loader is continuously running and behind the page throwing javascript error as mentioned below.

Scrom file Attachment:

Draft 5s training Module SCORM 1.2.zip

Error Details:

Uncaught TypeError: Cannot read property 'charAt' of undefined
at cp.QuizState.readNumber (eval at e (CPXHRLoader.js:37), :1374:423)
at cp.QuizState.readString (eval at e (CPXHRLoader.js:37), :1376:34)
at cp.PlaybackController.restoreObjectsFromState (eval at e (CPXHRLoader.js:37), :1455:20)
at Function.cp.resumeValuesFromDataChunk (eval at e (CPXHRLoader.js:37), :1369:460)
at cp.PlaybackController.RestoreQuizState (eval at e (CPXHRLoader.js:37), :1496:35)
at Function.cp.NewQuizLibraryInit (eval at e (CPXHRLoader.js:37), :982:3)
at Function.cp.CPPreInit (eval at e (CPXHRLoader.js:37), :990:246)
at Function.cp.ContinueCPInit (eval at e (CPXHRLoader.js:37), :1936:33)
at LoadContent (eval at e (CPXHRLoader.js:37), :1368:439)
at InitializeExecuted (eval at e (CPXHRLoader.js:37), :1879:36)

Multiple SCORM on single page

Was wondering if its possible to use this beautiful JS to show multiple SCORM files on single page.
Is it possible ?

Unable to find a API Adaptor

Hi,
I am testing that scorm API adaptor. It returned "unable to find a API adaptor". Can anyone help me?

This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Scorm Test</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>
  
<style>
    iframe {
        width: 900px;
        height: 600px;
        position: absolute;
        left:0;
        right: 0;
        top:0;
        bottom: 0;
        margin: auto;
    }
</style>
</head>

<body>
    <iframe src="GOLF12/shared/launchpage.html" frameborder="0"></iframe>
    <button onclick="save()">Save</button>
    
    <script type="text/javascript" src="src/scormAPI.js"></script>
    <script>
        $(document).ready(function() {
            window.API.cmi.core.student_id = 101;
        });
        function save() {
            var simplifiedObject = window.API.cmi.toJSON();
            console.log(simplifiedObject);
        }
    </script>
</body>

</html>

GOLF12/shared/launchpage.html is scorm course path.
An error has returned the following screenshots:

image

image

A little more example code would be useful.

    window.API_1484_11.on("Terminate", function () {
        var simplifiedObject = window.API_1484_11.cmi.toJSON();
        alert(JSON.stringify(simplifiedObject));
    });

is working fine

however I can't seem to read in values from the LMS.

    window.API_1484_11.on("GetValue.cmi.learner_id", function (CMIElement, value) {
        value = '123';
    });

    window.API_1484_11.on("Initialize", function () {
        alert('initialize SCORM');
    });

I am getting the "initialize SCORM" alert OK but the learner_id is not being returned on terminate.

Obviously I am doing something stupid.

Courses comunications SCORM Angular

Hi! I'm trying to create an angular application where people can upload courses(SCORM). I don't understand how to communicate with that courses, how do i get data, and store in my db. How to create the relation between courses and my application. This need s to be dynamic. Thank you!

!!!I don't want to create courses. I just want to use them.

help me

I cannot understand this program. Please explain how to i play scorm package by this programs?
I am new to scorm. please help me to play the scorm package

thank you.

Couldn't use this repo with my scorm2004 4th edition package

I have a scorm2004 package that I exported from rise.com with the file structure of this: (You can see simplfy scorm repo files in there as well)
image

You can download the said package here.

The launch file is scormcontent/index.html so I imported the scormAPI.js at that file

<script type="text/javascript" src="../simplify-scorm/src/scormAPI.js"></script>

However, I got this error:
image

I am new with scorm but I believeI obeyed the given instructions on the README.md which says

To use, you must include the scormAPI.js file, or the minified version scormAPI.min.js, on the launching page of your SCORM 1.2 or SCORM 2004 application.

I hope I made myself clear.

Publish as an npm package

Would you consider publishing this code as an npm package? It would really simplify using this code. I'm willing to help out if needed, but I don't think it will even require any changes ๐Ÿ˜„

User interactions not added to window.API_1484_11.cmi

Hello, i'm using simplify-scorm to run our scorm courses (2004).
This is working as excpected for the most part : We can display the course, we can progress, we can finish it.
But no interactions are added to window.API_1484_11.cmi.interactions array and i can't explain why.
I don't know if this is an error or a misinterpretation of the features or their use on my part... But suppose strongly it must be the possible so i'm asking for help.

Actually we add the simplify-scorm by calling it in our template as such : <script type="text/javascript" src="{{ asset('/scorm/templates/js/scormAPI.min.js') }}"></script>.
Then, in another js file, we use it like this:

    scormAPI = window.API_1484_11

    // Initalize learner data
    scormAPI.cmi.learner_id = user_uuid
    scormAPI.cmi.learner_name = user_name
    if(scormData) {
        participation_data = JSON.parse(scormData)
        scormAPI.loadFromJSON(participation_data)
    }

    // Initialize handler
    scormAPI.on("Initialize", function() {
        console.log("Scorm Course Initialized with success")
    })

    // Commit handler
    scormAPI.on("Commit", function() {
        var progress = Math.round(scormAPI.cmi.progress_measure*100)
        var data = scormAPI.cmi.toJSON()

        console.log(`Scorm Course is committing progress ... (${progress}%)`)
        response = $.post(commit_url, {
            "data": data,
            "progress": progress
        }, "json")
    })

And it works, we got progression, we save it, etc...
But interactions are never assigned and a simple console.log(scormAPI.cmi.interactions) within the commit function reveals nothing have been added to interactions array.

Simplify-scorm is meant to record interactions right ?
And if not, where or how can i get them in order to record them myself ?
Thank you in advance for your help !

Line 8 window.simplifyScorm is undefined error

Hi Gabriel,
First; thank you for this page. I couldn't find much information out there for open source LMS functionality. I am using the adapt_learning authoring tool to build my scorm1.2 zip files. Working in Django, I cannot seem to get the launch part down of the code required to open a new tab or iframe. The error I keep getting is below. I'll also include how I've coded it in my Django html template
simplescorm_error
.
Here is a snippet of my code:

`
START

<iframe src="" style="border:0px #ffffff none;" id="iframescorm" name="myiFrame" scrolling="no" frameborder="1" marginheight="0px" marginwidth="0px" height="650px" width="100%" type="text/html" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" mozallowfullscreen="mozallowfullscreen"></iframe> <script src="{% static 'courses/scormAPI.js' %}"></script> <script> var scorm = {}; // scorm.url = 'MY_LESSON_URL'; scorm.url = 'myURL' scorm.student_id = 'MY_ID'; scorm.student_name = 'MY_NAME'; scorm.start = () => { window.API.cmi.core.student_id = scorm.student_id; window.API.apiLogLevel = 4; document.getElementById("iframescorm").setAttribute("src", scorm.url); } </script>`

I'm not a super JS developer, but I'm assuming the issue rest somewhere in me not initializing the window.simplifyScorm variable. Any help you can offer is greatly appreciated.

scorm player php mysql

Hello friends,
I'm trying to develop a scorm player that sends to mysql, has anyone done anything like this? Thank you.

Question: back button api lost connection

hi, i would like to understand if my code is correct for start lesson:

<a id="a-apri-lezione" href="javascript:void(0);" onclick="scorm.start(); return false;">
STAART
</a>

<iframe src="" style="border:0px #ffffff none;" id="iframescorm" name="myiFrame" scrolling="no" frameborder="1" marginheight="0px" marginwidth="0px" height="650px" width="100%" type="text/html" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" mozallowfullscreen="mozallowfullscreen"></iframe>

<script src="/scormAPI.js"></script>

<script>
var scorm = {};
scorm.url = 'MY_LESSON_URL';
scorm.student_id = 'MY_ID';
scorm.student_name = 'MY_NAME';

scorm.start = () => {
window.API.cmi.core.student_id = scorm.student_id;
window.API.apiLogLevel = 4;
document.getElementById("iframescorm").setAttribute("src", scorm.url);
}
</script>

This code works, but when user click back button API lost connection with lesson.
To restart everything I am forced to refresh browser.

window.open(scormUrl)

All SCORM reporting works fine when i just do location.href = scormUrl;
But when i use window.open(scormUrl) the reporting doesn't work. It is fetching the last data from the backend but it seems like something goes wrong when i do "loadFromJSON(response)" and the SCORM api doesn't get initialized.

Have anyone else experienced this issue and if so, did you solve it?

window.simplifyScorm is undefined

<title>Course </title> <script type="text/javascript" src="simplify-scorm/src/scormAPI.js"></script>
<script type="text/javascript">

	function updateSelectedPages(page){
		let newPage = page ;
		return function updateFunction(newPage){
			let pageContent = document.getElementById('pageContent');
			pageContent.innerHTML = '<style>' + page.css + '</style>' + page.html;
			this.style.color = '#039be5';
		} 
	}

	function createMenuItem(name , page) {
		let li = document.createElement('li');
		let a = document.createElement('a');
		a.textContent = name ;
		a.addEventListener('click',updateSelectedPages(page));
		li.appendChild(a);
		return li;
	}

	function lms(){	
		
		console.log('window.API ',  window.API)
		console.log('window.API ',window.API)
		window.API.on("LMSInitialize", function() {
			console.log('window.API.cmi ', window.API.cmi)
		});
	}

	function load() {
		lms();

		$.getJSON("data.json", function (data) {
			var lessonName  = document.getElementById('lessonName');
			lessonName.textContent = data.lesson.name ;
			var contentList = document.getElementById('contentList');
			let lessonePages =  data.lessonePages ;
			let length = lessonePages.length;
			if (length > 0) {
				let pageContent = document.getElementById('pageContent');
				pageContent.innerHTML = '<style>' + lessonePages[0].css + '</style>' + lessonePages[0].html;
			}
			for (let i = 0; i < length; i++) {
				let page = lessonePages[i]; 
				contentList.appendChild(createMenuItem('Page '+ (i+1) , page) );
			}
		});
	}

</script>
<!-- Wrapper -->
<div id="wrapper">

	<!-- Main -->
	<div id="main">
		<div class="inner">

			<!-- Header -->
			<header id="header">
				<a class="logo" ><strong id="lessonName"></strong> </a>
			</header>

			<!-- Section -->
			<section id="pageContent">

			</section>
		</div>
	</div>

	<!-- Sidebar -->
	<div id="sidebar">
		<div class="inner">
			<!-- Menu -->
			<nav id="menu">
				<header class="major">
					<h2>Lesson Contenet</h2>
				</header>
				<ul id="contentList">

				</ul>
			</nav>
		</div>
	</div>

</div>

<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/browser.min.js"></script>
<script src="assets/js/breakpoints.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.