|
|
Line 1: |
Line 1: |
− | <pre>{{#vardefine:totalReviews|0}}
| + | Seems like trying to use '''expr''' with '''var_final''' causes an error. Any thoughts? - [[User:Hivebrain|Hivebrain]] ([[User talk:Hivebrain|talk]]) 16:22, 1 July 2015 (CDT) |
− | {{#vardefine:cumulativeScore|0}}
| |
− | <!-- Calculate total number of reviews -->
| |
− | {{#if: {{{ace|}}} | {{#vardefine: cumulativeScore|{{#expr: {{#var: cumulativeScore}} + {{{ace}}} }} }} {{#vardefine: totalReviews|{{#expr: {{#var: totalReviews}} + 1 }} }} | }}
| |
− | ...
| |
− | {{#if: {{{vgce|}}} | {{#vardefine: cumulativeScore|{{#expr: {{#var: cumulativeScore}} + {{{vgce}}} }} }} {{#vardefine: totalReviews|{{#expr: {{#var: totalReviews}} + 1 }} }} | }}
| |
− | | |
− | <!-- in case it can't cope with divide by zero -->
| |
− | {{#ifeq: {{#var: totalReviews}} | 0 | {{#vardefine: totalReviews|1}} | }}
| |
− | | |
− | <!-- Calculate average -->
| |
− | {{#vardefine: average|
| |
− | {{#expr: {{#var: cumulativeScore}} / {{#var: totalReviews}}
| |
− | }}
| |
− | }}</pre>
| |
− | this will be hell<br>
| |
− | ideally we would be able to iterate over all the magazine name parameters, but I highly doubt mediawiki is that smart - [[User:Andlabs|Andlabs]] 16:15, 2 March 2012 (CST)
| |
− | :[http://www.mediawiki.org/wiki/Extension:Loops#.23forargs_.28Experimental.29 or not, but this still isn't optimal - we'd need to use prefixes for the score parameters] - [[User:Andlabs|Andlabs]] 16:19, 2 March 2012 (CST)
| |
− | :: Not sure how you're doing things here, but you should be able to calculate totalReviews like so: <nowiki>{{#if {{{ug|}}} | 1 | 0 }}+{{#if {{{vgce|}}} | 1 | 0}}</nowiki>+etc. - [[User:Hivebrain|Hivebrain]] 22:17, 2 March 2012 (CST)
| |
− | :::I'm trying to think of how to make it so we don't have to write that for every magazine - [[User:Andlabs|Andlabs]] 22:06, 4 March 2012 (CST)
| |
− | ::::Okay, I think I'm done. It's a bit ugly but seems to do the job. Might need further testing. -[[User:Black Squirrel|Black Squirrel]] 06:18, 5 March 2012 (CST) | |