plugin/exo/Installation/Updater/Updater090000.php
private function updatePapers()
    {
        $this->log('Update Papers structures and hints...');

        $oldHints = $this->fetchHints();

        $questions = $this->om->getRepository('UJMExoBundle:Item\Item')->findAll();
        $decodedQuestions = [];

        $papers = $this->om->getRepository('UJMExoBundle:Attempt\Paper')->findAll();

        $this->om->startFlushSuite();

        $this->log(count($papers).' papers to process.');

        /** @var Paper $paper */
        foreach ($papers as $i => $paper) {
            // Checks the format of the structure to know if it has already been transformed
            $structure = $paper->getStructure();
            if ('{' !== substr($structure, 0, 1)) {
                // The structure is not a JSON (this is a little bit hacky)
                // Update structure
                $this->updatePaperStructure($paper, $questions, $decodedQuestions);

                // Update hints
                $this->updatePaperHints($paper, $oldHints);

                $this->om->persist($paper);
            }

            if (0 === $i % 200) {
                $this->om->forceFlush();
                $this->log('200 papers processed.');
            }
        }

        $this->om->endFlushSuite();

        $this->log('done !');
    }
private function updatePapers()
    {
        $this->log('Update Papers structures and hints...');

        $oldHints = $this->fetchHints();

        $questions = $this->om->getRepository('UJMExoBundle:Item\Item')->findAll();
        $decodedQuestions = [];

        $papers = $this->om->getRepository('UJMExoBundle:Attempt\Paper')->findAll();

        $this->om->startFlushSuite();

        $this->log(count($papers).' papers to process.');

        /** @var Paper $paper */
        foreach ($papers as $i => $paper) {
            // Checks the format of the structure to know if it has already been transformed
            $structure = $paper->getStructure();
            if ('{' !== substr($structure, 0, 1)) {
                // The structure is not a JSON (this is a little bit hacky)
                // Update structure
                $this->updatePaperStructure($paper, $questions, $decodedQuestions);

                // Update hints
                $this->updatePaperHints($paper, $oldHints);

                $this->om->persist($paper);
            }

            if (0 === $i % 200) {
                $this->om->forceFlush();
                $this->log('200 papers processed.');
            }
        }

        $this->om->endFlushSuite();

        $this->log('done !');
    }
private function updatePapers ( ) { $ this -> log ( 'Update Papers structures and hints...' ) ; $ oldHints = $ this -> fetchHints ( ) ; $ questions = $ this -> om -> getRepository ( 'UJMExoBundle:Item\Item' ) -> findAll ( ) ; $ decodedQuestions = [ ] ; $ papers = $ this -> om -> getRepository ( 'UJMExoBundle:Attempt\Paper' ) -> findAll ( ) ; $ this -> om -> startFlushSuite ( ) ; $ this -> log ( count ( $ papers ) . ' papers to process.' ) ; /** @var Paper $paper */ foreach ( $ papers as $ i => $ paper ) { // Checks the format of the structure to know if it has already been transformed $ structure = $ paper -> getStructure ( ) ; if ( '{' !== substr ( $ structure , 0 , 1 ) ) { // The structure is not a JSON (this is a little bit hacky) // Update structure $ this -> updatePaperStructure ( $ paper , $ questions , $ decodedQuestions ) ; // Update hints $ this -> updatePaperHints ( $ paper , $ oldHints ) ; $ this -> om -> persist ( $ paper ) ; } if ( 0 === $ i % 200 ) { $ this -> om -> forceFlush ( ) ; $ this -> log ( '200 papers processed.' ) ; } } $ this -> om -> endFlushSuite ( ) ; $ this -> log ( 'done !' ) ; }
Updates papers data.

- Dump the full exercise definition in `structure`
- Move hints to answers
Updates papers data .