Copies an Exercise resource.

@param Exercise $exercise

@return Exercise
422972
public function copy(Exercise $exercise)
    {
        // Serialize quiz entities
        $exerciseData = $this->serializer->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS]);

        // Populate new entities with original data
        $newExercise = $this->createCopy($exerciseData, null);

        // Save copy to db
        $this->om->flush();

        return $newExercise;
    }
1363742
public function duplicate($newBID)
    {
        if ($this->btTable) {
            $ni = new BlockRecord($this->btTable);
            $ni->bID = $this->bID;
            $ni->Load('bID=' . $this->bID);
            $newInstance = clone $ni;
            $newInstance->bID = $newBID;
            $newInstance->Insert();

            return $newInstance;
        }
    }
307958
public function replicate(array $attributes = [])
    {
        $copy = new static(array_merge($this->toArray(), $attributes));
        $copy->setConstraints(clone $this->getConstraints());
        return $copy;
    }
1108581
public function findByQuestion(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
    {
        $qb = $this->createQueryBuilder('a')
            ->join('a.paper', 'p', 'WITH', 'p.exercise = :exercise')
            ->where('a.questionId = :question')
            ->setParameters([
                'exercise' => $exercise,
                'question' => $question->getUuid(),
            ]);

        if ($finishedPapersOnly) {
            $qb->andWhere('p.end IS NOT NULL');
        }

        return $qb->getQuery()->getResult();
    }
260305
public function getMinMaxAverageScores(Exercise $exercise, $scoreOn)
    {
        $papers = $this->paperRepository->findBy([
            'exercise' => $exercise,
        ]);

        $scores = $this->getPapersScores($papers, $scoreOn);

        $result = [
            'min' => 0 === count($scores) ? 0 : min($scores),
            'max' => 0 === count($scores) ? 0 : max($scores),
        ];
        $average = 0 === count($scores) ? 0 : array_sum($scores) / count($scores);
        $result['avg'] = $average !== floor($average) ? floatval(number_format($average, 2)) : $average;

        return $result;
    }
540570
public function isSolutionAvailable(Exercise $exercise, Paper $paper)
    {
        $correctionMode = $exercise->getCorrectionMode();
        switch ($correctionMode) {
            case ShowCorrectionAt::AFTER_END:
                $available = !empty($paper->getEnd());
                break;

            case ShowCorrectionAt::AFTER_LAST_ATTEMPT:
                $available = 0 === $exercise->getMaxAttempts() || $paper->getNumber() === $exercise->getMaxAttempts();
                break;

            case ShowCorrectionAt::AFTER_DATE:
                $now = new \DateTime();
                $available = empty($exercise->getDateCorrection()) || $now >= $exercise->getDateCorrection();
                break;

            case ShowCorrectionAt::NEVER:
            default:
                $available = false;
                break;
        }

        return $available;
    }
1151420
public function copy($frequency, $destBlock)
    {
        $frequencyCloned = clone $frequency;
        $frequencyCloned->setBlock($destBlock);

        $this->om->persist($frequencyCloned);

        return $frequencyCloned;
    }
1167842
public function getPapersSuccessDistribution(Exercise $exercise, $scoreOn)
    {
        $papers = $this->paperRepository->findBy([
            'exercise' => $exercise,
        ]);

        $nbSuccess = 0;
        $nbMissed = 0;
        $nbPartialSuccess = 0;

        $scores = $this->getPapersScores($papers, $scoreOn);

        /* @var Paper $paper */
        foreach ($scores as $score) {
            if ($score === floatval(0)) {
                ++$nbMissed;
            } elseif ($score === floatval($scoreOn)) {
                ++$nbSuccess;
            } else {
                ++$nbPartialSuccess;
            }
        }

        return [
            'nbSuccess' => $nbSuccess,
            'nbMissed' => $nbMissed,
            'nbPartialSuccess' => $nbPartialSuccess,
        ];
    }
563628
public function copy()
    {
        $copied = clone $this;

        $worksheetCount = count($this->workSheetCollection);
        for ($i = 0; $i < $worksheetCount; ++$i) {
            $this->workSheetCollection[$i] = $this->workSheetCollection[$i]->copy();
            $this->workSheetCollection[$i]->rebindParent($this);
        }

        return $copied;
    }
458873
public function copy($source, $destination = null)
    {
        if ($destination === null) {
            $destination = basename($source);
        }

        $this->toCopy[] = array($source, $destination);

        return $this;
    }
449332
def exerciseOptions(self, id, contract, exerciseAction, exerciseQuantity, account, override):
        """"""
        return _swigibpy.EClient_exerciseOptions(self, id, contract, exerciseAction, exerciseQuantity, account, override)
409277
public static function replicate($data)
    {
        $copy = clone $data;

        foreach ($copy as $key => $value) {
            if (is_object($value)) {
                $copy->{$key} = static::replicate($value);
            }
        }

        return $copy;
    }
313113
public function copy($newPath = null)
    {
        if (is_null($newPath)) {
            $newPath = $this->path . '-copy';
        }

        if (@$this->filesystem->copy($this->path, $newPath)) {
            return $this->getClone()->setPath($newPath);
        } else {
            $lastError = error_get_last();
            throw new CopyFailedException($this, $newPath, $lastError['message']);
        }
    }
995344
private function serializeParameters(Exercise $exercise)
    {
        $parameters = [
            'type' => $exercise->getType(),
            'maxAttempts' => $exercise->getMaxAttempts(),
            'maxAttemptsPerDay' => $exercise->getMaxAttemptsPerDay(),
            'maxPapers' => $exercise->getMaxPapers(),
            'showFeedback' => $exercise->getShowFeedback(),
            'progressionDisplayed' => $exercise->isProgressionDisplayed(),
            'timeLimited' => $exercise->isTimeLimited(), // todo : remove me
            'duration' => $exercise->getDuration(),
            'anonymizeAttempts' => $exercise->getAnonymizeAttempts(),
            'interruptible' => $exercise->isInterruptible(),
            'numbering' => $exercise->getNumbering(),
            'mandatoryQuestions' => $exercise->getMandatoryQuestions(),
            'answersEditable' => $exercise->isAnswersEditable(),
            'showOverview' => $exercise->getShowOverview(),
            'showEndConfirm' => $exercise->getShowEndConfirm(),
            'showEndPage' => $exercise->getShowEndPage(),
            'endNavigation' => $exercise->hasEndNavigation(),
            'showMetadata' => $exercise->isMetadataVisible(),
            'showStatistics' => $exercise->hasStatistics(),
            'allPapersStatistics' => $exercise->isAllPapersStatistics(),
            'showFullCorrection' => !$exercise->isMinimalCorrection(),
            'showScoreAt' => $exercise->getMarkMode(),
            'showCorrectionAt' => $exercise->getCorrectionMode(),
            'successMessage' => $exercise->getSuccessMessage(),
            'failureMessage' => $exercise->getFailureMessage(),
            'totalScoreOn' => $exercise->getTotalScoreOn(),
            'successScore' => $exercise->getSuccessScore(),
            'correctionDate' => $exercise->getDateCorrection() ? DateNormalizer::normalize($exercise->getDateCorrection()) : null,
        ];

        if (!empty($exercise->getEndMessage())) {
            $parameters['endMessage'] = $exercise->getEndMessage();
        }

        return $parameters;
    }
41578
public function copy()
    {
        return parent::copy()->setGlue($this->glue)
                             ->setPrefix($this->prefix)
                             ->setSuffix($this->suffix);
    }
1110259
public static function copy($value){
		
		if(\is_object($value)){
			
			if(\is_callable($value)){
				return \Closure::bind($value, null);
			}
			
			return clone $value;
			
		}
		
		return $value;
		
	}
453124
public function copy($stream)
    {
        if($this->getResource())
        {
            if (!$stream instanceof KFilesystemStreamInterface && !is_resource($stream) && !get_resource_type($stream) == 'stream')
            {
                throw new InvalidArgumentException(sprintf(
                    'Stream must be on object implementing the FilesystemStreamInterface or a resource of type "stream".'
                ));
            }

            if($stream instanceof KFilesystemStreamInterface) {
                $resource = $stream->getResource();
            } else {
                $resource = $stream;
            }

            return fwrite($resource, $this->read());
        }

        return false;
    }