I have coded a solution. I edited the question.php page with the following...
I created this function:
// *****************************************************
function showcorrect_popup($prevquestion, $prevanswer) {
global $dbprefix;
global $correctaanswerpopup, $capopup, $clang;
// Set correct answers session variable
if (!isset($_SESSION)) {
$_SESSION = "0";
}
// A1 is the code of the answer, and A1 will always be the correct answer
//$prevanswer = {INSERTANS:SIDXGIDXQID};
if ($prevanswer == "A1") {
$_SESSION++;
$capopup = "<script type=\"text/javascript\">\n
alert(\"".$clang->gT("Correct", "js")."\");\n
</script>";
} else {
// Show Correct Answer
$aquery = "SELECT answer FROM {$dbprefix}answers WHERE qid=".$prevquestion[0]." ORDER BY code ASC LIMIT 1";
$aresult = db_execute_assoc($aquery); //Checked
while ($arow = $aresult->FetchRow()) {
$capopup = "<script type=\"text/javascript\">\n
alert(\"".$clang->gT("The correct answer is: ".$arow.". Continue", "js")."\");\n
</script>";
}
}
$correctaanswerpopup="Y";
return array($correctaanswerpopup, $capopup);
}
// *****************************************************
And i call it just after the mandatory check:
// Display the "mandatory" popup if necessary
if (isset($notanswered) && $notanswered!=false) {
list($mandatorypopup, $popup) = mandatory_popup($ia, $notanswered);
// Show answer to previous question
} elseif ((isset($move)) && (($move == "movenext") || ($move == "movesubmit"))) {
// These variables are to show the variables for current question, step, etc.
/*print_r($_SESSION[$currentquestion-1]);
echo '<br />';
echo '$currentquestion: '.$currentquestion.'<br />';
echo '$_SESSION[step]: '.$_SESSION.'<br />';
echo '$thisstep: '.$thisstep.'<br />';
echo '$_POST[grpdesc]: '.$_POST.'<br />';
echo '$newgroup: '.$newgroup.'<br />';*/
// If not a new group and $_POST[grpdesc] doesn't exist, call the function
$prevquestion = $_SESSION[$currentquestion-1];
$prevanswer = $_SESSION["$prevquestion[1]"];
if (($newgroup == "N") && (!isset($_POST))) {
list($correctanswerpopup, $capopup) = showcorrect_popup($prevquestion,$prevanswer); // Display alert
}
}
I hope this helps someone out, as it took me a few days to get my head around the system.