From 299c725c31862a4efa1a63704f2481827bbf2b03 Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Wed, 4 Sep 2024 19:03:18 -0400 Subject: [PATCH] Ok, so if a user and a course exists, we've successfully created and enrollment and an attempt for the person. I guess we just have to try and push it now... --- .../mark_course_as_complete.py | 35 +++++++----------- .../utils/__pycache__/calls.cpython-310.pyc | Bin 1890 -> 1948 bytes .../Mark_Course_As_Complete/utils/calls.py | 2 +- .../Migration_tool/migration_playground.py | 15 ++++---- .../utils/__pycache__/calls.cpython-310.pyc | Bin 1482 -> 1482 bytes wan_ip.txt | 2 +- 6 files changed, 23 insertions(+), 31 deletions(-) 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 70887187..2f566324 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 @@ -151,16 +151,21 @@ def get_enrollment_status(uuid, learner_uuid): resource_check = check_resources() if resource_check['data'] != []: print("We're in! Enrollment confirmed. Let's create an attempt") - create_attempt() + create_item("course_attempts") else: print("Nice! We have an enrollment. So now we just need to update progress.") - create_attempt(mig_enroll_url["data"]) + check_item(mig_enroll_url["data"]) def check_item(itype): if itype not in items: - create_item(i_type= "attempts") + create_item(itype) + create_attempt_resource() + else: + create_attempt_resource() + +def create_attempt_resource(): print(f"Is there a project ID? {list(probject.values())[0]}") attempt_url = f"{baseurl}/migration/projects/{list(probject.values())[0]}/items/{list(items.values())[0]}/course_attempt_resources" print(attempt_url) @@ -168,7 +173,7 @@ def check_item(itype): formatted_now = now.strftime("%Y-%m-%d %H:%M:%S") new_attempt_payload = { "data": [ { - "type": "attempts", + "type": "course_attempts", "attributes": { "uuid": "1234567890", "display_name": f"{list(people.keys())[0]}'s Attempt for course {list(courses.keys())[0]}", @@ -192,20 +197,8 @@ def check_item(itype): } mig_attempt_url = f"{baseurl}migration/projects/{list(probject.values())[0]}/items/{list(probject.values())[0]}/enrollment_resources" mig_attempt_call = calls.post(attempt_url, new_attempt_payload) - print("**********") - print(f"MigAttemptURL") - print(mig_attempt_call) - print("**********") - check_resources() - - -""" - If the learner is enrolled, we can go straight to creating an attempt. - ( - "/v2/migration/projects/{project_id}/items/{item_id}/course_attempt_resources", - "post", - ) -""" + checking = check_resources() + print(checking) def check_resources(): @@ -238,10 +231,9 @@ def create_project(): def create_item(i_type): # Item Type Options: 'courses', 'sections', 'activities', 'people', 'enrollments', 'course_attempts', 'quiz_attempts', 'certificates', 'learning_path_attempts' - item_full_url = ( - f"{baseurl}/migration/{PROJ_URL}/{list(probject.values())[0]}/{ITEM_URL}" - ) + item_full_url = (f"{baseurl}/migration/{PROJ_URL}/{list(probject.values())[0]}/{ITEM_URL}") item_type = i_type + print(item_type) item_payload = { "data": { "type": "migration_items", @@ -251,7 +243,6 @@ def create_item(i_type): item_return = calls.post(item_full_url, item_payload) items[item_type] = item_return["data"]["id"] print(f"Created Item ID: { items[item_type] }") - print(probject) def get_group_course(list): 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 6ec7cea3b23c4af8afaf78b54374ab694cfc2c2e..2e07bcf1be45aaa54fefe8b0547806afca6dcb32 100644 GIT binary patch delta 232 zcmaFFH;11$pO=@50SLZ7y^;27Bd;wpn++oaLsjDB0On*{y(*3xrUh&Z8ERQ-Si%{? z8G;#D7)sbH6Brq4Ss59sBuki6m}^*PGo-N2Wo~9WIwNlXJoVu!@4{&1tOqjEs_#r?II5$vteTKvId_0RXi^Iy(RW delta 189 zcmbQk|A>z_pO=@50SNq$+(`Srk=K@)O@@(yp(=860CTdgS`|kP(*m}I47DsZEa42{ z48aU63?=N95sVDAtc(m*f+fr;%r&gD8B$p1GEe@%tjuUMS%gJdvQVq^Kn!N|tM$IkalfKh;H^8!|V VMn;Lr7uZyR