create new tag
, view all tags


I try to build an application with VotePlugin / RatingContrib , searched twiki.org, tried different approaches, but still can't get it working: I use VotePlugin to display the ratings, including average $score, $mylast vote and the absolute $sum of people participating in this vote:

%VOTE{id="RatingSomething" open="off" secret="off" stars1="RatingSomething" width1="10" format1="$small<br /> | Average: $score | My: $mylast | Participation: $sum |"}%

But additionally, I would like to display the "relative participation" in the vote, or to say in short: 100 * $sum / "number of users of the site". So I found two ways to get the number of users of the site:

1) SpreadSheetPlugin and FormattedSearch:

%CALC{$SET(total,0)}%<br />%SEARCH{ "%META:FORM.*[U]serForm" web="%MAINWEB%" type="regex" nosearch="on" nototal="on" format="$percntCALC{$SETM(total,+1)}$percnt" }%<br />Number of users: %CALC{$GET(total)}%

2) UserInfoPlugin:


And so i tried to combine this with a CALC by the SpreadSheetPlugin: e.g. inside the vote tag

%VOTE{id="RatingSomething" open="off" secret="off" stars1="RatingSomething" width1="10" format1="$small<br /> | Average: $score | My: $mylast | Participation: $sum | Number of Users: %NRUSERS% | Relative Participation: %CALC{"$EVAL( 100 * ( $sum / %NRUSERS% ) ) "}% "}%

When I replace % of CALC by $percnt (and " inside by \") , "$perc" is replaced by the VotePlugin with the result of the formatting token "$perc" , which expands to "100*$score/$sum"

Perhaps problem is also the "evil" nesting (VOTE(CALC(VOTE)))...

After some tries I put this outside the vote tag:

%CALC{"$EVAL(  100 * ( $percntVOTE{id=\"RatingSomething\" open=\"off\" secret=\"off\" stars1=\"RatingSomething\" width1=\"10\" format1=\"$sum\"}$percnt / $percntNRUSERS$percnt ) ) "}%
But yes, $sum outside of the vote tag ... doesn't work.

So I tried to use the SET pseudo-tag of the MacrosPlugin, but couldn't make it work in this case:

%SET PARTABS = %VOTE{id="RatingSomething" open="off" secret="off" stars1="RatingSomething" width1="10" format1="$sum"}%
Absolute Participation: %PARTABS%
%CALC{"$EVAL( 100 * ( %PARTABS% / %NRUSERS% ) )"}%
%CALC{"$EVAL( 100 * ( $percntPARTABS$percnt / $percntNRUSERS$percnt ) )"}%


So after revision 40 smile of the topic, I'd really appreciate help!



TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin, VotePlugin, MacrosPlugin, UserInfoPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Plugins

-- IngoBlickling - 31 Mar 2008


ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

I couldn't get it working for days on this way, so I had a look into VotePlugin and UserInfoPlugin modules and added some lines to core.pm of VotePlugin to include number of users directly and do the calculation there. And now it seems to work for me! If interested, have a look at VotePluginDev (comment 10 Apr 2008). So closed it as answered.

-- IngoBlickling - 10 Apr 2008

Change status to:
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2008-04-11 - IngoBlickling
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.