/**
  * Build the orphan questions
  */
 public function build_quiz_orphan_questions()
 {
     $table_qui = Database::get_course_table(TABLE_QUIZ_TEST);
     $table_rel = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
     $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION);
     $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
     $courseId = api_get_course_int_id();
     $sql = 'SELECT *
             FROM ' . $table_que . ' as questions
             LEFT JOIN ' . $table_rel . ' as quizz_questions
             ON questions.id=quizz_questions.question_id
             LEFT JOIN ' . $table_qui . ' as exercises
             ON quizz_questions.exercice_id = exercises.id
             WHERE
                 questions.c_id = quizz_questions.c_id AND
                 questions.c_id = exercises.c_id AND
                 exercises.c_id = ' . $courseId . ' AND
                 (quizz_questions.exercice_id IS NULL OR
                 exercises.active = -1)';
     $db_result = Database::query($sql);
     if (Database::num_rows($db_result) > 0) {
         // This is the fictional test for collecting orphan questions.
         $orphan_questions = new Quiz(-1, get_lang('OrphanQuestions', ''), '', 0, 0, 1, '', 0);
         $this->course->add_resource($orphan_questions);
         while ($obj = Database::fetch_object($db_result)) {
             $question = new QuizQuestion($obj->id, $obj->question, $obj->description, $obj->ponderation, $obj->type, $obj->position, $obj->picture, $obj->level, $obj->extra);
             $sql = 'SELECT * FROM ' . $table_ans . ' WHERE question_id = ' . $obj->id;
             $db_result2 = Database::query($sql);
             while ($obj2 = Database::fetch_object($db_result2)) {
                 $question->add_answer($obj2->id, $obj2->answer, $obj2->correct, $obj2->comment, $obj2->ponderation, $obj2->position, $obj2->hotspot_coordinates, $obj2->hotspot_type);
             }
             $this->course->add_resource($question);
         }
     }
 }