Howdy, Stranger!

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

Supported by

Problem with ratingscale

Hi,

is there any way to group a variable for a checkbox and a rating scale? So that the participant can answer either with a point on the scale or by marking a checkbox. I also need to have a validator that checks that the participants have done one of these things. It works if I have a validator with the following code: "return var.var1 != 'no'" and var1 is the variable for both the rating scale and the checkbox(not adding a group for the checkbox). However, in this case, it's not possible to unselect the rating scale. This means that if the participant first click on a point on the scale and then wants to answer with the checkbox instead, it's not possible. (I'm using legacy and inline scripts).

Thanks in advance!

Comments

  • Hi Lina,

    That's an interesting scenario. So I guess you want have a checkbox that participants can check to indicate that they don't want to check anything on the rating scale. Right? Of course the most pragmatic solution would be to simply add one node to the rating scale, and label it 'Not applicable' or something like that.

    A more elaborate solution would be to validate the form on every click, and uncheck any nodes on the rating scale whenever the no-rating checkbox has been checked. That's possible, but it requires a bit of hacking, as you can see in the script below. (Personally I'd probably go with the easy option of adding a node to the rating scale!)

    Cheers,

    Sebastiaan

    def validate():
        
        # If the no-rating checkbox is checked, disallow any value to be set on
        # the rating scale
        if var.no_rating != 'no':
            rating_scale.set_value(None)
            rating_scale._update()
            form.render()
        print(var.no_rating, var.rating)
        # Only accept the form when the Ok button has been clicked
        return var.ok_button == 'yes'
        
    
    form = Form(validator=validate)
    # The .construct() is a hack that turns the widget into an object that
    # supports .set_value() etc.
    rating_scale = RatingScale(
        nodes=5,
        var='rating',
        click_accepts=True  # To call validate() on every click
    ).construct(form)
    checkbox = Checkbox(
        text='Don\'t rate',
        var='no_rating',
        click_accepts=True  # To call validate() on every click
    )
    button = Button(text='Ok', var='ok_button')
    form.set_widget(rating_scale, (0, 0))
    form.set_widget(checkbox, (1, 0))
    form.set_widget(button, (0, 1), colspan=2)
    form._exec()
    


  • Hi Sebastiaan,

    yes exactly! The reason for this question was that I wanted to add a "Don't want to answer" option. Thank you so much for your suggestions. I'll try both and see what works best for me.

    All the best,

    Lina

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