Umherirrender has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/364109 )

Change subject: Break long lines
......................................................................

Break long lines

Change-Id: I6830de495b8c943ef015b29b40a57d9539c92d6c
---
M Question.php
M Quiz.class.php
M phpcs.xml
3 files changed, 87 insertions(+), 31 deletions(-)


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

diff --git a/Question.php b/Question.php
index 57212ca..c73a33d 100644
--- a/Question.php
+++ b/Question.php
@@ -204,20 +204,29 @@
                                                        // A single choice 
object with many correct proposal is a syntax error.
                                                        if ( $this->mType == 
'singleChoice' && $expectOn > 1 ) {
                                                                
$this->setState( 'error' );
-                                                               $inputStyle = 
'style="outline: ' . Quiz::getColor( 'error' ) . ' solid 3px; *border: 3px 
solid ' . Quiz::getColor( 'error' ) . ';"';
-                                                               $title = 
'title="' . wfMessage( 'quiz_colorError' )->escaped() . '"';
+                                                               $inputStyle = 
'style="outline: ' . Quiz::getColor( 'error' ) .
+                                                                       ' solid 
3px; *border: 3px solid ' . Quiz::getColor( 'error' ) .
+                                                                       ';"';
+                                                               $title = 
'title="' .
+                                                                       
wfMessage( 'quiz_colorError' )->escaped() . '"';
                                                                $disabled = 
'disabled="disabled"';
                                                        }
                                                        if ( 
$this->mBeingCorrected ) {
                                                                if ( $checked ) 
{
                                                                        
$checkedCount++;
                                                                        
$this->setState( 'right' );
-                                                                       
$inputStyle = 'style="outline: ' . Quiz::getColor( 'right' ) . ' solid 3px; 
*border: 3px solid ' . Quiz::getColor( 'right' ) . ';"';
-                                                                       $title 
= 'title="' . wfMessage( 'quiz_colorRight' )->escaped() . '"';
+                                                                       
$inputStyle = 'style="outline: ' . Quiz::getColor( 'right' ) .
+                                                                               
' solid 3px; *border: 3px solid ' .
+                                                                               
Quiz::getColor( 'right' ) . ';"';
+                                                                       $title 
= 'title="' . wfMessage( 'quiz_colorRight' )->escaped() .
+                                                                               
'"';
                                                                } else {
                                                                        
$this->setState( 'na_wrong' );
-                                                                       
$inputStyle = 'style="outline: ' . Quiz::getColor( 'wrong' ) . ' solid 3px; 
*border: 3px solid ' . Quiz::getColor( 'wrong' ) . ';"';
-                                                                       $title 
= 'title="' . wfMessage( 'quiz_colorWrong' )->escaped() . '"';
+                                                                       
$inputStyle = 'style="outline: ' . Quiz::getColor( 'wrong' ) .
+                                                                               
' solid 3px; *border: 3px solid ' .
+                                                                               
Quiz::getColor( 'wrong' ) . ';"';
+                                                                       $title 
= 'title="' . wfMessage( 'quiz_colorWrong' )->escaped() .
+                                                                               
'"';
                                                                }
                                                        }
                                                        break;
@@ -226,8 +235,11 @@
                                                                if ( $checked ) 
{
                                                                        
$checkedCount++;
                                                                        
$this->setState( 'wrong' );
-                                                                       
$inputStyle = 'style="outline: ' . Quiz::getColor( 'wrong' ) . ' solid 3px; 
*border: 3px solid ' . Quiz::getColor( 'wrong' ) . ';"';
-                                                                       $title 
= 'title="' . wfMessage( 'quiz_colorWrong' )->escaped() . '"';
+                                                                       
$inputStyle = 'style="outline: ' . Quiz::getColor( 'wrong' ) .
+                                                                               
' solid 3px; *border: 3px solid ' .
+                                                                               
Quiz::getColor( 'wrong' ) . ';"';
+                                                                       $title 
= 'title="' . wfMessage( 'quiz_colorWrong' )->escaped() .
+                                                                               
'"';
                                                                } else {
                                                                        
$this->setState( 'na_right' );
                                                                }
@@ -235,13 +247,17 @@
                                                        break;
                                                default:
                                                        $this->setState( 
'error' );
-                                                       $inputStyle = 
'style="outline: ' . Quiz::getColor( 'error' ) . ' solid 3px; *border: 3px 
solid ' . Quiz::getColor( 'error' ) . ';"';
+                                                       $inputStyle = 
'style="outline: ' . Quiz::getColor( 'error' ) .
+                                                               ' solid 3px; 
*border: 3px solid ' . Quiz::getColor( 'error' ) .
+                                                               ';"';
                                                        $title = 'title="' . 
wfMessage( 'quiz_colorError' )->escaped() . "\"";
                                                        $disabled = 
'disabled="disabled"';
                                                        break;
                                        }
                                        $signesOutput .= '<td class="sign">';
-                                       $signesOutput .= '<input class="check" 
' . $inputStyle . ' type="' . $inputType . '" ' . $title . ' name="' . $name . 
'" value="' . $value . '" ' . $checked . ' ' . $disabled . ' />';
+                                       $signesOutput .= '<input class="check" 
' . $inputStyle . ' type="' .
+                                               $inputType . '" ' . $title . ' 
name="' . $name . '" value="' . $value .
+                                               '" ' . $checked . ' ' . 
$disabled . ' />';
                                        $signesOutput .= '</td>';
                                }
                                if ( $typeId == 'sc' ) {
@@ -256,7 +272,9 @@
                                        $text = '???';
                                        $this->setState( 'error' );
                                }
-                       } elseif ( preg_match( $this->mCorrectionPattern, $raw, 
$matches ) && $this->mBeingCorrected ) {
+                       } elseif ( preg_match( $this->mCorrectionPattern, $raw, 
$matches ) &&
+                               $this->mBeingCorrected
+                       ) {
                                $rawClass = 'correction';
                                $text = array_pop( $matches );
                                $signesOutput = '<td>&#x2192;</td>';
@@ -330,7 +348,8 @@
                        if ( preg_match( $this->mCorrectionPattern, $raw, 
$matches ) ) {
                                if ( $this->mBeingCorrected ) {
                                        $rawClass = 'correction';
-                                       $text = '<td>&#x2192; ' . 
$this->mParser->recursiveTagParse( $matches[1] ) . '</td>';
+                                       $text = '<td>&#x2192; ' . 
$this->mParser->recursiveTagParse( $matches[1] ) .
+                                               '</td>';
                                } else {
                                        continue;
                                }
@@ -358,7 +377,18 @@
        function parseTextField( $input ) {
                global $wqInputId;
                $wqInputId++;
-               $title = $state = $size = $maxlength = $class = $style = $value 
= $disabled = $big = $poss = $name = $bigDisplay = '';
+               $title = '';
+               $state =  '';
+               $size =  '';
+               $maxlength =  '';
+               $class =  '';
+               $style =  '';
+               $value =  '';
+               $disabled =  '';
+               $big =  '';
+               $poss =  '';
+               $name =  '';
+               $bigDisplay = '';
                // determine size and maxlength of the input.
                if ( array_key_exists( 3, $input ) ) {
                        $size = $input[3];
@@ -386,23 +416,36 @@
                        }
                        $class = 'numbers';
                        $poss = ' ';
-                       foreach ( preg_split( '` *\| *`', trim( $input[1] ), 
-1, PREG_SPLIT_NO_EMPTY ) as $possibility ) {
+                       foreach (
+                               preg_split( '` *\| *`', trim( $input[1] ), -1, 
PREG_SPLIT_NO_EMPTY ) as $possibility
+                       ) {
                                if ( $state == '' || $state == 'NA' || $state 
== 'wrong' ) {
-                                       if ( preg_match( 
'`^(-?\d+\.?\d*)(-(-?\d+\.?\d*)| (\d+\.?\d*)(%))?$`', str_replace( ',', '.', 
$possibility ), $matches ) ) {
+                                       if ( preg_match(
+                                               
'`^(-?\d+\.?\d*)(-(-?\d+\.?\d*)| (\d+\.?\d*)(%))?$`',
+                                               str_replace( ',', '.', 
$possibility ),
+                                               $matches )
+                                       ) {
                                                if ( array_key_exists( 5, 
$matches ) ) {
                                                        $strlen = $size = 
$maxlength = '';
                                                } elseif ( array_key_exists( 3, 
$matches ) ) {
-                                                       $strlen = strlen( 
$matches[1] ) > strlen( $matches[3] ) ? strlen( $matches[1] ) : strlen( 
$matches[3] );
+                                                       $strlen = strlen( 
$matches[1] ) > strlen( $matches[3] )
+                                                               ? strlen( 
$matches[1] )
+                                                               : strlen( 
$matches[3] );
                                                } else {
                                                        $strlen = strlen( 
$matches[1] );
                                                }
                                                if ( $this->mBeingCorrected && 
$value !== "" ) {
                                                        $value = str_replace( 
',', '.', $value );
                                                        if ( is_numeric( $value 
) && (
-                                                               ( 
array_key_exists( 5, $matches )
-                                                                       && 
$value >= ( $matches[1] - ( $matches[1] * $matches[4] ) / 100 )
-                                                                       && 
$value <= ( $matches[1] + ( $matches[1] * $matches[4] ) / 100 )
-                                                               ) || ( 
array_key_exists( 3, $matches ) && $value >= $matches[1] && $value <= 
$matches[3]
+                                                               (
+                                                                       
array_key_exists( 5, $matches )
+                                                                       && 
$value >=
+                                                                               
( $matches[1] - ( $matches[1] * $matches[4] ) / 100 )
+                                                                       && 
$value <=
+                                                                               
( $matches[1] + ( $matches[1] * $matches[4] ) / 100 )
+                                                               ) || (
+                                                                       
array_key_exists( 3, $matches ) &&
+                                                                       $value 
>= $matches[1] && $value <= $matches[3]
                                                                ) || $value == 
$possibility )
                                                        ) {
                                                                $state = 
'right';
@@ -413,12 +456,18 @@
                                                        }
                                                }
                                        } else {
-                                               $strlen = preg_match( '` 
\(i\)$`', $possibility ) ? mb_strlen( $possibility ) - 4 : mb_strlen( 
$possibility );
+                                               $strlen = preg_match( '` 
\(i\)$`', $possibility )
+                                                       ? mb_strlen( 
$possibility ) - 4
+                                                       : mb_strlen( 
$possibility );
                                                $class = 'words';
                                                if ( $this->mBeingCorrected && 
$value !== "" ) {
                                                        if ( $value == 
$possibility ||
-                                                               ( preg_match( 
'`^' . preg_quote( $value, '`' ) . ' \(i\)$`i', $possibility ) ) ||
-                                                               ( 
!$this->mCaseSensitive && preg_match( '`^' . preg_quote( $value, '`' ) . '$`i', 
$possibility ) )
+                                                               ( preg_match(
+                                                                       '`^' . 
preg_quote( $value, '`' ) . ' \(i\)$`i', $possibility
+                                                               ) ) ||
+                                                               ( 
!$this->mCaseSensitive && preg_match(
+                                                                       '`^' . 
preg_quote( $value, '`' ) . '$`i', $possibility
+                                                               ) )
                                                        ) {
                                                                $state = 
'right';
                                                                $title = 
wfMessage( 'quiz_colorRight' )->escaped();
@@ -435,7 +484,9 @@
                                        }
                                }
                                if ( $this->mBeingCorrected ) {
-                                       $strlen = preg_match( '` \(i\)$`', 
$possibility ) ? mb_strlen( $possibility ) - 4 : mb_strlen( $possibility );
+                                       $strlen = preg_match( '` \(i\)$`', 
$possibility )
+                                               ? mb_strlen( $possibility ) - 4
+                                               : mb_strlen( $possibility );
                                        $possibility = substr( $possibility, 0, 
$strlen );
                                        $poss .= $possibility . '<br />';
                                }
diff --git a/Quiz.class.php b/Quiz.class.php
index 7ef1d2c..0a1aadd 100644
--- a/Quiz.class.php
+++ b/Quiz.class.php
@@ -41,7 +41,8 @@
                $this->mAddedPoints = 1;
                $this->mCutoffPoints = 0;
                $this->mIgnoringCoef = false;
-               $this->mDisplaySimple = ( array_key_exists( 'display', $argv ) 
&& $argv['display'] == 'simple' );
+               $this->mDisplaySimple = ( array_key_exists( 'display', $argv ) 
&&
+                       $argv['display'] == 'simple' );
 
                if ( $this->mBeingCorrected ) {
                        $lAddedPoints = str_replace( ',', '.',
@@ -64,7 +65,9 @@
 
                if ( array_key_exists( 'points', $argv ) &&
                        ( !$this->mBeingCorrected || $this->mDisplaySimple ) &&
-                       preg_match( '`([\d\.]*)/?([\d\.]*)(!)?`', str_replace( 
',', '.', $argv['points'] ), $matches )
+                       preg_match(
+                               '`([\d\.]*)/?([\d\.]*)(!)?`', str_replace( ',', 
'.', $argv['points'] ), $matches
+                       )
                ) {
                        if ( is_numeric( $matches[1] ) ) {
                                $this->mAddedPoints = $matches[1];
@@ -131,7 +134,8 @@
                $settingsTable = $templateParser->processTemplate(
                        'Setting',
                        [
-                               'isSettingFirstRow' => ( !$this->mDisplaySimple 
|| $this->mBeingCorrected || $this->mState === 'error' ),
+                               'isSettingFirstRow' => ( !$this->mDisplaySimple 
|| $this->mBeingCorrected ||
+                                       $this->mState === 'error' ),
                                'isSettingOtherRow' => ( !$this->mDisplaySimple 
|| $this->mBeingCorrected ),
                                'notSimple' => !$this->mDisplaySimple,
                                'corrected' => $this->mBeingCorrected,
@@ -288,8 +292,10 @@
                        What is this block of code?
                        The only place X !X and /X are spoken about is here
                        https://en.wikiversity.org/wiki/Help:Quiz
-                       "A few exotic features are not yet covered, such as 
shuffle control using {X} {!X} {/X} tags."
-                       These were added in commit fb53a3b0 back in 2007, 
without any explanation and/or documentation. The commit message is actually 
unrelated.
+                       "A few exotic features are not yet covered,
+                       such as shuffle control using {X} {!X} {/X} tags."
+                       These were added in commit fb53a3b0 back in 2007,
+                       without any explanation and/or documentation. The 
commit message is actually unrelated.
                */
                if ( !array_key_exists( 3, $matches ) || trim( $matches[3] ) == 
'' ) {
                        switch ( $matches[1] ) {
diff --git a/phpcs.xml b/phpcs.xml
index 6e8e2fb..72d8126 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -7,11 +7,10 @@
                <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingReturn" />
                <exclude 
name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" />
                <exclude 
name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
-               <exclude name="Generic.Files.LineLength" />
        </rule>
        <file>.</file>
        <arg name="extensions" value="php,php5,inc" />
-       <arg name="encoding" value="utf8" />
+       <arg name="encoding" value="UTF-8" />
        <exclude-pattern>vendor</exclude-pattern>
        <rule ref="MediaWiki.NamingConventions.ValidGlobalName">
                <properties>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6830de495b8c943ef015b29b40a57d9539c92d6c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Quiz
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

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

Reply via email to