function wrsqz_get_correct_responses($questionType, $dbType, $response, &$question, &$state, $mode = 'M') {
//mode='M' => MathML <math xmlns=".......
//mode='W' => encoded MathML for filtering  �math xmlns=�...
//mode='T' => Plain Text 2^(1/2)...

	if ($questionType == 'shortanswer') {
            if (!is_array($response)){
                $response = array();
            }
            
            mb_parse_str($question->options->wiris->eqoption, $eqoptionArray);
            $editor = isset($eqoptionArray['editor']) && $eqoptionArray['editor'] == 'true';
            $multipleAnswers = $editor && isset($eqoptionArray['multipleAnswers']) && $eqoptionArray['multipleAnswers'] == 'true';
            
            //get the first maximum graded answer and, in the multipleanswer case,
            //the names of the variables to be used (depending on if we use test
            //functions or not).
            if($question->options->answers){
            	foreach ($question->options->answers as $answer) {
                    if (((int) $answer->fraction) === 1) {
                        $correctanswer = $answer->answer;
                        if($multipleAnswers){
                            if (isset($eqoptionArray['testFunction']) && isset($eqoptionArray['testFunction'][$answer->id])){
                                $index = $eqoptionArray['testFunction'][$answer->id];
                                $names = $eqoptionArray['testFunctionName'][$index];
                            }else{
                                $names = $answer->answer;
                            }
                        }
                    }
                }
	    }else{
                $correctanswer=null;
            }
		//$correctanswer=#p
		//encode it depending on the use of wiris editor and the desired mode

		if ($editor) {
			if ($multipleAnswers) {
				if ($mode == 'T'){
					//plain text for directly display (space separated)
					$response['']=wrsqz_assemble(wrsqz_variablesToText($correctanswer), $state->vars);
				}else if($mode == 'M'){
					//mathml for an applet
					$response['']=wrsqz_multipleAnswersTable($correctanswer,$state->vars,$names);
				}else if($mode == 'W'){
					//encoded mathml for filtering
					$response['']=wrsqz_multipleAnswersTable($correctanswer,$state->vars, $names);
					$response['']=wrsqz_mathmlEncode($response['']);
				}
			} else {
				if ($mode == 'T'){
					$response[''] = wrsqz_assemble(wrsqz_variablesToText($correctanswer), $state->vars);
				}else if ($mode == 'M'){
					$response[''] = wrsqz_assemble(wrsqz_textToVariables($correctanswer), $state->vars);
				}else if ($mode == 'W'){
					$response[''] = wrsqz_assemble($correctanswer, $state->vars);
				}
			}
		} else {
			//if editor is not used, we use text mode (T) always.
			$response[''] = wrsqz_assemble(wrsqz_variablesToText($correctanswer), $state->vars);
		}
	}
	return $response;
}
    }
    $variableString = implode(',', $variables);
    // ##Ma,##Mb
    //call servlet in order to evaluate the program & get variables
    $message = callServlet($variableString, $problem);
    //clean undefined variables from servlet response
    $definedNames = array();
    foreach ($message['vars'] as $variable => $value) {
        if ($value != 'undefined' && $value != 'no_definido' && $value != 'indefinit' && $value != 'indéfini' && $value != 'indefinito') {
            $definedNames[] = mb_substr($variable, 3);
        }
    }
    if (!empty($definedNames)) {
        $definedNamesString = implode(' ', $definedNames);
        // Generate the MathML output
        $editorMathML = wrsqz_multipleAnswersTable($definedNamesString, $message['vars'], $definedNamesString);
        echo $editorMathML;
    } else {
        echo '<math></math>';
    }
} else {
    //If multipleAnswers is not et, we copy the last WIRIS CAS output
    //Get the last output inside WIRIS CAS mathML.
    $start = strlastpos($problem, '<output>') + strlen('<output>');
    $end = strlastpos($problem, '</output>');
    $math = mb_substr($problem, $start, $end - $start);
    //remove the <math> tag
    $start = mb_strpos($math, '>') + 1;
    $end = mb_strrpos($math, '<');
    $math = mb_substr($math, $start, $end - $start);
    //We have the WIRIS CAS MathML, but we want the Editor MathML. We use the service with a convenient program