Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- token='your token here'
- def migrateContents(old_course_id, new_course_id):
- payload={'migration_type':'course_copy_importer','settings[source_course_id]': str(old_course), 'date_shift_options[remove_dates]': 'True'}
- r = requests.post('https://xxxx.instructure.com/api/v1/courses/'+ str(new_course)+ '/content_migrations/', params=payload, headers = {'Authorization': 'Bearer ' + token})
- data = r.json()
- #print data
- progress_url = data[u'progress_url']
- print "Migration URL is: " + str(progress_url)
- progress = 0
- while progress != 100:
- progress_check = requests.get(progress_url, headers = {'Authorization': 'Bearer ' + token})
- progress_result = progress_check.json()
- print "Migration Status is: " + str(data[u'workflow_state']) + ", | progress: " + str(progress_result[u'completion']) + "%"
- #print progress_result
- progress = progress_result[u'completion']
- time.sleep(20)
- if progress_result[u'completion'] == 100:
- print "------------------------------"
- print "Migration completed."
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement