parent
6c541949e3
commit
15243bb264
@ -0,0 +1,266 @@ |
||||
<?php |
||||
|
||||
namespace Entity; |
||||
|
||||
use Doctrine\ORM\Mapping as ORM; |
||||
use Doctrine\Common\Collections\ArrayCollection; |
||||
|
||||
/** |
||||
* Jury |
||||
* |
||||
* @ORM\Table(name="jury") |
||||
* @ORM\Entity(repositoryClass="Entity\Repository\JuryRepository") |
||||
*/ |
||||
class Jury |
||||
{ |
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) |
||||
* @ORM\Id |
||||
* @ORM\GeneratedValue(strategy="IDENTITY") |
||||
*/ |
||||
private $id; |
||||
|
||||
/** |
||||
* @var string |
||||
* |
||||
* @ORM\Column(name="name", type="string", length=255, precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $name; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="branch_id", type="integer", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $branchId; |
||||
|
||||
/** |
||||
* @var \DateTime |
||||
* |
||||
* @ORM\Column(name="opening_date", type="datetime", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $openingDate; |
||||
|
||||
/** |
||||
* @var \DateTime |
||||
* |
||||
* @ORM\Column(name="closure_date", type="datetime", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $closureDate; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="opening_user_id", type="integer", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $openingUserId; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="closure_user_id", type="integer", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $closureUserId; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="exercise_id", type="integer", precision=0, scale=0, nullable=false, unique=false) |
||||
*/ |
||||
private $exerciseId; |
||||
|
||||
/** |
||||
* @ORM\OneToMany(targetEntity="JuryMembers", mappedBy="jury") |
||||
**/ |
||||
private $members; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$this->members = new ArrayCollection(); |
||||
} |
||||
|
||||
/** |
||||
* @return mixed |
||||
*/ |
||||
public function getMembers() |
||||
{ |
||||
return $this->members; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Get id |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getId() |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
/** |
||||
* Set name |
||||
* |
||||
* @param string $name |
||||
* @return Jury |
||||
*/ |
||||
public function setName($name) |
||||
{ |
||||
$this->name = $name; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get name |
||||
* |
||||
* @return string |
||||
*/ |
||||
public function getName() |
||||
{ |
||||
return $this->name; |
||||
} |
||||
|
||||
/** |
||||
* Set branchId |
||||
* |
||||
* @param integer $branchId |
||||
* @return Jury |
||||
*/ |
||||
public function setBranchId($branchId) |
||||
{ |
||||
$this->branchId = $branchId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get branchId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getBranchId() |
||||
{ |
||||
return $this->branchId; |
||||
} |
||||
|
||||
/** |
||||
* Set openingDate |
||||
* |
||||
* @param \DateTime $openingDate |
||||
* @return Jury |
||||
*/ |
||||
public function setOpeningDate($openingDate) |
||||
{ |
||||
$this->openingDate = $openingDate; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get openingDate |
||||
* |
||||
* @return \DateTime |
||||
*/ |
||||
public function getOpeningDate() |
||||
{ |
||||
return $this->openingDate; |
||||
} |
||||
|
||||
/** |
||||
* Set closureDate |
||||
* |
||||
* @param \DateTime $closureDate |
||||
* @return Jury |
||||
*/ |
||||
public function setClosureDate($closureDate) |
||||
{ |
||||
$this->closureDate = $closureDate; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get closureDate |
||||
* |
||||
* @return \DateTime |
||||
*/ |
||||
public function getClosureDate() |
||||
{ |
||||
return $this->closureDate; |
||||
} |
||||
|
||||
/** |
||||
* Set openingUserId |
||||
* |
||||
* @param integer $openingUserId |
||||
* @return Jury |
||||
*/ |
||||
public function setOpeningUserId($openingUserId) |
||||
{ |
||||
$this->openingUserId = $openingUserId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get openingUserId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getOpeningUserId() |
||||
{ |
||||
return $this->openingUserId; |
||||
} |
||||
|
||||
/** |
||||
* Set closureUserId |
||||
* |
||||
* @param integer $closureUserId |
||||
* @return Jury |
||||
*/ |
||||
public function setClosureUserId($closureUserId) |
||||
{ |
||||
$this->closureUserId = $closureUserId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get closureUserId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getClosureUserId() |
||||
{ |
||||
return $this->closureUserId; |
||||
} |
||||
|
||||
/** |
||||
* Set exerciseId |
||||
* |
||||
* @param integer $exerciseId |
||||
* @return Jury |
||||
*/ |
||||
public function setExerciseId($exerciseId) |
||||
{ |
||||
$this->exerciseId = $exerciseId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get exerciseId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getExerciseId() |
||||
{ |
||||
return $this->exerciseId; |
||||
} |
||||
} |
||||
@ -0,0 +1,143 @@ |
||||
<?php |
||||
|
||||
namespace Entity; |
||||
|
||||
use Doctrine\ORM\Mapping as ORM; |
||||
|
||||
/** |
||||
* JuryMembers |
||||
* |
||||
* @ORM\Table(name="jury_members") |
||||
* @ORM\Entity |
||||
*/ |
||||
class JuryMembers |
||||
{ |
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false) |
||||
* @ORM\Id |
||||
* @ORM\GeneratedValue(strategy="IDENTITY") |
||||
*/ |
||||
private $id; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="user_id", type="integer", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $userId; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="role_id", type="integer", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $roleId; |
||||
|
||||
/** |
||||
* @var integer |
||||
* |
||||
* @ORM\Column(name="jury_id", type="integer", precision=0, scale=0, nullable=true, unique=false) |
||||
*/ |
||||
private $juryId; |
||||
|
||||
/** |
||||
* @ORM\ManyToOne(targetEntity="User") |
||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="user_id") |
||||
*/ |
||||
private $user; |
||||
|
||||
/** |
||||
* @ORM\ManyToOne(targetEntity="Jury") |
||||
* @ORM\JoinColumn(name="jury_id", referencedColumnName="id") |
||||
*/ |
||||
private $jury; |
||||
|
||||
|
||||
/** |
||||
* @ORM\ManyToOne(targetEntity="Role") |
||||
* @ORM\JoinColumn(name="role_id", referencedColumnName="id") |
||||
*/ |
||||
private $role; |
||||
|
||||
|
||||
/** |
||||
* Get id |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getId() |
||||
{ |
||||
return $this->id; |
||||
} |
||||
|
||||
/** |
||||
* Set userId |
||||
* |
||||
* @param integer $userId |
||||
* @return JuryMembers |
||||
*/ |
||||
public function setUserId($userId) |
||||
{ |
||||
$this->userId = $userId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get userId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getUserId() |
||||
{ |
||||
return $this->userId; |
||||
} |
||||
|
||||
/** |
||||
* Set roleId |
||||
* |
||||
* @param integer $roleId |
||||
* @return JuryMembers |
||||
*/ |
||||
public function setRoleId($roleId) |
||||
{ |
||||
$this->roleId = $roleId; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get roleId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getRoleId() |
||||
{ |
||||
return $this->roleId; |
||||
} |
||||
|
||||
/** |
||||
* Set juryId |
||||
* |
||||
* @param integer $id |
||||
* @return JuryMembers |
||||
*/ |
||||
public function setJuryId($id) |
||||
{ |
||||
$this->juryId = $id; |
||||
|
||||
return $this; |
||||
} |
||||
|
||||
/** |
||||
* Get juryId |
||||
* |
||||
* @return integer |
||||
*/ |
||||
public function getJuryId() |
||||
{ |
||||
return $this->juryId; |
||||
} |
||||
} |
||||
@ -0,0 +1,51 @@ |
||||
<?php |
||||
|
||||
namespace Entity\Repository; |
||||
|
||||
use Doctrine\ORM\EntityRepository; |
||||
use Doctrine\Common\Collections\Criteria; |
||||
|
||||
/** |
||||
* JuryRepository |
||||
* |
||||
*/ |
||||
class JuryRepository extends EntityRepository |
||||
{ |
||||
/** |
||||
* Get all users that are registered in the course. No matter the status |
||||
* |
||||
* @param \Entity\Course $course |
||||
* @return \Doctrine\ORM\QueryBuilder |
||||
*/ |
||||
public function getJuryByPresidentId($userId) |
||||
{ |
||||
$qb = $this->createQueryBuilder('a'); |
||||
|
||||
//Selecting user info |
||||
$qb->select('DISTINCT u'); |
||||
|
||||
// Loading EntityUser |
||||
$qb->from('Entity\Jury', 'u'); |
||||
|
||||
// Selecting members |
||||
$qb->innerJoin('u.members', 'c'); |
||||
|
||||
// Inner join with the table c_quiz_question_rel_category. |
||||
$qb->innerJoin('c.role', 'r'); |
||||
|
||||
//@todo check app settings |
||||
//$qb->add('orderBy', 'u.lastname ASC'); |
||||
|
||||
$wherePart = $qb->expr()->andx(); |
||||
|
||||
//Get only users subscribed to this course |
||||
$wherePart->add($qb->expr()->eq('r.name', $qb->expr()->literal('ROLE_JURY_PRESIDENT'))); |
||||
$wherePart->add($qb->expr()->eq('c.userId', $userId)); |
||||
|
||||
$qb->where($wherePart); |
||||
$q = $qb->getQuery(); |
||||
return $q->execute(); |
||||
//return $qb; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,5 @@ |
||||
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %} |
||||
{% block content %} |
||||
{% import app.template_style ~ "/default_actions/settings.tpl" as actions %} |
||||
{{ actions.add(form, links) }} |
||||
{% endblock %} |
||||
@ -0,0 +1,5 @@ |
||||
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %} |
||||
{% block content %} |
||||
{% import app.template_style ~ "/default_actions/settings.tpl" as actions %} |
||||
{{ actions.edit(form, links) }} |
||||
{% endblock %} |
||||
@ -0,0 +1,5 @@ |
||||
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %} |
||||
{% block content %} |
||||
{% import app.template_style ~ "/default_actions/settings.tpl" as actions %} |
||||
{{ actions.list(items, links) }} |
||||
{% endblock %} |
||||
@ -0,0 +1,5 @@ |
||||
{% extends app.template_style ~ "/layout/layout_1_col.tpl" %} |
||||
{% block content %} |
||||
{% import app.template_style ~ "/default_actions/settings.tpl" as actions %} |
||||
{{ actions.read(item, links) }} |
||||
{% endblock %} |
||||
@ -0,0 +1,108 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace ChamiloLMS\Controller\Admin\Administrator; |
||||
|
||||
use ChamiloLMS\Controller\CommonController; |
||||
use Silex\Application; |
||||
use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Entity; |
||||
use ChamiloLMS\Form\JuryType; |
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
||||
|
||||
/** |
||||
* Class JuryController |
||||
* @todo @route and @method function don't work yet |
||||
* @package ChamiloLMS\Controller |
||||
* @author Julio Montoya <gugli100@gmail.com> |
||||
*/ |
||||
class JuryController extends CommonController |
||||
{ |
||||
/** |
||||
* |
||||
* @Route("/") |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function indexAction() |
||||
{ |
||||
return parent::listingAction(); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @Route("/{id}", requirements={"id" = "\d+"}, defaults={"foo" = "bar"}) |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function readAction($id) |
||||
{ |
||||
return parent::readAction($id); |
||||
} |
||||
|
||||
/** |
||||
* @Route("/add") |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function addAction() |
||||
{ |
||||
return parent::addAction(); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @Route("/{id}/edit", requirements={"id" = "\d+"}, defaults={"foo" = "bar"}) |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function editAction($id) |
||||
{ |
||||
return parent::editAction($id); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @Route("/{id}/delete", requirements={"id" = "\d+"}, defaults={"foo" = "bar"}) |
||||
* @Method({"GET"}) |
||||
*/ |
||||
public function deleteAction($id) |
||||
{ |
||||
return parent::deleteAction($id); |
||||
} |
||||
|
||||
protected function getControllerAlias() |
||||
{ |
||||
return 'jury.controller'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getTemplatePath() |
||||
{ |
||||
return 'admin/administrator/juries/'; |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getRepository() |
||||
{ |
||||
return $this->get('orm.em')->getRepository('Entity\Jury'); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getNewEntity() |
||||
{ |
||||
return new Entity\Jury(); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
protected function getFormType() |
||||
{ |
||||
return new JuryType(); |
||||
} |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
<?php |
||||
|
||||
namespace ChamiloLMS\Form; |
||||
|
||||
use Symfony\Component\Form\AbstractType; |
||||
use Symfony\Component\Form\FormBuilderInterface; |
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
||||
use Entity; |
||||
|
||||
class JuryType extends AbstractType |
||||
{ |
||||
public function buildForm(FormBuilderInterface $builder, array $options) |
||||
{ |
||||
$builder->add('name', 'text'); |
||||
$builder->add('opening_date', 'datetime', array( |
||||
'data' => new \DateTime() |
||||
) |
||||
); |
||||
|
||||
$builder->add('closure_date', 'datetime', array( |
||||
'data' => new \DateTime() |
||||
) |
||||
); |
||||
|
||||
$builder->add('opening_user_id', 'text'); |
||||
$builder->add('closure_user_id', 'text'); |
||||
$builder->add('exercise_id', 'text'); |
||||
|
||||
//$builder->add('users', 'collection', array('type' => new JuryType())); |
||||
|
||||
$builder->add('submit', 'submit'); |
||||
} |
||||
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver) |
||||
{ |
||||
$resolver->setDefaults( |
||||
array( |
||||
'data_class' => 'Entity\Jury' |
||||
) |
||||
); |
||||
} |
||||
|
||||
public function getName() |
||||
{ |
||||
return 'jury'; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue