view_student.py
def post(self):
        """
        A function that determines how the viewStudent class handles POST requests
        INPUT: self
        OUTPUT: a rendering of the viewStudent.html file. The information included in the rendering depends on
                the information we get from the POST request
        """
        # Get the database object we will need
        students = gbmodel.students()
        teams = gbmodel.teams()
        reports = gbmodel.reports()

        # Validate that the one making the request is a professor
        # Might want to consider noting things like these or forcefuly logging the person out
        if not validate_professor():
            return display_access_control_error()

        # Otherwise, load the student page
        try:
            # Get the student and session id from the post request, and try to find the student in the db
            student_id = request.form.getlist('student_id')[0]
            session_id = request.form.getlist('session_id')[0]
            student = students.get_student_in_session(student_id, session_id)

            # If the student is found, find all of the student's team members and see if the student filled
            # out reviews for those team members
            if student is not None:
                # Get team name
                team = teams.get_team_from_id(student.tid)
                if team is None:
                    return self.display_error(("Students' team not found in database (when searching via team"
                                               " id)"))

                # Record it, along with some other information about the student
                student_details = {"name": student.name, "id": student.id, "team_name": team.name}

                # See if the student completed a midterm and final review for their team members and
                # record it
                reviews = []
                team_members = students.get_team_members(student.tid)
                for team_member in team_members:
                    midterm_review_completed = self.check_review_done(reports,
                                                                      student.id,
                                                                      team_member.id,
                                                                      student.tid,
                                                                      False)
                    final_review_completed = self.check_review_done(reports,
                                                                    student.id,
                                                                    team_member.id,
                                                                    student.tid,
                                                                    True)
                    reviews.append({"reviewee_name": team_member.name,
                                    "reviewee_id": team_member.id,
                                    "completed": (midterm_review_completed, final_review_completed)})

                # Combine the recorded data with the viewStudent.html template and render the viewStudent
                # page
                return render_template('viewStudent.html',
                                       student=student_details,
                                       review_data=reviews,
                                       session_id=session_id)
            else:
                return self.display_error(("Student was not found in the database "
                                           "(when we searched via student ID)"))

        # https://stackoverflow.com/questions/47719838/how-to-catch-all-exceptions-in-try-catch-block-python
        except Exception as error:
            return self.display_error(error)

        A function that determines how the viewStudent class handles POST requests
        INPUT: self
        OUTPUT: a rendering of the viewStudent.html file. The information included in the rendering depends on
                the information we get from the POST request
        
A function that determines how the viewStudent class handles POST requests
INPUT: self
OUTPUT: a rendering of the viewStudent.html file. The information included in the rendering depends on
the information we get from the POST request
A function that determines how the viewStudent class handles POST requests INPUT : self OUTPUT : a rendering of the viewStudent . html file . The information included in the rendering depends on the information we get from the POST request
def post(self):
        students = gbmodel.students()
        teams = gbmodel.teams()
        reports = gbmodel.reports()
        if not validate_professor():
            return display_access_control_error()
        try:
            student_id = request.form.getlist('student_id')[0]
            session_id = request.form.getlist('session_id')[0]
            student = students.get_student_in_session(student_id, session_id)
            if student is not None:
                team = teams.get_team_from_id(student.tid)
                if team is None:
                    return self.display_error(("Students' team not found in database (when searching via team"
                                               " id)"))
                student_details = {"name": student.name, "id": student.id, "team_name": team.name}
                reviews = []
                team_members = students.get_team_members(student.tid)
                for team_member in team_members:
                    midterm_review_completed = self.check_review_done(reports,
                                                                      student.id,
                                                                      team_member.id,
                                                                      student.tid,
                                                                      False)
                    final_review_completed = self.check_review_done(reports,
                                                                    student.id,
                                                                    team_member.id,
                                                                    student.tid,
                                                                    True)
                    reviews.append({"reviewee_name": team_member.name,
                                    "reviewee_id": team_member.id,
                                    "completed": (midterm_review_completed, final_review_completed)})
                return render_template('viewStudent.html',
                                       student=student_details,
                                       review_data=reviews,
                                       session_id=session_id)
            else:
                return self.display_error(("Student was not found in the database "
                                           "(when we searched via student ID)"))
        except Exception as error:
            return self.display_error(error)
def post ( self ) : students = gbmodel . students ( ) teams = gbmodel . teams ( ) reports = gbmodel . reports ( ) if not validate_professor ( ) : return display_access_control_error ( ) try : student_id = request . form . getlist ( 'student_id' ) [ 0 ] session_id = request . form . getlist ( 'session_id' ) [ 0 ] student = students . get_student_in_session ( student_id , session_id ) if student is not None : team = teams . get_team_from_id ( student . tid ) if team is None : return self . display_error ( ( "Students' team not found in database (when searching via team" " id)" ) ) student_details = { "name" : student . name , "id" : student . id , "team_name" : team . name } reviews = [ ] team_members = students . get_team_members ( student . tid ) for team_member in team_members : midterm_review_completed = self . check_review_done ( reports , student . id , team_member . id , student . tid , False ) final_review_completed = self . check_review_done ( reports , student . id , team_member . id , student . tid , True ) reviews . append ( { "reviewee_name" : team_member . name , "reviewee_id" : team_member . id , "completed" : ( midterm_review_completed , final_review_completed ) } ) return render_template ( 'viewStudent.html' , student = student_details , review_data = reviews , session_id = session_id ) else : return self . display_error ( ( "Student was not found in the database " "(when we searched via student ID)" ) ) except Exception as error : return self . display_error ( error )
A function that determines how the viewStudent class handles POST requests
INPUT: self
OUTPUT: a rendering of the viewStudent.html file.
A function that determines how the viewStudent class handles POST requests INPUT : self OUTPUT : a rendering of the viewStudent . html file .
"""
        A function that determines how the viewStudent class handles POST requests
        INPUT: self
        OUTPUT: a rendering of the viewStudent.html file. The information included in the rendering depends on
                the information we get from the POST request
        """ # Get the database object we will need # Validate that the one making the request is a professor # Might want to consider noting things like these or forcefuly logging the person out # Otherwise, load the student page # Get the student and session id from the post request, and try to find the student in the db # If the student is found, find all of the student's team members and see if the student filled # out reviews for those team members # Get team name # Record it, along with some other information about the student # See if the student completed a midterm and final review for their team members and # record it # Combine the recorded data with the viewStudent.html template and render the viewStudent # page # https://stackoverflow.com/questions/47719838/how-to-catch-all-exceptions-in-try-catch-block-python
self