Auto-completion in Ace as a default option

Auto-completion in Ace as a default option

by Chris Nelson -
Number of replies: 3

Hi Richard,

We've received a second piece of feedback, this time from staff using CodeRunner: "Could we enable code completion in Ace by default? I know it's limited (it doesn't seem to include imported classes), but it could be useful if we don't have to go into a menu to find it in each CodeRunner window (the setting is not persistent)."

Would this be a possible future feature?

Thanks for reading :-)

In reply to Chris Nelson

Re: Auto-completion in Ace as a default option

by Richard Lobb -

Hi again Chris

Another interesting suggestion. But here I'm a bit more conflicted.

I personally dislike code completion. I'm a good typist and find it very distracting to have stuff keep popping up on screen and interrupting my flow. But I accept that many users love it.

There's also a philosophical question of whether code completion is pedagogically good for beginners: I've heard it argued that it impedes learning. I have no idea whether there's any actual data to support that claim, but it does fit with my own prejudices :)

Personal prejudices and pedagogical philosophy aside, though, I do generally believe that it's best to give users options to configure their environments how they like. Earlier this year I had some students beg for us to switch Ace to a dark theme. Again, this isn't something I myself would choose but dark themes are certainly very popular at present, and why shouldn't student be allowed to use them? There's some discussion of this here. Currently the Ace UI does check for the media preference "prefers-color-scheme: dark" but it hasn't proved all that usable. I must revisit it and remind myself exactly why.

What I'd really like to see is something that lets the user set various Ace editor configuration options and have them "stick" for all subsequent uses. See here for example. Unfortunately that's an 8-year-old page and the functionality hasn't become standard.

In the absence of a convenient way for students to individually customise their environments, I think the best we could do would be to let individual teachers customise the Ace editor they way they wanted. That could be achieved as follows.

All CodeRunner UI plugins can have options that are configured in the question prototype and can be overridden by the question itself. Associated with each UI plugin is a json file listing the UI's configuration parameters. For example see this file for the Graph UI configuration parameters. Each parameter is documented within the lang file, e.g. for the Graph UI isfsm parameter, in the English language file, we have

$string['graphui_isfsm_descr'] = 'True if the graph represents a Finite State Machine,
in which case it can contain an incoming edge from nowhere (the start edge) and can
have \'accept\' nodes';

If a UI plugin has such options, the question authoring form displays a UI parameters entry field. For example, for the Graph UI:

You don't see this field with standard CodeRunner questions using the Ace UI because I very deliberately did not give it any parameters. I was trying to avoid adding extra complexity to the authoring form, which is already more complicated than I'd like. But it would be pretty trivial to add, say, autocompletion and darktheme UI parameters to Ace. The result then would be that you as a teacher could customise your own question types to turn on autocompletion, while I could leave it off for all of my questions.

The downside is that the question authoring form has now acquired the extra complexity of a UI parameters field for all questions, not just for those using non-Ace UIs.

I'm frankly unsure whether I want to go down this path or not. But we should discuss. Could you bounce that idea around among your colleagues to see what they think about it please? And of course comments are welcome from anyone else reading this forum.

Thanks again for the suggestion.

Richard

In reply to Richard Lobb

Re: Auto-completion in Ace as a default option

by Anton Dil -
I wasn't aware Ace supported code completion in two modes: normal and 'live'. It's the second one that is in the options for the editor, and I also find it distracting. However, putting aside the merits of code completion, and how good Ace is at it (not very good as far as I can see) I do think it would be helpful if students could persist their preferences from the Ace options, e.g. to use a larger font, or turn off the gutter. That seems more important.
In reply to Anton Dil

Re: Auto-completion in Ace as a default option

by Anton Dil -
I see there is also a wrap mode which would help with the width of the editor and avoid right-scrolling, but again I don't think it's a persistent setting.