Code cleanup!
Teacher part updated

- sql JOINS
- added some if statements
- code cleanup
- try cahjcx