new stats, new texts, new awesome
This commit is contained in:
parent
d18596c322
commit
a0ad586bea
@ -20,6 +20,10 @@ class votes {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function get_user_choice_per_poll($poll_ID, $user_ID){
|
||||
return \DBD\UVOTE_DATA_USER_CHOICE_PER_POLL::Q1(array($poll_ID, $user_ID));
|
||||
}
|
||||
|
||||
public static function getUserPollData($poll_ID){
|
||||
if (!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
return NULL;}
|
||||
@ -80,6 +84,9 @@ class votes {
|
||||
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_user_overall_votes($user_ID, $creationDate){
|
||||
return \DBD\UVOTE_DATA_OVERALL_VOTES::Q1(array($user_ID, $user_ID, $user_ID, $creationDate));}
|
||||
|
||||
public static function get_bar_bt_per_poll($poll_ID){
|
||||
return \DBD\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));}
|
||||
|
||||
|
||||
14
uVote/dbd/qq/UVOTE_DATA_OVERALL_VOTES.php
Normal file
14
uVote/dbd/qq/UVOTE_DATA_OVERALL_VOTES.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class UVOTE_DATA_OVERALL_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 = ?)
|
||||
WHERE time_start > FROM_UNIXTIME(?);'
|
||||
);}}
|
||||
11
uVote/dbd/qq/UVOTE_DATA_USER_CHOICE_PER_POLL.php
Normal file
11
uVote/dbd/qq/UVOTE_DATA_USER_CHOICE_PER_POLL.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class UVOTE_DATA_USER_CHOICE_PER_POLL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
//pg
|
||||
'',
|
||||
//mys
|
||||
'SELECT * FROM `uvote_data` WHERE poll_ID = ? AND `user_ID` = ?;'
|
||||
);}}
|
||||
@ -1,6 +1,5 @@
|
||||
<h4>${title}</h4>
|
||||
<div class="progress" style="height: 30px;">
|
||||
<div class="bar bar-success" style="width: ${vote_yes_perc}%;">${vote_yes_perc}%</div>
|
||||
<div class="bar bar-danger" style="width: ${vote_no_perc}%;">${vote_no_perc}%</div>
|
||||
<div class="bar bar-info" style="width: ${vote_ent_perc}%;">${vote_ent_perc}%</div>
|
||||
</div>
|
||||
|
||||
<div class="progress" style="height: 20px; width: 350px; border-style: solid; border-width: 1px;">
|
||||
<div class="bar bar-success" style="width: ${vote_yes_perc}%;">${vote_yes_perc}%</div>
|
||||
<div class="bar bar-danger" style="width: ${vote_no_perc}%;">${vote_no_perc}%</div>
|
||||
<div class="bar bar-info" style="width: ${vote_ent_perc}%;">${vote_ent_perc}%</div>
|
||||
|
||||
@ -1,22 +1,26 @@
|
||||
<div style="width: 50%; float: left;">
|
||||
<div>
|
||||
${bars_user}
|
||||
</div>
|
||||
<div>
|
||||
${voice_weight}
|
||||
</div>
|
||||
<div>
|
||||
|
||||
${bars_bt}
|
||||
</div>
|
||||
<div>
|
||||
${bars_party}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<img src="${frontend_logos}logo2.png" style="" width="35%"/>
|
||||
|
||||
<div style="float: left;">
|
||||
<br>
|
||||
</br>
|
||||
<table>
|
||||
<tr>
|
||||
Ergebnis uVote
|
||||
${bars_user}
|
||||
</tr>
|
||||
<tr>
|
||||
Ergebnis Bundestag
|
||||
${bars_bt}
|
||||
</tr>
|
||||
<br>
|
||||
<tr>
|
||||
${voice_weight}
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
${bars_party}
|
||||
</tr>
|
||||
</table>
|
||||
<div style="float: left;">
|
||||
<img src="${frontend_logos}icon_urn_${vote_class}.png"/>
|
||||
${vote_buttons}
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
|
||||
@ -4,6 +4,26 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
|
||||
public function __construct($poll_ID) {
|
||||
$this->poll_ID=$poll_ID;}
|
||||
|
||||
public function vote_choice(){
|
||||
$result = '';
|
||||
$vars = votes::get_user_choice_per_poll($this->poll_ID, \SYSTEM\SECURITY\Security::getUser()->id);
|
||||
$vars['vote_class'] = $this->tablerow_class($vars);
|
||||
return $vars['vote_class'];
|
||||
}
|
||||
|
||||
private static function tablerow_class($choice){
|
||||
switch($choice){
|
||||
case 1:
|
||||
return 'pro';
|
||||
case 2:
|
||||
return 'con';
|
||||
case 3:
|
||||
return 'ent';
|
||||
default:
|
||||
return 'open';
|
||||
}
|
||||
}
|
||||
|
||||
private function bars_user(){
|
||||
$bars = votes::get_barsperusers($this->poll_ID,false);
|
||||
@ -60,7 +80,7 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
private function vote_buttons($poll_expired,$user_poll){
|
||||
if($poll_expired){
|
||||
if(!$user_poll){
|
||||
return '<h4>Stimme hier ab</h4>
|
||||
return '<h5>Stimme hier ab</h5>
|
||||
<a class="btn btn-success btn-default btnvote_yes"
|
||||
style="width: 70px"
|
||||
poll_ID="${poll_ID}"><font
|
||||
@ -83,7 +103,8 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
default: array('','','');
|
||||
}
|
||||
|
||||
return '<h4>Ändere deine bereits abgegebene Stimme hier ab</h4>
|
||||
return '
|
||||
<h5>Ändere deine Stimme hier ab</h5>
|
||||
<a class="btn '.$classes[0].' btn-default btnvote_yes"
|
||||
style="width: 70px"
|
||||
poll_ID="${poll_ID}"><font
|
||||
@ -97,7 +118,8 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
style="width: 70px"
|
||||
href="#"
|
||||
poll_ID="${poll_ID}"><font
|
||||
size="3">Enthaltung</font></a>';
|
||||
size="3">Enthaltung</font></a>
|
||||
';
|
||||
} else {
|
||||
return 'ye soon to come infos';
|
||||
}
|
||||
@ -113,8 +135,9 @@ class default_bulletin extends SYSTEM\PAGE\Page {
|
||||
$user_vote = votes::getUserPollData($this->poll_ID);
|
||||
|
||||
$vars = array();
|
||||
$vars['voice_weight'] = $vars['bars_user'] = $vars['bars_bt'] = '';
|
||||
$vars['voice_weight'] = $vars['bars_user'] = $vars['bars_bt'] = '';
|
||||
$vars['bars_party'] = 'Erst nach der Abgabe deiner Stimme werden dir die daten angezeigt';
|
||||
$vars['vote_class'] = $this->vote_choice();
|
||||
$vars['js'] = $this->js();
|
||||
$vars['css'] = $this->css();
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
<div style="">
|
||||
<h4>Ergebnis Bundestag</h4>
|
||||
<div class="progress" style="height: 20px;">
|
||||
<div class="bar bar-success" style="width: ${bt_pro}%;">${bt_pro}%</div>
|
||||
<div class="bar bar-danger" style="width: ${bt_con}%;">${bt_con}%</div>
|
||||
<div class="bar bar-info" style="width: ${bt_ent}%;"><p>${bt_ent}%</p></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress" style="height: 20px; width: 350px; border-style: solid; border-width: 1px;">
|
||||
<div class="bar bar-success" style="width: ${bt_pro}%;">${bt_pro}%</div>
|
||||
<div class="bar bar-danger" style="width: ${bt_con}%;">${bt_con}%</div>
|
||||
<div class="bar bar-info" style="width: ${bt_ent}%;"><p>${bt_ent}%</p></div>
|
||||
|
||||
|
||||
@ -141,6 +141,7 @@ function vote_click (poll_ID, vote) {
|
||||
var items = [];
|
||||
if(data.status == true){
|
||||
alert("success");
|
||||
$('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
|
||||
} else {
|
||||
alert(data.result.message);
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
</head>
|
||||
|
||||
<body style="background: ${frontend_logos}background.png, padding-top: 50px;">
|
||||
<body style="background: ${frontend_logos}background.png, padding-top: 51px;">
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner" style="padding-left: 50px; padding-right: 50px;">
|
||||
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
<div style="float: left">
|
||||
<table style="border-collapse: separate;
|
||||
border-spacing: 10px 5px; width: 350px;">
|
||||
border-spacing: 10px 5px; width: 350px;">
|
||||
${welcome_text}
|
||||
<tr>
|
||||
<h5>Übereinstimmung von uVote & Politik</h5>
|
||||
${uvote_to_bt}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div style="width: 50%; float: right; margin-bottom: 30px;">
|
||||
<div style="width: 50%; margin-bottom: 30px; float: left;">
|
||||
<h5>Entscheidungsverhalten der uVote Community</h5>
|
||||
<span style="float: left;">
|
||||
<span style="">
|
||||
${votes_all}
|
||||
</span>
|
||||
<span style=""> Wie oft die uVote Community
|
||||
@ -21,10 +22,11 @@
|
||||
<span style="">
|
||||
${votes_all_bt}
|
||||
</span>
|
||||
<span style="float: left;"> Wie oft der Bundestag
|
||||
<span style=""> Wie oft der Bundestag
|
||||
<br> Dafür, Dagegen oder
|
||||
<br> Enthaltung gestimmt hat.</span>
|
||||
</div>
|
||||
|
||||
<div style="clear: both; height: 50px;">
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@ -4,11 +4,12 @@ class user_main_uVote extends SYSTEM\PAGE\Page {
|
||||
private function uvote_to_parties (){
|
||||
$votes = votes::get_uvote_to_bt_overall();
|
||||
$result = '';
|
||||
print_r($votes, TRUE);
|
||||
|
||||
foreach($votes as $vote){
|
||||
$vote['match_percentage'] = round($vote['class_MATCH']/($vote['class_MATCH']+$vote['class_MISSMATCH'])*100,2);
|
||||
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uvoteparties.tpl'), $vote);
|
||||
}
|
||||
print_r($votes, TRUE);
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -80,6 +81,7 @@ class user_main_uVote extends SYSTEM\PAGE\Page {
|
||||
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(100));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_uVote/uVote.tpl'),$vars);
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
<h5>Aktueller Status</h5>
|
||||
<div style="width: 100%;">
|
||||
<div style="width: 300px; border-style: solid; border-width: 1px; padding: 5px;">
|
||||
<font size="2">Teilnahme an aktuellen Abstimmungen</font>
|
||||
<div class="progress" style="height: 20px;">
|
||||
<div class="bar" style="width: ${vote_perc}%;">${vote_perc}%</div>
|
||||
<div class="bar bar-info" style="width: 100%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="">
|
||||
<font size="1">Teilgenommen: ${voted},
|
||||
nicht Teilgenommen: ${not_voted}</font>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
11
uVote/page/user_main_urVote/overall_all_polls.tpl
Normal file
11
uVote/page/user_main_urVote/overall_all_polls.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
<div style="width: 300px; border-style: solid; border-width: 1px; padding: 5px;">
|
||||
<font size="2">Abstimmungsquote seit Accounterstellung</font>
|
||||
<div class="progress" style="height: 20px;">
|
||||
<div class="bar" style="width: ${vote_perc}%;">${vote_perc}%</div>
|
||||
<div class="bar bar-info" style=""></div>
|
||||
</div>
|
||||
<div style="">
|
||||
<font size="1">Teilgenommen: ${voted},
|
||||
nicht Teilgenommen: ${not_voted}</font>
|
||||
</div>
|
||||
</div>
|
||||
@ -16,6 +16,9 @@
|
||||
<div style="margin-left: 40px; float: left;">
|
||||
${user_temp_votes}
|
||||
</div>
|
||||
<div style="margin-left: 40px; float: left;">
|
||||
${user_overall_votes}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -3,10 +3,22 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
|
||||
|
||||
|
||||
|
||||
private function user_overall_votes (){
|
||||
$vars = votes::get_user_overall_votes(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->creationDate);
|
||||
$v = $vars['voted'] > 1 ? $vars['voted'] : 1;
|
||||
$nv = $vars['not_voted'];
|
||||
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/overall_all_polls.tpl'),
|
||||
array( 'vote_perc'=> round($v/($nv+$v)*100, 2),
|
||||
'no_vote_perc'=> round($nv/($nv+$v)*100, 2),
|
||||
'voted'=> $v,
|
||||
'not_voted'=> $nv));
|
||||
}
|
||||
|
||||
private function user_temp_votes (){
|
||||
$vars = votes::get_user_temp_votes(\SYSTEM\SECURITY\Security::getUser()->id);
|
||||
$v = $vars['voted'];
|
||||
$nv = $vars['not_voted'];
|
||||
print_r($vars, true);
|
||||
return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/all_polls.tpl'),
|
||||
array( 'vote_perc'=> round($v/($nv+$v)*100, 2),
|
||||
'no_vote_perc'=> round($nv/($nv+$v)*100, 2),
|
||||
@ -14,45 +26,45 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
|
||||
'not_voted'=> $nv));
|
||||
}
|
||||
|
||||
private function user_to_bt(){
|
||||
//$vars = votes::get_user_per_party_overall($user_ID);
|
||||
$result = '';
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
$res = $con->prepare( 'bt_to_user',
|
||||
'SELECT sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
|
||||
sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
|
||||
FROM uvote_data LEFT JOIN uvote_votes
|
||||
ON uvote_data.poll_ID = uvote_votes.ID
|
||||
WHERE user_ID = ?;',
|
||||
array(\SYSTEM\SECURITY\Security::getUser()->id));
|
||||
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);
|
||||
}
|
||||
return $result;
|
||||
$row['votes_cast'] = round(($row['class_MATCH']+$row['class_MISSMATCH']),2);
|
||||
private function user_to_bt(){
|
||||
//$vars = votes::get_user_per_party_overall($user_ID);
|
||||
$result = '';
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
$res = $con->prepare( 'bt_to_user',
|
||||
'SELECT sum(case when uvote_data.choice = uvote_votes.bt_choice then 1 else 0 end) class_MATCH,
|
||||
sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH
|
||||
FROM uvote_data LEFT JOIN uvote_votes
|
||||
ON uvote_data.poll_ID = uvote_votes.ID
|
||||
WHERE user_ID = ?;',
|
||||
array(\SYSTEM\SECURITY\Security::getUser()->id));
|
||||
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);
|
||||
}
|
||||
|
||||
return $result;
|
||||
$row['votes_cast'] = round(($row['class_MATCH']+$row['class_MISSMATCH']),2);
|
||||
}
|
||||
|
||||
|
||||
private function user_per_party_overall(){
|
||||
//$vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id));
|
||||
$result = '';
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
$res = $con->prepare( 'test',
|
||||
'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
|
||||
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
|
||||
FROM uvote_data INNER JOIN uvote_votes_per_party
|
||||
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
|
||||
WHERE user_ID = ? GROUP BY party;',
|
||||
array(\SYSTEM\SECURITY\Security::getUser()->id));
|
||||
while($row = $res->next()){
|
||||
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
|
||||
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urvoteparties.tpl'), $row);;
|
||||
}
|
||||
return $result;
|
||||
|
||||
private function user_per_party_overall(){
|
||||
//$vars = votes::get_user_per_party_overall(array(\SYSTEM\SECURITY\Security::getUser()->id));
|
||||
$result = '';
|
||||
$con = new \SYSTEM\DB\Connection();
|
||||
$res = $con->prepare( 'test',
|
||||
'SELECT party, sum(case when uvote_data.choice = uvote_votes_per_party.choice then 1 else 0 end) class_MATCH,
|
||||
sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH
|
||||
FROM uvote_data INNER JOIN uvote_votes_per_party
|
||||
ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID
|
||||
WHERE user_ID = ? GROUP BY party;',
|
||||
array(\SYSTEM\SECURITY\Security::getUser()->id));
|
||||
while($row = $res->next()){
|
||||
$row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2);
|
||||
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_urVote/urvoteparties.tpl'), $row);;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function html(){
|
||||
$vars = array();
|
||||
@ -61,6 +73,7 @@ class user_main_urVote extends SYSTEM\PAGE\Page {
|
||||
$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['user_overall_votes'] = $this->user_overall_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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user