[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Put Setting table's HTML in mustache template

2017-06-26 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/359656 )

Change subject: Put Setting table's HTML in mustache template
..


Put Setting table's HTML in mustache template

Currently raw HTML code is used to generate settings table that is
displayed in quiz.This change removes the code and moves it to mustache
template.It utilizes template parser to process template.

Bug:T161317
Change-Id: I6e307229efee16a1efd3c0c0a8c0162ba389d02d
---
M Quiz.class.php
M modules/ext.quiz.js
M templates/Quiz.mustache
A templates/Setting.mustache
4 files changed, 92 insertions(+), 49 deletions(-)

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



diff --git a/Quiz.class.php b/Quiz.class.php
index f0169d8..cbfe8db 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -124,52 +124,37 @@
// Generates the output.
 
$templateParser = new TemplateParser( __DIR__ . '/templates' );
-
+   $checked = '';
// Determine the content of the settings table.
-   $settings = array_fill( 0, 4, '' );
-   if ( !$this->mDisplaySimple ) {
-   $settings[0] .= '' . wfMessage( 'quiz_addedPoints', 
$this->mAddedPoints )->escaped() . '' . "\n";
-   $settings[0] .= '' . "\n";
-
-   $settings[1] .= '' . wfMessage( 
'quiz_cutoffPoints', $this->mCutoffPoints )->escaped() . '' . "\n";
-   $settings[1] .= '' . 
"\n";
-
-   $checked = ( $this->mIgnoringCoef ) ? ' 
checked="checked"' : '';
-   $settings[2] .= '' . wfMessage( 'quiz_ignoreCoef' 
)->escaped() . '' . "\n";
-   $settings[2] .= '' . "\n";
-
-   if ( $this->mShuffle && !$this->mBeingCorrected ) {
-   $settings[3] .= '' . "\n";
-   } else {
-   $settings[3] .= '' . "\n";
-   }
-   $settings[3] .= '' . "\n";
-   }
-   if ( $this->mBeingCorrected ) {
-   $settings[0] .= '' . "\n";
-   $settings[0] .= '' 
. wfMessage( 'quiz_colorRight' )->escaped() . '' . "\n";
-
-   $settings[1] .= '' . "\n";
-   $settings[1] .= '' 
. wfMessage( 'quiz_colorWrong' )->escaped() . '' . "\n";
-
-   $settings[2] .= '' . "\n";
-   $settings[2] .= '' 
. wfMessage( 'quiz_colorNA' )->escaped() . '' . "\n";
-   }
-   if ( $this->mState === 'error' ) {
-   $errorKey = $this->mBeingCorrected ? 3 : 0;
-   $settings[$errorKey] .= '' . "\n";
-   $settings[$errorKey] .= '' . wfMessage( 
'quiz_colorError' )->escaped() . '' . "\n";
-   }
-
-   // Build the settings table.
$settingsTable = '';
-   foreach ( $settings as $settingsTr ) {
-   if ( !empty( $settingsTr ) ) {
-   $settingsTable .= '' . "\n";
-   $settingsTable .= $settingsTr . "\n";
-   $settingsTable .= '' . "\n";
-   }
-   }
+   $settingsTable = $templateParser->processTemplate(
+   'Setting',
+   [
+   'notSimple' => !$this->mDisplaySimple,
+   'corrected' => $this->mBeingCorrected,
+   'shuffle' => $this->mShuffle,
+   'error' => $this->mState === 'error',
+   'wfMessage' => [
+   'quiz_added' => wfMessage( 
'quiz_addedPoints', $this->mAddedPoints )->text(),
+   'quiz_cutoff' => wfMessage( 
'quiz_cutoffPoints', $this->mCutoffPoints )->text(),
+   'quiz_ignoreCoef' => wfMessage( 
'quiz_ignoreCoef' )->text(),
+   'quiz_colorRight' => wfMessage( 
'quiz_colorRight' )->text(),
+   'quiz_colorWrong' => wfMessage( 
'quiz_colorWrong' )->text(),
+   'quiz_colorNA' => wfMessage( 
'quiz_colorNA' )->text(),
+   'quiz_colorError' => wfMessage( 
'quiz_colorError' )->text(),
+   'quiz_shuffle' => wfMessage( 
'quiz_shuffle' )->text()
+   ],
+   'color' => [
+   'colorWrong' => self::getColor( 'wrong' 
),
+   'colorRight' => self::getColor( 'right' 
),
+   'colorNA' 

[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Put Setting table's HTML in mustache template

2017-06-17 Thread Harjotsingh (Code Review)
Harjotsingh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/359656 )

Change subject: Put Setting table's HTML in mustache template
..

Put Setting table's HTML in mustache template

Currently raw HTML code is used to generate settings table that is
displayed in quiz.This change removes the code and moves it to mustache
template.It utilizes template parser to process template.

Bug:T161317
Change-Id: I6e307229efee16a1efd3c0c0a8c0162ba389d02d
---
M Quiz.class.php
M modules/ext.quiz.js
M templates/Quiz.mustache
A templates/Setting.mustache
4 files changed, 94 insertions(+), 51 deletions(-)


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

diff --git a/Quiz.class.php b/Quiz.class.php
index f0169d8..6bf8742 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -124,52 +124,37 @@
// Generates the output.
 
$templateParser = new TemplateParser( __DIR__ . '/templates' );
-
+   $checked = '';
// Determine the content of the settings table.
-   $settings = array_fill( 0, 4, '' );
-   if ( !$this->mDisplaySimple ) {
-   $settings[0] .= '' . wfMessage( 'quiz_addedPoints', 
$this->mAddedPoints )->escaped() . '' . "\n";
-   $settings[0] .= '' . "\n";
-
-   $settings[1] .= '' . wfMessage( 
'quiz_cutoffPoints', $this->mCutoffPoints )->escaped() . '' . "\n";
-   $settings[1] .= '' . 
"\n";
-
-   $checked = ( $this->mIgnoringCoef ) ? ' 
checked="checked"' : '';
-   $settings[2] .= '' . wfMessage( 'quiz_ignoreCoef' 
)->escaped() . '' . "\n";
-   $settings[2] .= '' . "\n";
-
-   if ( $this->mShuffle && !$this->mBeingCorrected ) {
-   $settings[3] .= '' . "\n";
-   } else {
-   $settings[3] .= '' . "\n";
-   }
-   $settings[3] .= '' . "\n";
-   }
-   if ( $this->mBeingCorrected ) {
-   $settings[0] .= '' . "\n";
-   $settings[0] .= '' 
. wfMessage( 'quiz_colorRight' )->escaped() . '' . "\n";
-
-   $settings[1] .= '' . "\n";
-   $settings[1] .= '' 
. wfMessage( 'quiz_colorWrong' )->escaped() . '' . "\n";
-
-   $settings[2] .= '' . "\n";
-   $settings[2] .= '' 
. wfMessage( 'quiz_colorNA' )->escaped() . '' . "\n";
-   }
-   if ( $this->mState === 'error' ) {
-   $errorKey = $this->mBeingCorrected ? 3 : 0;
-   $settings[$errorKey] .= '' . "\n";
-   $settings[$errorKey] .= '' . wfMessage( 
'quiz_colorError' )->escaped() . '' . "\n";
-   }
-
-   // Build the settings table.
-   $settingsTable = '';
-   foreach ( $settings as $settingsTr ) {
-   if ( !empty( $settingsTr ) ) {
-   $settingsTable .= '' . "\n";
-   $settingsTable .= $settingsTr . "\n";
-   $settingsTable .= '' . "\n";
-   }
-   }
+   $setTable = '';
+   $setTable = $templateParser->processTemplate(
+   'Setting',
+   [
+   'notSimple' => !$this->mDisplaySimple,
+   'corrected' => $this->mBeingCorrected,
+   'shuffle' => $this->mShuffle,
+   'error' => $this->mState === 'error',
+   'wfMessage' => [
+   'quiz_added' => wfMessage( 
'quiz_addedPoints', $this->mAddedPoints )->escaped(),
+   'quiz_cutoff' => wfMessage( 
'quiz_cutoffPoints', $this->mCutoffPoints )->escaped(),
+   'quiz_ignoreCoef' => wfMessage( 
'quiz_ignoreCoef' )->escaped(),
+   'quiz_colorRight' => wfMessage( 
'quiz_colorRight' )->escaped(),
+   'quiz_colorWrong' => wfMessage( 
'quiz_colorWrong' )->escaped(),
+   'quiz_colorNA' => wfMessage( 
'quiz_colorNA' )->escaped(),
+   'quiz_colorError' => wfMessage( 
'quiz_colorError' )->escaped(),
+   'quiz_shuffle' => wfMessage( 
'quiz_shuffle' )->escaped()
+   ],
+   'color' => [
+   'colorWrong' => self::getColor( 'wrong' 
),
+   'colorRight' => 

[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Put Setting table's HTML in mustache template

2017-06-14 Thread Harjotsingh (Code Review)
Harjotsingh has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/358942 )

Change subject: Put Setting table's HTML in mustache template
..

Put Setting table's HTML in mustache template

Currently raw HTML code is used to generate settings table that is
displayed in quiz.This change removes the code and moves it to mustache
template.It utilizes template parser to process template.

Bug:T161317
Change-Id: I2a1643bc327bda4a56c9e260a6088207515b7195
---
M Quiz.class.php
M modules/ext.quiz.js
M templates/Quiz.mustache
3 files changed, 35 insertions(+), 52 deletions(-)


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

diff --git a/Quiz.class.php b/Quiz.class.php
index db48a12..0875a92 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -125,53 +125,36 @@
// Generates the output.
 
$templateParser = new TemplateParser( __DIR__ . '/templates' );
-
-   // Determine the content of the settings table.
-   $settings = array_fill( 0, 4, '' );
-   if ( !$this->mDisplaySimple ) {
-   $settings[0] .= '' . wfMessage( 'quiz_addedPoints', 
$this->mAddedPoints )->escaped() . '' . "\n";
-   $settings[0] .= '' . "\n";
-
-   $settings[1] .= '' . wfMessage( 
'quiz_cutoffPoints', $this->mCutoffPoints )->escaped() . '' . "\n";
-   $settings[1] .= '' . 
"\n";
-
-   $checked = ( $this->mIgnoringCoef ) ? ' 
checked="checked"' : '';
-   $settings[2] .= '' . wfMessage( 'quiz_ignoreCoef' 
)->escaped() . '' . "\n";
-   $settings[2] .= '' . "\n";
-
-   if ( $this->mShuffle && !$this->mBeingCorrected ) {
-   $settings[3] .= '' . "\n";
-   } else {
-   $settings[3] .= '' . "\n";
-   }
-   $settings[3] .= '' . "\n";
-   }
-   if ( $this->mBeingCorrected ) {
-   $settings[0] .= '' . "\n";
-   $settings[0] .= '' 
. wfMessage( 'quiz_colorRight' )->escaped() . '' . "\n";
-
-   $settings[1] .= '' . "\n";
-   $settings[1] .= '' 
. wfMessage( 'quiz_colorWrong' )->escaped() . '' . "\n";
-
-   $settings[2] .= '' . "\n";
-   $settings[2] .= '' 
. wfMessage( 'quiz_colorNA' )->escaped() . '' . "\n";
-   }
-   if ( $this->mState === 'error' ) {
-   $errorKey = $this->mBeingCorrected ? 3 : 0;
-   $settings[$errorKey] .= '' . "\n";
-   $settings[$errorKey] .= '' . wfMessage( 
'quiz_colorError' )->escaped() . '' . "\n";
-   }
-
+   $checked = '';
// Build the settings table.
-   $settingsTable = '';
-   foreach ( $settings as $settingsTr ) {
-   if ( !empty( $settingsTr ) ) {
-   $settingsTable .= '' . "\n";
-   $settingsTable .= $settingsTr . "\n";
-   $settingsTable .= '' . "\n";
-   }
-   }
-
+   $setTable= '';
+   $setTable = $templateParser->processTemplate(
+   'Setting',
+   array( 'notSimple' => !$this->mDisplaySimple,
+   'corrected' => $this->mBeingCorrected,
+   'shuffle' => $this->mShuffle,
+   'error' => $this->mState === 'error',
+   'wfMessage' => array(
+   'quiz_added' => wfMessage( 
'quiz_addedPoints', $this->mAddedPoints )->escaped(),
+   'quiz_cutoff' => wfMessage( 
'quiz_cutoffPoints', $this->mCutoffPoints )->escaped(),
+   'quiz_ignoreCoef' => wfMessage( 
'quiz_ignoreCoef' ),
+   'quiz_colorRight' => wfMessage( 
'quiz_colorRight' )->escaped(),
+   'quiz_colorWrong' => wfMessage( 
'quiz_colorWrong' )->escaped(),
+   'quiz_colorNA' => wfMessage( 
'quiz_colorNA' )->escaped(),
+   'quiz_colorError' => wfMessage( 
'quiz_colorError' )->escaped(),
+   'quiz_shuffle' => wfMessage( 
'quiz_shuffle' )->escaped()
+   ),
+   'color' => array(
+   'colorWrong' => self::getColor(