pybossa

Pybossa : How are answers stored and evaluated


I am working on a Pybossa based crowdsourcing platform. In the task presented I am stuck on the following code -

$(".btn-submit").off('click').on('click', function(){
        var answer = $("textarea#text").val();
        $("#viewport_" + task.id).hide();
        pybossa.saveTask(task.id, answer).done(function(data){
            deferred.resolve();
            $("#success").fadeIn();
            setTimeout(function() { $("#success").fadeOut() }, 2000);
        })
    });

This code is for fetching the reply and storing it as answer

What if I have many questions in a task to which user replies, structured as follows -

Q.1 This is question 1?
Q.2 This is question 2?
Q.3 This is question 3?

And the user replies to these in separate text forms -

answer1

answer2

answer3

How do I store multiple answers, in a way that Pybossa can also take weighted average of each while calculating results (For example via Golden Tasks.) I would also like to know how Pybossa evaluates answers.


Solution

  • I want to do a similar thing. The solution I have so far is to construct a Javascript object and save it into the taskrun results. Later I will parse this and extract the fields I want.

    I create an HTML form:

    <form action = "">
    <input placeholder="First Name" type="text" name="firstname">
    <input placeholder="Last Name" type="text" name="lastname">
    <select class="span2" name="gender">
       <option value="Male">Male</option>
       <option value="Female">Female</option>
    </select>
    <button class="btn btn-submit">Submit!</button>
    </form>
    

    Then in the pybossa.saveTask method construct an answer object:

    var firstname = $("input[name='firstname']").val();
    var lastname = $("input[name='lastname']").val();
    var gender = $("select[name='gender']").val();
    
    var answer = {
      firstname: firstname,
      lastname: lastname,
      gender: gender   
     };
    

    But this doesn't answer the second part of your question, ie how to enable PyBossa to take a weighted average of results.