Skip to content
Snippets Groups Projects
Commit 36717acb authored by Hans William Forbrigd's avatar Hans William Forbrigd
Browse files

Merge branch 'william_feature_getassignments' into 'main'

asfdds

See merge request mattiaae/idatt2900-072!7
parents 34325158 057eb629
No related branches found
No related tags found
No related merge requests found
class Node:
def __init__(self, data, children=[]):
self.root = root
self.children = children
...@@ -7,6 +7,7 @@ import typer ...@@ -7,6 +7,7 @@ import typer
import click import click
from typing import Optional from typing import Optional
from dotenv import load_dotenv from dotenv import load_dotenv
from anytree import Node, RenderTree
import os import os
...@@ -100,9 +101,9 @@ def get_children(data, url, acc, count: int = 0): ...@@ -100,9 +101,9 @@ def get_children(data, url, acc, count: int = 0):
else: else:
typer.echo('ja') typer.echo('ja')
id = data['id'] id = data['id']
url = f'{url}/{id}/children' old = f'{url}/{id}/children'
typer.echo(url) typer.echo(url)
response = requests.get(url, cookies = cookies) response = requests.get(old, cookies = cookies)
if response.status_code == 403 or response.status_code == 404: if response.status_code == 403 or response.status_code == 404:
typer.echo(response.json()['status']) typer.echo(response.json()['status'])
typer.echo(response.json()['message']) typer.echo(response.json()['message'])
...@@ -116,7 +117,7 @@ def get_children2(d, url): ...@@ -116,7 +117,7 @@ def get_children2(d, url):
key = 'hasChildren' key = 'hasChildren'
while key in d and d[key] == True: while key in d and d[key] == True:
id = d['id'] id = d['id']
url = f'{url}/{id}/children' url = f'{url}{id}/children'
typer.echo() typer.echo()
typer.echo(url) typer.echo(url)
typer.echo() typer.echo()
...@@ -134,6 +135,10 @@ def get_assignments(course_id: str = typer.Argument('_27251_1', help='The course ...@@ -134,6 +135,10 @@ def get_assignments(course_id: str = typer.Argument('_27251_1', help='The course
url = f'{base_url}courses/{course_id}/contents' url = f'{base_url}courses/{course_id}/contents'
x = requests.get(url, cookies=cookies) x = requests.get(url, cookies=cookies)
data = x.json()['results'] data = x.json()['results']
# parent_id = data[8]['id']
# name = data[8]['title']
# parent = Node(parent_id+name)
# print(parent['id'])
res = get_children(data[8], url, []) res = get_children(data[8], url, [])
# res = get_children2(data[2], url) # res = get_children2(data[2], url)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment