Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display SCORM content in Android

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...

like image 486
Zeba Avatar asked Oct 04 '22 01:10

Zeba


1 Answers

  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.

like image 98
Murtaza Ashraf Avatar answered Oct 07 '22 19:10

Murtaza Ashraf