Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Extending EM with own function

  • orvil
  • orvil's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 4 months ago - 10 years 4 months ago #110399 by orvil
Extending EM with own function was created by orvil
Hi all,

I'd like to extend the EM by some own funtions for csv-strings (like '1;01.01.2015;Hello World'). Found some info at [url=https://https://www.limesurvey.org/manual/Expression_Manager_for_developers]Expression Manager for developers[/url]

It's working fine with the php part of the code (em_core_helper.php). So an added function like
Code:
csvgetdata(separator, datastring, item)
works fine and gives back what is expected (eg by calling csvgetdata(';', '1;01.01.2015;Hello World', 3) it gives back 'Hello World' :)

Now my annoying :woohoo: problem:
Obviously for relevance equations the javascript part of the code is required (is this correct?)

I tried to add functions at em_javascript.js, but nothing happens. Even the simple function
Code:
function testme()
{
  return 1;
}

does not work for the relevance equation. Is there anything to add at other files? The description at 'Expression Manager for Developers' does not mention anythig about this.

Hope there is someone for help.
Thanks in advance

Best regards/Beste Grüße,
O. Villani
Last edit: 10 years 4 months ago by orvil.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
10 years 4 months ago #110419 by DenisChenu
Replied by DenisChenu on topic Extending EM with own function
em_core_helper.php
Code:
$this->RDP_ValidFunctions = array(
......
'emFunctionName' => array('phpFunction', 'jsFunction', gT('Some explanation'), 'another explanatuion', 'a link', $numberOfArg}

And try with return 'test' maybe.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: orvil
The topic has been locked.
  • orvil
  • orvil's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 4 months ago #110421 by orvil
Replied by orvil on topic Extending EM with own function
Hi Denis,

thanks, of course I did this already - but with no effect. I had a look at Firebug, I think it's maybe a cache problem. Yesterday it did not work even with emptying the cache, today its working. But I'm not shure about the behaviour.

Is there some information to find when and where either the php or the js part of EM code ist used?

THX

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
10 years 4 months ago #110430 by DenisChenu
Replied by DenisChenu on topic Extending EM with own function
EM code (and file ) is really hard to debug and understand.

But the last time i add a function, i do like this witout problem.

Maybe a js issue ?
May a php issue

Don't know.

To debug limesurvey, you can use tracevar function (and look at your console.log)

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • orvil
  • orvil's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 4 months ago #110453 by orvil
Replied by orvil on topic Extending EM with own function
It was indeed a cache problem. I don't know why an how, but after restarting things are working fine :)

Thanks for the debug tip!

btw: is there a way to make own EM-functions update-save or/and to share them?

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
10 years 4 months ago #110461 by DenisChenu
Replied by DenisChenu on topic Extending EM with own function
Hi,

Not actually, but i'm sure a future release have EM function in Plugin.

You can work on this project if needed, maybe put a Feature Request for this.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
  • orvil
  • orvil's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 4 months ago #110516 by orvil
Replied by orvil on topic Extending EM with own function
Yes, good idea. Unfortunately I cannot do it by myself at the moment, no free time for that and the new organize view for 2.06 is still open on my shedule :(
But I'd like to share the csv functions then. Found some other post where this could be a solution.

Best regards/Beste Grüße,
O. Villani
The topic has been locked.
Moderators: holchtpartner

Lime-years ahead

Online-surveys for every purse and purpose