Welcome to the LimeSurvey Community Forum

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

Search Results (Searched for: html)

  • vnunzi
  • vnunzi's Avatar
27 Nov 2023 16:32 - 27 Nov 2023 16:33
Hi everyone,

I am currently using LimeSurey in order to send personnalized emails (using both email templates and expression manager).
I was looking for a way to have multiple versions of my email, which I could send at once using the participants table attributes.
The simplest way I found to store those versions (which contain HTML code) is to code them as questions in the survey, and pipe them in the template using the expression manager.

As a result, my email template looks something like this:

Code:
{if(TOKEN:ATTRIBUTE_1 == "version1", version1.question, "")}
{if(TOKEN:ATTRIBUTE_1 == "version2", version2.question, "")}
{if(TOKEN:ATTRIBUTE_1 == "version3", version3.question, "")}
...


It seemed to work very well at first, but then it started sending blank emails (even though I had not changed anything in my code).
I struggled to find an answer, and then I noticed something: if I preview my survey (with my the versions of my email as questions) just before sending my emails, they have content again. But if I come back the next day and start sending emails without previewing my questions first, everything is empty again.

Here's my question: do I need to preview the HTML I am piping in order to "reactivate" some ressources? I don't really know how else to put it, but does piping in LimeSurvey only works if the survey has been viewed in the last X hours? 

Thank you very much for you help.

Best,
Victor

PS: my access to LimeSurvey is provided by another compagny as part of a corporate plan, so I don't know what is the version, and I have very limited access to admin settings.
  • DenisChenu
  • DenisChenu's Avatar
21 Nov 2023 11:04
Replied by DenisChenu on topic remotecontrol doesn't work after update to 6.3.5

My hypothesis is - RPC does not return JSON but an HTML error page that limer has no idea about as it expects only a JSON string
Seems to be a PHP issue.

Can try you activate log file ?
manual.limesurvey.org/Optional_settings/en#Logging_settings
with debug=2 ?

Then you have more detail on the error in the log file.

 
  • r0bis
  • r0bis's Avatar
21 Nov 2023 10:12
Yes, this is what I am also getting. It seems that there is no content at all in terms of JSON, that there is just a 500 ERROR page that is returned. From what I understand the normal expected response is a JSON string, but there is no JSON

The error arises in this call
> session_key <- as.character(jsonlite::fromJSON(content(r, encoding="utf-8"))$result)
> Error: Argument 'txt' must be a JSON string, URL or file

If you look at the content that jsonLite is trying to parse, it is an HTML document:
> content(r, encoding="utf-8")
{html_document}
<html xmlns=" www.w3.org/1999/xhtml " xml:lang="en" lang="en">
[1] <head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n<title>ArgumentCoun ...
[2] <body>\n<div class="container">\n\t<h1>ArgumentCountError</h1>\n\n\t<p class="message">\n\t\tToo

I also know too little about JSON and what is the normally expected return. If you still have some working LS versions, you could easily check if this content is something different.

My hypothesis is - RPC does not return JSON but an HTML error page that limer has no idea about as it expects only a JSON string
  • iceclimber81
  • iceclimber81's Avatar
20 Nov 2023 22:19 - 20 Nov 2023 23:37
Replied by iceclimber81 on topic remotecontrol doesn't work after update to 6.3.5
Thanks for looking into this, r0bis.

I just experimented with limer / remotecontrol on different LS versions on my server and found that it still works on LS 6.3.4, but the upgrade to LS 6.3.5 (and later) breaks it.

When checking the changelog , I found this issue mentioned for 6.3.4 --> 6.3.5: Fixed issue #19214: JSON RPC response content type should be application/json (#3610) --> see issue described here: bugs.limesurvey.org/view.php?id=19214

If I understand correctly, starting from 6.3.5, the JSON RPC response content type is application/json, while before it was text/javascript. This might break the limer get_session_key() function.

UPDATE: Getting an error message:

When trying to call the remotecontrol API with the limer approach on LS 6.3.5 and later:
Code:
body.json = list(method = "get_session_key",
   id = 1,
   params = list(username = getOption('lime_username'), password = getOption('lime_password')))
 
r <- POST(getOption('lime_api'), content_type_json(), body = jsonlite::toJSON(body.json, auto_unbox = TRUE))
xml <- content(r, encoding="utf-8")
rvest::html_text(xml)


the response shows an error message:
Code:
500: Internal Server Error
call_user_func_array(): Argument #1 ($callback) must be a valid callback, second array member is not a valid method

Unfortunately, I'm not familiar enough with JSON to figure out how to modify the request so it is valid.
 
  • r0bis
  • r0bis's Avatar
20 Nov 2023 17:59 - 20 Nov 2023 21:43
remotecontrol error was created by r0bis
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Community Edition Version 6.3.6+231120 (PHP 7.4)
Own server or LimeSurvey hosting: own server, hosted on A2 provider, installed first via softaculous, maintained by paid comfortUpdate
Survey theme/template: default (Fruity) 
==================
After the last update today remotecontrol no longer works.

PHP has been 7.4 for a while on my server.
I use R for reports and data analysis. Until today limer worked well, after the update I get error on authentication:

> skey <- get_session_key()
Error: Argument 'txt' must be a JSON string, URL or file.

The options are correct, the same code worked yesterday. I had this type of error once before - first was
resolved by updating github cloudyr/limer to the latest version. Second time that was when hosting providers systems thought my ip was suspicious and was asking to solve captcha for login. After successful login to admin pages I was able to do remotecontrol again. 
This time I get the error and no idea how to troubleshoot. Remotecontrol is very important to us, an idea how to work on this would be much appreciated.

I played around with function from migliorati and came to conclusion some things work. But it seems that the response coming back from limesurvey might not be JSON or is an empty response altogether for example you do the usual limer options setup and then:

  body.json = list(method = "get_session_key",
                   id = 1,
                   params = list(username = getOption('lime_username'),
                                 password = getOption('lime_password')))
now you have the json rpc request (I think); then you give that request to httr:OST

POST(getOption('lime_api'),
            content_type_json(),
            body = jsonlite::toJSON(body.json,
                                    auto_unbox = TRUE))
you get a response similar to :Response [ lime.server.yours/index.php/admin/remotecontrol ]
Date: 2023-11-20 19:21
Status: 500
Content-Type: text/html; charset=UTF-8
Size: 20.8 kB
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
" www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" www.w3.org/1999/xhtml " xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ArgumentCountError</title>

<style type="text/css">
/*<![CDATA[*/

say instead of printing you save it to an object RRR, then we can see that it does not seem to be a JSON response at all through 
jsonlite::validate(RRR)Error in jsonlite::validate(content(RR, encoding = "utf-8")) :
is.character(txt) is not TRUE
  • r0bis
  • r0bis's Avatar
20 Nov 2023 17:44 - 20 Nov 2023 20:45
This is really quite bad, I get the same error and the only change I made was used comfort update. Now LS version is

LimeSurvey Community Edition Version 6.3.6+231120

and my PHP has been 7.4 for a good few months and until this update was working well.

I played around with function from migliorati and came to conclusion that a lot of things work. But it seems that the response coming back from limesurvey might not be JSON? for example you do the usual limer options setup and then:

  body.json = list(method = "get_session_key",
                   id = 1,
                   params = list(username = getOption('lime_username'),
                                 password = getOption('lime_password')))
now you have the json rpc request (I think); then you give that request to httr::POST

POST(getOption('lime_api'),
            content_type_json(),
            body = jsonlite::toJSON(body.json,
                                    auto_unbox = TRUE))
you get a response similar to :Response [ lime.server.yours/index.php/admin/remotecontrol ]
Date: 2023-11-20 19:21
Status: 500
Content-Type: text/html; charset=UTF-8
Size: 20.8 kB
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
" www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" www.w3.org/1999/xhtml " xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>ArgumentCountError</title>

<style type="text/css">
/*<![CDATA[*/say instead of printing you save it to an object RRR, then I am sure in RRR$cookies[7] you have your session key

 
  • tpartner
  • tpartner's Avatar
18 Nov 2023 15:38
Replied by tpartner on topic Reset survey (delete answers) if quota are met
Have the quota redirect to a PHP page that uses the API to remove the response.

- api.limesurvey.org/classes/remotecontrol...thod_delete_response
  • tpartner
  • tpartner's Avatar
18 Nov 2023 15:29
A few problems,

- You don't need to load jQuery in your scripts - it is already loaded.
- There are some undefined variables in the script in the first question.
- The script in the second question is has several errors.

This script, placed in the source of an array-texts question will hide the text inputs and insert radio inputs to control them.

Code:
<script type="text/javascript" data-author="Tony Partner">
 
  $(document).on('ready pjax:scriptcomplete',function(){
    var thisQuestion = $('#question{QID}');
 
    // If inserted radios not present
    if ($('.inserted-radio', thisQuestion).length == 0) {
 
      // Define the radio list HTML
      var radioTemplate = '<ul class="list-unstyled radio-list">\
        <li class="answer-item radio-item">\
          <input type="radio" class="inserted-radio" value="1" name="SGQA" id="inserted-radio-SGQA-1">\
          <label for="inserted-radio-SGQA-1" class="control-label radio-label">Yes</label>\
        </li>\
        <li class="answer-item radio-item">\
          <input type="radio" class="inserted-radio" value="2" name="SGQA" id="inserted-radio-SGQA-2">\
          <label for="inserted-radio-SGQA-2" class="control-label radio-label">No</label>\
        </li>\
        <li class="answer-item radio-item">\
          <input type="radio" class="inserted-radio" value="3" name="SGQA" id="inserted-radio-SGQA-3">\
          <label for="inserted-radio-SGQA-3" class="control-label radio-label">??</label>\
        </li>\
      </ul>';
 
      // Insert the radios
      $('.answer-item', thisQuestion).addClass('with-radios').each(function() {
        var thisSQID = $(':text.form-control', this).attr('id').replace(/answer/, '');        
        var radioHtml = radioTemplate.replace(/SGQA/g, thisSQID);
        $(this).append(radioHtml);
      });
    }
 
    // Listener on the radios
    $('.radio-item :radio', thisQuestion).on('click', function() {
      $(this).closest('td').find(':text.form-control').val($(this).val()).trigger('keyup');
    });
 
    // Returning to the page
    $(':text.form-control', thisQuestion).filter(function() {
      return $.trim($(this).val()) != '';
    }).each(function() {
      var thisCell = $(this).closest('td');
      var thisVal = $.trim($(this).val());
      $('.inserted-radio[value="'+thisVal+'"]', thisCell).trigger('click');
    });
 
    // Apply some styles
    $(':text.form-control', thisQuestion).css({
      'position': 'absolute',
      'left': '-9999em'
    });
    $('.radio-list', thisQuestion).css({
      'text-align': 'left'
    });
  });
</script>
  • bhavik
  • bhavik's Avatar
17 Nov 2023 22:52
Here is the script:

<script type="text/javascript" src=" code.jquery.com/jquery-3.6.0.min.js ">
<script type="text/javascript">
    $(document).ready(function() {
        var checkClosest = function(event) {
            event.target.firstElementChild.click();
        };

        var thisQuestion = $('#question{QID}');

        // Insert dropdowns
        if (!thisQuestion.find(".inserted-dropdown").length) {
            var dropdownTemplate = '<div style="text-align: left" class="list-question-select">\
                <span class="clickable-span">\
                    <select class="inserted-dropdown" name="dropdown_{QID}">\
                        <option value="">Please choose</option>\
                        <option value="rare, not severe">rare, not severe</option>\
                        <option value="rare, severe">rare, severe</option>\
                        <option value="occasional, not severe">occasional, not severe</option>\
                        <option value="occasional, severe">occasional, severe</option>\
                        <option value="frequent, not severe">frequent, not severe</option>\
                        <option value="frequent, severe">frequent, severe</option>\
                        <option value="No">Not Applicable</option>\
                    </select>\
                </span>\
            </div>';
            
            $('.answer-item', thisQuestion).addClass('with-select').each(function() {
                var dropdownHtml = dropdownTemplate.replace(/{QID}/g, $(this).data('qid'));
                $(this).append(dropdownHtml);
            });
        }
        
        // Insert date fields with "Know" and "Don't know" options
        if (!thisQuestion.find(".date-fields").length) {
            var dateFieldsTemplate = '<div class="date-fields" style="display: none;">\
                <div class="date-field-container">\
                    <label>Approx date of onset (if known):</label><br>\
                    <label class="know-label">Know:</label>\
                    <input type="date" class="date-field large-date" id="onset-date_{QID}">\
                    <br>\
                    <label class="dont-know-label">Don\'t know:</label>\
                    <input type="checkbox" class="dont-know-checkbox" id="dont-know-onset-date_{QID}">\
                </div>\
                <div class="date-field-container">\
                    <label>Approx end date (if at all):</label><br>\
                    <label class="know-label">Know:</label>\
                    <input type="date" class="date-field large-date" id="end-date_{QID}">\
                    <br>\
                    <label class="dont-know-label">Don\'t know:</label>\
                    <input type="checkbox" class="dont-know-checkbox" id="dont-know-end-date_{QID}">\
                </div>\
                <div class="inline-fields">\
                    <textarea class="comment-box" rows="3" cols="40" style="width: 100%;" placeholder="Comments"></textarea>\
                </div>\
            </div>';
            
            $('.answer-item', thisQuestion).each(function() {
                var dateFieldsHtml = dateFieldsTemplate.replace(/{QID}/g, $(this).data('qid'));
                $(this).append(dateFieldsHtml);
            });
        }

        thisQuestion.find("select[name^='dropdown']").each(function() {
            var currName = $(this).attr('name').substr(8);
            var listQuestionSelect = $(this).closest(".answer-item").find(".list-question-select");
            var dateFields = $(this).closest(".answer-item").find(".date-fields");
            
            listQuestionSelect.find('select').each(function() {
                $(this).attr('name', 'dropdown' + currName);
            });
            
            listQuestionSelect.find('select.inserted-dropdown').on("change", function(event) {
                var answerItem = $(this).closest('.answer-item');
                var selectedValue = $(this).val();
                var dateFields = answerItem.find('.date-fields');
                
                if (selectedValue !== '' && selectedValue !== 'No') {
                    dateFields.show();
                } else {
                    dateFields.hide();
                }
            });

            listQuestionSelect.find('.comment-box').on('click', function(event) {
                event.stopPropagation();
                
            });
        });
        


        // Clean-up styles
        $('select.inserted-dropdown').addClass('big-dropdown');
        $('.list-question-select span').addClass('clickable-span');
        $('.with-select input:text', thisQuestion).css({
            'position': 'absolute',
            'left': '-9999em'
        });
        
        // Hide all rows in the array text question initially
        $('[id^="javatbd128651X28X6425SQ"]').hide();
        //$('.ls-heading.ls-header .answertext.control-label[role="columnheader"]').hide(); // Hides the headers
        //$('.ls-heading.ls-heading-repeat').hide();
        $('#question6425').hide();
        
        $('[id^="answer128651X28X6347SQ"]').change(function() {
            // Extract the subquestion code from the checkbox ID
            var row = this.id.match(/SQ\d+$/)[0];
            console.log('row:', row);
        });
        
        var checkedQuestionCodes = []; // Initialize an empty array to store checked question codes
        // Event handler for radio button changes
        $('input.inserted-radio[type=radio]').change(function() {
            // Extract the last part of the name attribute which is the subQuestionCode
            var subQuestionCode = $(this).attr('name').split('_').pop();
            console.log('SubQuestionCode:', subQuestionCode);
            
            var name = $(this).attr('name');
            var sqIndex = name.indexOf('SQ'); // Find the index of 'SQ' in the string
            var questionCode = sqIndex !== -1 ? name.substring(sqIndex, sqIndex + 5) : null; // Extract 'SQ' and the following three characters
            
            // Check if the selected radio button's value is "1"
            if ($(this).val() === "1") {
                if (checkedQuestionCodes.indexOf(questionCode) === -1) {
                    checkedQuestionCodes.push('#javatbd128651X28X6425' + questionCode);
                }
                $('#javatbd128651X28X6425' + questionCode).show();
                $('.ls-heading.ls-header .answertext.control-label[role="columnheader"]').show();
                $('#question6425').show();
            } else {
                var index = checkedQuestionCodes.indexOf('#javatbd128651X28X6425' + questionCode);
                if (index !== -1) {
                    checkedQuestionCodes.splice(index, 1);
                }
                $('#javatbd128651X28X6425' + questionCode).hide();
            }
            console.log('Checked Question Codes:', checkedQuestionCodes);
        });
        $('input.inserted-radio[type=radio][value="1"]:checked').each(function() {
            $(this).trigger('change');
        });
        

        
    });
</script>
<style>
    .know-label,
    .dont-know-label {
        text-indent: 10px;
    }
    .ls-heading.ls-header .answertext.control-label[role="columnheader"] {
        background-color: #add8e6; /* Light blue color */
    }
</style>
 
  • Joffm
  • Joffm's Avatar
16 Nov 2023 13:02 - 16 Nov 2023 13:08
Replied by Joffm on topic Bedingte Fragen anhand von Schwellenwerten
Hallo,
Ich habe es doch geschrieben.

Hier die css-Klassen; diese kannst Du in der "custom.css" des erweiterten themes anfügen.

Hier werden ja neue Klassen definiert.
Gut, das steht jetzt zwar in der "custom.css", aber nirgendwo im ganzen LS Code werden sie benutzt.
Also musst Du eben sagen, bei welchen Fragen sie angesprochen werden.

Dazu werden die Namen im Feld css-Klassen eingetragen; aber das hast Du ja in der Beispielstudie gesehen

Wenn Du glaubst eine Klasse (oder Einstellung) nur sehr, sehr selten zu benutzen, kannst Du den Code auch im Fragetext (Quellcode-Modus) einfügen - also der Standard für kleine Sachen.
Nicht vergessen: Hier mit den <style></style> tags umschließen
Aber auch hier muss die Klasse ins Feld "css-Klassen"

Noch eine Erklärung:
Nur .question-title-container { display:none; } würde den Container mit dem Fragetext immer - bei jeder Frage - verstecken
.no-question .question-title-container { display:none; } versteckt ihn nur dann, wenn er nach der Klasse ".no-question" folgt.
Das ist die ganze Idee.

Und Tutorial:
Na, über css gibt es bestimmt hundert Videos auf Youtube.
Außerdem sind gute Quellen
[url] wiki.selfhtml.org/wiki/CSS [/url]
und
[url] www.w3schools.com/css/ [/url]

Joffm


 
  • Joffm
  • Joffm's Avatar
15 Nov 2023 13:04 - 15 Nov 2023 13:59
Could look like this
 
And as you display four subquestions you have to create an array with four subquestions and 6 answer options (some are not used)
A simple HTML table with the images.and the shown script with the following changes.
In the script the radio buttons are in the same cells as the image.
In this example there is a separate row below each image.

And please clarify

where you can only choose 1 option from all the options.

One choice of all 14?
Or one choice in each row?

Joffm
  • DenisChenu
  • DenisChenu's Avatar
15 Nov 2023 10:39 - 15 Nov 2023 10:42
Replied by DenisChenu on topic Really strange HTTP 500 when installing

Which HTML?
The html produced

And you have something like that : (to be unziped : HTML file)

And you can send it here to have a look at the issue …
  • urbana
  • urbana's Avatar
15 Nov 2023 10:36
Replied by urbana on topic Really strange HTTP 500 when installing
I am not 100% sure I follow you sorry :)

You recommend:
Doing this once:
debug = 2 and asset_manger false

Than saving the HTML
Which HTML?
  • DenisChenu
  • DenisChenu's Avatar
15 Nov 2023 10:33
Replied by DenisChenu on topic Really strange HTTP 500 when installing
Hi,

With you setdebug.php : you set debug=2 and disable asset_manager

I think with only (one time test)
Code:
    'config'=>array(
        'debug'=>2,
        'debugsql'=>0,
        'use_asset_manager' => true,
    )
you have the line where it call empty asset

You do it one time, save HTML (to have whole process)
And set again 'use_asset_manager' => false, after

I check : to disable asset manager : you need YII_DEBUG to true and Yii::app()->getConfig('use_asset_manager') to false (default is false)
Code:
if (!YII_DEBUG || Yii::app()->getConfig('use_asset_manager')) {
  • fabionardecchia67
  • fabionardecchia67's Avatar
15 Nov 2023 09:33
Domande più colonne e diverse opzioni was created by fabionardecchia67
La tua versione di LimeSurvey: Versione 2.73.1+171220
==================
Buongiorno, sto creando una nuova indagine e mi è stato chiesto di inserire in un'unica domanda i tre allegati in foto.
In poche parole in questa domanda devo inserire più colonne tra cui due colonne dove chiedo il nome e il cognome della persona (solo testo) ed altre tre/quattro colonne dove la persona deve scegliere per esempio il lavoro che fa e il contratto che ha (menù dropdown).
Io negli anni precedenti lo avevo impostato in più domande ma quest'anno mi hanno richiesto tutto in un'unica domanda.
Non penso che Limesurvey permette di fare questa cosa se non modificando html o altro, purtroppo sono ignorante sull'argomento quindi volevo chiedervi un aiuto.
p.s. non posso aggiornare ad una versione più recente Limesurvey.
Grazie mille in anticipo!
Displaying 226 - 240 out of 4821 results.

Lime-years ahead

Online-surveys for every purse and purpose