Harjotsingh has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/356983 )
Change subject: Suppressing question numbering in a quiz when only one question in a quiz ...................................................................... Suppressing question numbering in a quiz when only one question in a quiz Bug:T162803 Change-Id: I6931c03208d8ecece0b8113c3b0603f8c0682187 --- M Quiz.class.php M templates/Question.mustache 2 files changed, 10 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quiz refs/changes/83/356983/1 diff --git a/Quiz.class.php b/Quiz.class.php index 6f6c9c8..ec308d7 100755 --- a/Quiz.class.php +++ b/Quiz.class.php @@ -250,6 +250,8 @@ $output = ''; $questionPattern = '`(.*?[^|\}])\}[ \t]*(\n(.*)|$)`s'; + $numQuestion = count( $unparsedQuestions ); + $numDisplay = ( $numQuestion == 1 ) ? false : true; foreach ( $unparsedQuestions as $unparsedQuestion ) { // If this "unparsedQuestion" is not a full question, // we put the text into a buffer to add it at the beginning of the next question. @@ -259,7 +261,7 @@ if ( preg_match( $questionPattern, $unparsedQuestion, $matches ) ) { $buffer = ''; - $output .= $this->parseQuestion( $matches ); + $output .= $this->parseQuestion( $matches , $numDisplay ); } else { $buffer = $unparsedQuestion; } @@ -279,9 +281,10 @@ * @param $matches array: elements matching $questionPattern. * $matches[1] is the question header. * $matches[3] is the question object. + * @param $numDisplay Boolean: specifies whether to display question number. * @return string */ - function parseQuestion( $matches ) { + function parseQuestion( $matches , $numDisplay ) { $question = new Question( $this->mBeingCorrected, $this->mCaseSensitive, @@ -401,6 +404,7 @@ array( 'question' => array( 'id' => $this->mQuestionId, + 'numdis' => $numDisplay, 'text' => $questionText, 'answers' => $answers ), diff --git a/templates/Question.mustache b/templates/Question.mustache index 790f13a..54c70d9 100644 --- a/templates/Question.mustache +++ b/templates/Question.mustache @@ -1,6 +1,8 @@ <div class="question"> <div class="header"> - <span class="questionId">{{ question.id }}</span> + {{#if question.numdis }} + <span class="questionId">{{ question.id }}</span> + {{/if}} <span class="questionText">{{{ question.text }}}</span> </div> <table class="object" style="{{ state.tableStyle }}" title="{{ state.tableTitle }}"> @@ -8,4 +10,4 @@ {{{ question.answers }}} </tbody> </table> -</div> \ No newline at end of file +</div> -- To view, visit https://gerrit.wikimedia.org/r/356983 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6931c03208d8ecece0b8113c3b0603f8c0682187 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Quiz Gerrit-Branch: master Gerrit-Owner: Harjotsingh <harjo...@ymail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits