Index: trunk/extensions/Translate/scripts/groupStatistics.php |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | $optionsWithArgs = array( 'groups', 'output', 'skiplanguages' ); |
88 | 88 | require( dirname( __FILE__ ) . '/cli.inc' ); |
89 | 89 | |
90 | | -class TranslateStatsOutput extends WikiStatsOutput { |
| 90 | +class TranslateStatsOutput extends wikiStatsOutput { |
91 | 91 | function heading() { |
92 | 92 | echo '{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;" width="100%"' . "\n"; |
93 | 93 | } |
— | — | @@ -164,8 +164,13 @@ |
165 | 165 | } |
166 | 166 | |
167 | 167 | $reportScore = false; |
| 168 | +// Check if score should be reported and prepare weights |
168 | 169 | if ( isset( $options['most'] ) && isset( $localisedWeights[$options['most']] ) ) { |
169 | 170 | $reportScore = true; |
| 171 | + $weights = array(); |
| 172 | + foreach( $localisedWeights[$options['most']] as $weight ) { |
| 173 | + $weights[] = $weight; |
| 174 | + } |
170 | 175 | } |
171 | 176 | |
172 | 177 | // Get groups from input |
— | — | @@ -213,16 +218,29 @@ |
214 | 219 | if( isset( $options['most'] ) && isset( $options['speakers'] ) ) { |
215 | 220 | $out->element( 'Speakers', true ); |
216 | 221 | } |
217 | | -/*if( $reportScore ) { |
218 | | - $out->element( 'Score', true ); |
219 | | -}*/ |
| 222 | + |
| 223 | +$totalWeight = 0; |
| 224 | +if( $reportScore ) { |
| 225 | + foreach( $localisedWeights[$options['most']] as $weight ) { |
| 226 | + $totalWeight += $weight; |
| 227 | + } |
| 228 | + $out->element( 'Score (' . $totalWeight . ')', true ); |
| 229 | +} |
| 230 | + |
220 | 231 | foreach ( $groups as $g ) { |
221 | 232 | // Add unprocessed description of group as heading |
222 | | - $out->element( $g->getLabel(), true ); |
223 | | - if ( isset( $options['fuzzy'] ) ) { |
| 233 | + if( $reportScore ) { |
| 234 | + $gid = $g->getId(); |
| 235 | + $heading = $g->getLabel() . " (" . $localisedWeights[$options['most']][$gid] . ")"; |
| 236 | + } else { |
| 237 | + $heading = $g->getLabel(); |
| 238 | + } |
| 239 | + $out->element( $heading, true ); |
| 240 | + if ( !$reportScore && isset( $options['fuzzy'] ) ) { |
224 | 241 | $out->element( 'Fuzzy', true ); |
225 | 242 | } |
226 | 243 | } |
| 244 | + |
227 | 245 | $out->blockend(); |
228 | 246 | |
229 | 247 | $rows = array(); |
— | — | @@ -345,16 +363,29 @@ |
346 | 364 | } |
347 | 365 | |
348 | 366 | // Fill the score field |
349 | | - /*if( $reportScore ) { |
350 | | - $weights = $localisedWeights[$options['most']]; |
351 | | - }*/ |
| 367 | + if( $reportScore ) { |
| 368 | + // Keep count |
| 369 | + $i = 0; |
| 370 | + // Start with 0 points |
| 371 | + $score = 0; |
352 | 372 | |
| 373 | + foreach ( $columns as $fields ) { |
| 374 | + list( $invert, $upper, $total ) = $fields; |
| 375 | + // Weigh the score and add it to the current score |
| 376 | + $score += ( $weights[$i] * $upper ) / $total; |
| 377 | + $i++; |
| 378 | + } |
| 379 | + |
| 380 | + // Report a round numbers |
| 381 | + $score = number_format( $score, 0 ); |
| 382 | + |
| 383 | + $out->element( $score ); |
| 384 | + } |
| 385 | + |
353 | 386 | // Fill fields for groups |
354 | 387 | foreach ( $columns as $fields ) { |
355 | | - //var_dump( $fields, true ); |
356 | | - //exit(1); |
357 | 388 | list( $invert, $upper, $total ) = $fields; |
358 | | - $c = $out->formatPercent( $upper, $total, $invert, /* Decimals */ 2 ); |
| 389 | + $c = $out->formatPercent( $upper, $total, $invert ); |
359 | 390 | $out->element( $c ); |
360 | 391 | } |
361 | 392 | $out->blockend(); |