Check out the LimeSurvey source code on GitHub!

Extending EM with own function

More
2 years 7 months ago - 2 years 7 months ago #110399 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=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: 2 years 7 months ago by orvil.

Please Log in to join the conversation.

More
2 years 7 months ago #110419 by DenisChenu
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).
The following user(s) said Thank You: orvil

Please Log in to join the conversation.

More
2 years 7 months ago #110421 by orvil
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
2 years 7 months ago #110430 by DenisChenu
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).

Please Log in to join the conversation.

More
2 years 7 months ago #110453 by orvil
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 7 months ago #110461 by DenisChenu
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).

Please Log in to join the conversation.

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

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form