def submit_all(): result = askquestion(title="Confirmation", message= "Do you want to process?") if result == "yes": person = Person() person.lname = input_lastname.get(1.0, "end-1c") person.fname = input_firstname.get(1.0, "end-1c") person.birthday = datetime.date(birthYear.get(), months.index(birthMonth.get()) + 1, birthDay.get()) person.nationality = selected_nationality.get() person.gender = selected_gender.get() person.streetNumber = str(input_houseNo.get(1.0, "end-1c")) + str(input_houseNo2.get(1.0, "end-1c")) person.streetname = input_street.get(1.0, "end-1c") person.city = input_city.get(1.0, "end-1c") person.postalCode = str(input_postal.get(1.0, "end-1c")) + str(input_postal2.get(1.0, "end-1c")) person.phone = input_phoneNumber.get(1.0, "end-1c") person.email = input_email.get(1.0, "end-1c") person.insert() teacher = Teacher() teacher.personID = person.personID teacher.salary = input_salary.get(1.0, "end-1c") person.userName = (person.lname + str(teacher.teacherID)) person.userPass = "******" person.update() get_counsellor = selected_counsellor.get() if (get_counsellor == "Yes"): teacher.studycouncelor = 'Y' else: teacher.studycouncelor = 'N' teacher.insert() ui.AdminWindowTeachers.admin_window_teachers(window, return_function) #avoid circular import
def teacher(id): if current_user.role_name != 'AdminUser': return render_error(403) if id == 'new': t = Teacher() else: try: id = int(id) except ValueError: return render_error(400) t = db.session.query(Teacher).filter(Teacher.id == id).one_or_none() if t is None: return render_error(404) form = TeacherForm(request.form if request.method == 'POST' else None, obj=t) if form.button_delete.data: form.validate() if db.session.query(CurriculumUnit).filter(CurriculumUnit.teacher_id == t.id).count() > 0: form.button_delete.errors.append('Невозможно удалить преподавателя, к которому привязаны единицы учебного плана') if len(form.button_delete.errors) == 0: db.session.delete(t) db.session.commit() db.session.flush() return redirect(url_for('teachers')) if form.button_save.data and form.validate(): form.populate_obj(t) db.session.add(t) db.session.commit() if id == 'new': db.session.flush() return redirect(url_for('teacher', id=t.id)) return render_template('teacher.html', teacher=t, form=form)
class TeacherDAO: teacherTable = { "trung": Teacher("TC1", "Nguyen Quoc Hoang Trung", True, "30-04-1997", "Math"), } location = "database/teacherTable" def createTable(self): # if file existed if Path(self.location).is_file(): return f = open(self.location, "wb") f.write(pickle.dumps(self.teacherTable)) f.close() def readFromFile(self): f = open(self.location, "rb") table = pickle.loads(f.read()) return table def selectAll(self): return self.readFromFile() def selectOne(self, id): table = self.readFromFile() if id in table: teacher = table[id] return teacher return None
def test_teacher_create_class(self): """Can teacher create a class?""" import pdb pdb.set_trace() new_teacher = Teacher(username="******", password="******", fname="Walt", lname="Disney") db.session.add(new_teacher) db.session.commit() teacher_id = Teacher.query.filter_by( username='******').one().teacher_id with app.test_client() as c: with c.session_transaction() as sess: sess['teacher_id'] = teacher_id create_class_info = { 'registration code': "999", 'name': "6th Period Band", 'type_class': "marching_band" } result = self.client.post("/create-class", data=create_class_info, follow_redirects=True) self.assertIn("6th Period Band", result.data)
def getTeacher(self): global g_Database rows = g_Database.fetchAll('SELECT * FROM teacher WHERE personID=' + str(self.personID)) if (not len(rows)): return None teacher = Teacher() teacher.read_row(rows[0]) return teacher
def create_teacher(fname, lname, email, password, zipcode=None, bio=None, mobile_number=None, days_of_week=None,teaching_experience_in_hours=None, pay_rate_per_hour=None, pod_id=None, img_url=None,covid_risk_profile_id=None): """Add a new teacher to the teachers table and return the teacher.""" teacher = Teacher(fname=fname, lname=lname, email=email, password=password, zipcode=zipcode, bio=bio, mobile_number=mobile_number, days_of_week=days_of_week, teaching_experience_in_hours=teaching_experience_in_hours, pay_rate_per_hour=pay_rate_per_hour, pod_id=pod_id,img_url=img_url, covid_risk_profile_id=covid_risk_profile_id) db.session.add(teacher) db.session.commit() return teacher
def generateTeacher(is_admin=False): person = generatePerson() teacher = Teacher() teacher.salary = random.randint(2500, 6500) teacher.studycouncelor = random.choice(['Y', 'N']) teacher.personID = person.personID teacher.insert() if is_admin: person.userName = "******" else: person.userName = (person.lname + str(teacher.teacherID)) person.userPass = "******" person.email = (person.lname + "." + person.fname + "@diemenacademy.nl") person.update() return teacher
def load_teachers(teachers_filename): """Load teachers into database.""" print "Teacher" for i, row in enumerate(open(teachers_filename)): username, password, fname, lname = row.split("|") teacher = Teacher(username=username, password=password, fname=fname, lname=lname) db.session.add(teacher) if i % 10 == 0: print i db.session.commit()
def admin_add_user(role, fields): if role.lower() == 'student': user = Student() elif role.lower() == 'teacher': user = Teacher() elif role.lower() == 'admin': user = Admin() else: raise APIError('Invalid role') fields['password'] = hash_password(fields['password']) for key, value in fields.items(): if not value: continue user.__setattr__(key, value) db.session.add(user) db.session.commit() return user.dict
def teacher_register_process(): """Process registration.""" # Get form variables username = request.form["username"] password = request.form["password"] fname = request.form["fname"] lname = request.form["lname"] # Create new teacher object new_teacher = Teacher(username=username, password=password, fname=fname, lname=lname) # Add teacher to database db.session.add(new_teacher) db.session.commit() #flash confirmation, log teacher in, redirect to teacher profile flash("Teacher {} {} added.".format(fname, lname)) session["teacher_id"] = new_teacher.teacher_id return redirect("/teachers/{}".format(session["teacher_id"]))
teacher_phone= "", teacher_password=hash_input("abaker"), ) ] for rec in teacher_records: # Check to see if your student exists, if so, skip if my_teacher := session.query(Teacher).filter_by(teacher_email=rec['teacher_email']).first(): print(f'Teacher {my_teacher} already exists. Skipping') continue # Otherwise – create the teacher my_teacher = Teacher(**rec) # add them to the session session.add(my_teacher) # commit the session session.commit() # ------------------------------------------------------------------------------ # CREATE STUDENTS # Create a list of records for our student student_records = [
#______________________functions for creating table records___________________________# def create_teacher(teacher_fname, teacher_lname, teacher_email, teacher_phone, teacher_password): """Creates a new teacher record""" # Check if email is already in use: if teacher := db.session.query(Teacher).filter_by( teacher_email=teacher_email).first(): # Either return False which will cause an error – or return the teacher – in which # case, your method should be renamed `get_or_create_teacher()` return False teacher = Teacher(teacher_fname=teacher_fname, teacher_lname=teacher_lname, teacher_email=teacher_email, teacher_phone=teacher_phone, teacher_password=teacher_password) db.session.add(teacher) db.session.commit() # refresh to get the teacher with all their data db.session.refresh(teacher) return teacher def create_student(student_fname, student_lname, student_email, program_name, instrument, student_password, student_phone, teacher_id): """Creates a new student record"""
import torch.distributed torch.cuda.set_device(curdevice) def Log(message: str): if curdevice == 0: print(message) from model import DehazeSR, Teacher train_teacher = args.train_teacher if train_teacher: model = Teacher() else: model = DehazeSR() model_teacher_name = args.teacher model_checkpoint_name = args.checkpoint_name checkpoint_file = args.checkpoint if checkpoint_file is not None: _filepath = f"checkpoints/{checkpoint_file}" print(f'loading model from {_filepath}') state_dict = torch.load(_filepath, map_location='cpu')['model'] Log('setup') if torch.cuda.is_available():
hour = Hour(code=k, name=v) db.session.add(hour) for k, v in data.week.items(): day = Day(code=k, name=v) db.session.add(day) for k, v in data.goals.items(): goal = Goal(code=k, name=v) db.session.add(goal) for k, v in data.times.items(): time = Time(code=k, name=v) db.session.add(time) for t in data.teachers: teacher = Teacher(id=t['id'], name=t['name'], about=t['about'], rating=t['rating'], picture=t['picture'], price=t['price'], free=t['free']) db.session.add(teacher) for g in t['goals']: new_goal = Goal.query.filter(Goal.code == g).first() teacher.goals.append(new_goal) db.session.commit() app.run()