pybossa-api-helper.js
1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(function(pybossaApiHelper, $, undefined) {
var pybossaEndpoint = '';
var projectName = '';
function _getProjectId() {
return $.ajax({
url : pybossaEndpoint + '/api/project?short_name=' + projectName
});
}
function _getUserProgress() {
return $.ajax({
url : pybossaEndpoint + '/api/project/' + projectName + '/userprogress',
cache : false,
dataType : 'json'
});
}
function _getAnswers(projectId, userId) {
return $.ajax({
url : pybossaEndpoint + '/api/taskrun?project_id=' + projectId
+ '&user_id=' + userId
});
}
pybossaApiHelper.setup = function(endpoint, name) {
pybossaEndpoint = endpoint;
projectName = name;
}
pybossaApiHelper.getProjectId = function() {
return _getProjectId();
}
pybossaApiHelper.getUserProgress = function() {
return _getUserProgress();
}
pybossaApiHelper.getAnswers = function(projectId, userId) {
return _getAnswers(projectId, userId);
}
}(window.pybossaApiHelper = window.pybossaApiHelper || {}, jQuery));