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)
|
||||
|
||||
@ -168,9 +168,10 @@ def get_specific_project():
|
||||
"""
|
||||
Returns results from a specific project.
|
||||
"""
|
||||
proj_id = "13aa7aed-3fb5-4488-9185-3befd0c1ae86"
|
||||
proj_id = "c8341414-58da-4291-8507-216da3fbf045"
|
||||
url = f"{BASEURL}/projects/{proj_id}"
|
||||
calls.get(url)
|
||||
ret = calls.get(url)
|
||||
print(ret)
|
||||
|
||||
def create_course():
|
||||
project_id = "6c7a21c2-de35-4b9d-9b80-a235401783af"
|
||||
@ -278,8 +279,8 @@ def create_attempt():
|
||||
"""
|
||||
|
||||
def get_item():
|
||||
project_id = "6c7a21c2-de35-4b9d-9b80-a235401783af"
|
||||
item_id = "80b95e38-78d1-44b9-8d9f-be96d9c7bf6e"
|
||||
project_id = "c8341414-58da-4291-8507-216da3fbf045"
|
||||
item_id = "4ce43bf5-0c73-427b-ad96-17b5aa8f16b2"
|
||||
print("Checking item")
|
||||
get_item_url = f"{BASEURL}/projects/{project_id}/items/{item_id}"
|
||||
get_item = calls.get(get_item_url)
|
||||
@ -307,9 +308,9 @@ if __name__ == "__main__":
|
||||
# delete_all_projects()
|
||||
# read_json_docs()
|
||||
# create_project()
|
||||
get_all_projects()
|
||||
# get_specific_project()
|
||||
# get_all_projects()
|
||||
get_specific_project()
|
||||
# create_enrollment()
|
||||
# check_resources()
|
||||
# get_item()
|
||||
get_item()
|
||||
# create_attempt()
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user