Java Applet storing instructions in Moodle? Is this possible?

Java Applet storing instructions in Moodle? Is this possible?

by Mark Zarb -
Number of replies: 4

Hi all,

I hope this post is in the right section; was not sure where to post it! If not, I'll gladly move it elsewhere.

This is my question: I have a Java applet, and would like it to interface with Moodle in such a way that if I click a button, eg, it would send a string of text to Moodle and store it *somewhere*... I have my Java applet ready but am unsure as to where to continue. Could someone shed some light on this situation?

Thanks!

- Mark

Average of ratings: -
In reply to Mark Zarb

Re: Java Applet storing instructions in Moodle? Is this possible?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Sure, this should be possible. There are a few options:

1) [Easiest] Your Java applet can send the browser to a new URL. This URL could include the string e.g. http://whatever/nextpage.php?answer=I+have+typed+something. You can make nextpage.php as a Moodle script which can save the data somewhere in the Moodle database, or for example carry out other things such as updating a grade in the gradebook. This option only works if your applet is now finished and not needed any more, as changing the page will lose the applet.

2) [Still quite easy] If I remember correctly, your Java applet can make network requests as long as they are to the exact same server the applet is running on, without even having to sign the applet. Since that's what you want to do, it's all good. So you can make your Java applet request a URL on your server, such as http://whatever/storedata.php?answer=whatever - this can use the normal Java URL request mechanisms, so you can do a POST instead if you need to store a lot of data.

3) [Harder] If you sign your Java applet - this will require a paid-for SSL certificate, and the user will have to click an 'agree' button of some kind - then it can do anything you like such as connect to arbitrary servers. I don't think you need this (but you might if I'm wrong and it won't let you do the suggestion in #2).

If you hit a restriction that means Java won't let you do something for security reasons (ie you would need to sign the applet to allow it) that will be a SecurityException, so you can tell whether you're hitting that problem or something else.

The remaining question is how to write the Moodle script involved. This should be fairly easy - one option is to build your applet into a Moodle module ('activity') which both displays the Java applet itself, and provides the back-end infrastructure. Activities can have database tables which you can use to store the user data.

--sam
Average of ratings: Useful (1)
In reply to sam marshall

Re: Java Applet storing instructions in Moodle? Is this possible?

by Douglas Ivers -

Are these 3 or 4 methods still the only options for sending results from a custom applet back to Moodle?  Isn't SCORM another way?  Also, I've read some things about QuizPort, but not sure if is applet-aware yet.

Background:  I create applets that are specialized activities and games for and designed by professors.  Moodle is becoming the standard at the local university, and I've read in these forums that applets can be launched from Moodle.  I'd like to program my applets to send the student score (or just whether completed) back to Moodle.  What are my options?

In reply to Douglas Ivers

Re: Java Applet storing instructions in Moodle? Is this possible?

by sara lopez -

Hi Douglas

Have you found anything about this? I'd like to program my applets to send the student score (or just whether completed) back to Moodle too.  

In reply to sara lopez

Re: Java Applet storing instructions in Moodle? Is this possible?

by Matt Bury -
Picture of Plugin developers

Hi Sarah,

Doing this with Java requires JRE to be installed on users' computers. In my experience, Flash is more frequently installed and enabled than JRE (Disclosure: I'm a Flash developer). I'm actually considering developing an alternative to the NanoGong activity, which is in Java, in Flash for those who work in JRE-less environments. I have the prototype up and running but it only does heavy WAV files at the moment.

I've already developed a framework for getting Flash apps to integrate and communicate with Moodle: http://code.google.com/p/swf-activity-module/ So the hard work's already been done for you. The existing service scripts are here: http://code.google.com/p/swf-activity-module/source/browse/trunk/src/moodle/lib/amfphp/services With this framework it's possible to get apps to store data in Moodle's database and/or write data to the server (in moodledata). It supports a range of datatypes including datasets (SQL query results), string, number, integer, array, object, byte array, bitmap data, JPEG, PNG, WAV, MP3, etc.

The latest version of Flash Player now supports multithreading which makes converting captured microphone input to MP3 on the fly a practical possibility. The resulting MP3 data can then be sent to a PHP service script as a byte array where it gets written as an MP3 file. I already have this working on a couple of apps for bitmap data:

Pushing data into Moodle's database tables is as easy as it could be with the SWF Activity Module.

I hope this helps! smile