Dependency Graph

Dependency Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

This bug affects 1 person(s).
 14
IDProjectCategoryView StatusLast Update
13513Feature requestsExpression Managerpublic2021-03-07 21:55
Reporterorvil Assigned ToDenisChenu  
PrioritynoneSeverityfeature 
Status closedResolutionfixed 
Summary13513: Update save way to add custom made EM functions
Description

Additional EM functions are very helpful to adapt questionaires on specific needs, to shorten surveys and/or replace complicated EM expressions with shorter ones.

But with (almost) every update an adapted em_core_helper.php and em_javascript.js is replaced with the default one.

Solution would be an update save way to add custom made em functions, e.g. like a plugin.

TagsNo tags attached.
Bug heat14
Story point estimate
Users affected %

Relationships

has duplicate 14130 closedDenisChenu Allow to expose PHP functions to Expression Manager via config or GUI. 

Activities

jelo

jelo

2018-03-21 21:54

partner   ~47167

Why not open it up via a include file which can be edited via settings.
I would like to see a easy way to get more php functions exposed to EM.
The LOC needed to expose a new php function into EM seem to be not that huge.

You already proposed the plugin idea over two years ago.
https://www.limesurvey.org/forum/development/100938-extending-em_core_helper-php

To me ExpressionManager seems to be a big blackhole which nobody likes to really touch.
Rock–paper–scissors might help finding the right developer to refactor it ;-)
The very old wishlist is still here:
https://manual.limesurvey.org/Project_Ideas_for_GSoC_2012#Enhance_Expression_Manager

orvil

orvil

2018-03-22 09:37

reporter   ~47171

You are right, did this already (2Y7M ago), forgot it meanwhile :o

Anyhow it is not that hard to write new functions for the EM and some features requested in the wishlist you mentioned are avaliable meanwhile.

My idea to realize an EM extender like a plugin is based on the possibility to share plugins with the community.

Unfortunately plugins and plugin how-to's are
a) not very well documented at the moment and
b) the interface on the website to share them seems to be a little abandoned - at least compared to e.g. the R community ( https://cran.r-project.org/ > see Packages) or some CMS I'm working with.

Although this would be a real booster for LS!

DenisChenu

DenisChenu

2018-03-22 10:53

developer   ~47176

Last edited: 2018-03-22 10:53

Expression Manager NEED to be extendable :).

  1. New EM->knowVars (and way to set it)
  2. New function
  3. Add specific Expression (like currently ranking default/min value etc …)

:)

It's a +1000 for this Feature

orvil

orvil

2018-05-20 21:24

reporter   ~47696

Finally found a way to implement this!

Working with php and js, so usable in question.by-question, group-by-group and all-in-one mode of showing a survey.
See http://www.sdi-research.co.at/dev/iSurvey300/index.php/548491?newtest=Y&lang=en for a running example

created pull requests for em_core_helper.php (~30 lines of code), and sample extensions files (php, js)
https://github.com/LimeSurvey/LimeSurvey/pull/1077/commits/941b655accb2e7e05109da98830fb36d240edb85
https://github.com/LimeSurvey/LimeSurvey/pull/1077/commits/c03aa8de82b142388ae65d5cd6b73b938458953f
https://github.com/LimeSurvey/LimeSurvey/pull/1077/commits/a0c0f8b1198bf99e55f44fc6d4887dd0671be2e1

DenisChenu

DenisChenu

2018-05-21 09:18

developer   ~47697

Yep : EM function a php function (existing or not) + a js function (existing or not).

But , i think we need to move all of this to an helper or model to more easily managed after, and maybe add some caching (because test/read file is time consuming).

I think @olle like if we have "one function => one directory", and maybe he a 'config' … file

Personnaly, i had it with event if i do it. But think LS GMBH don't like event.

@orvil : you don't have limesurvey-team irc access ?

orvil

orvil

2018-05-21 10:40

reporter   ~47698

@DenisChenu: as someone wrote once the LEM is genius, but a big black hole, hard to understand and to maintain.
So on the long run I agree: the functionality should be moved modular into the MVC concept (as eg. questions too ;) But: why not combine this step with migration to yii2 ?

Think this will take quite some time (1-2 years probably?). So the proposed solution is an interim way, but I think all created additional functions can be migrated to a new solution then easily.

By the way: the folders and folder structure i choose for implementation is a suggestion => an other structure and folder naming is possible too, to pre-fit a modular concept

Finally, no, I'm sorry I don't have a limesurvey-team irc access.

ollehar

ollehar

2018-05-22 10:28

administrator   ~47702

Can this be done easily with a new event?

DenisChenu

DenisChenu

2018-05-30 10:29

developer   ~47906

@olle : it's what i think adding a new event, plugin can add function to EM

orvil

orvil

2018-05-30 10:50

reporter   ~47907

@DenisChenu: Hi, do you have some some progress with the em extension/plugin already?
If not, i will have some time this weekend to dig into (hopefilly) Or maybe there is a way to develop this together?
Found some questions in the forum with typical need of an EM solution (e.g. how to generate a list of non repeating random variables)

ollehar

ollehar

2018-05-30 10:57

administrator   ~47909

OK, well, if anyone makes a PR we can merge it.

orvil

orvil

2018-05-30 10:58

reporter   ~47910

As you suggested the em plugin requires three++ steps to take:

  1. to add an event handler into the em helper file
  2. to create a pattern for 2 files with additional php / js functions
  3. the plugin
    ...
    testing, cursing, testing again, cursing again,... ;)
orvil

orvil

2018-05-30 11:00

reporter   ~47911

@olle: sorry I'm a noop: what's meant by PR?

ollehar

ollehar

2018-05-30 11:20

administrator   ~47912

PR = pull request (on github).

orvil

orvil

2018-05-30 13:05

reporter   ~47918

oh, that easy :)))

DenisChenu

DenisChenu

2018-05-30 17:36

developer   ~47928

https://github.com/LimeSurvey/LimeSurvey/pull/1081

DenisChenu

DenisChenu

2018-05-31 11:05

developer   ~47930

I have some issue with travis, i think it's because i made the pull request on a old version.

I redo it , but same principle done

ollehar

ollehar

2018-05-31 11:23

administrator   ~47931

Develop Travis is broken right now. Master should work.

DenisChenu

DenisChenu

2018-06-01 08:17

developer   ~47937

No, i have an issue on my commit, i fix it today :)

DenisChenu

DenisChenu

2018-10-10 17:49

developer   ~49297

Fix committed to master_13513 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=28297

DenisChenu

DenisChenu

2018-10-16 17:07

developer   ~49340

Fix committed to develop branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=28345

Related Changesets

LimeSurvey: master_13513 2a6f8fd5

2018-05-30 17:35:01

DenisChenu

Details Diff
New feature 13513 : allow plugins to add expresssion manager function Affected Issues
13513
mod - application/controllers/admin/expressions.php Diff File
mod - application/helpers/expressions/em_core_helper.php Diff File
mod - application/helpers/expressions/em_manager_helper.php Diff File
add - plugins/Demo/demoAddEmFunction/assets/demoAddEmFunction.js Diff File
add - plugins/Demo/demoAddEmFunction/demoAddEmFunction.php Diff File
add - plugins/Demo/demoAddEmFunction/exampleFunctions.php Diff File

LimeSurvey: develop 2a7490b5

2018-10-16 17:06:56

DenisChenu


Committer: GitHub Details Diff
New feature 13513 : allow plugins to add expresssion manager function (#1081)

Dev: fix call_user_func_array not call_user_func
Dev: fixed issue with any number of arguments function
Dev: PHP function receive a big array with argument : call_user_function
Dev: add doHtmlList in example
Dev: rename event to ExpressionManagerStart : this is the real event
Dev: idea to add too a way to update knowVars of EM
Dev: add config.xml for plugin
Dev: fix js not loaded (strangely : Em is not initialized)
Dev: register expression-extend just after done
Dev: add sayHello function
Affected Issues
13513
mod - application/config/packages.php Diff File
mod - application/controllers/admin/expressions.php Diff File
mod - application/helpers/expressions/em_core_helper.php Diff File
mod - application/helpers/expressions/em_manager_helper.php Diff File
add - plugins/Demo/demoAddEmFunction/assets/demoAddEmFunction.js Diff File
add - plugins/Demo/demoAddEmFunction/config.xml Diff File
add - plugins/Demo/demoAddEmFunction/demo/limesurvey_survey_demo.lss Diff File
add - plugins/Demo/demoAddEmFunction/demoAddEmFunction.php Diff File
add - plugins/Demo/demoAddEmFunction/exampleFunctions.php Diff File

Issue History

Date Modified Username Field Change
2018-03-21 17:42 orvil New Issue
2018-03-21 18:43 c_schmitz Project Bug reports => Feature requests
2018-03-21 21:54 jelo Note Added: 47167
2018-03-22 09:37 orvil Note Added: 47171
2018-03-22 10:53 DenisChenu Note Added: 47176
2018-03-22 10:53 DenisChenu Note Edited: 47176
2018-05-20 21:24 orvil Note Added: 47696
2018-05-21 09:18 DenisChenu Note Added: 47697
2018-05-21 10:40 orvil Note Added: 47698
2018-05-22 10:28 ollehar Note Added: 47702
2018-05-30 10:29 DenisChenu Note Added: 47906
2018-05-30 10:50 orvil Note Added: 47907
2018-05-30 10:57 ollehar Note Added: 47909
2018-05-30 10:58 orvil Note Added: 47910
2018-05-30 11:00 orvil Note Added: 47911
2018-05-30 11:20 ollehar Note Added: 47912
2018-05-30 13:05 orvil Note Added: 47918
2018-05-30 17:36 DenisChenu Note Added: 47928
2018-05-31 11:05 DenisChenu Note Added: 47930
2018-05-31 11:23 ollehar Note Added: 47931
2018-06-01 08:17 DenisChenu Note Added: 47937
2018-10-06 10:38 DenisChenu Relationship added has duplicate 14130
2018-10-10 17:49 DenisChenu Changeset attached => LimeSurvey master_13513 2a6f8fd5
2018-10-10 17:49 DenisChenu Note Added: 49297
2018-10-10 17:49 DenisChenu Assigned To => DenisChenu
2018-10-10 17:49 DenisChenu Resolution open => fixed
2018-10-16 17:07 DenisChenu Changeset attached => LimeSurvey develop 2a7490b5
2018-10-16 17:07 DenisChenu Note Added: 49340
2018-10-16 17:23 DenisChenu Status new => resolved
2018-10-16 17:23 DenisChenu Fixed in Version => develop
2021-03-07 21:55 c_schmitz Status resolved => closed