Java and Moodle Integration/Interaction

Java and Moodle Integration/Interaction

by Ming-Han Lee -
Number of replies: 8
Hi everyone,

I have been googling a bit trying to find ways to have Java applications (using Web Start) interact with Moodle, either directly or via some PHP code hacking. So far the consensus seems to be that the two don't play particularly nice with each other. However, does that suggest it is nevertheless doable? This is what I'd like to do for a university project; perhaps some of you could point me to some good places to get started:

On our Moodle platform the students could click on a link and start an external Java application via Java Web Start. They could watch animations as well as answer some simple quiz questions through pop-up windows.

If I want to keep track of each student's scores on these quizzes and have them saved in a Moodle database so that individual student could easily view his or her scores (e.g. in a block called scoreboard), what are the steps I'll need to take?

Any suggestion is appreciated; thanks!

M.







Average of ratings: -
In reply to Ming-Han Lee

Re: Java and Moodle Integration/Interaction

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi,

You could make a new module that manages the link to your JNLP file etc., and also includes custom php scripts that your WebStart application will contact in order to save scores. Obviously you will need to think carefully about security here (some degree of lax security is inevitable but it would be nice if at least, the php script was secured against altering a different user's score, and was only capable of altering the score that 'belongs' to that instance of the module and not some other score).

Rather than use new database tables and UI, I would suggest making the students' score go into the Moodle gradebook! See e.g. forum for examples of how a module can save grades. It is not exactly 'easy' but not all that difficult either.

(I am about to go on holiday, woo smile so won't be able to comment further on this, sorry. Hopefully this might get you started, or elicit other suggestions.)

--sam


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

Re: Java and Moodle Integration/Interaction

by Ming-Han Lee -
Thanks Sam; I'll look into how to make new Moodle modules and definitely the gradebook. It's good to know where to get started.

Have a super awesome holiday!smile

M.
In reply to Ming-Han Lee

Re: Java and Moodle Integration/Interaction

by Alan Trick -
This is certainly possible. You would need to make some sort of web service api. Also, you would need to handle authentication, but you should be able to do that by hijacking the browser's session.

Also, there shouldn't be any need for lax security.
Average of ratings: Useful (1)
In reply to Alan Trick

Re: Java and Moodle Integration/Interaction

by Ming-Han Lee -
Hey there Alan,

Would you care to elaborate more on security? If I'm not mistaken, Moodle could be configured to either use cookies or sessions to authenticate users. What would be a suitable configuration (easier to code and more secure) for my purpose?

M.
In reply to Ming-Han Lee

Re: Java and Moodle Integration/Interaction

by Matt Bury -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi M.

I've already been down the same path as you when I started the SWF Activity Module. The only difference is that this one is for Flash while yours is for Java. It's open source so you're free to download and use it in any way you like. I think it may even be possible to adapt it for use with Java apps.

I'm using Flash Remoting to communicate with Moodle which I believe is similar to JSON. Java has been around for longer than Flash so there must be an established protocol for DB communcation with it.

http://code.google.com/p/moodle-swf/

If you have any questions, don't hesitate to contact me.

Matt
In reply to Matt Bury

Re: Java and Moodle Integration/Interaction

by Ming-Han Lee -
Hey there Matt,

Thanks so much for sharing your hard work. I'm fairly new to ActionScript, so this is a great opportunity to look at somebody's code and learn to write my own. I'll play with the SWF Activity Module a bit and definitely come back to you later...with loads of questions smile

Have a great day!

M.
In reply to Ming-Han Lee

Re: Java and Moodle Integration/Interaction

by Alan Trick -
A session is actually uses cookies, it's not an either/or thing. The way it works is that a 'session' is created on the webserver. This is a file that contains the user's data. The user is given a cookie that identifies which session is his.

You can access the browser's cookie from within the applet. Then, when you make HTTP requests to fetch grade information, send the cookie along. Moodle will recognise that and connect the request with your session.
In reply to Alan Trick

Re: Java and Moodle Integration/Interaction

by Matt Bury -
Picture of Particularly helpful Moodlers Picture of Plugin developers

You can access the browser's cookie from within the applet. Then, when you make HTTP requests to fetch grade information, send the cookie along. Moodle will recognise that and connect the request with your session.

Flash handles this automatically smile