TurkServer / turkserver-meteor

Web-based, real-time behavioral studies and experiments using Meteor
http://turkserver.readthedocs.io
MIT License
90 stars 23 forks source link

getTreatments(): get the treatment names from an assignment object serverside #86

Closed ElliotSalisbury closed 8 years ago

ElliotSalisbury commented 8 years ago

I needed to have access to the treatments of the different assignments during the initialization of an instance:

e.g.:

TurkServer.Instance.initialize(function () {
        //should only be two users, check the treatments of each user and record which one is blind
        var blindUserId = -1;
        var sightedAssistantId = -1;
        var users = this.instance.users();
        for (var i=0; i<users.length; i++){
            var userId = users[i];
            var assignment = TurkServer.Assignment.getCurrentUserAssignment(userId);
            var treatments = assignment.getTreatments();
            if(treatments.indexOf("blind_treatment") != -1) {
                blindUserId = userId
            }else{
                sightedAssistantId = userId;
            }
        }
}
mizzao commented 8 years ago

Thanks. Do you think it is in general more useful to have a structure like this, with just the treatment names, or to actually get the treatment key/value pairs as here: https://github.com/TurkServer/turkserver-meteor/blob/2c6e373e92e73036584eb8c39271f6eb9d97ab52/server/instance.js#L168

ElliotSalisbury commented 8 years ago

So when testing this (in the instance initialization) that function returned empty. I assumed it was returning treatments assigned to the instance object, not the assignment objects. To me, it didn't make sense that an instance could be assigned a treatment though?

mizzao commented 8 years ago

Both instances (a group of people at a particular point in time) and assignments (one person over the course of a task) can be assigned treatments. In the client, these all get merged together and all properties are visible.

This way, you can have treatments both active on "worlds" and "individuals", and determine UX based on some combination of them. The instance treatments may be useful when groups of people get assigned to a different task or interface within the same HIT, for example.

In any case, while accessing these treatments on the server we should come up with a consistent convention for them...or maybe both variants are useful.

ElliotSalisbury commented 8 years ago

Okay that makes sense. At the moment I think we can only retrieve instance treatments server side.

What would be the best convention here? A TurkServer.getTreatments(assignmentId) call that returns both?

mizzao commented 8 years ago

Let's try to think about this and hammer the details of a better API out in person when I visit next week!