Ejemplo n.º 1
0
 /**
  * get interview questions and answers when possible
  * @param int $wikiId wiki id
  * @param bool $answeredOnly get only answered questions
  * @param bool $asArray return array of arrays instead of objects
  */
 public function getInterviewQuestions($wikiId, $answeredOnly = false, $asArray = false)
 {
     $interview = new Interview($wikiId);
     $questions = array();
     $answers = $this->parseInterviewAnswers();
     $index = 0;
     $interviewQuestions = $interview->getQuestions();
     $questionsNum = count($interviewQuestions);
     foreach ($interviewQuestions as $question) {
         $index++;
         $question->setCaption(wfMsg('userprofilepage-question-caption', $index, $questionsNum));
         if (isset($answers[$question->getId()])) {
             $question->setAnswerBody($answers[$question->getId()]);
         }
         if ($answeredOnly && $question->hasAnswer()) {
             $questions[] = $asArray ? $question->toArray() : $question;
         } else {
             if (!$answeredOnly) {
                 $questions[] = $asArray ? $question->toArray() : $question;
             }
         }
     }
     return $questions;
 }