plugin/drop-zone/Manager/DropzoneManager.php
public function getAvailableDropForPeer(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null)
    {
        $peerDrop = null;
        $drops = [];

        switch ($dropzone->getDropType()) {
            case Dropzone::DROP_TYPE_USER:
                if (!empty($user)) {
                    $drops = $this->dropRepo->findUserAvailableDrops($dropzone, $user);
                }
                break;
            case Dropzone::DROP_TYPE_TEAM:
                if ($teamId) {
                    $drops = $this->dropRepo->findTeamAvailableDrops($dropzone, $teamId);
                }
                break;
        }
        $validDrops = [];

        foreach ($drops as $drop) {
            $corrections = $drop->getCorrections();

            if (count($corrections) < $dropzone->getExpectedCorrectionTotal()) {
                $validDrops[] = $drop;
            }
        }
        if (count($validDrops) > 0) {
            /* Selects the drop with the least corrections */
            $peerDrop = $this->getDropWithTheLeastCorrections($validDrops);

            /* Creates empty correction */
            $correction = new Correction();
            $correction->setDrop($peerDrop);
            $correction->setUser($user);
            $correction->setTeamUuid($teamId);
            $correction->setTeamName($teamName);
            $currentDate = new \DateTime();
            $correction->setStartDate($currentDate);
            $correction->setLastEditionDate($currentDate);
            $peerDrop->addCorrection($correction);
            $this->om->persist($correction);
            $this->om->flush();
        }

        return $peerDrop;
    }
public function getAvailableDropForPeer(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null)
    {
        $peerDrop = null;
        $drops = [];

        switch ($dropzone->getDropType()) {
            case Dropzone::DROP_TYPE_USER:
                if (!empty($user)) {
                    $drops = $this->dropRepo->findUserAvailableDrops($dropzone, $user);
                }
                break;
            case Dropzone::DROP_TYPE_TEAM:
                if ($teamId) {
                    $drops = $this->dropRepo->findTeamAvailableDrops($dropzone, $teamId);
                }
                break;
        }
        $validDrops = [];

        foreach ($drops as $drop) {
            $corrections = $drop->getCorrections();

            if (count($corrections) < $dropzone->getExpectedCorrectionTotal()) {
                $validDrops[] = $drop;
            }
        }
        if (count($validDrops) > 0) {
            /* Selects the drop with the least corrections */
            $peerDrop = $this->getDropWithTheLeastCorrections($validDrops);

            /* Creates empty correction */
            $correction = new Correction();
            $correction->setDrop($peerDrop);
            $correction->setUser($user);
            $correction->setTeamUuid($teamId);
            $correction->setTeamName($teamName);
            $currentDate = new \DateTime();
            $correction->setStartDate($currentDate);
            $correction->setLastEditionDate($currentDate);
            $peerDrop->addCorrection($correction);
            $this->om->persist($correction);
            $this->om->flush();
        }

        return $peerDrop;
    }
public function getAvailableDropForPeer ( Dropzone $ dropzone , User $ user = null , $ teamId = null , $ teamName = null ) { $ peerDrop = null ; $ drops = [ ] ; switch ( $ dropzone -> getDropType ( ) ) { case Dropzone :: DROP_TYPE_USER : if ( ! empty ( $ user ) ) { $ drops = $ this -> dropRepo -> findUserAvailableDrops ( $ dropzone , $ user ) ; } break ; case Dropzone :: DROP_TYPE_TEAM : if ( $ teamId ) { $ drops = $ this -> dropRepo -> findTeamAvailableDrops ( $ dropzone , $ teamId ) ; } break ; } $ validDrops = [ ] ; foreach ( $ drops as $ drop ) { $ corrections = $ drop -> getCorrections ( ) ; if ( count ( $ corrections ) < $ dropzone -> getExpectedCorrectionTotal ( ) ) { $ validDrops [ ] = $ drop ; } } if ( count ( $ validDrops ) > 0 ) { /* Selects the drop with the least corrections */ $ peerDrop = $ this -> getDropWithTheLeastCorrections ( $ validDrops ) ; /* Creates empty correction */ $ correction = new Correction ( ) ; $ correction -> setDrop ( $ peerDrop ) ; $ correction -> setUser ( $ user ) ; $ correction -> setTeamUuid ( $ teamId ) ; $ correction -> setTeamName ( $ teamName ) ; $ currentDate = new \ DateTime ( ) ; $ correction -> setStartDate ( $ currentDate ) ; $ correction -> setLastEditionDate ( $ currentDate ) ; $ peerDrop -> addCorrection ( $ correction ) ; $ this -> om -> persist ( $ correction ) ; $ this -> om -> flush ( ) ; } return $ peerDrop ; }
Gets available drop for peer evaluation.

@param Dropzone $dropzone
@param User     $user
@param string   $teamId
@param string   $teamName

@return Drop | null
Gets available drop for peer evaluation .