PyBossa download and task submission

(This is my first question on Stackoverflow, so I hope I'm right.)

I am trying to set up a CrowdCrafting.org project using the PyBOSSA infrastructure . I followed their tutorial to develop a project. The first parts seemed very understandable to me, creating a project and adding that the tasks worked fine. Then I created my own html page to present the task to users. Now the next step is to download tasks from the project, provide them to users and save their answers. Unfortunately, I do not understand how to do this. I will try to formulate some questions so that you understand my problem:

  • How can I try this? It seems that the only way is to update the code and then run pbs update_project
  • Where can I find documentation for PyBossa.js ? I just saw (in the tutorial and on other pages) that there are some functions, such as pybossa.taskLoaded(function(task, deferred){}); and pybossa.presentTask(function(task, deferred){}); . But I do not know how they work, and what else is. This page looks like it will contain documentation, but it does not contain (broken links or an empty index).
  • How to use the library? I want to: a) download the task, b) present it to the user, c) show my progress to the user and d) send an answer. So I think that I will need to name 4 different functions. But I do not know how to do this.

I look forward to any information from you.

Edit: 4. After looking at the sample project code, I don’t understand what kind of disqus it is. I think disqus is a forum software, but I am not sure about it, and I don’t know what it is about my project (or theirs).

Edit: As far as I understand, the main parts of the JS library are:

 pybossa.taskLoaded(function(task, deferred) { if ( !$.isEmptyObject(task) ) { deferred.resolve(task); } else { deferred.resolve(task); } }); pybossa.presentTask(function(task, deferred) { if ( !$.isEmptyObject(task) ) { // choose a container within your html to load the data into (depends on your layout and on the way you created the tasks) $("#someID").html(task.info.someName); // by clickin "next_button" save answer and load next task $("#next_button").click( function () { // save answer into variable here var answer = $("#someOtherID").val(); if (typeof answer != 'undefined') { pybossa.saveTask(task.id, answer).done(function() { deferred.resolve(); }); } }); } else { $("#someID").html("There are no more tasks to complete. Thanks for participating in ... "); } }); pybossa.run('<short name>'); 
+7
javascript crowdsourcing
source share
1 answer

I will try to answer your questions one by one:

  • You can run pbs update project or go to the project page> task> task presenter and edit the code there.

  • I believe this link works, and there you should find the information you want.

  • So, once you have created a project and added tasks and a presenter (the HTML that you created), you should include Javascript code inside the presenter itself. You just need to write these two functions: pybossa.taskLoaded(function(task, deferred){}); and pybossa.presentTask(function(task, deferred){}); pybossa.taskLoaded(function(task, deferred){}); and pybossa.presentTask(function(task, deferred){});

    In the first of them, you will need to write what you want to do as soon as the task is downloaded, but you are not ready to present it to the user (for example, download additional data related to tasks, except for the task itself, like images from external sites). once this is done, you should call deferred.resolve() , which is the way to tell pybossa.js that we ended up with the task load (either if it was successful or some kind of error occurred).

    After that, you should write a callback for the second one (pybossa.presentTask), where you configured everything for your task, like event handlers for sending a response to a button, and here where you have to put the user logic by completing the task and where you have to call pybossa.saveTask() . Once again, you should defer .resolve () at the end of the call to tell pybossa.js that the user has completed this task and will present the following. I would recommend that you do an inside callback for pybossa.saveTask(task).done(callbackFunc()) , so make sure you move on to the next task as soon as the current one is saved.

  • You may forget about this code discussion. These are only templates, provided that it includes some code that allows people to comment on tasks. Disquss is used for this, but it depends on whether you want to use it or not, so that you can safely remove this code.

+6
source share

All Articles