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.

Add script to question, with position

In this 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

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. All HTML are loaded, then you can update question or answers at this place without any other function.
POS_READY
The script is inserted in the jQuery’s ready function. Just when you add $(function() { }) in the workaround.
POS_LOAD
The script is inserted in the window.onload() function. All HTML and files are loaded (css, image …).

Plugin and XSS

New version of this plugin use XSS, then disable edition of java-script for non admin user. But if user with XSS enable edit question : this don’t remove exiting java-script.