Ejemplo n.º 1
0
function print_list_result_bar($data, $listindex, $answers, $class)
{
    $list_name = $data['lists'][$listindex]['name_x'];
    $list_points = calculate_points($data['answers'][$listindex], $answers);
    $ach_points = count_achievable_points($answers);
    if ($ach_points != 0) {
        $list_percentage = intval(100 * $list_points / $ach_points);
    } else {
        $list_percentage = 0;
    }
    echo "<tr class='{$class}'>\n\t<td><b>{$list_name}</b></td><td>{$list_points} of {$ach_points}</td>\n\t<td><div class='progress'>\n\t\t<div class='progress-bar' role='progressbar' aria-valuenow='{$list_points}' aria-valuemin='0' aria-valuemax='{$ach_points}' style='width: {$list_percentage}%;'>\n\t\t\t{$list_percentage} %\n\t\t</div>\n\t</div></td>\n\t</tr>";
}
Ejemplo n.º 2
0
    ?>
     <p><small>Not happy with your result? Perhaps you would like to <a href="multiplier.php" onclick="callPage(event, 'multiplier.php', <?php 
    echo "'{$answerstring}', '{$count}'";
    ?>
)" title="Mark theses as important to you">mark some theses as important to you</a>.</small></p>
     <?php 
}
?>
     
     <div id="result-bars">
     <table class="table table-bordered table-hover">
     <tr><th style="width: 200px;">Party</th><th style="width:100px">Points</th><th style="width:640px;">Points</th></tr>
            <?php 
$top = calculate_points($data['answers'][0], $answers);
for ($i = 0; $i < sizeof($data['answers']); $i++) {
    calculate_points($data['answers'][$i], $answers) == $top ? $class = "success" : ($class = "");
    print_list_result_bar($data, $i, $answers, $class);
    echo "\n";
}
?>

     </table>
    </div>
    
    <?php 
if (!$bars_only) {
    ?>
    <div id="result-table">
    <div class="panel panel-default">
	<div class="panel-body">
		Show/Hide parties:
Ejemplo n.º 3
0
function sort_lists_by_points($data, $answers)
{
    $offset = 1 / floatval(sizeof($data['lists']));
    $sorted = array();
    $temp_answers = array();
    $temp_names = array();
    for ($i = 0; $i < sizeof($data['answers']); $i = $i + 1) {
        $sorted[$i] = calculate_points($data['answers'][$i], $answers) - $i * $offset;
        $temp_answers[(string) (calculate_points($data['answers'][$i], $answers) - $i * $offset)] = $data['answers'][$i];
        $temp_names[(string) (calculate_points($data['answers'][$i], $answers) - $i * $offset)] = $data['lists'][$i];
    }
    sort($sorted);
    $sorted_answers = array();
    $sorted_names = array();
    for ($i = 0; $i < sizeof($sorted); $i = $i + 1) {
        $sorted_answers[$i] = $temp_answers[(string) $sorted[$i]];
        $sorted_names[$i] = $temp_names[(string) $sorted[$i]];
    }
    $sorted_answers = rev_arr($sorted_answers);
    $sorted_names = rev_arr($sorted_names);
    for ($i = 0; $i < sizeof($data['answers']); $i = $i + 1) {
        $data['answers'][$i] = $sorted_answers[$i];
        $data['lists'][$i] = $sorted_names[$i];
    }
    return $data;
}