Extending EM with own function

More
3 years 2 days ago - 3 years 2 days ago #110399 by orvil
orvil created the topic: Extending EM with own function
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=http://http://manual.limesurvey.org/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
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
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: 3 years 2 days ago by orvil.

Please Log in to join the conversation.

More
3 years 1 day ago #110419 by DenisChenu
DenisChenu replied the topic: Extending EM with own function
em_core_helper.php
$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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: orvil

Please Log in to join the conversation.

More
3 years 1 day ago #110421 by orvil
orvil replied the 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

Please Log in to join the conversation.

More
3 years 1 day ago #110430 by DenisChenu
DenisChenu replied the 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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
3 years 1 hour ago #110453 by orvil
orvil replied the 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

Please Log in to join the conversation.

More
2 years 11 months ago #110461 by DenisChenu
DenisChenu replied the 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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 11 months ago #110516 by orvil
orvil replied the 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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now