STACK : Line Break in Question Variables

STACK : Line Break in Question Variables

by Adrian Föll -
Number of replies: 5

Hello,


im trying to find out if there is any way to do Line Breaks in the Question Variables Field in STACK. 

I know the documentation says that items are seperated by a newline or ;.

Is there still a way to do it?

I am using some nested loops and if-conditions and I just want to make it more readable for me and others.


Thanks

Adrian

Average of ratings: -
In reply to Adrian Föll

Re: STACK : Line Break in Question Variables

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes. It is a text area. You can do multi-line input. Just press enter to start a new line.

(I feel sure I must have misinterpreted your question. Surely the answer can't be that simple.)

In reply to Tim Hunt

Re: STACK : Line Break in Question Variables

by Adrian Föll -

Thanks for the quick reply.

I am using a port of STACK for the ILIAS learning platform, maybe there are some differences

and these problems arise just in the ILIAS port of STACK.

For example I have this code in one part of the question variables.

while ... do [ for ... do [... , if ... then ... ,  ...] ] ;

and I want it to look something like this :

while ...

     do [

        for ... do [

            ... , if ... then ... , ...

        ]

    ];

I need to make the code as easily readable as possible, so I just want to figure out what options I have to do so.

In reply to Adrian Föll

Re: STACK : Line Break in Question Variables

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Adrian,

Currently in STACK the text area Tim mentions has one limitation, and that is that it interprets each line as a new CAS input.  I don't think this is an ILIAS issue really.

All this is done in this code starting here:

https://github.com/maths/moodle-qtype_stack/blob/master/stack/cas/keyval.class.php#L98

The "explode("\n", $str);" command splits up what is in the text area and the loop in lines 109 onwards make these into new CAS strings.

Adding support for multi-line input is very sensible, and I agree multi-line statements aid readability etc.  If you'd like to propose some code to turn multi-line statements into single cas variables, then please go ahead.  It will be a very valuable additional feature.  I can add it to the "todo list", but it isn't something I'm likely to add in the short term I'm afraid.

Chris