Achievements - Seluj78/IntraPy GitHub Wiki
To use the Achievement Handler
, you must import it first:
from IntraPy.achievement_handler import achievements
Once imported, Theses functions will be available to you:
get_achievements
def get_achievements(self, **options):
# Where options are the options you want to pass to get_achievements
Here's a list of all the parameters this function can take:
page_number
(An int, defining which page you want to get your accreditations from)page_size
(An int, defining the number of accreditations you want to get)pretty
(A boolean, False by default. Set to True if you want the output to be formatted (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it))from_page
(An int, The page you want to start your loop from)to_page
(An int, The page you want to end your loop to)sort
(A string. The sort field. Sorted by id asc by default. Please refer to the api documentation for more info on what sort can be applied)filter
(A Filtering on one or more fields Example: To filter on achievements with the id field matching a_value or another_value:filter="[id]=1,2"
. Please refer to the api documentation for more info on what filter can be applied)range
Select on a particular range. Example: To range on achievements with the title_id field between min_value and max_value:range="[title_id]=min_value,max_value"
page_number
variable has priority over from_page
and to_page
Please note that The list of accreditations will be returned in a list like so by default, if you print it:
[{'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}, {'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}, {'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX} ...]
Or, with pretty=True
:
[
{
"achievements": [],
"description": "XXX",
"id": 1,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX,
"visible": XXX
},
{
"achievements": [],
"description": "XXX",
"id": XXX,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX",
"visible": XXX
},
{
"achievements": [],
"description": "XXX",
"id": XXX,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX",
"visible": XXX
},
...
]
Here are a few examples to get you started:
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements()) # This will print all the achievements availables
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements(pretty=True)) # This will print all the achievements availables, in a formatted form (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements(page_number=2, page_size=5, pretty=True)) # This will return 5 achievements from page 2 in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements(from_page=2, to_page=5, pretty=True)) # This will all the achievements from page 2 to page 5 (with a default page size of 30) in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements(sort="description")) # This will print all the achievements availables, sorted by description
get_achievement_by_id
def get_achievements_by_id(self, achievement_id: int):
# Where accredidation_id is the id of the accredidation you want to get more info on.
This function will return the info on a peculiar id
you asked for.
The info will be returned on a json form:
{
"achievements": [],
"description": "XXX",
"id": 1,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX,
"visible": XXX
}
Of course here the list is formatted but if you execute this:
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievement_by_id(1))
you'll get something like this:
{'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}
pretty=True
isn't supported yet on get_achievement_by_id()
Important note: get_achievements_cursus
def get_achievements_cursus(self, cursus_id, **options):
# Where cursus_id is the cursus you want to get the achievements from
# and options are the options you want to pass to get_achievements_cursus
Here's a list of all the parameters this function can take:
page_number
(An int, defining which page you want to get your accreditations from)page_size
(An int, defining the number of accreditations you want to get)pretty
(A boolean, False by default. Set to True if you want the output to be formatted (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it))from_page
(An int, The page you want to start your loop from)to_page
(An int, The page you want to end your loop to)sort
(A string. The sort field. Sorted by id asc by default. Please refer to the api documentation for more info on what sort can be applied)filter
(A Filtering on one or more fields Example: To filter on achievements_cursus with the id field matching a_value or another_value:filter="[id]=1,2"
. Please refer to the api documentation for more info on what filter can be applied)range
Select on a particular range. Example: To range on achievements with the title_id field between min_value and max_value:range="[title_id]=min_value,max_value"
page_number
variable has priority over from_page
and to_page
Please note that The list of accreditations will be returned in a list like so by default, if you print it:
[{'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}, {'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}, {'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX} ...]
Or, with pretty=True
:
[
{
"achievements": [],
"description": "XXX",
"id": 1,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX,
"visible": XXX
},
{
"achievements": [],
"description": "XXX",
"id": XXX,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX",
"visible": XXX
},
{
"achievements": [],
"description": "XXX",
"id": XXX,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX",
"visible": XXX
},
...
]
Here are a few examples to get you started:
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_cursus(CURSUS_ID)) # This will print all the achievements availables in the specified cursus
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_cursus(CURSUS_ID, pretty=True)) # This will print all the achievements availables in the specified cursus, in a formatted form (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_cursus(CURSUS_ID, page_number=2, page_size=5, pretty=True)) # This will return 5 achievements in the specified cursus from page 2 in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_cursus(CURSUS_ID, from_page=2, to_page=5, pretty=True)) # This will all the achievements in the specified cursus from page 2 to page 5 (with a default page size of 30) in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_cursus(CURSUS_ID, sort="description")) # This will print all the achievements availables in the specified cursus, sorted by description
get_achievements_campus
def get_achievements_campus(self, campus_id, **options):
# Where campus_id is the campus you want to get the achievements from
# and options are the options you want to pass to get_achievements_campus
Here's a list of all the parameters this function can take:
page_number
(An int, defining which page you want to get your accreditations from)page_size
(An int, defining the number of accreditations you want to get)pretty
(A boolean, False by default. Set to True if you want the output to be formatted (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it))from_page
(An int, The page you want to start your loop from)to_page
(An int, The page you want to end your loop to)sort
(A string. The sort field. Sorted by id asc by default. Please refer to the api documentation for more info on what sort can be applied)filter
(A Filtering on one or more fields Example: To filter on achievements_campus with the id field matching a_value or another_value:filter="[id]=1,2"
. Please refer to the api documentation for more info on what filter can be applied)range
Select on a particular range. Example: To range on achievements with the title_id field between min_value and max_value:range="[title_id]=min_value,max_value"
page_number
variable has priority over from_page
and to_page
Please note that The list of accreditations will be returned in a list like so by default, if you print it:
[{'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}, {'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX}, {'id': XXX, 'name': 'XXX', 'description': 'XXX', 'tier': 'XXX', 'kind': 'XXX', 'visible': XXX, 'image': 'XXX', 'nbr_of_success': XXX, 'users_url': 'XXX', 'achievements': [], 'parent': XXX, 'title': XXX} ...]
Or, with pretty=True
:
[
{
"achievements": [],
"description": "XXX",
"id": 1,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX,
"visible": XXX
},
{
"achievements": [],
"description": "XXX",
"id": XXX,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX",
"visible": XXX
},
{
"achievements": [],
"description": "XXX",
"id": XXX,
"image": "XXX",
"kind": "XXX",
"name": "XXX",
"nbr_of_success": XXX,
"parent": XXX,
"tier": "XXX",
"title": XXX,
"users_url": "XXX",
"visible": XXX
},
...
]
Here are a few examples to get you started:
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_campus(CAMPUS_ID)) # This will print all the achievements availables in the specified campus
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_campus(CAMPUS_ID, pretty=True)) # This will print all the achievements availables in the specified campus, in a formatted form (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_campus(CAMPUS_ID, page_number=2, page_size=5, pretty=True)) # This will return 5 achievements in the specified campus from page 2 in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_campus(CAMPUS_ID, from_page=2, to_page=5, pretty=True)) # This will all the achievements in the specified campus from page 2 to page 5 (with a default page size of 30) in a pretty format (The pretty option, when set to True doesn't modifies the behaviour of the list nor how you can access it)
from IntraPy.achievement_handler import achievements
achievements = achievements.Achievements()
print(achievements.get_achievements_campus(CAMPUS_ID, sort="description")) # This will print all the achievements availables in the specified campus, sorted by description