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.