Ejemplo n.º 1
0
    def get_by_user_name_and_lesson_name(cls, connection, user_name,
                                         lesson_name):
        """Get an activity with user_name, lesson_name from 'activity_lesson' table

        :param connection: DB connection object
        :param user_name: user name
        :param lesson_name: lesson name
        :return: activity details
            {
                'user_id': user_id,
                'lesson_id': lesson_id,
                'opened_at': <datetime>,
                'completed': True (or) False,
                'completed_at': <datetime>
            }
        """
        user_id = User.get_user_id(connection, user_name)
        lesson_id = Lesson.get_lesson_id(connection, lesson_name)
        return cls.get_by_user_id_and_lesson_id(connection, user_id, lesson_id)
Ejemplo n.º 2
0
    def get_by_lesson_name(cls, connection, lesson_name, completed=None):
        """Get all activities with lesson_name from 'activity_lesson' table of all users

        :param connection: DB connection object
        :param lesson_name: lesson name
        :param completed: status of the activity (True/False/None)
                True - returns all the completed lesson_name lessons of all users
                False - return all the in-progress lesson_name lessons of all user
                None - return all the lesson_name lessons of all users
        :return: list of activities of all users with lesson_name
            [{
                'user_id': <user-id>,
                'lesson_id': lesson_id,
                'opened_at': <datetime>,
                'completed': True (or) False,
                'completed_at': <datetime>
            }]
        """
        lesson_id = Lesson.get_lesson_id(connection, lesson_name)
        return cls.get_by_lesson_id(connection, lesson_id, completed=completed)