Howdy, Stranger!

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

Supported by

[solved] Question Randomization on One Page Using Forms

edited February 2013 in OpenSesame

I would like to present multiple questions in randomized order on one page using Forms. I was able to use the open sesame code to create a page with multiple question, but I have not been successful in getting it to randomize the order of question presentation. If I create multiple variables with a list of all the questions, then that creates the problem of having some questions asked more than once and others skipped. Is there a way to sample randomly from a variable with the specification that previously called up levels of that variable should not be sampled? Could you point me in the right direction for a solution to my problem.

Thanks and thank you for Open Sesame.

Jason

Comments

  • edited February 2013

    Hi Jason,

    Is there a way to sample randomly from a variable with the specification that previously called up levels of that variable should not be sampled?

    Generally speaking, yes. In Python you would use the pop() function to take the last item out of list. If you shuffle the list first, this will give you random sampling without replacement:

    from random import shuffle
    l = [1,2,3,4] # Create a list
    shuffle(l) # Shuffle the list order
    while len(l) > 0: # While the list is not empty
        val = l.pop() # 'Pop' the first item
        print val # And print it
    

    However, I suspect that this might not be what you have in mind. If not, could you perhaps describe in more detail what you are trying to do and how you have currently set up your experiment?

    Cheers,
    Sebastiaan

  • edited February 2013

    I'm running an experiment with some self-report measures at the end. I would like to randomize the order of presentation of the self-report questions so that each participant will get the same questions presented in a randomized order, on the same page. For instance the order of question 1, 2, and 3 below would be determined randomly, but each participant would get every question on one screen.


    from libopensesame import widgets form = widgets.form(self.experiment, cols=[1,2,1], rows=[1,1,1,1,1]) title = widgets.label(form, text='Indicate how much you agree with the following statement') question1 = widgets.label(form, text='', center=False) question2 = widgets.label(form, text='', center=False) question3 = widgets.label(form, text='', center=False) ratingScale1 = widgets.rating_scale(form, var='question1', nodes=['Agree', "Don't know", 'Disagree']) ratingScale2 = widgets.rating_scale(form, var='question3', nodes=['Agree', "Don't know", 'Disagree']) ratingScale3 = widgets.rating_scale(form, var='question3', nodes=['Agree', "Don't know", 'Disagree']) image_button = widgets.image_button(form, path=self.experiment.get_file('nextbutton.png'), var='response') form.set_widget(title, (0,0), colspan=2) form.set_widget(question1, (0,1)) form.set_widget(question2, (0,2)) form.set_widget(question3, (0,3)) form.set_widget(ratingScale1, (1,1)) form.set_widget(ratingScale2, (1,2)) form.set_widget(ratingScale3, (1,3)) form.set_widget(image_button, (1,4)) form._exec()
  • edited 10:00PM

    Ah, I see. So you want to present the same three questions on a single form, but randomize the order of the questions. This is quite easy to accomplish, especially since you are using Python code already. First you create a list of row indices ([1,2,3]). You shuffle this list, to get a random order of row indices (e.g. [3,1,2], and then use this list to specify the actual row indices of the question and ratingScale widgets (i.e., rows[0], etc.).

    Hope this helps!

    from libopensesame import widgets
    from random import shuffle
    
    # Create a list of row indices for the questions (1, 2, and 3)
    # and shuffle the list. When specifying the rows for the
    # questions, you can then use rows[0], rows[1], and rows[2], to
    # get a randomized order.
    rows = [1,2,3]
    shuffle(rows)
    
    form = widgets.form(self.experiment, cols=[1,2,1], rows=[1,1,1,1,1])
    title = widgets.label(form, text='Indicate how much you agree with the following statement')
    question1 = widgets.label(form, text='q1', center=False)
    question2 = widgets.label(form, text='q2', center=False)
    question3 = widgets.label(form, text='q3', center=False)
    ratingScale1 = widgets.rating_scale(form, var='question1', nodes=['Agree', "Don't know", 'Disagree'])
    ratingScale2 = widgets.rating_scale(form, var='question3', nodes=['Agree', "Don't know", 'Disagree'])
    ratingScale3 = widgets.rating_scale(form, var='question3', nodes=['Agree', "Don't know", 'Disagree'])
    image_button = widgets.image_button(form, path=self.experiment.get_file('nextbutton.png'), var='response')
    form.set_widget(title, (0,0), colspan=2)
    form.set_widget(question1, (0,rows[0]))
    form.set_widget(question2, (0,rows[1]))
    form.set_widget(question3, (0,rows[2]))
    form.set_widget(ratingScale1, (1,rows[0]))
    form.set_widget(ratingScale2, (1,rows[1]))
    form.set_widget(ratingScale3, (1,rows[2]))
    form.set_widget(image_button, (1,4))
    form._exec()
    

    PS. I removed your last post, as it seemed to only contain the code that you already posted.

  • edited 10:00PM

    Thank you! That does exactly what I need it to do! It randomizes the order of question presentation while also keeping the rating scales attached to their respective questions. I was somewhat concerned that the latter part wasn't going to happen, but it did.

  • edited 10:00PM

    This is a quite common task and should somehow be implemented within the gui items / questionnaire possibilites.

  • edited 10:00PM

    HI @refuzee,

    if you believe this is something that should be built-in OpenSesame by default, you can request it in the wishlist. There, suggestions for future improvements of OpenSesame are very welcome and collected centralized.

    Thanks,

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games