plugin/exo/Library/Attempt/PaperGenerator.php
public function create(Exercise $exercise, User $user = null, Paper $previousPaper = null)
    {
        // Create the new Paper entity
        $paper = new Paper();
        $paper->setExercise($exercise);
        $paper->setUser($user);
        $paper->setAnonymized($exercise->getAnonymizeAttempts());

        // Get the number of the new Paper
        $paperNum = (null === $previousPaper) ? 1 : $previousPaper->getNumber() + 1;
        $paper->setNumber($paperNum);

        // Generate the structure for the new paper
        // Reuse a previous paper if exists and has not been invalidated
        $structure = $this->generateStructure(
            $exercise,
            ($previousPaper && !$previousPaper->isInvalidated()) ? $previousPaper : null
        );
        $paper->setStructure(json_encode($structure));

        return $paper;
    }
public function create(Exercise $exercise, User $user = null, Paper $previousPaper = null)
    {
        // Create the new Paper entity
        $paper = new Paper();
        $paper->setExercise($exercise);
        $paper->setUser($user);
        $paper->setAnonymized($exercise->getAnonymizeAttempts());

        // Get the number of the new Paper
        $paperNum = (null === $previousPaper) ? 1 : $previousPaper->getNumber() + 1;
        $paper->setNumber($paperNum);

        // Generate the structure for the new paper
        // Reuse a previous paper if exists and has not been invalidated
        $structure = $this->generateStructure(
            $exercise,
            ($previousPaper && !$previousPaper->isInvalidated()) ? $previousPaper : null
        );
        $paper->setStructure(json_encode($structure));

        return $paper;
    }
public function create ( Exercise $ exercise , User $ user = null , Paper $ previousPaper = null ) { // Create the new Paper entity $ paper = new Paper ( ) ; $ paper -> setExercise ( $ exercise ) ; $ paper -> setUser ( $ user ) ; $ paper -> setAnonymized ( $ exercise -> getAnonymizeAttempts ( ) ) ; // Get the number of the new Paper $ paperNum = ( null === $ previousPaper ) ? 1 : $ previousPaper -> getNumber ( ) + 1 ; $ paper -> setNumber ( $ paperNum ) ; // Generate the structure for the new paper // Reuse a previous paper if exists and has not been invalidated $ structure = $ this -> generateStructure ( $ exercise , ( $ previousPaper && ! $ previousPaper -> isInvalidated ( ) ) ? $ previousPaper : null ) ; $ paper -> setStructure ( json_encode ( $ structure ) ) ; return $ paper ; }
Creates a paper for a new attempt.

@param Exercise $exercise      - the exercise tried
@param User     $user          - the user who wants to pass the exercise
@param Paper    $previousPaper - the previous paper if one exists

@return Paper
Creates a paper for a new attempt .