Howdy, Stranger!

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

Supported by

MC Question point calculations.

Hello again,

I am trying to use OS to make a simple calculation of the points of randomly selected MCQ's. Before the main loop I have set the sequence to zero with the following inline script code to break the loop after a certain amount of trials:

exp.set('count_Knowledge_Q_Seq',0)

Then the loop, the sequence, and the form follow. And after MCQ's and the Logger the following inline script code is placed to calculate the correct or incorrect answered points (it would not do sooner because it would not recognize that there is a response variable):

var.Point = 1 if var.response == var.Correct_Answer else 0
var.Grade = 'Sorry, better study next time' if var.Pika = range(0,4)
var.Grade = 'Barely made it' if var.Pika = 5
var.Grade = 'Nice' if var.Point = range(6,9)
var.Grade = '10 Points, Good' if var.Point = 10
var.Grade = '11 Points, Good' if var.Point = 11
var.Grade = '12 Points, Good' if var.Point = 12
var.Grade = '13 Points, Good' if var.Point = 13
var.Grade = '14 Points, Good' if var.Point = 14
var.Grade = '15 Points, Good' if var.Point = 15

My aim is to present var.Grade to a sketchpad for the students to see after the test. But there is a syntax error in line 3 it says:

code: var.Grade = 'Sorry, better study next time' if var.Point = range(0,4)
item-stack: Exp[run].Knowledge_Loop[run].Knowledge_Q_Seq[prepare].Calc_Point_Script[prepare]
exception type: SyntaxError
exception message: invalid syntax (, line 3)
item: Calc_Point_Script
time: Sun Aug 07 18:41:03 2016
phase: prepare
line: 2

I tried adding more "=" and make them in two's like so "==" as well as different if/then lines, but the same error was persistent throughout. I could not find this problem in the forum specifically.

Also, one other thing seems to be raising its head. Why should participants see how we have programmed the experiment in OS? For instance, there are correct answers in the table and I do not want participants to see those. Can OS run constantly per each student on the same computer and not reveal itself every time the experiment ends?

Thank You
DCube

Comments

  • Hi DCube,

    the syntax should be:


    if var.response == var.Correct_Answer: var.Point = 1 else: var.Point = 0 # and accordingly: if var.Pika in range(0,4): var.Grade = 'Sorry, better study next time'

    I'm not sure whether I understand your second question. Why do your participants see the correct answers? If you just open another tab (e.g. general Experimental features), they don't learn anything about the experiment. Or do I misunderstand anything?

    Eduard

    Buy Me A Coffee

  • Thank You Eduard,

    Now it seems there is no SyntaxError when "in range(x,y)" is used. However, the SyntaxError now lies with concrete numerical values (when they are not a range) in the same inline_script named Calc_Point_Script. Here is what I mean:

    I followed your coding and although it worked for "in range" it did not worked for values 5 & 10. So I switched the word from "in" to "=" like below:

    if var.response == var.Correct_Answer:
    var.Point = 1
    else:
    var.Point = 0
    if var.Point in range(0,4):
    var.Grade = 'Sorry, better study next time'
    if var.Point = 5
    var.Grade = 'Barely made it'
    if var.Point in range (6,9)
    var.Grade = 'Good'
    if var.Point = 10
    var.Grade = 'Very Good'

    It provided the same SyntaxError as before:

    code: if var.Point = 5
    item-stack: Exp[run].Knowledge_Loop[run].Knowledge_Q_Seq[prepare].Calc_Point_Script[prepare]
    exception type: SyntaxError
    exception message: invalid syntax (, line 8)
    item: Calc_Point_Script
    time: Mon Aug 08 16:30:29 2016
    phase: prepare
    line: 7

    The constant problem I am having is that my variables do not seem to go along with the symbol "=" and I do not know how to tell what the variable should do if points are summed at various degrees. So, which symbol in OS equates a variable with a concrete (i.e., not in range) number? It does not seems to be "=" or "=="

    Regarding the second question, I have OS operating under One Tab Mode. I suppose unclicking this mode would yield additional tabs that may make it more difficult (i.e., hide) the correct answers from students in the MCQ's, but why do they have to see that it is OS to begin with? What I am alluding to is: Does OS has a Continuous Loop feature that does not permits for OS to end (and thus reveal itself) unless ESC and "Q" keys are typed first?

    I tried putting a grand loop above the main Experimental sequence that could have done that, but that does not work.

    DCube.

  • Hi DCube,

    This is another Syntax error. The problem is that you don't use colons and indentations properly. These two are central to the Python syntax. I recommend you to do one of the many Python tutorials online (e.g. this). The problems you report here are not really related to OpenSesame.

    So, at the end of every if statement, you need to have a colon :. And the next line, you have to start on a deeper indentation level (convention is 4 whitespaces) to indicate the hierarchy of your code. Here an example:

    if var.Point == 0:
        print var.Point
    

    I hope this makes sense

    Eduard

    Buy Me A Coffee

  • Thank you Eduard,

    After adding colons it worked (the indentation level was fine, it just did not show in this forum after copy/paste). I shall look into some basic Python coding on the site that you provided, so thanks for that too.

    I noticed that when there is a SyntaxError that the Inline Script is red colored. It turns back to the original green after Syntax is corrected. So the color red should signal if all is well with Python coding in Inline Script.

    You are right that although I am using OS and OS' Inline Script that the problem was more related to Python. But now it is definitely OS because although the MCQ form has a clear variable named response, and although the second inline script asks for the response variable after the MCQ (after a participant has made responses in the response variable), I get a "Stopped" response saying: The variable 'response' does not exist. Tip: Use the variable inspector (Ctrl+I) to see all variables. Changing the name of the response variable to Student_Response variable does not helps neither. And the variable response is there but is not active/bold like other variables.

    Why would OS not recognize the dependent response variable that is clearly there? Does the second Inline Script bypasses the order in the chain hierarchy somehow?

    Thank You
    DCube

  • Hey,

    What is the structure of your experiment? Is the code that you posted above executed in the run or prepare phase of that inline_script? I need a little more info to help you here.

    Eduard

    Buy Me A Coffee

  • Sure,

    Here is the structure:

    Main Experimental sequence named "Exp" >

    Inline Script that sets the Knowledge Sequence as zero so as to count and stop in break if, which is named as "Set_Knowledge_Script" >

    Loop with tables of questions and answers that is used to randomize named as "Knowledge Loop" >

    The Knowledge Sequence mentioned above named as "Knowledge_Q_Seq" >

    MCQ form named as "Knowledge_Qs_MC_Form" >

    Calculation Point Inline Script, which is the one with syntax errors and that is not working now named as "Calc_Point_Script" > Looger > Sketchpad to present to the students their MCQ grade (i.e., var.grade).

    I mention the exact names because here are the details that OS mentions when running the Experiment:

    item-stack: Exp[run].Knowledge_Loop[run].Knowledge_Q_Seq[prepare].Calc_Point_Script[prepare]

    DCube

  • edited August 2016

    And that's where the issue is. Your response is collected not before the run phase of your MCQs, however, you try to compute the points in the prepare phase of the same sequence. Have a look at this part of the documentation to learn about the differences between and proper usage of the prepare-run-strategy. Once you moved your script into the run phase of the inline_script your response variable should exist.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited August 2016

    Thanks Eduard,

    That surely did it. Now the experiment runs at least without errors.

    But although points are provided per each correct answer, the points are still not calculated into the variable Grade. Here is the indented Inline Script (it just does not appears so when I post in the forum):

    if var.Student_Response == var.Correct_Answer:
        var.Point = 1    
    else:
        var.Point = 0
    if var.Point in range(0,4):
        var.Grade = 'Sorry, better study next time' 
    if var.Point == 5:
        var.Grade = 'Barely made it'
    if var.Point in range (6,9):
        var.Grade = 'Good'
    if var.Point == 10:
        var.Grade = 'Very Good!'
    

    I know that to be the case because I can see that there are values of 1 for each correct answer under the variable Points. But the variable Grade always shows the first quoted text of 'Sorry, better study next time' no matter if points grow above the range of 4 as instructed to do so above. It does not shows the later text in turn such as 'Good' even if there were 6 points (within the 6-9 range). This hints that OS is not summing the points so as to categorise what type of a var.Grade variable it should be.

    Also, I can only get to see these from the quickrun logger. I want to see the Point calculating variable Grade appear on the sketchpad, not just see it on the logger. When I run the experiment with a blank sketchpad the variable Grade becomes active as it can be seen in the variable inspector. If I were to instruct the sketchpad to show the Grade variable the experiment halts and tells me that the variable does not exists and the previously bold Grade variable is no longer bold.

    What could be wrong this time when I put both inline script codes on the run page. Why are not points being calculated and why do they not appear on the sketchpad?

    Thank You
    DCube

  • I edited your code to make it more readible. For the next time, you can do the same by using Markdown commands. Let me know, if you need help on that.

    This hints that OS is not summing the points so as to categorise what type of a var.Grade variable it should be.

    Right, OpenSesame doesn't count the points, because you don't tell it to add, but to replace.


    # replacing points if correct: point = 1 else: point = 0 # adding points points = 0 if correct: points = points + 1

    Do you see the difference? On every trial, you just overwrite the current score with either 1 or 0. Instead you need to have a variable that is initialized before the trial sequence starts and add either 0 or 1 to the count in every trial.

    If I were to instruct the sketchpad to show the Grade variable the experiment halts and tells me that the variable does not exist

    That is the same issue as the one before. A sketchpad is drawn in the prepare phase. At this time, the variable points doesn't exist yet. You fix the issue with the initialization of the point counter, this problem should also be gone.

    Eduard

    Buy Me A Coffee

  • edited August 2016

    Hi Eduard,

    Well, the symbol of Inline Script is not red, so there is no syntax error, so that is good. But now it does not recognizes the correct variable. I did not understood the "Markdown Commands" so yes, if it helps communication I would like some help with that too.

    This is the indented inline scrips:

    if var.Student_Response == var.Correct_Answer:
        var.correct
    var.point = 0
    if var.correct:
        var.point = var.point + 1
    if var.Point in range(0,4):
        var.Grade = 'Sorry, beeter study next time' 
    if var.Point == 5:
        var.Grade = 'Barely made it'
    if var.Point in range(6,9):
        var.Grade = 'Good'
    if var.Point == 10:
        var.Grade = 'Very Good!'
    

    This is the error OS tells me:

    The variable 'correct' does not exist. Tip: Use the variable inspector (Ctrl+I) to see all variables.

    Details

    item-stack: Exp[run].Knowledge_Loop[run].Knowledge_Q_Seq[run].Calc_Point_Script[run]

    As you can see, now all are "run" and it still fails to detect the assigned variables.

    There should be a beginners book that covers other than PyGaze experiments with OS that we should read. These questions may seem simple but the experiment would not run and you got nothing until these simple issues are solved first.

    DCube

  • edited August 2016

    It does not know the variable because you haven't created it.

    # This doesn't do anything
    var.correct
    # This is probably what you wanted to do
    var.correct = True
    

    There should be a beginners book that covers other than PyGaze experiments with OS that we should read

    Well, there a couple of tutorials that you could do: e.g. http://osdoc.cogsci.nl/3.1/tutorials/beginner/
    But still, this issue you have is still not per se OpenSesame related. It stems from not using Python code properly.

    Btw. If you want to post a piece of code, put it in between ~~~.python and ~~~
    For example:

    <~~~.python>

    'some code'

    <~~~>

    (Of course, you would need to remove the little arrows). If you press 'edit' on one of your previous posts, you can see another example.

    Buy Me A Coffee

  • edited August 2016

    Thanks Eduard,

    After mingling with some codes, this version at least played the experiment.

    if var.Student_Response == var.Correct_Answer:
        var.correct = True
    if var.correct:
        var.Point = True 
        var.point = 0
        var.Point = var.Point + 1
    if var.Point in range(0,4):
        var.Grade = 'Sorry, better study next time' 
    if var.Point == 5:
        var.Grade = 'Barely made it'
    if var.Point in range(6,9):
        var.Grade = 'Good'
    if var.Point == 10:
        var.Grade = 'Very Good!'
    

    But points were not being calculated again, and they were being replaced because even when there were more than 4 points it still provided the "Sorry, better study next time" claim. This BTW was only visible through quickrun and not sketchpad which was the intended goal.

    Putting variables in sketchpad so as the calculated grade to show up stopped the experiment again. If I put [Grade] on the sketchpad it says that the variable Grade does not exists. If I put [var.Grade] on the sketchpad it says that the variable correct does not exists.

    item-stack: Exp[run].Knowledge_Loop[run].Knowledge_Q_Seq[run].Calc_Point_Script[run]

    So we are back to the same problem. Can you please write the entire Inline Code for me and tell me how to put various stages in either prepare or run format so as I could have random MCQ's that are on the Loop table be calculated in a variable that could be presented in a sketchpad? It seems as if we are nearly there, its just a few steps away to be done with this experiment.

    I have read that beginners tutorial, I was alluding to other reading material that could cover other than pygaze experiments (e.g., MCQ's). Doing MCQ's should have been simple and straightforward since its a common request, but its the codes in the Inline Script and the prepare/run arrangement that messes the questionnaire.

    DCube

  • Did you initialize the counter of the points before the trial_loop? In a loop, every assignment that has the form variable = value, will be overwritten on every iteration. To keep track of a variable across trials, you need to initialize a variable before you enter the trial_loop and add values to it during the trial.

    Your line var.Points = True will reset the count to 1 on every iteration. So, the highest you can get is 2. If you remove this line (and also the line var.point = 0, as I don't see what purpose it has), your script should be functional. To make it more efficient you can change the last three ifstatements to elifs.

    Once this is done, make sure that the variables var.Point and var.grade exist before the trial_loopis entered and you should be done. Just fixing your code, won't solve the issue because the problem lies at several places in your experiment and without seeing your structure or your experiment, it's quite hard to write the code that you need, just like that.
    If you upload your experiment, I can have a closer look.

    Eduard

    Buy Me A Coffee

  • edited August 2016

    Thanks Eduard,

    I was going to give up on this otherwise! :smile:

    The following MCQ needing user could benefit from our work. They may be more pressed in time (not have time to experiment with OS) and could just download this here in this forum's thread neatly instead.

    Its attached.

    DCube

  • Maybe I have not communicated this correctly,

    The above mentioned and attached MCQ file does not works. So prior for other users to benefit from our work, Eduard, it's Inline Scripts and run/prepare modes should be fixed first. I attached it since you said you would have a closer look if done so.

    DCube

  • Hi Eduard.

    (Un)lucky for my students, now no matter how much they score at the test the result is always "Good!" ;-)

    See for yourself by putting these questions and answers on the Loop table for instance:

    http://www.indiabix.com/general-knowledge/biology/

    Perhaps you missed this outcome because question options, questions, and correct answers that I attached were trivial. I made them trivial because the MCQ in this thread could then be used from various users from various courses, not just questions related to my courses.

    DCube

  • edited August 2016

    You're right. There was a sloppy-coding-related issue, but it is resolved now. Also, I optimized the script a little.

    Note, if you want to loop over a questionnaire, you would have to reset the Points counter. Otherwise it will continue to count from wherever it stopped on the previous loop.

    Eduard

    Buy Me A Coffee

  • All seems to be working well now,

    So, all a user has to do now is change the trivial questions to meaningful course related ones, change the number of MCQ's that they like their tests to have by assigning the required number of questions minus 2 in the Knowledge_Loop area's "Break if" command (e.g., if you want 15 questions then the number should be [count_Knowledge_Q_Seq] > 13 and if you want 20 questions then the number in Break if should be > 18 ). Lastly, the users may benefit if they choose the random option in the Knowledge_Loop area rather then Sequential one already set in this last attachment, so as the questions would be randomly issued to students, preventing copies.

    A future request may be for OS not only to randomize the order of the questions, but for OS to also randomize the order of Choices presented within the random question. This should force students to give an educated guess rather than memorize by heart which question is linked with which number of answer (e.g., Question 3 is a, Question 7 is b, etc).

    But, I guess I must also report a bug. Every now and then, instead of presenting the grade OS just presents a number value of 0 (i.e., zero) for some reason. Is that what you meant with "looping over the questionnaire" and if so how should one "reset" first prior to issuing the MCQ's to students so as to avoid this problem?

    Thanks
    DCube

  • edited August 2016

    This could only be the reason if you have a nested loop, that is if you have multiple blocks in which all the questions are presented repeatedly. If you have only a single block (as in the example I uploaded), you wouldn't have to reset the Point counter.
    Right now, participants receive a point for every correctly answered question. If there are more than 15 questions, the could also get more than 15 points. However, the code as it is doesn't support scores higher than 15 and therefore doesn't set a grade, so that the default grade, which is 0 is used. To fix that, you simply need to make sure that for every value that the variable Points can have, there is a corresponding grade.

    Eduard

    Edit: The current code doesn't have a proper mapping of cases when the Point counter equals 4 or 9 (You should look up how exactly the range() function works`.

    Buy Me A Coffee

  • Hi Eduard,

    It was easy to make if-then commands for points that are at the limits of range() command, which in this case it was 0, 4, 6, & 9. After adding those then for 15 questions (i.e., Break if variable > 13) the MCQ's seem to be working fine now. I did not had the "0" bug presented on the screen again.

    So now I attach a free MCQ with 15 questions that anyone may adjust (see my post above and previous ones) and use for their courses.

    DCube

  • Eduard,

    How difficult it is to randomize the order of answers within randomized order of questions in OS?

    DCube

  • edited August 2016

    Not too difficult. You need to do this in another inline_script though. This new inline_script, you have to add as a first item into your loop. There (in the prepare phase) you do following steps:
    1. take all the answers from the loop table and save them in a list
    2. shuffle the list
    3. save each entry of the list to 5 new variables coding for the answers

    Finally, you have to change the MCQ form to take the new responses as options and not the old ones. Also, in the final inline_script , when you check whether a response is correct or not, you have to use the new variables.

    Eduard

    Buy Me A Coffee

  • edited August 2016

    Inline Script and Python language are not my strengths as it may be evident from the exchange thus far.

    Unless someone could apply the above instruction to the uploaded free 15MCQ of OS (no pressure at all to you Eduard) then this thread could be closed as a [solved] thread I suppose...

    DCube

  • import random
    options = [var.question_option1,var.question_option2,var.question_option3,var.question_option4,var.question_option5]
    random.shuffle(options)
    var.questionOption1,var.questionOption2,var.questionOption3,var.questionOption4,var.questionOption5 = options
    

    Finally, replace all var.question_optionsX with corresponding var.questionOptionX

    I haven't tried it, but something like that should work.

    Eduard

    Buy Me A Coffee

  • Is there anyone who would like to try the above code and see if it works?

  • Hello,

    It has been a long time since I came to the forums. I see that OpenSesame has been updated to 3.2 Kafka. However, the free_15_MC programme that we worked on above no longer works in this version!

    So I have two question:

    1) Does the latest version 3.2 also requires audio drivers?

    2) If it does not requires audio drivers, then, how can we fix the free_15_MC_in_OS programme to work in the updated 3.2 version also?

    Regards,
    DCube

  • Would virtual drivers instead of real audio hardware and drivers do for this latest 3.2 Kafka release for instance?

  • edited February 2019

    Perhaps some context could help with attracting some attention to my problem.

    I am trying to use OpenSesame on a University for exams. We designed it with Eduard a few years ago and uploaded here, making it a free OS exam application of sorts.

    Now I am trying to use it and there are some problems with it. For one, I have a class with 90 computers, where only about 10% have audio drives. For the other, the above mentioned OS exam application does not works in the newest version in Windows XP.

    So then, I was going to ask if we could make it work in the newest version of OS, however, that would not be a useful question if the newest version also requires audio drivers like the previous one. Thereby, to prioritise, we would have:

    1) Does the newest version also requires audio drivers? If it does, then is there a round about way to deal with it?

    2) Could the above exam application that we worked on with Eduard (where is he BTW?) also work in this newest version of OS?

    Regards,
    DCube

  • edited February 2019

    Hi DCube,

    Here I am :smile:

    As far as I remember from our labs, Opensesame doesn't run if the sound card is deactivated, so I'd suppose that you would need one. What we did, to "fix" it, was to plug some audio jacks into the computers, which was sufficient to activate the sound and allowed Opensesame to be booted. Maybe this would be a solution for your guys, too?

    2)

    I don't remember the application and the exact syntax. In theory it should work also with the newest version, but there is a fair chance you have to make some minor editions.

    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