def dummy_data(): student_1 = Student('Student 1', 'Economics') student_2 = Student('Student 2', 'Sports') working_student_1 = Working_student('Working Student 1', 'Web Dev', 'Full stack developer', 25000) working_student_2 = Working_student('Working Student 2', 'Web Dev', 'Junior Python Developer', 17000) student_1.add_grade(80) student_1.add_grade(70) student_1.add_grade(86) student_2.add_grade(90) student_2.add_grade(93) student_2.add_grade(91) working_student_1.add_grade(65) working_student_1.add_grade(70) students.extend( [student_1, student_2, working_student_1, working_student_2]) teacher_1 = Teacher('Corey Schaufer', 'Python') teacher_2 = Teacher('Pretty Printed', 'Django') teacher_3 = Teacher('The Net Ninja', 'Javascript') teachers.extend([teacher_1, teacher_2, teacher_3]) print('Dummy data created sucessfully! \n')
def teacher_page(): # teacher sign in page if request.method == "POST": user = Teacher("", "", "", "", "") user.email = request.form['email'] user.password = request.form['password'] result = db.get_teacher(user.email) if result: password2 = result['teacher_password'] if hasher.verify(user.password, password2): session['logged_in'] = True session['email'] = user.email session['name'] = result['teacher_name'] session['surname'] = result['teacher_surname'] session['id'] = result['teacher_id'] flash('You are now logged in', 'success') #?? return redirect(url_for('teacher_main_page')) else: error = " wrong password !" return render_template('teacher_sign.html', error=error) else: error = " email not found !" return render_template('teacher_sign.html', error=error) return render_template('teacher_sign.html')
def make_teachers(file_name): """ Create all teacher objects from the Teacher csv file :param file_name: The file to extract data from using the csv module's DictReader :returns: A list of Teacher objects """ teacher_list = [] teachers = csv.DictReader( open(file_name, encoding='utf-8-sig' )) # Need encoding field to delete the Byte Order Mark (BOM) for teacher in teachers: email = teacher['Email Address'].strip() name = teacher['Teacher\'s Full Name'].strip() school = teacher['District/Entity'] subject = teacher['Subject'] grade = teacher['Grade'] principal_email = teacher['Principal\'s email'].strip() principal_name = teacher['Principal\'s name'].strip() school_name = teacher['School Name'].strip() stage_3_times = teacher['Stage 3 Lab'] other_stage_3_times = teacher[ 'If Other, indicate Stage 3 lab time'].strip() stage_1_and_2_times = teacher['Stage 1 & 2 Lab'] other_stage_1_and_2_times = teacher[ 'If Other, indicate Stage 1 & 2 lab time'].strip() new_teacher = Teacher( email=email, name=name, school=school, school_name=school_name, certification=Certification(subject=subject, grades=convert_grade(grade)), principal_email=principal_email, principal_name=principal_name, stage2_times=create_times(stage_1_and_2_times, other_stage_1_and_2_times), stage3_times=create_times(stage_3_times, other_stage_3_times)) teacher_list.append(new_teacher) return teacher_list
def signUp(): if request.method == "POST": form_name = request.form["fname"] form_surname = request.form["lname"] form_id = request.form["ownid"] form_email = request.form["Email"] form_password = hasher.hash(request.form["password"]) form_person = request.form["person"] db = current_app.config["db"] if request.form["password"] != request.form[ "confirm_password"]: #for error password_error = "Passwords not matching! Try Again" return render_template('signup.html', password_error=password_error) if db.check_exists_student_id(form_id) or db.check_exists_teacher_id( form_id): #for error error = "The ID exists! Try Again" return render_template('signup.html', error=error) if db.check_exists_student_email( form_email) or db.check_exists_teacher_email( form_email): #for error error = "The email has already used!" return render_template('signup.html', error=error) if form_person == "teacher": teacher = Teacher(form_id, form_name, form_surname, form_email, form_password) teacher_key = db.add_teacher(teacher) return redirect(url_for("successful", teacher_key=teacher_key)) elif form_person == "student": student = Student(form_id, form_name, form_surname, form_email, form_password) student_key = db.add_student(student) return redirect(url_for("successful", student_key=student_key)) else: return "person is not chosen!" else: return render_template('signup.html')
def Full_teacher(path) -> [Teacher]: xlsx_file = Path(path) wb_obj = openpyxl.load_workbook(xlsx_file) sheet = wb_obj['параметры преподавателей'] pr = [] NUMBERS_OF_PROGRAMS = [] for row in sheet.iter_rows(min_row=2): pr.append(str(row[3].value).split(';')) flatten = lambda l: [item for sublist in l for item in sublist] for i in list(set(flatten(pr))): NUMBERS_OF_PROGRAMS.append(i) del pr teachers = [] for _, row in enumerate(sheet.iter_rows(min_row=2)): azaza = [] [ azaza.append(j) for j in NUMBERS_OF_PROGRAMS if j not in str(row[3].value).split(';') ] tch = Teacher(row[0].value, row[1].value, str(row[3].value).split(';'), azaza, row[4].value, row[7].value, row[2].value) teachers.append(tch) return teachers
# <course>, <course>, ..."`. The list of courses should be comma seperated # without one at the end. Use `super()` to access base method. # # # Create a new instance of the class Teacher. Initiate it with the name # `Skorstten` and ssn `578118-6946`. # Use the add_course method to add the following courses, `htmlphp`, `webgl` # and `ramverk2`. # # # Answer with the Teacher object's string representation. # # Write your code below and put the answer into the variable ANSWER. # teacher = Teacher("Skorstten", "578118-6946") teacher.add_course("htmlphp") teacher.add_course("webgl") teacher.add_course("ramverk2") ANSWER = str(teacher) # I will now test your answer - change false to true to get a hint. dbwebb.assert_equal("1.3", ANSWER, True) # """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" # Exercise 1.4 (2 points) # # Create a new class name **Student** make it inherit from class "Person". # Add the instance attribute "courses_grades" and initiate it to and empty # list.
from classes import Teacher, Student, Course compsci = Course("Computer Science 101", "CS101") maria = Student("Maria", "Martinez") joe = Student("Joe", "Smith") ashven = Student("Ashven", "Matthew") imani = Teacher("Imani", "Matthews") compsci.add([maria, joe, ashven]) compsci.set_teacher(imani) print(compsci.teacher, compsci.students) joe.addgrade(compsci, 80) joe.addgrade(compsci, 89) joe.addgrade(compsci, 100) print() print("GPA for {} is {:.2f}.".format(joe, joe.gpa_for(compsci)))
first_name Методы: create_homework - текст задания и количество дней на это задание, возвращает экземпляр Homework Обратите внимание, что для работы этого метода не требуется сам объект. PEP8 соблюдать строго, проверку делаю автотестами и просмотром кода. Всем перечисленным выше атрибутам и методам классов сохранить названия. К названием остальных переменных, классов и тд. подходить ответственно - давать логичные подходящие имена. """ from classes import Student, Teacher if __name__ == '__main__': teacher = Teacher('Daniil', 'Shadrin') student = Student('Roman', 'Petrov') teacher.last_name # Shadrin student.first_name # Roman expired_homework = teacher.create_homework('Learn functions', 0) expired_homework.created # Example: 2019-05-26 16:44:30.688762 expired_homework.deadline # 0:00:00 expired_homework.text # 'Learn functions' # create function from method and use it create_homework_too = teacher.create_homework oop_homework = create_homework_too('create 2 simple classes', 5) oop_homework.deadline # 5 days, 0:00:00 student.do_homework(oop_homework)
def setUp(self): self.teacher = Teacher(name='ramadan') self.question = Question('', '', '')