1
|
|
|
<?php |
2
|
|
|
/* For licensing terms, see /license.txt */ |
3
|
|
|
|
4
|
|
|
namespace Chamilo\CourseBundle\Entity\Repository; |
5
|
|
|
|
6
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
7
|
|
|
use Chamilo\UserBundle\Entity\User; |
8
|
|
|
use Doctrine\ORM\EntityRepository; |
9
|
|
|
use Doctrine\ORM\Query\Expr; |
10
|
|
|
use Doctrine\ORM\Query\Expr\Join; |
11
|
|
|
use Doctrine\ORM\Query\Expr\OrderBy; |
12
|
|
|
|
13
|
|
|
class CStudentPublicationRepository extends EntityRepository |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Find all the works registered by a teacher |
17
|
|
|
* @param User $user |
18
|
|
|
* @param Course $course |
19
|
|
|
* @param int $sessionId Optional |
20
|
|
|
* @param int $groupId Optional |
21
|
|
|
* @return array |
22
|
|
|
*/ |
23
|
|
|
public function findByTeacher(User $user, Course $course, $sessionId = 0, $groupId = 0) |
24
|
|
|
{ |
25
|
|
|
$qb = $this->createQueryBuilder('w'); |
26
|
|
|
return $qb |
27
|
|
|
->leftJoin( |
28
|
|
|
'ChamiloCourseBundle:CStudentPublicationAssignment', |
29
|
|
|
'a', |
30
|
|
|
Join::WITH, |
31
|
|
|
'a.publicationId = w.iid AND a.cId = w.cId' |
32
|
|
|
) |
33
|
|
|
->where( |
34
|
|
|
$qb->expr()->andX( |
35
|
|
|
$qb->expr()->eq('w.cId', ':course'), |
36
|
|
|
$qb->expr()->eq('w.sessionId', ':session'), |
37
|
|
|
$qb->expr()->in('w.active', [0, 1]), |
38
|
|
|
$qb->expr()->eq('w.parentId', 0), |
39
|
|
|
$qb->expr()->eq('w.postGroupId', ':group'), |
40
|
|
|
$qb->expr()->eq('w.userId', ':user') |
41
|
|
|
) |
42
|
|
|
) |
43
|
|
|
->orderBy('w.sentDate', 'DESC') |
44
|
|
|
->setParameters([ |
45
|
|
|
'course' => intval($course->getId()), |
46
|
|
|
'session' => intval($sessionId), |
47
|
|
|
'group' => intval($groupId), |
48
|
|
|
'user' => $user->getId() |
49
|
|
|
]) |
50
|
|
|
->getQuery() |
51
|
|
|
->getResult(); |
52
|
|
|
} |
53
|
|
|
} |