/** * Prepares an array of user answer to the current poll and interprets these. * Stores the result in $this->interpResult */ private function interpretVote() { $this->interpResult = new qp_InterpResult(); $interpTitle = $this->getInterpTitle(); if ( $interpTitle === false ) { # this poll has no interpretation script return; } if ( !( $interpTitle instanceof Title ) || !$interpTitle->exists() ) { $this->interpResult->storeErroneous = false; $this->interpResult->setError( wfMsg( 'qp_error_no_interpretation' ) ); return; } $interpArticle = new Article( $interpTitle, 0 ); # prepare array of user answers that will be passed to the interpreter $poll_answer = array(); foreach ( $this->Questions as $qdata ) { if ( !$this->isUsedQuestion( $qdata->question_id ) ) { continue; } $questions = array(); foreach ( $qdata->ProposalText as $propkey => &$proposal_text ) { $proposals = array(); foreach ( $qdata->Categories as $catkey => &$cat_name ) { $text_answer = ''; if ( array_key_exists( $propkey, $qdata->ProposalCategoryId ) && ( $id_key = array_search( $catkey, $qdata->ProposalCategoryId[ $propkey ] ) ) !== false ) { $proposals[$catkey] = $qdata->ProposalCategoryText[ $propkey ][ $id_key ]; } } if ( isset( $qdata->ProposalNames[$propkey] ) ) { $questions[$qdata->ProposalNames[$propkey]] = $proposals; } else { $questions[$propkey] = $proposals; } } if ( $qdata->name !== null ) { $poll_answer[$qdata->name] = $questions; } else { $poll_answer[$qdata->question_id] = $questions; } } # interpret the poll answer to get interpretation answer $this->interpResult = qp_Interpret::getResult( $interpArticle, array( 'answer' => $poll_answer, 'randomQuestions' => $this->randomQuestions ) ); }