def main():
	print "Enter the SIS IDs of each course, seperated by a comma and a space.\n" \
		"Eg. 7482, 4728, 5472"
	coursesisid = raw_input(">>> ").split(", ")
	
	params['per_page'] = 100
	
	for course in coursesisid:

		print "Processing..."

		request = jg.api_list(url + "/api/v1/courses/" \
			"sis_course_id:%s/groups" % course, params = params)
		group = request.call()

		headers = ["Name", "SIS ID", "Email", "Group"]

		filename = os.path.join(jg.fileout().get(), "enrollmentlistswithgroups/%s.csv" % course)

		with open(filename, "a") as fp:
			writer = csv.writer(fp)
			writer.writerow(headers)
		
		
		for items in group:

			print items[u'name']
		
			students = requests.get(url + "/api/v1/groups/%s/users" \
				% items[u'id'], params = params).json()

			for student in students:
	
		
				print student[u'name']
					
				# pulls each student's primary contact email
			
				studentdata = requests.get(url + "/api/v1/" \
					"users/sis_user_id:%s/profile" % student[u'sis_user_id'], params = params).json()

				row = [student[u'name'].encode('utf-8', 'ignore'), student[u'sis_user_id'], \
					studentdata[u'primary_email'], items[u'name']]

	
				with open(filename, "a") as fp:
					writer = csv.writer(fp)
					writer.writerow(row)

			### ADDS A BLANK LINE BETWEEN EACH GROUP
			with open(filename, "a") as fp:
					writer = csv.writer(fp)
					writer.writerow([""])
Exemple #2
0
def main():
    print "Enter the SIS IDs of each course, seperated by a comma and a space.\n" \
     "Eg. 7482, 4728, 5472"
    coursesisid = raw_input(">>> ").split(", ")

    params['per_page'] = 100

    for course in coursesisid:

        print "Processing..."

        request = jg.api_list(url + "/api/v1/courses/" \
         "sis_course_id:%s/groups" % course, params = params)
        group = request.call()

        headers = ["Name", "SIS ID", "Email", "Group"]

        filename = os.path.join(jg.fileout().get(),
                                "enrollmentlistswithgroups/%s.csv" % course)

        with open(filename, "a") as fp:
            writer = csv.writer(fp)
            writer.writerow(headers)

        for items in group:

            print items[u'name']

            students = requests.get(url + "/api/v1/groups/%s/users" \
             % items[u'id'], params = params).json()

            for student in students:

                print student[u'name']

                # pulls each student's primary contact email

                studentdata = requests.get(url + "/api/v1/" \
                 "users/sis_user_id:%s/profile" % student[u'sis_user_id'], params = params).json()

                row = [student[u'name'].encode('utf-8', 'ignore'), student[u'sis_user_id'], \
                 studentdata[u'primary_email'], items[u'name']]

                with open(filename, "a") as fp:
                    writer = csv.writer(fp)
                    writer.writerow(row)

            ### ADDS A BLANK LINE BETWEEN EACH GROUP
            with open(filename, "a") as fp:
                writer = csv.writer(fp)
                writer.writerow([""])
def main():
	print "Enter the SIS IDs of each course, seperated by a comma and a space.\n" \
		"Eg. 7482, 4728, 5472"
	coursesisid = raw_input(">>> ").split(", ")
	
	params['per_page'] = 50
	
	for course in coursesisid:

		print "Processing..."

		group = requests.get(url + "/api/v1/courses/" \
			"sis_course_id:%s/groups" % course, params = params)
		print group
		group = group.json()
		
		
		for items in group:

			print items[u'name']
		
			students = requests.get(url + "/api/v1/groups/%s/users" \
				% items[u'id'], params = params).json()

			row = [items[u'name']]
			row2 = [""]
			row3 = [""]
			for student in students:
		
				print student[u'name'].encode('utf-8', 'ignore')
		
				row.append(student[u'name'].encode('utf-8', 'ignore'))
				row2.append(student[u'sis_user_id'])

				studentdata = requests.get(url + \
					"/api/v1/users/sis_user_id:%s/profile" % student[u'sis_user_id'], params = params).json()
				row3.append(studentdata[u'primary_email'])
	
			filename = os.path.join(jg.fileout().get(), 
				"groupreports/%s.csv" % course)

			with open(filename, "a") as fp:
				writer = csv.writer(fp)
				writer.writerow(row)
				writer.writerow(row2)
				writer.writerow(row3)
				writer.writerow(["", ""])
Exemple #4
0
def main():
    print "Enter the SIS IDs of each course, seperated by a comma and a space.\n" \
     "Eg. 7482, 4728, 5472"
    coursesisid = raw_input(">>> ").split(", ")

    params['per_page'] = 50

    for course in coursesisid:

        print "Processing..."

        group = requests.get(url + "/api/v1/courses/" \
         "sis_course_id:%s/groups" % course, params = params)
        print group
        group = group.json()

        for items in group:

            print items[u'name']

            students = requests.get(url + "/api/v1/groups/%s/users" \
             % items[u'id'], params = params).json()

            row = [items[u'name']]
            row2 = [""]
            row3 = [""]
            for student in students:

                print student[u'name'].encode('utf-8', 'ignore')

                row.append(student[u'name'].encode('utf-8', 'ignore'))
                row2.append(student[u'sis_user_id'])

                studentdata = requests.get(url + \
                 "/api/v1/users/sis_user_id:%s/profile" % student[u'sis_user_id'], params = params).json()
                row3.append(studentdata[u'primary_email'])

            filename = os.path.join(jg.fileout().get(),
                                    "groupreports/%s.csv" % course)

            with open(filename, "a") as fp:
                writer = csv.writer(fp)
                writer.writerow(row)
                writer.writerow(row2)
                writer.writerow(row3)
                writer.writerow(["", ""])
def main():

    getallenrollments.params = params
    getallenrollments.url = url
    courses = getallenrollments.get_all_courses()

    to_write_lines = []
    modules_to_publish = {}
    # { course : {module : [item, item] } }

    for c in courses.items():

        #print "\n\nExamining course: " + c[0]
        assignments = requests.get(
            url + "/api/v1/courses/sis_course_id:%s/assignments" % c[1],
            params=params)

        assignments = assignments.json()

        for a in assignments:

            try:
                if not a['published']:
                    x = "\nCourse: " + c[0] + ", Assignment: " + a[
                        'name'] + " not published."
                    to_write_lines.append(x.encode('utf-8'))
                    print x
                #print a['submission_types']
                if "none" in a['submission_types']:
                    y = "\nCourse: " + c[0] + ", Assignment: " + a[
                        'name'] + " submission type is None."
                    print y
                    to_write_lines.append(y.encode('utf-8'))
            except KeyError:
                print a
    today = datetime.datetime.today().strftime("%d-%m-%Y")

    with open(
            os.path.join(jg.fileout().get(),
                         "assignmentchecker/%s.txt" % today), "w") as fp:
        for i in to_write_lines:
            fp.write(str(i))
def get_courses(campuslist):
	today = datetime.datetime.now().strftime("%d-%y") 
	
	filename = os.path.join(jg.fileout().get(), 
		"studentenrollment/enrollmentreport_%s.csv" % today)
	with open(filename, "w") as fp:
		for students in campuslist:
			#header denote name/sis id
			params["as_user_id"] = "sis_user_id:%s" % students[3]
			user_courses = requests.get(url + "/api/v1/courses", \
				params=params).json()

			student_data = [students[0], students[1], students[3]]
			print "\n" + str(student_data)
			for i in user_courses:
				if i[u'enrollment_term_id'] == 6163: ##### CHANGE TO CORRECT TERM ID
					print i['name']
					student_data.append(i['name'])
			writer = csv.writer(fp)
			writer.writerow(student_data)

	print "\nFile saved to %s.\n" % filename
Exemple #7
0
def get_list(course, header):

    coursedetails = requests.get(url + "/api/v1/courses/sis_course_id:%s" % course, \
     params = params).json()

    coursename = coursedetails['name']
    term = coursedetails['enrollment_term_id']
    students = requests.get(url + "/api/v1/courses/sis_course_id:%s/students" \
     % course, params = params)
    students = students.json()

    outputlocation = jg.fileout().get()

    filename = os.path.join(outputlocation, "enrollmentlists/%s/%s-%s.csv" \
      % ("TermID-"+str(term), coursename, course))
    dir = os.path.dirname(filename)

    if not os.path.isdir(dir):
        os.makedirs(dir)
    else:
        pass

    try:
        with open(filename, "w") as fp:
            writer = csv.writer(fp)
            writer.writerow(["Name", "SIS User ID", header])
            for i in students:
                try:
                    writer.writerow([i['name'].encode('utf-8', 'ignore'), \
                      i['sis_user_id'], ""])
                except KeyError:
                    writer.writerow([i['name'].encode('utf-8', 'ignore'), \
                      "", ""])
            print "\nSuccessfully saved Course %s student list to %s.\n" % (
                course, filename)

    except TypeError:
        print students
        print "\nAn error occured, unable to retrieve student list.\n"
def main():

	getallenrollments.params = params
	getallenrollments.url = url
	courses = getallenrollments.get_all_courses()
	
	to_write_lines = []
	modules_to_publish = {}
		# { course : {module : [item, item] } }
	
	for c in courses.items():

		#print "\n\nExamining course: " + c[0]
		assignments = requests.get(url + "/api/v1/courses/sis_course_id:%s/assignments" % c[1], params=params)
		
		assignments = assignments.json()
		
		for a in assignments:
			
			try:
				if not a['published']:
					x = "\nCourse: " + c[0] + ", Assignment: " + a['name'] + " not published."
					to_write_lines.append(x.encode('utf-8'))
					print x
				#print a['submission_types']
				if "none" in a['submission_types']:
					y = "\nCourse: " + c[0] + ", Assignment: " + a['name'] + " submission type is None."
					print y
					to_write_lines.append(y.encode('utf-8'))
			except KeyError:
				print a
	today = datetime.datetime.today().strftime("%d-%m-%Y")
	
	with open(os.path.join(jg.fileout().get(), 
				"assignmentchecker/%s.txt" % today), "w") as fp:
		for i in to_write_lines:
			fp.write(str(i))
Exemple #9
0
def main():

    getallenrollments.params = params
    getallenrollments.url = url
    courses = getallenrollments.get_all_courses()

    to_write_lines = []
    modules_to_publish = {}
    # { course : {module : [item, item] } }

    for c in courses.items():

        print "\n\nExamining course: " + c[0]
        modules = requests.get(
            url + "/api/v1/courses/sis_course_id:%s/modules" % c[1],
            params=params)
        modules = modules.json()

        for module in modules:
            if not module['published']:
                x = "\nModule group: " + module['name']
                to_write_lines.append(x)

                if c[1] not in modules_to_publish:
                    modules_to_publish[c[1]] = {module['id']: []}
                else:
                    modules_to_publish[c[1]][module['id']] = []
                print x

            submodules = requests.get(
                url + "/api/v1/courses/sis_course_id:%s/modules/%s/items" %
                (c[1], module["id"]),
                params=params)
            for m in submodules.json():
                if not m['published']:
                    y = "\n" + m['title'] + ": NOT published."
                    to_write_lines.append(y)
                    if c[1] not in modules_to_publish:
                        modules_to_publish[c[1]] = {}
                    if module['id'] in modules_to_publish[c[1]]:
                        modules_to_publish[c[1]][module['id']].append(m['id'])
                    else:
                        modules_to_publish[c[1]][module['id']] = [m['id']]
                    print y

    today = datetime.datetime.today().strftime("%d-%m-%Y")

    with open(os.path.join(jg.fileout().get(), "publisher/%s.txt" % today),
              "w") as fp:
        for i in to_write_lines:
            fp.write(str(i))

    print "\n\nPublish all unpublished modules and sub-items? Y for yes, any other key to quit."
    if raw_input(">>> ").lower() == "y":
        params['module[published]'] = True
        for course, modules in modules_to_publish.items():
            for module in modules.keys():
                r = requests.put(
                    url + "/api/v1/courses/sis_course_id:%s/modules/%s" %
                    (course, module),
                    params=params)
                r = r.json()
                print r['name'] + ": published = " + str(r['published'])

                for item in modules[module]:
                    r = requests.put(
                        url +
                        "/api/v1/courses/sis_course_id:%s/modules/%s/items/%s"
                        % (course, module, item),
                        params=params)
                    r = r.json()
                    try:
                        print r['title'] + ": published = " + str(
                            r['published'])
                    except KeyError:
                        print r
Exemple #10
0
def main():

	getallenrollments.params = params
	getallenrollments.url = url
	courses = getallenrollments.get_all_courses()
	
	to_write_lines = []
	modules_to_publish = {}
		# { course : {module : [item, item] } }
	
	for c in courses.items():

		print "\n\nExamining course: " + c[0]
		modules = requests.get(url + "/api/v1/courses/sis_course_id:%s/modules" % c[1], params=params)
		modules = modules.json()

		for module in modules:
			if not module['published']:
				x = "\nModule group: " + module['name']
				to_write_lines.append(x)
				
				if c[1] not in modules_to_publish:
					modules_to_publish[c[1]] = {module['id']:[]}
				else:
					modules_to_publish[c[1]][module['id']] = []
				print x
			
			submodules = requests.get(url + 
					"/api/v1/courses/sis_course_id:%s/modules/%s/items" 
					% (c[1], module["id"]), params=params)
			for m in submodules.json():
				if not m['published']:
					y = "\n" + m['title'] + ": NOT published."
					to_write_lines.append(y)
					if c[1] not in modules_to_publish:
						modules_to_publish[c[1]] = {}
					if module['id'] in modules_to_publish[c[1]]:
						modules_to_publish[c[1]][module['id']].append(m['id'])
					else:
						modules_to_publish[c[1]][module['id']] = [m['id']]
					print y
	
	today = datetime.datetime.today().strftime("%d-%m-%Y")
	
	with open(os.path.join(jg.fileout().get(), 
				"publisher/%s.txt" % today), "w") as fp:
		for i in to_write_lines:
			fp.write(str(i))

	print "\n\nPublish all unpublished modules and sub-items? Y for yes, any other key to quit."
	if raw_input(">>> ").lower() == "y":
		params['module[published]'] = True
		for course, modules in modules_to_publish.items():
			for module in modules.keys():
				r = requests.put(url + "/api/v1/courses/sis_course_id:%s/modules/%s"
					% (course, module), params = params)
				r = r.json()
				print r['name'] + ": published = " + str(r['published'])
			
				for item in modules[module]:
					r = requests.put(url + "/api/v1/courses/sis_course_id:%s/modules/%s/items/%s"
						% (course, module, item), params = params)
					r = r.json()
					try:
						print r['title'] + ": published = " + str(r['published'])
					except KeyError:
						print r