Exemplo n.º 1
0
def listSectionStatus():
    try:
        requested = request.form
        r= Registrar("UPENN_OD_emmK_1000220", "2g0rbtdurlau4didkj9schee95")
        course = r.search({'course_id': requested['course_id']})
        d = {}
        for x in course:
            l = []
            s = x["section_id"]
            print ("section" + s)
            if x["is_closed"]:
                l.append("Closed")
                print "is_closed"
            else:
                l.append("Open")
                print "is _open"
            if (x["activity_description"] == "Lecture"):
                p = x["instructors"][0]["name"]
            elif (x["activity_description"] == "Recitation"):
                p = x["primary_instructor"]
            else:
                p = ""
            print "professor: " + p
            l.append(p)
            t = x["first_meeting_days"]
            print "time: " + t
            l.append(t)
            d[s] = l
        return render_template("courses.html", d = d)
    except ValueError as e:
        return render_template("courses.html", d={})
Exemplo n.º 2
0
	def test_filter_out_courses_where_prereq_not_met(self):
		r = Registrar("UPENN_OD_emFc_1001364", "6kl4eonkquheuti65e32qick6l")
		courses_taken = ["CIS 160", "CIS 110"]
		cis121 = r.section('cis', '121', '001')
		cis262 = r.section('cis', '262', '001')
		all_courses = [cis121, cis262]
		courses_eligble_for = courseComparator.filter_out_courses_where_prereq_not_met(all_courses, courses_taken)
		self.assertEqual(len(courses_eligble_for), 1)
Exemplo n.º 3
0
	def test_multiple_courses_some_conflicts(self):
		r = Registrar("UPENN_OD_emFc_1001364", "6kl4eonkquheuti65e32qick6l")
		cis262 = r.section('cis', '262', '001')
		cis320 = r.section('cis', '320', '001')
		cis380 = r.section('cis', '380', '001')
		econ001 = r.section('econ', '001', '205')
		all_courses = [cis320, cis380, econ001]
		remaing_courses = courseComparator.filter_out_courses_that_overlap(cis262, all_courses)
		self.assertEqual(len(remaing_courses), 1)
def main():
	output = open('coursefile.txt', 'w')
	r = Registrar('UPENN_OD_emud_1000683', '1vkd6m32bo1polkdfup713dmte')
	search_params = r.search_params()
	departments = search_params['departments_map'].keys()
	for dept in departments:
		print dept
		courses_in_dept = r.department(dept)
		for course in courses_in_dept:
			output.write(str(course) + "\n")
	output.close()
Exemplo n.º 5
0
def get_opening(course):
    try:
        print "get_opening"
        r = Registrar("UPENN_OD_emmK_1000220", "2g0rbtdurlau4didkj9schee95")
        courses = r.search({'course_id': course['id']})
        # runs once
        for c in courses:
            course['is_closed'] = (c['is_closed'] == True)
            return course
    except OSError:
        print "error in get_opening"
    except ValueError as e:
        print e
Exemplo n.º 6
0
def get_opening(course):
    try:
    	print "get_opening"
    	r = Registrar("UPENN_OD_emmK_1000220", "2g0rbtdurlau4didkj9schee95")
    	courses = r.search({'course_id': course['id']})
    	# runs once
    	for c in courses:
		course['is_closed'] = (c['is_closed'] == True)
    		return course
    except OSError: 
    	print "error in get_opening"
    except ValueError as e:
	print e
Exemplo n.º 7
0
def load_all_courses():
    r = Registrar("UPENN_OD_emoG_1000340", "7vgj93rojjmbuh3rrsgs7vc2ic")
    courses = r.search({'course_id': ""})
        # runs once
    for c in courses:
        id = c['section_id']
	is_closed = (c['is_closed'] == True)
	try:
	    if (c["activity_description"] == "Lecture"):
	        instructor = c["instructors"][0]["name"]
            elif (c["activity_description"] == "Recitation"):
                instructor = c["primary_instructor"]
            else:
                instructor = ""
        except IndexError:
            instructor = ""
        print "adding: " + id
	db.hmset(id, {"id":id, "is_closed": is_closed, "instructor": instructor})
Exemplo n.º 8
0
def load_all_courses():
    r = Registrar("UPENN_OD_emoG_1000340", "7vgj93rojjmbuh3rrsgs7vc2ic")
    courses = r.search({'course_id': ""})
    # runs once
    for c in courses:
        id = c['section_id']
        is_closed = (c['is_closed'] == True)
        try:
            if (c["activity_description"] == "Lecture"):
                instructor = c["instructors"][0]["name"]
            elif (c["activity_description"] == "Recitation"):
                instructor = c["primary_instructor"]
            else:
                instructor = ""
        except IndexError:
            instructor = ""
        print "adding: " + id
        db.hmset(id, {
            "id": id,
            "is_closed": is_closed,
            "instructor": instructor
        })
 def setUp(self):
     self.registrar = Registrar("UPENN_OD_emFc_1001364",
                                "6kl4eonkquheuti65e32qick6l")
	def __init__(self):
		self.registrar = Registrar('UPENN_OD_emFc_1001364', '6kl4eonkquheuti65e32qick6l')
		os.environ['PCR_AUTH_TOKEN']='kdutFhMEbUaKdvQbcRKszEiwZeThFs'
class ScheduleBuilder(object):

	def __init__(self):
		self.registrar = Registrar('UPENN_OD_emFc_1001364', '6kl4eonkquheuti65e32qick6l')
		os.environ['PCR_AUTH_TOKEN']='kdutFhMEbUaKdvQbcRKszEiwZeThFs'


	def set_requirements(self, reqs):
		if reqs == None or len(reqs) == 0:
			return 'Must have at least one requirement'

		total_credits = 0
		for req in reqs:
			total_credits = total_credits + reqs[req]
		
		if total_credits > 6.5:
			return 'Why the f**k are you taking more than six and a half classes, go outside'

		self.req_numbers = reqs
		return True
		

	def find_all_classes(self, req_type, course_level_above=None, course_level_below=None, starts_after=None):
		# First enter default params for all courses

		print "Finding classes with params: "

		search_params = {}
		search_params['term'] = '2015C'
		search_params['fulfills_requiremement'] = req_type
		#search_params['status'] = 'O'
		#search_params['is_cancelled'] = False
		# if course_level_above is not None:
		# 	search_params['course_level_above'] = course_level_above
		# if course_level_below is not None:
		# 	search_params['course_level_below'] = course_level_below
		# if starts_after is not None:
		# 	search_params['starts_at_or_after_hour'] = starts_after

		print search_params

		all_courses = self.registrar.search(search_params)

		print "request finished"

		return all_courses

	# def add_ratings(courses):
	# 	for course in courses:
	# 		course_info = penncoursereview(CourseParser.get_course_department(course), CourseParser.get_course_number(course), \
	# 			CourseParser.get_section(course))

	# 		difficulty_rating = course_info./


	def enter_preferences(self, starts_after=None, ends_before=None, no_class_days=None, difficulty_limit=None, work_limit=None, lunch_break=None):
		self.all_valid_classes = []

		for req in self.req_numbers:
			print req
			self.all_valid_classes = self.all_valid_classes + self.get_all_courses(self.find_all_classes(req, starts_after=starts_after))
			
		self.filter_class_days(self.all_valid_classes, no_class_days)
		self.all_valid_classes.sort(cmp_course)


	def cmp_course(course1, course2):
		start_time1 = course1['meetings'][0]['start_time_24']
		start_time2 = course2['meetings'][0]['start_time_24']

		if start_time1 < start_time2:
			return -1
		elif start_time2 < start_time1:
			return 1
		else:
			return 0

	def filter_class_days(self, req_classes, no_class_days):
		for req in req_classes:
			current_classes = req_classes[req]
			for i in range(0, len(req_classes[req]) - 1):
				if self.class_meets_on_days(current_classes[i]):
					del current_classes[i]

	def find_schedule(self):
		result = self.find_schedule_recurse(self.all_valid_classes, self.req_numbers, [])

		return result

	def find_schedule_recurse(self, all_courses, req_numbers, selected_classes):

		if self.total_reqs_remaining(req_numbers) == 0:
			return selected_classes
		elif len(all_courses) == 0:
			return False

		for i in range(0, len(all_courses)):
			course_to_add = all_courses[i]

			# if course is not needed in requirements
			all_course_reqs = CourseParser.get_requirements(course_to_add)
			if course_to_add not in all_course_reqs:
				del all_courses[i]
				continue

			selected_classes.append(course_to_add)
			all_courses = courseComparator.filter_out_courses_that_overlap(course_to_add, all_courses)

			for req in all_course_reqs:
				req_numbers[req] = req_numbers[req] - 1

			return find_schedule_recurse(all_courses, req_numbers, selected_classes)

	def total_reqs_remaining(self, req_numbers):
		total = 0
		for req in req_numbers:
			total = total + req_numbers[req]

		return total

	def get_all_courses(self, generator):
		print "changing generator into list"
		all_courses_list = []
		num = 0
		for item in generator:
			all_courses_list.append(item)
			# print json.dumps(item, indent=4, sort_keys=True, separators=(', ', ': '))
			print num
			num = num + 1

		print "created list with " + len(all_courses_list) + " items"
		return all_courses_list
class ScheduleBuilder(object):
    def __init__(self):
        self.registrar = Registrar('UPENN_OD_emFc_1001364',
                                   '6kl4eonkquheuti65e32qick6l')
        os.environ['PCR_AUTH_TOKEN'] = 'kdutFhMEbUaKdvQbcRKszEiwZeThFs'

    def set_requirements(self, reqs):
        if reqs == None or len(reqs) == 0:
            return 'Must have at least one requirement'

        total_credits = 0
        for req in reqs:
            total_credits = total_credits + reqs[req]

        if total_credits > 6.5:
            return 'Why the f**k are you taking more than six and a half classes, go outside'

        self.req_numbers = reqs
        return True

    def find_all_courses(self,
                         req_type,
                         course_level_above=None,
                         course_level_below=None,
                         starts_after=None):
        # First enter default params for all courses

        print "Finding classes with params: "

        search_params = {}
        search_params['fulfills_requirement'] = req_type
        search_params['term'] = '2015C'
        search_params['status'] = 'O'
        search_params['is_cancelled'] = False
        # if course_level_above is not None:
        # 	search_params['course_level_above'] = course_level_above
        # if course_level_below is not None:
        # 	search_params['course_level_below'] = course_level_below
        # if starts_after is not None:
        # 	search_params['starts_at_or_after_hour'] = starts_after

        all_courses = self.registrar.search(search_params)

        print "request finished"

        return all_courses

    # def add_ratings(courses):
    # 	for course in courses:
    # 		course_info = penncoursereview(CourseParser.get_course_department(course), CourseParser.get_course_number(course), \
    # 			CourseParser.get_section(course))

    # 		difficulty_rating = course_info./

    def enter_preferences(self,
                          starts_after=None,
                          ends_before=None,
                          no_class_days=None,
                          difficulty_limit=None,
                          work_limit=None,
                          lunch_break=None):
        self.all_valid_courses = []

        for req in self.req_numbers:
            print req
            self.all_valid_courses = self.all_valid_courses + self.generator_to_list(
                self.find_all_courses(req, starts_after=starts_after))
        print "No class days"
        if no_class_days is not None:
            print 'befroe'
            no_class_days = CourseParser.convert_to_ascii(no_class_days)
            print "middle"
            print self.all_valid_courses
            self.all_valid_courses = self.filter_course_days(
                self.all_valid_courses, no_class_days)
            print "after"
        self.all_valid_courses.sort(self.cmp_course)
        print 'double smeag'
        return True

    def cmp_course(self, course1, course2):

        if len(course1['meetings']) == 0 and len(course2['meetings']):
            return 0
        elif len(course1['meetings']) == 0:
            return 1
        elif len(course2['meetings']) == 0:
            return -1

        start_time1 = course1['meetings'][0]['start_time_24']
        start_time2 = course2['meetings'][0]['start_time_24']

        if start_time1 < start_time2:
            return -1
        elif start_time2 < start_time1:
            return 1
        else:
            return 0

    def filter_course_days(self, courses, no_class_days):
        correct_courses = list()
        for i, course in enumerate(courses):

            if courseComparator.course_meets_on_days(course, no_class_days):
                continue
            else:
                correct_courses.append(course)

        return correct_courses

    def find_schedule(self):

        result = self.find_schedule_recurse(self.all_valid_courses,
                                            self.req_numbers, [])

        return result

    def find_schedule_recurse(self, all_courses, req_numbers,
                              selected_classes):

        if self.total_reqs_remaining(req_numbers) == 0:
            return selected_classes
        elif len(all_courses) == 0:
            return False

        for i in range(0, len(all_courses) - 1):

            print i
            course_to_add = all_courses[i]

            # if course is not needed in requirements
            all_course_reqs = CourseParser.get_requirements(course_to_add)

            fulfills_requirement = False
            for req in all_course_reqs:
                if req in req_numbers.keys() and req_numbers[req] > 0:
                    fulfills_requirement = True
                    break

            if not fulfills_requirement:
                print 'doesnt fulfill req'
                continue

            print 'ADDING COURSE'
            selected_classes.append(course_to_add)

            courses_after_selected = all_courses[i:]

            all_courses = courseComparator.filter_out_courses_that_overlap(
                course_to_add, courses_after_selected)

            for req in all_course_reqs:
                if req in req_numbers.keys() and req_numbers[req] > 0:
                    req_numbers[req] = req_numbers[req] - 1
                    break

            return self.find_schedule_recurse(courses_after_selected,
                                              req_numbers, selected_classes)

    def total_reqs_remaining(self, req_numbers):
        total = 0
        for req in req_numbers:
            total = total + req_numbers[req]

        return total

    def generator_to_list(self, generator):
        all_courses_list = []
        num = 0
        for item in generator:
            all_courses_list.append(item)

            num = num + 1

        return all_courses_list
Exemplo n.º 13
0
	def test_multiple_sections_of_same_course(self):
		r = Registrar("UPENN_OD_emFc_1001364", "6kl4eonkquheuti65e32qick6l")
		econ001001 = r.section('econ', '001', '001')
		econ001002 = r.section('econ', '001', '002')
		self.assertTrue(courseComparator.courses_overlap(econ001001, econ001002))
Exemplo n.º 14
0
	def test_single_course_conflict(self):
		r = Registrar("UPENN_OD_emFc_1001364", "6kl4eonkquheuti65e32qick6l")
		cis262 = r.section('cis', '262', '001')
		cis320 = r.section('cis', '320', '001')
		self.assertTrue(courseComparator.courses_overlap(cis262, cis320))
class ScheduleBuilder(object):

	def __init__(self):
		self.registrar = Registrar('UPENN_OD_emFc_1001364', '6kl4eonkquheuti65e32qick6l')
		os.environ['PCR_AUTH_TOKEN']='kdutFhMEbUaKdvQbcRKszEiwZeThFs'


	def set_requirements(self, reqs):
		if reqs == None or len(reqs) == 0:
			return 'Must have at least one requirement'

		total_credits = 0
		for req in reqs:
			total_credits = total_credits + reqs[req]
		
		if total_credits > 6.5:
			return 'Why the f**k are you taking more than six and a half classes, go outside'

		self.req_numbers = reqs
		return True
		

	def find_all_courses(self, req_type, course_level_above=None, course_level_below=None, starts_after=None):
		# First enter default params for all courses

		print "Finding classes with params: "

		search_params = {}
		search_params['fulfills_requirement'] = req_type
		search_params['term'] = '2015C'
		search_params['status'] = 'O'
		search_params['is_cancelled'] = False
		# if course_level_above is not None:
		# 	search_params['course_level_above'] = course_level_above
		# if course_level_below is not None:
		# 	search_params['course_level_below'] = course_level_below
		# if starts_after is not None:
		# 	search_params['starts_at_or_after_hour'] = starts_after

		all_courses = self.registrar.search(search_params)

		print "request finished"

		return all_courses

	# def add_ratings(courses):
	# 	for course in courses:
	# 		course_info = penncoursereview(CourseParser.get_course_department(course), CourseParser.get_course_number(course), \
	# 			CourseParser.get_section(course))

	# 		difficulty_rating = course_info./


	def enter_preferences(self, starts_after=None, ends_before=None, no_class_days=None, difficulty_limit=None, work_limit=None, lunch_break=None):
		self.all_valid_courses = []

		for req in self.req_numbers:
			print req
			self.all_valid_courses = self.all_valid_courses + self.generator_to_list(self.find_all_courses(req, starts_after=starts_after))
		print "No class days"
		if no_class_days is not None:
			print 'befroe'
			no_class_days = CourseParser.convert_to_ascii(no_class_days)
			print "middle"
			print self.all_valid_courses
			self.all_valid_courses = self.filter_course_days(self.all_valid_courses, no_class_days)
			print "after"
		self.all_valid_courses.sort(self.cmp_course)
		print 'double smeag'
		return True


	def cmp_course(self, course1, course2):

		if len(course1['meetings']) == 0 and len(course2['meetings']):
			return 0
		elif len(course1['meetings']) == 0:
			return 1
		elif len(course2['meetings']) == 0:
			return -1

		start_time1 = course1['meetings'][0]['start_time_24']
		start_time2 = course2['meetings'][0]['start_time_24']

		if start_time1 < start_time2:
			return -1
		elif start_time2 < start_time1:
			return 1
		else:
			return 0

	def filter_course_days(self, courses, no_class_days):
		correct_courses = list()
		for i, course in enumerate(courses):

			if courseComparator.course_meets_on_days(course, no_class_days):
				continue
			else:
				correct_courses.append(course)
				
		return correct_courses

	def find_schedule(self):

		result = self.find_schedule_recurse(self.all_valid_courses, self.req_numbers, [])


		return result

	def find_schedule_recurse(self, all_courses, req_numbers, selected_classes):

		if self.total_reqs_remaining(req_numbers) == 0:
			return selected_classes
		elif len(all_courses) == 0:
			return False

		for i in range(0, len(all_courses) - 1):

			print i
			course_to_add = all_courses[i]

			# if course is not needed in requirements
			all_course_reqs = CourseParser.get_requirements(course_to_add)

			fulfills_requirement = False
			for req in all_course_reqs:
				if req in req_numbers.keys() and req_numbers[req] > 0:
					fulfills_requirement = True
					break

			if not fulfills_requirement:
				print 'doesnt fulfill req'
				continue

			print 'ADDING COURSE'
			selected_classes.append(course_to_add)

			courses_after_selected = all_courses[i:]

			all_courses = courseComparator.filter_out_courses_that_overlap(course_to_add, courses_after_selected)

			for req in all_course_reqs:
				if req in req_numbers.keys() and req_numbers[req] > 0:
					req_numbers[req] = req_numbers[req] - 1
					break

			return self.find_schedule_recurse(courses_after_selected, req_numbers, selected_classes)

	def total_reqs_remaining(self, req_numbers):
		total = 0
		for req in req_numbers:
			total = total + req_numbers[req]

		return total

	def generator_to_list(self, generator):
		all_courses_list = []
		num = 0
		for item in generator:
			all_courses_list.append(item)

			num = num + 1

		return all_courses_list
	def test_single_course_conflict(self):
		r = Registrar("UPENN_OD_emFc_1001364", "6kl4eonkquheuti65e32qick6l")
		cis262 = r.section('cis', '262', '001')
		cis320 = r.section('cis', '320', '001')
		self.assertTrue(courseComparator.courses_overlap(cis262, cis320))
Exemplo n.º 17
0
	def test_shared_meeting_days_some(self):
		r = Registrar("UPENN_OD_emFc_1001364", "6kl4eonkquheuti65e32qick6l")
		cis262 = r.section('cis', '262', '001')
		cis380 = r.section('cis', '380', '001')
		shared_days = courseComparator.shared_meeting_days(cis262, cis380)
		self.assertEqual(len(shared_days), 2)
 def __init__(self):
     self.registrar = Registrar('UPENN_OD_emFc_1001364',
                                '6kl4eonkquheuti65e32qick6l')
     os.environ['PCR_AUTH_TOKEN'] = 'kdutFhMEbUaKdvQbcRKszEiwZeThFs'
Exemplo n.º 19
0
import redis
import os
from multiprocessing import Pool
from functools import partial
from twilio.rest import TwilioRestClient
import twilio
from penn.registrar import Registrar
import time

# setup database access
pool = redis.ConnectionPool(host='grideye.redistogo.com',
                            port=9195,
                            db=0,
                            password="******")
db = redis.Redis(connection_pool=pool)
r = Registrar("UPENN_OD_emoG_1000340", "7vgj93rojjmbuh3rrsgs7vc2ic")


# gets course info from course registrar, updates database, and texts users
def completeTask():
    #pool = Pool(5)
    #updated_courses = pool.map(get_opening, get_old_courses())
    updated_courses = [get_opening(course) for course in get_old_courses()]
    #pool.map(update_database, updated_courses)
    for course in updated_courses:
        update_database(course)
    for course in updated_courses:
        text_open_courses(course)


#  gets courses from redis database