Refactor some code in student_pages_controller