Ejemplo n.º 1
0
 /**
  * sort the paths of questions
  *
  * @param UJM\ExoBundle\Services\classes\QTI\qtiRepository $qtiRepos
  *
  * @return array of String array with the paths of questions sorted
  */
 public function sortPathOfQuestions($qtiRepos)
 {
     $pathQtiDir = $qtiRepos->getUserDir() . 'questions';
     $questions = new \DirectoryIterator($pathQtiDir);
     //create array with sort file
     $qdirs = array();
     foreach ($questions as $question) {
         if ($question != '.' && $question != '..' && $question->getExtension() == "") {
             $qdirs[] = $pathQtiDir . '/' . $question->getFilename();
         }
     }
     sort($qdirs);
     return $qdirs;
 }
Ejemplo n.º 2
0
 /**
  * create the directory questions to export an exercise and export the qti files
  *
  * @param UJM\ExoBundle\Services\classes\QTI\qtiRepository $qtiRepos
  * @param collection of  UJM\ExoBundle\Entity\Interaction $interactions
  */
 private function createQuestionsDirectory($qtiRepos, $interactions)
 {
     mkdir($qtiRepos->getUserDir() . 'questions');
     $i = 'a';
     foreach ($interactions as $interaction) {
         $qtiRepos->export($interaction);
         mkdir($qtiRepos->getUserDir() . 'questions/' . 'question_' . $i);
         $iterator = new \DirectoryIterator($qtiRepos->getUserDir());
         foreach ($iterator as $element) {
             if (!$element->isDot() && $element->isFile()) {
                 rename($qtiRepos->getUserDir() . $element->getFilename(), $qtiRepos->getUserDir() . 'questions/' . 'question_' . $i . '/' . $element->getFilename());
             }
         }
         $i .= 'a';
     }
 }