introduced statistics, landing page and more eyecandy
This commit is contained in:
@@ -107,4 +107,12 @@ body {
|
||||
|
||||
td.code {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.mow-container {
|
||||
width: 700px;
|
||||
}
|
||||
|
||||
.mow-container .form-horizontal .controls {
|
||||
margin-left: 130px;
|
||||
}
|
||||
1
data/.gitignore
vendored
Normal file
1
data/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sav
|
||||
103
data/stats.php
Normal file
103
data/stats.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
include '../includes/file.php';
|
||||
|
||||
$visits = get_visits('', 'visits.sav');
|
||||
|
||||
$max_visitors = 0;
|
||||
foreach($visits as $value){
|
||||
if(sizeof($value) > $max_visitors){
|
||||
$max_visitors = sizeof($value);
|
||||
}
|
||||
}
|
||||
|
||||
$max_visits = 0;
|
||||
foreach($visits as $value){
|
||||
$count = 0;
|
||||
foreach($value as $key => $v){
|
||||
$count += $v;
|
||||
}
|
||||
if($count > $max_visits){
|
||||
$max_visits = $count;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>mahlowat - Statistik</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta content="">
|
||||
<link href="../css/bootstrap.css" rel="stylesheet" media="screen">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container top-buffer">
|
||||
|
||||
<div class="well">
|
||||
<h1>Besucher</h1>
|
||||
<p>Von wie vielen IP-Adressen wurde der Mahlowat aufgerufen?</p>
|
||||
|
||||
<table class="table table-bordered table-hover">
|
||||
<tr><th style="width: 200px;">Datum</th><th style="width:100px">Besucher</th><th style="width:640px;"> </th></tr>
|
||||
<?php
|
||||
foreach($visits as $day => $value){
|
||||
$dayvisitors = sizeof($value);
|
||||
|
||||
if($max_visitors != 0){
|
||||
$day_percentage = intval( 100 * $dayvisitors / $max_visitors);
|
||||
} else {
|
||||
$day_percentage = 0;
|
||||
}
|
||||
|
||||
$dayvisitors == $max_visitors ? $class = "success" : $class = "";
|
||||
|
||||
echo "<tr class='$class'>
|
||||
<td><b>$day</b></td><td>$dayvisitors</td>
|
||||
<td><div class='progress'><div class='bar' title='$dayvisitors' style='width: $day_percentage%;'></div></div>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="well">
|
||||
<h1>Durchläufe</h1>
|
||||
<p>Wie oft wurde die Gewichtungs-Seite aufgerufen?</p>
|
||||
|
||||
<table class="table table-bordered table-hover">
|
||||
<tr><th style="width: 200px;">Datum</th><th style="width:100px">Durchläufe</th><th style="width:640px;"> </th></tr>
|
||||
<?php
|
||||
foreach($visits as $day => $value){
|
||||
$dayvisits = 0;
|
||||
foreach($value as $key => $v){
|
||||
$dayvisits += $v;
|
||||
}
|
||||
|
||||
if($max_visits != 0){
|
||||
$day_percentage2 = intval( 100 * $dayvisits / $max_visits);
|
||||
} else {
|
||||
$day_percentage2 = 0;
|
||||
}
|
||||
|
||||
$dayvisits == $max_visits ? $class = "success" : $class = "";
|
||||
|
||||
echo "<tr class='$class'>
|
||||
<td><b>$day</b></td><td>$dayvisits</td>
|
||||
<td><div class='progress'><div class='bar' title='$dayvisits' style='width: $day_percentage2%;'></div></div>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3
faq.php
3
faq.php
@@ -47,11 +47,12 @@
|
||||
<li>Sind die Antworten entgegengesetzt oder hat eine Hochschulgruppe eine Frage nicht beantwortet, gibt es keine Punkte für die Hochschulgruppe.</li>
|
||||
</ul>
|
||||
<p>Eine Frage, die die Testperson übersprungen hat, wird nicht gewertet. Entsprechend gibt es dann insgesamt weniger Punkte zu erreichen.</p>
|
||||
<p>Eine Frage, die doppelt gewichtet werden soll, wird doppelt gewichtet, das heißt, für sie wird die doppelte Punktzahl gutgeschrieben (0/2/4). Entsprechend gibt es insgesamt mehr Punkte zu erreichen.</p>
|
||||
|
||||
<h4>Ich habe einen Fehler gefunden!</h4>
|
||||
<p>Dann solltest du das <a href="http://www.akut-bonn.de/kontakt/" title="Kontakt zur akut">melden</a>. Wir freuen uns über sachdienliche Hinweise.</p>
|
||||
|
||||
<a href="<?php echo $back; ?>" title="Zurück zum Mahlowat">Zurück zum Mahlowat</a>
|
||||
<a class="btn btn-primary" href="<?php echo $back; ?>" title="Zurück zum Mahlowat">Zurück zum Mahlowat</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
99
includes/file.php
Normal file
99
includes/file.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
function add_visit($id, $file){
|
||||
$visits = get_visits($id, $file);
|
||||
if($visits != null){
|
||||
$date = date('Ymd');
|
||||
|
||||
if(!isset($visits[$date][$id])){
|
||||
$visits[$date][$id] = 1;
|
||||
} else {
|
||||
$visits[$date][$id] = $visits[$date][$id] + 1;
|
||||
}
|
||||
set_visits($visits, $file);
|
||||
} else {
|
||||
echo '<!-- ERROR konnte Besuche nicht zählen -->';
|
||||
}
|
||||
}
|
||||
|
||||
function get_visits($id, $file){
|
||||
if(!file_exists($file)){
|
||||
$visits[date('Ymd')][$id] = 0;
|
||||
return $visits;
|
||||
}
|
||||
if(is_readable($file)){
|
||||
|
||||
$handle = fopen($file, 'r');
|
||||
$contents = fread($handle, filesize($file));
|
||||
fclose($handle);
|
||||
|
||||
$visits = unserialize($contents);
|
||||
return $visits;
|
||||
} else {
|
||||
echo "<!-- ERROR $file kann nicht gelesen werden! -->";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function set_visits($visits, $file){
|
||||
if(is_writable($file) or (is_writable(dirname($file)) and !file_exists($file))){
|
||||
|
||||
$handle = fopen($file, 'w');
|
||||
if (!fwrite($handle, serialize($visits))) {
|
||||
echo "<!-- ERROR Kann in die Datei $file nicht schreiben -->";
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
} else {
|
||||
echo "<!-- ERROR $file nicht beschreibbar! -->";
|
||||
}
|
||||
}
|
||||
|
||||
function get_salt($hashfile){
|
||||
// a) file does not exist yet
|
||||
if(!file_exists($hashfile)){
|
||||
if(is_writable(dirname($hashfile))){
|
||||
|
||||
$hash[0] = date('Ymd');
|
||||
$hash[1] = mt_rand();
|
||||
|
||||
$handle = fopen($hashfile, 'w');
|
||||
if (!fwrite($handle, serialize($hash))) {
|
||||
echo "<!-- ERROR Kann in die Datei $hashfile nicht schreiben -->";
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
} else {
|
||||
echo "<!-- ERROR Kann Datei $hashfile nicht erstellen! -->";
|
||||
}
|
||||
}
|
||||
|
||||
if(is_readable($hashfile)){
|
||||
|
||||
$handle = fopen($hashfile, 'r');
|
||||
$contents = fread($handle, filesize($hashfile));
|
||||
fclose($handle);
|
||||
|
||||
$hash = unserialize($contents);
|
||||
|
||||
// b) hash is not of today
|
||||
if($hash[0] != date('Ymd')){
|
||||
$hash[0] = date('Ymd');
|
||||
$hash[1] = mt_rand();
|
||||
|
||||
$handle = fopen($hashfile, 'w');
|
||||
if (!fwrite($handle, serialize($hash))) {
|
||||
echo "<!-- ERROR Kann in die Datei $hashfile nicht schreiben -->";
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
return $hash[1];
|
||||
} else {
|
||||
echo "<!-- ERROR $file kann nicht gelesen werden! -->";
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -210,7 +210,7 @@ function code_to_answer($code){
|
||||
if($i == $curr){
|
||||
return '<li class="active"><a href="#">'.$i."</a></li>\n";
|
||||
} else {
|
||||
return '<li class=""><a href="index.php?id='.$i.'">'.$i."</a></li>\n";
|
||||
return '<li class=""><a href="mahlowat.php?id='.$i.'">'.$i."</a></li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
105
index.php
105
index.php
@@ -1,46 +1,3 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include 'includes/funcs.php';
|
||||
include 'includes/theses.php';
|
||||
|
||||
if(!isset($_SESSION['answers'])){
|
||||
$_SESSION['answers'] = Array('skip','skip','skip','skip','skip','skip');
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['theses'])){
|
||||
$_SESSION['theses'] = get_theses_array();
|
||||
}
|
||||
|
||||
if(isset($_POST['q_id'])){
|
||||
$q_id = intval($_POST['q_id']) + 1;
|
||||
} elseif(isset($_GET['id'])){
|
||||
$q_id = intval($_GET['id']) - 2;
|
||||
} else {
|
||||
$q_id = -1;
|
||||
}
|
||||
|
||||
// check if last answer was yes, neutral, no or skip
|
||||
if(isset($_POST['yes'])){
|
||||
$_SESSION['answers'][$q_id] = 1;
|
||||
}
|
||||
if(isset($_POST['neutral'])){
|
||||
$_SESSION['answers'][$q_id] = 0;
|
||||
}
|
||||
if(isset($_POST['no'])){
|
||||
$_SESSION['answers'][$q_id] = -1;
|
||||
}
|
||||
if(isset($_POST['skip'])){
|
||||
$_SESSION['answers'][$q_id] = 'skip';
|
||||
}
|
||||
|
||||
if($q_id > 4){
|
||||
header("Location: multiplier.php");
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
@@ -53,58 +10,20 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container top-buffer">
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
for($i = 1; $i < sizeof($_SESSION['answers'])+1; $i = $i + 1){
|
||||
echo pagitem($i, $q_id+2);
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="container mow-container top-buffer">
|
||||
|
||||
<h1>These <?php echo $q_id+2; ?></h1>
|
||||
<form class="form-horizontal" action="index.php" method="post">
|
||||
<input type="hidden" name="q_id" value="<?php echo $q_id; ?>">
|
||||
<p class="statement">
|
||||
<?php echo $_SESSION['theses']['l'][$q_id+1]; ?>
|
||||
</p>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<?php
|
||||
$curr_ans = $_SESSION['answers'][$q_id+1];
|
||||
$yes_class = "icon-thumbs-up";
|
||||
$neutral_class = "bg-icon-circle";
|
||||
$no_class = "icon-thumbs-down";
|
||||
if(!($curr_ans === 'skip')){
|
||||
if($curr_ans == 1){$yes_class .= " icon-white";}
|
||||
if($curr_ans == 0){$neutral_class .= " icon-white";}
|
||||
if($curr_ans == -1){$no_class .= " icon-white";}
|
||||
}
|
||||
echo "<button type='submit' class='btn btn-success' name='yes'><i class='$yes_class'></i> Zustimmung</button>
|
||||
<button type='submit' class='btn btn-warning' name='neutral'><i class='$neutral_class'></i> Neutral</button>
|
||||
<button type='submit' class='btn btn-danger' name='no'><i class='$no_class'></i> Ablehnung</button>";
|
||||
?>
|
||||
<button type="submit" class="btn" name="skip"><i class="icon-share-alt"></i> Überspringen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h1>Mahlowat</h1>
|
||||
|
||||
<div class="text-right">
|
||||
<hr />
|
||||
<small>Du kannst die Befragung
|
||||
<a href="killsession.php" title="Von vorn beginnen">neu starten</a>
|
||||
oder den Rest der Thesen
|
||||
<a href="multiplier.php" title="Gewichtung ändern">überspringen</a>.<br />
|
||||
Außerdem haben wir auch eine <a href="faq.php?from=index.php?id=<?php echo $q_id+2; ?>" title="FAQ">FAQ-Seite</a>.
|
||||
</small>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Der Mahlowat ist ein technisches Hilfsmittel, das es ermöglicht, zu ausgewählten Themen die eigenen Standpunkte mit denen der Hochschulgruppen abzugleichen, die zur Wahl des 36. Studierendenparlaments antreten.</p>
|
||||
|
||||
<p>Er ist selbstverständlich nur als dummer Automat zu verstehen und spricht keine Wahlempfehlungen aus.</p>
|
||||
|
||||
<p>Der Mahlowat ist ein Angebot der akut-Redaktion und wurde auf Beschluss des XXXV. Studierendenparlaments entwickelt.</p>
|
||||
|
||||
<p class="text-center"><a class="btn btn-large btn-primary" href="mahlowat.php" title="Mahlowat starten">Mit der Befragung beginnen!</a></p>
|
||||
|
||||
<p class="text-center"><a href="faq.php" title="Fragen und Antworten"><small>FAQ</small></a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php } ?>
|
||||
</html>
|
||||
113
mahlowat.php
Normal file
113
mahlowat.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include 'includes/funcs.php';
|
||||
include 'includes/theses.php';
|
||||
|
||||
if(!isset($_SESSION['answers'])){
|
||||
$_SESSION['answers'] = Array('skip','skip','skip','skip','skip','skip');
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['theses'])){
|
||||
$_SESSION['theses'] = get_theses_array();
|
||||
}
|
||||
|
||||
if(isset($_POST['q_id'])){
|
||||
$q_id = intval($_POST['q_id']) + 1;
|
||||
} elseif(isset($_GET['id'])){
|
||||
$q_id = intval($_GET['id']) - 2;
|
||||
} else {
|
||||
$q_id = -1;
|
||||
}
|
||||
|
||||
// check if last answer was yes, neutral, no or skip
|
||||
if(isset($_POST['yes'])){
|
||||
$_SESSION['answers'][$q_id] = 1;
|
||||
}
|
||||
if(isset($_POST['neutral'])){
|
||||
$_SESSION['answers'][$q_id] = 0;
|
||||
}
|
||||
if(isset($_POST['no'])){
|
||||
$_SESSION['answers'][$q_id] = -1;
|
||||
}
|
||||
if(isset($_POST['skip'])){
|
||||
$_SESSION['answers'][$q_id] = 'skip';
|
||||
}
|
||||
|
||||
if($q_id > 4){
|
||||
header("Location: multiplier.php");
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>mahlowat</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta content="">
|
||||
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container mow-container top-buffer">
|
||||
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
for($i = 1; $i < sizeof($_SESSION['answers'])+1; $i = $i + 1){
|
||||
echo pagitem($i, $q_id+2);
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h1>These <?php echo $q_id+2; ?></h1>
|
||||
<form class="form-horizontal" action="mahlowat.php" method="post">
|
||||
<input type="hidden" name="q_id" value="<?php echo $q_id; ?>">
|
||||
<p class="statement">
|
||||
<?php echo $_SESSION['theses']['l'][$q_id+1]; ?>
|
||||
</p>
|
||||
<div class="controls">
|
||||
<?php
|
||||
$curr_ans = $_SESSION['answers'][$q_id+1];
|
||||
$yes_class = "btn";
|
||||
$neutral_class = "btn";
|
||||
$no_class = "btn";
|
||||
$skip_class = "btn";
|
||||
if(!($curr_ans === 'skip')){
|
||||
if($curr_ans == 1){$yes_class .= " btn-success";}
|
||||
if($curr_ans == 0){$neutral_class .= " btn-warning";}
|
||||
if($curr_ans == -1){$no_class .= " btn-danger";}
|
||||
} else {
|
||||
$yes_class .= " btn-success";
|
||||
$neutral_class .= " btn-warning";
|
||||
$no_class .= " btn-danger";
|
||||
}
|
||||
echo "<button type='submit' class='$yes_class' name='yes'><i class='icon-thumbs-up'></i> Zustimmung</button>
|
||||
<button type='submit' class='$neutral_class' name='neutral'><i class='bg-icon-circle'></i> Neutral</button>
|
||||
<button type='submit' class='$no_class' name='no'><i class='icon-thumbs-down'></i> Ablehnung</button>
|
||||
<button type='submit' class='$skip_class' name='skip'><i class='icon-share-alt'></i> Überspringen</button>";
|
||||
?>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="text-right">
|
||||
<hr />
|
||||
<small>Du kannst die Befragung
|
||||
<a href="killsession.php" title="Von vorn beginnen">neu starten</a>
|
||||
oder den Rest der Thesen
|
||||
<a href="multiplier.php" title="Gewichtung ändern">überspringen</a>.<br />
|
||||
Außerdem haben wir auch eine <a href="faq.php?from=mahlowat.php?id=<?php echo $q_id+2; ?>" title="FAQ">FAQ-Seite</a>.
|
||||
</small>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php } ?>
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
include 'includes/funcs.php';
|
||||
include 'includes/theses.php';
|
||||
include 'includes/file.php';
|
||||
|
||||
$warning = false;
|
||||
if(!isset($_SESSION['answers'])){
|
||||
@@ -64,7 +65,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Schließen</button>
|
||||
<a href="index.php" class="btn btn-primary">Thesen bearbeiten</a>
|
||||
<a href="mahlowat.php" class="btn btn-primary">Thesen bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -75,7 +76,9 @@
|
||||
}, 1000);
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
<?php } else {
|
||||
add_visit(crypt($_SERVER['REMOTE_ADDR'], get_salt('./data/salt.sav')), './data/visits.sav');
|
||||
} ?>
|
||||
|
||||
<div class="container top-buffer">
|
||||
|
||||
@@ -106,7 +109,7 @@
|
||||
<small>Du kannst die Befragung
|
||||
<a href="killsession.php" title="Von vorn beginnen">neu starten</a>
|
||||
oder deine
|
||||
<a href="index.php" title="Antworten ändern">Antworten ändern</a>.<br />
|
||||
<a href="mahlowat.php" title="Antworten ändern">Antworten ändern</a>.<br />
|
||||
Außerdem haben wir auch eine <a href="faq.php?from=multiplier.php" title="FAQ">FAQ-Seite</a>.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Schließen</button>
|
||||
<a href="index.php" class="btn btn-primary">Thesen bearbeiten</a>
|
||||
<a href="mahlowat.php" class="btn btn-primary">Thesen bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<small>Du kannst die Befragung
|
||||
<a href="killsession.php" title="Von vorn beginnen">neu starten</a>,
|
||||
deine
|
||||
<a href="index.php" title="Antworten ändern">Antworten ändern</a>
|
||||
<a href="mahlowat.php" title="Antworten ändern">Antworten ändern</a>
|
||||
oder die
|
||||
<a href="multiplier.php" title="Gewichtung ändern">Gewichtung anpassen</a>.<br />
|
||||
Außerdem haben wir auch eine <a href="faq.php?from=result-bars.php" title="FAQ">FAQ-Seite</a>.
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn" data-dismiss="modal" aria-hidden="true">Schließen</button>
|
||||
<a href="index.php" class="btn btn-primary">Thesen bearbeiten</a>
|
||||
<a href="mahlowat.php" class="btn btn-primary">Thesen bearbeiten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
<small>Du kannst die Befragung
|
||||
<a href="killsession.php" title="Von vorn beginnen">neu starten</a>,
|
||||
deine
|
||||
<a href="index.php" title="Antworten ändern">Antworten ändern</a>
|
||||
<a href="mahlowat.php" title="Antworten ändern">Antworten ändern</a>
|
||||
oder die
|
||||
<a href="multiplier.php" title="Gewichtung ändern">Gewichtung anpassen</a>.<br />
|
||||
Außerdem haben wir auch eine <a href="faq.php?from=result-table.php" title="FAQ">FAQ-Seite</a>.
|
||||
|
||||
Reference in New Issue
Block a user