RatingsTest
From Sega Retro
Seems like trying to use expr with var_final causes an error. Any thoughts? - Hivebrain (talk) 16:22, 1 July 2015 (CDT)
- From the two minutes I've taken to look into this, I think var_final is created at the very last minute, i.e. after all the standard wiki parsing has been done.
- So it's not really a variable at all I guess. I can't... vary. -Black Squirrel (talk) 11:52, 2 July 2015 (CDT)
- I'm thinking the best plan might be to introduce loops: https://www.mediawiki.org/wiki/Extension:Loops
{{#vardefine: totalReviews|0}} {{#vardefine: cumulativeScore|0}} {{#vardefine: finished|false}} {{#vardefine: oneLoop|false}} <!-- while not done --> {{#while:| {{#ifeq: {{#var: finished}}|false}} | {{#ifeq: {{#var: oneLoop}}|true| <!-- if looped once --> {{#vardefine: average|{{#expr: {{#var: cumulativeScore}} / ({{#var: totalReviews}} * 100) }} }} {{#vardefine: finished|true}} <!-- exit after this loop --> | }} <!-- add up scores (this gets done twice) --> ... {{#vardefine: totalReviews|{{#var: totalReviews}} + 1}} {{#vardefine: cumulativeScore|{{#var: cumulativeScore}} + score}} ... {{#vardefine:oneLoop|true}} }}
no idea if the syntax works but yeah.
-Black Squirrel (talk) 13:29, 2 July 2015 (CDT)