A migration workedcd ../.. Marking a learner as complete is done. Woohoo.

This commit is contained in:
Norm Rasmussen
2024-09-05 15:04:49 -04:00
parent 3643bcba35
commit c05336900d
102 changed files with 3030 additions and 121 deletions

View File

@ -120,12 +120,10 @@ def create_project():
"""
project_name = ""
payload = {
"data":[
"data": [
{
"type": "migration_projects",
"attributes": {
"name": project_name
},
"type": "migration_projects",
"attributes": {"name": project_name},
}
]
}
@ -137,16 +135,23 @@ def get_all_projects():
"""
Returns all projects.
"""
count = 0
project_ids = []
url = f"{BASEURL}/projects"
ret = calls.get(url)
while True:
count += 1
url = f"{BASEURL}/projects?page={count}"
ret = calls.get(url)
nextlink = ret["links"]
if ret["data"] != []:
for items in ret["data"]:
project_ids.append(items["id"])
print(f"{ items['attributes']['name'] } -- { items['id'] }")
else:
print("Looks like there are no projects created!")
if ret["data"] != []:
for items in ret["data"]:
project_ids.append(items["id"])
print(f"{ items['attributes']['name'] } -- { items['id'] }")
if "next" not in nextlink:
break
else:
print("Looks like there are no projects created!")
return project_ids
@ -173,6 +178,7 @@ def get_specific_project():
ret = calls.get(url)
print(ret)
def create_course():
project_id = "6c7a21c2-de35-4b9d-9b80-a235401783af"
item_id = "80b95e38-78d1-44b9-8d9f-be96d9c7bf6e"
@ -212,17 +218,17 @@ def create_enrollment():
enroll_payload = {
"data": [
{
"attributes": {
"uuid": "1234567890",
"display_name": "Enrollment Resource Test",
"type": "course",
"data": {
"enrolled_at": formatted_now,
"course_id": course_uuid,
"person_id": learner_uuid
"attributes": {
"uuid": "1234567890",
"display_name": "Enrollment Resource Test",
"type": "course",
"data": {
"enrolled_at": formatted_now,
"course_id": course_uuid,
"person_id": learner_uuid,
},
}
}
}
]
}
enroll_url = calls.post(
@ -258,7 +264,7 @@ def create_attempt():
"completed_at": formatted_now,
"completed_activities": [
{"uuid": "1111", "completed_at": formatted_now}
]
],
}
}
}
@ -278,6 +284,7 @@ def create_attempt():
)
"""
def get_item():
project_id = "c8341414-58da-4291-8507-216da3fbf045"
item_id = "4ce43bf5-0c73-427b-ad96-17b5aa8f16b2"
@ -287,14 +294,11 @@ def get_item():
print(get_item)
def check_resources():
PROJ_ID = "6c7a21c2-de35-4b9d-9b80-a235401783af"
ITEM_ID = "80b95e38-78d1-44b9-8d9f-be96d9c7bf6e"
print("Checking resources")
get_resources_url = (
f"{BASEURL}/projects/{PROJ_ID}/items/{ITEM_ID}/resources"
)
get_resources_url = f"{BASEURL}/projects/{PROJ_ID}/items/{ITEM_ID}/resources"
get_resources = calls.get(get_resources_url)
print(get_resources)
# if get_resources["data"] == []:
@ -305,12 +309,12 @@ def check_resources():
if __name__ == "__main__":
# delete_all_projects()
delete_all_projects()
# read_json_docs()
# create_project()
# get_all_projects()
get_specific_project()
# get_specific_project()
# create_enrollment()
# check_resources()
get_item()
# get_item()
# create_attempt()