Welcome to the LimeSurvey Community Forum

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

Asterisk displays on a seperate line for mandatory questions

  • pvb8008
  • pvb8008's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145139 by pvb8008
I just did a clean install of Limesurvey 2.56.1.

I am using the default template for a very simple survey that has all questions as mandatory. In the template on some questions the asterisk is inline before the question (the way I want it). On other questions the asterisk is on its own line with the question below it.

The difference seems to be random. Some are inline and some are not. Is there a way to control this and have the asterisk inline?

(see screen shot)

Thanks!

Peter
Attachments:
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145140 by holch
Is there a difference between questions types?

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.
  • pvb8008
  • pvb8008's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145142 by pvb8008
@holch

No. I tried with the same long free text and with short free text--got the same outcome. The length of the question and the question type don't seem to make any difference. I looked to be sure there was no additional space or errant line break in the html code also. I looked in the manual but have not been able to locate where this is addressed.

Thanks,

Peter
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145147 by Joffm
Hi, Peter,
select "source code" in question text editor.
Very probably there is a <p> tag around the text.
Remove it at least from the first line.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, gascon_alf
The topic has been locked.
  • pvb8008
  • pvb8008's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145149 by pvb8008
Indeed. The one's that were inline had no <p> tag. The one's that had the asterisk on a separate line had the <p> tag. I removed the paragraph tags (both open <p> and closed </p>) and all now are consistent. You saved me tons of time trying to sort this out.

THANK YOU!!

Peter
The following user(s) said Thank You: gascon_alf
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago - 7 years 3 months ago #145152 by tpartner
I use a JavaScript workaround like this to insert the asterisk into the <p> element (if found). It allows the unrestricted use of <p> elements.

Code:
$(document).ready(function() {
 
  // Fix the asterisk placement
  $.fn.tagName = function() {
    return this.get(0).tagName;
  }
  $('span.asterisk').each(function(i){
    if($(this).next().length > 0 &amp;&amp; $(this).next().tagName().toLowerCase() == 'p') {
      $(this).prependTo($(this).next());
    }
  });
});

Of course, then you also need to add a little margin for the asterisk.

Code:
p span.asterisk {
  margin-right: 0.3em;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 3 months ago by tpartner.
The topic has been locked.
  • pvb8008
  • pvb8008's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145153 by pvb8008
Nice.

I see that this is an oddity in the program or theme that it puts the asterisk on its own line when using standard paragraph tags. So I must not be the only one who has encountered this.

Thanks.

Peter
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145155 by tpartner
The problem is that the asterisk is inserted at the template level (question.pstpl), not by the editor so there is no way of knowing what HTML elements will be in the question text.

<p> elements are block elements so will be rendered with a preceding line-break.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • pvb8008
  • pvb8008's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145157 by pvb8008
Noted.

Where are you putting the javascript? Which css file is the styling fix added to?

Peter
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago - 7 years 3 months ago #145158 by tpartner
Sorry, I should have included that.

- The JavaScript in template.js
- The CSS in template.css

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 3 months ago by tpartner.
The following user(s) said Thank You: pvb8008
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145165 by DenisChenu

tpartner wrote: I use a JavaScript workaround like ....

Why not with float:left css ?

It work on 2.6 version and 3.0 version.

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145181 by tpartner
Personal preference - I prefer to place it in the <p> element.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose