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...
This commit is contained in:
@ -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):
|
||||
|
||||
Binary file not shown.
@ -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}")
|
||||
print(f"PostResponse: {post_response.text}")
|
||||
return post_response
|
||||
finally:
|
||||
# PP.pprint(json_get)
|
||||
|
||||
Reference in New Issue
Block a user