oTree Forum >

Loop over visible form fields in likert style, disregard field for tracking time

#1 by Jonas

Hey all,
for an experiment we need a page that contains a table with likert scales as its rows. I copied the code from here: https://otree.readthedocs.io/en/latest/forms.html . On this page I would also like to include an invisible field populated with a time measurement done in javascript. How do I include all fields in the template loop but the time field? Using an integer field for the time field results in the error "IntegerField' object is not iterable". Specifying an emtpy label and empty choices results in the table having one visible empty row

I tried jinja2 syntax (accessing loop.last), but your template language isn't jinja2 right? 

I also tried giving the template two separate form lists, but then I run into the problem described here:https://groups.google.com/g/otree/c/h01H9v3xI6g . I cant access the labels of the entries in the custom form list.  

I also cant just list all fields manually because i would like the length of the list of form to be variable.

I even tried to hide the last row with javascript...

Spent hours trying to solve this, would really appreciate help! :)

#2 by Jonas

Bump :)

Still wasnt able to fix this :S

#3 by Jonas

Sry! but still didn't solve this, so "bump" :S

#4 by Jonas

Found a solution!

Just using live pages now:

end_time = models.StringField(initial="-999", blank=True)

def live_method(player, data):
        player.end_time = data["time"]
function tracking() {
  var mat_time = new Date(); //creates new date object meaning the current time
  mat_time = mat_time.toISOString(); //transforms it to milliseconds

  liveSend({'time': mat_time})


Write a reply

Set forum username