def profile_get(): if 'id' not in session: return redirect("/index") if session['type'] == 'students': profile = databs().fetch("SELECT student_id, name, gender, email, grade FROM students WHERE student_id=%s", session["id"]) return utils.my_render_template("studentsprofile.html", profile = profile[0]) elif session['type'] == 'teachers': profile = databs().fetch("SELECT teacher_id, name, email FROM teachers WHERE teacher_id=%s", session["id"]) return utils.my_render_template("teachersprofile.html", profile = profile[0]) elif session['type'] == 'administrators': profile = databs().fetch("SELECT worker_id, name, email FROM administrators WHERE worker_id=%s", session["id"]) return utils.my_render_template("adminsprofile.html", profile = profile[0])
def courses_get(): if 'id' not in session: return redirect("/index") if session['type'] == "students": return redirect("index") coursesname = databs().fetch("SELECT serial, course_name, course_code, credit, hours FROM courses_code WHERE state!=1") return utils.my_render_template("courses.html", courses = coursesname)
def updateteacherlist_get(): if 'id' not in session: return redirect("/index") if session['type'] == "students": return redirect("index") teachers = databs().fetch("SELECT teacher_id, name, email, reg_time FROM teachers where state!=1") return utils.my_render_template("teachers.html", teachers = teachers)
def uploadimage_get(): if 'id' not in session: return redirect("/index") files = [] if os.path.exists(os.path.join(app.config['UPLOAD_PATH'], session['id']) + '.jpg'): files = [session['id'] + '.jpg'] return utils.my_render_template("uploadimage.html", files=files)
def recordattendance_get(): if 'id' not in session or session['type'] != "teachers": return redirect("/index") if 'course_id' not in request.args: courses = databs().fetch("""SELECT teachers_courses.serial, course_code, course_name FROM courses_code INNER JOIN teachers_courses ON courses_code.serial = teachers_courses.course_code_id WHERE courses_code.state != 1 and teachers_courses.teacher_id = %s""", [session['id']]) teachers = databs().fetch("SELECT teacher_id, name FROM teachers") return utils.my_render_template("studentsattendance.html", courses=courses, teachers=teachers) else: studentlist = databs().fetch(""" SELECT students.student_id, name, time_arrive FROM students INNER JOIN students_monitoring on students_monitoring.student_id = students.student_id WHERE course_id=%s""", [request.args["course_id"]]) return utils.my_render_template("recordattendance.html", studentlist=studentlist, course_id=request.args["course_id"])
def monitoringpage_get(): if 'id' not in session: return redirect("/index") where = "" arguments = [] if session['type'] == "students": where = " and student_id = %s" arguments = [ session['id'] ] monitoring = databs().fetch("""SELECT student_id, course_code, course_name, time_arrive FROM students_monitoring INNER JOIN courses_code ON courses_code.serial=students_monitoring.course_id""" + where, arguments) return utils.my_render_template("monitoringpage.html", monitoring = monitoring)
def updateteacherscourses_get(): if 'id' not in session: return redirect("/index") courses = databs().fetch("""SELECT serial, teachers.teacher_id, teachers.name, courses_code.serial, course_code, course_name, day, time_start, time_end FROM courses_code INNER JOIN teachers_courses ON courses_code.serial = teachers_courses.course_code_id INNER JOIN teachers ON teachers.teacher_id = teachers_courses.teacher_id WHERE courses_code.state != 1""") print(courses) teachers = databs().fetch("SELECT teacher_id, name FROM teachers") return utils.my_render_template("teacherscourses.html", courses=courses, teachers=teachers)
def updatestudentscourses_get(): if 'id' not in session: return redirect("/index") courses = databs().fetch("""SELECT serial, students.student_id, students.name, courses_code.serial, course_code, course_name, credit, hours FROM courses_code INNER JOIN students_courses ON courses_code.serial = students_courses.course_id INNER JOIN students ON students.student_id = students_courses.student_id WHERE courses_code.state != 1""") print(courses) students = databs().fetch("SELECT student_id, name FROM students") listcourses = databs().fetch("SELECT course_id, course_code, course_name FROM courses_code") return utils.my_render_template("studentscourses.html", students=students, listcourses=listcourses, studentcourses=courses)
def teacherscourses_get(): if 'id' not in session: return redirect("/index") where = "" arguments = [] if session['type'] == "teachers": where = " and teachers.teacher_id = %s" arguments = [ session['id'] ] courses = databs().fetch("""SELECT teachers_courses.serial, teachers.teacher_id, teachers.name, courses_code.serial, course_code, course_name, credit, hours, day, time_start, time_end FROM courses_code INNER JOIN teachers_courses ON courses_code.serial = teachers_courses.course_code_id INNER JOIN teachers ON teachers.teacher_id = teachers_courses.teacher_id WHERE courses_code.state != 1""" + where, arguments) teachers = databs().fetch("SELECT teacher_id, name FROM teachers") print(teachers) return utils.my_render_template("teacherscourses.html", courses=courses, teachers=teachers)
def coursesmonitoring_get(): if 'id' not in session or session['type'] != "teachers": return redirect("/index") students = databs().fetch(""" SELECT students_monitoring.id, course_code, course_name, students.student_id, name, time_arrive FROM students INNER JOIN students_monitoring ON students.student_id = students_monitoring.student_id INNER JOIN teachers_courses ON students_monitoring.course_id = teachers_courses.serial INNER JOIN courses_code ON teachers_courses.course_code_id = courses_code.serial WHERE courses_code.state != 1 and teachers_courses.teacher_id= %s order by time_arrive desc """, [session['id']]) courses = databs().fetch(""" SELECT teachers.teacher_id, course_code, course_name FROM teachers INNER JOIN teachers_courses ON teachers.teacher_id = teachers_courses.teacher_id INNER JOIN courses_code ON teachers_courses.course_code_id = courses_code.serial where teachers_courses.teacher_id=%s""", [session['id']]) return utils.my_render_template("coursesmonitoring.html", students=students, courses=courses)
def studentscourses_get(): if 'id' not in session: return redirect("/index") where = "" arguments = [] if session['type'] == "students": where = " and students.student_id = %s" arguments = [ session['id'] ] print(arguments) courses = databs().fetch("""SELECT students_courses.serial, students.student_id, students.name, courses_code.serial, course_code, course_name, credit, hours FROM courses_code INNER JOIN students_courses ON courses_code.serial = students_courses.course_id INNER JOIN students ON students.student_id = students_courses.student_id WHERE courses_code.state != 1""" + where, arguments) print(courses) students = databs().fetch("SELECT student_id, name FROM students") teachers = databs().fetch("SELECT teacher_id, name FROM teachers") listcourses = databs().fetch("SELECT serial, course_code, course_name FROM courses_code") return utils.my_render_template("studentscourses.html", studentcourses=courses, students=students, teachers=teachers, listcourses=listcourses)
def index(): if 'id' not in session: return redirect("/") return utils.my_render_template("index.html")
def register_get(): if 'id' in session: return redirect("/index") return utils.my_render_template("register.html")
def main(): if 'id' in session: return redirect("/index") return utils.my_render_template("homepage.html")
def updatestudentlist_get(): if 'id' not in session: return redirect("/index") students = databs().fetch("SELECT student_id, name, grade, gender, email, reg_time FROM students where state!=1") return utils.my_render_template("students.html", students = students)