[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Remove empty cell from settings table in Quiz

2017-08-06 Thread jenkins-bot (Code Review)
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}}
   

[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Remove empty cell from settings table in Quiz

2017-07-23 Thread Harjotsingh (Code Review)
Harjotsingh has uploaded a new change for review. ( 
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.

Bug: T171154
Change-Id: Idb35c7a6aa95ad7bf9d4e9a13d42d7088f33567e
---
M Quiz.class.php
M templates/Setting.mustache
2 files changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Quiz 
refs/changes/27/367327/1

diff --git a/Quiz.class.php b/Quiz.class.php
index 0a43cfa..9122924 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -123,6 +123,7 @@
 * @return string
 */
function parseQuiz( $input ) {
+   global $wgOut;
// Ouput the style and the script to the header once for all.
if ( $this->mQuizId == 0 ) {
global $wgOut;
@@ -147,6 +148,8 @@
'notSimple' => !$this->mDisplaySimple,
'corrected' => $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(),
@@ -170,6 +173,7 @@
'shuffleDisplay' => $this->numberQuestions > 1
]
);
+   $wgOut->addHTML("set ".$settingsTable."");
 
$quiz_score = wfMessage( 'quiz_score' )->rawParams(
'' . $this->mScore . '',
diff --git a/templates/Setting.mustache b/templates/Setting.mustache
index f6496d4..a85b8da 100644
--- a/templates/Setting.mustache
+++ b/templates/Setting.mustache
@@ -41,6 +41,7 @@

 {{/ isSettingOtherRow}}
 {{# notSimple}}
+   {{# shuffleOrError}}

{{# shuffle}}
{{^ corrected}}
@@ -62,4 +63,5 @@
{{/ corrected}}
{{/ error}}

+   {{/ shuffleOrError}}
 {{/ notSimple}}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb35c7a6aa95ad7bf9d4e9a13d42d7088f33567e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Harjotsingh 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits