Get current questionnaire has started

@param UserInterface $user
173934
public function getQuestionnaireStarted(UserInterface $user)
    {
        $userSessions = $this->manager->getRepository('QcmPublicBundle:UserSession')->findBy(array(
            'user' => $user
        ));

        foreach ($userSessions as $userSession) {
            $configuration = $userSession->getConfiguration();
            if (!is_null($configuration->getStartAt()) && is_null($configuration->getEndAt())) {
                $this->startQuestionnaire($userSession);
                $this->getLastAnsweredQuestion();
                break;
            }
        }
    }
1002548
public static function isAdmin(UserInterface $user = null): bool
    {
        $user = $user ?? self::user();

        return $user->getPreference('canadmin') === '1';
    }
761077
public function removeUser(UserInterface $user)
    {
        $this->users->removeElement($user);

        if ($user->hasRole($this) === true)
            $user->removeRole($this);
        
        return $this;
    }
563682
private function generateTokenForUser(UserInterface $user)
    {
        // if a token was already requested within the request interval time frame
        if (null !== $user->getPasswordResetToken()
            && $this->dateIsInRequestFrame($user->getPasswordResetTokenExpiresAt())) {
            throw new TokenAlreadyRequestedException(self::getRequestInterval());
        }
        $em = $this->getDoctrine()->getManager();

        $user->setPasswordResetToken($this->getToken());
        $expireDateTime = (new \DateTime())->add(self::getResetInterval());
        $user->setPasswordResetTokenExpiresAt($expireDateTime);
        $user->setPasswordResetTokenEmailsSent(0);

        $em->persist($user);
        $em->flush();
    }
1248456
public function findPendingInvitationsQuery(UserInterface $user)
    {
        $qb = $this->createQueryBuilder('i');

        return $qb
            ->join('i.event', 'e')

            // Add conditions.
            ->andWhere($qb->expr()->eq('e.active', ':active'))
            ->andWhere($qb->expr()->gt('e.end', ':now'))
            ->andWhere($qb->expr()->isNull('i.response'))
            ->andWhere($qb->expr()->eq('i.invitee', ':invitee'))

            // Add parameters.
            ->setParameter('active', true)
            ->setParameter('now', new \DateTime())
            ->setParameter('invitee', $user->getUsername())

            // Get query.
            ->getQuery();
    }
438232
public function getFavouriteAccountsForUser(UserInterface $user)
    {
        $criteria = new Criteria();
        $criteria
            ->where($criteria->expr()->in(
                'id',
                $user->getMyFavouriteAccountIds()
            ))
        ;

        return $this->oh->getOrganization()
            ->getAccounts()
            ->matching($criteria)
        ;
    }
134558
public function findUserOrdersForCurrentMonth($locale, UserInterface $user)
    {
        try {
            $qb = $this->getOrderQuery($locale)
                ->andWhere('status.id >= :statusId')
                ->andWhere('o.changed >= :currentMonth')
                ->andWhere('o.creator = :user')
                ->setParameter('statusId', OrderStatus::STATUS_CONFIRMED)
                ->setParameter('currentMonth', date('Y-m-01 0:00:00'))
                ->setParameter('user', $user)
                ->orderBy('o.created', 'ASC');

            return $qb->getQuery()->getResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
241507
protected function storeDateTimeSettingsInSession(UserInterface $user, SessionInterface $session)
    {
        $session->set('campaignchain.locale', $user->getLocale());
        $session->set('campaignchain.timezone', $user->getTimezone());
        $session->set('campaignchain.dateFormat', $user->getDateFormat());
        $session->set('campaignchain.timeFormat', $user->getTimeFormat());
    }
379796
public function checkCurrentUser(GetResponseUserEvent $event)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        if ($currentUser instanceof UserInterface) {
            $resetUser = $event->getUser();

            if ($currentUser->getId() !== $resetUser->getId()) {
                $this->setRedirecToLogin($event);
            }
        }
    }
565630
protected function loadAPIUser(SyliusUserInterface $user)
    {
        $eZSyliusUser = $this->eZUserRepository->findOneBy(
            array(
                'syliusUserId' => $user->getId(),
                'syliusUserType' => $this->syliusUserType,
            )
        );

        if (!$eZSyliusUser instanceof EzSyliusUser) {
            return null;
        }

        try {
            return $this->repository->getUserService()->loadUser(
                $eZSyliusUser->getEzUserId()
            );
        } catch (NotFoundException $e) {
            return null;
        }
    }
390747
protected function applyUserLocale(UserInterface $user)
    {
        // Set the current language according to locale preference
        $locale = $user->getLocale();

        if (null === $lang = LangQuery::create()->findOneByLocale($locale)) {
            $lang = Lang::getDefaultLanguage();
        }

        $this->getSession()->setLang($lang);
    }
729722
public function isAdmitted(UserInterface $user = null)
    {
        if (is_null($user)) {
            return !$this->currentUser() instanceof GuestUser;
        }

        return $user->getIdentifier() === $this->currentUser()->getIdentifier();
    }
362222
public function checkCredentials($credentials, UserInterface $user)
    {
        return $this->userPasswordEncoderFactory->isPasswordValid($user, $credentials->getPassword());
    }
23493
protected function attachRefreshToken(UserInterface $user)
    {
        $refreshTokenManager = $this->container->get('gesdinet.jwtrefreshtoken.refresh_token_manager');
        $refreshToken = $refreshTokenManager->getLastFromUsername($user->getUsername());
        $refreshTokenTtl = $this->container->getParameter('gesdinet_jwt_refresh_token.ttl');

        if (!$refreshToken instanceof RefreshToken) {
            $refreshToken = $refreshTokenManager->create();
            $expirationDate = new \DateTime();
            $expirationDate->modify(sprintf('+%s seconds', $refreshTokenTtl));
            $refreshToken->setUsername($user->getUsername());
            $refreshToken->setRefreshToken();
            $refreshToken->setValid($expirationDate);

            $refreshTokenManager->save($refreshToken);
        }

        return $refreshToken->getRefreshToken();
    }
602755
public function completed(UserInterface $user)
    {
        $queryBuilder = $this->createQueryBuilder('a');

        $queryBuilder
            ->where('a.user = :user')
            ->andWhere('a.completed = :completed');

        $queryBuilder
            ->setParameters([
                'user' => $user,
                'completed' => true
            ]);

        try
        {
            return $queryBuilder->getQuery()->getSingleResult();
        }
        catch (NoResultException $e)
        {
            return false;
        }
    }
1037370
public function getUserRole(UserInterface $user)
    {
        $currentRole = '';
        $userRoles = $user->getRoles();

        if (in_array($userRoles[0], $this->getOrderedRoles())) {
            $currentRole = $userRoles[0];
        }

        return $currentRole;
    }
1046736
protected function getCurrentUser()
    {
        if (!$this->tokenStorage) {
            return;
        }

        if (!$this->tokenStorage->getToken()) {
            return;
        }

        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof UserInterface) {
            return $user;
        }

        return;
    }