Skip to content

Commit 2ea7300

Browse files
authored
Merge pull request #46 from osmlab/dev
dev > master
2 parents 21e2d1d + 5d2591b commit 2ea7300

27 files changed

Lines changed: 703 additions & 229 deletions

docs/usage/functionality.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Functionality
22
=====================================================
3+
For usage examples check out `this link. <https://github.com/osmlab/maproulette-python-client/tree/dev/examples>`_
34

45
Module: project
56
-----------------------------------------------------

examples/add_tasks_to_challenge.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

examples/add_user_list_to_project.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/add_user_to_project.py

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@
77
# Create an API objects with the above config object:
88
api = maproulette.Challenge(config)
99

10-
# Creating a test challenge model with name and child task
10+
# Fetching a challenge based on challenge ID is easy. Specify the ID of the challenge you want:
11+
challenge_id = '12974'
12+
13+
# Printing response
14+
print(json.dumps(api.get_challenge_by_id(challenge_id), indent=4, sort_keys=True))
15+
16+
# We can also access a challenge by specifying the parent project ID and the challenge name:
17+
challenge_name = 'Test_Challenge'
18+
project_id = '2491'
19+
print(json.dumps(api.get_challenge_by_name(project_id=project_id,
20+
challenge_name=challenge_name), indent=4, sort_keys=True))
21+
22+
# We can access challenge statistics as well:
23+
print(json.dumps(api.get_challenge_statistics_by_id(challenge_id)))
24+
25+
# Accessing a challenge's tasks is easy too. Specify the ID of the challenge you want:
26+
print(json.dumps(api.get_challenge_tasks(challenge_id), indent=4, sort_keys=True))
27+
28+
# In order to create a new challenge, we can make our lives easier by using the Challenge Model
1129
challenge_data = maproulette.ChallengeModel(name='Test_Challenge_Name')
1230

1331
# Adding example description
@@ -29,7 +47,15 @@
2947
# Adding example overpass QL input for challenge
3048
challenge_data.overpassQL = open('data/Example_OverpassQL_Query', 'r').read()
3149

32-
print(challenge_data.overpassQL)
33-
3450
# Create challenge
3551
print(json.dumps(api.create_challenge(challenge_data)))
52+
53+
# If we want to add tasks to an existing challenge we can specify the challenge ID:
54+
challenge_id = 'TEST_ID'
55+
56+
# Provide a GeoJSON of the task data:
57+
with open('data/Example_Geometry.geojson', 'r') as data_file:
58+
data = json.loads(data_file.read())
59+
60+
# Printing response:
61+
print(api.add_tasks_to_challenge(data, challenge_id))

examples/create_project_from_model.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/find_project.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/find_user_by_username.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/get_challenge_by_id.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/get_challenge_statistics_by_id.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)