Flash quiz template

140 views
Skip to first unread message

tukgae

unread,
Nov 3, 2009, 5:27:52 AM11/3/09
to eLearning Technology and Development
Dear All
I would like some advice regarding my content
Now, my html file generate from reload pack to SCORM and then when
upload to my server, status show only incomplete when user don't pass
score 80% and status show complete when user pass score more than 80,
which is what we want, but we also want the responses and raw score
reported on successful completion. So far we have no score reported;
only the Successful completion is reported and incomplete even when
they complete but fail.

I'm used quite template flash CS4, I want to server show status status
as are, and also score/response.

Your help would be appreciated as I am pretty new at this.
Regards
Tukgae

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" language="JavaScript"
name="fsIeVbscript">
<!--
// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1
&& navigator.userAgent.indexOf("Windows") != -1 &&
navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('<script language=\"VBScript\"\>\n');
document.write('On Error Resume Next\n');
document.write('Sub quiz3_FSCommand(ByVal command, ByVal args)\n');
document.write(' Call quiz3_DoFSCommand(command, args)\n');
document.write('End Sub\n');
document.write('</script\>\n');
}
//-->
</script>
<title>quiz3</title>
</head>
<script type="text/javascript" language="JavaScript" name="cmifrag">
<!--
// FS SCORM - fscommand adapter for ADL SCORM 1.2 and Flash MX 2004
Learning Interactions
// version 1.0 08/19/03
// Modified by Andrew Chemey, Macromedia
// Based on FS SCORM adapater version 1.2.4:
// Fragments Copyright 2002 Pathlore Software Corporation All rights
Reserved
// Fragments Copyright 2002 Macromedia Inc. All rights reserved.
// Fragments Copyright 2003 Click2learn, Inc. All rights reserved.
// Developed by Tom King, Macromedia,
// Leonard Greenberg, Pathlore,
// and Claude Ostyn, Click2learn, Inc.
// Includes code by Jeff Burton and Andrew Chemey, Macromedia
(01/09/02)
// -----------------------------------------------------------------
// Change these preset values to suit your taste and requirements.
var g_bShowApiErrors = false; // change to true to show error
messages
var g_bInitializeOnLoad = true; // change to false to not initialize
LMS when HTML page loads
// Translate these strings if g_bShowApiErrors is true
// and you need to localize the application
var g_strAPINotFound = "Management system interface not found.";
var g_strAPITooDeep = "Cannot find API - too deeply nested.";
var g_strAPIInitFailed = "Found API but LMSInitialize failed.";
var g_strAPISetError = "Trying to set value but API not available.";
var g_strFSAPIError = 'LMS API adapter returned error code: "%1"\nWhen
FScommand called API.%2\nwith "%3"';
var g_strDisableErrorMsgs = "Select cancel to disable future
warnings.";
// Change g_bSetCompletedAutomatically to true if you want the status
to
// be set to completed automatically when calling LMSFinish. Normally,
// this flag remains false if the Flash movie itself sets status
// to completed by sending a FSCommand to set status to "completed",
// "passed" or "failed" (both of which imply "completed")
var g_bSetCompletedAutomatically = false;
// This value is normally given by the LMS, but in case it is not
// this is the default value to use to determine passed/failed.
// Set this null if the Flash actionscript uses its own method
// to determine passed/fail, otherwise set to a value from 0 to 1
// inclusive (may be a floating point value, e.g "0.75".
var g_SCO_MasteryScore = 0.8; // allowable values: 0.0..1.0, or null
//==================================================================
// WARNING!!!
// Do not modify anything below this line unless you know exactly what
// you are doing!
// You should not have to change these two values as the Flash
template
// presets are based on them.
var g_nSCO_ScoreMin = 0; // must be a number
var g_nSCO_ScoreMax = 100; // must be a number > nSCO_Score_Min
// Per SCORM specification, the LMS provided mastery score,
// if any, will override the SCO in interpreting whether the score
// should be interpreted when the pass/fail status is determined.
// The template tries to obtain the mastery score, and if it
// is available, to set the status to passed or failed accordingly
// when the SCO sends a score. The LMS may not actually make the
// determination until the SCO has been terminated.
// Default value for this flag is true. Set it to false if don't
// want to predict how the LMS will set pass/fail status based on
// the mastery score (the LMS will win in the end anyway).
var g_bInterpretMasteryScore = true;
// This script implements various aspects of
// common logic behavior of a SCO.
/////////// API INTERFACE INITIALIZATION AND CATCHER
FUNCTIONS ////////
var g_nFindAPITries = 0;
var g_objAPI = null;
var g_bInitDone = false;
var g_bFinishDone = false;
var g_bSCOBrowse = false;
var g_dtmInitialized = new Date(); // will be adjusted after
initialize
var g_bMasteryScoreInitialized = false;
function AlertUserOfAPIError(strText) {
if (g_bShowApiErrors) {
var s = strText + "\n\n" + g_strDisableErrorMsgs;
if (!confirm(s)){
g_bShowApiErrors = false
}
}
}
function ExpandString(s){
var re = new RegExp("%","g")
for (i = arguments.length-1; i > 0; i--){
s2 = "%" + i;
if (s.indexOf(s2) > -1){
re.compile(s2,"g")
s = s.replace(re, arguments[i]);
}
}
return s
}
function FindAPI(win) {
while ((win.API == null) && (win.parent != null) && (win.parent !=
win)) {
g_nFindAPITries ++;
if (g_nFindAPITries > 500) {
AlertUserOfAPIError(g_strAPITooDeep);
return null;
}
win = win.parent;
}
return win.API;
}
function APIOK() {
return ((typeof(g_objAPI)!= "undefined") && (g_objAPI != null))
}
function SCOInitialize() {
var err = true;
if (!g_bInitDone) {
if ((window.parent) && (window.parent != window)){
g_objAPI = FindAPI(window.parent)
}
if ((g_objAPI == null) && (window.opener != null)) {
g_objAPI = FindAPI(window.opener)
}
if (!APIOK()) {
AlertUserOfAPIError(g_strAPINotFound);
err = false
} else {
err = g_objAPI.LMSInitialize("");
if (err == "true") {
g_bSCOBrowse = (g_objAPI.LMSGetValue("cmi.core.lesson_mode") ==
"browse"); if (!g_bSCOBrowse) {
if (g_objAPI.LMSGetValue("cmi.core.lesson_status") == "not
attempted") {
err = g_objAPI.LMSSetValue
("cmi.core.lesson_status","incomplete")
}
}
} else {
AlertUserOfAPIError(g_strAPIInitFailed)
}
}
if (typeof(SCOInitData) != "undefined") {
// The SCOInitData function can be defined in another script of the
SCO
SCOInitData()
}
g_dtmInitialized = new Date();
}
g_bInitDone = true;
return (err + "") // Force type to string
}
function SCOFinish() {
if ((APIOK()) && (g_bFinishDone == false)) {
SCOReportSessionTime()
if (g_bSetCompletedAutomatically){
SCOSetStatusCompleted();
}
if (typeof(SCOSaveData) != "undefined"){
// The SCOSaveData function can be defined in another script of the
SCO
SCOSaveData();
}
g_bFinishDone = (g_objAPI.LMSFinish("") == "true");
}
return (g_bFinishDone + "" ) // Force type to string
}
// Call these catcher functions rather than trying to call the API
adapter directly
function SCOGetValue(nam) {return ((APIOK())?g_objAPI.LMSGetValue
(nam.toString()):"")}
function SCOCommit() {return ((APIOK())?g_objAPI.LMSCommit
(""):"false")}
function SCOGetLastError() {return ((APIOK())?g_objAPI.LMSGetLastError
():"-1")}
function SCOGetErrorString(n) {return ((APIOK())?
g_objAPI.LMSGetErrorString(n):"No API")}
function SCOGetDiagnostic(p) {return ((APIOK())?
g_objAPI.LMSGetDiagnostic(p):"No API")}
//LMSSetValue is implemented with more complex data
//management logic below
var g_bMinScoreAcquired = false;
var g_bMaxScoreAcquired = false;
// Special logic begins here
function SCOSetValue(nam,val){
var err = "";
if (!APIOK()){
AlertUserOfAPIError(g_strAPISetError + "\n" + nam + "\n" + val);
err = "false"
} else if (nam == "cmi.core.score.raw") err = privReportRawScore(val)
if (err == ""){
err = g_objAPI.LMSSetValue(nam,val.toString() + "");
if (err != "true") return err
}
if (nam == "cmi.core.score.min"){
g_bMinScoreAcquired = true;
g_nSCO_ScoreMin = val
}
else if (nam == "cmi.core.score.max"){
g_bMaxScoreAcquired = true;
g_nSCO_ScoreMax = val
}
return err
}
function privReportRawScore(nRaw) { // called only by SCOSetValue
if (isNaN(nRaw)) return "false";
if (!g_bMinScoreAcquired){
if (g_objAPI.LMSSetValue("cmi.core.score.min",g_nSCO_ScoreMin+"")!=
"true") return "false"
}
if (!g_bMaxScoreAcquired){
if (g_objAPI.LMSSetValue("cmi.core.score.max",g_nSCO_ScoreMax+"")!=
"true") return "false"
}
if (g_objAPI.LMSSetValue("cmi.core.score.raw", nRaw)!= "true") return
"false";
g_bMinScoreAcquired = false;
g_bMaxScoreAcquired = false;
if (!g_bMasteryScoreInitialized){
var nMasteryScore = parseInt(SCOGetValue
("cmi.student_data.mastery_score"),10);
if (!isNaN(nMasteryScore)) g_SCO_MasteryScore = nMasteryScore
}
if ((g_bInterpretMasteryScore)&&(!isNaN(g_SCO_MasteryScore))){
var stat = (nRaw >= g_SCO_MasteryScore? "passed" : "failed");
if (SCOSetValue("cmi.core.lesson_status",stat) != "true") return
"false";
}
return "true"
}
function MillisecondsToCMIDuration(n) {
//Convert duration from milliseconds to 0000:00:00.00 format
var hms = "";
var dtm = new Date(); dtm.setTime(n);
var h = "000" + Math.floor(n / 3600000);
var m = "0" + dtm.getMinutes();
var s = "0" + dtm.getSeconds();
var cs = "0" + Math.round(dtm.getMilliseconds() / 10);
hms = h.substr(h.length-4)+":"+m.substr(m.length-2)+":";
hms += s.substr(s.length-2)+"."+cs.substr(cs.length-2);
return hms
}
// SCOReportSessionTime is called automatically by this script,
// but you may call it at any time also from the SCO
function SCOReportSessionTime() {
var dtm = new Date();
var n = dtm.getTime() - g_dtmInitialized.getTime();
return SCOSetValue("cmi.core.session_time",MillisecondsToCMIDuration
(n))
}
// Since only the designer of a SCO knows what completed means,
another
// script of the SCO may call this function to set completed status.
// The function checks that the SCO is not in browse mode, and
// avoids clobbering a "passed" or "failed" status since they imply
"completed".
function SCOSetStatusCompleted(){
var stat = SCOGetValue("cmi.core.lesson_status");
if (SCOGetValue("cmi.core.lesson_mode") != "browse"){
if ((stat!="completed") && (stat != "passed") && (stat != "failed"))
{
return SCOSetValue("cmi.core.lesson_status","completed")
}
} else return "false"
}
// Objective management logic
function SCOSetObjectiveData(id, elem, v) {
var result = "false";
var i = SCOGetObjectiveIndex(id);
if (isNaN(i)) {
i = parseInt(SCOGetValue("cmi.objectives._count"));
if (isNaN(i)) i = 0;
if (SCOSetValue("cmi.objectives." + i + ".id", id) == "true"){
result = SCOSetValue("cmi.objectives." + i + "." + elem, v)
}
} else {
result = SCOSetValue("cmi.objectives." + i + "." + elem, v);
if (result != "true") {
// Maybe this LMS accepts only journaling entries
i = parseInt(SCOGetValue("cmi.objectives._count"));
if (!isNaN(i)) {
if (SCOSetValue("cmi.objectives." + i + ".id", id) == "true"){
result = SCOSetValue("cmi.objectives." + i + "." + elem, v)
}
}
}
}
return result
}
function SCOGetObjectiveData(id, elem) {
var i = SCOGetObjectiveIndex(id);
if (!isNaN(i)) {
return SCOGetValue("cmi.objectives." + i + "."+elem)
}
return ""
}
function SCOGetObjectiveIndex(id){
var i = -1;
var nCount = parseInt(SCOGetValue("cmi.objectives._count"));
if (!isNaN(nCount)) {
for (i = nCount-1; i >= 0; i--){ //walk backward in case LMS does
journaling
if (SCOGetValue("cmi.objectives." + i + ".id") == id) {
return i
}
}
}
return NaN
}
// Functions to convert AICC compatible tokens or abbreviations to
SCORM tokens
function AICCTokenToSCORMToken(strList,strTest){
var a = strList.split(",");
var c = strTest.substr(0,1).toLowerCase();
for (i=0;i<a.length;i++){
if (c == a[i].substr(0,1)) return a[i]
}
return strTest
}
function normalizeStatus(status){
return AICCTokenToSCORMToken("completed,incomplete,not
attempted,failed,passed", status)
}
function normalizeInteractionType(theType){
return AICCTokenToSCORMToken("true-false,choice,fill-
in,matching,performance,sequencing,likert,numeric", theType)
}
function normalizeInteractionResult(result){
return AICCTokenToSCORMToken("correct,wrong,unanticipated,neutral",
result)
}
// Detect Internet Explorer
var g_bIsInternetExplorer = navigator.appName.indexOf("Microsoft") !=
-1;
// Handle fscommand messages from a Flash movie, remapping
// any AICC Flash template commands to SCORM if necessary
function quiz3_DoFSCommand(command, args){
var quiz3Obj = g_bIsInternetExplorer ? quiz3 : document.quiz3;
// no-op if no SCORM API is available
var myArgs = new String(args);
var cmd = new String(command);
var v = "";
var err = "true";
var arg1, arg2, n, s, i;
var sep = myArgs.indexOf(",");
if (sep > -1){
arg1 = myArgs.substr(0, sep); // Name of data element to get from
API
arg2 = myArgs.substr(sep+1) // Name of Flash movie variable to set
} else {
arg1 = myArgs
}
if (!APIOK()) return;
if (cmd.substring(0,3) == "LMS"){
// Handle "LMSxxx" FScommands (compatible with fsSCORM html
template)
if ( cmd == "LMSInitialize" ){
err = (APIOK() + "")
// The actual LMSInitialize is called automatically by the template
} else if ( cmd == "LMSSetValue" ){
err = SCOSetValue(arg1,arg2)
} else if ( cmd == "LMSFinish" ){
err = SCOFinish()
// Handled automatically by the template, but the movie
// may call it earlier.
} else if ( cmd == "LMSCommit" ){
err = SCOCommit()
} else if ( cmd == "LMSFlush" ){
// no-op
// LMSFlush is not defined in SCORM and calling it causes test
suite error
} else if ((arg2) && (arg2.length > 0)){
if ( cmd == "LMSGetValue") {
quiz3Obj.SetVariable(arg2, SCOGetValue(arg1));
} else if ( cmd == "LMSGetLastError") {
quiz3Obj.SetVariable(arg2, SCOGetLastError(arg1));
} else if ( cmd == "LMSGetErrorString") {
quiz3Obj.SetVariable(arg2, SCOGetLastError(arg1));
} else if ( cmd == "LMSGetDiagnostic") {
quiz3Obj.SetVariable(arg2, SCOGetDiagnostic(arg1));
} else {
// for unknown LMSGetxxxx extension
v = eval('g_objAPI.' + cmd + '(\"' + arg1 + '\")');
quiz3Obj.SetVariable(arg2,v);
}
} else if (cmd.substring(0,3) == "LMSGet") {
err = "-2: No Flash variable specified"
}
// end of handling "LMSxxx" cmds
} else if ((cmd.substring(0,6) == "MM_cmi")||(cmd.substring(0,6) ==
"CMISet")) {
// Handle a Macromedia Learning Components FScommands.
// These are using AICC HACP data model conventions,
// so remap data from AICC to SCORM as necessary.
var F_intData = myArgs.split(";");
if (cmd == "MM_cmiSendInteractionInfo") {
n = SCOGetValue("cmi.interactions._count");
s = "cmi.interactions." + n + ".";
// Catch gross errors to avoid SCORM compliance test failure
// If no ID is provided for this interaction, we cannot record it
v = F_intData[2]
if ((v == null) || (v == "")) err = 201; // If no ID, makes no
sense to record
if (err =="true"){
err = SCOSetValue(s + "id", v)
}
if (err =="true"){
var re = new RegExp("[{}]","g")
for (i=1; (i<9) && (err=="true"); i++){
v = F_intData[i];
if ((v == null) || (v == "")) continue
if (i == 1){
err = SCOSetValue(s + "time", v)
} else if (i == 3){
err = SCOSetValue(s + "objectives.0.id", v)
} else if (i == 4){
err = SCOSetValue(s + "type", normalizeInteractionType(v))
} else if (i == 5){
// strip out "{" and "}" from response
v = v.replace(re, "");
err = SCOSetValue(s + "correct_responses.0.pattern", v)
} else if (i == 6){
// strip out "{" and "}" from response
v = v.replace(re, "");
err = SCOSetValue(s + "student_response", v)
} else if (i == 7){
err = SCOSetValue(s + "result", normalizeInteractionResult(v))
} else if (i == 8){
err = SCOSetValue(s + "weighting", v)
} else if (i == 9){
err = SCOSetValue(s + "latency", v)
}
}
}
} else if (cmd == "MM_cmiSendObjectiveInfo"){
err = SCOSetObjectiveData(F_intData[1], ".score.raw", F_intData[2])
if (err=="true"){
SCOSetObjectiveData(F_intData[1], ".status", normalizeStatus
(F_intData[3]))
}
} else if ((cmd=="CMISetScore") ||(cmd=="MM_cmiSendScore")){
err = SCOSetValue("cmi.core.score.raw", F_intData[0]);
} else if ((cmd=="CMISetStatus") || (cmd=="MM_cmiSetLessonStatus")){
err = SCOSetValue("cmi.core.lesson_status", normalizeStatus
(F_intData[0]))
} else if (cmd=="CMISetTime"){
err = SCOSetValue("cmi.core.session_time", F_intData[0])
} else if (cmd=="CMISetCompleted"){
err = SCOSetStatusCompleted()
} else if (cmd=="CMISetStarted"){
err = SCOSetValue("cmi.core.lesson_status", "incomplete")
} else if (cmd=="CMISetPassed"){
err = SCOSetValue("cmi.core.lesson_status", "passed")
} else if (cmd=="CMISetFailed"){
err = SCOSetValue("cmi.core.lesson_status", "failed")
} else if (cmd=="CMISetData"){
err = SCOSetValue("cmi.suspend_data", F_intData[0])
} else if (cmd=="CMISetLocation"){
err = SCOSetValue("cmi.core.lesson_location", F_intData[0])
} else if (cmd=="CMISetTimedOut"){
err = SCOSetValue("cmi.core.exit", "time-out")
} // Other Learning Component FScommands are no-ops in this context
} else {
if (cmd=="CMIFinish" || cmd=="CMIExitAU"){
err = SCOFinish()
} else if (cmd=="CMIInitialize" || cmd=="MM_StartSession"){
err = SCOInitialize()
} else {
// Unknown command; may be invoking an API extension
// If commands comes with a 2nd argument, assume a value is
expected
// otherwise assume it is just a cmd
if (eval('g_objAPI.' + cmd)) {
v = eval('g_objAPI.' + cmd + '(\"' + arg1 + '\")');
if ((arg2) && (arg2.length > 0)){
quiz3Obj.SetVariable(arg2,v)
} else {
err = v
}
} else {
err = "false"
}
}
}
// End of command translation and processing
// handle detected errors, such LMS error returns
if ((g_bShowApiErrors) && (err != "true")) {
AlertUserOfAPIError(ExpandString(g_strFSAPIError, err, cmd, args))
}
return err
}
//-->
</script>
<body bgcolor="#ffffff" onload="SCOInitialize()" onunload="SCOFinish
()" onbeforeunload="SCOFinish()">
<script type="text/javascript" language="JavaScript" name="earlyInit">
<!--
// Determine whether to attempt to initialize API before loading
// movie in case there is some ActionScript that fires off before
// the rest of the HTML page has finished loading. This is
// configurable by setting the global boolean (g_bInitializeOnLoad)
// in the beginning of this file. Default value is TRUE.
if (g_bInitializeOnLoad) {
SCOInitialize()
}
//-->
</script>
<!--url's used in the movie-->
<!--text used in the movie-->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=9,0,0,0" id="quiz3" width="800" height="600"
align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="quiz3.swf" /><param name="quality"
value="high" /><param name="bgcolor" value="#ffffff" /><embed
src="quiz3.swf" quality="high" bgcolor="#ffffff" width="800"
height="600" name="quiz3" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>

Charles Parcell

unread,
Nov 3, 2009, 3:42:35 PM11/3/09
to eLearning Technology and Development
OK. Somewhere in your Flash file it should make the call to send the
items you indicated. I am not sure if they are already there in your
template or if you will have to add them. They should look something
like this.

quiz3_DoFSCommand("CMISetScore", ".92"); // Send the raw score of 92

or

quiz3_DoFSCommand("MM_cmiSendScore", ".92"); // Send the raw score of
92

For interactions such as student responses the call will be something
like this.

quiz3_DoFSCommand("MM_cmiSendInteractionInfo", ... );

It is too difficult to tell how these are actually implemented in the
Flash file itself. But there is code in the JavaScript that you sent
that seems to handle everything you are wanting to report to the LMS.
Finding the correct function and making sure they are triggered is
your challenge. The answer is in the ActionScript and not in the
JavaScript.

But if you wanted to circumvent this invloved JavaScript, you could
just call out JS yourself. But I think with student responses, you
might want to find the proper ActionScript within your template.

Charles P.

tukgae tukgae

unread,
Nov 3, 2009, 9:53:38 PM11/3/09
to elearning-technolo...@googlegroups.com
thank Charles P
Did you mean to put the code in the html file, what java script function
in my flash file template is already at last result page show pass or failed and score
 
this code in flash template

var navMovie_mc;
var feedbackMovie_mc;
var nextButton_mc;
var resetButton_mc;
var submitButton_mc;
var pagenum_mc;

//tracking mechanism for added questions
var questionStatusArray:Array;
var currentQuestion:int = 0;
var intervalQuestionInit;
var currentFrameLabel_1:String = new String("welcome");
var tracking:Boolean = true;
var trackingMC;
var timer:Timer;
var tadapter;
var dataloaded;
if(this.noofQuestions == undefined)
{
 this.noofQuestions = this.totalFrames - 2;
 this.passPercent = 80;
 this.passString = "Congratulations, you have passed!";
 this.failString = "Sorry, you failed!";
 
}
if(navigation_mc != null)
{
 navMovie_mc = navigation_mc;
 navMovie_mc.visible = false;
}
function showDebug (_str)
{
 //_debug.appendText (_str+"\n");
}
function initialized (event:TimerEvent)
{
 var checkInit = tadapter.isInitialized();
 showDebug ("checkInit = "+checkInit);
 if (checkInit)
 {
  //tadapter.sendInteractionData("int001", "obj001", "choice", "C","C","right",50,"", "", "")
  //tadapter.sendInteractionData("100001", "q1234", "choice", "1", "1", "1", 10, 0, undefined, undefined);
  timer.stop ();
  timer.removeEventListener (TimerEvent.TIMER_COMPLETE,initialized);
  tadapter.getTrackingData ();
  dataloaded = tadapter.isTrackingDataLoaded();
  showDebug ("dataloaded = "+dataloaded);
  if (dataloaded)
  {
   initializeNavigation ();
  }
  else
  {
   timer = new Timer(8000,1);
   timer.addEventListener (TimerEvent.TIMER_COMPLETE,callinitializeNavigation);
   timer.start ();
  }
 }
}
var lmsScore_int;
var lmsLocation_str;
var lmsStatus_str;
function callinitializeNavigation (event:TimerEvent)
{
 dataloaded = tadapter.isTrackingDataLoaded();
 showDebug ("timer dataloaded = "+dataloaded);
 showDebug ("timer.repeatCount = "+timer.repeatCount);
 if (dataloaded)
 {
  lmsScore_int = tadapter.getScoreRaw();
  lmsLocation_str = tadapter.getLessonLocation();
  lmsStatus_str = tadapter.getLessonStatus();
  initializeNavigation ();
  timer.stop ();
  timer.removeEventListener (TimerEvent.TIMER_COMPLETE,callinitializeNavigation);
 }
}
function initQuiz ()
{
 trackingMC = tracking_adapter;
 trackingMC.createLMSAdapter ("SCORM");
 tadapter = trackingMC.currentTrackingAdapter();
 trace ("adapter not null = "+tadapter);
 if (tadapter != null)
 {
  trace ("adapter not null");
  if (tadapter.isInitialized())
  {
   trace ("adapter already initialized");
  }
  else
  {
   trace ("initializing the LMS adapter");
   tadapter.initialize ();
   timer = new Timer(500,1);
   timer.addEventListener (TimerEvent.TIMER_COMPLETE,initialized);
   timer.start ();
  }
 }
 else
 {
  initializeNavigation ();
 }

}
function initializeNavigation ()
{
 if (_loading != null)
 {
  _loading.visible = false;
 }
 
 feedbackMovie_mc = navigation_mc.feedback_mc;
 nextButton_mc = navigation_mc.next_btn;
 resetButton_mc = navigation_mc.reset_btn;
 submitButton_mc = navigation_mc.submit_btn;
 pagenum_mc = navigation_mc.pagenum_mc;
 questionStatusArray = new Array(this.noofQuestions);
 for (var i=0; i<questionStatusArray.length; i++)
 {
  var obj = new Object();
  obj.pointsScored = 0;
  obj.point = 0;
  questionStatusArray[i] = obj;
 }
 navMovie_mc.visible = true;
 makeInvisible (feedbackMovie_mc,resetButton_mc,submitButton_mc,pagenum_mc);
 submitButton_mc.addEventListener (MouseEvent.CLICK,submitClicked);
 resetButton_mc.addEventListener (MouseEvent.CLICK,resetClicked);
 nextButton_mc.addEventListener (MouseEvent.CLICK,nextClicked);
 if (submitButton_mc is MovieClip)
 {
  submitButton_mc.buttonMode = submitButton_mc.tabEnabled = submitButton_mc.focusRect = true;
  resetButton_mc.buttonMode = resetButton_mc.tabEnabled = resetButton_mc.focusRect = true;
  nextButton_mc.buttonMode = nextButton_mc.tabEnabled = nextButton_mc.focusRect = true;
  submitButton_mc.addEventListener (MouseEvent.MOUSE_OVER,showHighlight);
  resetButton_mc.addEventListener (MouseEvent.MOUSE_OVER,showHighlight);
  nextButton_mc.addEventListener (MouseEvent.MOUSE_OVER,showHighlight);
  submitButton_mc.addEventListener (MouseEvent.MOUSE_OUT,showHighlight);
  resetButton_mc.addEventListener (MouseEvent.MOUSE_OUT,showHighlight);
  nextButton_mc.addEventListener (MouseEvent.MOUSE_OUT,showHighlight);
 }
}
function showHighlight (e:MouseEvent):void
{
 if (e.type == "mouseOver")
 {
  e.currentTarget.gotoAndStop (2);
 }
 else if (e.type == "mouseOut")
 {
  e.currentTarget.gotoAndStop (1);
 }
}
function makeVisible (...args)
{
 for (var i=0; i<args.length; i++)
 {
  args[i].visible = true;
 }
}
function makeInvisible (...args)
{
 for (var i=0; i<args.length; i++)
 {
  args[i].visible = false;
 }
}
function setEnable (...args)
{
 for (var i=0; i<args.length; i++)
 {
  args[i].enabled = true;
 }
 submitButton_mc.addEventListener (MouseEvent.CLICK,submitClicked);
 resetButton_mc.addEventListener (MouseEvent.CLICK,resetClicked);
}
function setEnable2 (...args)
{
 for (var i=0; i<args.length; i++)
 {
  args[i].enabled = true;
 }
 nextButton_mc.addEventListener (MouseEvent.CLICK,nextClicked);
}

function setDisable (...args)
{
 for (var i=0; i<args.length; i++)
 {
  args[i].enabled = false;
 }
 submitButton_mc.removeEventListener (MouseEvent.CLICK,submitClicked);
 resetButton_mc.removeEventListener (MouseEvent.CLICK,resetClicked);
}
function setDisable2 (...args)
{
 for (var i=0; i<args.length; i++)
 {
  args[i].enabled = false;
 }
 nextButton_mc.removeEventListener (MouseEvent.CLICK,nextClicked);
}
function submitClicked (e:MouseEvent):void
{
 if (e.currentTarget is MovieClip)
 {
  e.currentTarget.gotoAndStop (1);
 }
 var resultstring = this["question_mc_"+currentQuestion].checkAnswer(e);
 feedbackMovie_mc.text = this["question_mc_"+currentQuestion].getFeedbackString();
 //trace("feedbackMovie_mc.text = "+feedbackMovie_mc.text);
 //questionStatusArray[currentQuestion-1].point = this["question_mc_"+currentQuestion].points;
 questionStatusArray[currentQuestion-1].pointsScored = this["question_mc_"+currentQuestion].getPointsScored();
 
 var _obj; 
 trace("resultstring.toLowerCase() = "+resultstring.toLowerCase());
 if (resultstring.toLowerCase() == "correct" || resultstring.toLowerCase() == "right")
 {
  setDisable (resetButton_mc,submitButton_mc);
  setEnable2 (nextButton_mc);
  if (tadapter != null)
  {
   _obj = this["question_mc_"+currentQuestion].getInteractionDetails();
   trace("_obj = "+_obj);
   trace(_obj is Array);
   trace(_obj[0]);
    if(_obj is Array)
    {
     for(var i=0;i<_obj.length;i++)
     {
      this.sendQuestionInteractionData (_obj[i]);
     }
    }
    else
    {
     this.sendQuestionInteractionData (_obj);
    }
  }
 }
 else if (resultstring.toLowerCase() != "notcomplete")
 {
  var _totaltries = this["question_mc_"+currentQuestion].totalTries;
  var _triescompleted = this["question_mc_"+currentQuestion].completedTries;
  trace("_totaltries = "+_totaltries);
  trace("_triescompleted = "+_triescompleted);
  if (_triescompleted >= _totaltries)
  {
   setDisable (resetButton_mc,submitButton_mc);
   setEnable2 (nextButton_mc);
   if (tadapter != null)
   {
    _obj = this["question_mc_"+currentQuestion].getInteractionDetails();
    this.sendQuestionInteractionData (_obj);
   }
  }
 }
}
function resetClicked (e:MouseEvent):void
{
 if (e.currentTarget is MovieClip)
 {
  e.currentTarget.gotoAndStop (1);
 }
 this["question_mc_" + currentQuestion].resetQuestion (e);
}
function sendQuestionInteractionData (_obj:Object)
{
 tadapter.sendInteractionData (_obj.id,_obj.objectiveId,_obj.type,_obj.correct_response,_obj.student_response,_obj.result_str,_obj.weight_int,_obj.latency_str,_obj.date_str,_obj.time_str);
}
function sendSessionTrackingData ()
{
 var totalpoints = 0;
 var totalpointsscored = 0;
 trace("questionStatusArray.length = "+questionStatusArray.length);
 for (var i=0; i<questionStatusArray.length; i++)
 {
  totalpointsscored += questionStatusArray[i].pointsScored;
  totalpoints += questionStatusArray[i].point;
 }
 var percentage = (totalpointsscored/totalpoints)*100;
 percentage = parseInt(percentage.toString());
 var status_str;
 var successstatus_str;
 trace("totalpointsscored = "+totalpointsscored);
 trace("totalpoints = "+totalpoints);
 trace("percentage = "+percentage);
 if ((this.currentFrame+1)==this.totalFrames)
 {
  status_str = "completed";
 }
 else
 {
  status_str = "incomplete";
 }
 if (percentage>=this.passPercent)
 {
  successstatus_str = "passed";
 }
 else
 {
  successstatus_str = "failed";
 }
 tadapter.sendTrackingData (totalpointsscored, 0, totalpoints, true, this.currentFrame, status_str, successstatus_str, true, "", "");
}
function nextClicked (e:MouseEvent):void
{
 
 
 if (intervalQuestionInit != undefined)
 {
  clearInterval (intervalQuestionInit);
 }
 if (this["question_mc_"+currentQuestion] != null && this["question_mc_"+currentQuestion] != undefined)
 {
  questionStatusArray[currentQuestion-1].point = this["question_mc_"+currentQuestion].points;
 trace("currentQuestion = "+currentQuestion);
 trace("currentQuestion points = "+questionStatusArray[currentQuestion-1].point);
 }
 
 if (e.currentTarget is MovieClip)
 {
  e.currentTarget.gotoAndStop (1);
 }
 if (tadapter != null)
 {
  sendSessionTrackingData ();
 }
 currentQuestion++;
 trace("currentQuestion = "+currentQuestion);
 if (currentQuestion>0 && currentQuestion<=this.noofQuestions)
 {
  //in Question Frame
  navMovie_mc.pagenum_mc.pagenum_txt.text = currentQuestion +" of "+this.noofQuestions;
  currentFrameLabel_1 = "Question";
  this.nextFrame ();

 }
 else
 {
  currentFrameLabel_1 = "Result";
  //in result frame
  this.nextFrame ();
  makeInvisible (feedbackMovie_mc,resetButton_mc,submitButton_mc,nextButton_mc,pagenum_mc);
  if(tadapter != null)
   tadapter.finish ();
 }
 intervalQuestionInit = setInterval(checkForEvent,200);
}
function checkForEvent ()
{
 if (this["question_mc_"+currentQuestion] != null)
 {
  feedbackMovie_mc.text = "";
  QuestionInitialized ();
  makeVisible (feedbackMovie_mc,resetButton_mc,submitButton_mc,pagenum_mc);
  setEnable (resetButton_mc,submitButton_mc);
  setDisable2 (nextButton_mc)
  clearInterval (intervalQuestionInit);
 }
 else if (this["result_mc"] != null)
 {
  setResultPage ();
  clearInterval (intervalQuestionInit);
 }
}
function setResultPage ()
{
 var totalpoints = 0;
 var totalpointsscored = 0;
 for (var i=0; i<questionStatusArray.length; i++)
 {
  totalpointsscored += questionStatusArray[i].pointsScored;
  totalpoints += questionStatusArray[i].point;
 }
 var percentage = (totalpointsscored/totalpoints)*100;
 percentage = parseInt(percentage.toString());
 this["result_mc"].totalpoints_txt.text = totalpoints.toString();
 this["result_mc"].scoredpoints_txt.text = totalpointsscored.toString();
 this["result_mc"].scoredpercentage_txt.text = percentage.toString()+"%";
 if (percentage>=this.passPercent)
 {
  this["result_mc"].resultString_txt.text = this.passString;
 }
 else
 {
  this["result_mc"].resultString_txt.text = this.failString;
  
  ;
 }
}
function checkQuizScore ()
{
 //this.passPercent
}
function QuestionInitialized ():void
{
 var questionMC = this["question_mc_"+currentQuestion];
 //questionMC.tracking = true;
}
stop ();
initQuiz ();


Charles Parcell

unread,
Nov 4, 2009, 3:12:47 PM11/4/09
to eLearning Technology and Development
Sorry, I got side tracked with work. :)

I have only quickly looked over the AS code. I have a few questions.

Do you have a Submit button in your project somewhere? It appears that
this button contains code to build the interactions.

Is this a custom template or is it provided with some Adobe product?

When I have more time later tonight I will look over this in more
detail. Is there anyway you could upload the FLA file to this group or
e-mail to me?

Charles P.
> ...
>
> read more »

Charles Parcell

unread,
Nov 5, 2009, 1:19:07 AM11/5/09
to eLearning Technology and Development
Try putting an alert in your JavaScript. Add it as the first line of the quiz3_DoFSCommand function.

alert("command\n" + command);
alert("args\n" + args);

This will show you if the function is being called and if the correct data is being sent.


Back tracking from the JavaScript to the ActionScript... In the SubmitClicked function there is a call...

this.sendQuestionInteractionData(_obj);

I would try placing a trace in the sendQuestionInteractionData function. You want to make sure that this is being called and also that the object being passed to the function contains all the data it should be.


The above function then calls to...

tadapter.sendInteractionData(...);  // lots of data being passed to the function

tadapter is an alias to tracking_adapter, which would appear to be a MovieClip. Without knowing what code is within tracking_adapter I can only guess at the issue. It could be that the function sendInteractionData within it is not calling to correct ExternalInterface function in your JavaScript.

There should be an ExternalInterface call to the JavaScript function quiz3_DoFSCommand. Or it could be an fscommand that is calling to the JavaScript function quiz3_DoFSCommand. If it is a fscommand, I would really suggest you switch it to ExternalInterface. In any case, it should be passing "MM_cmiSendInteractionInfo" in one of it's parameters.

Hope this helps.

Charles P.


Reply all
Reply to author
Forward
0 new messages