gbmodel/model_sqlalchemy.py
def dashboard(self, session_id):
        """
        Return a lists of sessions from the database
        and a list of teams + students from a selected session
        Input: session id of the selected session
        """
        student = students()
        session = capstone_session()
        today = datetime.datetime.now()
        sessions = session.get_sessions()
        if self.get_team_session_id(session_id) is None:
            return None, sessions
        tids = [row.id for row in self.get_team_session_id(session_id)]
        team_names = [row.name for row in self.get_team_session_id(session_id)]
        lists = [[] for _ in range(len(tids))]
        flag = 0
        for i in range(len(tids)):
            # Get min and max
            try:
                # Query to get the min & max student points of their final
                final_points = db.session.query(
                    func.max(reports.points).label("max_points"),
                    func.min(reports.points).label("min_points"),
                    reports.reviewee).filter_by(tid=tids[i], is_final=True).filter(
                        reports.reviewee != reports.reviewer).group_by(reports.reviewee)
                # Query to get the min & max student points of their midterm
                midterm_points = db.session.query(
                    func.max(reports.points).label("max_points"),
                    func.min(reports.points).label("min_points"),
                    reports.reviewee).filter_by(tid=tids[i], is_final=False).filter(
                        reports.reviewee != reports.reviewer).group_by(reports.reviewee)
                # Query to get the students in the students table
                team_members = student.query.filter_by(tid=tids[i], session_id=session_id)
            except exc.SQLAlchemyError:
                handle_exception()
                return 'Error'

            temp = [team_names[i]]
            for team_member in team_members:
                # Checks whether the review is within the midterm dates
                if session.check_review_state(session_id, today) == "midterm":
                    for m in midterm_points:
                        if (team_member.id == m.reviewee):  # If the student's ID matches the review ID
                            params = {"name": team_member.name,
                                      "id": team_member.id,
                                      "active": "Midterm: ",
                                      "min_points": m.min_points,
                                      "max_points": m.max_points,
                                      "lead": int(team_member.is_lead)}
                            temp.append(params)
                            flag = 1
                # Checks whether the review is within the final dates
                elif session.check_review_state(session_id, today) == "final":
                    for f in final_points:
                        if (team_member.id == f.reviewee):  # If the student's ID matches the review ID
                            params = {"name": team_member.name,
                                      "id": team_member.id,
                                      "active": "Final: ",
                                      "min_points": f.min_points,
                                      "max_points": f.max_points,
                                      "lead": int(team_member.is_lead)}
                            temp.append(params)
                            flag = 1
                if flag == 0:
                    params = {"name": team_member.name,
                              "id": team_member.id,
                              "active": "",
                              "min_points": "",
                              "max_points": "",
                              "lead": int(team_member.is_lead)}
                    temp.append(params)
                flag = 0
            lists[i] = temp
        return lists, sessions

        Return a lists of sessions from the database
        and a list of teams + students from a selected session
        Input: session id of the selected session
        
Return a lists of sessions from the database
and a list of teams + students from a selected session
Input: session id of the selected session
Return a lists of sessions from the database and a list of teams + students from a selected session Input : session id of the selected session
def dashboard(self, session_id):
        student = students()
        session = capstone_session()
        today = datetime.datetime.now()
        sessions = session.get_sessions()
        if self.get_team_session_id(session_id) is None:
            return None, sessions
        tids = [row.id for row in self.get_team_session_id(session_id)]
        team_names = [row.name for row in self.get_team_session_id(session_id)]
        lists = [[] for _ in range(len(tids))]
        flag = 0
        for i in range(len(tids)):
            try:
                final_points = db.session.query(
                    func.max(reports.points).label("max_points"),
                    func.min(reports.points).label("min_points"),
                    reports.reviewee).filter_by(tid=tids[i], is_final=True).filter(
                        reports.reviewee != reports.reviewer).group_by(reports.reviewee)
                midterm_points = db.session.query(
                    func.max(reports.points).label("max_points"),
                    func.min(reports.points).label("min_points"),
                    reports.reviewee).filter_by(tid=tids[i], is_final=False).filter(
                        reports.reviewee != reports.reviewer).group_by(reports.reviewee)
                team_members = student.query.filter_by(tid=tids[i], session_id=session_id)
            except exc.SQLAlchemyError:
                handle_exception()
                return 'Error'
            temp = [team_names[i]]
            for team_member in team_members:
                if session.check_review_state(session_id, today) == "midterm":
                    for m in midterm_points:
                        if (team_member.id == m.reviewee):  
                            params = {"name": team_member.name,
                                      "id": team_member.id,
                                      "active": "Midterm: ",
                                      "min_points": m.min_points,
                                      "max_points": m.max_points,
                                      "lead": int(team_member.is_lead)}
                            temp.append(params)
                            flag = 1
                elif session.check_review_state(session_id, today) == "final":
                    for f in final_points:
                        if (team_member.id == f.reviewee):  
                            params = {"name": team_member.name,
                                      "id": team_member.id,
                                      "active": "Final: ",
                                      "min_points": f.min_points,
                                      "max_points": f.max_points,
                                      "lead": int(team_member.is_lead)}
                            temp.append(params)
                            flag = 1
                if flag == 0:
                    params = {"name": team_member.name,
                              "id": team_member.id,
                              "active": "",
                              "min_points": "",
                              "max_points": "",
                              "lead": int(team_member.is_lead)}
                    temp.append(params)
                flag = 0
            lists[i] = temp
        return lists, sessions
def dashboard ( self , session_id ) : student = students ( ) session = capstone_session ( ) today = datetime . datetime . now ( ) sessions = session . get_sessions ( ) if self . get_team_session_id ( session_id ) is None : return None , sessions tids = [ row . id for row in self . get_team_session_id ( session_id ) ] team_names = [ row . name for row in self . get_team_session_id ( session_id ) ] lists = [ [ ] for _ in range ( len ( tids ) ) ] flag = 0 for i in range ( len ( tids ) ) : try : final_points = db . session . query ( func . max ( reports . points ) . label ( "max_points" ) , func . min ( reports . points ) . label ( "min_points" ) , reports . reviewee ) . filter_by ( tid = tids [ i ] , is_final = True ) . filter ( reports . reviewee != reports . reviewer ) . group_by ( reports . reviewee ) midterm_points = db . session . query ( func . max ( reports . points ) . label ( "max_points" ) , func . min ( reports . points ) . label ( "min_points" ) , reports . reviewee ) . filter_by ( tid = tids [ i ] , is_final = False ) . filter ( reports . reviewee != reports . reviewer ) . group_by ( reports . reviewee ) team_members = student . query . filter_by ( tid = tids [ i ] , session_id = session_id ) except exc . SQLAlchemyError : handle_exception ( ) return 'Error' temp = [ team_names [ i ] ] for team_member in team_members : if session . check_review_state ( session_id , today ) == "midterm" : for m in midterm_points : if ( team_member . id == m . reviewee ) : params = { "name" : team_member . name , "id" : team_member . id , "active" : "Midterm: " , "min_points" : m . min_points , "max_points" : m . max_points , "lead" : int ( team_member . is_lead ) } temp . append ( params ) flag = 1 elif session . check_review_state ( session_id , today ) == "final" : for f in final_points : if ( team_member . id == f . reviewee ) : params = { "name" : team_member . name , "id" : team_member . id , "active" : "Final: " , "min_points" : f . min_points , "max_points" : f . max_points , "lead" : int ( team_member . is_lead ) } temp . append ( params ) flag = 1 if flag == 0 : params = { "name" : team_member . name , "id" : team_member . id , "active" : "" , "min_points" : "" , "max_points" : "" , "lead" : int ( team_member . is_lead ) } temp . append ( params ) flag = 0 lists [ i ] = temp return lists , sessions
Return a lists of sessions from the database
and a list of teams + students from a selected session
Input: session id of the selected session
Return a lists of sessions from the database and a list of teams + students from a selected session Input : session id of the selected session
"""
        Return a lists of sessions from the database
        and a list of teams + students from a selected session
        Input: session id of the selected session
        """ # Get min and max # Query to get the min & max student points of their final # Query to get the min & max student points of their midterm # Query to get the students in the students table # Checks whether the review is within the midterm dates # If the student's ID matches the review ID # Checks whether the review is within the final dates # If the student's ID matches the review ID
self
session_id