Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Results</title>
  5. <link rel="stylesheet" type="text/css" href="main.css">
  6. <script src="jquery-2.1.4.js"></script>
  7. <script src="jquery.color-2.1.2.min.js"></script>
  8. </head>
  9. <body>
  10.  
  11. <?php
  12.  
  13. $con = require('connect.php');
  14. $id = isset($_GET['id']) ? $_GET['id'] : 999;
  15. if ($id!=999)
  16. {
  17. $row = mysqli_fetch_array(mysqli_query($con, "SELECT sections FROM results WHERE result_id='$id'"));
  18. $sectxt = $row[0];
  19. $section=json_decode($sectxt,true);
  20. $leftright=
  21.  
  22.  
  23. $row = mysqli_fetch_array(mysqli_query($con, "SELECT answers FROM results WHERE result_id='$id'"));
  24. $anstxt = $row[0];
  25. $answers=json_decode($anstxt,true);
  26. }
  27. else
  28. {echo ("<h2>Error!</h2>");}
  29.  
  30.  
  31. function echofiscal($inp,$secins){
  32. //get the result from the array
  33. $section=json_decode($secins,true);
  34. $secres=$section[$inp];
  35. //initialize result
  36. $res="";
  37. if (abs($secres)<.9)
  38. {$res="Centrist";}
  39. else
  40. {
  41. if (abs($secres)>.9)
  42. {
  43. $resA="-Leaning";
  44. }
  45. if (abs($secres)>2)
  46. {
  47. $resA="-Extreme";
  48. }
  49.  
  50. if ($secres<.01)
  51. {$resB="Left";}
  52. else
  53. {$resB="Right";}
  54.  
  55. $res=$resB.$resA;
  56. }
  57.  
  58. echo ("$res");
  59. }
  60.  
  61. function echosocial($inp,$secins){
  62. //get the result from the array
  63. $section=json_decode($secins,true);
  64. $secres=$section[$inp];
  65. //initialize result
  66. $res="";
  67. if (abs($secres)<.9)
  68. {$res="Centrist";}
  69. else
  70. {
  71. if (abs($secres)>.9)
  72. {
  73. $resA="-Leaning";
  74. }
  75. if (abs($secres)>2)
  76. {
  77. $resA="-Extreme";
  78. }
  79.  
  80. if ($secres>.01)
  81. {$resB="Authoritarian";}
  82. else
  83. {$resB="Liberal";}
  84.  
  85. $res=$resB.$resA;
  86. }
  87.  
  88. echo ("$res");
  89. }
  90.  
  91. function echopercent($cont,$idA){
  92.  
  93. $row = mysqli_fetch_array(mysqli_query($cont, "SELECT X FROM results WHERE result_id='$idA'"));
  94. $x = $row[0];
  95.  
  96. $row = mysqli_fetch_array(mysqli_query($cont, "SELECT Y FROM results WHERE result_id='$idA'"));
  97. $y = -$row[0];
  98. if (abs($y)>50)
  99. {$y=($y/abs($y))*50;}
  100.  
  101. echo ("<h2>Scores: Fiscal: $x% Social: $y%</h2>");
  102. }
  103.  
  104. function echopos($cont,$idA){
  105.  
  106. $row = mysqli_fetch_array(mysqli_query($cont, "SELECT X FROM results WHERE result_id='$idA'"));
  107. $x = $row[0]+50;
  108.  
  109. $row = mysqli_fetch_array(mysqli_query($cont, "SELECT Y FROM results WHERE result_id='$idA'"));
  110. $y = $row[0];
  111. if (abs($y)>50)
  112. {$y=($y/abs($y))*50;}
  113. $y+=50;
  114.  
  115. echo ("style='left:$x%; top:$y%'");
  116. }
  117.  
  118. function echoquestions($tid,$qtext){
  119. $answers=json_decode($qtext,true);
  120. $total=count($answers);
  121. $echomsg="";
  122. for ($i=0;$i<($total+1);$i++)
  123. {
  124. //check each question/answer. If it belongs here, echo it.
  125. if ($answers[$i][1]==$tid && $answers[$i][0]!="Basic question" && $answers[$i][0]!="")
  126. {
  127. $anstotal=$answers[$i][0];
  128.  
  129. $echomsg.='<div class="answerpost"><h2>';
  130. $echomsg.=$anstotal;
  131. $echomsg.="</h2>";
  132.  
  133. if (strlen($anstotal)<70)
  134. {$echomsg.="<div class='spacer'></div>";}
  135.  
  136. $echomsg.="<h3 class='answercontent'>";
  137. if ($answers[$i][2]==1)
  138. {
  139. $ansmsg="Strongly Agree";
  140. }
  141. if ($answers[$i][2]==2)
  142. {
  143. $ansmsg="Agree";
  144. }
  145. if ($answers[$i][2]==3)
  146. {
  147. $ansmsg="Not Sure";
  148. }
  149. if ($answers[$i][2]==4)
  150. {
  151. $ansmsg="Disagree";
  152. }
  153. if ($answers[$i][2]==5)
  154. {
  155. $ansmsg="Strongly Disagree";
  156. }
  157. $echomsg.=$ansmsg;
  158. $echomsg.="</h3><h2>This answer was considered ";
  159. if (abs($answers[$i][3])==0)
  160. {$echomsg.="average ";}
  161. if (abs($answers[$i][3])==1)
  162. {$echomsg.="non-average ";}
  163. if (abs($answers[$i][3])==2)
  164. {$echomsg.="extreme ";}
  165. if (abs($answers[$i][3])==3)
  166. {$echomsg.="very extreme ";}
  167. $echomsg.="changing your score ".$answers[$i][3];
  168. $echomsg.=".</h2></div>";
  169. //echo $answers[$i][1];
  170. }
  171. }
  172. echo $echomsg;
  173. }
  174.  
  175. ?>
  176.  
  177. <div class="containall">
  178. <h1>Results at a glance:</h1>
  179. <div class="flexion">
  180. <div class="resultsbox"><div class="pointer" <?php echopos($con,$id)?>></div></div>
  181. <div class="groupscontain">
  182. <?php echopercent($con,$id); ?>
  183. <h2>On the issues:</h2>
  184. <div class="columncontain">
  185. <div class="column">
  186. <a class="sectionbut" href="#z1">Sexual and racial diversity in companies: <?php echofiscal(0,$sectxt); ?></a>
  187. <a class="sectionbut" href="#z2">Social healthcare: <?php echofiscal(1,$sectxt); ?></a>
  188. <a class="sectionbut" href="#z3">Public colleges/schooling: <?php echofiscal(2,$sectxt); ?></a>
  189. <a class="sectionbut" href="#z4">International trade policies and regulations: <?php echofiscal(3,$sectxt); ?></a>
  190. <a class="sectionbut" href="#z5">Social security: <?php echofiscal(4,$sectxt); ?></a>
  191. <a class="sectionbut" href="#z6">Green energy/the environment: <?php echofiscal(5,$sectxt); ?></a>
  192. <a class="sectionbut" href="#z7">Stimulus: <?php echofiscal(6,$sectxt); ?></a>
  193. </div>
  194. <div class="column">
  195. <a class="sectionbut" href="#z8">Abortion: <?php echosocial(7,$sectxt); ?></a>
  196. <a class="sectionbut" href="#z9">Hate vs free speech: <?php echosocial(8,$sectxt); ?></a>
  197. <a class="sectionbut" href="#z10">Religion and government: <?php echosocial(9,$sectxt); ?></a>
  198. <a class="sectionbut" href="#z11">Criminal justice: <?php echosocial(10,$sectxt); ?></a>
  199. <a class="sectionbut" href="#z12">Immigration: <?php echosocial(11,$sectxt); ?></a>
  200. <a class="sectionbut" href="#z13">Drugs: <?php echosocial(12,$sectxt); ?></a>
  201. <a class="sectionbut" href="#z14">Foreign Policy: <?php echosocial(13,$sectxt); ?></a>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="morestuff">
  206. <h1>In further detail: </h1>
  207. <h3 style="font-size:1.3em" id="z1">Sexual and Racial diversity in companies: <?php echofiscal(0,$sectxt); ?></h3>
  208. <?php echoquestions(0,$anstxt);?>
  209.  
  210. <h3 style="font-size:1.3em" id="z2">Social Healthcare: <?php echofiscal(1,$sectxt); ?></h3>
  211. <?php echoquestions(1,$anstxt);?>
  212.  
  213. <h3 style="font-size:1.3em" id="z3">Public Colleges/schooling: <?php echofiscal(2,$sectxt); ?></h3>
  214. <?php echoquestions(2,$anstxt);?>
  215.  
  216. <h3 style="font-size:1.3em" id="z4">International trade policies and regulations: <?php echofiscal(3,$sectxt); ?></h3>
  217. <?php echoquestions(3,$anstxt);?>
  218.  
  219. <h3 style="font-size:1.3em" id="z5">Social Security: <?php echofiscal(5,$sectxt); ?></h3>
  220. <?php echoquestions(5,$anstxt);?>
  221.  
  222. <h3 style="font-size:1.3em" id="z6">Green Energy/the Environment: <?php echofiscal(4,$sectxt); ?></h3>
  223. <?php echoquestions(4,$anstxt);?>
  224.  
  225. <h3 style="font-size:1.3em" id="z7">Stimulus: <?php echofiscal(6,$sectxt); ?></h3>
  226. <?php echoquestions(6,$anstxt);?>
  227. <h1> the Social issues: </h1>
  228. <h3 style="font-size:1.3em" id="z8">Abortion: <?php echosocial(7,$sectxt); ?></h3>
  229. <?php echoquestions(7,$anstxt);?>
  230.  
  231. <h3 style="font-size:1.3em" id="z9">Hate vs Free speech: <?php echosocial(8,$sectxt); ?></h3>
  232. <?php echoquestions(8,$anstxt);?>
  233.  
  234. <h3 style="font-size:1.3em" id="z10">Religion and government: <?php echosocial(9,$sectxt); ?></h3>
  235. <?php echoquestions(9,$anstxt);?>
  236.  
  237. <h3 style="font-size:1.3em" id="z11">Criminal justice: <?php echosocial(10,$sectxt); ?></h3>
  238. <?php echoquestions(10,$anstxt);?>
  239.  
  240. <h3 style="font-size:1.3em" id="z12">Immigration: <?php echosocial(11,$sectxt); ?></h3>
  241. <?php echoquestions(11,$anstxt);?>
  242.  
  243. <h3 style="font-size:1.3em" id="z13">Drugs: <?php echosocial(12,$sectxt); ?></h3>
  244. <?php echoquestions(12,$anstxt);?>
  245.  
  246. <h3 style="font-size:1.3em" id="z14" >Foreign policy: <?php echosocial(13,$sectxt); ?></h3>
  247. <?php echoquestions(13,$anstxt);?>
  248.  
  249. </div>
  250. </div>
  251. </div>
  252.  
  253. <script src="app.js"></script>
  254. <script>
  255. $(function() {
  256. $('a[href*="#"]:not([href="#"])').click(function() {
  257. if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  258. var target = $(this.hash);
  259. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  260. if (target.length) {
  261. $('html, body').animate({
  262. scrollTop: target.offset().top
  263. }, 1000);
  264. return false;
  265. }
  266. }
  267. });
  268. });
  269. </script>
  270. </body>
  271. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement