Index: trunk/extensions/Quiz/Quiz.class.php |
— | — | @@ -34,47 +34,47 @@ |
35 | 35 | # Reset the counter of div "shuffle" or "noshuffle" inside the quiz. |
36 | 36 | $this->mShuffleDiv = 0; |
37 | 37 | # 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 ( |
60 | 60 | array_key_exists( 'points', $argv ) && |
61 | 61 | ( !$this->mBeingCorrected || $this->mDisplaySimple ) && |
62 | 62 | preg_match( '`([\d\.]*)/?([\d\.]*)(!)?`', str_replace( ',', '.', $argv['points'] ), $matches ) |
63 | 63 | ) |
64 | 64 | { |
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'; |
79 | 79 | } |
80 | 80 | |
81 | 81 | static function resetQuizID() { |
— | — | @@ -83,10 +83,10 @@ |
84 | 84 | } |
85 | 85 | |
86 | 86 | static function loadMessages() { |
87 | | - static $messagesLoaded = false; |
88 | | - if ( $messagesLoaded ) { |
| 87 | + static $messagesLoaded = false; |
| 88 | + if ( $messagesLoaded ) { |
89 | 89 | return true; |
90 | | - } |
| 90 | + } |
91 | 91 | $messagesLoaded = true; |
92 | 92 | wfLoadExtensionMessages( 'QuizExtension' ); |
93 | 93 | return true; |
— | — | @@ -122,14 +122,14 @@ |
123 | 123 | $start = $wgContLang->isRTL() ? 'right' : 'left'; |
124 | 124 | $end = $wgContLang->isRTL() ? 'left' : 'right'; |
125 | 125 | $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. |
131 | 131 | $head .= ".quiz table.object, .quiz table.correction { background-color: transparent; }"; |
132 | 132 | $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"; |
134 | 134 | $head .= ".quiz .settings td { padding: 0.1em 0.4em 0.1em 0.4em }\n"; |
135 | 135 | $head .= ".quiz table.settings { background-color: transparent; }\n"; |
136 | 136 | # Part for the basic types's inputs. |
— | — | @@ -142,12 +142,12 @@ |
143 | 143 | $head .= ".quiz a.input span.correction { padding:3px; margin:0; list-style-type:none; display:none; background-color:" . Quiz::getColor( 'correction' ) . "; }\n"; |
144 | 144 | $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"; |
145 | 145 | $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 ); |
152 | 152 | } |
153 | 153 | |
154 | 154 | # Process the input |
— | — | @@ -156,11 +156,11 @@ |
157 | 157 | # Generates the output. |
158 | 158 | $classHide = ( $this->mBeingCorrected ) ? '' : ' class="hideCorrection"'; |
159 | 159 | $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, '' ); |
163 | 163 | if( !$this->mDisplaySimple ) { |
164 | | - $settings[0] .= '<td>' . wfMsgHtml( 'quiz_addedPoints', $this->mAddedPoints ) . ':</td>' . |
| 164 | + $settings[0] .= '<td>' . wfMsgHtml( 'quiz_addedPoints', $this->mAddedPoints ) . ':</td>' . |
165 | 165 | "<td><input class=\"numerical\" type=\"text\" name=\"addedPoints\" value=\"$this->mAddedPoints\"/>  </td>"; |
166 | 166 | $settings[1] .= '<td>' . wfMsgHtml( 'quiz_cutoffPoints', $this->mCutoffPoints ) . ':</td>' . |
167 | 167 | "<td><input class=\"numerical\" type=\"text\" name=\"cutoffPoints\" value=\"$this->mCutoffPoints\"/></td>"; |
— | — | @@ -199,23 +199,23 @@ |
200 | 200 | } |
201 | 201 | $output .= "<input type=\"hidden\" name=\"quizId\" value=\"$this->mQuizId\" />"; |
202 | 202 | |
203 | | - $output .= '<div class="quizQuestions">'; |
| 203 | + $output .= '<div class="quizQuestions">'; |
204 | 204 | $output .= $input; |
205 | 205 | $output .= '</div>'; |
206 | 206 | |
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 ) { |
209 | 209 | $output .= '<input class="reset" type="submit" value="' . |
210 | 210 | wfMsgHtml( 'quiz_reset' ) . '" style="display: none;" />'; |
211 | | - } |
| 211 | + } |
212 | 212 | $output .= '</p>'; |
213 | 213 | $output .= '<span class="correction">'; |
214 | 214 | $output .= wfMsgHtml( 'quiz_score', |
215 | 215 | "<span class=\"score\">$this->mScore</span>", |
216 | 216 | "<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"; |
220 | 220 | return $output; |
221 | 221 | } |
222 | 222 | |