jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/367327 )
Change subject: Remove empty cell from settings table in Quiz
..
Remove empty cell from settings table in Quiz
Currently a empty cell is seen inside settings table which is caused by
tags from mustache template.This patch removes the tags and alters
the template.It also adds tests for setting template.
Bug: T171154
Change-Id: Idb35c7a6aa95ad7bf9d4e9a13d42d7088f33567e
---
M Quiz.class.php
M templates/Setting.mustache
M tests/phpunit/QuizTest.php
3 files changed, 117 insertions(+), 21 deletions(-)
Approvals:
jenkins-bot: Verified
Mvolz: Looks good to me, approved
diff --git a/Quiz.class.php b/Quiz.class.php
index ffa930d..d139c24 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -94,27 +94,13 @@
}
/**
-* Convert the input text to an HTML output.
+* Get HTML from template using TemplateParser
*
-* @param $input String: text between and tags, in quiz
syntax.
+* @param $templateParser TemplateParser
* @return string
*/
- function parseQuiz( $input ) {
- // Ouput the style and the script to the header once for all.
- if ( $this->mQuizId == 0 ) {
- $this->mParser->getOutput()->addModules( 'ext.quiz' );
- $this->mParser->getOutput()->addModuleStyles(
'ext.quiz.styles' );
- }
-
- // Process the input
- $input = $this->parseQuestions( $this->parseIncludes( $input )
);
-
- // Generates the output.
-
- $templateParser = new TemplateParser( __DIR__ . '/templates' );
- $checked = '';
- // Determine the content of the settings table.
- $settingsTable = '';
+ function getSettingsTable( $templateParser ) {
+ $checked = $this->mIgnoringCoef ? 'checked="checked"' : '';
$settingsTable = $templateParser->processTemplate(
'Setting',
[
@@ -122,8 +108,10 @@
$this->mState === 'error' ),
'isSettingOtherRow' => ( !$this->mDisplaySimple
|| $this->mBeingCorrected ),
'notSimple' => !$this->mDisplaySimple,
- 'corrected' => $this->mBeingCorrected,
+ 'corrected' => ( $this->mBeingCorrected &&
$this->mBeingCorrected ),
'shuffle' => $this->mShuffle,
+ 'shuffleOrError' => ( $this->mShuffle &&
$this->numberQuestions > 1 ) ||
+ $this->mState === 'error',
'error' => $this->mState === 'error',
'wfMessage' => [
'quiz_added' => wfMessage(
'quiz_addedPoints', $this->mAddedPoints )->text(),
@@ -141,6 +129,30 @@
'shuffleDisplay' => $this->numberQuestions > 1
]
);
+ return $settingsTable;
+ }
+
+ /**
+* Convert the input text to an HTML output.
+*
+* @param $input String: text between and tags, in quiz
syntax.
+* @return string
+*/
+ function parseQuiz( $input ) {
+ // Ouput the style and the script to the header once for all.
+ if ( $this->mQuizId == 0 ) {
+ $this->mParser->getOutput()->addModules( 'ext.quiz' );
+ $this->mParser->getOutput()->addModules(
'ext.quiz.styles' );
+ }
+
+ // Process the input
+ $input = $this->parseQuestions( $this->parseIncludes( $input )
);
+
+ // Generates the output.
+ $templateParser = new TemplateParser( __DIR__ . '/templates' );
+ // Determine the content of the settings table.
+ $settingsTable = '';
+ $settingsTable = $this->getSettingsTable( $templateParser );
$quiz_score = wfMessage( 'quiz_score' )->rawParams(
'' . $this->mScore . '',
diff --git a/templates/Setting.mustache b/templates/Setting.mustache
index 41f0add..47b8c95 100644
--- a/templates/Setting.mustache
+++ b/templates/Setting.mustache
@@ -41,14 +41,15 @@
{{/ isSettingOtherRow}}
{{# notSimple}}
+ {{# shuffleOrError}}
- {{# shuffle}}
+ {{#if shuffle}}
{{^ corrected}}
{{# shuffleDisplay}}
{{/ shuffleDisplay}}
{{/ corrected}}
- {{/ shuffle}}
+ {{/if}}