Answer with php code : can I bypass the mandatory php tags?

Answer with php code : can I bypass the mandatory php tags?

de benoit darties -
Número de respuestas: 2

Hi!

First of all Thank you very much for this amazing plugin!

It's simply an unbelievable tool for students.


I have a concern with questions requiring php code. I've read that the student need to begin his code with a <?php or <? mark, and not close it, to perform a successful test.

Is there a way to change this? Ideally, I'd like that the answer either include both opening and closing mark, or none. I tried some basic modifications on the template, but without success.

Thanks for your reply



En respuesta a benoit darties

Re: Answer with php code : can I bypass the mandatory php tags?

de benoit darties -

I think I finally found  the problem...

There was a confusion due to the mention of an error occurring the template editing box (see screenshot). But everything works when testing


Adjunto Capture d’écran 2018-07-02 à 17.32.24.png
En respuesta a benoit darties

Re: Answer with php code : can I bypass the mandatory php tags?

de Richard Lobb -

Good to know the problem is solved.

Yes, those syntax errors are confusing, I admit. They are generated by the Ace code editor which is managing the template - the embedded Twig code isn't valid PHP. You can turn off Ace if you wish by customising the question or its prototype. There's a checkbox "Template uses Ace" at the bottom of the Customisation panel.

Screen dump showing Template Uses Ace checkbox

I prefer to have it on by default, myself, because syntax colouring makes it much easier to edit large templates. Also, nearly all my templates are in Python nowadays, regardless of what language the question is asking for, and the double braces are generally valid Python.

For small PHP templates, though, the Ace editor might be more of a hindrance than a help.

Richard