diff --git a/uvote/api/api_uvote.php b/uvote/api/api_uvote.php index c2768ad..0ba84f0 100644 --- a/uvote/api/api_uvote.php +++ b/uvote/api/api_uvote.php @@ -23,22 +23,24 @@ class api_uvote extends \SYSTEM\API\api_system { return votes::vote_accord_with_party($party);} //graphs - public static function call_graph_bt_to_uvote_overall_by_time($timespan = 84600){ + public static function call_graph_bt_to_uvote_overall_by_time($timespan = 592200){ return graphs::graph_bt_to_uvote_overall_by_time($timespan);} - public static function call_graph_bt_to_user_overall_by_time($timespan = 84600){ + public static function call_graph_bt_to_user_overall_by_time($timespan = 592200){ return graphs::graph_bt_to_user_overall_by_time($timespan);} - public static function call_graph_party_to_user_overall_by_time_party_cdu($party = 'cdu', $timespan = 84600){ + public static function call_graph_party_to_user_overall_by_time_party_cdu($party = 'cdu', $timespan = 592200){ return graphs::graph_party_to_user_overall_by_time($party, $timespan);} - public static function call_graph_party_to_user_overall_by_time_party_csu($party = 'csu', $timespan = 84600){ + public static function call_graph_party_to_user_overall_by_time_party_csu($party = 'csu', $timespan = 592200){ return graphs::graph_party_to_user_overall_by_time($party, $timespan);} - public static function call_graph_party_to_user_overall_by_time_party_spd($party = 'spd', $timespan = 84600){ + public static function call_graph_party_to_user_overall_by_time_party_spd($party = 'spd', $timespan = 592200){ return graphs::graph_party_to_user_overall_by_time($party, $timespan);} - public static function call_graph_party_to_user_overall_by_time_party_gruene($party = 'gruene', $timespan = 84600){ + public static function call_graph_party_to_user_overall_by_time_party_gruene($party = 'gruene', $timespan = 592200){ return graphs::graph_party_to_user_overall_by_time($party, $timespan);} - public static function call_graph_party_to_user_overall_by_time_party_linke($party = 'linke', $timespan = 84600){ + public static function call_graph_party_to_user_overall_by_time_party_linke($party = 'linke', $timespan = 592200){ return graphs::graph_party_to_user_overall_by_time($party, $timespan);} - + + public static function call_donut_party_to_user_overall(){ + return graphs::donut_party_to_user_overall();} //comments public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) { return comments::write_comment($poll_ID, $c_choice, $c_txt, $c_src);} diff --git a/uvote/api/votes/bars.php b/uvote/api/votes/bars.php new file mode 100644 index 0000000..3755b42 --- /dev/null +++ b/uvote/api/votes/bars.php @@ -0,0 +1,133 @@ +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)); + $i = 0; + while($row = $res->next()){ + + $res2 = votes::vote_accord_with_party($row['party']); + $row['according_laws'] = self::build_according_law_html($res2, $row['party']); + $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_analysis/tpl/urvoteparties.tpl'), $row);; + } + return $result; + } + public static function build_according_law_html($part, $party){ + $part = json_decode($part, true); + $result = "
Bei folgenden Gesetzen hast du genauso abgestimmt wie die ".$party.":

"; + foreach ($part['result'] as $p){ + $result .= $p['title']."
"; + } + $result .= "

"; + new INFO($result); + return $result; + } + public static function user_per_party_by_choicetype($choice){ + $bar = switchers::bar_class($choice); + $result = ''; + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'user_to_party_by_choice', + '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 = ? AND uvote_data.choice = ? GROUP BY party;', + array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); + $i = 0; + while($row = $res->next()){ + $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); + $row['bar'] = $bar; + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvoteparties_by_choice.tpl'), $row);; + } + if(empty($result)){ + return 'Keine relevanten Daten verfügbar'; + } + + return $result; + } + public static function user_per_bt_by_choicetype($choice){ + switch($choice){ + case 1: + $bar = 'progress-bar-success'; + $icon_type = 'pro'; + break; + case 2: + $bar = 'progress-bar-danger'; + $icon_type = 'con'; + break; + case 3: + $bar = 'progress-bar-info'; + $icon_type = 'ent'; + break; + case 0: + $bar = 'progress-bar'; + } + $result = ''; + $con = new \SYSTEM\DB\Connection(); + $res = $con->prepare( 'user_to_party_by_choice_bt', + 'SELECT user_ID, 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 INNER JOIN uvote_votes + ON uvote_data.poll_ID = uvote_votes.ID + WHERE user_ID = ? AND uvote_data.choice = ? GROUP by user_ID;', + array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); + $i = 0; + + while($row = $res->next()){ + if(empty($row['class_MATCH'])){ + return 'Keine relevanten Daten verfügbar
'; + } + $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); + $row['bar'] = $bar; + $row['icon_type'] = $icon_type; + $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvotebt_by_choice.tpl'), $row);; + } + if(empty($result)){ + return 'Keine relevanten Daten verfügbar'; + } + + return $result; + } + public static 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_analysis/tpl/bt_to_user_overall.tpl'), $row); + } + return $result; + } +} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + diff --git a/uvote/api/votes/graphs.php b/uvote/api/votes/graphs.php index c819397..12f2815 100644 --- a/uvote/api/votes/graphs.php +++ b/uvote/api/votes/graphs.php @@ -27,9 +27,20 @@ class graphs { public static function graph_party_to_user_overall_by_time ($party, $timespan, $returnasjson = true){ $result = array(); $res = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME::QQ(array($timespan, \SYSTEM\SECURITY\Security::getUser()->id, $party, \SYSTEM\SECURITY\Security::getUser()->id)); + $total = \SQL\UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH::Q1(array($party, \SYSTEM\SECURITY\Security::getUser()->id)); while ($row = $res->next()){ $result[] = array( 0 => $row['day'], - 'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1)); + 'class_match' => $row['class_match'] / $total['total']*100); + } + return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result; + } + + public static function donut_party_to_user_overall ($returnasjson = true){ + $result = array(); + $res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(13)); + while ($row = $res->next()){ + $result[] = array( 0 => $row['party'], + 'class_match' => $row['class_MATCH']); } return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result; } diff --git a/uvote/api/votes/lists.php b/uvote/api/votes/lists.php new file mode 100644 index 0000000..c31cc72 --- /dev/null +++ b/uvote/api/votes/lists.php @@ -0,0 +1,62 @@ + 0 ? 'Abstimmen' : 'Ansehen'; + $vote['uv'] = $vote['bt'] = ''; + $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5'; + + $user_vote = votes::getUserPollData($vote['ID']); + $vote['vote_class'] = switchers::tablerow_class($user_vote); + if($user_vote){ + //user vote + $vote['vote_class'] = switchers::tablerow_class($user_vote); + + //bt vote + $party_votes = votes::get_barsperparty($vote['ID']); + $vote['bt_vote_class'] = switchers::tablerow_class($vote['bt_choice']); + foreach($party_votes as $pv){ + $vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote_bt.tpl'), + array( 'party' => $pv['party'], + 'choice' => switchers::get_party_per_poll($pv['choice']), + 'choice_class' => switchers::badge_class($pv['choice']))); + } + + //uvote vote + $uvote = votes::get_users_choice_per_poll($vote['ID']); + $vote['uv_vote_class'] = count($uvote) > 0 ? switchers::tablerow_class($uvote[0]['choice']) : ''; + foreach($uvote as $v){ + $vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote_uv.tpl'), + array( 'badge' => switchers::badge_class($v['choice']), + 'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0)); + } + } + + //new panels: + $vote['panel_class'] = switchers::panel_class($user_vote); + + if($time_remain > 0){ + $result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); + } else { + $result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); + } + } + return $result[0].$result[1]; + } +} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + diff --git a/uvote/api/votes/switchers.php b/uvote/api/votes/switchers.php new file mode 100644 index 0000000..7036753 --- /dev/null +++ b/uvote/api/votes/switchers.php @@ -0,0 +1,71 @@ +next(); return $result['choice']; } - public static function get_user_match_per_choice($choice){ - switch($choice){ - case 1: - $bar = 'progress-bar-success'; - break; - case 2: - $bar = 'progress-bar-danger'; - break; - case 3: - $bar = 'progress-bar-info'; - break; - case 0: - $bar = 'progress-bar'; - } - $result = ''; - $con = new \SYSTEM\DB\Connection(); - $res = $con->prepare( 'user_to_party_by_choice', - '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 = ? AND uvote_data.choice = ? GROUP BY party;', - array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); - $i = 0; - while($row = $res->next()){ - $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); - $row['bar'] = $bar; - $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvoteparties_by_choice.tpl'), $row);; - } - if(empty($result)){ - return 'Keine relevanten Daten verfügbar'; - } - - return $result; - } - public static function get_user_match_per_choice_bt($choice){ - switch($choice){ - case 1: - $bar = 'progress-bar-success'; - $icon_type = 'pro'; - break; - case 2: - $bar = 'progress-bar-danger'; - $icon_type = 'con'; - break; - case 3: - $bar = 'progress-bar-info'; - $icon_type = 'ent'; - break; - case 0: - $bar = 'progress-bar'; - } - $result = ''; - $con = new \SYSTEM\DB\Connection(); - $res = $con->prepare( 'user_to_party_by_choice_bt', - 'SELECT user_ID, 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 INNER JOIN uvote_votes - ON uvote_data.poll_ID = uvote_votes.ID - WHERE user_ID = ? AND uvote_data.choice = ? GROUP by user_ID;', - array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); - $i = 0; - - while($row = $res->next()){ - if(empty($row['class_MATCH'])){ - return 'Keine relevanten Daten verfügbar
'; - } - $row['match_percentage'] = round($row['class_MATCH']/($row['class_MATCH']+$row['class_MISSMATCH'])*100,2); - $row['bar'] = $bar; - $row['icon_type'] = $icon_type; - $result .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/urvotebt_by_choice.tpl'), $row);; - } - if(empty($result)){ - return 'Keine relevanten Daten verfügbar'; - } - - return $result; - } + + public static function get_barsperusers($poll_ID,$return_as_json = true){ $con = new \SYSTEM\DB\Connection(); //count @@ -153,11 +75,26 @@ class votes { return $res; } - public static function get_user_temp_votes($user_ID){ - return \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array($user_ID, $user_ID));} + public static function get_user_temp_votes(){ + $vars = \SQL\UVOTE_DATA_TEMP_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \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_analysis/tpl/all_polls.tpl'), + array( 'vote_perc'=> round($v/(($nv+$v)*100+1), 2), + 'no_vote_perc'=> round($nv/(($nv+$v)*100+1), 2), + 'voted'=> $v, + 'not_voted'=> $nv));} - public static function get_user_overall_votes($user_ID, $creationDate){ - return \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array($user_ID, $user_ID, $user_ID, $creationDate));} + public static function get_user_overall_votes(){ + $vars = \SQL\UVOTE_DATA_OVERALL_VOTES::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, \SYSTEM\SECURITY\Security::getUser()->id, \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_analysis/tpl/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));} public static function get_bar_bt_per_poll($poll_ID){ return \SQL\UVOTE_DATA_BT_PER_POLL::Q1(array($poll_ID));} diff --git a/uvote/page/default_page/css/default_page.css b/uvote/page/default_page/css/default_page.css index 84f72b3..e77f6da 100644 --- a/uvote/page/default_page/css/default_page.css +++ b/uvote/page/default_page/css/default_page.css @@ -7,6 +7,10 @@ body { border: 2px solid #ccc; }*/ +.popover{ + max-width: 600px; + width: 600px; +} .pro{ background: #5eb95e; } diff --git a/uvote/page/default_page/css/vote.css b/uvote/page/default_page/css/vote.css index 2a35caf..e0cdecf 100644 --- a/uvote/page/default_page/css/vote.css +++ b/uvote/page/default_page/css/vote.css @@ -2,7 +2,6 @@ padding: 5px; margin: 5px; width: 100%; - border: solid lightgray 3px; } #vote_sub1 { diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js index 19f566b..99dc6d1 100644 --- a/uvote/page/default_page/js/loadtexts.js +++ b/uvote/page/default_page/js/loadtexts.js @@ -291,7 +291,6 @@ function load_visualisation_user_to_party_overall(id, party, timespan){ json = json.result; $('img#loader').hide(); var data = new google.visualization.DataTable(); - console.log(json); first = true; $.each(json[0], function(key, value){ if(first){ @@ -306,8 +305,74 @@ function load_visualisation_user_to_party_overall(id, party, timespan){ data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); - var options = {title: 'Übereinstimmung mit ' + party, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "800", height: "250"}; + var options = { title: 'Übereinstimmung mit ' + party, + aggregationTarget: 'category', + selectionMode: 'multiple', + legend: 'none', + chartArea:{}, +// vAxis:{logScale: false}, + vAxis: {viewWindow: {min: 0, max: 100}}, + lineWidth: 7, + interpolateNulls: false, + width: "800", + height: "250"}; new google.visualization.LineChart(document.getElementById(id)).draw(data, options); }); } +function load_visualisation_user_to_parties_overall(id, timespan){ + $('img#loader').show(); + $.getJSON('./api.php?call=donut_party_to_user_overall',function(json){ + if(!json || json.status != true || !json.result){ + $('img#loader').hide(); + return; + } + json = json.result; + $('img#loader').hide(); + var data = new google.visualization.DataTable(); + console.log(json); + first = true; + $.each(json[0], function(key, value){ + if(first){ + data.addColumn('string',key); + first = false; + } else { + data.addColumn('number',key); + } + }); + $.each(json, function(key, value){ + first = true; + data.addRow($.map(value, function(v) { if(first){first=false;return v;}else{return [parseFloat(v)];}}));}); + var options = { title: 'Übereinstimmung mit den Fraktionen relativ zueinander', + titleTextStyle: {fontSize: 14, bold: 0, italic: 0}, + pieSliceText: 'label', + legend: 'none', + colors: ['#000736', '#0022FF', '#33FF00', '#D2067A', '#F20101'], + pieHole: '0.4', + chartArea:{}, + width: "500", + height: "400"}; + new google.visualization.PieChart(document.getElementById(id)).draw(data, options); + }); +} +function load_visualisation_user(id, timespan){ +google.load("visualization", "1", {packages:["corechart"]}); + google.setOnLoadCallback(drawChart); + function drawChart() { + var data = google.visualization.arrayToDataTable([ + ['Task', 'Hours per Day'], + ['Work', 11], + ['Eat', 2], + ['Commute', 2], + ['Watch TV', 2], + ['Sleep', 7] + ]); + var options = { + title: 'My Daily Activities', + pieHole: 0.4, + }; + + var chart = new google.visualization.PieChart(document.getElementById('donutchart')); + chart.draw(data, options); + } + } \ No newline at end of file diff --git a/uvote/page/default_page/tpl/loggedinformtop.tpl b/uvote/page/default_page/tpl/loggedinformtop.tpl index 130cffc..d7fe0ba 100644 --- a/uvote/page/default_page/tpl/loggedinformtop.tpl +++ b/uvote/page/default_page/tpl/loggedinformtop.tpl @@ -1,3 +1,3 @@ - \ No newline at end of file diff --git a/uvote/page/default_page/tpl/loginform.tpl b/uvote/page/default_page/tpl/loginform.tpl index eb944b8..5bed726 100644 --- a/uvote/page/default_page/tpl/loginform.tpl +++ b/uvote/page/default_page/tpl/loginform.tpl @@ -1,34 +1,4 @@ - \ No newline at end of file diff --git a/uvote/page/default_page/tpl/menu.tpl b/uvote/page/default_page/tpl/menu.tpl index 0ee882c..95c8b0a 100644 --- a/uvote/page/default_page/tpl/menu.tpl +++ b/uvote/page/default_page/tpl/menu.tpl @@ -1,15 +1,8 @@ -
-
diff --git a/uvote/page/default_page/tpl/menu_loggedout.tpl b/uvote/page/default_page/tpl/menu_loggedout.tpl index f9acf00..559f363 100644 --- a/uvote/page/default_page/tpl/menu_loggedout.tpl +++ b/uvote/page/default_page/tpl/menu_loggedout.tpl @@ -1,8 +1,3 @@ - \ No newline at end of file +
+ +
diff --git a/uvote/page/default_page/tpl/page.tpl b/uvote/page/default_page/tpl/page.tpl index 4ca474f..48445ef 100644 --- a/uvote/page/default_page/tpl/page.tpl +++ b/uvote/page/default_page/tpl/page.tpl @@ -35,7 +35,23 @@
-
${menu}
+
+
+ +
+
+ +
+
+

+
+
+ ${menu} +
+
+ ${loginform} +
+
diff --git a/uvote/page/default_register/tpl/register.tpl b/uvote/page/default_register/tpl/register.tpl index 65de8f0..2a42de5 100644 --- a/uvote/page/default_register/tpl/register.tpl +++ b/uvote/page/default_register/tpl/register.tpl @@ -6,16 +6,10 @@
-
- -
+
${welcome_text}
- - - -
@@ -96,12 +90,8 @@
-
-
-
- -
+
- - \ No newline at end of file + + diff --git a/uvote/page/user_main_analysis/tpl/bt_to_user_overall.tpl b/uvote/page/user_main_analysis/tpl/bt_to_user_overall.tpl index 5bcda82..2d1256a 100644 --- a/uvote/page/user_main_analysis/tpl/bt_to_user_overall.tpl +++ b/uvote/page/user_main_analysis/tpl/bt_to_user_overall.tpl @@ -1,5 +1,5 @@ -Bundestag gesamt -
+ +
@@ -8,7 +8,7 @@ Bundestag gesamt
${match_percentage}%
- +
${class_MATCH} matches diff --git a/uvote/page/user_main_analysis/tpl/urvoteparties.tpl b/uvote/page/user_main_analysis/tpl/urvoteparties.tpl index 285cc49..dc5cec3 100644 --- a/uvote/page/user_main_analysis/tpl/urvoteparties.tpl +++ b/uvote/page/user_main_analysis/tpl/urvoteparties.tpl @@ -2,7 +2,7 @@
-
+
@@ -13,10 +13,14 @@ ${match_percentage}% ---> +--> +
+ +
+ \ No newline at end of file + +}); + diff --git a/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl b/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl index 13aed63..fcd08ae 100644 --- a/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl +++ b/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl @@ -1,9 +1,9 @@ -
+
-
+

- ${urVote_title} + ${urVote_title}

@@ -13,14 +13,14 @@
-
-
-
+
+
+

- Deine Daten +    Deine Daten

-
+
${basic_stats} @@ -36,65 +36,87 @@
-
-
+
+

- Bilanz: Fraktionen +    Bilanz: Fraktionen

+
+
Gesamtübereinstimmung mit den Fraktionen im Bundestag
auf %Angabe clicken für Details +
+
${choices_user_ID}
- ${choices_bt_to_user} +
+ +
-
+
-
-
+
+

- Bilanz: Fraktionen nach Stimmverhalten +    Bilanz: Fraktionen nach Stimmverhalten

-
+
Übereinstimmung der pro Stimmen
${choices_user_ID_per_party_pro}
-
+
Übereinstimmung der contra Stimmen
${choices_user_ID_per_party_con}
-
+
Übereinstimmung der Enthaltungen
${choices_user_ID_per_party_ent}
-
- -
Übereinstimmung mit dem Bundestag
- ${choices_user_ID_per_bt_pro} - ${choices_user_ID_per_bt_con} - ${choices_user_ID_per_bt_ent} -
-
-
-
-
+
+
+

- Entwicklung: Fraktionen +    Bilanz: Bundestag +

+
+
+
+ Bundestag gesamt + ${choices_bt_to_user} +
+
+ Übereinstimmung mit dem Bundestag + + ${choices_user_ID_per_bt_pro} + ${choices_user_ID_per_bt_con} + ${choices_user_ID_per_bt_ent} +
+
+
+
+ + +
+
+
+

+    Entwicklung: Fraktionen

@@ -126,21 +148,21 @@
-
-
+
+

- community Statistik +    community Statistik

Entscheidungsverhalten der uVote Community
- - ${votes_all} - - Wie oft die uVote Community -
insgesamt Dafür, Dagegen oder -
Enthaltung gestimmt hat.
+ + ${votes_all} + + Wie oft die uVote Community +
insgesamt Dafür, Dagegen oder +
Enthaltung gestimmt hat.
Entscheidungsverhalten des Bundestags
@@ -164,7 +186,7 @@ - + diff --git a/uvote/page/user_main_analysis/user_main_analysis.php b/uvote/page/user_main_analysis/user_main_analysis.php index c87a69e..1a9d437 100644 --- a/uvote/page/user_main_analysis/user_main_analysis.php +++ b/uvote/page/user_main_analysis/user_main_analysis.php @@ -1,88 +1,6 @@ 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_analysis/tpl/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)); - } - public static function user_temp_votes (){ - $vars = votes::get_user_temp_votes(\SYSTEM\SECURITY\Security::getUser()->id, \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_analysis/tpl/all_polls.tpl'), - array( 'vote_perc'=> round($v/(($nv+$v)*100+1), 2), - 'no_vote_perc'=> round($nv/(($nv+$v)*100+1), 2), - 'voted'=> $v, - '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_analysis/tpl/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)); - $i = 0; - while($row = $res->next()){ - - $res2 = votes::vote_accord_with_party($row['party']); - $row['according_laws'] = $this->build_according_law_html($res2, $row['party']); - $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_analysis/tpl/urvoteparties.tpl'), $row);; - } - return $result; -} -private function user_per_party_by_choicetype($choice){ - return votes::get_user_match_per_choice($choice); -} -private function user_per_bt_by_choicetype($choice){ - return votes::get_user_match_per_choice_bt($choice); -} - public function build_according_law_html($part, $party){ - $part = json_decode($part, true); - $result = "
Bei folgenden Gesetzen hast du genauso abgestimmt wie die ".$party."':

"; - foreach ($part['result'] as $p){ - $result .= $p['title']."
"; - } - $result .= "
"; - new INFO($result); - return $result; - } private function votes_all(){ $votes = votes::get_all_votes(); $result = ''; @@ -131,33 +49,35 @@ private function user_per_bt_by_choicetype($choice){ } return $result; } - public static function get_basic_stats(){ - $vars = votes::get_user_choice_overall(\SYSTEM\SECURITY\Security::getUser()->id); - $vars['user_total_total'] = $vars['user_total_pro'] + $vars['user_total_con'] + $vars['user_total_ent']; - $vars['user_total_pro_percentage'] = round($vars['user_total_pro']/$vars['user_total_total']*100+1); - $vars['user_total_con_percentage'] = round($vars['user_total_con']/$vars['user_total_total']*100+1); - $vars['user_total_ent_percentage'] = round($vars['user_total_ent']/$vars['user_total_total']*100+1); - return \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/user_total.tpl'),$vars); - } + public static function js(){ return array(\SYSTEM\WEBPATH(new \PPAGE(),'user_main_analysis/js/user_main_analysis.js'));} public function html(){ $vars = array(); -// $vars['poll_compare'] = $this->count_all_polls(); - $vars['basic_stats'] = $this->get_basic_stats(); + + //second panel + $vars['basic_stats'] = bars::get_user_choice_overall(\SYSTEM\SECURITY\Security::getUser()->id); + $vars['user_temp_votes'] = votes::get_user_temp_votes(); + $vars['user_overall_votes'] = votes::get_user_overall_votes(); + + //third panel + $vars['choices_user_ID'] = bars::user_per_party_overall(); + + //fourth panel + $vars['choices_user_ID_per_party_pro'] = bars::user_per_party_by_choicetype('1'); + $vars['choices_user_ID_per_party_con'] = bars::user_per_party_by_choicetype('2'); + $vars['choices_user_ID_per_party_ent'] = bars::user_per_party_by_choicetype('3'); + + //fifth panel + $vars['choices_bt_to_user'] = bars::user_to_bt(); + $vars['choices_user_ID_per_bt_pro'] = bars::user_per_bt_by_choicetype('1'); + $vars['choices_user_ID_per_bt_con'] = bars::user_per_bt_by_choicetype('2'); + $vars['choices_user_ID_per_bt_ent'] = bars::user_per_bt_by_choicetype('3'); + + $vars['votes_all'] = $this->votes_all(); $vars['votes_all_bt'] = $this->votes_all_bt(); - $vars['choices_user_ID'] = $this->user_per_party_overall(); - $vars['choices_user_ID_per_party_pro'] = $this->user_per_party_by_choicetype('1'); - $vars['choices_user_ID_per_party_con'] = $this->user_per_party_by_choicetype('2'); - $vars['choices_user_ID_per_party_ent'] = $this->user_per_party_by_choicetype('3'); - $vars['choices_user_ID_per_bt_pro'] = $this->user_per_bt_by_choicetype('1'); - $vars['choices_user_ID_per_bt_con'] = $this->user_per_bt_by_choicetype('2'); - $vars['choices_user_ID_per_bt_ent'] = $this->user_per_bt_by_choicetype('3'); - $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=files&cat=frontend_logos&id='; - $vars['user_temp_votes'] = $this->user_temp_votes(); - $vars['user_overall_votes'] = $this->user_overall_votes(); + $vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote')); $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register')); return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_analysis/tpl/user_main_analysis.tpl'),$vars); diff --git a/uvote/page/user_main_votelist/tpl/user_main_votelist.tpl b/uvote/page/user_main_votelist/tpl/user_main_votelist.tpl index e640ac7..a801b02 100644 --- a/uvote/page/user_main_votelist/tpl/user_main_votelist.tpl +++ b/uvote/page/user_main_votelist/tpl/user_main_votelist.tpl @@ -1,7 +1,6 @@
-
-
+

Willkommen auf uvote.eu! @@ -12,23 +11,29 @@ ${welcome_text}

- ${user_temp_votes} - ${user_count} Nutzer auf uVote +
+ ${user_temp_votes} +
+
+
+
+ ${user_count} +
+
+
+ Nutzer auf uVote +
+
-
- -
- - - - +
+
-
+

- Hier gehts zur Abstimmung +  Hier gehts zur Abstimmung

diff --git a/uvote/page/user_main_votelist/tpl/vote.tpl b/uvote/page/user_main_votelist/tpl/vote.tpl index b3d01d8..855e636 100644 --- a/uvote/page/user_main_votelist/tpl/vote.tpl +++ b/uvote/page/user_main_votelist/tpl/vote.tpl @@ -12,5 +12,6 @@
+
\ No newline at end of file diff --git a/uvote/page/user_main_votelist/user_main_votelist.php b/uvote/page/user_main_votelist/user_main_votelist.php index 1ae2b04..fe4d79e 100644 --- a/uvote/page/user_main_votelist/user_main_votelist.php +++ b/uvote/page/user_main_votelist/user_main_votelist.php @@ -1,119 +1,17 @@ 0 ? 'Abstimmen' : 'Ansehen'; - $vote['uv'] = $vote['bt'] = ''; - $vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5'; - - $user_vote = votes::getUserPollData($vote['ID']); - $vote['vote_class'] = $this->tablerow_class($user_vote); - if($user_vote){ - //user vote - $vote['vote_class'] = $this->tablerow_class($user_vote); - - //bt vote - $party_votes = votes::get_barsperparty($vote['ID']); - $vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']); - foreach($party_votes as $pv){ - $vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote_bt.tpl'), - array( 'party' => $pv['party'], - 'choice' => $this->get_party_per_poll($pv['choice']), - 'choice_class' => $this->badge_class($pv['choice']))); - } - - //uvote vote - $uvote = votes::get_users_choice_per_poll($vote['ID']); - $vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : ''; - foreach($uvote as $v){ - $vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/tpl/vote_uv.tpl'), - array( 'badge' => self::badge_class($v['choice']), - 'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0)); - } - } - - //new panels: - $vote['panel_class'] = self::panel_class($user_vote); - - if($time_remain > 0){ - $result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); - } else { - $result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/vote.tpl'), $vote); - } - } - return $result[0].$result[1]; - } - public static function panel_class($choice){ - switch($choice){ - case 1: - return 'panel-success'; - case 2: - return 'panel-danger'; - case 3: - return 'panel-info'; - default: - return 'panel-default'; - } - } + + public function html(){ $vars = array(); - $vars['votelist'] = $this->generate_votelist(); + $vars['votelist'] = lists::generate_votelist(); $vars['frontend_logos'] = './api.php?call=files&cat=frontend_logos&id='; $vars['user_count'] = $this->user_count(); - $vars['user_temp_votes'] = user_main_analysis::user_temp_votes(); + $vars['user_temp_votes'] = votes::get_user_temp_votes(); $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote_register')); $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('uvote')); return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_main_votelist/tpl/user_main_votelist.tpl'), $vars); diff --git a/uvote/sql/qq/UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH.php b/uvote/sql/qq/UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH.php new file mode 100644 index 0000000..8cdcdf8 --- /dev/null +++ b/uvote/sql/qq/UVOTE_DATA_GRAPH_PARTY_TO_USER_OVERALL_BY_TIME_OVERMATCH.php @@ -0,0 +1,8 @@ +