diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/mark_course_as_complete.py b/Scripts/Migration_tool/Mark_Course_As_Complete/mark_course_as_complete.py index 2f566324..7791b71b 100644 --- a/Scripts/Migration_tool/Mark_Course_As_Complete/mark_course_as_complete.py +++ b/Scripts/Migration_tool/Mark_Course_As_Complete/mark_course_as_complete.py @@ -90,6 +90,7 @@ def get_people(): ppl_email = learner[1] people[ppl_email] = ppl_uuid get_courses(ppl_uuid) + create_person_resource() elif type(email) is list: person_uuids = get_group_person(email) else: @@ -100,6 +101,7 @@ def get_courses(learner_uuid): course = "Norm Manager Test" if type(course) is str: course_return = get_individual_course(course, learner_uuid) + create_course_resource() elif type(course) is list: courses_uuids = get_group_course(course, learner_uuid) else: @@ -242,7 +244,54 @@ def create_item(i_type): } item_return = calls.post(item_full_url, item_payload) items[item_type] = item_return["data"]["id"] + item_id = item_return["data"]["id"] print(f"Created Item ID: { items[item_type] }") + return item_id + +def create_person_resource(): + item_id = create_item("people") + persource_url = f"{baseurl}/migration/projects/{list(probject.values())[0]}/items/{item_id}/person_resources" + persource_payload = { + "data": [ + { + "type": "people", + "attributes": { + "uuid": f"{list(people.values())[0]}", + "display_name": f"{list(people.keys())[0]}", + "data": { + "first_name": "FIRST", + "last_name": "NAME", + "email": "norm@rsmsn.co" + } + } + }, + ] + } + pers_return = calls.post(persource_url, persource_payload) + print(f"Person Resource - {pers_return}") + +def create_course_resource(): + item_id = create_item("courses") + coursource_url = f"{baseurl}/migration/projects/{list(probject.values())[0]}/items/{item_id}/person_resources" + coursource_payload = { + "data": [ + { + "type": "courses", + "attributes": { + "uuid": f"{list(people.values())[0]}", + "display_name": f"{list(people.keys())[0]}", + "data": { + "name": "Norm's Manager Test", + "short_description": " Short Desc", + "full_description": " Full Desc", + "navigation_mode": "Free Form" + } + } + }, + ] + } + cours_return = calls.post(coursource_url, coursource_payload) + print(f"Course Resource - {cours_return}") def get_group_course(list): @@ -263,6 +312,9 @@ def get_individual_person(email): if items["attributes"]["registration_status"] == "activated": single_uuid = items["id"] single_email = items["attributes"]["email"] + # first_name = items["attributes"]["name"].split()[0] + # last_name = items["attributes"]["name"].split()[1] + # person = (first_name, last_name, single_email, single_uuid) print( f"Awesome. This dude is activated. Proceeding with learner {single_uuid}" ) @@ -287,7 +339,15 @@ def get_group_person(list): print("Sorry bruv, but ya mate ain't activated yet. Can't do nuffin.") return multiple_uuids +def start_migration(): + start_url = f"{baseurl}/migration/projects/{list(probject.values())[0]}/start_migration" + empty = "" + mig = calls.post(start_url, empty) + print(mig.text) + print(mig) + if __name__ == "__main__": create_project() get_people() + start_migration() diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/utils/__pycache__/calls.cpython-310.pyc b/Scripts/Migration_tool/Mark_Course_As_Complete/utils/__pycache__/calls.cpython-310.pyc index 2e07bcf1..d8d7481c 100644 Binary files a/Scripts/Migration_tool/Mark_Course_As_Complete/utils/__pycache__/calls.cpython-310.pyc and b/Scripts/Migration_tool/Mark_Course_As_Complete/utils/__pycache__/calls.cpython-310.pyc differ diff --git a/Scripts/Migration_tool/Mark_Course_As_Complete/utils/calls.py b/Scripts/Migration_tool/Mark_Course_As_Complete/utils/calls.py index 721afdcd..cc5bfb8c 100644 --- a/Scripts/Migration_tool/Mark_Course_As_Complete/utils/calls.py +++ b/Scripts/Migration_tool/Mark_Course_As_Complete/utils/calls.py @@ -39,7 +39,7 @@ def post(url, payload): return json_post except JSONDecodeError as e: print(f"Error occurred. Here's the info: {e}.") - print(f"PostResponse: {post_response.text}") + print(f"PostResponse: {post_response}") return post_response finally: # PP.pprint(json_get) diff --git a/wan_ip.txt b/wan_ip.txt index 3fd542b5..a80f7120 100644 --- a/wan_ip.txt +++ b/wan_ip.txt @@ -1 +1 @@ -174.229.208.71 +69.116.172.63