private function sendFinishedLog(Drop $drop) { // var_dump('sendFinishedLog'); if ($drop != null) { // var_dump('drop not null'); if ($drop->getDropzone()->getPeerReview() === false or $drop->countFinishedCorrections() >= $drop->getDropzone()->getExpectedTotalCorrection()) { // var_dump('pas de peer review ou bien assez de correction'); $finished = false; if ($drop->getDropzone()->getPeerReview() === true) { // var_dump('peer review. mais est ce que le user a corrigé assez de copie'); $nbCorrections = $this->entityManager->getRepository('IcapDropzoneBundle:Correction')->countFinished($drop->getDropzone(), $drop->getUser()); if ($nbCorrections >= $drop->getDropzone()->getExpectedTotalCorrection()) { $finished = true; } } else { // var_dump('pas de peer review donc fini !'); $finished = true; } if ($finished === true) { // var_dump('finish'); $grade = $drop->getCalculatedGrade(); $event = new LogDropEvaluateEvent($drop->getDropzone(), $drop, $grade); $event->setDoer($drop->getUser()); // var_dump('finish grade = '.$grade); $this->eventDispatcher->dispatch('log', $event); } } } }
private function sendFinishedLog(Drop $drop) { if ($drop != null) { if ($drop->getDropzone()->getPeerReview() === false || $drop->countFinishedCorrections() >= $drop->getDropzone()->getExpectedTotalCorrection()) { $finished = false; if ($drop->getDropzone()->getPeerReview() === true) { $nbCorrections = $this->entityManager->getRepository('IcapDropzoneBundle:Correction')->countFinished($drop->getDropzone(), $drop->getUser()); if ($nbCorrections >= $drop->getDropzone()->getExpectedTotalCorrection()) { $finished = true; } } else { $finished = true; } if ($finished === true) { $grade = $drop->getCalculatedGrade(); $event = new LogDropEvaluateEvent($drop->getDropzone(), $drop, $grade); $event->setDoer($drop->getUser()); $this->eventDispatcher->dispatch('log', $event); } } } }
public function testCountFinishedCorrections() { echo "testing DROP->CountFinishedCorrections\n"; // WARN, countFinished correction care about the valid property // a finished correction but invalis should not be in the count. $correction1 = $this->createCorrection(10, true); $correction2 = $this->createCorrection(20, false, true); $correction3 = $this->createCorrection(5, true, false); $correction4 = $this->createCorrection(3, false); $correction5 = $this->createCorrection(12, false, false); $correction6 = $this->createCorrection(12, true, true); $drop1 = new Drop(); $drop1->setCorrections(array($correction1, $correction2)); $this->assertEquals(1, $drop1->countFinishedCorrections()); $drop2 = new Drop(); $drop2->setCorrections(array($correction2, $correction3, $correction4, $correction5)); $this->assertEquals(0, $drop2->countFinishedCorrections()); $drop3 = new Drop(); $drop3->setCorrections(array($correction1, $correction3)); $this->assertEquals(1, $drop3->countFinishedCorrections()); $drop4 = new Drop(); $drop4->setCorrections(array($correction1, $correction2, $correction4, $correction5, $correction3, $correction6)); $this->assertEquals(2, $drop4->countFinishedCorrections()); }
/** * * STATES FOR NORMAL ARE : * 0 : not started * 1 : Waiting for drop * 2 : Drop received, waiting for correction * 3 : Copy corrected , Evaluation end. * * STATES FOR PEERREVIEW (for X correction ): * 0 : notStarted * 1 : Waiting for drop * 2 : Drop received * 3 : Correction 1/x * 4 : Correction 2/X * 5 : Correction X/X * 6 : Waiting for correction * 7 : copy corrected, Evaluation End. * * WARNING : if a drop has the 'unlockedDrop' property, it will make the drop being at the last state. * currentstate : index of the current state in the stateArray * percent : rounded progress in percent * nbCorrection : corrections made by the user in this evaluation. * * @param \Icap\DropzoneBundle\Entity\Dropzone $dropzone * @param \Icap\DropzoneBundle\Entity\Drop|\Icap\DropzoneBundle\Manager\Drop $drop * @param int $nbCorrection number of correction the user did. * @return array (states, currentState,percent,nbCorrection) */ public function getDrozponeProgress(Dropzone $dropzone, Drop $drop = null, $nbCorrection = 0) { $begin_states = array('Evaluation not started', 'awaiting for drop', 'drop provided'); $end_states = array('waiting for correction', 'corrected copy'); $states = array(); $states = array_merge($states, $begin_states); $expectedCorrections = $dropzone->getExpectedTotalCorrection(); $currentState = 0; // set the states of the dropzone. if ($dropzone->getPeerReview()) { // case of peerReview /* * --------------------- SPECIAL CASE BEGIN ------------------------------ * particular case where the peerReview end whereas the user didnt * had time to make all the expected corrections. * so we make a hack to allow them to see their note and simulate that * they did the expected corrections. */ $allow_user_to_not_have_expected_corrections = $this->isPeerReviewEndedOrManualStateFinished($dropzone, $nbCorrection); /* --------------------- SPECIAL CASE END ------------------------------*/ if (!$allow_user_to_not_have_expected_corrections && $drop != null && !$drop->isUnlockedDrop()) { for ($i = 0; $i < $expectedCorrections; $i++) { array_push($states, 'correction n°%nb_correction%/%expected_correction%'); } } $states = array_merge($states, $end_states); // getting the current state. // if no drop, state is 0 as default. if (!empty($drop)) { $currentState++; if ($drop->getFinished()) { $currentState++; } // @TODO manage invalidated corrections. // update the state with the correction number. if ($nbCorrection > $expectedCorrections) { $nbCorrection = $expectedCorrections; } if (!$allow_user_to_not_have_expected_corrections && !$drop->isUnlockedDrop()) { $currentState += $nbCorrection; if ($nbCorrection >= $expectedCorrections) { $currentState++; } } else { $currentState++; } if ($drop->countFinishedCorrections() >= $expectedCorrections) { $currentState++; if ($allow_user_to_not_have_expected_corrections) { $currentState++; } } else { if ($drop->isUnlockedDrop()) { $currentState++; } } // admin case ( can correct more than expected ) if ($currentState >= count($states)) { $currentState = count($states) - 1; } } } else { // case of normal correction. $states = array_merge($states, $end_states); // if no drop, state is 0 as default. if (!empty($drop)) { $currentState++; if ($drop->getFinished()) { $currentState += 2; } if ($drop->countFinishedCorrections() >= $expectedCorrections) { $currentState++; } } } $percent = round($currentState * 100 / (count($states) - 1)); return array('states' => $states, 'currentState' => $currentState, 'percent' => $percent, 'nbCorrection' => $nbCorrection); }