5

I have an native Android Moodle based application wherein I have to display the courses which are in SCORM format in the application.
Can someone please help me how to go about this...
The courses are uploaded to my Moodle based website in SCORM format.
The get_course_contents web service gives me a url pointing to the course files, as specified here
https://github.com/dongsheng/moodle/wiki/WebService:get_course_contents

How do I display these SCORM files in my native Android application?
Do I need to parse the imsmanifest.xml file and get details of SCORM package and display the HTML5 contents? Or is there another/better way??

**


**
Update:
I have now tried to display the SCORM package contents in a WebView.
My SCORM package is like:
enter image description here
I have copied this package in the Assets folder of my POC project.
My WebView settings are:

settings.setJavaScriptEnabled(true);
settings.setPluginsEnabled(true);
PluginState state = PluginState.ON;
settings.setPluginState(state);
settings.setAllowFileAccess(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setDatabaseEnabled(true);

String databasePath = this.getApplicationContext()
        .getDir("database", Context.MODE_PRIVATE).getPath();
settings.setDatabasePath(databasePath);
webview.loadUrl("file:///android_asset/ttttt.html");

And my manifest is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.html5test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.html5test.MainActivity"
            android:hardwareAccelerated="true"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

But I'm not getting required results and cannot view my SWF....

enter image description here

Also, when I copied the SCORM package onto the sdcard of the device and tried to open the html file, it opened up in HTMLViewer app and showed a blank white screen...

enter image description here

Can someone please help me out with this....
Thanks in advance...

Zeba
  • 3,041
  • 1
  • 28
  • 39

4 Answers4

3
  1. First you have to understand structure of scorm.

  2. You can see scorm package is a zip file containing several folders right and a manifest file.

  3. First you have to unzip that zip package of scorm and then you have to parse that imsmanifest.xml file and maintain two lists one containing titles and other addresses of html files corresponding to that title.

  4. I have used sax2r2 parser to parse that manifest file and got that two array lists one containing title and other addresses of html files.

  5. Later you just have to fill up you ios list with titles array, and when user click on any title of that list get the position of list and retrieve the address of html files corresponding to that title from addresses array list.

  6. inaly you can open html file in webview of your ios, make sure have enabled parameters required for open scorm html5 file.

In android I have enabled and set these values this is java code but it may help you.

WebViewClient webViewClient = new WebViewClient();
    webView.setWebViewClient(webViewClient);
    webView.clearCache(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.setInitialScale(1);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.clearHistory();
    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.loadUrl("file://" + open_scorm.scorm_path
            + open_scorm.scorm_name + "/" + open_scorm.href.get(0));

webView is used to open html/html5 files in android and i have enabled above settings in android, these settings are by default in android, may be in ios you just have to load that html file and dnt have to enable all these values.

In above you can see I am retrieving href.get(0) which is first html5 file of scorm.

In simple words you just have to unzip scorm , parse imsmanifest.xml file and get data of it and use it to open/parse scorm.

Murtaza Ashraf
  • 190
  • 1
  • 5
  • no problem, you may ask any question if you got any trouble, i do have android application that is downloading and parsing the scorm and one can view scorm... – Murtaza Ashraf Mar 20 '14 at 19:03
  • @MurtazaAshraf : Hello, I have one doubt in imsmanifest.xml file I can find addresses of HTML files but I could not find their titles. Please help. – Rohit Chaskar Aug 24 '15 at 07:33
  • Its with labels/titles you can check manifest for this. Make sure you are using standard SCORM manifest. Thanks – Murtaza Ashraf Aug 25 '15 at 10:36
  • @MurtazaAshraf what if i want to track ppt's last slide opened state? and save it for next time? not able to achieve it. something like moodle player. – Anant Shah Oct 10 '18 at 11:24
2

Zeba,

You need to provide LMS (Moodle) SCORM API. This API (it is a javascript which defines standard SCORM functions such as LMSInitialize() and LMSFinish()) acts as a bridge between your Android SCORM player (client) and the LMS (server).

In webversion of Moodle, Moodle checks the version of SCORM package and then includes the appropriate API to be used as a main API (there are aicc.js.php, scorm_12.js.php and scorm_13.js.php).

You may want to extend these APIs to be used in your Android application. Once you have the API, you can get the SCORM content by returning the url of the file from a webservice function.

Each SCO files (ex. scormpackage.zip/index.html) have its own APIWrapper. The wrapper will find such LMS API and use it to be connected to the LMS backend.

Look at the adlnet website to see how SCORM packages consumes APIWrapper to keep track of SCORM content.

Bogie
  • 153
  • 9
  • 1
    I have been able to get the API wrapper with APIs within but not able to use them. Can you please tell me how can I get the API object or API adapter using which I can call these APIs? – Zeba Mar 19 '14 at 11:37
  • And also how can I do it for offline mode? – Zeba Mar 19 '14 at 11:48
  • You can try create Moodle local webservice function to get the API. For example, re-implement mod/scorm/loaddatamodel.php in your webservice function to returns the API. Then you can load the API in the device by calling this function. I have no idea about offline mode. Maybe you will need to create local webservice function that will provide the SCORM package. Then it is downloaded to the device. Unzip that and open the files locally. – Bogie Mar 20 '14 at 09:06
  • 1
    @Zeba if you want to create Android SCORM player, you can trace around Moodle *mod/scorm/player.php* and other files it depends on. Once you have the key how Moodle built ups the player, you may want to implement its player in Android. With the combination of local webservice, nothing's imposible ;-) – Bogie Mar 20 '14 at 09:21
  • I have been able to get the SCORM package and download it on device and unzip it so that it can be accessed locally. Infact, I have also been able to display its contents using WebView. I have a javascripts API wrapper file which has APIs like – Zeba Mar 20 '14 at 12:59
  • As I said before, the API wrapper within the SCORM file will do that automatically, accessing the main API returned from the server. You can embed that main API and use it while the device is online. If the device is getting offline, you can switch to custom API. The wrapper and main API is the different things. The wrapper inside the SCORM file asks request to the main API. Then the main API forwards that request to the server asynchronously. – Bogie Mar 20 '14 at 22:44
0

core_course_get_courses

this function you can use .

Ashisha Nautiyal
  • 1,389
  • 2
  • 19
  • 39
  • Yes @Ashish Nautiyal... I'm using that function to get the course contents from the moodle based server.. But my question is 'How do I display these SCORM files in my native Android application?' – Zeba Sep 26 '13 at 12:49
  • buddy Implementing scorm is not that easy . All the best :) – Ashisha Nautiyal Sep 27 '13 at 04:51
  • I figured out that about SCORM :) But my main intention right now was just to display the SCORM package contents on the android device. And I could finally achieve that by installing flash player on the device :) Thanks for your help anyways..... – Zeba Oct 01 '13 at 07:46
  • @AshishNautiyal: I need to implement a scorm player for Android. Can you help in providing some links or any other references that would help me. Thanks! – user2234 Nov 26 '13 at 09:24
  • in native i guess it is too too complicated . Bro you can up vote to my ans if liked . thanks – Ashisha Nautiyal Nov 26 '13 at 13:09
-1

Use mobile moodle. Much functionality is being added and it works synchronized to your website, has versions for android, IOS and windows mobile.

https://docs.moodle.org/31/en/Moodle_Mobile_features

Works offline, but with some limits for things like quiz, which can only be scored in contact with the website.

No need to make everything new yourself. Moodle Mobile plays SCORM already.