Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Widget and variables

Hello everybody!

How can I add an already configured variable to a widget? I would like to ask my participants some questions about the answers they already provided?

Thanks in advance.

Comments

  • Hi @Gio38000 ,


    Welcome to the forum!


    As you probably noticed, something like the following won't work, because the content of both text_input items ("first_question" and "follow_up_question") are prepared in the prepare phase of the experiment, and at this time the answer to the first question is not yet known.



    As a work-around, you can try something like the following structure, where you can use the response to the first question by using the square-bracket syntax like so:




    See this working example:




    Does this help?


    Cheers,


    Lotje

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Hello!


    Thank you very much for your answer, but my question is about coding in Python actually. I will try to be more specific:

    1. I ask the participants to give me some answers (item by item) and for this, I used "form_base" (javascript) as you can see in the screenshot.
    2. Then I want them to judge their own answer and for that, I used inline_script (python).

    I already managed to code to make their answers appear one by one as you can see circled in green (that works very well). But now I want to make all the answers (i.e., items) appear. I think I need a line code for that. I already tried (as you can see circled in red) but it did not work.

    Do you have some ideas?


  • Hi Gio,

    I am a little confused. As far as I know it is not possible to combine inline_javascript with inline_python. One only works online, the other only in the lab version. Also form_base" should not be available for Javascript. Based on your screenshot, I think you use the Python implementations, to run the form_base and your custom made form in the while loop, but with HTML-formatting in the label field. Does this make sense?

    Can you try to put an "f" before the string? Like this:

    label_recall = Label(text=f"Vous...")

    This could work. If not you might have to extract the var.response_letter variable from the var object first. For example by:

    resp_letter = var.response_letter

    And then have

    {resp_letter}

    in your string.

    Hope this helps,

    Eduard

    Buy Me A Coffee

  • Hello,

    Thank you guys.

    Problem solved.

Sign In or Register to comment.