function addShowResults2( $inp ) {
		self::$cellTemplateParam['percents'] = ' ';
		if ( ( $percents = $this->ctrl->getPercents( $this->proposalId, $this->catId ) ) !== false ) {
			# there is a stat in cell
			self::$cellTemplateParam['percents'] = $percents . '%';
			self::$cellTemplateParam['bar1style'] = 'width:' . $percents . 'px;' . self::$cellTemplate[ 'bar1showres' ];
			self::$cellTemplateParam['bar2style'] = 'width:' . ( 100 - $percents ) . 'px;' . self::$cellTemplate[ 'bar2showres' ];
			return qp_Renderer::renderTagArray( self::$cellTemplate['bar'] );
		} else {
			return '';
		}
	}
	/**
	 * Renders question table with header and proposal views
	 */
	function renderTable() {
		$questionTable = array();
		# add header views to $questionTable
		foreach ( $this->hviews as $header ) {
			$rowattrs = array();
			$attribute_maps = array();
			if ( is_object( $header ) ) {
				$row = &$header->row;
				$rowattrs['class'] = $header->className;
				$attribute_maps = &$header->attribute_maps;
			} else {
				$row = &$header;
			}
			qp_Renderer::addRow( $questionTable, $row, $rowattrs, 'th', $attribute_maps );
		}
		foreach ( $this->pviews as $pkey => $propview ) {
			$prop = $this->renderParsedProposal( $pkey, $propview );
			$rowattrs = array( 'class' => $propview->rowClass );
			if ( $this->transposed ) {
				qp_Renderer::addColumn( $questionTable, $prop, $rowattrs );
			} else {
				qp_Renderer::addRow( $questionTable, $prop, $rowattrs );
			}
		}
		return $questionTable;
	}
	/**
	 * @return  string  html representation of question statistics
	 */
	public function displayStats( qp_SpecialPage $page, $pid ) {
		$ctrl = $this->ctrl;
		$current_title = $page->getTitle();
		$output = $this->displayHeader() .
			"<div class=\"qpoll\">\n" . "<table class=\"qdata\">\n" .
			qp_Renderer::displayRow(
				array_map( array( $this, 'categoryentities' ), $ctrl->CategorySpans ),
				array( 'class' => 'spans' ),
				'th',
				array( 'count' => 'colspan', 'name' => 0 )
			) .
			qp_Renderer::displayRow(
				array_map( array( $this, 'categoryentities' ), $ctrl->Categories ),
				array(),
				'th',
				array( 'name' => 0 )
			);
		# multiple choice polls doesn't use real spans, instead, every column is like "span"
		$spansUsed = count( $ctrl->CategorySpans ) > 0 || $ctrl->type == "multipleChoice";
		foreach ( $ctrl->ProposalText as $propkey => &$proposal_text ) {
			if ( isset( $ctrl->Votes[ $propkey ] ) ) {
				if ( $ctrl->Percents === null ) {
					$row = $ctrl->Votes[ $propkey ];
				} else {
					$row = $ctrl->Percents[ $propkey ];
					foreach ( $row as $catkey => &$cell ) {
						# Replace spaces with en spaces
						$formatted_cell = str_replace( " ", "&#8194;", sprintf( '%3d%%', intval( round( 100 * $cell ) ) ) );
						# only percents !=0 are displayed as link
						if ( $cell == 0.0 && $ctrl->question_id !== null ) {
							$cell = array( 0 => $formatted_cell, "style" => "color:gray" );
						} else {
							$cell = array( 0 => $page->qpLink( $current_title, $formatted_cell,
								array( "title" => wfMsgExt( 'qp_votes_count', array( 'parsemag' ), $ctrl->Votes[ $propkey ][ $catkey ] ) ),
								array( "action" => "qpcusers", "id" => $pid, "qid" => $ctrl->question_id, "pid" => $propkey, "cid" => $catkey ) ) );
						}
						if ( $spansUsed ) {
							if ( $ctrl->type == "multipleChoice" ) {
								$cell[ "class" ] = ( ( $catkey & 1 ) === 0 ) ? "spaneven" : "spanodd";
							} else {
								$cell[ "class" ] = ( ( $ctrl->Categories[ $catkey ][ "spanId" ] & 1 ) === 0 ) ? "spaneven" : "spanodd";
							}
						} else {
							$cell[ "class" ] = "stats";
						}
					}
				}
			} else {
				# this proposal has no statistics (no votes)
				$row = array_fill( 0, count( $ctrl->Categories ), '' );
			}
			$row[] = array( 0 => qp_Setup::entities( $proposal_text ), "style" => "text-align:left;" );
			$output .= qp_Renderer::displayRow( $row );
		}
		$output .= "</table>\n" . "</div>\n";
		return $output;
	}
	/**
	 * @return  string  html representation of user vote for Special:Pollresults output
	 */
	function displayUserVote() {
		$ctrl = $this->ctrl;
		$output = $this->displayHeader();
		$output .= "<div class=\"qpoll\">\n" . "<table class=\"qdata\">\n";
		foreach ( $ctrl->ProposalText as $propkey => &$serialized_tokens ) {
			if ( !is_array( $dbtokens = unserialize( $serialized_tokens ) ) ) {
				throw new MWException( 'dbtokens is not an array in ' . __METHOD__ );
			}
			$catId = 0;
			$row = array();
			foreach ( $dbtokens as &$token ) {
				if ( is_string( $token ) ) {
					# add a proposal part
					$row[] = array( '__tag' => 'span', 'class' => 'prop_part', qp_Setup::entities( $token ) );
				} elseif ( is_array( $token ) ) {
					# add a category definition with selected text answer (if any)
					# resulting category view tagarray
					$catview = array(
						'__tag' =>'span',
						'class' => 'cat_part',
						'' // text_answer
					);
					if ( array_key_exists( $propkey, $ctrl->ProposalCategoryId ) &&
						( $id_key = array_search( $catId, $ctrl->ProposalCategoryId[$propkey] ) ) !== false ) {
						if ( ( $text_answer = $ctrl->ProposalCategoryText[$propkey][$id_key] ) === '' ) {
							if ( count( $token ) === 1 ) {
								# indicate selected checkbox / radiobuttn
								$catview[0] = qp_Setup::RESULTS_CHECK_SIGN;
							}
						} else {
							# text answer is not empty;
							# try to extract select multiple, if any
							$text_answer = explode( qp_Setup::SELECT_MULTIPLE_VALUES_SEPARATOR, $text_answer );
							# place unused categories into the value of 'title' attribute
							$titleAttr = '';
							foreach ( $token as &$option ) {
								if ( !in_array( $option, $text_answer ) ) {
									if ( $titleAttr !== '' ) {
										$titleAttr .= ' | ';
									}
									$titleAttr .= qp_Setup::entities( $option );
								}
							}
							if ( count( $text_answer ) > 1 ) {
								# selected multiple values;
								# re-create the view for multiple category parts
								$catview = array();
								foreach ( $text_answer as $key => &$cat_part ) {
									$tag = array(
										'__tag' => 'span',
										'class' => 'cat_part',
										'title' => $titleAttr,
										qp_Setup::specialchars( $cat_part )
									);
									if ( in_array( $cat_part, $token ) ) {
											$tag['class'] .= ( $key % 2 === 0 ) ? ' cat_even' : ' cat_odd';
									} else {
										# add 'cat_unanswered' CSS class only to select multiple values
										$tag['class'] .= ' cat_unanswered';
									}
									if ( $key == 0 ) {
										$tag['class'] .= ' cat_first';
									}
									$catview[] = $tag;
								}
							} else {
								# text input or textarea
								$catview['title'] = $titleAttr;
								# note that count( $text_answer) here cannot be zero, because
								# explode() was performed on non-empty $text_answer
								$catview[0] = qp_Setup::specialchars( array_pop( $text_answer ) );
							}
						}
					} else {
						# many browsers trim the spaces between spans when the text node is empty;
						# use non-breaking space to prevent this
						$catview[0] = '&#160;';
						$catview['class'] .= ' cat_unanswered';
					}
					$row[] = $catview;
					# move to the next category (if any)
					$catId++;
				} else {
					throw new MWException( 'DB token has invalid type (' . gettype( $token ) . ') in ' . __METHOD__ );
				}
			}
			$output .= qp_Renderer::displayRow(
				array( $row ),
				array( 'class' => 'qdatatext' )
			);
		}
		$output .= "</table>\n" . "</div>\n";
		return $output;
	}
Пример #5
0
 /**
  * Show interpetation script source with line numbering (for debugging convenience)
  *
  * @param  $input				Text between <qpinterpret> and </qpinterper> tags, subset of PHP syntax.
  * @param  $argv				An array containing any arguments passed to the extension
  * @param  &$parser			The wikitext parser.
  * @param  &$frame			PPFrame object passed in MW 1.16+
  * @return 						script source with line numbering
  */
 static function showScript($input, $argv, $parser, $frame = false)
 {
     $lines_count = count(preg_split('`(\\r\\n|\\n|\\r)`', $input, -1));
     $line_numbers = '';
     if (!isset($argv['lang'])) {
         return '<strong class="error">' . wfMsg('qp_error_eval_missed_lang_attr') . '</strong>';
     }
     $lang = $argv['lang'];
     if (!array_key_exists($lang, self::$scriptLinesCount)) {
         self::$scriptLinesCount[$lang] = 1;
     }
     $slc =& self::$scriptLinesCount[$lang];
     for ($i = $slc; $i < $slc + $lines_count; $i++) {
         $line_numbers .= "{$i}\n";
     }
     $slc = $i;
     $out = array('__tag' => 'div', 'class' => 'qpoll', 0 => array());
     if (is_string($lintResult = qp_Interpret::lint($lang, $input))) {
         $out[0][] = array('__tag' => 'div', 'class' => 'interp_error', qp_Setup::specialchars($lintResult));
     }
     $out[0][] = array('__tag' => 'div', 'class' => 'line_numbers', $line_numbers);
     $out[0][] = array('__tag' => 'div', 'class' => 'script_view', qp_Setup::specialchars($input) . "\n");
     $markercount = count(self::$markerList);
     $marker = "!qpoll-script-view{$markercount}-qpoll!";
     self::$markerList[$markercount] = qp_Renderer::renderTagArray($out);
     return $marker;
 }
Пример #6
0
	function getPageHeader() {
		global $wgLang, $wgContLang;
		$link = "";
		if ( $this->pid !== null ) {
			$pollStore = new qp_PollStore( array( 'from' => 'pid', 'pid' => $this->pid ) );
			if ( $pollStore->pid !== null ) {
				$pollStore->loadQuestions();
				$poll_title = Title::makeTitle( intval( $this->ns ), $this->title, qp_AbstractPoll::s_getPollTitleFragment( $this->poll_id, '' ) );
				$pagename = qp_Setup::specialchars( $wgContLang->convert( $poll_title->getPrefixedText() ) );
				$pollname = qp_Setup::specialchars( $this->poll_id );
				$head = array();
				$head[] = $this->showPollActionsList(
					$pollStore->pid,
					$pollStore->mPollId,
					$poll_title
				);
				$head[] = wfMsg( 'qp_header_line_qpul', wfMsg( 'qp_users_link' ), $pagename, $pollname );
				$ques_found = false;
				foreach ( $pollStore->Questions as $qdata ) {
					if ( $qdata->question_id == $this->question_id ) {
						$ques_found = true;
						break;
					}
				}
				if ( $ques_found ) {
					$qpa = wfMsg( 'qp_header_line_qucl', $this->question_id, qp_Setup::entities( $qdata->CommonQuestion ) );
					if ( array_key_exists( $this->cat_id, $qdata->Categories ) ) {
						$categ = &$qdata->Categories[ $this->cat_id ];
						$proptext = $qdata->ProposalText[ $this->proposal_id ];
						$cat_name = $categ['name'];
						if ( array_key_exists( 'spanId', $categ ) ) {
							$cat_name =  wfMsg( 'qp_full_category_name', $cat_name, $qdata->CategorySpans[ $categ['spanId'] ]['name'] );
						}
						$head[] = wfMsg( 'qp_header_line_qucl',
							$this->question_id,
							qp_Setup::entities( $qdata->CommonQuestion ),
							qp_Setup::entities( $proptext ),
							qp_Setup::entities( $cat_name ) );
						qp_Renderer::applyAttrsToRow( $head, array( '__tag' => 'li', '__end' => "\n" ) );
						$head = array( '__tag' => 'ul', 'class' => 'head', $head );
						$link = PollResults::getPollsLink() .
							PollResults::getUsersLink() .
							qp_Renderer::renderTagArray( $head );
					}
				}
			}
		}
		return $link;
	}
	/**
	 * Encloses the output of $this->renderQuestionViews() into the output tag wrappers
	 * @return  rendered "final" html
	 */
	function renderPoll() {
		# Generates the output.
		$qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll', 0 => $this->renderQuestionViews() );
		return qp_Renderer::renderTagArray( $qpoll_div );
	}
	/**
	 * Renders question table with header and proposal views
	 */
	function renderTable() {
		$questionTable = array();
		# add header views to $questionTable
		$rowattrs = array();
		foreach ( $this->hviews as $header ) {
			$rowattrs['class'] = $header->className;
			if ( $this->transposed ) {
				qp_Renderer::addColumn( $questionTable, $header->row, $rowattrs, 'th', $header->attribute_maps );
			} else {
				qp_Renderer::addRow( $questionTable, $header->row, $rowattrs, 'th', $header->attribute_maps );
			}
		}
		# add proposal views to $questionTable
		ksort( $this->pviews );
		foreach ( $this->pviews as $propview ) {
			$row = &$propview->row;
			$rowattrs = array( 'class' => $propview->rowClass );
			$text = array( '__tag' => 'td', '__end' => "\n", 'class' => 'proposaltext', 'style' => $this->proposalTextStyle, 0 => $this->rtp( $propview->text ) );
			# insert proposal text to the beginning / end according to proposalsFirst property
			if ( $this->proposalsFirst ) {
				# first element is proposaltext
				array_unshift( $row, $text );
			} else {
				# last element is proposaltext
				$row[] = $text;
			}
			if ( $this->transposed ) {
				qp_Renderer::addColumn( $questionTable, $row, $rowattrs );
			} else {
				qp_Renderer::addRow( $questionTable, $row, $rowattrs );
			}
		}
		return $questionTable;
	}
	/**
	 * Add interpretation results to tagarray of poll view
	 */
	function showInterpResults( array &$tagarray, qp_InterpResult $ctrl, $showDescriptions = false ) {
		if ( $ctrl->hasVisibleProperties() ) {
			return;
		}
		$interp = array();
		if ( $showDescriptions ) {
				$interp[] = array( '__tag' => 'div', wfMsg( 'qp_results_interpretation_header' ) );
		}
		# currently, error is not stored in DB, only the vote and long / short interpretations
		# todo: is it worth to store it?
		if ( ( $scriptError = $ctrl->error ) != '' ) {
			$interp[] = array( '__tag' => 'div', 'class' => 'interp_error', qp_Setup::specialchars( $scriptError ) );
		}
		# output long result, when permitted and available
		if ( $this->showInterpretation['long'] &&
				( $answer = $ctrl->long ) !== '' ) {
			if ( $showDescriptions ) {
				$interp[] = array( '__tag' => 'div', 'class' => 'interp_header', wfMsg( 'qp_results_long_interpretation' ) );
			}
			$interp[] = array( '__tag' => 'div', 'class' => 'interp_answer_body', is_null( $this->pview ) ? nl2br( qp_Setup::specialchars( $answer ) ) : $this->pview->rtp( $answer ) );
		}
		# output short result, when permitted and available
		if ( $this->showInterpretation['short'] &&
				( $answer = $ctrl->short ) !== '' ) {
			if ( $showDescriptions ) {
				$interp[] = array( '__tag' => 'div', 'class' => 'interp_header', wfMsg( 'qp_results_short_interpretation' ) );
			}
			$interp[] = array( '__tag' => 'div', 'class' => 'interp_answer_body', nl2br( qp_Setup::specialchars( $answer ) ) );
		}
		if ( $this->showInterpretation['structured'] &&
				( $answer = $ctrl->structured ) !== '' ) {
			if ( $showDescriptions ) {
				$interp[] = array( '__tag' => 'div', 'class' => 'interp_header', wfMsg( 'qp_results_structured_interpretation' ) );
			}
			$strucTable = $ctrl->getStructuredAnswerTable();
			$rows = array();
			foreach ( $strucTable as &$line ) {
				if ( isset( $line['keys'] ) ) {
					# current node is associative array
					qp_Renderer::addRow( $rows, $line['keys'], array(), 'th' );
					qp_Renderer::addRow( $rows, $line['vals'] );
				} else {
					# current node is scalar value
					qp_Renderer::addRow( $rows, array( $line['vals'] ) );
				}
			}
			$interp[] = array( '__tag' => 'table', 'class' => 'structured_answer', $rows );
			unset( $strucTable );
		}
		$tagarray[] = array( '__tag' => 'div', 'class' => 'interp_answer', $interp );
	}
	/**
	 * Creates question view which should be renreded and
	 * also may be altered during the poll generation
	 */
	function questionParseBody( $inputType ) {
		$proposalId = -1;
		# set static view state for the future qp_TabularQuestionProposalView instances
		qp_TabularQuestionProposalView::applyViewState( $this->view );
		$prop_attrs = qp_Setup::$propAttrs;
		$prop_attrs->setQuestion( $this );
		while ( $prop_attrs->iterate() ) {
			# new proposal view
			$pview = new qp_TabularQuestionProposalView( $proposalId + 1, $this );
			$proposalId++;
			$prop_attrs->dbText = $pview->text = $prop_attrs->cpdef;
			if ( is_string( $prop_attrs->error ) ) {
				$pview->prependErrorMessage( wfMsg( $prop_attrs->error ), 'error' );
			} elseif ( $prop_attrs->name !== '' ) {
				$this->mProposalNames[$proposalId] = $prop_attrs->name;
			}
			$this->mProposalText[$proposalId] = strval( $prop_attrs );
			foreach ( $this->mCategories as $catId => $catDesc ) {
				# start new input field tag (category)
				$pview->addNewCategory( $catId );
				$inp = array( '__tag' => 'input' );
				$pview->resetSpanState();
				# Determine the input's name and value.
				switch( $this->mType ) {
				case 'multipleChoice':
					$name = "q{$this->mQuestionId}p{$proposalId}s{$catId}";
					$value = "s{$catId}";
					break;
				case 'singleChoice':
					$name = "q{$this->mQuestionId}p{$proposalId}";
					$value = "s{$catId}";
					# category spans have sense only with single choice proposals
					$pview->renderSpan( $name, $value, $catDesc );
					break;
				}
				# Determine if the input had to be checked.
				if ( $this->poll->mBeingCorrected && qp_Setup::$request->getVal( $name ) == $value ) {
					$inp[ 'checked' ] = 'checked';
				}
				if ( $this->answerExists( $inputType, $proposalId, $catId ) !== false ) {
					$inp[ 'checked' ] = 'checked';
				}
				if ( array_key_exists( 'checked', $inp ) ) {
					if ( $this->mSubType == 'unique' ) {
						if ( $this->poll->mBeingCorrected && !$this->isUniqueProposalCategoryId( $proposalId, $catId ) ) {
							$pview->prependErrorMessage( wfMsg( 'qp_error_non_unique_choice' ), 'NA' );
							unset( $inp[ 'checked' ] );
							qp_Renderer::addClass( $row[ $catId ], 'error' );
						}
					} else {
						$pview->spanWasChecked( true );
					}
				}
				if ( array_key_exists( 'checked', $inp ) ) {
					# add category to the list of user answers for current proposal (row)
					$this->mProposalCategoryId[ $proposalId ][] = $catId;
					$this->mProposalCategoryText[ $proposalId ][] = '';
				}
				$pview->setCategorySpan();
				if ( $this->mSubType == 'unique' ) {
					# unique (orderid,question,proposal,category) "coordinate" for javascript
					$inp['id'] = "uq{$this->poll->mOrderId}q{$this->mQuestionId}p{$proposalId}c{$catId}";
					# If type='unique()' question has more proposals than categories, such question is impossible to complete
					if ( count( $this->mProposalText ) > count( $this->mCategories ) ) {
						# if there was no previous errors, hightlight the whole row
						if ( $this->getState() == '' ) {
							$pview->addCellsClass( 'error' );
						}
						$pview->prependErrorMessage( wfMsg( 'qp_error_unique' ), 'error' );
					}
				}
				$inp['class'] = 'check';
				$inp['type'] = $inputType;
				$inp['name'] = $name;
				$inp['value'] = $value;
				$pview->setCat( $inp );
			}
			# If the proposal text is empty, the question has a syntax error.
			if ( $pview->text !== null && trim( $pview->text ) == '' ) {
				$pview->setErrorMessage( wfMsg( 'qp_error_proposal_text_empty' ), 'error' );
				$pview->addCellsClass( 'error' );
			}
			if ( $inputType === 'radio' && $prop_attrs->catreq > 1 ) {
				# radio buttons row always require not more than one category,
				# otherwise the poll will be impossible to submit sucessfully.
				$prop_attrs->catreq = 1;
			}
			# If the proposal was submitted but unanswered
			if ( $this->poll->mBeingCorrected &&
						$prop_attrs->hasMissingCategories(
							$answered_cats_count = $this->getAnsweredCatCount( $proposalId ),
							count( $this->mCategories )
						) ) {
				# if there was no previous errors, hightlight the whole row
				if ( $this->getState() == '' ) {
					$pview->addCellsClass( 'error' );
				}
				# the proposal was submitted but has not enough categories answered
				$pview->prependErrorMessage(
					($answered_cats_count > 0) ?
						wfMsg( 'qp_error_not_enough_categories_answered' ) :
						wfMsg( 'qp_error_no_answer' )
					, 'NA'
				);
			}
			if ( $pview->text !== null ) {
				$this->view->addProposal( $proposalId, $pview );
			}
		}
	}
	/**
	 * todo: unfortunately, rendering of the question also conditionally modifies
	 * state of poll controller
	 * @modifies parent controller
	 * @return  string  html representation of the question
	 */
	function renderQuestion() {
		$output_table = array( '__tag' => 'table', '__end' => "\n", 'class' => 'object' );
		if ( $this->propWidth !== '' ) {
			$output_table['style'] = 'width:100%;';
		}
		# Determine the side border color the question.
		if ( $this->ctrl->getState() != '' ) {
			if ( isset( $output_table['class'] ) ) {
				$output_table['class'] .= ' error_mark';
			} else {
				$output_table['class'] = 'error_mark';
			}
			# set poll controller state according to question controller state
			$this->ctrl->applyStateToParent();
		}
		$output_table[] = array( '__tag' => 'tbody', '__end' => "\n", 0 => $this->renderTable() );
		$tags = array();
		if ( $this->ctrl->poll->questions->usedCount() > 1 ) {
			# display question number only if there are more than one question in poll
			$tags[] = array(
				'__tag' => 'div', '__end' => "\n", 'class' => 'header',
					array( '__tag' => 'span', 'class' => 'questionId', 0 => $this->ctrl->usedId )
			);
		}
		if ( $this->headerErrorMessage !== '' ) {
			# either fatal or proposal error occured
			$tags[] = array(
				'__tag' => 'div',
				'class' => ( $this->ctrl->getState() === 'error' ) ? 'fatalerror' : 'proposalerror',
				qp_Setup::specialchars( $this->headerErrorMessage )
			);
		}
		$tags[] = array( '__tag' => 'div', $this->rtp( $this->ctrl->mCommonQuestion ) );
		# class 'question_mod4_[0-3]' is used to prettify question table cells;
		# todo: at some later point, when HTML5/CSS3 will take over, this will not be needed.
		$tags = array( '__tag' => 'div', '__end' => "\n", 'class' => 'question question_mod4_' . ( $this->ctrl->usedId % 4 ), $tags );
		$tags[] = &$output_table;
		return qp_Renderer::renderTagArray( $tags );
	}
Пример #12
0
	/**
	 * Encloses the output of $this->renderQuestionViews() into the output tag wrappers
	 * @return  rendered "final" html
	 */
	function renderPoll() {
		$pollStore = $this->ctrl->pollStore;
		# Generates the output.
		$qpoll_div = array( '__tag' => 'div', 'class' => 'qpoll' );
		$qpoll_div[] = array( '__tag' => 'a', 'name' => $this->ctrl->getPollTitleFragment( null, '' ), 0 => '' );
		# output script-generated error, when available
		# render short/long/structured result, when permitted and available
		$interpResultView = qp_InterpResultView::newFromBaseView( $this );
		$interpResultView->showInterpResults( $qpoll_div, $pollStore->interpResult );
		# unused anymore
		unset( $interpResultView );
		# create voting form and fill it with messages and inputs
		$qpoll_form = array( '__tag' => 'form', 'method' => 'post', 'action' => $this->ctrl->getPollTitleFragment(), 'autocomplete' => 'off', '__end' => "\n" );
		$qpoll_div[] = &$qpoll_form;
		# Determine the content of the settings table.
		$settings = Array();
		if ( $this->ctrl->mState != '' ) {
			$settings[0][] = array( '__tag' => 'td', 'class' => 'margin object_error' );
			$settings[0][] = array( '__tag' => 'td', 0 => wfMsgHtml( 'qp_result_' . $this->ctrl->mState ) );
		}
		# Build the settings table.
		if ( count( $settings ) > 0 ) {
			$settingsTable = array( '__tag' => 'table', 'class' => 'settings', '__end' => "\n" );
			foreach ( $settings as $settingsTr ) {
				$settingsTable[] = array( '__tag' => 'tr', 0 => $settingsTr, '__end' => "\n" );
			}
			$qpoll_form[] = &$settingsTable;
		}
		$qpoll_form[] = array( '__tag' => 'input', 'type' => 'hidden', 'name' => 'pollId', 'value' => $this->ctrl->mPollId );
		$qpoll_form[] = array( '__tag' => 'div', 'class' => 'pollQuestions', 0 => $this->renderQuestionViews() );
		$submitBtn = array( '__tag' => 'input', 'type' => 'submit' );
		$submitMsg = 'qp_vote_button';
		if ( $pollStore->isAlreadyVoted() ) {
			$submitMsg = 'qp_vote_again_button';
		}
		if ( $this->ctrl->mBeingCorrected ) {
			if ( $pollStore->getState() == "complete" ) {
				$submitMsg = 'qp_vote_again_button';
			}
		} else {
			if ( $pollStore->getState() == "error" ) {
				$submitBtn['disabled'] = 'disabled';
			}
		}
		$atLeft = $this->ctrl->attemptsLeft();
		if ( $atLeft === false ) {
			$submitBtn['disabled'] = 'disabled';
		}
		# disable submit button in preview mode & printable version
		if ( qp_Setup::$request->getVal( 'action' ) == 'parse' ||
				qp_Setup::$output->isPrintable() ) {
			$submitBtn['disabled'] = 'disabled';
		}
		$submitBtn['value'] = wfMsgHtml( $submitMsg );
		$p = array( '__tag' => 'p' );
		$p[] = $submitBtn;
		# output "no more attempts" message, when applicable
		if ( $atLeft === false ) {
			$p[] = array( '__tag' => 'span', 'class' => 'attempts_counter', qp_Setup::specialchars( wfMsg( 'qp_error_no_more_attempts' ) ) );
		} elseif ( $atLeft !== true ) {
			$p[] = array( '__tag' => 'span', 'class' => 'attempts_counter', qp_Setup::specialchars( wfMsgExt( 'qp_submit_attempts_left', array( 'parsemag' ), intval( $atLeft ) ) ) );
		}

		$qpoll_form[] = &$p;
		return qp_Renderer::renderTagArray( $qpoll_div );
	}