jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/357781 )

Change subject: Remove Shuffle feature if only one question is in quiz
......................................................................


Remove Shuffle feature if only one question is in quiz

Quiz extension can shuffle questions by using shuffle feature.A shuffle button
is shown which allows for shuffling.Currently when a quiz has only a single
question, the shuffle button is visible but as there is only one question it
doesn't shuffle anything.This change hides the shuffle button if there is only
one question in a quiz by introducing a global variable.

Bug:T146392
Change-Id: Ib52b4cdc3c0aeda33ebfbc1ae8ce2949e781c5fb
---
M Quiz.class.php
M templates/Setting.mustache
2 files changed, 8 insertions(+), 4 deletions(-)

Approvals:
  jenkins-bot: Verified
  Mvolz: Looks good to me, approved



diff --git a/Quiz.class.php b/Quiz.class.php
index cbfe8db..b5c3330 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -36,6 +36,7 @@
                $this->mBeingCorrected = ( $wgRequest->getVal( 'quizId' ) == 
strval( $this->mQuizId ) );
                // Initialize various parameters used for the score calculation
                $this->mState = 'NA';
+               $this->numberQuestions = 0;
                $this->mTotal = $this->mScore = 0;
                $this->mAddedPoints = 1;
                $this->mCutoffPoints = 0;
@@ -152,7 +153,8 @@
                                ],
                                'mAddedPoints' => $this->mAddedPoints,
                                'mCutoffPoints' => $this->mCutoffPoints,
-                               'checked' => $checked
+                               'checked' => $checked,
+                               'shuffleDisplay' => $this->numberQuestions > 1
                        ]
                );
 
@@ -234,8 +236,8 @@
 
                $output = '';
                $questionPattern = '`(.*?[^|\}])\}[ \t]*(\n(.*)|$)`s';
-               $numQuestion = count( $unparsedQuestions );
-               $numDisplay = $numQuestion > 1;
+               $this->numberQuestions = count( $unparsedQuestions );
+               $numDisplay = $this->numberQuestions > 1;
                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.
diff --git a/templates/Setting.mustache b/templates/Setting.mustache
index 674073e..547b580 100644
--- a/templates/Setting.mustache
+++ b/templates/Setting.mustache
@@ -38,7 +38,9 @@
        {{# notSimple}}
                {{# shuffle}}
                        {{^ corrected}}
-                               <td><input class="shuffle" name="shuffleButton" 
type="button" value="{{ wfMessage.quiz_shuffle }}" style="display: none;"/></td>
+                               {{# shuffleDisplay}}
+                                       <td><input class="shuffle" 
name="shuffleButton" type="button" value="{{ wfMessage.quiz_shuffle }}" 
style="display: none;"/></td>
+                               {{/ shuffleDisplay}}
                        {{/ corrected}}
                {{/ shuffle}}
                {{^ shuffle}}

-- 
To view, visit https://gerrit.wikimedia.org/r/357781
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib52b4cdc3c0aeda33ebfbc1ae8ce2949e781c5fb
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Harjotsingh <[email protected]>
Gerrit-Reviewer: Harjotsingh <[email protected]>
Gerrit-Reviewer: Mvolz <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to