'<math><mrow><msqrt><mrow><mn>2</mn><msqrt><mn>3</mn></msqrt></mrow></msqrt><mi>#a</mi></mrow></math>', '<math><mrow><msub><mi>#</mi><mi>a</mi></msub></mrow></math>' => '<math><mrow><msub><mi>#</mi><mi>a</mi></msub></mrow></math>', '<math><mrow><mi>#</mi><msub><mi>a</mi><mi>c</mi></msub></mrow></math>'=>'<math><mrow><msub><mi>#a</mi><mi>c</mi></msub></mrow></math>', ); foreach($tests as $test=>$correct){ $resp = wrsqz_prepareVariablesInsideFormulas($test, FALSE); echo '<tr><td>'; echo $resp == $correct ? 'OK' : 'KO'; echo '</td>'; echo '<td>'.htmlentities($test, ENT_COMPAT, 'UTF-8').'</td>'; echo '<td>'.htmlentities($resp, ENT_COMPAT, 'UTF-8').'</td>'; echo '</tr>'; } foreach($tests as $test=>$correct){ $correct = wrsqz_mathmlEncode($correct); $test = wrsqz_mathmlEncode($test); $resp = wrsqz_prepareVariablesInsideFormulas($test, TRUE); echo '<tr><td>'; echo $resp == $correct ? 'OK' : 'KO'; echo '</td>'; echo '<td>'.htmlentities($test, ENT_COMPAT, 'UTF-8').'</td>'; echo '<td>'.htmlentities($resp, ENT_COMPAT, 'UTF-8').'</td>'; echo '</tr>'; } ?> </tr> </table> </body> </html>
/** * To be called before save_question_options. * It changes formulas in questiontext fixing MathML issues related to variable assembling. * **/ function wrsqz_presave_question($questionType, $dbType, &$question, &$form, $course){ $form->questiontext = wrsqz_prepareVariablesInsideFormulas($form->questiontext); }