apexsquirt

[Philosophy Quiz] index.php

Jun 24th, 2023 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.05 KB | Source Code | 0 0
  1. <title>philosophy test / test de philosophie</title>
  2. <?php
  3. $agreement = array (
  4.     0 => ["strongly agree","agree","neutral/i don't know","disagree","strongly disagree","results","spiritual axis","observation axis","logic axis","moral axis","openness axis","trend axis","materialist","dualist","empiricist","idealist","exotic","classicist","relativist","absolutist","homogeneist","tolerant","analytic","literary"],
  5.     1 => ["fortement d'accord","d'accord","neutre/je sais pas","pas d'accord","fortement pas d'accord","résultats","axe spirituel","axe observatif","axe logique","axe moral","axe d'ouverture","axe de tendance","matérialiste","dualiste","empiriste","idéaliste","exotique","classiciste","relativiste","absolutiste","homogénéiste","tolérant","analytique","littéraire"],
  6. );
  7. /*
  8. nature of reality   :   materialist / dualist           6
  9. observation         :   empiricist / idealist           5
  10. logic               :   exotic / classicist             6
  11. moral               :   relativist / absolutist         6
  12. openness            :   homogeneist / tolerant          6
  13. approach            :   analytic / literary             6
  14. */
  15. if (isset($_GET["lang"])) $lang = $_GET["lang"];
  16. else $lang = 0;
  17. ?>
  18. <body lang="<?=str_replace(["0","1"],["en-GB","fr"],$lang);?>">
  19. <link rel="preconnect" href="https://fonts.googleapis.com">
  20. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  21. <link href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&family=Noto+Sans+Arabic&display=swap" rel="stylesheet">
  22. <style>
  23. td, legend, a, input {
  24.     font-size: 35px;
  25.     font-family: "Atkinson Hyperlegible", sans-serif;
  26. }
  27. td, fieldset, body {
  28.     color: #FFFFFF;
  29. }
  30. body {
  31.     background-color: #000000;
  32. }
  33. input {
  34.     border: 0px;
  35. }
  36. a {
  37.     color: black;
  38.     background-color: white;
  39.     text-decoration: none
  40. }
  41. a:hover {
  42.     color: white;
  43.     background-color: grey;
  44.     font-weight: bold
  45. }
  46. [a1] {
  47.     background-color: rgb(100,255,100)
  48. }
  49. [a2] {
  50.     background-color: rgb(200,255,200)
  51. }
  52. [a3] {
  53.     background-color: rgb(255,255,255)
  54. }
  55. [a4] {
  56.     background-color: rgb(255,200,200)
  57. }
  58. [a5] {
  59.     background-color: rgb(255,100,100)
  60. }
  61. </style>
  62. <?php
  63. $file = str_replace(["\n","\r"],"",file("questions.txt"));
  64. function scale($a) {
  65.     $score1 = 2*$a;
  66.     $score2 = 24-$score1;
  67.     $str = "<span style='color: red'>".round($score1*100/24)."<small><small>%</small></small></span><td><span style='background-color: red'>";
  68.     for ($i = 0; $i < 24; $i++) {
  69.         if ($i == $score1)
  70.             $str .= "</span><span style='background-color: rgb(127,192,255)'>";
  71.         $str .= "&nbsp;";
  72.     }
  73.     $str .= "</span><td><span style='color: rgb(127,192,255)'>".(100-round($score1*100/24))."<small><small>%</small></small></span>\n";
  74.     return $str;
  75. }
  76. ?>
  77. <center>
  78. <table height="100%" width="75%"><tr height="100%"><td height="100%" valign="center">
  79. <form method="get">
  80.   <fieldset>
  81.    <?php if (!isset($_GET["lang"])) { ?>
  82.    <legend style="border: solid 1px #FFFFFF; width: 100%"><center><b>‎👅?</b></center></legend>
  83.    <center>
  84.    <input type="radio" style="height: 30px; width: 30px" id="en" name="lang" value="0" checked>
  85.    <label for="en">English</label><br>
  86.    <input type="radio" style="height: 30px; width: 30px" id="fr" name="lang" value="1">
  87.    <label for="fr">Français</label><br>
  88.    <input type="hidden" name="q" value="0">
  89.    <input type="hidden" name="s" value="<?=base64_encode("0:0:0:0:0:0");?>">
  90.    <input type="submit" value="✔️">
  91.    <?php } elseif ($_GET["q"] < 33) { ?>
  92.    <legend style="border: solid 1px #FFFFFF; width: 100%"><center><?php print $file[intval($_GET["q"])*4+intval($_GET["lang"])]; ?></center></legend>
  93.    <center style="line-height: 60px">
  94.    <?php
  95.    eval("\$array = array(".$file[intval($_GET["q"])*4+2].");");
  96.    $score_arr = array("EXR" => 0,"OBS" => 1,"LOG" => 2,"MOR" => 3,"OPN" => 4,"APP" => 5);
  97.    $test = explode(":",base64_decode($_GET["s"]));
  98.    function add ($array, $score_arr, $test, $factor) {
  99.        $str = "";
  100.        foreach ($array as $i => $j)
  101.        $test[$score_arr[$i]] += $j*$factor;
  102.        foreach ($test as $i => $x) {
  103.          if ($i > 0) $str .= ":";
  104.          $str .= $x;
  105.        }
  106.        return base64_encode($str);
  107.    }
  108.    function addPRINT ($array, $score_arr, $test, $factor) {
  109.        $str = "";
  110.        foreach ($array as $i => $j)
  111.        $test[$score_arr[$i]] += $j*$factor;
  112.        foreach ($test as $i => $x) {
  113.          if ($i > 0) $str .= ":";
  114.          $str .= array_keys($score_arr,$i)[0].$x;
  115.        }
  116.        return base64_encode($str);
  117.    }
  118.    ?>
  119.    <a a1 href="?lang=<?=$_GET["lang"];?>&q=<?=intval($_GET["q"])+1;?>&s=<?php
  120.    print(add($array, $score_arr, $test, 1.0)); ?>"><?=$agreement[$_GET["lang"]][0];?></a><br>
  121.    <a a2 href="?lang=<?=$_GET["lang"];?>&q=<?=intval($_GET["q"])+1;?>&s=<?php
  122.    print(add($array, $score_arr, $test, 0.5)); ?>"><?=$agreement[$_GET["lang"]][1];?></a><br>
  123.    <a a3 href="?lang=<?=$_GET["lang"];?>&q=<?=intval($_GET["q"])+1;?>&s=<?php
  124.    print(add($array, $score_arr, $test, 0.0)); ?>"><?=$agreement[$_GET["lang"]][2];?></a><br>
  125.    <a a4 href="?lang=<?=$_GET["lang"];?>&q=<?=intval($_GET["q"])+1;?>&s=<?php
  126.    print(add($array, $score_arr, $test, -.5)); ?>"><?=$agreement[$_GET["lang"]][3];?></a><br>
  127.    <a a5 href="?lang=<?=$_GET["lang"];?>&q=<?=intval($_GET["q"])+1;?>&s=<?php
  128.    print(add($array, $score_arr, $test, -1.)); ?>"><?=$agreement[$_GET["lang"]][4];?></a>
  129.    <?php } elseif($_GET["q"] == 33) { ?>
  130.    <legend style="border: solid 1px #FFFFFF; width: 100%"><center><b><?=$agreement[$_GET["lang"]][5];?></b></center></legend>
  131.    <center>
  132.    <?php $test = explode(":",base64_decode($_GET["s"])); ?>
  133.    
  134.     <table><tr><td colspan='5'><center>
  135.     <b><?=$agreement[$_GET["lang"]][6];?></b>
  136.     <tr><td><?=$agreement[$_GET["lang"]][12];?>
  137.         <td style='text-align:right'><?=scale(6-$test[0]*.1);?>
  138.         <td style='text-align:right'><?=$agreement[$_GET["lang"]][13];?>
  139.     <tr><td colspan="5"><hr>
  140.     <tr><td colspan='5'><center>
  141.     <b><?=$agreement[$_GET["lang"]][7];?></b>
  142.     <tr><td><?=$agreement[$_GET["lang"]][14];?>
  143.         <td style='text-align:right'><?=scale(6-$test[1]*.1);?>
  144.         <td style='text-align:right'><?=$agreement[$_GET["lang"]][15];?>
  145.     <tr><td colspan="5"><hr>
  146.     <tr><td colspan='5'><center>
  147.     <b><?=$agreement[$_GET["lang"]][8];?></b>
  148.     <tr><td><?=$agreement[$_GET["lang"]][16];?>
  149.         <td style='text-align:right'><?=scale(6-$test[2]*.1);?>
  150.         <td style='text-align:right'><?=$agreement[$_GET["lang"]][17];?>
  151.     <tr><td colspan="5"><hr>
  152.     <tr><td colspan='5'><center>
  153.     <b><?=$agreement[$_GET["lang"]][9];?></b>
  154.     <tr><td><?=$agreement[$_GET["lang"]][18];?>
  155.         <td style='text-align:right'><?=scale(6-$test[3]*.1);?>
  156.         <td style='text-align:right'><?=$agreement[$_GET["lang"]][19];?>
  157.     <tr><td colspan="5"><hr>
  158.     <tr><td colspan='5'><center>
  159.     <b><?=$agreement[$_GET["lang"]][10];?></b>
  160.     <tr><td><?=$agreement[$_GET["lang"]][21];?>
  161.         <td style='text-align:right'><?=scale(6+$test[4]*.1);?>
  162.         <td style='text-align:right'><?=$agreement[$_GET["lang"]][20];?>
  163.     <tr><td colspan="5"><hr>
  164.     <tr><td colspan='5'><center>
  165.     <b><?=$agreement[$_GET["lang"]][11];?></b>
  166.     <tr><td><?=$agreement[$_GET["lang"]][22];?>
  167.         <td style='text-align:right'><?=scale(6-$test[5]*.1);?>
  168.         <td style='text-align:right'><?=$agreement[$_GET["lang"]][23];?>
  169.     </table>
  170.    <?php } ?>
  171.   </fieldset>
  172. </form>
  173. </table>
Add Comment
Please, Sign In to add comment