[RELEASED] Moodle API

Moodle API providing Scorm 1.2 and 2004 integration. It implements all common and most used features available.

★ Ever wanted to integrate Scorm tracking options in a VR simulation developed with Oculus or HTC Vive?
★ Ever wanted to integrate Scorm tracking options in a standalone (Windows, Mac, Linux) or mobile (Android, iOS) application?

This is your answer. You will be able to integrate it within minutes.

Asset Store link

Online documentation

Supported Platforms

It should work on any platform that supports “UnityWebRequest” class.

Features

  • Supports Moodle 3.0+ (some endpoints may require a greater version).

  • Initial implementation it’s Scorm oriented so if you need any endpoint that it’s not available yet, I can implement it really fast.

  • Full object oriented API (you don’t deserialize anything, it’s already done it for you).

  • C# Source code included.

  • Documentation available.

  • Easy integration to your Unity project.

  • Well organized and structured code.

  • Event based. Example: OnScormTracksInserted(MoodleAPI sender, uint trackIds)

  • Fully testable in editor: You can also log Moodle original endpoint url and JSON response.

  • Examples available. You can find editor test runner tests that shows how to use the available API.

  • Requires Unity 5.3+ (by default uses UnityWebRequest) but you can make it 5.0, 5.1, 5.2 backwards compatible implementing:

  • IWebRequest: Interface to make requests. You can use Best HTTP that is backwards compatible.

  • IWebRequestFactory: Interfaces that creates requests.

It has been approved!

This is interesting. Correct me if I’m wrong, but doesn’t SCORM require the application to run inside moodle itself. So it can’t update the parameters remotely outside of moodle.

Normally it is but Moodle exposes in it’s official REST API some endpoints to overcome this limitation. It’s really nice.

So as you can see you can run your application and set Scorm tracks remotely without any problems.

This is so great!!..will there be a step by step how to video to implement this?.. for those who are new to developing unity training modules that need to be scorm tracked.

1 Like

What don’t you understand? Did you read my docs? I think that it’s well explained. There are some code examples with comments trying to explain them step by step.

Ask specific questions and I will try to answer them.

Can you tell me whether the Moodle API can be used to achieve what I need? I am new to Moodle, so the technical API specifications don’t tell me what I can and cannot do with it.

I have a set of Unity games and I would like to organize them as resources in an LMS (and Moodle looks like a good choice), so that a student can go through a course and access the Unity games in the same way as any other course material. Preferably the Unity game should be able to read the name of the logged in Moodle user and display it in-game. When the user completes the game, it notifies Moodle to mark it as completed, so that the user and course admin can track progress through the course.

Can the Moodle API be used to do this?
If so, how do I configure the Moodle course to include the Unity game as a course resource/activity?

Yes as you said you can:

  1. Read logged in user details.
  2. Track user progress across a course.

In order to achieve that you need to create a course with a scorm type activity and once you have that and you have the correct permissions for that user in that course you can start using the API.

Good evening,
I am quite new to the e-learning business and therefore: Please dont get mad if I ask seemingly stupid questions.
First I would like to know if I can develop what is going to be my SCORM package with BOLT? Then, can interactive 3D content also be content of a with this Pugin exported content?
Thank you for helping me and make me understand the whole topic better!
Best regards,
BilderBoy

Hi,
I’ve just purchased the asset, but when I import it into a project I immediate get hit with a bunch of errors saying NUnit, TestTools, UnityTest and UnityTestAttribute don’t exist (on both 2018.38 and 2019.1.4). There’s nothing about this in the documentation that I can see, but because it seems to be just for testing I’ve deleted the test folder and it looks like I can continue. However, I suspect this is the sort of thing that will confuse a lot of less technical users, including a lot of teachers looking to write their own edtech.

Thanks, I will update the docs and the asset.

Thanks. I’m a bit baffled with the asset, to be honest. The documented API doesn’t even tell me how to log attempts and values. All I want to do is run a simple quiz and log the answers given, which I’ve been doing before now in JavaScript with no problems, but the API reference for this asset doesn’t include anything I recognise as part of the basic SCORM API (e.g. GetValue and SetValue) and there’s no example that does this in the package or documentation.

Have you looked at the example in the documentation?

It is a complete example of how to log in with a user and save an attempt with its corresponding score and status.

Also in the “Tests” folder that you have removed you have in “MoodleApiTest.Scorm.cs” many examples on how to use the API.

Hmmm… so it appears the documentation in the package is missing the longer example that your online copy has – the package only has the basic example which does nothing other than log a user in.

I’m a programmer by background, and I suspect a lot of people who aren’t coders (people building with no-code solutions like Fungus etc) would benefit from a lot more support – at a minimum I’d say an example of a one-question quiz that logs the answer given would help a lot.

Am I right in saying that the asset only lets you log complete attempts at SCORM activities, and not individual events as and when they arise? In SCORM packages I’ve written directly in HTML5, I’ve logged individual questions with SetValue, but the only thing I can see in your code that offers access to individual data items is the dictionary in the InsertScormTracks() method, which stores an entire activity session (attempt), not a single event.

Sorry for that.

In the “InsertScormTracksAdvanced” method that it’s in the “Tests” folder you can see an example using Scorm API objectives that it’s what you want.

My asset implements the Scorm related Moodle’s REST API and there is only one function for that and describes as: “Saves a scorm tracking record.”

As you can see I’m just using the API and I can’t do anything that it’s not exposed by the API.

If you have more questions please ask them without any problem.

Fair enough. It might be worth adding a link in the documentation to a good tutorial on the REST API – I personally came to the asset via a search for a SCORM asset, then I saw you had the Moodle-specific one too. I’ve never looked at the Moodle REST API before – I didn’t even know it existed until I saw your asset! I suspect a lot of people interested in the asset would benefit from being pointed in the right direction…

Thanks for the info so far.

I’ve been working through the code to try to work out how to do what I need, and there are two things I can’t work out for myself.

  1. In order to add a new attempt at a previously attempted SCORM, I need to call GetScormAttemptCount, but I have to specify a user ID, but I can’t see how to get the ID of the currently logged in user.

  2. I’m attempting to update interactions in the following code

    public void TestProc()
    {
                result = new Dictionary<string, string>() {
                        { "cmi.core.lesson_location", "7" },
                        { "cmi.core.lesson_status", "completed" },
                        { "cmi.core.score.min", "0" },
                        { "cmi.core.score.max", "100" },
                        { "cmi.core.score.raw", "60" },
                        { "cmi.suspend_data", "test data" },
                        { "cmi.core.session_time", "PT1H10M25S" },
                        { "cmi.interactions.0.id","0" },
                        { "cmi.interactions.0.type","true-false" },
                        { "cmi.interactions.0.time", "00:00:00.00" },
                        { "cmi.interactions.0.student_response", "true" },
                        { "cmi.interactions.0.result", "correct" },
                        { "cmi.interactions.0.latency", "00:00:01.25"},
                        { "cmi.interactions.1.id","1" },
                        { "cmi.interactions.1.type","fill-in" },
                        { "cmi.interactions.1.time", "00:00:00.00" },
                        { "cmi.interactions.1.student_response", "car" },
                        { "cmi.interactions.1.result", "correct" },
                        { "cmi.interactions.1.latency", "00:00:01.25"}
                    };
          
            api.InsertScormTracks(1, ++attemptCount, result);
    }

(Log on and count lookup is currently done in Start and I’ve hardcoded the user ID in my call to GetScormAttemptCount for the purposes of testing.)

Unfortunately when I look at the SCORM interactions report in Moodle, I can see columns for interaction 0 only (“Question 0”, “Response 0”, “Right answer 0” and “Result 0”) and they’re all showing up as empty. Am I doing something wrong with the API, or is this likely to be a configuration problem with my Moodle instance?

Gracias de nuevo,
Niall.

Check “MoodleApiTest.Scorm.cs” script and “GetScormAttemptCount” method. You will see that you need “GetUser” method and “OnUserDetailsRetrieved” event.

I don’t understand, it should work. Interactions are the only thing that doesn’t work, right? As you can see my tests are using objectives not interactions but it should be the same.

Check “EndpointLogEnabled” bool and paste the complete url in the browser to see the result you get. As you’ll see the query format it’s always the same format for all values, it’s really weird if it doesn’t work only for interactions.

Just before I purchase, I have a couple of questions…

1 - Does this work with Unity 2019.x,… if not, what is the latest version I can use?

2 - What is the difference between this and your other asset “SCORM API” in term of use with moodle

Thanks in advance