Beispiel #1
0
 /**
  * create the step and the question.
  *
  * @param Step[]   $steps
  * @param Exercise $exercise
  * @param string   $exoPath
  */
 private function createQuestion(array $steps, Exercise $exercise, $exoPath)
 {
     foreach ($steps as $step) {
         $this->qtiRepository->razValues();
         $newStep = $this->createStep($step, $exercise);
         $questions = opendir($exoPath . '/' . $step['order']);
         $questionFiles = [];
         while (($question = readdir($questions)) !== false) {
             if ($question !== '.' && $question !== '..') {
                 $questionFiles[] = $exoPath . '/' . $step['order'] . '/' . $question;
             }
         }
         sort($questionFiles);
         foreach ($questionFiles as $question) {
             $this->qtiRepository->createDirQTI();
             $files = opendir($question);
             while (($file = readdir($files)) !== false) {
                 if ($file !== '.' && $file !== '..') {
                     copy($question . '/' . $file, $this->qtiRepository->getUserDir() . 'ws/' . $file);
                 }
             }
             $this->qtiRepository->scanFilesToImport($newStep);
         }
         $this->qtiRepository->assocExerciseQuestion(true);
     }
 }