Flash module add-on: Flash-Moodle connection query

Flash module add-on: Flash-Moodle connection query

by Cathy Macdonald -
Number of replies: 7

Hi there
Here is code and error notices for (I thought) a basic communication between Flash and Moodle.
All it has to do is show an answer and a score that is already given to it on the click of a button.
Having perused various forums and tutorials for Flash and PHP, I'm starting at basics to learn as I'm still pretty
confused (I'm not a PHP-er). This effort is based on a tutorials found in Moodle.org etc.

1. Here is the frame 1 AS code.

//frame 1: variables  &  functions:
var theAnswer;
var theScore;
//to match Moodle php variables
answers = theAnswer;
score = theScore;
// start timer
startTime = getTimer();
//fake results to test this
theAnswer = "This is working";
theScore = 100;
//button ends timer and sends result through moodle
_root.finishButton.onRelease = function() {
 endTime = getTimer()-startTime;
 moodleService.send_response(answers, endTime, score);
 moodleService.cleanUp();
};
moodleService.init();

2. Here is the service.php
//service php for basic_result
<?php
global $CFG;
require("$CFG->dirroot/mod/flash/movies/library.php");
class service  {
   /*var $_frmCredentials;
   function service($_frmCredentials)   {
       $this->_frmCredentials=$_frmCredentials;
   }
   function send_response($message, $time, $score){
           flash_save_response($this->_frmCredentials['accessid'],$this->_frmCredentials['courseid'], $this->_frmCredentials['cmid'],1,
                        array('answer'=>$message, 'time'=>intval($time)/1000), $score);
   }
}/*
var $fromcredentials;
function service($fromcredentials)   {
$this->fromcredentials=$fromcredentials;
}
 function send_response($message, $time, $score){
           flash_save_response($this->fromcredentials['accessid'],$this->fromcredentials['courseid'], $this->fromcredentials['cmid'],1,
                        array('answer'=>$message, 'time'=>intval($time)/1000), $score);
}
}
?>

3. Here are the output and errors from Moodle.

//using the $_frmCredentials variable, I get:

Moodle Content Loader Version 1.5
Flash Player Version : WIN 9,0,28,0
Operating System : Windows XP
Loading main movie file.
All files loaded successfully.

//this line is the error
Error sent from Moodle Service :Error - Invalid credentials

//Then after using Quit Movie, I get
Course ID Module not provided
------------------------------------------------------------------
//using the $fromcredentials variable, I get:

Moodle Content Loader Version 1.5
Flash Player Version : WIN 9,0,28,0
Operating System : Windows XP
Loading main movie file.
All files loaded successfully.

//this line is the error
Moodle Service Connection Failure :Connection Failure

//Then after using Quit Movie, it returns to splash page.

That's it. Probably something very simple. Would appreciate any help.
Many thanks.
btw: We're on Moodle1.8.0 and using Flash6.0MX and FlashPlayer9 installed, if that helps. (I know that Allessandro is not upgrading
preloaders).
And I'm using the 'Regular Font & Preloader', as it's not a Learning Interaction.
Cheers.

Average of ratings: -
In reply to Cathy Macdonald

Re: Flash module add-on: Flash-Moodle connection query

by Cathy Macdonald -

Update on this

Even using Jamie's old tutorial for userfirstname and question input, the

'Error sent from Moodle Service :Error - Invalid credentials' briefly flags up before dispaying the movie - which works and tracks ok, which is great, and what we want for FMX and Moodle1.8 big grin !

So, we're getting somewhere, and I have something to work on. But how to avoid this 'Invalid credentials' error - anyone, please? Many thanks.

Cathy

In reply to Cathy Macdonald

Re: Flash module add-on: Flash-Moodle connection query

by Cathy Macdonald -

Hi all, especially Rene

Update on "invalid credentials"...
This seems to be a server database issue, and may not be Flash-Moodle.

Have a quick Google with: "invalid credentials" error
You'll get loads of server/ldap stuff  etc.  for example,

Tests to see if the error information includes the string "invalid credentials", which indicates that either the dn or password is invalid. ...
livedocs.adobe.com/coldfusion/7/htmldocs/00001194.htm

GSSException (Java 2 Platform SE v1.4.2)Returns a string explaining the GSS-API level major error code in this exception. ... Invalid credentials. See Also:: Constant Field Values ...
java.sun.com/j2se/1.4.2/docs/api/org/ietf/jgss/GSSException.html

GWArchive - GroupWise Email Archiving :: GroupWise Legal Discovery ...Work-around: Enter invalid credentials. When you try to connect, the attempt will fail with Error 5. Follow the procedures for troubleshooting error 5. ...
www.messagingarchitects.com/support/gwanywhere/troubleshoot/

The last one may be the most useful for those with the technical knowledge and understanding of this stuff, especially as I noticed reference to "...session ID"; which may be more relevant to the Moodle set up? (User and password are not the issue here).

It may, or not, be worth having a look through this if it's crucial to you at this stage.

Cathy

In reply to Cathy Macdonald

Re: Flash module add-on: Flash-Moodle connection query

by Frank Cappelle -
Hi Cathy,

I just noticed one thing - you do not seem to be passing any values to Moodle.

The lines:

theAnswer = "This is working";
theScore = 100;

should come before the line:

answers = theAnswer;
score = theScore;

I don't know this will make any difference, but I hope it helps.

cheers,

Frank

In reply to Cathy Macdonald

Re: Flash module add-on: Flash-Moodle connection query

by Rene Z -

Hi again Cathy,

I would change the Frame 1 actionscript as below, just for testing:

//fake results to test this
_root.answer = "This is working";
_root.score = 100;
_root.startTime = getTimer();

//button ends timer and sends result through moodle
_root.finishButton.onRelease = function() {
    endTime = getTimer()-_root.startTime;
    moodleService.send_response(_root.answer, endTime, _root.score);
    moodleService.cleanUp();
};

moodleService.init();

This assumes that you have a button in your movie named finishButton. Note the use of the prefix _root to make the variables accessible from the onRelease function. Also, note that the event is called onRelease not XonRelease. I think the 'X' was a typographic error in Jamie's tuturial.

Having said all this, I don't think this will help you solve your "Invalid Credentials" problem, as I doesn't for me either.

The ldap stuff you get when searching in Google for "Invalid credentials" has got nothing to do this with problem. I am not even using ldap for authentication and I assume you are neither.

For some reason, the session that is created in moodleService.init() and stored in _$SESSION, can not be accessed when moodleService.send_response is called. Where did it go? What happened to it? Did it NOT get created in moodleService.init()? These are questions I am trying to answer. The whole thing is complicated by the fact that "most of the time" it works fine (for me).

Let me know if you get any further with the changed actionscript.

Rene.

In reply to Rene Z

Re: Flash module add-on: Flash-Moodle connection query

by Rene Z -

I noticed that after submitting my post, the actionscript line

"_root.finishButton.onRelease = function() {"

was transformed to

"_root.finishButton.XonRelease = function() {"

Just for the record, there is no 'X' in front of the onRelease event.

Rene.

In reply to Rene Z

Re: Flash module add-on: Flash-Moodle connection query

by Cathy Macdonald -

Hi Rene
Thanks for reply. Apologies for my delay; our local Internet was down from Friday until late this morning.
I didn't actually put the 'X' in (you now know). For some reason the Web/Forum inserts that (presumably through some script-tracking mechanism associated 
with ActiveX - would be nice if it could be fixed, but it's more likely coming from Windows/IE than Moodle.)

Changing the order within the .as should make no diference in Flash as the variables are declared at the top of the script, but Moodle prefers it - it tracked smile. So no need for further test-scripting in .as. But I still get '..:Error - Invalid credentials' but it loads and plays the movie anyway (not all the time, I've noticed now).

No, we don't use ldap either, but we thought it was worth a look to maybe point to another way of looking at a server/dns problem we've had for some time (quizes will not track from external access, but will internally).

The _$SESSION problem is beyond me too just now. Maybe if you post that paragraph to a new thread (maybe even in the server forum, since no joy in this one?). However, I spoke to my Moodle Administrator colleague. He says there are glitches with the php.init file. Whether or not this is feeding through to $ession variables is not known yet. (And at the moment we're having to sort the XHTML/XML problem with debugging with a customised theme in 1.8. So we can't trace through the PHP to get more detail on the 'Invalid credentials' (not yet, anyway).

I'm even beginning to wonder if this 'Invalid credentials' isn't another bug; we've found quite a few in the course of our Moodle development.

We'll get there in the end smile
Cathy

In reply to Cathy Macdonald

Re: Flash module add-on: Flash-Moodle connection query

by Cathy Macdonald -

Hi all

It's OK,this 'connection failure' has been sorted now. . cool

Cathy