LimeSurvey Manual
Menu
Navigation
Main page
Recent changes
Help
Special pages
Printable version
Recent changes
Help
English
Log in to Manual
Login
Log in to your account
English
Log in to Manual
Get started for free
Sign up
Actions
Translate
Language statistics
Message group statistics
Export
Special
Export translations
Settings
Group
Activating a survey
Adding answers or subquestions
Administering LimeSurvey
Alternatives to the LimeSurvey import function
Assessments
Backup entire database
Batch deletion
Category:Advanced Question Settings
Category:General Question Options
Category:Question Settings
Central Participant Database
Changing an active survey
Check data integrity
Check question logic
Check survey logic - Advanced
Closing a survey
ComfortUpdate
Copy question
Custom translation
Data encryption
Data entry
Data policy settings
DateFunctions
Default answers
Delete question
Delete survey
Display/Export survey
Edit question
Email bounce tracking system
Email templates
Export question
Export responses
Exporting results
Expression Manager
Expression Manager sample surveys
ExpressionScript - Presentation
ExpressionScript Engine - Quick start guide
ExpressionScript examples
ExpressionScript How-tos
ExpressionScript sample surveys
Extension compatibility
Failed email notifications
First login - your user preferences
General FAQ
General settings
Getting started
Global settings
Google API howto
Home page settings
How to design a good survey (guide)
Import responses
Importing a survey
Installation - LimeSurvey CE
Installation FAQ
Installation of the LimeSurvey XAMPP package
Installation security hints
Installation using a command line interface (CLI)
Installation Version 1.92 or older
Iterate survey
Label sets
LDAP settings
License
LimeSurvey Manual
LimeSurvey PRO vs LimeSurvey CE
LimeSurvey Users
LimeSurvey Video-Tutorial
LimeSurvey-compatible hosting companies
List question groups
List questions
Localization
Major version upgrade
Make your plugin compatible with LS4
Manage user groups
Manage users
Menu configuration
Menu entries configuration
Multilingual survey
New Template System in LS3.x
Not categorized and advanced features
Notifications & data
Optional settings
Overview
Panel integration
Participant settings
Plugin manager
Plugin menu
Plugins - advanced
Presentation
Preview function
Problems & solutions
Publication & access
QS:Allowed filetypes
QS:Alphasort
QS:Answer width
QS:Array filter
QS:Array filter exclude
QS:Array filter style
QS:Assessment value
QS:Autocheck exclusive option
QS:Category separator
QS:Chart type
QS:Choice column width
QS:Choice header
QS:Code filter
QS:Commented checkbox
QS:CSS Class
QS:Date max
QS:Date min
QS:Date time format
QS:Display chart
QS:Display columns
QS:Display map
QS:Display rows
QS:Display type
QS:Dropdown dates
QS:Dropdown dates year max
QS:Dropdown dates year min
QS:Dropdown prefix
QS:Dropdown prepostfix
QS:Dropdown separators
QS:Dropdown size
QS:Dualscale headerA
QS:Dualscale headerB
QS:Em validation q
QS:Em validation q tip
QS:Em validation sq
QS:Em validation sq tip
QS:Encryption
QS:Equals num value
QS:Equation
QS:Exclusive option
QS:Get order previous q
QS:Hidden
QS:Hide tip
QS:Input box size
QS:Input boxes
QS:Input max characters
QS:Label column width
QS:Location city
QS:Location country
QS:Location defaultcoordinates
QS:Location mapheight
QS:Location mapservice
QS:Location mapwidth
QS:Location mapzoom
QS:Location nodefaultfromip
QS:Location postal
QS:Location state
QS:Mandatory
QS:Max answers
QS:Max filesize
QS:Max num value
QS:Max num value n
QS:Max num value sgqa
QS:Max subquestions
QS:Maximum chars
QS:Maximum number of files
QS:Min answers
QS:Min num value
QS:Min num value n
QS:Minimum number of files
QS:Minute step interval
QS:Month display style
QS:Multiflexible checkbox
QS:Multiflexible max
QS:Multiflexible min
QS:Multiflexible step
QS:Num value int only
QS:Numbers only
QS:Other
QS:Other comment mandatory
QS:Other numbers only
QS:Other Position
QS:Other replace text
QS:Page break
QS:Prefix
QS:Preg validation
QS:Printable survey relevance help
QS:Public statistics
QS:Question theme
QS:Random group
QS:Random order
QS:Rank header
QS:Relevance
QS:Remove text or uncheck checkbox
QS:Repeat headers
QS:Reverse
QS:Samechoiceheight
QS:Samelistheight
QS:Scale export
QS:Show comment
QS:Show grand total
QS:Show title
QS:Show totals
QS:Showpopups
QS:Slider accuracy
QS:Slider default
QS:Slider handle shape
QS:Slider handle Unicode shape
QS:Slider initial value
QS:Slider layout
QS:Slider max
QS:Slider middlestart
QS:Slider min
QS:Slider orientation
QS:Slider rating
QS:Slider reset
QS:Slider reverse
QS:Slider separator
QS:Slider showminmax
QS:Subquestion width
QS:Suffix
QS:Text input width
QS:Theme editor - advanced options
QS:Time limit
QS:Time limit action
QS:Time limit countdown message
QS:Time limit disable next
QS:Time limit disable prev
QS:Time limit message
QS:Time limit message delay
QS:Time limit message style
QS:Time limit timer style
QS:Time limit warning
QS:Time limit warning display time
QS:Time limit warning message
QS:Time limit warning style
QS:Use dropdown
QS:Value range allows missing
Question groups - introduction
Question toolbar options
Question type - 5 point choice
Question type - Array
Question type - Array (10 point choice)
Question type - Array (5 point choice)
Question type - Array (Increase-Same-Decrease)
Question type - Array (Numbers)
Question type - Array (Texts)
Question type - Array (Yes-No-Uncertain)
Question type - Array by column
Question type - Array dual scale
Question type - Date
Question type - Equation
Question type - File upload
Question type - Gender
Question type - Huge free text
Question type - Language switch
Question type - List (Dropdown)
Question type - List (Radio)
Question type - List with comment
Question type - Long free text
Question type - Multiple choice
Question type - Multiple choice with comments
Question type - Multiple numerical input
Question type - Multiple short text
Question type - Numerical input
Question type - Ranking
Question type - Short free text
Question type - Text display
Question type - Yes-No
Question types
Questions - introduction
QueXML PDF Export
Quick start guide - LimeSurvey 2.50+
Quick start guide - LimeSurvey 3.0+
Quick-translation
Regenerate question codes
Reorder questions and question groups
Reset conditions
Resources
Responses & statistics
Responses (survey results)
Running a survey safely
Setting conditions
SGQA identifier
Statistics
Survey group permissions
Survey menu
Survey participants
Survey permissions
Survey quotas
Survey settings
Survey settings version 2
Survey structure
Survey toolbar options
Surveys - introduction
Surveys - management
Tab Separated Value survey structure
Template:Deprecated
Template:DeprecatedIn
Template:Example
Template:FeatureChange
Template:FeatureStarting
Template:Hint
Template:NewIn
Template:UpdatedIn
Testing a survey
Text elements
Theme editor
Theme options
Themes
Timing statistics
Tools
Transferring an installation
Translating LimeSurvey
Troubleshooting
TwoFactorAdminLogin
Upgrading from a previous version
URL fields
Using regular expressions
Version change log
Version guide
View saved but not submitted responses
Workarounds
Language
aa - Afar
aae - Arbëresh
ab - Abkhazian
abs - Ambonese Malay
ace - Achinese
acm - Iraqi Arabic
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
ann - Obolo
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
ban-bali - Balinese (Balinese script)
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bci - Baoulé
bcl - Central Bikol
bdr - West Coast Bajau
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bew - Betawi
bg - Bulgarian
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
blk - Pa'O
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Iriga Bicolano
bug - Buginese
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
cdo - Mindong
ce - Chechen
ceb - Cebuano
ch - Chamorro
chn - Chinook Jargon
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cpx - Pu–Xian Min
cpx-hans - Pu–Xian Min (Simplified Han script)
cpx-hant - Pu–Xian Min (Traditional Han script)
cpx-latn - Pu–Xian Min (Latin script)
cr - Cree
crh - Crimean Tatar
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
crh-ro - Dobrujan Tatar
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
dag - Dagbani
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
dga - Dagaare
din - Dinka
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dv - Divehi
dz - Dzongkha
ee - Ewe
efi - Efik
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - Spanish (formal address)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
fat - Fanti
ff - Fula
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fon - Fon
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gaa - Ga
gag - Gagauz
gan - Gan
gan-hans - Gan (Simplified Han script)
gan-hant - Gan (Traditional Han script)
gcf - Guadeloupean Creole
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
gld - Nanai
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
gpe - Ghanaian Pidgin
grc - Ancient Greek
gsw - Alemannic
gu - Gujarati
guc - Wayuu
gur - Frafra
guw - Gun
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
hno - Northern Hindko
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
hsn - Xiang
ht - Haitian Creole
hu - Hungarian
hu-formal - Hungarian (formal address)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
ibb - Ibibio
id - Indonesian
ie - Interlingue
ig - Igbo
igl - Igala
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kai - Karekare
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kcg - Tyap
kea - Kabuverdianu
kg - Kongo
kge - Komering
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjh - Khakas
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ksw - S'gaw Karen
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kus - Kʋsaal
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mad - Madurese
mag - Magahi
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Māori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mnc - Manchu
mnc-latn - Manchu (Latin script)
mnc-mong - Manchu (Mongolian script)
mni - Manipuri
mnw - Mon
mo - Moldovan
mos - Mossi
mr - Marathi
mrh - Mara
mrj - Western Mari
ms - Malay
ms-arab - Malay (Jawi script)
mt - Maltese
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Minnan
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
nia - Nias
nit - కొలామి
niu - Niuean
nl - Dutch
nl-informal - Dutch (informal address)
nmz - Nawdm
nn - Norwegian Nynorsk
no - Norwegian
nod - Northern Thai
nog - Nogai
nov - Novial
nqo - N’Ko
nrm - Norman
nso - Northern Sotho
nv - Navajo
ny - Nyanja
nyn - Nyankole
nyo - Nyoro
nys - Nyungar
oc - Occitan
ojb - Northwestern Ojibwa
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pcm - Nigerian Pidgin
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
pwn - Paiwan
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rki - Arakanese
rm - Romansh
rmc - Carpathian Romani
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
rsk - Pannonian Rusyn
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rut - Rutul
rw - Kinyarwanda
ryu - Okinawan
sa - Sanskrit
sah - Yakut
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
se-fi - Northern Sami (Finland)
se-no - Northern Sami (Norway)
se-se - Northern Sami (Sweden)
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
sh-cyrl - Serbo-Croatian (Cyrillic script)
sh-latn - Serbo-Croatian (Latin script)
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy - Shawiya
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sjd - Kildin Sami
sje - Pite Sami
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sms - Skolt Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
sro - Campidanese Sardinian
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - Siberian Tatar
su - Sundanese
sv - Swedish
sw - Swahili
syl - Sylheti
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Tayal
tcy - Tulu
tdd - Tai Nuea
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tly-cyrl - Talysh (Cyrillic script)
tn - Tswana
to - Tongan
tok - Toki Pona
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
ttj - Tooro
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vmw - Makhuwa
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
wal - Wolaytta
war - Waray
wls - Wallisian
wo - Wolof
wuu - Wu
wuu-hans - Wu (Simplified Han script)
wuu-hant - Wu (Traditional Han script)
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yrl - Nheengatu
yue - Cantonese
yue-hans - Cantonese (Simplified Han script)
yue-hant - Cantonese (Traditional Han script)
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
Format
Export for off-line translation
Export in native format
Export in CSV format
Fetch
<languages /> == Overview == Starting from LimeSurvey 2.05, LimeSurvey will officially support plugins. Some plugins will be supported by the LimeSurvey team and will go into core. Some will be supported by others outside the LimeSurvey team. To help find them, check out the [[Available third party plugins]] and add your own plugin to it! Plugins allow users to customize the functionality of their installation while still being able to benefit from regular software updates. This documentation is meant for developers that are extending LimeSurvey for their own use or for their clients; end users will not be helped by this documentation. Plugins must implement the [https://github.com/LimeSurvey/LimeSurvey/blob/master/application/libraries/PluginManager/iPlugin.php iPlugin] interface. We recommend extending your plugin class from the [https://github.com/LimeSurvey/LimeSurvey/blob/master/application/libraries/PluginManager/PluginBase.php PluginBase] class. Plugins are developed around an [http://manual.limesurvey.org/Plugin_events event] mechanism. == Plugin settings == By extending you benefit from common functionality required by plugins that we already have implemented for you. One of these function is the implementation of the getPluginSettings function. This function must return an array describing the configuration options for the user. The example plugin exposes just 1 configurable setting, the message it'll show. <syntaxhighlight lang="php"> protected $settings = array( 'logo' => array( 'type' => 'logo', 'path' => 'assets/logo.png' ), 'message' => array( 'type' => 'string', 'label' => 'Message' ) ); </syntaxhighlight> The array contains a name for each setting as a key. The values are arrays containing the required meta data. Supported types are: * logo * int (integer number) * string (alphanumeric) * text * html * relevance * info * password * date * select Besides type a number of other keys are available: * label, defines a label * default, defines a value to show if no value is specified (only for global settings, not for survey settings) * current, defines the current value. * readOnly : shown the settings as readonly * htmlOptions, the htmlOptions of the input part ( see Yii manual [[https://www.yiiframework.com/doc/api/1.1/CHtml]]) * pluginOptions, for some settings (html or select) : set the widget option * labelOptions : htmlOptions of the label * controlOptions : htmlOptions of the wrapper of label and input You can find a plugin example using all actual settings at [https://gitlab.com/SondagesPro/SampleAndDemo/exampleSettings exampleSettings] === Read and write plugin settings === It's possible to read and write plugin settings directly from your plugin code. Example: <syntaxhighlight lang="php"> $mySetting = $this->get('mySetting'); $this->set('mySetting', $mySetting + 1); </syntaxhighlight> You can get a default value if the setting happens to be null: <syntaxhighlight lang="php"> $mySetting = $this->get('mySetting', null, null, 10); // 10 is default </syntaxhighlight> === Survey specific plugin settings === Two events are used to create survey specific plugin settings: * newSurveySettings * beforeSurveySettings Example to disable a plugin for a specific survey: <syntaxhighlight lang="php"> public function init() { $this->subscribe('beforeSurveySettings'); $this->subscribe('newSurveySettings'); // Other events... } public function beforeSurveySettings() { $event = $this->event; $surveyId = intval($event->get('survey')); $event->set( "surveysettings.{$this->id}", [ 'name' => get_class($this), 'settings' => [ 'isActive' => [ 'type' => 'boolean', 'label' => 'isActive', 'current' => $this->getIsActive($surveyId), 'help' => 'Activate plugin for this survey' ], ] ] ); } public function newSurveySettings() { $event = $this->event; foreach ($event->get('settings') as $name => $value) { $this->set($name, $value, 'Survey', $event->get('survey'), false); } } private function getIsActive(int $sid): bool { return (bool) $this->get('isActive', 'Survey', $sid, false); } </syntaxhighlight> == Events == Plugins subscribe to events and can interact with LimeSurvey when the event is fired. For a list of currently available events check [[Plugin events]]. == API == Plugins should only extend LimeSurvey via its "public" API. This means that directly using classes found in the source code is a bad practice. Though we can't force you not to, you risk having a broken plugin with every minor update we do. As much as possible interact with LimeSurvey only via methods described [http://api.limesurvey.org/classes/LimeSurvey.PluginManager.LimesurveyApi.html here]. Same as for events. The API object is available via <code>$this->api</code> when extending from PluginBase, otherwise you can get it from the PluginManager instance that is passed to your plugins' constructor. New functions can be added to the API object upon request. == Form extension{{NewIn|v=6}} == === Introduction === The form extension system is a more general way to extend forms in core LimeSurvey without adding a new event for each form. It consists of the following components: * A global module called '''FormExtensionService''' * A library of '''input classes''' that plugins can add to above module initialization * A '''widget''', together with custom renderers, that are used in the LimeSurvey view files Each form is identified by a '''position string''', like <form name><dot><tab name>. Example: <code>globalsettings.general</code> or <code>globalsettings.security</code>. The point behind a class-based system without HTML is to free the plugin authors of the work to update the HTML when the core HTML changes. Still, the author can use the <code>RawHtmlInput</code> type if needed. One thing you cannot do in this system is to add ''new form tabs''. === Example === To add a new input to a form from a plugin, use the following code from your <code>init()</code> function: TODO: Save in plugin settings instead of global <syntaxhighlight lang="php"> // At top of file use LimeSurvey\Libraries\FormExtension\Inputs\TextInput; use LimeSurvey\Libraries\FormExtension\SaveFailedException; // Inside init() Yii::app()->formExtensionService->add( 'globalsettings.general', new TextInput([ 'name' => 'myinput', 'label' => 'Label', 'disabled' => true, 'tooltip' => 'Moo moo moo', 'help' => 'Some help text', 'save' => function($request, $connection) { $value = $request->getPost('myinput'); if ($value === 'some invalid value') { throw new SaveFailedException("Could not save custom input 'myinput'"); } else { SettingGlobal::setSetting('myinput', $value); } }, 'load' => function () { return getGlobalSetting('myinput'); } ]) ); </syntaxhighlight> === Validation === Validation of the input is done in the <code>save</code> function (see example above). If the posted value is invalid, throw a <code>SaveFailedException</code>, and a warning flash message will be shown to the user. === Supported forms === The following forms can be extended: * globalsettings.general{{NewIn|v=6.0.0}} If you want to add support for another core form, you need to apply the following change in a pull-request: In the view file, add: <syntaxhighlight lang="php"> <?php use LimeSurvey\Libraries\FormExtension\FormExtensionWidget; use LimeSurvey\Libraries\FormExtension\Inputs\DefaultBaseRenderer; ?> ... more HTML <?= FormExtensionWidget::render( App()->formExtensionService->getAll('globalsettings.security'), new DefaultBaseRenderer() ); ?> </syntaxhighlight> You might have to create a new renderer class based on <code>DefaultBaseRenderer</code>, if the form HTML is different than other forms. You might also need to extend the default renderer class with input types not yet added. The second change you have to do is add a call to the form extension service class in the controller action that saves the form: <syntaxhighlight lang="php"> $request = App()->request; Yii::app()->formExtensionService->applySave('globalsettings', $request); </syntaxhighlight> That's it! == Localization {{NewIn|v=3}} == It's possible for plugins to add their own locale files. File format used is .mo, same as core translations. The files must be stored in <plugin root folder>/locale/<language>/<language>.mo where "<language>" is a two letter word like "de" or "fr". To use the specific locale file, use the plugin function gT: <syntaxhighlight lang="php"> $this->gT("A plugin text that needs to be translated"); </syntaxhighlight> If the given string can't be found in the plugin specific locale file, the function will look in the core locale files. So it's safe to use strings like "Cancel": <syntaxhighlight lang="php"> $this->gT("Cancel"); // Will be translated even if "Cancel" is not in the plugin locale file </syntaxhighlight> If you are using views together with your plugin, you should use <syntaxhighlight lang="php"> $plugin->gT("Translate me"); </syntaxhighlight> to do plugin specific translation in your view. You can use the [https://github.com/LimeSurvey/LimeSurvey/blob/master/locale/_template/limesurvey.pot limesurvey.pot] file as an example of how a pot file can look like. This is imported into your translation tool. === Tools === One open-source tool to edit po- and mo-files is [https://poedit.net/ Poedit]. == Logging {{NewIn|v=3}} == If you want to log something from your plugin, just write <syntaxhighlight lang="php"> $this->log("Your message"); </syntaxhighlight> The default logging level is trace, but you can give another log level as an optional second argument: <syntaxhighlight lang="php"> $this->log("Something went wrong!", CLogger::LEVEL_ERROR); </syntaxhighlight> The log file can be found in folder <limesurvey root folder>/tmp/runtime/plugin.log Your plugin name is automatically used as category. A nice way to see only the errors from your plugin is using grep (on Linux): $ tail -f tmp/runtime/plugin.log | grep <your plugin name> More info about configuring logging in Yii 1: [[Optional_settings#Logging_settings]]. == Extension updates {{NewIn|v=4}} == Since LimeSurvey version 4.0.0, there's a system in place to deal with plugin and other extension updates. To use this system, your extension config.xml file needs to include updater configuration. <syntaxhighlight lang="xml"> <updaters> <updater> <stable>1</stable> <type>rest</type> <source>https://comfortupdate.limesurvey.org/index.php?r=limestorerest</source> <manualUpdateUrl>https://somedownloadlink.com/maybegithub</manualUpdateUrl> </updater> </updaters> </syntaxhighlight> (The source tag above points to the LimeStore REST API, which will be used for all extensions available in our LimeStore.) {| class="wikitable" |+ Updater tag descriptions |- ! Tag ! Description |- | stable | "1" if this source only gives you stable version numbers; "0" if the source will also provide unstable versions, like <code>0.3.3-beta</code>. |- | type | For now, only type <code>rest</code> is supported. It's easy to add new updater types (version checkers), like git, wget, etc. |- | source | The URL to fetch new versions from. |- | manualUpdateUrl | URL which the user can go to to update the latest version of the extension. |- | automaticUpdateUrl | TODO |} If you don't want to supply an updater, you should put the following text in your config XML file: <syntaxhighlight lang="xml"> <updaters disabled="disabled"> </updaters> </syntaxhighlight> This way, you tell the system that you purposefully disabled the update system, and didn't just forget to add it. The new plugin '''UpdateCheck''' - installed and activated by default - checks for new updates for ''all'' installed extensions when a super admin logs in, asynchronously, max one time every 24 hours. If any new versions are found, a notification is pushed. [[File:availableupdates.png||Available updates]] If a new security update is found, the notification will open automatically and be styled in "danger" class. [[File:availablesecurityupdates.png||Available security updates]] You can manually check for updates by going to the plugin manager view and click on "Check updates". Note that this button is only visible if the UpdateCheck plugin is activated. [[File:manuallycheckforupdates.png||Manually check for updates]] === Under the hood === This section provides a brief overview over the extension updater implementation. The extension updater is part of the ExtensionInstaller library. Below is a UML diagram for the classes related to the updater process. [[File:extensionupdateruml.png||Extension updater UML diagram]] Program flow when Yii starts: <pre> Yii init VersionFetcherServiceLocator->init() Add REST version fetcher ExtensionUpdaterServiceLocator->init() Add PluginUpdater TODO: Add an updater for each extension type (theme, question template, ...) </pre> Program flow when running the UpdaterCheck plugin: <pre> Get all updaters from ExtensionUpdaterServiceLocator Loop each updater For each updater, loop through version fetchers configured by <updater> XML For each version fetcher, contact remote source and get version information Compose all versions into a notification </pre> The [https://github.com/LimeSurvey/LimeSurvey/blob/develop/application/core/plugins/UpdateCheck/UpdateCheck.php#L130 checkAll] method in the UpdateCheck plugin provides an example of how to query all extensions for new versions. ==== Adding new version fetchers ==== To add a new custom version fetcher, run this during Yii initialization: <syntaxhighlight lang="php"> $service = \Yii::app()->versionFetcherServiceLocator $service->addVersionFetcherType( 'myNewVersionFetcherType', function (\SimpleXMLElement $updaterXml) { return new MyNewVersionFetcher($updaterXml); } ); </syntaxhighlight> Of course, the class <code>MyNewVersionFetcher</code> has to subclass <code>VersionFetcher</code>. To use your new version fetcher, configure the <code>type</code> tag in the updater XML to use <code>myNewVersionFetcherType</code> (instead of e.g. <code>rest</code>). ==== Adding new extension updaters ==== To add a new custom extension updater, run this during Yii initialization: <syntaxhighlight lang="php"> $service = \Yii::app()->extensionUpdaterServiceLocator; $service->addUpdaterType( 'myNewExtensionUpdater', function () { return MyNewExtensionUpdater::createUpdaters(); } ); </syntaxhighlight> Class <code>MyNewExtensionUpdater</code> has to subclass <code>ExtensionUpdater</code>. The top <code>type</code> tag in config.xml ('plugin', 'theme', ...) will control which extension updater are used for this extension. The system is not fully customizable yet, since you also need to add a custom ExtensionInstaller, menu items, etc. But in theory, and maybe in the future, it should be possible to add a new type of extension this way. == Extension installer == The extension installer library consists of two abstract classes: * ExtensionInstaller * FileFetcher The ExtensionInstaller is subclassed for each extension type, like PluginInstaller, QuestionThemeInstaller, etc. The FileFetcher is subclassed for each different way to fetch files. Currently, only uploaded zip files are supported, but in the future, there could be a Github or LimeStore fetcher too. [[File: extensioninstalleruml.png]] == Special plugins == * [[Authentication plugin development]] * [[Export plugin development]] == Available plugins == * [[Authentication plugins]] * [[Audit log]] * [[AzureOAuthSMTP Plugin]] * [[CintLink]] * [[Available third party plugins]] == Tutorial == [https://medium.com/@evently/creating-limesurvey-plugins-adcdf8d7e334 This] step-by-step tutorial shows how to create a plugin that sends a post request on every survey response submission. The tutorial shows you how to create and save global and per-survey settings, how to register events and more. [[Category:Development]] [[Category:Plugins]]