Howdy, Stranger!

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

Supported by

Calculating correct response in OSWEB using js


I have had to update my experiment so that it is compatible with OSWEB and this has left me with a few issues.

Rather than use a linked sketchpad for responses I am now using a custom form with buttons however the output for responses is 'yes' or 'no'.

I have a variable for the correct response in the loop and would like to somehow create a new variable that simply states 1 for correct response or 0 for incorrect response.

So for example if the variable for correct response in the pool is anger and the variable anger_rb is 'yes' then correct_response would = 1.

I have tried to write an inline javascript for this but have got completely lost as I have very limited js knowledge.

Thanks in advance for any help!


  • Hi @predictorgilt,

    I'd have to see your task or a simplified version of it to test a solution but, generally speaking, as long as what you're after is setting a variable to a certain value based on the values of other variables, in Javascript within OSWeb, you can do it with "if" statements. Looking up "If then else Javascript" in google will bring up lots of pages where you can find how the syntax works.

    There is something a little odd in your request, though, since you seem to want to define the value of correct_response based partly on the value of that same variable.

    If you're after a variable that will be 1 or 0 based on whether the response is correct or incorrect respectively, you can get it from vars.correct. This variable, in a trial of your loop, will take the value 1 or 0 as long as you've defined what the correct response is in that trial (either manually through code, or by including a "correct_response" column in your loop.

    If, for some reason (e.g., you want to define the correct response dynamically based on several conditions), you wanted to define the score for each response, you could do it using some along those lined (I'm relatively new to Javascript myself):

    if (vars.correct_response == 'anger" and vars.anger_rb == 'yes') {
       vars.correct = 1
    } else {
       vars.correct = 0

    If for some reason you don't want to use the reserved vars.correct variable and want to create your own, you can do so:

    if (vars.correct_response == 'anger" and vars.anger_rb == 'yes') {
       vars.anger_score = 1
    } else {
       vars.anger_score = 0

    You would then be able to call upon the content of that variable in OSWeb objects (e.g., feedback object) using "[anger_score]".

    If you'd like to see some more advanced examples of Javascript used to calculate scores based on conditions, have a look at this thread; you might find some useful pointers there:

    Hope this helps!


    Buy Me A Coffee

  • Thank you very much for the response ! I shall try this out now.

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 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