Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/inc/Entity/Repository/CQuizQuestionRepository.php

41 lines
1.0 KiB

<?php
namespace Entity\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\Common\Collections\Criteria;
/**
* CQuizQuestion
*
*/
class CQuizQuestionRepository extends EntityRepository
{
/**
* Get all questions per category
*
* @param int $categoryId
* @return \Doctrine\ORM\QueryBuilder
*/
public function getQuestionsByCategory($categoryId)
{
// Setting alias for this class "q" = CQuizQuestion.
$qb = $this->createQueryBuilder('q');
// Select all question information.
$qb->select('q');
// Inner join with the table c_quiz_question_rel_category.
$qb->innerJoin('q.quizQuestionRelCategoryList', 'c');
// Inner join with question extra fields.
//$qb->innerJoin('q.extraFields', 'e');
$wherePart = $qb->expr()->andx();
$wherePart->add($qb->expr()->eq('c.categoryId', $categoryId));
$qb->where($wherePart);
//echo $qb->getQuery()->getSQL()."<br>";
return $qb;
}
}