, by Denis Chenu

This plugin a textarea when editing a question, this textarea are used for javascript.

When you want update partially a question, you can use jquery. It’s quick, limesurvey manual and forum post have a lot of script for such workaround.

It’s seems easy, quick and convenient for some purpose.

But where to place the script ? If you use HTML editor, it can be hard to put in a clean way. This plugin offer the solution.

The plugin in action

On each question, for all current question type : a new textarea is shown.

Global settings for the Script

In in textarea : you can put your javascript workaround. You can use expression manager , for example {QID} or {SGQ} [1].

In the global settings : you have 2 options

Global settings of addScriptToQuestion
Show the scriptPosition attribute
You can choose to show a settings in each question to allow the user to choose the script position, default to false
Default script position
Choose where the scripts are put, you have all the option, the default are to put the script ate end of the page. We advise you to keep this solution.

The script position

The choice in javascript position use the Yii way

The script is inserted in the head section right before the title element. HTML are not started, then you need to use $(document).on or other systems.
The script is inserted at the beginning of the body section.. Near same then POS_HEAD : HTML are not produced or loaded.
The script is inserted at the end of the body section. All HTML are loaded, then you can update question or answers at this place without any other function.
The script is inserted in the jQuery’s ready function. Just when you add $(function() { }) in the workaround.
The script is inserted in the window.onload() function. All HTML and files are loaded (css, image …).

Plugin and XSS

This plugin don’t test XSS, don’t add and activate this plugin if you don’t trust your user.

With XSS : the HTML of your admin user are filtered, for example : you are sure a starting tag was closed. Then adding this plugins allow you to create clean HTML and allowing script for your admin user.