new fancy statistics

This commit is contained in:
Nael 2014-03-05 20:28:48 +01:00
parent a0ad586bea
commit 98b57e0af4
9 changed files with 103 additions and 21 deletions

View File

@ -0,0 +1,7 @@
SELECT
SUM(CASE WHEN a.choice = c.bt_choice THEN 1 ELSE 0 END) class_match,
SUM(CASE WHEN a.choice = c.bt_choice THEN 0 ELSE 1 END) class_mismatch
FROM uvote_data as a
LEFT JOIN (Select choice, poll_ID FROM uvote_data GROUP BY choice LIMIT 1) b ON a.poll_ID = b.poll_ID
LEFT JOIN uvote_votes as c ON a.poll_ID = c.ID
WHERE bt_choice

View File

@ -0,0 +1,9 @@
SELECT
DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(a.`timestamp`) - MOD(UNIX_TIMESTAMP(a.`timestamp`),86400)),"%Y/%m/%d %H:%i:%s") as day,
SUM(CASE WHEN a.choice = c.bt_choice THEN 1 ELSE 0 END) class_match,
SUM(CASE WHEN a.choice = c.bt_choice THEN 0 ELSE 1 END) class_mismatch
FROM uvote_data as a
LEFT JOIN (Select choice, poll_ID FROM uvote_data GROUP BY choice LIMIT 1) b ON a.poll_ID = b.poll_ID
LEFT JOIN uvote_votes as c ON a.poll_ID = c.ID
WHERE bt_choice
GROUP BY day

View File

@ -2,27 +2,57 @@
<br>
</br>
<table>
<div style="float:right">
${voice_weight}
</div>
<tr>
Ergebnis uVote
${bars_user}
</tr>
<tr>
Ergebnis Bundestag
${bars_bt}
</tr>
<br>
<tr>
${voice_weight}
</tr>
<tr>
${bars_party}
</tr>
<tr>
${choice_party}
</tr>
</table>
<div style="float: left;">
<div style="float: left;">
<img src="${frontend_logos}icon_urn_${vote_class}.png"/>
${vote_buttons}
</div>
<div style="floa: right">
${vote_buttons}
</div>
</div>
<div style="clear: both"></div>
<!--<div class="btn" id="test">
test
</div>
-->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>One fine body&hellip;</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

View File

@ -6,10 +6,8 @@ class default_bulletin extends SYSTEM\PAGE\Page {
$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'];
$vars = votes::getUserPollData($this->poll_ID);
return $this->tablerow_class($vars);
}
private static function tablerow_class($choice){
@ -24,7 +22,33 @@ class default_bulletin extends SYSTEM\PAGE\Page {
return 'open';
}
}
private function get_party_per_poll($choice){
switch($choice){
case 1:
return 'PRO';
case 2:
return 'CON';
case 3:
return 'ENT';
default:
return 'NONE';
}
}
private function choice_party (){
$result = '';
$party_votes = votes::get_barsperparty($this->poll_ID);
// $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
foreach($party_votes as $pv){
$result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/vote_bt.tpl'),
array( 'party' => $pv['party'],
'choice' => $this->get_party_per_poll($pv['choice']),
'choice_class' => $this->tablerow_class($pv['choice'])));
}
return $result;
}
private function bars_user(){
$bars = votes::get_barsperusers($this->poll_ID,false);
$bars['vote_yes_perc'] = round($bars['yes_perc']*100,0);
@ -135,6 +159,7 @@ class default_bulletin extends SYSTEM\PAGE\Page {
$user_vote = votes::getUserPollData($this->poll_ID);
$vars = array();
$vars['choice_party'] = $this->choice_party();
$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();

View File

@ -0,0 +1 @@
<img src="${frontend_logos}icon_${party}.png" width="30"/><span class="badge ${choice_class}"">${choice}</span><br/>

View File

@ -1,8 +1,10 @@
<div class="row" style="margin: 0;">
<div class="span6" style="width: 50%;">
<iframe src="${iframe_link}" width="730" height="650"></iframe>
</div>
<div class="row" style="margin: 0;">
<div class="span6">
<h3>${title}</h3>
Quelle: <a href="${iframe_link}">${iframe_link} </a>
</div>
<div class="span6" style="width: 50%;">
<iframe src="${iframe_link}" width="730" height="650"></iframe>
</div>
</div>

View File

@ -138,10 +138,12 @@ function get_barsperparty (poll_ID) {
function vote_click (poll_ID, vote) {
$.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) {
var items = [];
var items = [];
if(data.status == true){
alert("success");
$('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
$('#user_main').load('./?action=open_bulletin&poll_ID=' + poll_ID, function(){
open_vote(poll_ID);
});
} else {
alert(data.result.message);
}
@ -187,6 +189,10 @@ function open_vote (poll_ID) {
$('.btnvote_off').click(function () {
vote_click($(this).attr('poll_ID'),3);
});
$('#test').click(function(){
$('#myModal').modal();
});
});
}

View File

@ -1,4 +1,6 @@
<h5>Aktueller Status</h5>
<div style="padding-bot: 20px;">
<font>Aktueller Status</font>
</div>
<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;">

View File

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