Home
LimeSurvey Forums
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Change from "%" to "number" in {PERCENTCOMPLETE (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: Re:Change from "%" to "number" in {PERCENTCOMPLETE
#11588
ypse (User)
Fresh Lemon
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
[done] Change from % to "number" {PERCENTCOMPLETE} 7 Months, 3 Weeks ago Karma: 1  
First: this is a fantastic app. Thx.

Now the problem

I designed my own template, and I have a little problem.
It's name is "{PERCENTCOMPLETE}"

How should I change from "%" to "number"
Example : 3/6 [3 step from 6]

[the variable {PERCENTCOMPLETE} in the survey.pstpl of the template ] ??

I find makegraph function in /index.php [#711] and /admin/templates.php [#829], but I'm not sure if this is correct way

Additionaly I think about adding number of percent ...
Now we have 0% ... 100%
My change : 0% ..X_NUMBER%Complite.. 100%
Example: 0% ..12%.. 100%

I find this line

Code:

$size=intval(($thisstep-1)/$total*100);

and use $size into chart.jpg status bar.


But, still I'm searching a way to have "number" instead of "percent" ...


Someone help ?
I use 1.7 ver.
 
Logged Logged  
 
Last Edit: 2008/05/21 10:03 By Mazi.
 
Y
  The administrator has disabled public write access.
#11597
wiero (User)
Fresh Lemon
Posts: 16
graphgraph
User Offline Click here to see the profile of this user
Re:Change from "%" to "number" in {PERCENTCOMPLETE 7 Months, 3 Weeks ago Karma: 0  
in index.php there is function makegraph.

in this way you can make 2/50 (steps) like progress state

Code:

function makegraph($thisstep, $total)
{
global $thissurvey;
global $thistpl, $publicurl, $clang;
$chart=$thistpl."/chart.jpg";
if (!is_file($chart)) {$shchart="chart.jpg";}
else {$shchart = "$publicurl/templates/{$thissurvey['templatedir']}/chart.jpg";}
$graph = "<table class='graph' width='100' align='center' cellpadding='2'><tr><td>n"
// . "<table width='180' align='center' cellpadding='0' cellspacing='0' border='0' class='innergraph'>n"
// . "<tr><td align='right' width='40'>0%&nbsp;</td>n";
// $size=intval(($thisstep-1)/$total*100);
.($thisstep-1)."/$total"
// $graph .= "<td width='100' align='left'>n"
// . "<table cellspacing='0' cellpadding='0' border='0' width='100%'>n"
// . "<tr><td class='progressbar'>n"
// . "<img src='$shchart' height='12' width='$size' align='left' alt='$size% ".$clang->gT("complete")."' />n"
// . "</td></tr>n"
// . "</table>n"
// . "</td>n"
// . "<td align='left' width='40'>&nbsp;100%</td></tr>n"
. "</table>n"
. "</td></tr>n</table>n";
return $graph;
}



instead of
Code:


($thisstep-1)."/$total"



you can make 0% 12% 100% like view

Code:


        ."0%..".round(($thisstep-1)*100/$total,2)."%..100%"



if it is what you need

i took the code from 1.43 so there might be some diffrences
 
Logged Logged  
 
Last Edit: 2008/04/02 09:17 By wiero.
  The administrator has disabled public write access.
#11599
ypse (User)
Fresh Lemon
Posts: 7
graphgraph
User Offline Click here to see the profile of this user
Re:Change from "%" to "number" in {PERCENTCOMPLETE 7 Months, 3 Weeks ago Karma: 1  
Thx

With some little modyfications

Code:


function makegraph($thisstep, $total) 

  global $thissurvey; 
  global $thistpl, $publicurl, $clang; 
  $chart=$thistpl."/chart.jpg"; 
  if (!is_file($chart)) {$shchart="chart.jpg";} 
  else {$shchart = "$publicurl/templates/{$thissurvey['templatedir']}/chart.jpg";} 
  $graph = "<table class='graph' align='center' cellpadding='2'><tr><td>n" 
  ."Question ".($thisstep)." from $total. Progress ".round(($thisstep-1)*100/$total,0)."%"
  . "</td></tr>n</table>n"; 
  return $graph; 
}




P.S.
Karma +1
 
Logged Logged  
 
Y
  The administrator has disabled public write access.
#11607
Mazi (Moderator)
Moderator Lime
Posts: 3252
graph
User Offline Click here to see the profile of this user
Re:Change from "%" to "number" in {PERCENTCOMPLETE 7 Months, 3 Weeks ago Karma: 25  
Great solution. Can you add this to the bug- and feature tracker to share your solution with the community?

This is an example of how to add such a great improvement:
Adding option for survey users to view survey results.

If you have done please give some feedback (ID of the entry) so that I can link your solution in the wiki, too.

Thanks a lot!
 
Logged Logged  
 
Best regards,
Mazi
______________________
Need help? I can: set up Limesurvey for you / create your survey / implement additional features / design your template / offer premium support -> Contact.
  The administrator has disabled public write access.
Go to top