- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Conditional line/paragraph breaks
- slarson55
- Topic Author
- Offline
- New Member
Less
More
3 years 11 months ago #196474
by slarson55
Conditional line/paragraph breaks was created by slarson55
Hello all,
So, I have searched and although there is a nice solution written by tpartner in this forum about evaluating as html:
www.limesurvey.org/forum/design-issues/9...line-break-in-string
I was wondering if there is a way to add line/paragraph/etc. breaks conditionally (I want to be able to add them only when the answer is null) and cannot find a way to do so.
I have a print page with hundreds of answers so converting them to {html_entity_decode(equation1)} method would be an endeavor.
So, I have searched and although there is a nice solution written by tpartner in this forum about evaluating as html:
www.limesurvey.org/forum/design-issues/9...line-break-in-string
I was wondering if there is a way to add line/paragraph/etc. breaks conditionally (I want to be able to add them only when the answer is null) and cannot find a way to do so.
I have a print page with hundreds of answers so converting them to {html_entity_decode(equation1)} method would be an endeavor.
The topic has been locked.
- slarson55
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
3 years 11 months ago - 3 years 11 months ago #196477
by slarson55
Replied by slarson55 on topic Conditional line/paragraph breaks
I wanted to provide an example of the code for illustration, too:
{if(!is_empty(R3),join("- ",R3.question,": ",R3.shown),"")}
{if(!is_empty(R3_SQ001_SQ001),join("- ", R3_SQ001_SQ001.question, ": ", R3_SQ001_SQ001.shown, " | " , R3_SQ001_SQ002.shown, " | ", R3_SQ001_SQ003.shown),"")}
{if(!is_empty(R3_SQ002_SQ001),join("- ", R3_SQ002_SQ001.question, ": ", R3_SQ002_SQ001.shown, " | " , R3_SQ002_SQ002.shown, " | ", R3_SQ002_SQ003.shown),"")}
{if(!is_empty(R3_SQ003_SQ001),join("- ", R3_SQ003_SQ001.question, ": ", R3_SQ003_SQ001.shown, " | " , R3_SQ003_SQ002.shown, " | ", R3_SQ003_SQ003.shown),"")}
{if(!is_empty(R3_SQ004_SQ001),join("- ", R3_SQ004_SQ001.question, ": ", R3_SQ004_SQ001.shown, " | " , R3_SQ004_SQ002.shown, " | ", R3_SQ004_SQ003.shown),"")}
{if(!is_empty(R3_SQ005_SQ001),join("- ", R3_SQ005_SQ001.question, ": ", R3_SQ005_SQ001.shown, " | " , R3_SQ005_SQ002.shown, " | ", R3_SQ005_SQ003.shown),"")}
{if(!is_empty(R3_SQ006_SQ001),join("- ", R3_SQ006_SQ001.question, ": ", R3_SQ006_SQ001.shown, " | " , R3_SQ006_SQ002.shown, " | ", R3_SQ006_SQ003.shown),"")}
{if(!is_empty(R3_SQ007_SQ001),join("- ", R3_SQ007_SQ001.question, ": ", R3_SQ007_SQ001.shown, " | " , R3_SQ007_SQ002.shown, " | ", R3_SQ007_SQ003.shown),"")}
{if(!is_empty(R3_SQ008_SQ001),join("- ", R3_SQ008_SQ001.question, ": ", R3_SQ008_SQ001.shown, " | " , R3_SQ008_SQ002.shown, " | ", R3_SQ008_SQ003.shown),"")}
{if(!is_empty(R3_SQ009_SQ001),join("- ", R3_SQ009_SQ001.question, ": ", R3_SQ009_SQ001.shown, " | " , R3_SQ009_SQ002.shown, " | ", R3_SQ009_SQ003.shown),"")}
{if(!is_empty(R3_SQ010_SQ001),join("- ", R3_SQ010_SQ001.question, ": ", R3_SQ010_SQ001.shown, " | " , R3_SQ010_SQ002.shown, " | ", R3_SQ010_SQ003.shown),"")}
{if(!is_empty(R3_SQ011_SQ001),join("- ", R3_SQ011_SQ001.question, ": ", R3_SQ011_SQ001.shown, " | " , R3_SQ011_SQ002.shown, " | ", R3_SQ011_SQ003.shown),"")}
{if(!is_empty(R3_SQ012_SQ001),join("- ", R3_SQ012_SQ001.question, ": ", R3_SQ012_SQ001.shown, " | " , R3_SQ012_SQ002.shown, " | ", R3_SQ012_SQ003.shown, " | ", R3_SQ012_SQ004.shown, " | ", R3_SQ012_SQ005.shown," | ", R3_SQ012_SQ006.shown),"")}
{if(!is_empty(R3_SQ013_SQ001),join("- ", R3_SQ013_SQ001.question, ": ", R3_SQ013_SQ001.shown, " | " , R3_SQ013_SQ002.shown, " | ", R3_SQ013_SQ003.shown),"")}
{if(!is_empty(R3_SQ014_SQ001),join("- ", R3_SQ014_SQ001.question, ": ", R3_SQ014_SQ001.shown, " | " , R3_SQ014_SQ002.shown, " | ", R3_SQ014_SQ003.shown),"")}
{if(!is_empty(R3_SQ015_SQ001),join("- ", R3_SQ015_SQ001.question, ": ", R3_SQ015_SQ001.shown, " | " , R3_SQ015_SQ002.shown, " | ", R3_SQ015_SQ003.shown),"")}
{if(!is_empty(R3_SQ016_SQ001),join("- ", R3_SQ016_SQ001.question, ": ", R3_SQ016_SQ001.shown, " | " , R3_SQ016_SQ002.shown, " | ", R3_SQ016_SQ003.shown),"")}
{if(!is_empty(R3_SQ017_SQ001),join("- ", R3_SQ017_SQ001.question, ": ", R3_SQ017_SQ001.shown, " | " , R3_SQ017_SQ002.shown, " | ", R3_SQ017_SQ003.shown),"")}
{if(!is_empty(R3_SQ018_SQ001),join("- ", R3_SQ018_SQ001.question, ": ", R3_SQ018_SQ001.shown, " | " , R3_SQ018_SQ002.shown, " | ", R3_SQ018_SQ003.shown),"")}
{if(!is_empty(R3_SQ019_SQ001),join("- ", R3_SQ019_SQ001.question, ": ", R3_SQ019_SQ001.shown, " | " , R3_SQ019_SQ002.shown, " | ", R3_SQ019_SQ003.shown),"")}
{if(!is_empty(R3_SQ020_SQ001),join("- ", R3_SQ020_SQ001.question, ": ", R3_SQ020_SQ001.shown, " | " , R3_SQ020_SQ002.shown, " | ", R3_SQ020_SQ003.shown),"")}
As you can see, if it adds a pagebreak after each of those "if thens", it's bulkier than needed. This one question adds 20 blank lines if they don't fill it in during the survey on my "print" page.
{if(!is_empty(R3),join("- ",R3.question,": ",R3.shown),"")}
{if(!is_empty(R3_SQ001_SQ001),join("- ", R3_SQ001_SQ001.question, ": ", R3_SQ001_SQ001.shown, " | " , R3_SQ001_SQ002.shown, " | ", R3_SQ001_SQ003.shown),"")}
{if(!is_empty(R3_SQ002_SQ001),join("- ", R3_SQ002_SQ001.question, ": ", R3_SQ002_SQ001.shown, " | " , R3_SQ002_SQ002.shown, " | ", R3_SQ002_SQ003.shown),"")}
{if(!is_empty(R3_SQ003_SQ001),join("- ", R3_SQ003_SQ001.question, ": ", R3_SQ003_SQ001.shown, " | " , R3_SQ003_SQ002.shown, " | ", R3_SQ003_SQ003.shown),"")}
{if(!is_empty(R3_SQ004_SQ001),join("- ", R3_SQ004_SQ001.question, ": ", R3_SQ004_SQ001.shown, " | " , R3_SQ004_SQ002.shown, " | ", R3_SQ004_SQ003.shown),"")}
{if(!is_empty(R3_SQ005_SQ001),join("- ", R3_SQ005_SQ001.question, ": ", R3_SQ005_SQ001.shown, " | " , R3_SQ005_SQ002.shown, " | ", R3_SQ005_SQ003.shown),"")}
{if(!is_empty(R3_SQ006_SQ001),join("- ", R3_SQ006_SQ001.question, ": ", R3_SQ006_SQ001.shown, " | " , R3_SQ006_SQ002.shown, " | ", R3_SQ006_SQ003.shown),"")}
{if(!is_empty(R3_SQ007_SQ001),join("- ", R3_SQ007_SQ001.question, ": ", R3_SQ007_SQ001.shown, " | " , R3_SQ007_SQ002.shown, " | ", R3_SQ007_SQ003.shown),"")}
{if(!is_empty(R3_SQ008_SQ001),join("- ", R3_SQ008_SQ001.question, ": ", R3_SQ008_SQ001.shown, " | " , R3_SQ008_SQ002.shown, " | ", R3_SQ008_SQ003.shown),"")}
{if(!is_empty(R3_SQ009_SQ001),join("- ", R3_SQ009_SQ001.question, ": ", R3_SQ009_SQ001.shown, " | " , R3_SQ009_SQ002.shown, " | ", R3_SQ009_SQ003.shown),"")}
{if(!is_empty(R3_SQ010_SQ001),join("- ", R3_SQ010_SQ001.question, ": ", R3_SQ010_SQ001.shown, " | " , R3_SQ010_SQ002.shown, " | ", R3_SQ010_SQ003.shown),"")}
{if(!is_empty(R3_SQ011_SQ001),join("- ", R3_SQ011_SQ001.question, ": ", R3_SQ011_SQ001.shown, " | " , R3_SQ011_SQ002.shown, " | ", R3_SQ011_SQ003.shown),"")}
{if(!is_empty(R3_SQ012_SQ001),join("- ", R3_SQ012_SQ001.question, ": ", R3_SQ012_SQ001.shown, " | " , R3_SQ012_SQ002.shown, " | ", R3_SQ012_SQ003.shown, " | ", R3_SQ012_SQ004.shown, " | ", R3_SQ012_SQ005.shown," | ", R3_SQ012_SQ006.shown),"")}
{if(!is_empty(R3_SQ013_SQ001),join("- ", R3_SQ013_SQ001.question, ": ", R3_SQ013_SQ001.shown, " | " , R3_SQ013_SQ002.shown, " | ", R3_SQ013_SQ003.shown),"")}
{if(!is_empty(R3_SQ014_SQ001),join("- ", R3_SQ014_SQ001.question, ": ", R3_SQ014_SQ001.shown, " | " , R3_SQ014_SQ002.shown, " | ", R3_SQ014_SQ003.shown),"")}
{if(!is_empty(R3_SQ015_SQ001),join("- ", R3_SQ015_SQ001.question, ": ", R3_SQ015_SQ001.shown, " | " , R3_SQ015_SQ002.shown, " | ", R3_SQ015_SQ003.shown),"")}
{if(!is_empty(R3_SQ016_SQ001),join("- ", R3_SQ016_SQ001.question, ": ", R3_SQ016_SQ001.shown, " | " , R3_SQ016_SQ002.shown, " | ", R3_SQ016_SQ003.shown),"")}
{if(!is_empty(R3_SQ017_SQ001),join("- ", R3_SQ017_SQ001.question, ": ", R3_SQ017_SQ001.shown, " | " , R3_SQ017_SQ002.shown, " | ", R3_SQ017_SQ003.shown),"")}
{if(!is_empty(R3_SQ018_SQ001),join("- ", R3_SQ018_SQ001.question, ": ", R3_SQ018_SQ001.shown, " | " , R3_SQ018_SQ002.shown, " | ", R3_SQ018_SQ003.shown),"")}
{if(!is_empty(R3_SQ019_SQ001),join("- ", R3_SQ019_SQ001.question, ": ", R3_SQ019_SQ001.shown, " | " , R3_SQ019_SQ002.shown, " | ", R3_SQ019_SQ003.shown),"")}
{if(!is_empty(R3_SQ020_SQ001),join("- ", R3_SQ020_SQ001.question, ": ", R3_SQ020_SQ001.shown, " | " , R3_SQ020_SQ002.shown, " | ", R3_SQ020_SQ003.shown),"")}
As you can see, if it adds a pagebreak after each of those "if thens", it's bulkier than needed. This one question adds 20 blank lines if they don't fill it in during the survey on my "print" page.
Last edit: 3 years 11 months ago by slarson55.
The topic has been locked.
- slarson55
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
3 years 11 months ago #196519
by slarson55
Replied by slarson55 on topic Conditional line/paragraph breaks
Sorry to put another message here, I forgot to put the LS version: 3.21 and the attachment of the lsg (might be able to get the lss but would have to get rid of information)
Attachments:
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
3 years 11 months ago #196522
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Conditional line/paragraph breaks
Hi,
you'd always attach a lss export of the relevant questions.
Other exports (lsq and lsg) are language sensitive, meaning we have to guess which base language your group export contains, then have to create a new survey hoping the guess was right, to import your group.
AND these exports don't contain survey settings that might be important to be able to help.
Please ease our life.
Joffm
Your group only contains an equation which IMO should be a question of type "text display", but not the questions which you want to display the results of.
So again: Attach a lss export with the relevant questions. To answer your question only a small example is sufficient.
you'd always attach a lss export of the relevant questions.
Other exports (lsq and lsg) are language sensitive, meaning we have to guess which base language your group export contains, then have to create a new survey hoping the guess was right, to import your group.
AND these exports don't contain survey settings that might be important to be able to help.
Please ease our life.
Joffm
Your group only contains an equation which IMO should be a question of type "text display", but not the questions which you want to display the results of.
So again: Attach a lss export with the relevant questions. To answer your question only a small example is sufficient.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- slarson55
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
3 years 11 months ago - 3 years 11 months ago #196523
by slarson55
Replied by slarson55 on topic Conditional line/paragraph breaks
I am just going to put the whole thing here because I am lazy, but how would I truncate the .lss? just use a text editor?
Attachments:
Last edit: 3 years 11 months ago by slarson55.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
3 years 11 months ago - 3 years 11 months ago #196528
by holch
Problem is, that we are lazy aswell. Human nature. And as your problem is not really our problem, our laziness prevents us from looking at your problem. If you could only find a way to provide an LSS file with just the relevant parts....
.... oh, wait, I have an idea. You could just copy the survey and in that copy you delete every question group and question that is not relevant for the problem and then export the LSS...
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Conditional line/paragraph breaks
I am just going to put the whole thing here because I am lazy, but how would I truncate the .lss? just use a text editor?
Problem is, that we are lazy aswell. Human nature. And as your problem is not really our problem, our laziness prevents us from looking at your problem. If you could only find a way to provide an LSS file with just the relevant parts....
.... oh, wait, I have an idea. You could just copy the survey and in that copy you delete every question group and question that is not relevant for the problem and then export the LSS...
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 3 years 11 months ago by holch.
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
3 years 11 months ago - 3 years 11 months ago #196529
by holch
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Conditional line/paragraph breaks
Now on a more serious note: This survey has 17 question groups and 94 questions in total. So it would take forever to understand the questionnaire structure and find the problematic part. You didn't even say where to find the problem within the questionnaire.
Just remember that most of us that help out in the forum here are doing this as a voluntary, we are doing this in our spare time, we are not getting paid for this. My intrinsic urge to help gets greatly reduced when it is a lot of work to even identify the problem.
Help us to help you.
I think I am going to sleep now.
Just remember that most of us that help out in the forum here are doing this as a voluntary, we are doing this in our spare time, we are not getting paid for this. My intrinsic urge to help gets greatly reduced when it is a lot of work to even identify the problem.
Help us to help you.
I think I am going to sleep now.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Last edit: 3 years 11 months ago by holch.
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12790
- Thank you received: 3940
3 years 11 months ago - 3 years 11 months ago #196530
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Conditional line/paragraph breaks
I have to support holch.
To show your wishes, two or three questions were sufficient.
And it is obvious that you get empty lines. You have a "<br />" after each line, without considering if it is empty or not.
Because the linefeed is necessary only if the line is not empty, you should include the "<br />" into the "join"-function.
Like
{if(!is_empty(Q1_SQ001),join( "- ", Q1_SQ001.question, Q1_SQ001.shown,'<br />'),"")}
Because I am lazy too, I didn't change the entire code to test (that's up to you)
Joffm
And consider the remarks here in an other thread about the editor and inserting HTML code.
To show your wishes, two or three questions were sufficient.
And it is obvious that you get empty lines. You have a "<br />" after each line, without considering if it is empty or not.
Because the linefeed is necessary only if the line is not empty, you should include the "<br />" into the "join"-function.
Like
{if(!is_empty(Q1_SQ001),join( "- ", Q1_SQ001.question, Q1_SQ001.shown,'<br />'),"")}
Because I am lazy too, I didn't change the entire code to test (that's up to you)
Joffm
And consider the remarks here in an other thread about the editor and inserting HTML code.
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 years 11 months ago by Joffm.
The following user(s) said Thank You: slarson55
The topic has been locked.
- slarson55
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
3 years 11 months ago #196538
by slarson55
Replied by slarson55 on topic Conditional line/paragraph breaks
Dear Joffm, Holch,
I wanted to thank you both, and I am guessing you guys probably got a lot of other, terribly unhelpful responses in the forums this week. So as for saving it to a new survey and clipping the answers there.... doyyyyy did not think of that. So thanks Holch, despite the sarcasm being thick enough to cut, that suggestion will also be quite helpful. As for Joffm, thanks for walking me through what was needed, and yes, your solution did indeed solve the issue. Feels good. Next time I won't be one of the unhelpful posters.
Sidenote: Why does single ' ' work, but not " " or just having the <br /> by itself?
I wanted to thank you both, and I am guessing you guys probably got a lot of other, terribly unhelpful responses in the forums this week. So as for saving it to a new survey and clipping the answers there.... doyyyyy did not think of that. So thanks Holch, despite the sarcasm being thick enough to cut, that suggestion will also be quite helpful. As for Joffm, thanks for walking me through what was needed, and yes, your solution did indeed solve the issue. Feels good. Next time I won't be one of the unhelpful posters.
Sidenote: Why does single ' ' work, but not " " or just having the <br /> by itself?
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
3 years 11 months ago #196543
by holch
Sorry if I was too tough though - it was late yesterday.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Conditional line/paragraph breaks
Yeah, I figured that it was quite sarcastic, but your "I am just going to put the whole thing here because I am lazy," was just calling for it.So thanks Holch, despite the sarcasm being thick enough to cut, that suggestion will also be quite helpful.
Sorry if I was too tough though - it was late yesterday.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The following user(s) said Thank You: slarson55
The topic has been locked.
- holch
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 11758
- Thank you received: 2753
3 years 11 months ago #196544
by holch
I think single quotes and double quotes should both work, in this case, I think. Why the quotes? It indicates to the expression manager/script that it is a "string" and does not require any processing like the variables that come before it.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
Replied by holch on topic Conditional line/paragraph breaks
Sidenote: Why does single ' ' work, but not " " or just having the <br /> by itself?
I think single quotes and double quotes should both work, in this case, I think. Why the quotes? It indicates to the expression manager/script that it is a "string" and does not require any processing like the variables that come before it.
I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.
The topic has been locked.