def input_students_infor(self, driver): if self.driver.nofstudents == None or self.driver.nofstudents <= 0: print("Student list is empty. Please enter number of students!!!") elif self.driver.nofstudents > len(self.driver.students): for i in range(0, self.driver.nofstudents): print(f"Enter information of student #{i + 1}") while True: try: sid = int(input(f"Enter student id: ")) while sid <= 0: sid = int( input( f"ID must be positive. Enter again student id: " )) except: print("ID has to be positive integer!!!") else: break while True: try: sname = input(f"Enter name of student #{sid}: ") while len(sname) == 0: sname = input( f"Student name can't be empty.Enter agian name of student #{sid}: " ) except: print( f"Student name can't be empty.Enter agian name of student #{sid}: " ) else: break # Still not good!!!Name is still entered by numbers while True: try: sdob = input( f"Enter date of birth of student #{sid}: ") while len(sdob) == 0: sdob = input( f"Student name can't be empty.Enter agian name of student #{sid}: " ) except: print( "Student name can't be empty.Enter again name of student!!!" ) else: break # Still not good!!!Dob is still entered by letters self.driver.students.append(Student(driver, sid, sname, sdob)) self.driver.studentmark.append( Student(driver, sid, sname, sdob)) else: print( f"The student list is full({len(self.driver.students)} students).Please use function 1 to extra student list" )
def student_infor(self, menu): cu.addstr("\n** STUDENT INFORMATION **\n") while True: cu.addstr("\tStudent ID: ") cu.refresh() id = cu.getstr().decode() if id in menu.student_id: error("This ID already existed. Please try another one\n") elif len(id) == 0: error("This cannot be empty. Please try again\n") else: break while True: cu.addstr("\tStudent's name: ") cu.refresh() name = cu.getstr().decode() if len(name) == 0: error("This cannot be empty. Please try again\n") else: break while True: cu.addstr("\tStudent's date of birth: ") cu.refresh() dob = cu.getstr().decode() if len(dob) == 0: error("This cannot be empty. Please try again\n") else: break if len(menu.students) == 0: f = open("students.txt", "w") else: f = open("students.txt", "a") f.write(id + "\t" + name + "\t" + dob + "\n") f.close() Student(menu, id, name, dob)
def setStudent(): print("Input Student Information: ") for i in range(StudentCount): student_id = input("Enter Student Id: ") student_name = input("Enter Student Name: ") student_birthday = input("Enter Student Date of Birth: ") StudentList[i] = Student(student_id, student_name, student_birthday)
def get_info_student(screen): number_student = get_number_student(screen) students = [] for i in range(number_student): std = Student() std.input(screen) students += [std] return students
def addStudent(): Students = [] count = int(input("number of students")) for i in range(0, count): name = input("student name:") DOB = input("date of birth:") SID = int(input("student ID :")) soc = Student(name, DOB, SID) Students.append(soc) return Students
def add_student(students): id = input("Student's ID: ") name = input("Student's name: ") dOB = input("Student's DOB: ") student = Student.Student(id, name, dOB) students.append(student) f = open('Students.txt', 'a') f.write("StudentID: " + id + "\n" + "StudentName: " + name + "\n" + "SudentDoB: " + DoB) f.close()
def get_info_student(screen): number_student = get_number_student(screen) students = [] student_file = open("student.txt", "a") student_file.write("Student info:") for i in range(number_student): std = Student() std.input(screen) students += [std] student_file.write("Student info") student_file.close() return students
def input_mark_file(driver, sid, sname, sdob, cid, cname, credit, value): # Set for students s_sid = driver.mark.student.set_sid(sid) #int s_sname = driver.mark.student.set_sname(sname) #str s_sdob = driver.mark.student.set_sdob(sdob) #str student = Student(s_sid, s_sname, s_sdob) # Set for courses s_cid = driver.mark.course.set_cid(cid) #int s_cname = driver.mark.course.set_cname(cname) #str s_credit = driver.mark.course.set_credit(credit) #int course = Course(s_cid, s_cname, s_credit) # Set for marks s_value = driver.mark.set_value(value) #int driver.marks.append(Mark(driver, student, course, s_value))
def __parse_students_from_file(self): if Repository.FILE_TXT in self.path_students: file_students = open(self.path_students, "r") lines = file_students.readlines() for line in lines: if len(line) < 3: continue data = line.strip().split(';') self.data.append(Student(int(data[0]), data[1])) file_students.close() return if Repository.FILE_PICKLE in self.path_students: file_students = open(self.path_students, "rb") self.data = pickle.load(file_students) file_students.close() return
def input_student_information(self, engine): while True: # sid = input("- Enter student ID: ") self.__screen.addstr("-> Enter student ID: ") self.__screen.refresh() sid = self.__screen.getstr().decode() if len(sid) == 0 or sid is None: # print("Error: Student ID cannot be empty") self.print_error("Student ID cannot be empty") else: break if sid in engine.students_id: # print("Error: Student ID existed") self.print_error("Student ID already exists") curses.endwin() exit() else: while True: # name = input("- Enter student name: ") self.__screen.addstr("-> Enter student name: ") self.__screen.refresh() name = self.__screen.getstr().decode() if len(name) == 0 or name is None: # print("Error: Student name cannot be empty") self.print_error("Student name cannot be empty") else: break while True: # dob = input("- Enter student date of birth: ") self.__screen.addstr("-> Enter student date of birth: ") self.__screen.refresh() dob = self.__screen.getstr().decode() if len(dob) == 0 or dob is None: # print("Error: Student date of birth cannot be empty") self.print_error("Student date of birth cannot be empty") else: break curses.curs_set(0) self.__screen.addstr(f"\n Successfully Added student: {name}") self.__screen.refresh() curses.napms(1000) curses.curs_set(1) Student(engine, sid, name, dob)
def preload_list(self): """ Adds to the repository a list of predefined values that are randomised Input: - Output: - """ randomiser = Randomiser() data_to_add = Group() for i in range(10): random_name = randomiser.get_random_first_name() + " " + randomiser.get_random_last_name() data_to_add.students.append(Student(i, random_name)) data_to_add.disciplines.append(Discipline(i, randomiser.get_random_discipline_name())) for i in range(10): data_to_add.grades.append(Grade( randomiser.get_random(data_to_add.disciplines), randomiser.get_random(data_to_add.students), randomiser.get_random_grade() )) if self.services.students.store_type == Repository.STORE_MEMORY: self.services.add_all(data_to_add)
def add_student(self, sid, name, track=True): student = Student(sid, name) self.students.add(student) if track: self.tracker.add_action(ActionTracker.ADD, student, ActionTracker.STUDENT)
def Student_Information(): for i in range (nos): print("Enter Student Information: ") Student_List[i] = Student(int(input("id:")),input("name: "),input("DoB: ")) Student_id.append(Student_List[i].id)
def add_student(students): id = input("Student's ID: ") name = input("Student's name: ") dOB = input("Student's DOB: ") student = Student.Student(id, name, dOB) students.append(student)
def input_students_file(driver, sid, sname, sdob): student = Student(driver, sid, sname, sdob) driver.students.append(student)