Difference between revisions of "RatingsTest"

From Sega Retro

Line 38: Line 38:
 
-[[User:Black Squirrel|Black Squirrel]] ([[User talk:Black Squirrel|talk]]) 13:29, 2 July 2015 (CDT)
 
-[[User:Black Squirrel|Black Squirrel]] ([[User talk:Black Squirrel|talk]]) 13:29, 2 July 2015 (CDT)
 
: Loops looks like a useful extension, but I don't see how it would help here. The problem is, I wanted to combine the score averaging stuff with the collapsible content, but since the average is shown first I needed to use var_final. This didn't work, so it looks like the only option is to put the averaging back where it was originally. - [[User:Hivebrain|Hivebrain]] ([[User talk:Hivebrain|talk]]) 13:53, 2 July 2015 (CDT)
 
: Loops looks like a useful extension, but I don't see how it would help here. The problem is, I wanted to combine the score averaging stuff with the collapsible content, but since the average is shown first I needed to use var_final. This didn't work, so it looks like the only option is to put the averaging back where it was originally. - [[User:Hivebrain|Hivebrain]] ([[User talk:Hivebrain|talk]]) 13:53, 2 July 2015 (CDT)
 +
 +
::The idea is that on the first loop, the cumulativeScore and totalReviews variables are added to, and on the second, the averaging occurs. Above what would be the collapsible content.
 +
 +
::it's the only way I can think of getting data that's at the "bottom" to the "top". -[[User:Black Squirrel|Black Squirrel]] ([[User talk:Black Squirrel|talk]]) 14:19, 2 July 2015 (CDT)

Revision as of 15:19, 2 July 2015

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)

Loops looks like a useful extension, but I don't see how it would help here. The problem is, I wanted to combine the score averaging stuff with the collapsible content, but since the average is shown first I needed to use var_final. This didn't work, so it looks like the only option is to put the averaging back where it was originally. - Hivebrain (talk) 13:53, 2 July 2015 (CDT)
The idea is that on the first loop, the cumulativeScore and totalReviews variables are added to, and on the second, the averaging occurs. Above what would be the collapsible content.
it's the only way I can think of getting data that's at the "bottom" to the "top". -Black Squirrel (talk) 14:19, 2 July 2015 (CDT)