Welcome to the LimeSurvey Community Forum

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

Rendering HTML in Text Display

  • matthewpulis
  • matthewpulis's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 3 months ago - 3 years 3 months ago #226140 by matthewpulis
Rendering HTML in Text Display was created by matthewpulis
Please help us help you and fill where relevant:
Your LimeSurvey version: 3.28.1+220229
Own server
Survey theme/template: fruity
==================


I have an Equation Type question which has some html text (including an <img> tag) - screenshot. When I am displaying the results, I am using Text display type to display {descAchiever} amongst other variables. But it is stripping the html. Any workarounds, please? descAchiever is rendered correctly by itself, but not when called in the front-end.



I am assigning descAchiever by using this Equation Type question:



Conditionally assigning the contents of descAchiever to whichDescription which will then be rendered:


And ultimately rendered with this Text Display question type:
Last edit: 3 years 3 months ago by matthewpulis. Reason: Images rendered wrongly

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226145 by holch
Replied by holch on topic Rendering HTML in Text Display
Not sure what happens there (always good to provide a LSS file with the relevant parts of the survey, not the whole survey), but HTML in Equations is always tricky.

However, from what I can see you only want to show the description of "Achiever", "Explorer", "Killer" or "Sozializer".

In this case, I would create 4 text display questions, one for each description, and then I would show or hide the questions via relevance equation. Much easier and you won't have problems with the HTML-Code.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

  • matthewpulis
  • matthewpulis's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 3 months ago #226147 by matthewpulis
Replied by matthewpulis on topic Rendering HTML in Text Display
Thanks @holch

This is the .lss for the relevant section.

So your suggestion is to display/hide rather than display dynamically as I am doing? Which function should I look into, please? 

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226148 by holch
Replied by holch on topic Rendering HTML in Text Display
You just need to create the 4 text display questions with the profile descriptions.

Then you write into the relevance equation of each question, when you want to show or hide it.

E.g. for the questions with the description of "Achiever" you would write something like
Code:
Qcode=="Achiever"

In this case, the question will only be shown if the the question "Qcode" is "Achiever". Of course, this highly depends on how you store if someone is an achiever.

I will try to have a look at your LSS file to see how this is done. Because the screenshots look rather confusing.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226149 by holch
Replied by holch on topic Rendering HTML in Text Display
OK, so there are about 50 something questions, a little bit much for having a quick look.

Anyway, from what I understand, the part were you store which type of player someon is is question "highestPersonCat". What I don't get is what "highestPersonality" is for. Because you check if "highestPersonCat" is Achiever and then write Achiever into highestPersonality. But isn't that the same as you would find in "highestPersonCat"? I don't have the time to click through all these questions to check what it actually does.


But in my opinion you would just need to write a relevance equation for the questions like "descAchiever". I would make them a "text display" question instead of an equation question, at the end you are not calculating anything in them anyway.

Then you could save quite a few equation questions, actually. You just need one question that defines which player type the person is, not sure if this is "highestPersonCat" or "highestPersonality", but I guess you know and I think it is "highestPersonCat", because you use this question to determine which description to show in "whichDescription").

In "whichDescription" I find it quite weird to use the check like this "Achiever==HighestPersonCat". Wouldn't "HighestPersonCat=="Achiever" make more sense? Anyway, in my solution, as far as I understand what you are trying to do, you could get rid of quite a few of these equations.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226151 by holch
Replied by holch on topic Rendering HTML in Text Display
OK, I think I know why you are doing this, because you not only want to show the description, but also the percentages, but even then, I think your approach is far too complicated.

Let me see if I can get you a simpler solution.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226152 by tpartner
Replied by tpartner on topic Rendering HTML in Text Display
Try {descAchiever.question}.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: matthewpulis, HorizonsMolBio

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226153 by Joffm
Replied by Joffm on topic Rendering HTML in Text Display

But it is stripping the html. 

Hi, first thing:
Do not use the inline editor. Use the source code editor.
The inline editor likes to do strange things.

And, as @holch, seems to be really too complicated.
But no time at the moment.

Joffm



 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 3 months ago #226154 by holch
Replied by holch on topic Rendering HTML in Text Display
Oh man, those stupid hidden questions made me search for so long why my descriptions are not shown correctly. No surprise, they were "always hidden" as they were copies of your "descAchiever", etc. I highly recommend to only hide questiosn once all testing is finished.

I showed most of the equations again, so I could understand what you are doing and if it works as expected and moved the questions that I deemed irrlevant to the end of the survey in a new group.

I seperated the description from the percentages.

By the way, during one of my tests I managed to have the same % for two types, not sure what shall happen in this case. Probably need to find a solution in "highestPersonality" for that.

At the moment, the way you determine the highestPersonality it depends on the order of your "if" construction.

E.g. I got this result right now:
Achiever: 20%
Explorer: 47%
Socialiser: 67%
Killer: 67%

So I was a Socializer and a Killer, but my result was "Killer".

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: matthewpulis

Please Log in to join the conversation.

  • matthewpulis
  • matthewpulis's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 3 months ago - 3 years 3 months ago #226180 by matthewpulis
Replied by matthewpulis on topic Rendering HTML in Text Display
@tpartner's solution worked perfectly for the original question :) Many thanks!
Last edit: 3 years 3 months ago by matthewpulis.

Please Log in to join the conversation.

  • matthewpulis
  • matthewpulis's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 3 months ago - 3 years 3 months ago #226182 by matthewpulis
Replied by matthewpulis on topic Rendering HTML in Text Display
Thanks for flagging this :) I will do a tie-breaker question for these circumstances.

The issue is how to do a tie-braker? Would appreciate some logical support on this, please.

I am thinking of doing a comparison (this is just needed for the winning category):

reminder: highestPersonCat is the variable which max(the 4 variables to find the highest count) and Achiever, Socialiser, Killer, and Explorer hold the total of how many valid answers each group got.

So let's say Achiever = 8, Socialiser = 7, Killer = 4, Explorer = 5 .. highestPersonCat would be 8 .. then I compare and I get the highest personality to be Achiever. However if both Achiever and Socialiser are 8, and the rest 4 and 5, then I have a problem, since it depends on my IF whether the result would be Achiever or Socialiser, as holch pointed out. So I am thinking of this?

Create a new variable: NeedATieBreaker (Equation Type)
Code:
 
IF (highestPersonCat == 
(
    (Achiever AND Socialiser) , "AS", 
        IF (highestPersonCat == (Achiever AND Killer) , "AK",
            IF (highestPersonCat == (Achiever AND Explorer) , "AE",
                IF (highestPersonCat == (Socialiser AND Killer) , "SK",
                    IF (highestPersonCat == (Socialiser AND Explorer) , "SE",
                        IF (highestPersonCat == (Killer AND Explorer) , "KE", FALSE))
                    )
                )
            )
)
 


Then create 6 question sets with 2 statements each corresponding to the pairs above, mark them hidden and relevant equation for the pair - for example in our case the question dependent on highestPersonCat = "SA" will be unhidden. Depending on the answer I adjust only the highestPersonality and whichDescription not the percentages - since the test relies on pairs of 15. So I'll use the tiebreaker to select the highlighted category. Does that make sense?

Is there a simpler solution, please? Many many thanks!!
Last edit: 3 years 3 months ago by matthewpulis.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose