def add_faculty(): """ This Function add a new faculty to the system (into pickle file) """ global count_f count_f+=1 print(count_f) name=input("Enter the name of the Faculty:") fac_id=input("Enter the Faculty Id:") while True: if len(fac_id)!=5: print("Invalid Faculty Id!!") fac_id=input("Enter the Faculty Id:") else: break if count_f==1: fac=Faculty(name,fac_id) l2.append(fac) with open("faculty_record.pkl","wb") as f: pickle.dump(l2,f) elif(check_faculty(fac_id)): print("Faculty already exists!!") else: fac=Faculty(name,fac_id) l2.append(fac) with open("faculty_record.pkl","wb") as f: pickle.dump(l2,f)
def find_all_coauthors(faculty_path): faculty_list = [] data = pd.read_excel(faculty_path) df = pd.DataFrame( data, columns=["Faculty", "Position", "Gender", "Management", "Area"]) file = open("pid.txt", "r") pid_list = file.readlines() pid_list_rstrip = [pid.replace("_", '/').rstrip() for pid in pid_list] for idx, df_line in df.iterrows(): faculty = Faculty(df_line["Faculty"], pid_list_rstrip[idx], df_line["Position"], df_line["Gender"], df_line["Management"], df_line["Area"]) faculty_list.append(faculty) coauthor_dict = {} pid_strings = [faculty.pid for faculty in faculty_list] for pid_string in pid_strings: xmlDoc = open(f'faculty_xml/{pid_string.replace("/","_")}.xml', 'r', encoding='utf-8') xmlDocData = xmlDoc.read() xmlDocTree = ET.XML(xmlDocData) coauthor_pid_list = [] for CA in xmlDocTree.iter('author'): if CA.attrib['pid'] not in pid_list_rstrip: #not in NTU coauthor_pid_list.append( CA.attrib['pid']) #repetition allowed for the question xmlDoc.close() coauthor_dict[pid_string] = coauthor_pid_list return (coauthor_dict)
def get_coworker_dict(faculty_path): faculty_list = [] data = pd.read_excel(faculty_path) df = pd.DataFrame( data, columns=["Faculty", "Position", "Gender", "Management", "Area"]) file = open("pid.txt", "r") pid_list = file.readlines() pid_list_rstrip = [pid.replace("_", '/').rstrip() for pid in pid_list] for idx, df_line in df.iterrows(): faculty = Faculty(df_line["Faculty"], pid_list_rstrip[idx], df_line["Position"], df_line["Gender"], df_line["Management"], df_line["Area"]) faculty_list.append(faculty) coauthor_dict = {} pid_strings = [faculty.pid for faculty in faculty_list] for pid_string in pid_strings: file = open(f'faculty_xml/{pid_string.replace("/","_")}.xml', 'r', encoding='utf-8') content = BeautifulSoup(file, "lxml") file.close() coauthor_pane = content.find("coauthors") coauthors = coauthor_pane.findAll("na") coauthor_pid_list = [] for coauthor in coauthors: try: if coauthor["pid"] in pid_list_rstrip: coauthor_pid_list.append(coauthor["pid"]) except: continue coauthor_dict[pid_string] = coauthor_pid_list return (coauthor_dict)
def getFaculty(self, netid): query = "PREPARE stmt(text) AS " \ "SELECT * FROM faculty WHERE netid = $1;" \ "EXECUTE stmt('" + netid.strip() + "');" result = Database.connectDB(self, query) if not result: return None faculty = Faculty(netid, result[0][1]) return faculty
def get_faculty_list(faculty_path): faculty_list = [] data = pd.read_excel(faculty_path) df = pd.DataFrame( data, columns=["Faculty", "Position", "Gender", "Management", "Area"]) file = open("pid.txt", "r") pid_list = file.readlines() pid_list_rstrip = [pid.replace("_", '/').rstrip() for pid in pid_list] for idx, df_line in df.iterrows(): faculty = Faculty(df_line["Faculty"], pid_list_rstrip[idx], df_line["Position"], df_line["Gender"], df_line["Management"], df_line["Area"]) faculty_list.append(faculty) return faculty_list
def find_area_with_pid(pid, faculty_path): area_list = [] data = pd.read_excel(faculty_path) df = pd.DataFrame( data, columns=["Faculty", "Position", "Gender", "Management", "Area"]) file = open("pid.txt", "r") pid_list = file.readlines() pid_list_rstrip = [pid.replace("_", '/').rstrip() for pid in pid_list] for idx, df_line in df.iterrows(): area = Faculty(df_line["Area"], pid_list_rstrip[idx], df_line["Faculty"], df_line["Position"], df_line["Gender"], df_line["Management"]) area_list.append(area) for area in area_list: # print(area) if (area.pid == pid): return area.name
def main(): # create each sort of person person = Person('woman', 'Latinx', 23, 'Rosario Alejandro') student = Student('person', 'Black', 20, 'Alex Aaron', 'Women\'s Studies', 'Spelman College') faculty = Faculty('woman', 'Black', 35, 'Dr. Ira Ingram', 'Philosophy', 'Intro to Philosophy', 'Ethics of Gender', 'Critical Thinking') worker = Worker('man', 'Japanese', 27, 'Todoroki Shouto', 'Hero', 300000) # put them in a list people = [person, student, faculty, worker] # print all their info for person in people: print(person)
from faculty import Faculty from Student import Student from FacultyStudent import FacultyStudent f1 = Faculty("fac1", "ece") f2 = Faculty("fac2", "cse") s1 = Student("asd", 45) s2 = Student("praveen", 34) fac = [] for i in fac: fac.append()
c = Coordinator() name = input("Enter Name of the Coordinator") cid = input("Enter your Coordinator Id") c.add_yourself(name, cid) else: print("Wrong Password Entered") elif key == "4": password = input("Enter the Faculty Password") if password == "fac123": work = input( "Which type of faculty you want to enter 1:Permanent Faculty \n 2:Visiting Faculty" ) f = Faculty() if work == "1": name = input("Enter Faculty name here") fieldid = input("Enter field Id here") salary = input("Enter Your Salary") f.add_faculty_permanent(name, fieldid, salary) elif work == "2": name = input("Enter Faculty name here") fieldid = input("Enter field Id here") salary = input("Enter Your Salary") f.add_faculty_visiting(name, fieldid, salary) else: print("Wrong Choice") else: print("You have Entered Wrong Password")
c.request_to_ccs("fdfd") elif work == "3": c.get_request_for_fresher_training("dfdf") else: print("Wrong Choice") else: print("You have Entered Wrong Password") elif key == "3": password = input("Enter the Faculty Password") if password == "fac123": f = Faculty() work = input( "What do you want \n 1:To Appoint me \n 2:Remove appointment ") if work == "1": f.to_appoint_me("sdasd") elif work == "2": f.remove_appointment("dsd") else: print("Wrong Choice") else: print("You have Entered Wrong Password") else: print("Wrong key pressed")
def main(): mydb = mysql.connector.connect(host="localhost", user="******", password="******", database="smarttimetabling") mycursor = mydb.cursor() mycursor.execute("SELECT id,dept_name,semester FROM section;") myresult = mycursor.fetchall() #print(type(myresult)) #print(myresult) sections = [] for x in myresult: s = Section(x[0], x[1], x[2]) sections.append(s) # for y in sections: # print(y) odcourses = [] electives = [] labcourses = [] theorycourses = [] allcourses = [] mycursor.execute( "SELECT id,l,p,c from Course WHERE id IN (SELECT subject_id FROM enrols where dept_name='CSE' and semester = 5 and substr(subject_id,3,3)!='CSE' and length(subject_id)=8);" ) myresult = mycursor.fetchall() for x in myresult: c = Course(x[0], x[1], x[2], x[3]) odcourses.append(c) # for y in odcourses: # print(y) mycursor.execute( "SELECT id,l,p,c from Course WHERE id IN (SELECT course_id from elective WHERE e_id IN (SELECT subject_id FROM enrols where dept_name='CSE' and semester = 5 and length(subject_id)=5));" ) myresult = mycursor.fetchall() for x in myresult: c = Course(x[0], x[1], x[2], x[3]) electives.append(c) # for y in electives: # print(y) mycursor.execute( "SELECT id,l,p,c from Course INNER JOIN Enrols ON Course.ID = Enrols.Subject_ID WHERE Course.p>0 and enrols.dept_name='CSE' and enrols.semester = 5;" ) myresult = mycursor.fetchall() for x in myresult: c = Course(x[0], x[1], x[2], x[3]) labcourses.append(c) print("LC", labcourses) # for y in labcourses: # print(y) mycursor.execute( "SELECT id,l,p,c from Course INNER JOIN Enrols ON Course.ID = Enrols.Subject_ID WHERE Course.type IN ('Theory', 'Project based') and enrols.dept_name='CSE' and enrols.semester = 5 and Course.dept_name='CSE';" ) myresult = mycursor.fetchall() for x in myresult: c = Course(x[0], x[1], x[2], x[3]) theorycourses.append(c) print("TC", theorycourses) # for y in theorycourses: # print(y) for z in odcourses: allcourses.append(z) for z in labcourses: allcourses.append(z) for z in theorycourses: allcourses.append(z) faculties = [] classrooms = [] labs = [] print(allcourses) allocid = 50000 print("s", sections) for s in sections: for c in allcourses: mycursor.execute( "SELECT ID FROM courseseligible where Domain_course = \'" + c.Cid + "\';") myresult = mycursor.fetchall() fiter = len(faculties) for x in myresult: flag0 = 0 for y in faculties: if y.Fid == x: flag0 = 1 break if flag0 == 0: f = Faculty(x) faculties.append(f) # for z in faculties: # print(z) iter0 = len(faculties) - fiter #print(c.Cp, type(c.Cp)) if c.Cp == 2: while (iter0): # PSlots = (S.SlotsFree n T.SlotsFree) - {4,10,16,22,28,6,12,18,24,30} PSlots = list((set(s.slotfree) & set(faculties[fiter].slotfree)) - set([4, 10, 16, 22, 28, 6, 12, 18, 24, 30])) while (len(PSlots) > 0): s1, s2 = random_slot(PSlots) if s1 == -1: fiter += 1 iter0 -= 1 # handle no teacher possible to allocate else: La = labAllocate(mydb, c, s1, s2, labs, s, f, allocid) if La != -1: allocid = La iter0 = 0 break else: PSlots = list(set(PSlots) - set([s1, s2])) if c.Cl > 0: slotc = [] slotd = [] while (iter0): PSlots = list( (set(s.slotfree) & set(faculties[fiter].slotfree))) slotc.clear() slotd.clear() iter4 = len(PSlots) iter4 = iter4**2 while (len(PSlots) > 0): slotc.clear() slotd.clear() for k in range(c.Cc): while (iter4): m = random.choice(PSlots) ts1, day2 = getTsDay(m) iter4 -= 1 if (day2 not in slotd): break slotd.append(day2) slotc.append(m) if len(slotc) < c.Cc: fiter += 1 iter0 -= 1 # handle no teacher possible to allocate else: Ca = classroomAllocate(mydb, c, slotc, classrooms, s, f, allocid) if Ca != -1: allocid = Ca iter0 = 0 break else: PSlots = list(set(PSlots) - set(slotc))