Added notes on order of operations for mark learner are complete.
This commit is contained in:
@ -2,14 +2,25 @@ import Calls
|
|||||||
|
|
||||||
baseurl = Calls.BASEURL
|
baseurl = Calls.BASEURL
|
||||||
|
|
||||||
|
"""
|
||||||
|
Order of operations:
|
||||||
|
1. Get input of people and course (or ppl/courses) - retain UUIDs of both
|
||||||
|
2. Check current enrollments of people and courses
|
||||||
|
3. Create Project and Item
|
||||||
|
4. If enrollments don't exist, create enrollment object
|
||||||
|
5. If enrollments do exist, create course attempt object
|
||||||
|
6. Payload should mark at 100%.
|
||||||
|
7. Check project & resources.
|
||||||
|
8. Run migration.
|
||||||
|
"""
|
||||||
|
|
||||||
def get_people():
|
def get_people():
|
||||||
email = "norm@rsmsn.co"
|
email = "norm@rsmsn.co"
|
||||||
if type(email) is str:
|
if type(email) is str:
|
||||||
learner_uuid = __get_individual_person__(email)
|
learner_uuid = get_individual_person(email)
|
||||||
get_courses(learner_uuid)
|
get_courses(learner_uuid)
|
||||||
elif type(email) is list:
|
elif type(email) is list:
|
||||||
person_uuids = __get_group_person__(email)
|
person_uuids = get_group_person(email)
|
||||||
else:
|
else:
|
||||||
print("Couldn't recognize the type of data you're trying to use.")
|
print("Couldn't recognize the type of data you're trying to use.")
|
||||||
|
|
||||||
@ -17,23 +28,23 @@ def get_people():
|
|||||||
def get_courses(learner_uuid):
|
def get_courses(learner_uuid):
|
||||||
course = "Norm Manager Test"
|
course = "Norm Manager Test"
|
||||||
if type(course) is str:
|
if type(course) is str:
|
||||||
course_uuids = __get_individual_course__(course, learner_uuid)
|
course_uuids = get_individual_course(course, learner_uuid)
|
||||||
elif type(course) is list:
|
elif type(course) is list:
|
||||||
courses_uuids = __get_group_course__(course, learner_uuid)
|
courses_uuids = get_group_course(course, learner_uuid)
|
||||||
else:
|
else:
|
||||||
print("Couldn't recognize the type of data you're trying to use.")
|
print("Couldn't recognize the type of data you're trying to use.")
|
||||||
|
|
||||||
|
|
||||||
def __get_individual_course__(name, learner_uuid):
|
def get_individual_course(name, learner_uuid):
|
||||||
url = f"{baseurl}/courses?filter[name][eq]={name}"
|
url = f"{baseurl}/courses?filter[name][eq]={name}"
|
||||||
returned = Calls.get(url)
|
returned = Calls.get(url)
|
||||||
|
|
||||||
for items in returned["data"]:
|
for items in returned["data"]:
|
||||||
single_uuid = items["id"]
|
single_uuid = items["id"]
|
||||||
print(f"Cool. Course {single_uuid} exists. Checking enrollments.")
|
print(f"Cool. Course {single_uuid} exists. Checking enrollments.")
|
||||||
enrollment = __get_enrollment_status__(single_uuid, learner_uuid)
|
enrollment = get_enrollment_status(single_uuid, learner_uuid)
|
||||||
|
|
||||||
def __get_enrollment_status__(uuid, learner_uuid):
|
def get_enrollment_status(uuid, learner_uuid):
|
||||||
enrollment_url = f"{baseurl}/courses/{uuid}/enrollments?filter[person_id][eq]={learner_uuid}"
|
enrollment_url = f"{baseurl}/courses/{uuid}/enrollments?filter[person_id][eq]={learner_uuid}"
|
||||||
enrolled = Calls.get(enrollment_url)
|
enrolled = Calls.get(enrollment_url)
|
||||||
if enrolled['data'] == "":
|
if enrolled['data'] == "":
|
||||||
@ -55,7 +66,7 @@ def __get_enrollment_status__(uuid, learner_uuid):
|
|||||||
)"""
|
)"""
|
||||||
|
|
||||||
|
|
||||||
def __get_group_course__(list):
|
def get_group_course(list):
|
||||||
multiple_uuids = []
|
multiple_uuids = []
|
||||||
for person in email:
|
for person in email:
|
||||||
url = f"{baseurl}/people?filter[email][eq]={email}"
|
url = f"{baseurl}/people?filter[email][eq]={email}"
|
||||||
@ -65,7 +76,7 @@ def __get_group_course__(list):
|
|||||||
multiple_uuids.append(learner_uuid)
|
multiple_uuids.append(learner_uuid)
|
||||||
|
|
||||||
|
|
||||||
def __get_individual_person__(email):
|
def get_individual_person(email):
|
||||||
url = f"{baseurl}/people?filter[email][eq]={email}"
|
url = f"{baseurl}/people?filter[email][eq]={email}"
|
||||||
returned = Calls.get(url)
|
returned = Calls.get(url)
|
||||||
|
|
||||||
@ -80,7 +91,7 @@ def __get_individual_person__(email):
|
|||||||
print("Sorry bruv, but ya mate ain't activated yet. Can't do nuffin.")
|
print("Sorry bruv, but ya mate ain't activated yet. Can't do nuffin.")
|
||||||
|
|
||||||
|
|
||||||
def __get_group_person__(list):
|
def get_group_person(list):
|
||||||
multiple_uuids = []
|
multiple_uuids = []
|
||||||
for person in email:
|
for person in email:
|
||||||
url = f"{baseurl}/people?filter[email][eq]={email}"
|
url = f"{baseurl}/people?filter[email][eq]={email}"
|
||||||
@ -96,6 +107,6 @@ def __get_group_person__(list):
|
|||||||
return multiple_uuids
|
return multiple_uuids
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if name == "main":
|
||||||
get_people()
|
get_people()
|
||||||
# get_courses()
|
# get_courses()
|
||||||
|
|||||||
Reference in New Issue
Block a user