def SubmitReviewMain(): global Professors ProfessorKeys = Sort_dict(Professors, False) ProfessorKeys = [i.decode('utf-8') for i in ProfessorKeys] return render_template('SubmitReviewMain.html', DepartmentKeys=Sort_dict(Options[3], False), DepartmentOptions=Options[3], Professors=Professors, ProfessorKeys=ProfessorKeys)
def bestClass(department): courseList = getClassReviews(department, "") print courseList courses = set([course[2] for course in courseList[0]]) courses = list(courses) crn_index = -2 date_index = -1 rating_index = 4 # get each prof overall rating into dictionary, with key being the name courseDict = {} num_courses = len(courses) courseRating = [] * num_courses for j in range(0, num_courses): courseName = courses[j] print courseName courseRatingList = calculateClassRatings( getClassReviews("", str(courseName))) print courseRatingList courseRating = [ courseRatingList[rating_index], int(courseRatingList[crn_index]), int(courseRatingList[date_index]) ] courseDict[courseName] = courseRating courseDictSorted = Sort_dict(courseDict, 1) return courseDict, courseDictSorted
def easiestProf(department): #a = calculateProfRatings(getProfReviews("", "", department, "")) #return a profList = getProfReviews("", "", department, "") profs = [] for prof in profList: if prof not in profs: # change to add only names profs.append(prof) workload_index = 3 # get each prof overall rating into dictionary, with key being the name profDict = {} num_profs = len(profs) profRating = [] * num_profs for j in range(0, num_profs): profFirst = profs[j][1] profLast = profs[j][0] profName = profLast + profFirst profRatingList = calculateProfRatings( getProfReviews(profLast, profFirst, "", "")) profRating = profRatingList[workload_index] profDict[profName] = profRating profDictSorted = Sort_dict(profDict, 1) return profDict, profDictSorted
def bestClass(department): courseList = getClassReviews(department, "") courses = set([course[2] for course in courseList[0]]) courses = list(courses) crn_index = 6 date_index = 7 toughness_index = 3 interest_index = 4 # get each prof overall rating into dictionary, with key being the name courseDict = {} num_courses = len(courses) courseRating = [] * num_courses for j in range(0, num_courses): courseName = courses[j] courseRatingList = calculateClassRatings( getClassReviews("", str(courseName))) # Best determiend by average of toughess and interest courseRating = [ round((courseRatingList[toughness_index] + courseRatingList[interest_index]) / 2.0, 2), int(courseRatingList[crn_index]), int(courseRatingList[date_index]) ] courseDict[courseName] = courseRating courseDictSorted = Sort_dict(courseDict, 1) return courseDict, courseDictSorted
def easiestProf(department): #a = calculateProfRatings(getProfReviews("", "", department, "")) #return a profList = getDepartmentReviews(department) profs = [] profIDs = {} professors = GetAllProfessors() for prof in profList: if professors[prof[0] + prof[1]] not in profIDs: profs.append(prof) profIDs[professors[prof[0] + prof[1]]] = 1 workload_index = 3 grading_index = 4 # get each prof overall rating into dictionary, with key being the name profDict = {} num_profs = len(profs) profRating = [] * num_profs for j in range(0, num_profs): profFirst = profs[j][1] profLast = profs[j][0] profName = profLast + profFirst id = professors[profName] profRatingList = calculateProfRatings(getProfReviews(id)) # Average of workload and grading profRating = round( (profRatingList[workload_index] + profRatingList[grading_index]) / 2.0, 2) profDict[profName] = profRating profDictSorted = Sort_dict(profDict, 1) return profDict, profDictSorted
def bestProf(department): profList = getDepartmentReviews(department) professors = GetAllProfessors() profs = [] profIDs = {} for prof in profList: if professors[prof[0] + prof[1]] not in profIDs: profs.append(prof) profIDs[professors[prof[0] + prof[1]]] = 1 workload_index = 3 grading_index = 4 quality_index = 5 # get each prof overall rating into dictionary, with key being the name profDict = {} num_profs = len(profs) profRating = [] * num_profs for j in range(0, num_profs): profFirst = profs[j][1] profLast = profs[j][0] profName = profLast + profFirst # need to get prof ID id = professors[profName] profRatingList = calculateProfRatings(getProfReviews(id)) # Average of workload, grading, and quality profRating = round(profRatingList[quality_index], 2) profDict[profName] = profRating profDictSorted = Sort_dict(profDict, 1) return profDict, profDictSorted
def InstructorByDepartment(Department): Teachers = [] ID_dict = {} Department_Name = Options[3][Department] for prof, ID in Professors.items(): department = ProfDepartments.get(ID) if department and Department_Name in department and ID not in ID_dict: Teachers.append(prof) ID_dict[ID] = 1 Teachers = sorted(Teachers) Teachers_Sorted = Sort_dict(Teachers, False) Best_Teachers, Best_Teachers_Sorted = bestProf(Options[3][Department]) Easiest_Teachers, Easiest_Teachers_Sorted = easiestProf(Options[3][Department]) Best_Classes, Best_Classes_Sorted = bestClass(Options[3][Department]) for course in Best_Classes: Best_Classes[course][0] = convert_num_to_letter_grade( Best_Classes[course][0]) for course in Easiest_Teachers: Easiest_Teachers[course] = convert_num_to_letter_grade( Easiest_Teachers[course]) for course in Best_Teachers: Best_Teachers[course] = convert_num_to_letter_grade( Best_Teachers[course]) Crn_and_Term = {} for course in Best_Classes_Sorted: Course = getClassReviews('', course)[0][0] Crn_and_Term[Course[2]] = ((Course[-2], Course[-1])) Easiest_Classes, Easiest_Classes_Sorted = easiestClass(Options[3][Department]) for course in Easiest_Classes: Easiest_Classes[course][0] = convert_num_to_letter_grade( Easiest_Classes[course][0]) DepartmentOptions = Options[3] for option in DepartmentOptions: if DepartmentOptions[option] == Department: Department = option number_of_courses = len(Easiest_Classes_Sorted) number_of_teachers = len(Best_Teachers_Sorted) return render_template('Department.html', number_of_teachers = number_of_teachers, number_of_courses = number_of_courses, Teachers_Sorted=Teachers_Sorted, Best_Teachers_Sorted=Best_Teachers_Sorted, Best_Teachers=Best_Teachers, Easiest_Teachers=Easiest_Teachers, Easiest_Teachers_Sorted=Easiest_Teachers_Sorted, Department=Department, Teachers=Teachers, Best_Classes=Best_Classes, Best_Classes_Sorted=Best_Classes_Sorted, Easiest_Classes=Easiest_Classes, Easiest_Classes_Sorted=Easiest_Classes_Sorted, Crn_and_Term=Crn_and_Term)
def DisplayClasses(term, subject, credit, attr, divs, campus): global Professors global ProfDepartments ClassList = GetClasses(term, subject, credit, attr, divs, campus) didAddProf = False didAddDept = False # Checks to see if every instructor is is Professors dictionary. If they # are not, we add their names to the text file, and recalculate the Professors dictionary ProfsAdded = [] for course in ClassList: try: profs = course['Instructor'] Department = ''.join([char for char in course['Course - Sec'].split(' ')[0] if char.isalpha()]) P = [course['Teacher_Info'][i].split('P=')[-1] for i in range(len(course['Teacher_Info']))] for i in range(len(profs)): if profs[i] not in Professors: f = open('./TeacherList.txt', 'a') f.write('<OPTION VALUE="' + str(P[i]) + '">' + str(profs[i]) + '\n') f.close() didAddProf = True if P[i] not in ProfDepartments and (P[i], Department) not in ProfsAdded: f = open('./ProfessorDepartments.txt', 'a') #f.write(str(profs[i]) + '; Departments:'+ Department + '\n') f.write(str(P[i]) + '; Departments:' + Department + '\n') f.close() didAddDept = True ProfsAdded.append((P[i], Department)) if Department not in ProfDepartments[P[i]] and (P[i], Department) not in ProfsAdded: f = open('./ProfessorDepartments.txt', 'a') #f.write(str(profs[i]) + '; Departments:'+ Department + '\n') f.write(str(P[i]) + '; Departments:' + Department + '\n') f.close() didAddDept = True ProfsAdded.append((P[i], Department)) except KeyError: pass if didAddProf: Professors = GetAllProfessors() didAddProf = False if didAddDept: ProfDepartments = GetAllProfessorDepartments() didAddDept = False # Keys specifies what exactly we want to show up on our class search Keys = ['Title', 'Course - Sec','Instructor', 'View_Books', 'Cr', 'Max', 'Opn', 'CRN', 'Teacher_Info', 'When', 'Begin', 'End', 'Where'] return render_template('DisplayClassData.html', TermOptionKeys=Sort_dict(Options[0], True), TermOptions=Options[0], DivisionOptionKeys=Sort_dict(Options[1], False), DivisionOptions=Options[1], CampusOptionKeys=Sort_dict(Options[2], False), CampusOptions=Options[2], SubjectOptionKeys=Sort_dict(Options[3], False), SubjectOptions=Options[3], AttributeOptionKeys=Sort_dict(Options[4], False), AttributeOptions=Options[4], CreditsOptionKeys=Sort_dict(Options[5], False), CreditsOptions=Options[5], ClassList=ClassList, Keys=Keys)
def InstructorByDepartment(Department): # Place holder lists #Teachers = set([''.join([i[0], i[1]]) for i in getProfReviews('', '',Options[3][Department], '')]) Teachers = [ prof for prof in ProfDepartments if Options[3][Department] in ProfDepartments[prof] ] Teachers_Sorted = Sort_dict(Teachers, False) Best_Professors = bestProf(Options[3][Department]) Best_Teachers, Best_Teachers_Sorted = bestProf( Options[3][Department]) #Best_Professors[0], Best_Professors[1] Easiest_Teachers, Easiest_Teachers_Sorted = easiestProf( Options[3][Department]) Best_Classes, Best_Classes_Sorted = bestClass(Options[3][Department]) Crn_and_Term = {} for course in Best_Classes_Sorted: Course = getClassReviews('', course)[0][0] Crn_and_Term[Course[2]] = ((Course[-2], Course[-1])) Easiest_Classes, Easiest_Classes_Sorted = easiestClass( Options[3][Department]) DepartmentOptions = Options[3] for option in DepartmentOptions: if DepartmentOptions[option] == Department: Department = option return render_template('Department.html', Teachers_Sorted=Teachers_Sorted, Best_Teachers_Sorted=Best_Teachers_Sorted, Best_Teachers=Best_Teachers, Easiest_Teachers=Easiest_Teachers, Easiest_Teachers_Sorted=Easiest_Teachers_Sorted, Department=Department, Teachers=Teachers, Best_Classes=Best_Classes, Best_Classes_Sorted=Best_Classes_Sorted, Easiest_Classes=Easiest_Classes, Easiest_Classes_Sorted=Easiest_Classes_Sorted, Crn_and_Term=Crn_and_Term)
def ClassSearch(): if request.method == 'POST': Term = request.form['TermOptions'] Subject = request.form.getlist('SubjectOptions') if Subject[0] == "All": Subject = Options[3].values() Credit = request.form['CreditsOptions'] Attribute = request.form['AttributeOptions'] Division = request.form['DivisionOptions'] Campus = request.form['CampusOptions'] return DisplayClasses(Term, Subject, Credit, Attribute, Division, Campus) return render_template('class_search.html', TermOptionKeys=Sort_dict(Options[0], True), TermOptions=Options[0], DivisionOptionKeys=Sort_dict(Options[1], False), DivisionOptions=Options[1], CampusOptionKeys=Sort_dict(Options[2], False), CampusOptions=Options[2], SubjectOptionKeys=Sort_dict(Options[3], False), SubjectOptions=Options[3], AttributeOptionKeys=Sort_dict(Options[4], False), AttributeOptions=Options[4], CreditsOptionKeys=Sort_dict(Options[5], False), CreditsOptions=Options[5])
def eval(): return render_template('instructor_eval.html', DepartmentKeys=Sort_dict(GetOptions()[3], False), DepartmentOptions=GetOptions()[3])