nice new statistics... oh man world revolution is coming DUDES!

This commit is contained in:
Nael 2014-02-23 23:35:53 +01:00
parent 7d3eead162
commit fbcde01b67
8 changed files with 47 additions and 30 deletions

View File

@ -77,6 +77,9 @@ class votes {
return $res;
}
public static function get_user_temp_votes($user_ID){
return \DBD\UVOTE_DATA_TEMP_VOTES::Q1(array($user_ID, $user_ID, $user_ID));}
public static function get_bar_bt_per_poll($poll_ID){
return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));}

View File

@ -1,11 +0,0 @@
<?php
namespace DBD;
class UVOTE_DATA_COUNT_VOTES extends \SYSTEM\DB\QQ {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT COUNT(*) as "count" FROM uvote_votes;'
);}}

View File

@ -0,0 +1,13 @@
<?php
namespace DBD;
class UVOTE_DATA_TEMP_VOTES extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT SUM(CASE WHEN uvote_data.user_ID = ? THEN 1 ELSE 0 END) as voted,
SUM(CASE WHEN uvote_data.user_ID = ? THEN 0 ELSE 1 END) AS not_voted
FROM uvote_data RIGHT JOIN uvote_votes ON ( uvote_data.poll_ID = uvote_votes.ID AND uvote_data.user_ID = ?);'
);}}

View File

@ -1,4 +1,4 @@
<div class="tabbable" style="">
<div class="tabbable" style="padding-right: 50px;">
<ul class="nav nav-tabs" id="tabs_user_main">
<li class="active"><a href="#tab_uVote" action="user_main_uVote">uVote</a></li>
<li><a href="#tab_urVote" action="user_main_urVote">urVote</a></li>

View File

@ -37,7 +37,7 @@ class user_main_uVote extends SYSTEM\PAGE\Page {
$vote['bt_choice'] = 'ENTH';
break;
case 0:
$vote['bt_choice'] = 'OPEN';
$vote['bt_choice'] = 'OFFEN';
}
//$vote['count'];
//$vote['choice'];

View File

@ -1 +1,7 @@
${poll_compare}
<h5>Deine aktuelle Abstimmungsquote</h5>
<div style="float: left">Abgestimmt/</div>
<div style="margin-left: 90px;">Offene Abstimmungen</div>
<div class="progress" style="height: 30px;">
<div class="bar bar-success" style="width: ${vote_perc}%;"></div>
<div class="bar bar-info" style="width: ${no_vote_perc}%;"></div>
</div>

View File

@ -1,18 +1,21 @@
<div id="statistics_uvote_users">
<div id="statistics_uvote_users">
<h4>${urVote_title}</h4>
<div style="float: left;">
<table style="border-collapse: separate;
border-spacing: 10px 5px;">
border-spacing: 10px 5px; width: 350px;">
<tr>
<h5>${urVote_title}</h5>
</tr>
<tr>
<h6>${urVote_user_party_compare}</h6>
<h5>${urVote_user_party_compare}</h5>
${choices_user_ID}
</tr>
<tr>
${choices_bt_to_user}
</tr>
</table>
</div>
</table>
</div>
<div style="float: left; padding-left: 50px;">
${user_temp_votes}
</div>
</div>

View File

@ -1,11 +1,13 @@
<?php
class user_main_urVote extends SYSTEM\PAGE\Page {
private function count_all_polls (){
$result = '';
$vars = votes::countAllPolls();
new INFO(print_r($vars, true));
return $result;
private function user_temp_votes (){
$vars = votes::get_user_temp_votes(\SYSTEM\SECURITY\Security::getUser()->id);
$v = $vars['voted'];
$nv = $vars['not_voted'];
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/all_polls.tpl'),
array( 'vote_perc'=> round($v/($nv+$v)*100,0),
'no_vote_perc'=> round($nv/($nv+$v)*100,0)));
}
private function user_to_bt(){
@ -22,7 +24,7 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
while($row = $res->next()){
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH']+1)*100,2);
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/bt_to_user_overall.tpl'), $row);;
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/bt_to_user_overall.tpl'), $row);
}
return $result;
$row['votes_cast'] = round(($row['class_MATCH']+$row['class_MISSMATCH']),2);
@ -54,6 +56,7 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
$vars['choices_user_ID'] = $this->user_per_party_overall();
$vars['choices_bt_to_user'] = $this->user_to_bt();
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
$vars['user_temp_votes'] = $this->user_temp_votes();
$vars = array_merge($vars, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urVote.tpl'),$vars);