After recent commits on 03/17/2024, some files like app.py were regressed to a state from previous commits weeks or months ago; this caused significant problems when running the server, such as the flask app not even being detected or files being imported from the wrong directory.
Thankfully, I don't think there were too many of these code reversions, but since I changed them back manually, there might have been one or two lines I could have missed. Everything now seems to be running the same as before though, so things seem to be fine at the moment.
And as a side note to whichever team member(s) that caused this problem: please, please, PLEASE update your fork/branch with the main repo before making a PR and merging. Careless issues like these are irritating to deal with, are a waste of time for the entire team, and can easily be prevented by spending an extra 5-10 minutes syncing your fork with upstream.
Deleted an old questionSubmit.py file that was added back, as part of the faulty commits.
Fixed various aspects of the login system:
Fixed the load_user() function in app.py to properly filter between teachers and students using Flask session. This way, teachers can actually login to their account, rather than logging in students who share the same primary key ID value as them into the teacher dashboard.
Made it so that if a user logs out, their account is actually logged out from the system through a new endpoint /logout (no cookies are kept from the previous session). As a result, attempting to visit any private, "logged-in"-only pages redirects them back to the login page. Likewise, logged-in users cannot access the login and register pages; it would bring them back to the profile page (maybe changing this to their dashboard page would be better).
Added an if statement to the base.html header such that the dashboard button link changes depending on the user's role; if the user is a student, it brings them to /dashboard; if they are a teacher, it brings them to /teachers (the teacher dashboard).
Imported Python's enumerate() function into the dashboard.html page through render_template() to prevent a crash when visiting the page. Originally, someone tried to use enumerate() in Jinja syntax, despite the function not existing within Jinja innately...
Fixed the teacher dashboard redirection link to redirect to the proper teacher_page() endpoint in main.py; this way, the proper header navigation items are available to the user, and they get sent to the actual teacher dashboard instead of a blank temp page.
Changes made:
/logout
(no cookies are kept from the previous session). As a result, attempting to visit any private, "logged-in"-only pages redirects them back to the login page. Likewise, logged-in users cannot access the login and register pages; it would bring them back to the profile page (maybe changing this to their dashboard page would be better)./dashboard
; if they are a teacher, it brings them to/teachers
(the teacher dashboard).teacher_page()
endpoint in main.py; this way, the proper header navigation items are available to the user, and they get sent to the actual teacher dashboard instead of a blank temp page.