Welcome, Guest
Username: Password: Remember me

TOPIC: Extending EM with own function

Extending EM with own function 5 months 11 hours ago #110399

  • orvil
  • orvil's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 104
  • Thank you received: 4
  • Karma: 4
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: 5 months 11 hours ago by orvil.
The administrator has disabled public write access.

Extending EM with own function 4 months 4 weeks ago #110419

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 869
  • Karma: 257
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.
The administrator has disabled public write access.
The following user(s) said Thank You: orvil

Extending EM with own function 4 months 4 weeks ago #110421

  • orvil
  • orvil's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 104
  • Thank you received: 4
  • Karma: 4
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 administrator has disabled public write access.

Extending EM with own function 4 months 4 weeks ago #110430

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 869
  • Karma: 257
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
The administrator has disabled public write access.

Extending EM with own function 4 months 4 weeks ago #110453

  • orvil
  • orvil's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 104
  • Thank you received: 4
  • Karma: 4
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 administrator has disabled public write access.

Extending EM with own function 4 months 4 weeks ago #110461

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 869
  • Karma: 257
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
The administrator has disabled public write access.

Extending EM with own function 4 months 3 weeks ago #110516

  • orvil
  • orvil's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 104
  • Thank you received: 4
  • Karma: 4
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 administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.256 seconds
Donation Image