[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Improve code readability in Quiz extension by reformatting code

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

Change subject: Improve code readability in Quiz extension by reformatting code
..


Improve code readability in Quiz extension by reformatting code

This extension had a lot of long code lines which has been wrapped.
Only code lines where HTML tags were present hasn't been changed.

Bug: T150103
Change-Id: Iacebb4d97a00307b64aacdaefc9b86c4f28dd5d5
---
M Question.php
M Quiz.class.php
M modules/ext.quiz.js
3 files changed, 271 insertions(+), 231 deletions(-)

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



diff --git a/Question.php b/Question.php
old mode 100644
new mode 100755
index dc88150..7347e79
--- a/Question.php
+++ b/Question.php
@@ -19,10 +19,10 @@
$this->mState = ( $beingCorrected ) ? 'NA' : '';
$this->mType = 'multipleChoice';
$this->mCoef = 1;
-   $this->mProposalPattern = '`^([+-]) ?(.*)`';
-   $this->mCorrectionPattern   = '`^\|\|(.*)`';
-   $this->mCategoryPattern = '`^\|(\n|[^\|].*\n)`';
-   $this->mTextFieldPattern= '`\{ ([^\}]*?)(_([\d]*) ?| 
)\}`';
+   $this->mProposalPattern =   '`^([+-]) ?(.*)`';
+   $this->mCorrectionPattern = '`^\|\|(.*)`';
+   $this->mCategoryPattern =   '`^\|(\n|[^\|].*\n)`';
+   $this->mTextFieldPattern =  '`\{ ([^\}]*?)(_([\d]*) ?| 
)\}`';
}
 
/**
@@ -32,19 +32,18 @@
 * @param $pState String:
 */
function setState( $pState ) {
-   if (
-   $pState == 'error' ||
-   ( $pState == 'wrong' && $this->mState != 'error' ) ||
+   if ( $pState == 'error' || ( $pState == 'wrong' && 
$this->mState != 'error' ) ||
( $pState == 'right' && ( $this->mState == 'NA' || 
$this->mState == 'na_right' ) ) ||
( $pState == 'na_wrong' && ( $this->mState == 'NA' || 
$this->mState == 'na_right' ) ) ||
( $pState == 'na_right' && ( $this->mState == 'NA' ) ) 
||
( $pState == 'new_NA' && ( $this->mState == 'NA' || 
$this->mState == 'right' ) )
-   )
-   {
+   ) {
$this->mState = $pState;
}
-   # Special cases
-   if( ( $pState == 'na_wrong' && $this->mState == 'right' ) || ( 
$pState == 'right' && $this->mState == 'na_wrong' ) ) {
+
+   // Special cases
+   if ( ( $pState == 'na_wrong' && $this->mState == 'right' ) ||
+   ( $pState == 'right' && $this->mState == 'na_wrong' ) ) 
{
$this->mState = 'wrong';
}
return;
@@ -73,15 +72,19 @@
 */
function parseHeader( $input ) {
$parametersPattern = '`\n\|([^\|].*)\s*$`';
-   $input = preg_replace_callback( $parametersPattern, array( 
$this, 'parseParameters' ), $input );
+   $input = preg_replace_callback(
+   $parametersPattern,
+   array( $this, 'parseParameters' ),
+   $input
+   );
$splitHeaderPattern = '`\n\|\|`';
$unparsedHeader = preg_split( $splitHeaderPattern, $input );
$output = $this->mParser->recursiveTagParse( trim( 
$unparsedHeader[0] ) . "\n" );
-   if( array_key_exists( 1, $unparsedHeader ) ) {
+   if ( array_key_exists( 1, $unparsedHeader ) ) {
$output .= '';
-   $output .= '' .
-   $this->mParser->recursiveTagParse( trim( 
$unparsedHeader[1] ) ) .
-   '';
+   $output .= '';
+   $output .= $this->mParser->recursiveTagParse( trim( 
$unparsedHeader[1] ) );
+   $output .= '';
$output .= '';
}
return $output;
@@ -95,9 +98,9 @@
 */
function parseParameters( $matches ) {
$typePattern = '`t[yi]p[eo]?="(.*?)"`';
-   if( preg_match( $typePattern, $matches[1], $type ) ) {
-   # List of all object type code and the correspondant 
question type.
-   switch( $type[1] ) {
+   if ( preg_match( $typePattern, $matches[1], $type ) ) {
+   // List of all object type code and the correspondant 
question type.
+   switch ( $type[1] ) {
case '{}':
$this->mType = 'textField';
break;
@@ -110,7 +113,8 @@
}
}

[MediaWiki-commits] [Gerrit] mediawiki...Quiz[master]: Improve code readability in Quiz extension by reformatting code

2016-12-03 Thread Divadsn (Code Review)
Divadsn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325097

Change subject: Improve code readability in Quiz extension by reformatting code
..

Improve code readability in Quiz extension by reformatting code

This extension had a lot of long code lines which has been wrapped.
Only code lines where HTML tags were present hasn't been changed.

Bug: T150103
Change-Id: Iacebb4d97a00307b64aacdaefc9b86c4f28dd5d5
---
M Question.php
M Quiz.class.php
M modules/ext.quiz.js
3 files changed, 276 insertions(+), 232 deletions(-)


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

diff --git a/Question.php b/Question.php
old mode 100644
new mode 100755
index dc88150..d545e7c
--- a/Question.php
+++ b/Question.php
@@ -19,10 +19,10 @@
$this->mState = ( $beingCorrected ) ? 'NA' : '';
$this->mType = 'multipleChoice';
$this->mCoef = 1;
-   $this->mProposalPattern = '`^([+-]) ?(.*)`';
-   $this->mCorrectionPattern   = '`^\|\|(.*)`';
-   $this->mCategoryPattern = '`^\|(\n|[^\|].*\n)`';
-   $this->mTextFieldPattern= '`\{ ([^\}]*?)(_([\d]*) ?| 
)\}`';
+   $this->mProposalPattern = '`^([+-]) ?(.*)`';
+   $this->mCorrectionPattern = '`^\|\|(.*)`';
+   $this->mCategoryPattern = '`^\|(\n|[^\|].*\n)`';
+   $this->mTextFieldPattern = '`\{ ([^\}]*?)(_([\d]*) ?| )\}`';
}
 
/**
@@ -32,19 +32,18 @@
 * @param $pState String:
 */
function setState( $pState ) {
-   if (
-   $pState == 'error' ||
-   ( $pState == 'wrong' && $this->mState != 'error' ) ||
+   if ( $pState == 'error' || ( $pState == 'wrong' && 
$this->mState != 'error' ) ||
( $pState == 'right' && ( $this->mState == 'NA' || 
$this->mState == 'na_right' ) ) ||
( $pState == 'na_wrong' && ( $this->mState == 'NA' || 
$this->mState == 'na_right' ) ) ||
( $pState == 'na_right' && ( $this->mState == 'NA' ) ) 
||
( $pState == 'new_NA' && ( $this->mState == 'NA' || 
$this->mState == 'right' ) )
-   )
-   {
+   ) {
$this->mState = $pState;
}
-   # Special cases
-   if( ( $pState == 'na_wrong' && $this->mState == 'right' ) || ( 
$pState == 'right' && $this->mState == 'na_wrong' ) ) {
+
+   // Special cases
+   if ( ( $pState == 'na_wrong' && $this->mState == 'right' ) ||
+   ( $pState == 'right' && $this->mState == 'na_wrong' ) ) 
{
$this->mState = 'wrong';
}
return;
@@ -73,15 +72,19 @@
 */
function parseHeader( $input ) {
$parametersPattern = '`\n\|([^\|].*)\s*$`';
-   $input = preg_replace_callback( $parametersPattern, array( 
$this, 'parseParameters' ), $input );
+   $input = preg_replace_callback(
+   $parametersPattern,
+   array( $this, 'parseParameters' ),
+   $input
+   );
$splitHeaderPattern = '`\n\|\|`';
$unparsedHeader = preg_split( $splitHeaderPattern, $input );
$output = $this->mParser->recursiveTagParse( trim( 
$unparsedHeader[0] ) . "\n" );
-   if( array_key_exists( 1, $unparsedHeader ) ) {
+   if ( array_key_exists( 1, $unparsedHeader ) ) {
$output .= '';
-   $output .= '' .
-   $this->mParser->recursiveTagParse( trim( 
$unparsedHeader[1] ) ) .
-   '';
+   $output .= '';
+   $output .= $this->mParser->recursiveTagParse( trim( 
$unparsedHeader[1] ) );
+   $output .= '';
$output .= '';
}
return $output;
@@ -95,9 +98,9 @@
 */
function parseParameters( $matches ) {
$typePattern = '`t[yi]p[eo]?="(.*?)"`';
-   if( preg_match( $typePattern, $matches[1], $type ) ) {
-   # List of all object type code and the correspondant 
question type.
-   switch( $type[1] ) {
+   if ( preg_match( $typePattern, $matches[1], $type ) ) {
+   // List of all object type code and the correspondant 
question type.
+   switch ( $type[1] ) {
case '{}':
$this->mType = 'textField';
break;
@@ -110,7 +113,8 @@
}
}