zeeguu/core/model/user_exercise_session.py
def update_exercise_session(cls, exercise, db_session):
        """

            Main callable method that keeps track of the exercise sessions.

            It does: If there is an open session for the user and article and the elapsed time is within the
            session_timeout range, it updates the session to the current time, otherwise, it closes and creates a new one

            Parameters:
            user_exercise = exercise instance
            db_session = database session

            returns: The exercise session or None when no user is found
        """
        user_id = exercise.find_user_id(db.session)
        if user_id:
            current_time = exercise.time
            start_time = current_time - timedelta(minutes=(exercise.solving_speed / 60000))

            most_recent_exercise_session = cls._find_most_recent_session(user_id, db_session)

            if most_recent_exercise_session:
                if most_recent_exercise_session._is_still_active(
                        current_time):  # Verify if the session is not expired (according to session timeout)
                    return most_recent_exercise_session._update_last_action_time(db_session, current_time=current_time)
                else:  # If the session is expired, close it and create a new one
                    most_recent_exercise_session._close_exercise_session(db_session)
                    return cls._create_new_session(db_session, user_id, start_time, current_time=current_time)
            else:
                return cls._create_new_session(db_session, user_id, start_time, current_time=current_time)
        else:
            return None


            Main callable method that keeps track of the exercise sessions.

            It does: If there is an open session for the user and article and the elapsed time is within the
            session_timeout range, it updates the session to the current time, otherwise, it closes and creates a new one

            Parameters:
            user_exercise = exercise instance
            db_session = database session

            returns: The exercise session or None when no user is found
        
Main callable method that keeps track of the exercise sessions.
It does: If there is an open session for the user and article and the elapsed time is within the
session_timeout range, it updates the session to the current time, otherwise, it closes and creates a new one

user_exercise = exercise instance
db_session = database session

The exercise session or None when no user is found
Main callable method that keeps track of the exercise sessions . It does : If there is an open session for the user and article and the elapsed time is within the session_timeout range it updates the session to the current time otherwise it closes and creates a new one user_exercise = exercise instance db_session = database session The exercise session or None when no user is found
def update_exercise_session(cls, exercise, db_session):
        user_id = exercise.find_user_id(db.session)
        if user_id:
            current_time = exercise.time
            start_time = current_time - timedelta(minutes=(exercise.solving_speed / 60000))
            most_recent_exercise_session = cls._find_most_recent_session(user_id, db_session)
            if most_recent_exercise_session:
                if most_recent_exercise_session._is_still_active(
                        current_time):  
                    return most_recent_exercise_session._update_last_action_time(db_session, current_time=current_time)
                else:  
                    most_recent_exercise_session._close_exercise_session(db_session)
                    return cls._create_new_session(db_session, user_id, start_time, current_time=current_time)
            else:
                return cls._create_new_session(db_session, user_id, start_time, current_time=current_time)
        else:
            return None
def update_exercise_session ( cls , exercise , db_session ) : user_id = exercise . find_user_id ( db . session ) if user_id : current_time = exercise . time start_time = current_time - timedelta ( minutes = ( exercise . solving_speed / 60000 ) ) most_recent_exercise_session = cls . _find_most_recent_session ( user_id , db_session ) if most_recent_exercise_session : if most_recent_exercise_session . _is_still_active ( current_time ) : return most_recent_exercise_session . _update_last_action_time ( db_session , current_time = current_time ) else : most_recent_exercise_session . _close_exercise_session ( db_session ) return cls . _create_new_session ( db_session , user_id , start_time , current_time = current_time ) else : return cls . _create_new_session ( db_session , user_id , start_time , current_time = current_time ) else : return None
Main callable method that keeps track of the exercise sessions.
Main callable method that keeps track of the exercise sessions .
"""

            Main callable method that keeps track of the exercise sessions.

            It does: If there is an open session for the user and article and the elapsed time is within the
            session_timeout range, it updates the session to the current time, otherwise, it closes and creates a new one

            Parameters:
            user_exercise = exercise instance
            db_session = database session

            returns: The exercise session or None when no user is found
        """ # Verify if the session is not expired (according to session timeout) # If the session is expired, close it and create a new one
cls
exercise
db_session