r74669 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74668‎ | r74669 | r74670 >
Date:16:16, 12 October 2010
Author:ashley
Status:deferred
Tags:
Comment:
Quiz: use tabs for indentation, not spaces
Modified paths:
  • /trunk/extensions/Quiz/Quiz.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Quiz/Quiz.class.php
@@ -34,47 +34,47 @@
3535 # Reset the counter of div "shuffle" or "noshuffle" inside the quiz.
3636 $this->mShuffleDiv = 0;
3737 # Determine if this quiz is being corrected or not, according to the quizId
38 - $this->mBeingCorrected = ( $wgRequest->getVal( 'quizId' ) == "$this->mQuizId" )? true : false;
39 - # Initialize various parameters used for the score calculation
40 - $this->mState = 'NA';
41 - $this->mTotal = $this->mScore = 0;
42 - $this->mAddedPoints = 1;
43 - $this->mCutoffPoints = 0;
44 - $this->mIgnoringCoef = false;
45 - $this->mDisplaySimple = ( array_key_exists( 'display', $argv ) && $argv['display'] == 'simple' ) ? true : false;
46 - if( $this->mBeingCorrected ) {
47 - $lAddedPoints = str_replace( ',', '.', $this->mRequest->getVal( 'addedPoints' ) );
48 - if( is_numeric( $lAddedPoints ) ) {
49 - $this->mAddedPoints = $lAddedPoints;
50 - }
51 - $lCutoffPoints = str_replace( ',', '.', $this->mRequest->getVal( 'cutoffPoints' ) );
52 - if( is_numeric( $lCutoffPoints ) ) {
53 - $this->mCutoffPoints = $lCutoffPoints;
54 - }
55 - if( $this->mRequest->getVal( 'ignoringCoef' ) == 'on' ) {
56 - $this->mIgnoringCoef = true;
57 - }
58 - }
59 - if (
 38+ $this->mBeingCorrected = ( $wgRequest->getVal( 'quizId' ) == "$this->mQuizId" )? true : false;
 39+ # Initialize various parameters used for the score calculation
 40+ $this->mState = 'NA';
 41+ $this->mTotal = $this->mScore = 0;
 42+ $this->mAddedPoints = 1;
 43+ $this->mCutoffPoints = 0;
 44+ $this->mIgnoringCoef = false;
 45+ $this->mDisplaySimple = ( array_key_exists( 'display', $argv ) && $argv['display'] == 'simple' ) ? true : false;
 46+ if( $this->mBeingCorrected ) {
 47+ $lAddedPoints = str_replace( ',', '.', $this->mRequest->getVal( 'addedPoints' ) );
 48+ if( is_numeric( $lAddedPoints ) ) {
 49+ $this->mAddedPoints = $lAddedPoints;
 50+ }
 51+ $lCutoffPoints = str_replace( ',', '.', $this->mRequest->getVal( 'cutoffPoints' ) );
 52+ if( is_numeric( $lCutoffPoints ) ) {
 53+ $this->mCutoffPoints = $lCutoffPoints;
 54+ }
 55+ if( $this->mRequest->getVal( 'ignoringCoef' ) == 'on' ) {
 56+ $this->mIgnoringCoef = true;
 57+ }
 58+ }
 59+ if (
6060 array_key_exists( 'points', $argv ) &&
6161 ( !$this->mBeingCorrected || $this->mDisplaySimple ) &&
6262 preg_match( '`([\d\.]*)/?([\d\.]*)(!)?`', str_replace( ',', '.', $argv['points'] ), $matches )
6363 )
6464 {
65 - if( is_numeric( $matches[1] ) ) {
66 - $this->mAddedPoints = $matches[1];
67 - }
68 - if( is_numeric( $matches[2] ) ) {
69 - $this->mCutoffPoints = $matches[2];
70 - }
71 - if( array_key_exists( 3, $matches ) ) {
72 - $this->mIgnoringCoef = true;
73 - }
74 - }
75 - $this->mShuffle = ( array_key_exists( 'shuffle', $argv ) && $argv['shuffle'] == 'none' ) ? false : true;
76 - $this->mCaseSensitive = ( array_key_exists( 'case', $argv ) && $argv['case'] == '(i)' ) ? false : true;
77 - # Patterns used in several places
78 - $this->mIncludePattern = '`^\{\{:?(.*)\}\}[ \t]*`m';
 65+ if( is_numeric( $matches[1] ) ) {
 66+ $this->mAddedPoints = $matches[1];
 67+ }
 68+ if( is_numeric( $matches[2] ) ) {
 69+ $this->mCutoffPoints = $matches[2];
 70+ }
 71+ if( array_key_exists( 3, $matches ) ) {
 72+ $this->mIgnoringCoef = true;
 73+ }
 74+ }
 75+ $this->mShuffle = ( array_key_exists( 'shuffle', $argv ) && $argv['shuffle'] == 'none' ) ? false : true;
 76+ $this->mCaseSensitive = ( array_key_exists( 'case', $argv ) && $argv['case'] == '(i)' ) ? false : true;
 77+ # Patterns used in several places
 78+ $this->mIncludePattern = '`^\{\{:?(.*)\}\}[ \t]*`m';
7979 }
8080
8181 static function resetQuizID() {
@@ -83,10 +83,10 @@
8484 }
8585
8686 static function loadMessages() {
87 - static $messagesLoaded = false;
88 - if ( $messagesLoaded ) {
 87+ static $messagesLoaded = false;
 88+ if ( $messagesLoaded ) {
8989 return true;
90 - }
 90+ }
9191 $messagesLoaded = true;
9292 wfLoadExtensionMessages( 'QuizExtension' );
9393 return true;
@@ -122,14 +122,14 @@
123123 $start = $wgContLang->isRTL() ? 'right' : 'left';
124124 $end = $wgContLang->isRTL() ? 'left' : 'right';
125125 $head = "<style type=\"text/css\">\n";
126 - $head .= ".quiz .settings input.numerical { width: 2em; }\n";
127 - $head .= ".quiz .question { margin-$start: 2em; }\n";
128 - $head .= ".quiz .margin { padding-$start: 20px; }\n";
129 - $head .= ".quiz .header .questionId { font-size: 1.1em; font-weight: bold; float: $start;}\n";
130 - $head .= "*>.quiz .header .questionId { text-indent: -1.5em; }\n"; // *> prevent ie6 from interpreting it.
 126+ $head .= ".quiz .settings input.numerical { width: 2em; }\n";
 127+ $head .= ".quiz .question { margin-$start: 2em; }\n";
 128+ $head .= ".quiz .margin { padding-$start: 20px; }\n";
 129+ $head .= ".quiz .header .questionId { font-size: 1.1em; font-weight: bold; float: $start;}\n";
 130+ $head .= "*>.quiz .header .questionId { text-indent: -1.5em; }\n"; // *> prevent ie6 from interpreting it.
131131 $head .= ".quiz table.object, .quiz table.correction { background-color: transparent; }";
132132 $head .= '.quiz .correction { background-color: ' . Quiz::getColor( 'correction' ) . ";}\n";
133 - $head .= ".quiz .hideCorrection .correction { display: none; }\n";
 133+ $head .= ".quiz .hideCorrection .correction { display: none; }\n";
134134 $head .= ".quiz .settings td { padding: 0.1em 0.4em 0.1em 0.4em }\n";
135135 $head .= ".quiz table.settings { background-color: transparent; }\n";
136136 # Part for the basic types's inputs.
@@ -142,12 +142,12 @@
143143 $head .= ".quiz a.input span.correction { padding:3px; margin:0; list-style-type:none; display:none; background-color:" . Quiz::getColor( 'correction' ) . "; }\n";
144144 $head .= ".quiz a.input:active span.correction, .quiz a.input:focus span.correction { display:inline; position:absolute; margin:1.8em 0 0 0.1em; }\n";
145145 $head .= "</style>\n";
146 - global $wgJsMimeType, $wgScriptPath, $wgOut;
147 - # Determine the extension folder
148 - $folder = array_pop( explode( '/', dirname( __FILE__ ) ) );
149 - $folder = ( $folder == 'extensions' ) ? '' : "/$folder";
150 - $head .= "<script type=\"$wgJsMimeType\" src=\"$wgScriptPath/extensions$folder/quiz.js\"></script>\n";
151 - $wgOut->addScript( $head );
 146+ global $wgJsMimeType, $wgScriptPath, $wgOut;
 147+ # Determine the extension folder
 148+ $folder = array_pop( explode( '/', dirname( __FILE__ ) ) );
 149+ $folder = ( $folder == 'extensions' ) ? '' : "/$folder";
 150+ $head .= "<script type=\"$wgJsMimeType\" src=\"$wgScriptPath/extensions$folder/quiz.js\"></script>\n";
 151+ $wgOut->addScript( $head );
152152 }
153153
154154 # Process the input
@@ -156,11 +156,11 @@
157157 # Generates the output.
158158 $classHide = ( $this->mBeingCorrected ) ? '' : ' class="hideCorrection"';
159159 $output = '<div class="quiz">';
160 - $output .= "<form id=\"quiz$this->mQuizId\" $classHide method=\"post\" action=\"#quiz$this->mQuizId\">\n";
161 - # Determine the content of the settings table.
162 - $settings = array_fill( 0, 4, '' );
 160+ $output .= "<form id=\"quiz$this->mQuizId\" $classHide method=\"post\" action=\"#quiz$this->mQuizId\">\n";
 161+ # Determine the content of the settings table.
 162+ $settings = array_fill( 0, 4, '' );
163163 if( !$this->mDisplaySimple ) {
164 - $settings[0] .= '<td>' . wfMsgHtml( 'quiz_addedPoints', $this->mAddedPoints ) . ':</td>' .
 164+ $settings[0] .= '<td>' . wfMsgHtml( 'quiz_addedPoints', $this->mAddedPoints ) . ':</td>' .
165165 "<td><input class=\"numerical\" type=\"text\" name=\"addedPoints\" value=\"$this->mAddedPoints\"/>&#160;&#160;</td>";
166166 $settings[1] .= '<td>' . wfMsgHtml( 'quiz_cutoffPoints', $this->mCutoffPoints ) . ':</td>' .
167167 "<td><input class=\"numerical\" type=\"text\" name=\"cutoffPoints\" value=\"$this->mCutoffPoints\"/></td>";
@@ -199,23 +199,23 @@
200200 }
201201 $output .= "<input type=\"hidden\" name=\"quizId\" value=\"$this->mQuizId\" />";
202202
203 - $output .= '<div class="quizQuestions">';
 203+ $output .= '<div class="quizQuestions">';
204204 $output .= $input;
205205 $output .= '</div>';
206206
207 - $output .= '<p><input type="submit" value="' . wfMsgHtml( 'quiz_correction' ) . '"/>';
208 - if( $this->mBeingCorrected ) {
 207+ $output .= '<p><input type="submit" value="' . wfMsgHtml( 'quiz_correction' ) . '"/>';
 208+ if( $this->mBeingCorrected ) {
209209 $output .= '<input class="reset" type="submit" value="' .
210210 wfMsgHtml( 'quiz_reset' ) . '" style="display: none;" />';
211 - }
 211+ }
212212 $output .= '</p>';
213213 $output .= '<span class="correction">';
214214 $output .= wfMsgHtml( 'quiz_score',
215215 "<span class=\"score\">$this->mScore</span>",
216216 "<span class=\"total\">$this->mTotal</span>" );
217 - $output .= '</span>';
218 - $output .= "</form>\n";
219 - $output .= "</div>\n";
 217+ $output .= '</span>';
 218+ $output .= "</form>\n";
 219+ $output .= "</div>\n";
220220 return $output;
221221 }
222222

Status & tagging log