<commit_before><?php

namespace QuizBundle\Repository;

use CommonBundle\Component\Doctrine\ORM\EntityRepository,
    QuizBundle\Entity\Quiz as QuizEntity;

/**
 * Round
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class Round extends EntityRepository
{
    /**
     * Gets all rounds belonging to a quiz
     * @param QuizBundle\Entity\Quiz $quiz The quiz the rounds must belong to
     */
    public function findAllByQuizQuery(QuizEntity $quiz)
    {
        $query = $this->_em->createQueryBuilder();

        $resultSet = $query->select('r')
            ->from('QuizBundle\Entity\Round', 'r')
            ->where(
                $query->expr()->eq('r.quiz', ':quiz')
            )
            ->orderBy('r.order', 'ASC')
            ->setParameter('quiz', $quiz)
            ->getQuery();

        return $resultSet;
    }

    /**
     * Gets the order for the next round in the quiz
     * @param \QuizBundle\Entity\Quiz $quiz
     * @return int
     */
    public function getNextRoundOrderForQuiz(QuizEntity $quiz)
    {
        $query = $this->_em->createQueryBuilder();
        $resultSet = $query->select('MAX(r.order)')
            ->from('QuizBundle\Entity\Round', 'r')
            ->where(
                $query->expr()->eq('r.quiz', ':quiz')
            )
            ->orderBy('r.order', 'DESC')
            ->setParameter('quiz', $quiz)
            ->getQuery()
            ->getSingleScalarResult();

        if($resultSet === null)
            return 1;

        return $resultSet + 1;
    }
}<commit_msg>fixed quizbug<commit_after><?php

namespace QuizBundle\Repository;

use CommonBundle\Component\Doctrine\ORM\EntityRepository,
    QuizBundle\Entity\Quiz as QuizEntity;

/**
 * Round
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class Round extends EntityRepository
{
    /**
     * Gets all rounds belonging to a quiz
     * @param QuizBundle\Entity\Quiz $quiz The quiz the rounds must belong to
     */
    public function findAllByQuizQuery(QuizEntity $quiz)
    {
        $query = $this->_em->createQueryBuilder();

        $resultSet = $query->select('r')
            ->from('QuizBundle\Entity\Round', 'r')
            ->where(
                $query->expr()->eq('r.quiz', ':quiz')
            )
            ->orderBy('r.order', 'ASC')
            ->setParameter('quiz', $quiz)
            ->getQuery();

        return $resultSet;
    }

    /**
     * Gets the order for the next round in the quiz
     * @param \QuizBundle\Entity\Quiz $quiz
     * @return int
     */
    public function getNextRoundOrderForQuiz(QuizEntity $quiz)
    {
        $query = $this->_em->createQueryBuilder();
        $resultSet = $query->select('MAX(r.order)')
            ->from('QuizBundle\Entity\Round', 'r')
            ->where(
                $query->expr()->eq('r.quiz', ':quiz')
            )
            ->setParameter('quiz', $quiz)
            ->getQuery()
            ->getSingleScalarResult();

        if($resultSet === null)
            return 1;

        return $resultSet + 1;
    }
}
{'fraction_non_alphanumeric': 0.14235556974146185, 'fraction_numerical': 0.0012767315671879987, 'mean_word_length': 2.0309477756286265, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3001276', 'n_tokens_mistral': 953, 'n_tokens_neox': 924, 'n_words': 211}