Changed some migration scripts. Getting closed! Walmart notes.

This commit is contained in:
Norm Rasmussen
2024-09-03 18:34:32 -04:00
parent 0c3af4c0fd
commit 8385bd1240
6 changed files with 102 additions and 38 deletions

View File

@ -1044,3 +1044,9 @@ This could be anything from an incorrect redirect, image not being displayed cor
Walmart meeting with Jessica and Mayra. Questions from Jessica:
* Automatic PDF with publishing. 99% done!
* Feedback from drivers - does blob storage help this project? Not really. The mechanism between capturing and sending feedback has too many variables.
## 09-03-2024
Spark is changing quickly
It's hard for them to go from "we'll get it done!" to "Let's see if it is on the roadmap."
Brent - what can we do to minimize this anxiety?

View File

@ -27,3 +27,4 @@ SANDATA = "HdZFoXGCFpt8NnTOzIQY0kVDj"
LUMINATE_US = "p5fidpuedHaOlPnd8EcpxzQMG"
SKAN = "89qJQDaFl3DvIpSSOUC5PM9V6"
KARBON = "peQbnkfUnYLGPfIzyCxfLs634"
BLOOMERANG = "ewGDqLgsklMnytqzUka2wmgIi"

View File

@ -7,13 +7,13 @@ import Apikeys
import time
pp = pprint.PrettyPrinter(indent=4)
APIKEY = Apikeys.CHUBB
APIKEY = Apikeys.BLOOMERANG
HEADERS = {
"accept": "application/json",
"X-Api-Key": APIKEY,
}
BASEURL = "https://api.northpass.com/v2/"
IMPORTFILE = "/Users/normrasmussen/Downloads/CISA OLC Users 072924-080924.csv"
IMPORTFILE = "/Users/normrasmussen/Downloads/bloomerang-mass-import.csv"
def bulk_invite_and_group():
@ -55,14 +55,14 @@ def bulk_invite_and_group():
for person in people:
miniload = {"email": person, "groups": group}
payload_1.append(miniload)
# print(f"The {group} payload has {len(payload_1)}")
print(f"The {group} payload has {len(payload_1)}")
payload = {"data": {"attributes": {"people": payload_1}}}
response = requests.post(url, headers=HEADERS, json=payload)
print(f"Completed. Status code is {response.status_code}")
print(response.text)
print("Running add props from func...")
time.sleep(3)
add_props_from_func(people, data, group)
# print("Running add props from func...")
# time.sleep(3)
# add_props_from_func(people, data, group)
def add_props_from_func(people, data, group):

View File

@ -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()

View File

@ -31,6 +31,16 @@ tupee = [
("/v2/migration/projects", "get", "post"),
("/v2/migration/projects/{project_id}", "get", "delete", "patch"),
("/v2/migration/projects/{project_id}/items", "get", "post"),
# IMPORTANT: Each item is of a type that must be one of the following along with their follow up endpoints:
# 'courses' --> course_resources
# 'sections', --> section_resources
# 'activities', --> activity_recourds
# 'people', --> person_resources
# 'enrollments', --> enrollment_resources
# 'course_attempts', --> course_attempt_resources
# 'quiz_attempts', --> quiz_attempt_resources
# 'certificates',
# 'learning_path_attempts --> learning_path_attempt_resources
("/v2/migration/projects/{project_id}/items/{item_id}", "get", "delete"),
# *************************
# Get Resources (Done after you've added them from below)
@ -162,6 +172,30 @@ def get_specific_project():
url = f"{BASEURL}/projects/{proj_id}"
calls.get(url)
def create_course():
project_id = "6c7a21c2-de35-4b9d-9b80-a235401783af"
item_id = "80b95e38-78d1-44b9-8d9f-be96d9c7bf6e"
learner_uuid = "101d891d-f145-4cb2-8f7f-f0d8a90a743e"
course_uuid = "0d41bb57-bc65-4e05-adfd-58436ed0bd50"
now = datetime.now()
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
course_url = f"{BASEURL}/projects/{project_id}/items/{item_id}/course_resources"
course_payload = {
"data": [
{
"attributes": {
"type": "course",
"uuid": "",
"display_name": "",
"name": "",
"short_description": "",
"full_description": "",
"navigation_mode": "",
}
}
]
}
def create_enrollment():
# important!! Received this error:
@ -273,9 +307,9 @@ if __name__ == "__main__":
# delete_all_projects()
# read_json_docs()
# create_project()
# get_all_projects()
get_all_projects()
# get_specific_project()
# create_enrollment()
# check_resources()
get_item()
# get_item()
# create_attempt()