Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Results</title>
- <link rel="stylesheet" type="text/css" href="main.css">
- <script src="jquery-2.1.4.js"></script>
- <script src="jquery.color-2.1.2.min.js"></script>
- </head>
- <body>
- <?php
- $con = require('connect.php');
- $id = isset($_GET['id']) ? $_GET['id'] : 999;
- if ($id!=999)
- {
- $row = mysqli_fetch_array(mysqli_query($con, "SELECT sections FROM results WHERE result_id='$id'"));
- $sectxt = $row[0];
- $section=json_decode($sectxt,true);
- $leftright=
- $row = mysqli_fetch_array(mysqli_query($con, "SELECT answers FROM results WHERE result_id='$id'"));
- $anstxt = $row[0];
- $answers=json_decode($anstxt,true);
- }
- else
- {echo ("<h2>Error!</h2>");}
- function echofiscal($inp,$secins){
- //get the result from the array
- $section=json_decode($secins,true);
- $secres=$section[$inp];
- //initialize result
- $res="";
- if (abs($secres)<.9)
- {$res="Centrist";}
- else
- {
- if (abs($secres)>.9)
- {
- $resA="-Leaning";
- }
- if (abs($secres)>2)
- {
- $resA="-Extreme";
- }
- if ($secres<.01)
- {$resB="Left";}
- else
- {$resB="Right";}
- $res=$resB.$resA;
- }
- echo ("$res");
- }
- function echosocial($inp,$secins){
- //get the result from the array
- $section=json_decode($secins,true);
- $secres=$section[$inp];
- //initialize result
- $res="";
- if (abs($secres)<.9)
- {$res="Centrist";}
- else
- {
- if (abs($secres)>.9)
- {
- $resA="-Leaning";
- }
- if (abs($secres)>2)
- {
- $resA="-Extreme";
- }
- if ($secres>.01)
- {$resB="Authoritarian";}
- else
- {$resB="Liberal";}
- $res=$resB.$resA;
- }
- echo ("$res");
- }
- function echopercent($cont,$idA){
- $row = mysqli_fetch_array(mysqli_query($cont, "SELECT X FROM results WHERE result_id='$idA'"));
- $x = $row[0];
- $row = mysqli_fetch_array(mysqli_query($cont, "SELECT Y FROM results WHERE result_id='$idA'"));
- $y = -$row[0];
- if (abs($y)>50)
- {$y=($y/abs($y))*50;}
- echo ("<h2>Scores: Fiscal: $x% Social: $y%</h2>");
- }
- function echopos($cont,$idA){
- $row = mysqli_fetch_array(mysqli_query($cont, "SELECT X FROM results WHERE result_id='$idA'"));
- $x = $row[0]+50;
- $row = mysqli_fetch_array(mysqli_query($cont, "SELECT Y FROM results WHERE result_id='$idA'"));
- $y = $row[0];
- if (abs($y)>50)
- {$y=($y/abs($y))*50;}
- $y+=50;
- echo ("style='left:$x%; top:$y%'");
- }
- function echoquestions($tid,$qtext){
- $answers=json_decode($qtext,true);
- $total=count($answers);
- $echomsg="";
- for ($i=0;$i<($total+1);$i++)
- {
- //check each question/answer. If it belongs here, echo it.
- if ($answers[$i][1]==$tid && $answers[$i][0]!="Basic question" && $answers[$i][0]!="")
- {
- $anstotal=$answers[$i][0];
- $echomsg.='<div class="answerpost"><h2>';
- $echomsg.=$anstotal;
- $echomsg.="</h2>";
- if (strlen($anstotal)<70)
- {$echomsg.="<div class='spacer'></div>";}
- $echomsg.="<h3 class='answercontent'>";
- if ($answers[$i][2]==1)
- {
- $ansmsg="Strongly Agree";
- }
- if ($answers[$i][2]==2)
- {
- $ansmsg="Agree";
- }
- if ($answers[$i][2]==3)
- {
- $ansmsg="Not Sure";
- }
- if ($answers[$i][2]==4)
- {
- $ansmsg="Disagree";
- }
- if ($answers[$i][2]==5)
- {
- $ansmsg="Strongly Disagree";
- }
- $echomsg.=$ansmsg;
- $echomsg.="</h3><h2>This answer was considered ";
- if (abs($answers[$i][3])==0)
- {$echomsg.="average ";}
- if (abs($answers[$i][3])==1)
- {$echomsg.="non-average ";}
- if (abs($answers[$i][3])==2)
- {$echomsg.="extreme ";}
- if (abs($answers[$i][3])==3)
- {$echomsg.="very extreme ";}
- $echomsg.="changing your score ".$answers[$i][3];
- $echomsg.=".</h2></div>";
- //echo $answers[$i][1];
- }
- }
- echo $echomsg;
- }
- ?>
- <div class="containall">
- <h1>Results at a glance:</h1>
- <div class="flexion">
- <div class="resultsbox"><div class="pointer" <?php echopos($con,$id)?>></div></div>
- <div class="groupscontain">
- <?php echopercent($con,$id); ?>
- <h2>On the issues:</h2>
- <div class="columncontain">
- <div class="column">
- <a class="sectionbut" href="#z1">Sexual and racial diversity in companies: <?php echofiscal(0,$sectxt); ?></a>
- <a class="sectionbut" href="#z2">Social healthcare: <?php echofiscal(1,$sectxt); ?></a>
- <a class="sectionbut" href="#z3">Public colleges/schooling: <?php echofiscal(2,$sectxt); ?></a>
- <a class="sectionbut" href="#z4">International trade policies and regulations: <?php echofiscal(3,$sectxt); ?></a>
- <a class="sectionbut" href="#z5">Social security: <?php echofiscal(4,$sectxt); ?></a>
- <a class="sectionbut" href="#z6">Green energy/the environment: <?php echofiscal(5,$sectxt); ?></a>
- <a class="sectionbut" href="#z7">Stimulus: <?php echofiscal(6,$sectxt); ?></a>
- </div>
- <div class="column">
- <a class="sectionbut" href="#z8">Abortion: <?php echosocial(7,$sectxt); ?></a>
- <a class="sectionbut" href="#z9">Hate vs free speech: <?php echosocial(8,$sectxt); ?></a>
- <a class="sectionbut" href="#z10">Religion and government: <?php echosocial(9,$sectxt); ?></a>
- <a class="sectionbut" href="#z11">Criminal justice: <?php echosocial(10,$sectxt); ?></a>
- <a class="sectionbut" href="#z12">Immigration: <?php echosocial(11,$sectxt); ?></a>
- <a class="sectionbut" href="#z13">Drugs: <?php echosocial(12,$sectxt); ?></a>
- <a class="sectionbut" href="#z14">Foreign Policy: <?php echosocial(13,$sectxt); ?></a>
- </div>
- </div>
- </div>
- <div class="morestuff">
- <h1>In further detail: </h1>
- <h3 style="font-size:1.3em" id="z1">Sexual and Racial diversity in companies: <?php echofiscal(0,$sectxt); ?></h3>
- <?php echoquestions(0,$anstxt);?>
- <h3 style="font-size:1.3em" id="z2">Social Healthcare: <?php echofiscal(1,$sectxt); ?></h3>
- <?php echoquestions(1,$anstxt);?>
- <h3 style="font-size:1.3em" id="z3">Public Colleges/schooling: <?php echofiscal(2,$sectxt); ?></h3>
- <?php echoquestions(2,$anstxt);?>
- <h3 style="font-size:1.3em" id="z4">International trade policies and regulations: <?php echofiscal(3,$sectxt); ?></h3>
- <?php echoquestions(3,$anstxt);?>
- <h3 style="font-size:1.3em" id="z5">Social Security: <?php echofiscal(5,$sectxt); ?></h3>
- <?php echoquestions(5,$anstxt);?>
- <h3 style="font-size:1.3em" id="z6">Green Energy/the Environment: <?php echofiscal(4,$sectxt); ?></h3>
- <?php echoquestions(4,$anstxt);?>
- <h3 style="font-size:1.3em" id="z7">Stimulus: <?php echofiscal(6,$sectxt); ?></h3>
- <?php echoquestions(6,$anstxt);?>
- <h1> the Social issues: </h1>
- <h3 style="font-size:1.3em" id="z8">Abortion: <?php echosocial(7,$sectxt); ?></h3>
- <?php echoquestions(7,$anstxt);?>
- <h3 style="font-size:1.3em" id="z9">Hate vs Free speech: <?php echosocial(8,$sectxt); ?></h3>
- <?php echoquestions(8,$anstxt);?>
- <h3 style="font-size:1.3em" id="z10">Religion and government: <?php echosocial(9,$sectxt); ?></h3>
- <?php echoquestions(9,$anstxt);?>
- <h3 style="font-size:1.3em" id="z11">Criminal justice: <?php echosocial(10,$sectxt); ?></h3>
- <?php echoquestions(10,$anstxt);?>
- <h3 style="font-size:1.3em" id="z12">Immigration: <?php echosocial(11,$sectxt); ?></h3>
- <?php echoquestions(11,$anstxt);?>
- <h3 style="font-size:1.3em" id="z13">Drugs: <?php echosocial(12,$sectxt); ?></h3>
- <?php echoquestions(12,$anstxt);?>
- <h3 style="font-size:1.3em" id="z14" >Foreign policy: <?php echosocial(13,$sectxt); ?></h3>
- <?php echoquestions(13,$anstxt);?>
- </div>
- </div>
- </div>
- <script src="app.js"></script>
- <script>
- $(function() {
- $('a[href*="#"]:not([href="#"])').click(function() {
- if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
- var target = $(this.hash);
- target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
- if (target.length) {
- $('html, body').animate({
- scrollTop: target.offset().top
- }, 1000);
- return false;
- }
- }
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement