Welcome to the LimeSurvey Community Forum

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

Rich Text Editor for Respondents

  • BITCNI
  • BITCNI's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 year 2 months ago #240219 by BITCNI
Rich Text Editor for Respondents was created by BITCNI
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
Some of our survey questions require long, complex answers, but screeds of plain text are hard to read.  Many of the people answering our Surveys have collected responses internally, perhaps via email in Outlook, and they want to copy the answers from various departments into the Answer box.  These answers may have Headings in Bold and other formatting within the answer, such as italics or colored text.  Is there a way to allow users to use formatting in their answers, so that the response isn't just 5,000 plain text words, which makes it very hard to read also?

Thanks

Please Log in to join the conversation.

  • BITCNI
  • BITCNI's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 year 2 months ago #240289 by BITCNI
Replied by BITCNI on topic Rich Text Editor for Respondents
Thank you so much. Would this also work for Questions that have comments, ie, 'List with Comment'?

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago - 1 year 1 month ago #240291 by tpartner
Replied by tpartner on topic Rich Text Editor for Respondents
 
Yes, as long as the comments element is a textarea (not a single-line text input).

Here is a slightly modified script that parses the HTML properly in the editor if respondents return to the page:

Code:
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
<script type="text/javascript" data-author="Tony Partner">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
    var thisTextarea = $('textarea:eq(0)', thisQuestion);
    var textID = $(thisTextarea).attr('id');
 
 
    // Clean up the textarea value before initiating the editor
    function decodeEntities(encodedString) {
      var textArea = document.createElement('textarea');
      textArea.innerHTML = encodedString;
      return textArea.value;
    }
    var decodedval = decodeEntities($(thisTextarea).val());
    $(thisTextarea).val(decodeEntities($(thisTextarea).val()));
 
    // Initiate the editor
    tinymce.init({ 
      selector:'#'+textID,
      plugins: 'code'    
    });
  });
</script>

 

 

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 year 1 month ago by tpartner.
The following user(s) said Thank You: BITCNI

Please Log in to join the conversation.

  • BITCNI
  • BITCNI's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 year 2 months ago #240302 by BITCNI
Replied by BITCNI on topic Rich Text Editor for Respondents
Thank you SO MUCH! This is exactly what we needed. I'm genuinely shocked the LS doesn't have Rich Text options in 2023. For a SaaS that's been operating for so long, it seems a major oversight?! Nonetheless, this works perfectly, so thank you again.

As a follow-up, could we add this into a Theme file to save our having to paste the code into each question's HTML source?

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago #240315 by holch
Replied by holch on topic Rich Text Editor for Respondents
Yes, but this means that then every text field will have this. To be honest in my use of survey tools I really don't see much need for this. And it seems like most others don't miss it either. That is probably why it isn't there as a function/setting. For the rare cases that people want it, you can code it. I wouldn't want it in the majority of my surveys.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
1 year 2 months ago #240323 by tammo
Replied by tammo on topic Rich Text Editor for Respondents
Yes, a survey tool is not the same as a CMS...


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago #240328 by tpartner
Replied by tpartner on topic Rich Text Editor for Respondents

As a follow-up, could we add this into a Theme file to save our having to paste the code into each question's HTML source?

Yes, you can place this in the theme files and apply it to specific questions with a CSS class name.

1) Place this in your theme custom_header.twig file:

Code:
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>

2) Place this in the theme custom.js file:

Code:
$(document).on('ready pjax:scriptcomplete',function(){
  tinymce.init({ 
    selector:'.question-container.with-editor textarea.form-control',
    plugins: 'code' 
  });
});

3) Add the "with-editor" CSS class to any questions where you want the editor applied.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago #240330 by holch
Replied by holch on topic Rich Text Editor for Respondents

Yes, a survey tool is not the same as a CMS...


Yeah. I can see this very helpful in special occasions, thus I have saved Tpartner's example for the future. Sometimes there might be a need or it would be good even in a survey where you usually don't get extremely long answers. So I understand that it can be interesting to have that.

But for my use (and that of many others that use Limesurvey for "traditional" surveys) it is rather a nice to have or "fine for it to be a workaround", rather than a feature to be implemented in LS. And with Tpartners solution on including it into the template and then activate it with a custom css class name per question, this is a good and easy solution I think if you want it in many text fields.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Please Log in to join the conversation.

  • BITCNI
  • BITCNI's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 year 2 months ago #240337 by BITCNI
Replied by BITCNI on topic Rich Text Editor for Respondents
Thank you. That's very helpful. :)
Have a great weekend, and thanks again!

Please Log in to join the conversation.

  • BITCNI
  • BITCNI's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 year 2 months ago #240338 by BITCNI
Replied by BITCNI on topic Rich Text Editor for Respondents
TBH, I don't think it would be bad to have this ability. It's better to have something than not have it. I'll bet money there are people who have wished this existed but just thought, "Oh, LS can't do it. Darn". Not everyone is comfortable working with HTML, and not everyone is curious! Some will just accept that it can't do it.
I realize that a lot of people do want simple answers, and not everyone wants a screed of text from respondents, but giving users the ability to put in a few headings or bold text is a nice feature, IMHO. :)

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 2 months ago - 1 year 2 months ago #240339 by holch
Replied by holch on topic Rich Text Editor for Respondents

TBH, I don't think it would be bad to have this ability. It's better to have something than not have it.


Oh, I totally agree. In a world where budgets are infinite (time & money) this makes total sense. However, this is rarely the case, especially in open source projects. If another important feature will not be implemented or come later because of rich text editor, I'd rather skip the built in rich text editor. ;-)

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 1 year 2 months ago by holch.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose