#### Howdy, Stranger!

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

Supported by

# Next Button doesn't work and using Input for Feedback

edited December 2017

Hey there!!
1) My Next Button doesn't work. It only works if I don't answer the question which is on the same form.- Counterproductive :

2) I want to use my answer collected by the form to give feedback and use it all troughout the experiment. I put the variable name of the textinput [text_input] in a feedback Item after my form but it doesnt show anything.

I used 2 Inlinescripts and one feedback_item where I wrote [text_input], in that order.

First Inlinescript:

``````    import random
import numpy as np
from numpy import random as nprand

def create_matrix():
# determine the random number of ones and zeros to be put into the lists
c0_min = 20 # minimal number of zeros
c0_var = 5 # range of possible additional zeros
c0 = int(nprand.rand()*c0_var + c0_min) # count of zeros

c1_min = 20 # ones
c1_var = 20
c1 = int(nprand.rand()*c1_var + c1_min) # count of zeros

# construct a long list with ones and zeros of random order
# items
items = [0,]*c0 + [1,]*c1
random.shuffle(items)

# determine the length of the rows 1-4
# there is a minimal length + a variable length
# len of rows
lmin = 10
rowcount = 4
spacemax = 5

# determine the number of characters that are freely assignable (total number minus minimal length)
l_temp = c0+c1-lmin*rowcount # variable assignable characters

# divide residual characters with respect to random weights among the rows
l_weights = nprand.rand(4)
l_weights = l_temp*l_weights/sum(l_weights)
s_count = nprand.randint(0,spacemax,4)

# calculate the final lengths of the rows
r1 = lmin + int(l_weights[0])
r2 = lmin + int(l_weights[1])
r3 = lmin + int(l_weights[2])
r4 = lmin + int(l_weights[3])

# construct the strings by iterating the previously shuffled character list
s1 = ''.join([str(i) for i in [' ', ]*s_count[0] + items[:r1]]) + "\n"
s2 = ''.join([str(i) for i in [' ', ]*s_count[1] +  items[r1:(r1+r2)]]) + "\n"
s3 = ''.join([str(i) for i in [' ', ]*s_count[2] +  items[(r1+r2):(r1+r2+r3)]]) + "\n"
s4 = ''.join([str(i) for i in [' ', ]*s_count[3] +  items[(r1+r2+r3):]])

# return row 1-4, number of zeros, number of ones.
return {"rows": s1+s2+s3+s4, "c0":c0, "c1":c1}

m = create_matrix()
print m["rows"]
var.grid = m["rows"]
# this is mockup code
tmarker = 10
timer = 5
print m['c0']

var.kbresponse = int()
# end of mockup code
var.h = str(m["c0"])
#m["c0"] = count zero,..
``````

** Second Inlinescript:**

``````    from libopensesame import widgets
form = widgets.form(exp, cols=[1,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=var.grid, center=False)

nextButton = widgets.button(form, text='Next')
form.set_widget(title, (0,0), colspan=2)
form.set_widget(question1, (0,0))

form.set_widget(nextButton, (0,4), colspan=2)
form._exec

var.text_input = widgets.text_input(form, text="Wieviele Nullen befinden sich in dem Zahlenblock:", var='response',
return_accepts=True)
form.set_widget(var.text_input, (0,3))
form._exec()
``````

Any pointers would be great!!!

• Hi,

Attached the modified experiment that should work.

1) My Next Button doesn't work. It only works if I don't answer the question which is on the same form.- Counterproductive

This is because you have activated the option `return_accept = True`. In order to proceed, you have to hit return. If you set `return_accept` to False, then you have to press the next button in order to proceed.

2) I want to use my answer collected by the form to give feedback and use it all troughout the experiment. I put the variable name of the textinput [text_input] in a feedback Item after my form but it doesnt show anything.

Not sure what went wrong in your case, but in the attached example, it does work. So if you set `var = 'Response'`, then you can call the the variable with var.Response, or [Response] henceforth.

Hope this helps.

Eduard