Changed some migration scripts. Getting closed! Walmart notes.
This commit is contained in:
@ -45,25 +45,41 @@ Order of operations:
|
||||
# self.ppl_uuid = ppl_uuid
|
||||
# self.ppl_email = ppl_email
|
||||
|
||||
PPL_UUID = ""
|
||||
# probject = {
|
||||
# "My First Project" : "1234567890",
|
||||
# "items": {
|
||||
# "enrollments": "11111111",
|
||||
# "people": "2222222",
|
||||
# "courses": "33333333"
|
||||
# },
|
||||
# "courses": {
|
||||
# "course 1": "44444"
|
||||
# },
|
||||
# "people": {
|
||||
# "joe schmo": "5555555"
|
||||
# }
|
||||
# }
|
||||
probject = {
|
||||
"items": {},
|
||||
"courses": {},
|
||||
"people" : {}
|
||||
}
|
||||
ITEM_TYPES = ['courses', 'sections', 'activities', 'people', 'enrollments', 'course_attempts', 'quiz_attempts', 'certificates', 'learning_path_attempts']
|
||||
|
||||
PPL_URL = "people"
|
||||
PPL_EMAIL = ""
|
||||
COURSE_URL = "courses"
|
||||
COURSE_UUID = ""
|
||||
COURSE_NAME = ""
|
||||
ITEM_URL = "items"
|
||||
ITEM_ID = ""
|
||||
PROJ_URL = "projects"
|
||||
PROJ_ID = ""
|
||||
|
||||
|
||||
def get_people():
|
||||
email = "norm@rsmsn.co"
|
||||
if type(email) is str:
|
||||
learner = get_individual_person(email)
|
||||
PPL_UUID = learner[0]
|
||||
PPL_EMAIL = learner[1]
|
||||
get_courses(PPL_UUID)
|
||||
ppl_uuid = learner[0]
|
||||
ppl_email = learner[1]
|
||||
probject["people"][ppl_email] = ppl_uuid
|
||||
get_courses(ppl_uuid)
|
||||
elif type(email) is list:
|
||||
person_uuids = get_group_person(email)
|
||||
else:
|
||||
@ -85,10 +101,14 @@ def get_individual_course(name, learner_uuid):
|
||||
returned = Calls.get(url)
|
||||
|
||||
for items in returned["data"]:
|
||||
COURSE_UUID = items["id"]
|
||||
COURSE_NAME = items["attributes"]["name"]
|
||||
print(f"Cool. Course {COURSE_UUID} exists. Checking enrollments.")
|
||||
enrollment = get_enrollment_status(COURSE_UUID, learner_uuid)
|
||||
course_uuid = items["id"]
|
||||
course_name = items["attributes"]["name"]
|
||||
probject["courses"][course_name] = course_uuid
|
||||
print(f"Cool. Course {course_uuid} exists. Checking enrollments.")
|
||||
# enrollment = get_enrollment_status(course_uuid, learner_uuid)
|
||||
|
||||
# Use this to get a specific value from the courses sub-dict
|
||||
print(list(probject["people"].values())[0])
|
||||
|
||||
|
||||
def get_enrollment_status(uuid, learner_uuid):
|
||||
@ -105,13 +125,13 @@ def get_enrollment_status(uuid, learner_uuid):
|
||||
"data": {
|
||||
"attributes": {
|
||||
{"enrolled_at": formatted_now},
|
||||
{"course_id": COURSE_UUID},
|
||||
{"person_id": PPL_UUID},
|
||||
{"course_id": uuid},
|
||||
{"person_id": learner_uuid},
|
||||
}
|
||||
}
|
||||
}
|
||||
mig_enroll_url = Calls.post(
|
||||
f"{baseurl}migration/projects/{PROJ_ID}/items/{ITEM_ID}/enrollment_resources",
|
||||
f"{baseurl}migration/projects/{probject}/items/{item_id}/enrollment_resources",
|
||||
mig_enroll_payload,
|
||||
)
|
||||
print("Cool, enrollment resource has been created. Let's check that it exists.")
|
||||
@ -167,37 +187,40 @@ def check_resources():
|
||||
print(get_resources)
|
||||
|
||||
|
||||
def create_project_item():
|
||||
project_name = "Testing Course"
|
||||
item_name = "Courses to Mark as Complete"
|
||||
def create_project():
|
||||
project_name = "Testing Project 2"
|
||||
proj_payload = {
|
||||
"data":
|
||||
{
|
||||
"type": "migration_projects",
|
||||
"attributes": {"name": project_name},
|
||||
}
|
||||
|
||||
}
|
||||
proj_full_url = f"{baseurl}/migration/{PROJ_URL}"
|
||||
print(proj_full_url)
|
||||
tmp_p = Calls.post(proj_full_url, proj_payload)
|
||||
PROJ_ID = tmp_p["data"]["id"]
|
||||
print(f"Created Project Id: {PROJ_ID}")
|
||||
probject[project_name] = tmp_p["data"]["id"]
|
||||
print(f"Created Project: {probject}")
|
||||
i_type = "enrollments"
|
||||
create_item(i_type, project_name)
|
||||
|
||||
item_full_url = f"{baseurl}/migration/{PROJ_URL}/{PROJ_ID}/{ITEM_URL}"
|
||||
def create_item(i_type, project_name):
|
||||
print(project_name)
|
||||
# Item Type Options: 'courses', 'sections', 'activities', 'people', 'enrollments', 'course_attempts', 'quiz_attempts', 'certificates', 'learning_path_attempts'
|
||||
item_full_url = f"{baseurl}/migration/{PROJ_URL}/{probject[project_name]}/{ITEM_URL}"
|
||||
item_type = i_type
|
||||
item_payload = {
|
||||
"data":
|
||||
{
|
||||
"type": "migration_items",
|
||||
"attributes": {
|
||||
"type": "courses"
|
||||
"type": item_type
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
item_return = Calls.post(item_full_url, item_payload)
|
||||
ITEM_ID = item_return["data"]["id"]
|
||||
print(f"Created Item ID: { ITEM_ID }")
|
||||
probject['items'][item_type] = item_return["data"]["id"]
|
||||
print(f"Created Item ID: { probject['items'][item_type] }")
|
||||
print(probject)
|
||||
|
||||
|
||||
def get_group_course(list):
|
||||
@ -244,5 +267,5 @@ def get_group_person(list):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
create_project_item()
|
||||
create_project()
|
||||
get_people()
|
||||
|
||||
Reference in New Issue
Block a user