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