rventura

Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • in reply to: Refreshing canvas #7037
    rventura
    Participant

    It’s working now, thank you!

    in reply to: Refreshing canvas #7034
    rventura
    Participant

    Great, thank you! It looks like I’m using v2.0.alpha. Here’s the demo link:

    https://farm.pcibex.net/r/ZStOSj/experiment.html?test=true

    Best,
    Rafael

    in reply to: Refreshing canvas #7030
    rventura
    Participant

    Hi Jeremy,

    Thanks for the quick reply! The code that I posted here had a few typos, but the code that’s giving the error message didn’t. My bad for obscuring the issue in a failed attempt to make the post easier to read. Besides, missing parentheses and extra comes don’t usually give me the error messages I’m receiving. Is there a way to check/update my PennController version? I gave the elements different names but still get the same error.

    Here’s the full code:

    newTrial("Begin_2",
        
        //
        newVar("value", 0).global(),
    
        newText("<h4>You are about to start Phase 2!</h4>")
            .print(),
            
        newText("<p> </p>").print(),
        newButton("Begin Phase 2!")
            .center()
            .print()
            .wait()
    
    );
    
    //Phase 2: Produce
    Template( GetTable( "icon.csv" ), row => 
        newTrial("Phase_2",
        
            //
            newCanvas("score", 600,20)
                .add( 275, 0,
                    newText("score", "score: ")
                ).print()
                .add( 325, 0,
                    newText( "score_value", "0" )
                ).print()
            ,
            
            getText("score_value").text( getVar("value") ),
    
            //
            newCanvas("next_trial", 600,250)
                .add( "center at 50%", "middle at 50%",
                    newText("<p>Next . . .</p>")
                ).print()
            ,
            
            newTimer("wait", 600).start().wait(),
            getCanvas("next_trial").remove(),
    
            newCanvas(600,250)
                .add("center at 50%", "middle at 50%", newImage("pic", row.File))
                .print()
            ,
            
            newScale("answer", row.A1, row.A2, row.A3, row.A4 )
                .center()
                .vertical()
                .labelsPosition("right")
                .print()
                .wait()
            ,
            
            getScale("answer")
                .test.selected( row.Noun1)
                .or( getScale("answer").test.selected( row.Noun2) )
                .success(
                    getVar("value").set( v => v+1 ),
                    getText("score_value").text( getVar("value") )
                )
                .failure(
                    getText("score_value").text( getVar("value") ) 
                )
            ,
                
            newText("<p> </p>").print(),
            newButton("next", "Next")
                .center()
                .print()
                .wait()
            
        )
    );

    Best,
    Rafael

    in reply to: Refreshing canvas #7022
    rventura
    Participant

    Hi Jeremy,

    That’s perfect, thank you! I have yet another question. I want to have a score tracker and for that I initialize a global variable with newVar(“value”, 0).global(). But when I try to update a Text element with getText(“value”).text( getVar(“value”) ), I get an error message I cannot decipher. The code and the error message are below:

    newTrial("Begin_2",
       
        newVar("value", 0).global(),
    
        newText("<h4>You are about to start Phase 2!</h4>").print(),
    
        newButton("Begin Phase 2!")
            .center()
            .print()
            .wait()
    
    );
    
    Template( GetTable( "icon.csv" ), row => 
        newTrial("Phase_2",
    
            newCanvas("score", 600,20)
                .add( 275, 0,
                    newText("score", "score: ")
                ).print()
                .add( 325, 0,
                    newText( "value", "0" )
                ).print()
            ,
            
            getText("value").text( getVar("value") ),
    
    ); 

    And the error message:

    [8:33:40] Command ‘0’ unknown on Var element ‘value’. (PennController: 34)
    [8:33:40] Command ‘length’ unknown on Var element ‘value’. (PennController: 34)
    [8:33:40] Command ‘parentNode’ unknown on Var element ‘value’. (PennController: 34)

    Thanks,
    Rafael

    in reply to: Refreshing canvas #6992
    rventura
    Participant

    Hi Jeremy,

    Thank you, that’s very helpful! A further question I have is: how can I time all the trials in the template? If a timer starts in the beginning of a trial, then a new timer starts every time the user clicks on the button and the user is taken to the next trial. Is there a general way to ensure that users are given a limited amount of time to finish all the trials in the template?

    Many thanks!

    Best,
    Rafael

    in reply to: Time format #6025
    rventura
    Participant

    Great, thank you!

Viewing 6 posts - 1 through 6 (of 6 total)