- Posts: 90
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Rich Text Editor for Respondents
- BITCNI
- Topic Author
- Offline
- Premium Member
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
- Topic Author
- Offline
- Premium Member
- Posts: 90
- Thank you received: 0
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10099
- Thank you received: 3589
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:
<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.
Please Log in to join the conversation.
- BITCNI
- Topic Author
- Offline
- Premium Member
- Posts: 90
- Thank you received: 0
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
- Offline
- LimeSurvey Community Team
- Posts: 11639
- Thank you received: 2737
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
- Offline
- Official LimeSurvey Partner
- Posts: 965
- Thank you received: 218
Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
Please Log in to join the conversation.
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10099
- Thank you received: 3589
Yes, you can place this in the theme files and apply it to specific questions with a CSS class name.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?
1) Place this in your theme custom_header.twig file:
<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:
$(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
- Offline
- LimeSurvey Community Team
- Posts: 11639
- Thank you received: 2737
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
- Topic Author
- Offline
- Premium Member
- Posts: 90
- Thank you received: 0
Have a great weekend, and thanks again!
Please Log in to join the conversation.
- BITCNI
- Topic Author
- Offline
- Premium Member
- Posts: 90
- Thank you received: 0
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
- Offline
- LimeSurvey Community Team
- Posts: 11639
- Thank you received: 2737
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.
Please Log in to join the conversation.