Pybossa : How are answers stored and evaluated

270 Views Asked by At

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.

2

There are 2 best solutions below

2
chr4s On BEST ANSWER

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.

1
Daniel Lombraña González On

The answer by ch4s is correct. For the second part you will need to use the webhooks solution of PYBOSSA.

You will need to use the webhooks, to notify that microservice when all the task_runs have been achieved. Then, the system will download it, process it, and generate a result. As it uses Enki and the API of PYBOSSA you can do anything that you want:

  • Requesting more task_runs for the same task (in other words, increasing the task redundancy via n_answers field).
  • Send an email with the results to anyone that you want.
  • Update the social networks of your choice with the information about the results.
  • Use the new web push notifications of PYBOSSA to notify your users about a new result (we do this in Sr. Alergeno