Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhollmann committed Jan 10, 2025
1 parent 93ebaa9 commit 729e495
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CORE_API=
DC_PATH=
DF_LINK=
MOODLE_AUTH=
MOODLE_LINK=
VATGER_API_TOKEN=
VATGER_API_BASE=http://vatsim-germany.org/api/
OAUTH_CLIENT_ID=
OAUTH_CLIENT_SECRET=
OAUTH_AUTH=
Expand Down
25 changes: 12 additions & 13 deletions monitor/core_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

api_key = os.getenv('CORE_API')
df_link = os.getenv('DF_LINK')
moodle_auth = os.getenv('MOODLE_AUTH')
moodle_link = os.getenv('MOODLE_LINK')

vatger_api_base = os.getenv('VATGER_API_BASE')
vatger_api_token = os.getenv('VATGER_API_TOKEN')

headers = {
'Accept': 'application/json'
Expand Down Expand Up @@ -54,17 +55,15 @@ def get_rating(id: int) -> int:

def check_course_completion(course: dict, cid: int) -> bool:
course_id = course['link'].split('id=')[-1]
headers = {
'Authorization': moodle_auth
}
request = requests.get(
f'{moodle_link}/module_completed?module_id={course_id}&user_id={cid}',
headers=headers).json()
if request:
completion_state = request[0]['completionstate']
if completion_state == 2:
return True
return False
header = {"Authorization": f"Token {vatger_api_token}"}
r = requests.get(
f"{vatger_api_base}moodle/course/{course_id}/user/{cid}/results",
headers=header,
).json()
try:
return r["completed"]
except:
return False


@cached(cache=TTLCache(maxsize=float('inf'), ttl=60*60))
Expand Down

0 comments on commit 729e495

Please sign in to comment.