Welcome to the LimeSurvey Community Forum

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

Copy subquestion to another subquestion with EM when .question is EM formula?

  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189821 by AlrikStelling
How to copy subquestion P001 of array question Spent, using Expression Manager to subquestion U001 of array question Usage (to get the same .question) when P001 contains an EM formula? (NOT a fixed value => this seems to cause an issue in this case).



BACKGROUND

First, one is asked to select a Department, then about the products of this department (4 different array questions):
- Spent, per product
- Usage, per product
- Quality, per product
- Importance, per product

Product names vary per department. Each subquestion (= product name) of Spent, Quality, Importance, Usage is created by an expresssion like : {if(department="A","Dep A-product X",if(department="B","Dep B-product XYZ",if(.... )))} which runs 9 levels deep as there are 9 departments.

Note that the formula contains hardcoded product names. There are 25 different formulas for max. 25 products per department. All this works just fine! BTW, JS run time issues were reason to take this more complicated approach.


QUESTION

Instead of copying the same nasty long formulas into all subquestions of all four questions, I wanted to link Usage, Quality, Importance to Spent and enter the long formulas at Spent only. Subquestions of Spent are coded P001,P002,P003,... (= product 1, product 2...)

I want to fill 1st subquestion U001 of array question Usage with a very short formula like: {Spent_P001.question}
This does not work. ( Whereas {Department.question} does work. ) Original question: How do I refer to the 1st subquestion of Spent, using the Expression Manager?

Updated question: Seems the reference is valid, but the issue is caused by the formula within Spent_P001. If I replace it with a fixed value, it works. If filled with a formula, it does not. Apparently "{copy {formule} }" does not work like that. Any suggestion how it can be done?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #189827 by Joffm
What about copying the whole question?
You only have to change the question code and question text.

On the other side I do not see any issue.
With these settings:


and


I get:


and


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 6 months ago by Joffm.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189836 by AlrikStelling
First of all, thanks for your quick reply! This is weird. Your setup is like mine. But it works for you and fails for me.

My formula in Q1_P001 itself works fine (Spent is in fact coded Q1 in my setup).

Q2_subquestion:
If I put in {Q1_P001.question} it fails. In the survey it shows up as "Q1_P001.question" with a red border around it. It fails to evaluate.
If I replace the formula in Q1_P001 by some hard coded value like "test", it works and I get "test" in the survey.
If I put in {Email.question} instead {Q1_P001.question} it works as well.

So, still puzzled as to why it fails to work.
Maybe I'll start from scratch again, but it is hard to imagine that it may be caused by using P001 instead of SQ001 (that's the only difference I see).



P.S. This is one of my nasty long formulas (Afdeling is dutch for department)

{if(Afdeling=='AF1','Onderwijs en Kwaliteit-P03',if(Afdeling=='AF2','HR-P03',if(Afdeling=='AF3','Marketing & Communicatie-P03',if(Afdeling=='AF4','Planning & Control-P03',if(Afdeling=='AF5','InformatieManagement-P03',if(Afdeling=='AF6','Strategie-P03',if(Afdeling=='AF7','SSC Administratie-P03',if(Afdeling=='AF8','SSC Facilitair-P03',if(Afdeling=='AF9','CvB-P03','Kies afdeling')))))))))}



P.P.S. Indeed, you can simply copy across. That's what I had done. But the survey will be "updated" several times, and I rather change one question only, instead of four. But the issue is NOT a show stopper. Just wanted to make it more "lean".
The topic has been locked.
  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189839 by AlrikStelling
I have replicated your setup (see attachment). This {Q2_SQ001.question} fails to evaluate.

It appears as Q2_SQ001.question with a red border around it in the survey, and is detected as error running Check Logic.

Still unclear as to why.



P.S. The hard coded value of "My item" is not picked up either anymore?! If I change {Q2_SQ001.question} into {Q1.question} it works, and shows "What is your department?"
The topic has been locked.
  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189842 by AlrikStelling
Did some further testing. It is getting weirder.

If I use {Q2_SQ001_SQ001.question}, then it brings "Dep 3 -AAA[]"
Which is almost correct, apart from the [] at the end.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189843 by Joffm
Hi,
well, you didn't mention that you are using an array(text).
In your first post you asked about an array question.
As you saw I showed an array.

And the property .question shows different values depending on the question type:
1. questions without subquestions (radios) -> the text of the question.
2. questions with subquestions (multiple, multiple numerical,..) -> the text of the subquestion.
3. questions with x-scale and y-scale (array(text), array(numbers),...) -> the text of the y-scale[text of x-scale].

This is what you see here "Dep 3 -AAA[]".
The empty brackets are the result of your missing x-scale subquestions.




There is a long discussion here about this strange behaviour of this property.

Joffm

You may create a label set of these equations. Then it's just three clicks to insert them.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189845 by AlrikStelling
Yes, you are spot on!
I am indeed using an array(text) for the first question Spent. And three 5-point-choice array questions for Quality, Usage, Importance. Spent is the number of hours spent working on a product in my case.

Your "2. Questions with subquestions (multiple, multiple numerical,..) -> the text of the subquestion." is still unclear to me. Could/should I use another question type in my case? If so, which one would that be?
If not, I suppose there is no way to get rid of those [ ], or is there?!
(Btw, had figured out it refered to this x-scale just after my update and had it filled like [test], like your [Text 1], and then it started to make some more sense to me.)

Suggestion for development: if nothing sits between [ and ], then remove [] from .question result?
(You could argue that if there is a single column only [Text 1] does not add much value.)

Thanks for the tip about label sets! Will have a look at it later. (So far, I created 4 XML import files using some Excel interface.)


*** Thanks again for all your fast responses. Highly appreciated!! ***

___________________________________________

P.S. I am pretty new to LimeSurvey. Have played with it 5 days by now. I am sorry for not having mentioned array(text) specifically. Didn't understand its impact. Now, I do ;-)

P.P.S. I skipped using array(number) as it caused the survey to slow down tremendously to the point it almost became impossible to enter a number.

P.P.P.S. My initial setup contained a list of all 9 departments x 25 products which I then filtered using relevance that linked to department. The filtering took like 10 seconds in Google Chrome (so a user woull see the full list before it collapsed), but got almost completely stuck in Microsoft Edge (with multiple "not responding messages"). That's why I "invented" this approach. Besides, 9 x 25 x 4 questions would hit the (possible) limit of 1000 columns. Initially I started with 30 products. Products itself are not fixed yet, and will "depend" on the level of aggregation applied.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #189846 by Joffm
What else you can do (and this is what you initially wanted):
Create a question of type matrix or multiple short text, where you insert your equations.
This question do you hide. It is only used to store the equations.

Now you can use the subquestions in further arrays (of any type) with the
{Qhidden_SQ001.question} syntax.

Joffm

if nothing sits between [ and ], then remove [] from .question result?

No, because the behaviour of this property is very logical (though not wished of some users)
The .question property refers exactly to one column in the database.
In a single punch question like "Yes/No" I answer to the question text. (one column in the database)
In a question of type array, multiple short text, multiple numerical, ... the subquestion is the question I answer to. (one column per subquestion in the database)
And in array(text), array(number) where is one dimension more, the question I answer to is given by the two coordinates - the y-scale and the x-scale. (one column per y-scale x x-scale in the database)

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 6 months ago by Joffm.
The topic has been locked.
  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189847 by AlrikStelling
I suppose that would work indeed, but would also make it bigger.

My solution: {rtrim(rtrim(Q2_SQ001_SQ001.question,"]"),"[")}


How to set the status to "Solved. Thanks for all your quick support."
The topic has been locked.
  • AlrikStelling
  • AlrikStelling's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189848 by AlrikStelling
P.S. Somehow I hadn't fully appreciated the array(x,y) concept in my single column answer case. Bit silly.

Couldn't {Q1_SQ001.question} be interpreted by LimeSurvey as to pick up "y-scale-part-of-the-question-text" of Q1_SQ001_Whatever.question? Not sure if that would have been handy in other cases besides mine, or if that would only create the risk of causing "array-misunderstanding". Just wondering...
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189862 by DenisChenu

AlrikStelling wrote: P.S. Somehow I hadn't fully appreciated the array(x,y) concept in my single column answer case. Bit silly.

Since each textarea have 2 params, i didn't see how to do differently.

AlrikStelling wrote: Couldn't {Q1_SQ001.question} be interpreted by LimeSurvey as to pick up "y-scale-part-of-the-question-text" of Q1_SQ001_Whatever.question? Not sure if that would have been handy in other cases besides mine, or if that would only create the risk of causing "array-misunderstanding". Just wondering...

Partially done in 4.X only QCode.question, not for array text and arry number currently.
If you need it : extensions.sondages.pro/about/contact.html

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose