Documentation

, 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 poisition

The choise in javascript position use the Yii way

POS_HEAD
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.
POS_BEGIN
The script is inserted at the beginning of the body section. Near same then POS_HEAD : HTML are not produced or loaded.
POS_END
the script is inserted at the end of the body section. Surely the best solution, the default solution. All HTML are loaded, then you can update question or answers at this place without any other function.
POS_LOAD
The script is inserted in the window.onload() function. The HTML are loaded, but all img, other script or css.
POS_READY
The script is inserted in the jQuery’s ready function. Just when you add $(function() { }) in the workaround. Happen after POS_END but before POS_READY.

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 fileted, 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.