Welcome, Guest
Username: Password: Remember me

TOPIC: Expression Manager: Get taliored version of asked question

Expression Manager: Get taliored version of asked question 2 years 7 months ago #72280

  • Steve
  • Steve's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 494
  • Thank you received: 46
  • Karma: 17
Hello,

I continued to play a little with the ExpressionManager. I tried to make a summary question (type: Text display) that shows the asked questions and answers given by the participant. So nothing special.

But I had some micro tailoring in my questions. For example
{if(!is_empty(name),implode(' ', ', ', name),'' )}
. When I use "Qcode.question" I only get let's say the source code of the question, e.g.
So how old are you {if(!is_empty(name),implode(' ', ', ', name),'' )}?
instead of
So how old are you MrX?

So I think it would be nice to get the question in the final tailord version. Is this possible in the current version (LimeSurvey 1.92RC2 Build 12099)?

Attachted sample survey to this post:

File Attachment:

File Name: limesurvey_survey_61131.lss
File Size: 30 KB
Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team
The administrator has disabled public write access.

Re: Expression Manager: Get taliored version of asked question 2 years 7 months ago #72282

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
vierundzwanzig-

Thanks for continuing to test the system.

The short answer is yes and no.

If you look at the raw, HTML, you'll see that it has "So how old are you MrX?". However, when the page loads, it calls ExprMgr_process_relevance_and_tailoring(), which over-writes that value with qcode.question.

The reason ExprMgr_process_relevance_and_tailoring() is called on page load is that there are still some places that EM isn't fully integrated into LS, so without it, all array_filter rows are visible. Once we modify all of the question types so that they check the sub-question-relevance status prior to generating the page, then we should be able to remove the call to ExprMgr_process_relevance_and_tailoring(). The upshot being that if you have report on a page and no other data entry fields, the report will start correct, and won't change (as it would if the user changed a value and ExprMgr_process_relevance_and_tailoring() were called).

Another option is to add a function to EM to generate fairly generic tables of reports. I had one in a prior software which let me specify the columns, column-headers, column-styles, and variables. It then generated a table meeting those criteria.

Another option is to try to find some way to let JavaScript to cascading substitutions. The core problem is that I wasn't able to get .innerHTML working properly with nested <span> segments.

Another option would be to force certain questions not to be dynamically changed. So, the PHP generation would be static and any on-screen changes would be ignored.

Any ideas you have would be most welcome.

-Tom
The administrator has disabled public write access.

Re: Expression Manager: Get taliored version of asked question 2 years 7 months ago #72319

  • Steve
  • Steve's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 494
  • Thank you received: 46
  • Karma: 17
Hello,

sorry, it's a bit complicated and I'm not sure if I understand correctly. You said that ExprMgr_process_relevance_and_tailoring() over-writes that value with qcode.question. But if I use an expression like {name} within a question (where the answer for the text display question type is also in the question text) it will work (it means, if the user didn't enter anything, nothing is shown, if the user enters a name, it will be replaced). So I don't understand why that is not possible for Qcode.question.
Perhaps your idea with the innerHTML is a good way to solve this. So let's say we use Javascript to get the question/question-text and then get the text from it. If the LEMtailor spans are not necessary for a simple text view we could try to remove them from text(-string). If we want to insert it into the summary question using Qcode.question or something like Qcode.questionShown if we want to let .question be at it is now (for the use case "insert raw question text") perhaps it would be an idea to use a div tag arround it, e.g. "<div id='questiontext1234'>So how old are you MrX?</div>" so it is easier to change the content of the div if something within the question changes.
Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.141 seconds
Donation Image