Welcome to the LimeSurvey Community Forum

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

Search Results (Searched for: random)

  • lelehd
  • lelehd's Avatar
03 Apr 2024 15:29 - 03 Apr 2024 15:30
Bonjour,

J'utilise limesurvey pour évaluer des caractéristiques de mes images (72 images présentées de manière randomisée). Chaque image doit être présentée une fois pendant x temps (via le chronomètre), puis notées à l'aide d'une question à multiples entrées numériques.
Globalement, pour randomiser mes stimulus plus facilement, j'ai créé par image un groupe (ex: S1) constitué d'une question type affichage de texte me permettant d'afficher l'image, puis suivi d'une question à multiples entrées numériques. Chaque groupe etant alors défini par rand1 permettant de randomiser les groupes.tre:

S01 (18631)
Description :  Aucune
Nom de groupe aléatoire :rand1

Cependant, lorsque je récupère mes résultats, et en testant le questionnaire, je remarque que les groupes sont bien mélangés, puisque les images n'apparaissent pas dans l'ordre de création, mais je n'ai pas accès à cet ordre (randomisé) lorsque je récupère les résultats. J'aimerais donc savoir si je peux trouver une manière de récupérer l'ordre : ex savoir si S1, S14, S25, S65 etc et non pas S1, S2,S3,S4 etc.



Merci,



 Version de votre LimeSurvey : Version 3.23.6+200929
 
  • J.Auer
  • J.Auer's Avatar
03 Apr 2024 09:49 - 03 Apr 2024 09:52
Here's a fix ChatGPT gave me. It seems to work properly now, not sure if this is the best solution, but it fixes my problem!

Code:
<p>Here is the Random Number:</p>
 
<p id="randomValue"> </p>
<script>
 
    var randomValue;
 
    $(document).ready(function() {
        randomValue = rand(0, 1);
        document.getElementById("randomValue").innerText = "Random Number: " + randomValue;
        
        $('#question{QID} :text.form-control:eq(0)').val(randomValue).trigger('keyup');
    });
 
    function openFullscreenPopup(url) {
        var width = screen.width;
        var height = screen.height;
        var popupWindow = window.open(url, 'popupWindow', 'width=' + width + ', height=' + height + ', left=0, top=0');
        if (window.focus) {
            popupWindow.focus();
        }
        return false;
    }
 
    function openVersion() {
        var gameVersion = (randomValue < 0.5) ? 'https://www.bing.com' : 'https://www.google.com';
        openFullscreenPopup(gameVersion);
    }
</script><button class="my-button" onclick="openVersion(); return false;">Open in Fullscreen</button>
  • J.Auer
  • J.Auer's Avatar
03 Apr 2024 09:26 - 03 Apr 2024 09:37
Thank you for your explanation! That makes sense now!However, I'm still encountering difficulties in making this work. After adding the provided line of code, I noticed that the RandomValue is no longer displayed in the text itself, and the button no longer opens the link. Additionally, the RandomValue is not being logged in the first answer. I've attempted this with different question types as well. Is there still something I might be missing?

Code:
<p>Here is the Random Number:</p>
 
<p id="randomValue"> </p>
<script>
    var randomValue = rand(0, 1);
 
    document.getElementById("randomValue").innerText = "Random Number: " + randomValue;
  
     $('#question{QID} :text.form-control:eq(0)').val(randomValue).trigger('keyup);
 
    function openFullscreenPopup(url) {
        var width = screen.width;
        var height = screen.height;
        var popupWindow = window.open(url, 'popupWindow', 'width=' + width + ', height=' + height + ', left=0, top=0');
        if (window.focus) {
            popupWindow.focus();
        }
        return false;
    }
 
    function openVersion() {
        var gameVersion = (randomValue < 0.5) ? 'https://www.bing.com' : 'https://www.google.com';
        openFullscreenPopup(gameVersion);
    }
</script><button class="my-button" onclick="openVersion(); return false;">Open in Fullscreen</button>


I also attached a screenshot of how this looks in the preview
 
  • Help123
  • Help123's Avatar
02 Apr 2024 21:57 - 02 Apr 2024 22:05
Replied by Help123 on topic Eine Bilderschleife mit Limesurvey kreieren
Guten Abend Joffm,

tut mir Leid für die verspätete Antwort. Ich habe mir über die Feiertage eine Auszeit von Limesurvey genommen.

Tausend Dank für deine Mühe und wow das funktioniert ja wirklich, da hast Du Limesurvey ja ganz schön ausgetrickst. Danke auch für das Video! Das macht alles noch viel verständlicher. Das Problem mit den randomisierten Fragegruppen wäre dadurch auf jeden Fall gelöst.

So wie es mir scheint bleibt es mir aber nicht erspart für alle Bilder eine Fragegruppe zu erstellen und die Bilder einzeln in die Frage zu platzieren. Das dauert leider super lange. Oder deutest Du hier an, dass es einen leichteren Weg gibt meine ganzen Bilder einzufügen: "...empfiehlt sich der Export (*.txt)  und Weiterbearbeitung in Excel". Das habe ich nicht ganz verstanden.

Und weil ich es nicht genug sagen kann nochmal vielen, lieben Dank Joffm!

Ich wünsche noch weiterhin einen schönen Abend.
  • Joffm
  • Joffm's Avatar
02 Apr 2024 18:19 - 02 Apr 2024 18:33
You should not change {QID}
{QID} is a system variable that always returns the actual QuestionID.
Same wirh
{SID}: Survey ID
{GID}: Group ID
{SAVEDID}: Response ID
and many more.

And put it at the end of the script where you generate the randomvalue, e.g. before "openFullscreen".

Joffm
  • J.Auer
  • J.Auer's Avatar
02 Apr 2024 17:30
Thank you for your input!
I'm not quite sure how to implement that, though. I've created a sorting question using my code. In the first answer, I included your code and tried it like this for example:
Code:
<script>  $('#question{31} :text.form-control:eq(0)').val(randomValue).trigger('keyup);  </script>
 However, it doesn't seem to work, so I must be doing something wrong for sure. 
I would greatly appreciate if you could provide a more detailed instructions on how to implement this. Thanks in advance!
  • tpartner
  • tpartner's Avatar
02 Apr 2024 17:01
If your code is in the source of a sort-text question, you can load that input like this:

Code:
$('#question{QID} :text.form-control:eq(0)').val(randomValue).trigger('keyup);
  • J.Auer
  • J.Auer's Avatar
02 Apr 2024 16:46 - 02 Apr 2024 16:47
Your LimeSurvey version: 6.4.12

Hello!

I'm in the process of setting up an initial assignment for participants, giving each either a 0 or 1. This will dictate which link opens in fullscreen upon pressing a button. (In my context, these correspond to Game Version 1 or Game Version 2, in this example Bing & Google).
I thought this would be the most efficient way to get balanced a 50/50 chance for both links.I've managed to implement this successfully using the code provided below. However, I'm now interested in storing the assigned number (either 0 or 1) to track this in the final responses.I've tried to set it as an answer to a follow-up question, but can't get it to work.

What steps should I take next, or is there a more effective approach to address my requirement?


relevant code:
Code:
<p>Random Number:</p>
<p id="randomValue"> </p>
 
<script>
    var randomValue = rand(0, 1);
    document.getElementById("randomValue").innerText = "Zufallszahl: " + randomValue;
  
    function openFullscreenPopup(url) {
        var width = screen.width;
        var height = screen.height; 
        var popupWindow = window.open(url, 'popupWindow', 'width=' + width + ', height=' + height + ', left=0, top=0');
        if (window.focus) {
            popupWindow.focus();
        }
        return false;
    }
 
    function openVersion() {
        var gameVersion = (randomValue < 0.5) ? 'https://www.bing.com' : 'https://www.google.com';
 
        openFullscreenPopup(gameVersion);
    }
 
</script>
<button class="my-button" onclick="openVersion(); return false;">Open in Fullscreen</button>
  • evhenii_access
  • evhenii_access's Avatar
29 Mar 2024 21:46
Joffm and tpartner - thank you both so much for your prompt response and great help!    So I now have two versions of script working correctly for this issue.     
  • Joffm
  • Joffm's Avatar
29 Mar 2024 18:41
Hi,
beware that this
   // Handle "Other"
    if(otherFixed == true && $('#question'+qID+' input[type="text"]').length > 0) {


is not changed to
   // Handle "Other"
    if(otherFixed == true &amp;&amp; $('#question'+qID+' input[type="text"]').length > 0) {

as in your sample.

And change the exclusive option to the correct value.
 
  • evhenii_access
  • evhenii_access's Avatar
29 Mar 2024 18:23
Sure,  here is the lss export with the suggested code, which does not seem to be working.    Thank you! 
  • evhenii_access
  • evhenii_access's Avatar
29 Mar 2024 18:19
Thank you very much! This worked for me
  • Joffm
  • Joffm's Avatar
29 Mar 2024 18:15
Send the lss export of your try.
I do not see an issue.


Joffm
  • evhenii_access
  • evhenii_access's Avatar
29 Mar 2024 17:55
This code pasted above (from Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced),   LimeSurvey version 3.x)   is not working for me at all - neither for 1 column, not for 2 or 3 columns display:  the last answer 'None' appears in a totally random position in the middle of the list.      

I've also tried other variants of code in this section Partially Randomized Answers - Multiple Options & List (radio) questions (Enhanced)  - these two - LimeSurvey version 2.06 and LimeSurvey version 2.73.0.  For 1 column they work fine, but for 3 columns they fail - they put 'None' in end position in some random column (1st or 2nd or 3rd).  
Displaying 76 - 90 out of 652 results.

Lime-years ahead

Online-surveys for every purse and purpose