def main():

	print "1: Use root account\n2: Type account ID"
	account_choice = int(raw_input(">>> "))
	if account_choice == 1:
		account = 86563
	elif account_choice == 2:
		account = int(raw_input("Please type the Account ID: "))
	else:
		print "Fail."
		sys.exit()

	print "\nCSV Format: | New Course Name | New Course SIS |"\
		" Source Course SIS | Start Date/Time | End Date/Time | Time Zone |"\
		"\nDate/time format: 'DD-MM-YYYYTHH:MM', timezone = 'UTC'"\
		"\nE.g.: '17-02-1991T07:35', timezone = 'EST'"
	courses = jg.dragfile()
	root_account = 86563
	term = jg.terms(root_account, url, params).choose()
	
	for line in courses:
	
		# [New name, New SIS, Source SIS, Start Date, End Date, Time Zone]
		# Datetime format: "17-02-1991T07:35", timezone = "EST"


		newcoursename = line[0]
		newcoursesis = line[1]
		sourcecoursesis = line[2]
		startdate, starttime = line[3].split('T')[0], line[3].split('T')[1]
		enddate, endtime = line[4].split('T')[0], line[4].split('T')[1]
		if line[5] == '':
			localtz = None
		else:
			localtz = line[5]
		
		if startdate != '':
			start = jg.canvasdate(startdate, starttime, localtz).get()
		
		if enddate != '':
			end = jg.canvasdate(startdate, starttime, localtz).get()

		new_sis = create_course(account, newcoursename, newcoursesis, \
			term, start, end)
	
		copy_course(account, new_sis, sourcecoursesis)
Exemple #2
0
def main():

    print "1: Use root account\n2: Type account ID"
    account_choice = int(raw_input(">>> "))
    if account_choice == 1:
        account = 86563
    elif account_choice == 2:
        account = int(raw_input("Please type the Account ID: "))
    else:
        print "Fail."
        sys.exit()

    print "\nCSV Format: | New Course Name | New Course SIS |"\
     " Source Course SIS | Start Date/Time | End Date/Time | Time Zone |"\
     "\nDate/time format: 'DD-MM-YYYYTHH:MM', timezone = 'UTC'"\
     "\nE.g.: '17-02-1991T07:35', timezone = 'EST'"
    courses = jg.dragfile()
    root_account = 86563
    term = jg.terms(root_account, url, params).choose()

    for line in courses:

        # [New name, New SIS, Source SIS, Start Date, End Date, Time Zone]
        # Datetime format: "17-02-1991T07:35", timezone = "EST"

        newcoursename = line[0]
        newcoursesis = line[1]
        sourcecoursesis = line[2]
        startdate, starttime = line[3].split('T')[0], line[3].split('T')[1]
        enddate, endtime = line[4].split('T')[0], line[4].split('T')[1]
        if line[5] == '':
            localtz = None
        else:
            localtz = line[5]

        if startdate != '':
            start = jg.canvasdate(startdate, starttime, localtz).get()

        if enddate != '':
            end = jg.canvasdate(startdate, starttime, localtz).get()

        new_sis = create_course(account, newcoursename, newcoursesis, \
         term, start, end)

        copy_course(account, new_sis, sourcecoursesis)
def get_all_courses():
	coursesid = int(raw_input("Please type the account ID of the account in which the courses are found: "))


	params["per_page"] = 100
	
	term = jg.terms(coursesid, url, params).choose()

	courses_url = url + "/api/v1/accounts/%s/courses" % coursesid

	all_courses = {}
	
	data = jg.api_list(courses_url, params).call()
	
	for course in data:
		if course['enrollment_term_id'] == term:
			all_courses[course['name']] = course['sis_course_id']

	return all_courses
Exemple #4
0
def get_all_courses():
    coursesid = int(
        raw_input(
            "Please type the account ID of the account in which the courses are found: "
        ))

    params["per_page"] = 100

    term = jg.terms(coursesid, url, params).choose()

    courses_url = url + "/api/v1/accounts/%s/courses" % coursesid

    all_courses = {}

    data = jg.api_list(courses_url, params).call()

    for course in data:
        if course['enrollment_term_id'] == term:
            all_courses[course['name']] = course['sis_course_id']

    return all_courses