def scoreTeacherrmp(teacher): """ TODO: Docstring Description in english. Returns: Return type Parameters: parameter -- description """ rmp_label_enum = sdat.enums().get('rmp') #print(sdat.enums()) global DEBUG if teacher.get('rmpdata') == None: try: if DEBUG: print("Downloading missing RMP data for " + teacher['name']) snc.rateThisProfessor(teacher, instructors) except: print("Can't rate professor, and no data!") if teacher.get('rmpdata').get('nodata') == True: print("No RMP data availible.") return for criteria in ('overall', 'wouldtakeagain', 'difficulty', 'hottness'): print("{1:<42} {0:>5}".format(teacher['rmpdata'][criteria], rmp_label_enum[criteria]))
def multicompare(teachers): """ TODO: Docstring Description in english. Returns: Return type Parameters: parameter -- description """ ues_label_enum = sdat.enums().get('ues') tempdict = dict() percentages = dict() bad = [] if teachers == [None]: print("No valid teachers to compare [MCUES]") return for teacher in teachers: if teacher['data'].get('ues') == None: if not args.quiet: print("No UES data availible for " + teacher['name']) bad.append(teacher) if teacher == None: bad.append(teacher) percentages.update({teacher['name']: 0}) tempdict.update( {teacher['id']: { 'total': 0, 'percent': 0, 'percentstr': "" }}) for error in bad: teachers.remove(error) if teachers == []: print("No valid teachers to compare after removals.") return for criteria in range(0, 15): for teacher in teachers: percent = 0 #print(teacher['name']) for degree in range(0, 5): percent += teacher['data']['ues'][criteria][ 'degree' + str(degree + 1)] * (degree) tempdict[teacher['id']]['total'] = teacher['data']['ues'][ criteria]['total'] try: percent = percent / (tempdict[teacher['id']]['total'] * 4) except ZeroDivisionError: percent = 0 tempdict[teacher['id']]['percent'] = percent tempdict[teacher['id']]['percentstr'] = str(round( percent * 100, 2)) + "% " percentages.update({teacher['name']: percent}) sortedd = sorted(percentages, key=percentages.get, reverse=True)[:5] print("{0:<40} ".format(ues_label_enum[criteria]), end='') for teacher in sortedd: print("{0:<20} ".format(teacher), end='') print("")
def multicomparermp(teachers): """ TODO: Docstring Description in english. Returns: Return type Parameters: parameter -- description """ rmp_label_enum = sdat.enums().get('rmp') percentages = dict() bad = [] for teacher in teachers: percentages.update({teacher['name']: '0.0'}) if teacher.get('rmpdata') == None: try: if not args.quiet: print("Downloading missing RMP data for " + teacher['name']) if not args.offline: snc.rateThisProfessor(teacher, instructors) else: raise ValueError('OFFLINE') except: print("Can't rate professor, and no data!") bad.append(teacher) for error in bad: teachers.remove(error) bad = [] for teacher in teachers: if teacher.get('rmpdata').get('nodata') == True: #print("Removing teacher with missing data " + teacher['name']) bad.append(teacher) for error in bad: teachers.remove(error) if teachers == []: if not args.quiet: print("No valid teachers to compare [MCR]") return for criteria in ('overall', 'wouldtakeagain', 'difficulty', 'hottness'): for teacher in teachers: percent = teacher['rmpdata'][criteria] percentages.update({teacher['name']: percent}) #print(percentages) sortedd = sorted(percentages, key=percentages.get, reverse=(criteria != 'difficulty'))[:5] print("{0:<40} ".format(rmp_label_enum[criteria]), end='') for teacher in sortedd: print("{0:<20} ".format(teacher), end='') print()
def scoreTeacherues(teacher): """ TODO: Docstring Description in english. Returns: Return type Parameters: parameter -- description """ if teacher['data'].get('ues') == None: if not args.quiet: print("No UES data availible.") return print("## UES Survey data") print("Datapoints: " + str(uesdatapoints(teacher))) ues_label_enum = sdat.enums().get('ues') print( "{0:<40} {1:5}% {2:>5} [{3[0]:>3}, {3[1]:>3}, {3[2]:>3}, {3[3]:>3}, {3[4]:>3}]" .format("Criteria", "%", "σ", ["SD", "D", "N", "A", "SA"])) for criteria in range(0, 15): total = teacher['data']['ues'][criteria]['total'] score = {} for degree in range(0, 5): score[degree] = teacher['data']['ues'][criteria]['degree' + str(degree + 1)] percent = 0 for degree in range(0, 5): #print(str(percent) + " ", end='') percent += int(score[degree] * (degree)) try: percent = percent / (total * 4) except ZeroDivisionError: percent = 0 percent = round(percent * 100, 2) try: stdev = round( statistics.stdev(statistify(teacher['data']['ues'][criteria])), 2) except statistics.StatisticsError: stdev = '-' print( "{0:<40} {1:5}% {2:>5} [{3[0]:>3}, {3[1]:>3}, {3[2]:>3}, {3[3]:>3}, {3[4]:>3}]" .format(ues_label_enum[criteria], percent, stdev, score))
def multicomparelegacy(teacherlist): """ TODO: Docstring Description in english. Returns: Return type Parameters: parameter -- description """ global args for surveytype in ['1', '2', 'H']: label_enum = sdat.enums().get("legacy_" + surveytype) if label_enum == None: print( "CODING ERROR: Missing friendly enumeration labels for survey type " + surveytype) continue tempdict = dict() percentages = dict() teachers = list(teacherlist) bad = [] if teachers == [None]: if not args.quiet: print("No valid teachers to compare [MCL1]") continue for teacher in teachers: if teacher['data'].get(surveytype) == None: if not args.quiet: print("No v" + surveytype + " data availible for " + teacher['name']) bad.append(teacher) if teacher == None: bad.append(teacher) percentages.update({teacher['name']: 0}) tempdict.update( {teacher['id']: { 'total': 0, 'percent': 0, 'percentstr': "" }}) for error in bad: teachers.remove(error) if teachers == []: #if not args.quiet: print("No valid teachers to compare [MCL2]") continue sections = [] sections.append({ 'critrange': range(0, 22), 'degrange': range(0, 6), 'scorefmtstr': "{1:<40} {2:5}% [{0[0]:>3}, {0[1]:>3}, {0[2]:>3}, {0[3]:>3}, {0[4]:>3}, {0[5]:>3}] ", 'labels': ["EX", "VG", "GD", "FR", "PR", "VP"] }) sections.append({ 'critrange': range(22, 27), 'degrange': range(0, 7), 'scorefmtstr': "{1:<40} {2:5}% [{0[0]:>3}, {0[1]:>3}, {0[2]:>3}, {0[3]:>3}, {0[4]:>3}, {0[5]:>3}, {0[6]:>3}] ", 'labels': ["MH", "", "", "AVG", "ML", "", "ML"] }) for section in sections: for criteria in section['critrange']: for teacher in teachers: percent = 0 for degree in section['degrange']: percent += teacher['data'][surveytype][criteria][ 'degree' + str(degree)] * (degree - 1) tempdict[teacher['id']]['total'] = teacher['data'][ surveytype][criteria]['total'] try: percent = percent / (tempdict[teacher['id']]['total'] * 4) except ZeroDivisionError: percent = 0 tempdict[teacher['id']]['percent'] = percent tempdict[teacher['id']]['percentstr'] = str( round(percent * 100, 2)) + "% " percentages.update({teacher['name']: percent}) sortedd = sorted(percentages, key=percentages.get, reverse=True)[:5] print("{0:<40} ".format(label_enum[criteria]), end='') for teacher in sortedd: print("{0:<20} ".format(teacher), end='') print("")
def scoreTeacherlegacy(teacher): """ TODO: Docstring Description in english. Returns: Return type Parameters: parameter -- description """ if (legacydatapoints(teacher) > 1): print("Datapoints: " + str(legacydatapoints(teacher))) for surveytype in ['1', '2', 'H', 'C']: if teacher['data'].get(surveytype) == None: if not args.quiet: print("No v" + surveytype + " data availible.") continue else: print("## Survey v" + surveytype + " data") label_enum = sdat.enums().get("legacy_" + surveytype) if label_enum == None: print( "CODING ERROR: Missing friendly enumeration labels for survey type " + surveytype) continue sections = [] sections.append({ 'critrange': range(0, 22), 'degrange': range(0, 6), 'scorefmtstr': "{1:<40} {2:5}% {3[0]:<5} [{0[0]:>3}, {0[1]:>3}, {0[2]:>3}, {0[3]:>3}, {0[4]:>3}, {0[5]:>3}]", 'labels': ["VP", "PR", "FR", "GD", "VG", "EX"] }) sections.append({ 'critrange': range(22, 27), 'degrange': range(0, 7), 'scorefmtstr': "{1:<40} {2:5}% {3[0]:<5} [{0[0]:>3}, {0[1]:>3}, {0[2]:>3}, {0[3]:>3}, {0[4]:>3}, {0[5]:>3}, {0[6]:>3}]", 'labels': ["MH", "", "", "AVG", "ML", "", "ML"] }) for section in sections: print(section['scorefmtstr'].format(section['labels'], "Criteria", "%", ["σ"])) for criteria in section['critrange']: total = teacher['data'][surveytype][criteria]['total'] score = {} for degree in section['degrange']: score[degree] = teacher['data'][surveytype][criteria][ 'degree' + str(degree)] percent = 0 for degree in section['degrange']: percent += int(score[degree] * (degree)) try: percent = percent / (total * (len(section['labels'])) - 1) except ZeroDivisionError: percent = 0 try: stdev = round( statistics.stdev( statistify(teacher['data'][surveytype][criteria])), 2) except statistics.StatisticsError: stdev = '-' print(section['scorefmtstr'].format( score, label_enum[criteria], str(round(percent * 100, 2)), [stdev]))