3
0
Fork 0
mirror of https://github.com/fsr/eseeva synced 2024-11-15 08:53:11 +01:00

first commit

This commit is contained in:
Lucas Woltmann 2014-07-08 20:14:37 +02:00
commit ca0216c0c6
21 changed files with 7115 additions and 0 deletions

112
README.md Normal file
View file

@ -0,0 +1,112 @@
#==============================================================================#
# ESE Evaluation ReadMe #
#==============================================================================#
# 1. General #
#------------------------------------------------------------------------------#
# The software was created for handling the ESE evaluation in a digitalized #
# way reduce the overhead of evaluating paper questionnaires by hand. Thus it #
# provides functions for defining questionnaires, saving filled in questionn- #
# aires in log files, reading them back, creating and handling access keys and #
# and provide a web interface from which all functions can be easily accessed #
#==============================================================================#
# 2. Functional principle #
#------------------------------------------------------------------------------#
# A key file (std. 'keys/keys.csv') contains a list of keys and their state. #
# The keys are used to authenticate a user that wants to fill in a new #
# questionnaire. #
# #
# Keys can have the following states: #
# - unissued => The key was created but has not jet been issued to a #
# student. #
# - issued => The key has been issued to a student and can be used to #
# fill in a questionnaire. #
# - activated => The key has been used to fill in a questionnaire and can #
# now be used to get the ESE cup. #
# - used => The key has been used to acquire an use cup. #
# #
# The people responsible for the ESE create a new list of keys by using the #
# page 'keyTable.php' and set the state of all keys that have been or will be #
# issued to student to 'issued'. #
# If a user has filled in its questionnaire by using the access code that has #
# been handed to him he may then go to a person that is authorized to hand out #
# ESE cup. Said person will then log into the system by using the page #
# 'keyControlPanel.php' and check if the state of the key is set to #
# 'activated'. If that is the case he hands the student his ESE cup and sets #
# the state of the corresponding key to 'used'. #
# The state system prevents users from filling in more than one questionnaire #
# or acquiring more than one ESE cup. #
#==============================================================================#
# 3. Preparing a new ESE Evaluation #
#------------------------------------------------------------------------------#
# a) First a new set of keys must be created by using the 'keyTable.php' page. #
# Select the amount of keys to be high enough to cover all students and #
# tutors. #
# b) Still in 'keyTable.php' set the state of all keys that will be issued to #
# students to 'issued'. #
# c) Open the file 'questionnaires/student_questionnaire.txt' and change the #
# list of questions for students to your liking. Do the same for the tutor #
# questions in the file 'questionnaires/tutor_questionnair.txt'. #
# You may also want to change the headline and title within the same files. #
# d) If you want to keep the old log data, you may also want to change the #
# of the log files for students and tutors in the file 'libs/loggingLib.php'#
# by changing the constants 'STUDENTLOGFILE' and 'TUTORLOGFILE' to the #
# desired values. Otherwise just delete the previous log files so that #
# blank ones will be created once the first questionnaire has been filled #
# in. #
#==============================================================================#
# 4. Checking if a student is authorised to acquire his cup #
#------------------------------------------------------------------------------#
# a) Access the page 'keyControlPanel.php' and enter the access code that was #
# provided to you by the people responsible for the ESE. #
# b) If the code was correct you may now enter the key code of the student in #
# question and check if its state is 'activated'. #
# c) Set the state of the key to used and hand a cup to the student. #
# d) You may are now back at step b) and may check a new code. #
#==============================================================================#
# 5. Analyse the results of the evaluation questionnaires #
#------------------------------------------------------------------------------#
# #
#==============================================================================#
# 6. Files #
#------------------------------------------------------------------------------#
# analysis.php > Analysis the provided log file and #
# displays its results. #
# keyControlPanel.php > Used to access the key file and check #
# or change the state of a key. Should #
# be used by everyone who is authorized #
# to hand out ESE cups. #
# keyTable.php > Graphical presentation of the key #
# file, can be used to generate new #
# keys or change the state of the #
# existing one. Should only be used by #
# a small number of responsible people. #
# student_questionnaire.php > The questionnaire page for students. #
# tutor_questionnaiere.php > The questionnaire page for tutors. #
# css/ > Contains all css style files. #
# bootstrap.css > Twitter bootstrap css file used for #
# the styling of the pages. #
# style.css > A custom style file for making a few #
# changes to the default bootstrap #
# style. #
# keys/ > Contains the key files. #
# keys.csv > The default key file if no other file #
# has been specified. #
# libs/ > Directory for all librarys. #
# formLib.php > Provides useful function for creating #
# the HTML forms that are used in the #
# questionnaires and several other #
# pages. #
# keyLib.php > Provides functions for creating, #
# checking and changing keys and #
# reading and writing key files. #
# logging.php > Provides functions for reading, #
# writing and appending log files. #
# questionnaireLib.php > Provides functions for reading #
# questionnaire files. #
# logs/ > Directory that contains all log files #
# that have been created. #
# questionnaires/ > Directory for all questionnaire files.#
# student_questionnaire.txt > Questionnaire file for students. #
# tutor_questionnaire.txt > Questionnaire file for tutors. #
#==============================================================================#
Patrick Reipschläger - 2013

175
analysis.php Normal file
View file

@ -0,0 +1,175 @@
<?php
//============================================================================
// Name : analysis.php
// Author : Patrick Reipschläger
// Version : 0.5
// Date : 08-2013
// Description : Analysis a ESE Evaluation log file. The file that is analysed
// may be passed as parameter with the URL.
//============================================================================
include_once 'libs/formLib.php';
include_once 'libs/questionnaireLib.php';
include_once 'libs/loggingLib.php';
include_once 'libs/chartLib.php';
// variables for the log data
$questionData;
$tutorData;
$commentData;
// Default log file is the student log file defined in 'loggingLib.php'
$logFile = STUDENTLOGFILE;
// if a logFile parameter has been passed in the URL, than that value will
// be used instead of the default value (with the added folder name)
if (isset($_GET["logFile"]))
$logFile = "logs/" . $_GET["logFile"];
// read the existing log file, if there is no existing log file, the RadLogFile
// function guarantees the initialization of the log variables, which will
// result in the same outcome as if an empty log file is read
ReadLogFile($logFile, $questionData, $tutorData, $commentData);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation Analyse</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<?php
CreateHeadline("ESE Evaluation - Data Analysis");
// if there was any question Data in the log file, display it
if (count($questionData) > 0)
{
CreateSectionHeader("Question Evaluation");
CreateLegend();
foreach ($questionData as $question)
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
// The question itself
echo " <p class=\"lead\"><span>" . $question[0];
//average
echo "</span><span style=\"float:right;\">⌀" .
round(
($question[1]+2*$question[2]+3*$question[3]+4*$question[4]+5*$question[5])
/(array_sum(array_slice($question,1,5))),
2)
. "</span>\n";
echo "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <div class=\"row\">\n";
$width = 800;
$height = 300;
//find max of answers to set max of x-axis, max of y-axis is always seven, because there are six possibilities to answer
$values = $question;
array_shift($values);
$maxX = max($values)+1;
$maxY = 7;
$img = CreateImage($width, $height);
// the amount of answers for the different options and a nice group of bars
for ($i = 1; $i < 7; $i++)
{
echo " <div class=\"col-2\"><p class=\"lead center\">" . $question[$i] . "</p></div>\n";
$color = ImageColorAllocate($img, 255, 80+2*$question[$i], 0);
DrawBar($img, $question[$i], $maxX, $i+1, $maxY, $question[$i], $color);
}
//finish image and save it
$caption = array("N/A","--","-", "0", "+", "++");
DrawCoords($img, $maxX, $maxY, $caption);
$file=str_replace("?", "", str_replace(" ", "", $question[0]));
ImagePNG($img,"question".$file.".png");
ImageDestroy($img);
echo " </div>\n";
echo " </div>\n";
echo " <div class=\"col-sm-3\">\n";
echo " </div>\n";
echo " <div class=\"col-sm-9\">\n";
echo " <img src=\"question".$file.".png\" class=\"lead center\">";
echo " </div>\n";
echo "</div>\n";
}
}
// if there was any tutor Data in the log file, display it
if (count($tutorData) > 0)
{
CreateSectionHeader("Tutor Evaluation");
CreateLegend();
foreach ($tutorData as $tutorName => $tutor)
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
// the name of the tutor
echo " <p class=\"lead\"><span>" . $tutorName . "</span>\n";
//average
echo "<span style=\"float:right;\">⌀" .
round(
($tutor[0]+2*$tutor[1]+3*$tutor[2]+4*$tutor[3]+5*$tutor[4])
/(array_sum($tutor)-$tutor[5]), 2)
. "</span>\n";
echo "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <div class=\"row\">\n";
$width = 800;
$height = 300;
//find max of answers to set max of x-axis, max of y-axis is always seven, because there are six possibilities to answer
$maxX = max($tutor)+1;
$maxY = 7;
$img = CreateImage($width, $height);
// the amount of answers for the different options and a picture
for ($i = 0; $i < 6; $i++)
{
echo " <div class=\"col-2\"><p class=\"lead center\">" . $tutor[$i] . "</p></div>\n";
$color = ImageColorAllocate($img, 255, 80+2*$tutor[$i], 0);
DrawBar($img, $tutor[$i], $maxX, $i+2, $maxY, $tutor[$i], $color);
}
//finish image and save it
$caption = array("N/A","--","-", "0", "+", "++");
DrawCoords($img, $maxX, $maxY, $caption);
$file = str_replace(" ", "", $tutorName);
ImagePNG($img,"tutor".$file.".png");
ImageDestroy($img);
echo " </div>\n";
echo " </div>\n";
echo " <div class=\"col-sm-3\">\n";
echo " </div>\n";
echo " <div class=\"col-sm-9\">\n";
echo " <img src=\"tutor".$file.".png\" class=\"lead center\">";
echo " </div>\n";
echo "</div>\n";
}
}
// if there was any comment Data in the log file, display it
if (count($commentData) > 0)
{
CreateSectionHeader("Comments");
foreach ($commentData as $comment)
// replace all new lines with html breaks to properly display multi-line comments
CreateParagraph(str_replace("\n", "<br/>\n", $comment));
}
?>
</div>
</body>
</html>

4677
css/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load diff

BIN
css/ese-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

67
css/print.css Normal file
View file

@ -0,0 +1,67 @@
@page { size:21.0cm 29.7cm; margin:1cm 0.5cm 1cm 0.5cm; }
body {
margin: 0mm;
padding: 0mm;
font-family: Arial;
}
.container {
width:20cm;
margin: 0mm;
padding: 0mm;
}
.ticket {
width: 6cm;
/* border: 1px dotted #ccc;*/
float: left;
padding: 3mm;
page-break-inside: avoid;
}
.tickettext {
float: left;
/* width: 4.3cm; */
}
.ticketimg {
float: right;
margin: 2mm 0 0 0;
padding: 0px;
}
.ticketimg img {
height: 1.81cm;
margin: 0px;
padding: 0px;
}
.patron {
font-size: 16pt;
font-family:Haettenschweiler;
}
.room {
margin-top: 1mm;
}
.time {
margin-bottom: 1mm;
}
.room, .time {
font-size: 8pt;
width: 100%;
text-align: right;
}
.evalink {
font-size: 7pt;
clear: both;
}
code {
width: 100%;
font-family: Monaco, monospace;
font-size: 10.5pt;
}

76
css/style.css Normal file
View file

@ -0,0 +1,76 @@
/*============================================================================
// Name : style.css
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 2013
// Description : Provides some customized styling for the twitter bootstrap
// css files. Used for the ESE questionnaire.
//==========================================================================*/
input[type="text"]
{
margin-top:5px;
}
input[type="checkbox"]
{
background-color:#FFF0F0;
}
input[type="submit"]
{
background-color:#E0E0FF;
font-size:16pt;
}
label
{
font-weight:normal;
}
textarea.form-control
{
height:100px;
}
p.lead
{
margin-top:10px;
margin-bottom:10px;
}
p.center
{
text-align:center;
}
div.container
{
background-color:#F8F8FF;
}
div.row
{
margin-left:0px;
margin-right:0px;
}
div.equalrow
{
background-color:#F0F0FF;
}
div.unequalrow
{
background-color:transparent;
}
div.hidden
{
display:none;
}
h1
{
text-align:center;
}

102
index.php Normal file
View file

@ -0,0 +1,102 @@
<?php
//============================================================================
// Name : student_questionnaire.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : The form that students have to fill in
// for the ESE evaluation.
//============================================================================
include_once 'libs/formLib.php';
include_once 'libs/questionnaireLib.php';
include_once 'libs/keyLib.php';
include_once 'libs/loggingLib.php';
// indicates if an error occurred and what error
$error = 0;
// Determines if a message box is shown, and what type of message box is shown
$keyState = "";
// load the questionnaire data
$questionnaire = ReadQuestionnaireFile(STUDENT_QUESTIONNAIRE);
// if the variable is set, the form has been posted to itself and can be validated
if (isset($_POST["submit"]))
{
// read the key
$keyData = ReadKeyFile(KEYFILE);
$keyState = GetKeyState($keyData, $_POST["code"]);
if ($keyState == KEYSTATE_ISSUED)
{
// variables for the log data
$questionData;
$tutorData;
$commentData;
// read the existing log file, if there is no existing log file, the RadLogFile
// function guarantees the initialization of the log variables, which will
// result in the same outcome as if an empty log file is read
ReadLogFile(STUDENTLOGFILE, $questionData, $tutorData, $commentData);
// add the data of the form to the existing log data
AddQuestionData($_POST, $questionData, $questionnaire);
AddTutorData($_POST, $tutorData);
AddCommentData($_POST, $commentData);
// write the altered data back to the log file, only change the state of the key,
// if that action was successful
if (WriteLogFile(STUDENTLOGFILE, $questionData, $tutorData, $commentData))
{
SetKeyState($keyData, $_POST["code"], KEYSTATE_ACTIVATED);
WriteKeyFile(KEYFILE, $keyData);
}
// otherwise set the error flag
else
$error = 1;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation für Studenten</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<form action="" method="post">
<?php
CreateQuestionnaireElement("headline", $questionnaire, $_POST);
if ($error)
CreateMessageBox(MSG_DANGER, "Achtung:", "Deine Evaluation konnte aufgrund eines internen Fehlersl eider nicht erfolgreich bearbeitet werden.<br/>Bitte versuch es später nocheinmal oder wende dich an einen der Verantwortlichen.");
else
CreateKeyMessageBox($keyState);
CreateQuestionnaireElement("code", $questionnaire, $_POST);
CreateQuestionnaireElement("tutorName", $questionnaire, $_POST);
CreateQuestionnaireElement("legend", $questionnaire, $_POST);
CreateAllQuestionElements($questionnaire, $_POST);
CreateQuestionnaireElement("comment", $questionnaire, $_POST);
?>
<div class="row">
<input class="form-control" type="submit" name="submit" value="Absenden"/>
</div>
</form>
</div>
</body>
</html>
<?php
function CreateKeyMessageBox($keyState)
{
switch($keyState)
{
case KEYSTATE_NONEXISTENT: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code konnte nicht verifiziert werden. Bitte überprüfe deine Eingabe."); break;
case KEYSTATE_UNISSUED: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code ist ungültig."); break;
case KEYSTATE_ISSUED: CreateMessageBox(MSG_SUCCESS, "Danke!", "Der eigebene Code ist korrekt. Dein Fragebogen wurde erfolgreich übermittelt und du bist nun zum Emfang einer ESE-Tasse berechtigt."); break;
case KEYSTATE_ACTIVATED: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code ist wurde bereits zum ausfüllen eines Fragebogens verwendet. Es darf pro Student nur ein Fragebogen ausgefüllt werden."); break;
case KEYSTATE_USED: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code ist wurde bereits eingelöst. Es darf pro Student nur eine ESE-Tasse ausgegeben werden."); break;
}
}
?>

287
keyControlPanel.php Normal file
View file

@ -0,0 +1,287 @@
<?php
//============================================================================
// Name : keyControlPanel.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : Control panel for managing key codes. The not so quick
// but dirty approach. At some point this should probably
// be rewritten using a cleaner approach.
//============================================================================
include_once 'libs/keyLib.php';
include_once 'libs/formLib.php';
// the super secret password that must be entered to access the control center
define ("ACCESS_CODE", "blub");
// all the states that the control center can have
define ("STATE_NONE", 0);
define ("STATE_ACCESS_ENTER", 1);
define ("STATE_ACCESS_FAILED", 2);
define ("STATE_ACCESS_SUCCESSFULL", 3);
define ("STATE_KEY_NONEXISTENT", 10);
define ("STATE_KEY_UNISSUED", 11);
define ("STATE_KEY_ISSUED", 12);
define ("STATE_KEY_ACTIVATED", 13);
define ("STATE_KEY_USED", 14);
define ("STATE_ACTION_UNISSUED", 20);
define ("STATE_ACTION_ISSUED", 21);
define ("STATE_ACTION_ACTIVATED", 22);
define ("STATE_ACTION_USED", 23);
define ("STATE_ACTION_NEWCODE", 24);
define ("STATE_ACTION_FAILED", 25);
// start a session prevent sending the same post twice
// if the user refreshes the page, it will default to the
// access code screen
session_start();
$formState = STATE_ACCESS_SUCCESSFULL;
$keyCode = "";
// if the variable is set, the form has been posted to itself
// if the submission ids of the post and the form don't match, the
// user has refreshed the site and thus its reseted to the default state
if (isset($_POST["submit"]) && isset($_SESSION["submissionId"]) && $_SESSION["submissionId"] == $_POST["submissionId"])
{
// check if the access code was correct
/*if ($_POST["accessCode"] != ACCESS_CODE)
$formState = STATE_ACCESS_FAILED;
// if the access code was correct, check if a key code has been entered
else*/
if (isset($_POST["keyCode"]))
{
// if a key code has been entered, get the state of that key
$keyCode = $_POST["keyCode"];
$keyData = ReadKeyFile(KEYFILE);
// if no action was performed on the entered key, simply display its state
if (!isset($_POST["action"]))
$formState = KeyStateToFormState(GetKeyState($keyData, $_POST["keyCode"]));
else
{
// otherwise set the state of the form to the action that should be performed
$formState = $_POST["action"];
// if the state is different from the new code action, perform said action
// on the key and if the action was successful save the key file
if ($formState != STATE_ACTION_NEWCODE)
{
if (SetKeyState($keyData, $keyCode, FormStateToKeyState($formState)))
WriteKeyFile(KEYFILE, $keyData);
else
$formState($STATE_ACTION_FAILED);
$_POST["action"] = STATE_ACTION_NEWCODE;
}
}
}
// if the access code was correct and no code was entered
else
$formState = STATE_ACCESS_SUCCESSFULL;
}
// generate a new submission id that is used within the form to prevent double posts
$_SESSION["submissionId"] = rand();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation - Key Control Center</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<form action="" method="post">
<?php
CreateHeadline("Key Control Panel");
CreateInfoBox($formState);
CreateAccessBox($formState);
echo $formState;
switch ($formState)
{
// if the access was successful or a action was performed successfully,
// just display the empty key code box
case STATE_ACCESS_SUCCESSFULL:
case STATE_ACTION_ISSUED:
case STATE_ACTION_UNISSUED:
case STATE_ACTION_ACTIVATED:
case STATE_ACTION_USED:
case STATE_ACTION_NEWCODE:
CreateKeyCodeBox("", true);
break;
// if previously entered key was not found or the action that should
// be performed has been failed, just display the key code box with
// previously entered value
case STATE_KEY_NONEXISTENT:
case STATE_ACTION_FAILED:
CreateKeyCodeBox($keyCode, true);
break;
// if an existing key has been entered, display the readonly key code box
// and all options that can be performed on the key
case STATE_KEY_UNISSUED:
case STATE_KEY_ISSUED:
case STATE_KEY_ACTIVATED:
case STATE_KEY_USED:
CreateKeyCodeBox($keyCode, false);
CreateRowHeader();
echo " <div class=\"col-12\">\n";
echo " <br/><p><strong>Bitte wähle die gewünschte Aktion aus:</strong></p>\n";
echo " </div>\n";
echo "</div>\n";
CreateOption("ESE Code Status auf 'Nicht Ausgegeben' setzen", STATE_ACTION_UNISSUED, true);
CreateOption("ESE Code Status auf 'Ausgegeben' setzen", STATE_ACTION_ISSUED, true);
CreateOption("ESE Code Status auf 'Fragebogen ausgefüllt' setzen", STATE_ACTION_ACTIVATED, true);
CreateOption("ESE Code Status auf 'eingelöst' setzen", STATE_ACTION_USED, true);
CreateOption("Neuen ESE-Code eingeben", STATE_ACTION_NEWCODE, true, true);
break;
}
?>
<div class="row">
<input class="form-control" type="submit" name="submit" value="Absenden"/>
</div>
<input type="hidden" value="<?php /*Hidden input with previously generated id - used for preventing double posts*/ echo $_SESSION['submissionId'];?>" name="submissionId">
</form>
</div>
</body>
</html>
<?php
/**
* Echos a new option row with the specified parameters.
*
* @param string $label The text that is displayed for that option.
* @param integer $id The unique id of that option
* @param boolean $enabled Indicates if that option should be enabled or not. Default is enabled.
* @param boolean $checked Indicates if that option should be checked or not. Default is not checked.
*/
function CreateOption($label, $id, $enabled = true, $checked = false)
{
CreateRowHeader();
echo " <div class=\"col-12\">\n";
echo " <label>\n";
echo " <input class=\"\" type=\"radio\" id=\"action\" name=\"action\" value=\"" . $id . "\" required";
if ($checked)
echo " checked";
if (!$enabled)
echo " disabled";
echo "/>\n";
echo " " . $label . "\n";
echo " </label>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos the key code text box.
*
* @param string $keyCode The key that should be displayed in the box.
* @param boolean $enabled Indicates if the key code box should be enabled or not.
*/
function CreateKeyCodeBox($keyCode, $enabled)
{
CreateRowHeader();
echo " <div class=\"col-6\">\n";
echo " <p class=\"lead\">ESE Code:</p>\n";
echo " </div>\n";
echo " <div class=\"col-6\">\n";
echo " <input class=\"form-control\" type=\"text\" id=\"keyCode\" name=\"keyCode\" value=\"" . $keyCode . "\" required";
if (!$enabled)
echo " readonly";
echo "/>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos the access code box according the current state of the form.
*
* @param integer $formState The current state of the form.
*/
function CreateAccessBox($formState)
{
if ($formState < STATE_ACCESS_SUCCESSFULL)
echo "<div class=\"row equalrow\">\n";
else
echo "<div class=\"row equalrow\" hidden>";
echo " <div class=\"col-6\">\n";
echo " <p class=\"lead\">Access Code:</p>\n";
echo " </div>\n";
echo " <div class=\"col-6\">\n";
echo " <input class=\"form-control\" type=\"text\" id=\"accessCode\" name=\"accessCode\" value=\"";
if ($formState != STATE_ACCESS_ENTER)
echo $_POST["accessCode"];
echo "\"/>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Creates a information message box depending on the current state of the form.
*
* @param integer $formState The current state of the form.
*/
function CreateInfoBox($formState)
{
switch ($formState)
{
case STATE_ACCESS_ENTER: CreateMessageBox(MSG_INFO, "Zugang:", "Bitte gib den korrekten Zugangscode ein, um das Key Control Panel nutzen zu können"); break;
case STATE_ACCESS_FAILED: CreateMessageBox(MSG_DANGER, "Zugang:", "Der eingegebene Zugangscode war falsch! Bitte überprüfe deine Eingabe."); break;
case STATE_ACCESS_SUCCESSFULL: CreateMessageBox(MSG_SUCCESS, "Zugang:", "Der eingegebene Zugangscode war korrekt! Bitte gib nun den ESE Code ein, welchen du überprüfen oder verändern möchtest."); break;
case STATE_KEY_NONEXISTENT: CreateMessageBox(MSG_DANGER, "Achtung:", "Der eingegebene ESE Code wurde nicht gefunden! Bitte überprüfe deine Eingabe."); break;
case STATE_KEY_UNISSUED: CreateMessageBox(MSG_WARNING, "ESE Code gefunden:", "Der eingegebene ESE Code wurde gefunden. <strong>Der Schlüssel wurde nicht an einen Studenten ausgegeben!</strong>."); break;
case STATE_KEY_ISSUED: CreateMessageBox(MSG_INFO, "ESE Code gefunden:", "Der Schlüssel wurde an einen Studenten ausgegeben, der Fragebogen wurde noch <strong>nicht ausgefüllt</strong>."); break;
case STATE_KEY_ACTIVATED: CreateMessageBox(MSG_INFO, "ESE Code gefunden:", "Der Schlüssel wurde an einen Studenten ausgegeben, der Fragebogen wurde <strong>ausgefüllt</strong>."); break;
case STATE_KEY_USED: CreateMessageBox(MSG_WARNING, "ESE Code gefunden:", "Der Schlüssel wurde an einen Studenten ausgegeben, der Fragebogen wurde ausgefüllt und der Student hat bereits eine <strong>ESE Tasse erhalten</strong>."); break;
case STATE_ACTION_UNISSUED: CreateMessageBox(MSG_SUCCESS, "ESE Code Status geändert:", "Der Schlüssel wurde erfolgreich auf den Status <strong>Nicht Ausgegeben</strong> gesetzt. Bitte gib einen ESE Code ein, welchen du überprüfen oder verändern möchtest."); break;
case STATE_ACTION_ISSUED: CreateMessageBox(MSG_SUCCESS, "ESE Code Status geändert:", "Der Schlüssel wurde erfolgreich auf den Status <strong>Ausgegeben</strong> gesetzt. Bitte gib einen ESE Code ein, welchen du überprüfen oder verändern möchtest."); break;
case STATE_ACTION_ACTIVATED: CreateMessageBox(MSG_SUCCESS, "ESE Code Status geändert:", "Der Schlüssel wurde erfolgreich auf den Status <strong>Fragebogen ausgefüllt</strong> gesetzt. Bitte gib einen ESE Code ein, welchen du überprüfen oder verändern möchtest."); break;
case STATE_ACTION_USED: CreateMessageBox(MSG_SUCCESS, "ESE Code Status geändert:", "Der Schlüssel wurde erfolgreich auf den Status <strong>Eingelöst</strong> gesetzt. Bitte gib einen ESE Code ein, welchen du überprüfen oder verändern möchtest."); break;
case STATE_ACTION_NEWCODE: CreateMessageBox(MSG_INFO, "ESE Code eingeben:", "Bitte gib den ESE Code ein, welchen du überprüfen oder verändern möchtest."); break;
case STATE_ACTION_FAILED: CreateMessageBox(MSG_DANGER, "Achtung:", "Der Status des angegebenen Schlüssels konnte <strong>nicht geändert</strong> werden! Bitte überprüfe deine Eingabe."); break;
}
}
/**
* Converts the specified key state constant to a valid form state constant
*
* @param string $keySate The key state that should be converted.
* @return integer
*/
function KeyStateToFormState($keyState)
{
switch($keyState)
{
case KEYSTATE_NONEXISTENT: return STATE_KEY_NONEXISTENT;
case KEYSTATE_UNISSUED: return STATE_KEY_UNISSUED;
case KEYSTATE_ISSUED: return STATE_KEY_ISSUED;
case KEYSTATE_ACTIVATED: return STATE_KEY_ACTIVATED;
case KEYSTATE_USED: return STATE_KEY_USED;
}
return STATE_NONE;
}
/**
* Converts the specified form state constant to a valid key state constant
*
* @param integer The form state that should be converted.
* @return integer
*/
function FormStateToKeyState($keyState)
{
switch($keyState)
{
case STATE_KEY_NONEXISTENT:
return KEYSTATE_NONEXISTENT;
case STATE_KEY_UNISSUED:
case STATE_ACTION_UNISSUED:
return KEYSTATE_UNISSUED;
case STATE_KEY_ISSUED:
case STATE_ACTION_ISSUED:
return KEYSTATE_ISSUED;
case STATE_KEY_ACTIVATED:
case STATE_ACTION_ACTIVATED:
return KEYSTATE_ACTIVATED;
case STATE_KEY_USED:
case STATE_ACTION_USED:
return KEYSTATE_USED;
}
return KEYSTATE_NONEXISTENT;
}
?>

158
keyTable.php Normal file
View file

@ -0,0 +1,158 @@
<?php
//============================================================================
// Name : keyTable.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : For managing all keys and their states.
//============================================================================
include_once 'libs/keyLib.php';
include_once 'libs/formLib.php';
// start a session prevent sending the same post twice
// if the user refreshes the page, it will default to the
// access code screen
session_start();
// the key file which should be edited, either the default key file or the one that was specified
$keyFile = KEYFILE;
if (isset($_GET["keyFile"]))
$keyFile = $_GET["keyFile"];
// holds the key data, either be generated from the form or by from the key file
$keyData;
// if the submission ids of the post and the form don't match, the
// user has refreshed the site and thus its reseted to the default state
if (isset($_SESSION["submissionId"]) && $_SESSION["submissionId"] == $_POST["submissionId"])
{
if (isset($_POST["changesConfirm"]))
{
$keyData = array();
$i = 0;
while(isset($_POST["keyIndex" . $i]))
{
if (!isset($_POST["keyDelete" . $i]) || $_POST["keyDelete" . $i] == false)
array_push($keyData, array($_POST["keyCode" . $i], $_POST["keyState" . $i]));
$i++;
}
WriteKeyFile($keyFile, $keyData);
}
else if (isset($_POST["keyGenNew"]))
{
$amount = $_POST["keyAmount"];
$keyFile = $_POST["keyFile"];
CreateKeyFile($amount, $keyFile);
$keyData = ReadKeyFile($keyFile);
}
else if (isset($_POST["keyGenAppend"]))
{
$amount = (int)$_POST["keyAmount"];
$keyFile = $_POST["keyFile"];
$keyData = ReadKeyFile($keyFile);
while($amount > 0)
{
$key = GenerateKey();
$duplicate = false;
foreach($keyData as $entry)
if ($entry[0] == $key)
{
$duplicate = true;
break;
}
if ($duplicate)
continue;
array_push($keyData, array($key, KEYSTATE_UNISSUED));
$amount--;
}
WriteKeyFile($keyFile, $keyData);
}
else
$keyData = ReadKeyFile($keyFile);
}
// if the page was refreshed by the user, just load the key file
else
$keyData = ReadKeyFile($keyFile);
// generate a new submission id that is used within the form to prevent double posts
$_SESSION["submissionId"] = rand();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation für Studenten</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<?php
CreateHeadLine("Key Control Panel");
?>
<?php
echo "<form action=\"keyTable.php?keyFile=" . $keyFile . "\" method=\"post\">\n";
CreateSectionHeader("Key Overview");
CreateRowHeader();
echo " <div class=\"col-1\">\n <p class=\"lead\">Index</p>\n </div>\n";
echo " <div class=\"col-6\">\n <p class=\"lead\">Code</p>\n </div>\n";
echo " <div class=\"col-2\">\n <p class=\"lead\">State</p>\n </div>\n";
echo " <div class=\"col-1\">\n <p class=\"lead\">Delete</p>\n </div>\n";
echo "</div>";
for ($i = 0; $i < count($keyData); $i++)
{
CreateRowHeader();
echo " <div class=\"col-1\">\n";
echo " <p class=\"lead\">" . $i . "</p>\n";
echo " <input type=\"hidden\" name=\"keyIndex" . $i . "\" value=\"" . $i . "\"/>";
echo " </div>\n";
echo " <div class=\"col-6\">\n";
echo " <input type=\"textbox\" class=\"form-control\" name=\"keyCode" . $i . "\" value=\"" . $keyData[$i][0] . "\" readonly/>\n";
echo " </div>\n";
echo " <div class=\"col-2\">\n";
echo " <select class=\"form-control lead\" name=\"keyState" . $i . "\">";
echo " <option value=\"" . KEYSTATE_UNISSUED . "\""; if ($keyData[$i][1] == KEYSTATE_UNISSUED) echo " selected"; echo">" . KEYSTATE_UNISSUED . "</option>";
echo " <option value=\"" . KEYSTATE_ISSUED . "\""; if ($keyData[$i][1] == KEYSTATE_ISSUED) echo " selected"; echo">" . KEYSTATE_ISSUED . "</option>";
echo " <option value=\"" . KEYSTATE_ACTIVATED . "\""; if ($keyData[$i][1] == KEYSTATE_ACTIVATED) echo " selected"; echo">" . KEYSTATE_ACTIVATED . "</option>";
echo " <option value=\"" . KEYSTATE_USED . "\""; if ($keyData[$i][1] == KEYSTATE_USED) echo " selected"; echo">" . KEYSTATE_USED . "</option>";
echo " </select>";
echo " </div>\n";
echo " <div class=\"col-1\">\n";
echo " <input type=\"checkbox\" class=\"form-control\" name=\"keyDelete" . $i . "\"/>\n";
echo " </div>\n";
echo "</div>\n";
}
CreateRowHeader();
echo " <div class=\"col-5\">\n <input type=\"submit\" class=\"form-control\" name=\"changesConfirm\" value=\"Confirm Changes\"/>\n </div>\n";
echo " <div class=\"col-2\"></div>\n";
echo " <div class=\"col-5\">\n <input type=\"submit\" class=\"form-control\" name=\"changesDiscard\" value=\"Discard Changes\"/>\n </div>\n";
echo "</div>\n";
// Hidden input with previously generated id - used for preventing double posts
echo "<input type=\"hidden\" value=\"" . $_SESSION['submissionId'] . "\" name=\"submissionId\" />\n";
echo "</form>\n";
?>
<?php
echo "<form action=\"keyTable.php?keyFile=" . $keyFile . "\" method=\"post\">\n";
CreateSectionHeader("Key File Manipulation");
CreateTextBox("Number of keys", "keyAmount", "10");
CreateTextBox("Key file name", "keyFile", $keyFile);
CreateRowHeader();
echo " <div class=\"col-5\">\n <input type=\"submit\" class=\"form-control\" name=\"keyGenNew\" value=\"Generate New Key File\"/>\n </div>\n";
echo " <div class=\"col-2\"></div>\n";
echo " <div class=\"col-5\">\n <input type=\"submit\" class=\"form-control\" name=\"keyGenAppend\" value=\"Append existing Key File\"/>\n </div>\n";
echo "</div>\n";
// Hidden input with previously generated id - used for preventing double posts
echo "<input type=\"hidden\" value=\"" . $_SESSION['submissionId'] . "\" name=\"submissionId\" />\n";
echo "</form>\n";
?>
</div>
</body>
</html>

117
libs/chartLib.php Normal file
View file

@ -0,0 +1,117 @@
<?php
//============================================================================
// Name : chartLib.php
// Author : Lucas Woltmann
// Version : 1.0
// Date : 08-2013
// Description : Provides functions for creating beautiful and astonishing charts
//============================================================================
function DrawCoords($image, $XLength, $YLength, $values)
{
$width = ImageSX($image);
$height = ImageSY($image);
//scale offset for each axis, minimize Xoffset for small values of Xlength
$Xoffset = 0.8*($width/$XLength);
$Yoffset = 0.8*($height/$YLength);
if($Xoffset>150)
{
$Xoffset=$Xoffset/10;
}
//lines out of image
if($width < ($XLength * $Xoffset) || $height < ($YLength * $Yoffset))
{
echo "lines out of boundaries";
}
$black = ImageColorAllocate($image, 0, 0, 0);
$left = ($width - $XLength * $Xoffset)/2;
$right = $width-$left;
$upper = ($YLength * $Yoffset)+$Yoffset;
$YSpace = ($upper - $Yoffset)/$YLength;
$XSpace = ($right - $left)/$XLength;
//draws X-Axis
ImageLine($image, $left, $upper, $right, $upper, $black);
//draws y-Axis with Yoffset as upper margin
ImageLine($image, $left, $upper,$left, $Yoffset,$black);
//draws arrows
ImageLine($image, $right-5, $upper-5,$right,$upper,$black);
ImageLine($image, $right-5, $upper+5,$right,$upper,$black);
ImageLine($image, $left, $Yoffset,$left+5,$Yoffset+5,$black);
ImageLine($image, $left, $Yoffset,$left-5,$Yoffset+5,$black);
//draws lines for measurement at the y-Axis
for($i=1;$i<$YLength;$i++)
{
ImageLine($image, $left-4, $upper-$YSpace*$i ,$left+4, $upper-$YSpace*$i,$black);
}
//same for the x-Axis
for($j=1;$j<$XLength;$j++)
{
ImageLine($image, $left+$XSpace*$j, $upper-4 ,$left+$XSpace*$j, $upper+4,$black);
}
//caption for x-Axis
$index=0;
while($index < $XLength)
{
if($index % 5 == 0)
{
ImageString($image, 4, $left+($XSpace*$index)-($Xoffset/4), $upper+($Yoffset/3), $index, $black);
}
$index++;
}
//caption for y-Axis
$index=0;
while($index < count($values))
{
ImageString($image, 4, $left-(0*$Xoffset+30), $upper-$YSpace*$index-($Yoffset*0.7), $values[$index], $black);
$index++;
}
}
function DrawBar($image, $length, $maxOfX ,$position, $maxOfY, $value, $color)
{
$imgWidth = ImageSX($image);
$imgHeight = ImageSY($image);
//scale offset for each axis and minimize Xoffset for small values of maxOfX
$Xoffset = 0.8*($imgWidth/$maxOfX);
$Yoffset = 0.8*($imgHeight/$maxOfY);
if($Xoffset>150)
{
$Xoffset=$Xoffset/10;
}
$length = $length*$Xoffset;
$black = ImageColorAllocate($image, 0, 0, 0);
$left = ($imgWidth - $maxOfX * $Xoffset)/2;
$upper = /*($maxOfY*$Yoffset) +*/ $Yoffset + ($position*$Yoffset);
$right = $left+$length;
ImageFilledRectangle($image, $left, $upper, $right, $upper-$Yoffset, $color);
ImageString($image, 4, $right+($Xoffset/3), $upper-$Yoffset*0.7, $value, $black);
}
function CreateImage($width, $height)
{
$image = ImageCreate($width, $height);
$white = ImageColorAllocateAlpha($image, 255, 255, 255, 127);
ImageFill($image, 0, 0, $white);
ImageSaveAlpha($image, TRUE);
return $image;
}
?>

263
libs/formLib.php Normal file
View file

@ -0,0 +1,263 @@
<?php
//============================================================================
// Name : formLib.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : Provides several functions for displaying form elements
// for the ESE evaluation for students and tutors.
//============================================================================
include ('questionnaireLib.php');
// constants for the different types of message boxes
define ("MSG_ALERT", 0);
define ("MSG_WARNING", 1);
define ("MSG_DANGER", 2);
define ("MSG_SUCCESS", 3);
define ("MSG_INFO", 4);
// global variable that get toggled if a new row is created and that
// indicates if the next created row is of equal or unequal style
$isEqualRow = true;
/**
* Echos a new row division element of equal or unequal style depending
* on the last row that has been created.
*
* @param boolean $toggle Indicates if the style should be switched or if the
* new row should have same style as the previous row
*/
function CreateRowHeader($toggle = true)
{
global $isEqualRow;
if ($toggle)
$isEqualRow = !$isEqualRow;
if ($isEqualRow == true)
echo "<div class=\"row equalrow\">\n";
else
echo "<div class=\"row unequalrow\">\n";
}
/**
* Echos a new headline division with the specified text with switching
* row styles.
*
* @param string $text The text that should be displayed in the headline.
*/
function CreateHeadline($text)
{
CreateRowHeader();
echo " <div class=\"col-sm-12\">\n";
echo " <h1>" . $text . "</h1>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new section headline with the specified text and switching
* row styles.
*
* @param string $text The text that should be displayed in the section header.
*/
function CreateSectionHeader($text)
{
CreateRowHeader();
echo " <div class=\"col-sm-12\">\n";
echo " <h2>" . $text . "</h2>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new paragraph with the specified text and switching
* row styles.
*
* @param string $text The text that should be displayed in the paragraph.
*/
function CreateParagraph($text)
{
CreateRowHeader();
echo " <div class=\"col-sm-12\">\n";
echo " <p class=\"lead\">" . $text . "</p>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new paragraph with the specified link and switching
* row styles.
*
* @param string $text The text that should be displayed for the link.
* @param string $link The target to which should be linked.
*/
function CreateLink($text, $link)
{
CreateRowHeader();
echo " <div class=\"col-sm-12\">\n";
echo " <p class=\"lead\"><a href=\"" . $link . "\">" . $text . "</a></p>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new division with a labelled text box and switching row styles.
*
* @param string $label The label that should be displayed for the text box.
* @param string $id The unique id that is used to identify the text box.
* @param string $value The text that should be displayed within the text box.
* The default value is no text.
*/
function CreateTextBox($label, $id, $value = "")
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
echo " <p class=\"lead\">" . $label . "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <input class=\"form-control\" type=\"text\" id=\"". $id . "\" name=\"". $id . "\" value=\"" . $value . "\" required/>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new division with the questionnaire answer legend and switching row styles.
* Should only be used once at the top of the list of questions.
*/
function CreateLegend()
{
CreateRowHeader();
echo " <div class=\"col-sm-2 col-offset-6\"><p class=\"lead\">Bewertung:</p></div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <div class=\"row\">\n";
echo " <div class=\"col-2\"><p class=\"lead center\">++</p></div>\n";
echo " <div class=\"col-2\"><p class=\"lead center\">+</p></div>\n";
echo " <div class=\"col-2\"><p class=\"lead center\">o</p></div>\n";
echo " <div class=\"col-2\"><p class=\"lead center\">-</p></div>\n";
echo " <div class=\"col-2\"><p class=\"lead center\">--</p></div>\n";
echo " <div class=\"col-2\"><p class=\"lead center\">N/A</p></div>\n";
echo " </div>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new division with a question and six radio buttons for the possible answer.
*
* @param string $id The unique id that is used to identify the question.
* @param integer $value Indicates which answer should initially be selected.
* The default value is -1, which means no answer is selected.
* The other possible values range from 1 to 6.
*/
function CreateQuestion($question, $id, $value = -1)
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
echo " <p class=\"lead\">" . $question . "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <div class=\"row\">\n";
for ($i = 1; $i < 7; $i++)
{
echo " <div class=\"col-2\"><input class=\"form-control\" type=\"radio\" id=\"" . $id . $i . "\" name=\"" . $id . "\" value=\"" . $i . "\" required";
if ($value == $i)
echo " checked";
echo "/></div>\n";
}
echo " </div>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new division with a labelled comment box and switching row styles.
*
* @param string $label The label that should be displayed for the comment box.
* @param string $id The unique id that is used to identify the comment box.
* @param string $value The comment that should be displayed within the comment box.
* The default value is no text.
*/
function CreateCommentBox($label, $id, $value = "")
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
echo " <p class=\"lead\">" . $label . "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <textarea class=\"form-control\" id=\"" . $id . "\" name=\"" . $id . "\">" . $value . "</textarea>\n";
echo " </div>\n";
echo "</div>\n";
}
/**
* Echos a new division for the questionnaire element with the specified id.
* What kind of division is created id determined by the type of the element.
*
* @param string $id The unique id of the element that should be created.
* @param array $questionnaire The questionnaire data that is used to build the form.
* Passed by reference.
* @param array $formData The list of all form elements and their values. This should
* simply be the $_POST array that was submitted.
* Passed by reference.
*/
function CreateQuestionnaireElement($id, &$questionnaire, &$formData)
{
if (!isset($questionnaire[$id]))
return;
$entry = $questionnaire[$id];
$type = $entry[0];
$value = "";
if (isset($formData[$id]))
$value = $formData[$id];
if ($type == Q_HEADLINE)
CreateHeadline($entry[1]);
if ($type == Q_LEGEND)
CreateLegend();
else if ($type == Q_TEXTBOX)
CreateTextBox($entry[1], $id, $value);
else if ($type == Q_QUESTION)
CreateQuestion($entry[1], $id, $value);
else if ($type == Q_COMMENT)
CreateCommentBox($entry[1], $id, $value);
}
/**
* Echos a range of new divisions with switching row styles for all questions that
* the specified questionnaire data contains. Only the questions are created, nothing else.
*
* @param array $questionnaire The questionnaire data that is used to build the form.
* Passed by reference.
* @param array $formData The list of all form elements and their values. This should
* simply be the $_POST array that was submitted.
* Passed by reference.
*/
function CreateAllQuestionElements(&$questionnaire, &$formData)
{
foreach($questionnaire as $id => $entry)
{
$type = $entry[0];
if ($type != Q_QUESTION)
continue;
$value = "";
if (isset($formData[$id]))
$value = $formData[$id];
CreateQuestion($entry[1], $id, $value);
}
}
/**
* Echos a new division with switching row styles that represents a message box.
*
* @param integer $msgType The type of message box that should be created. The MSG constants
* defined at the beginning of this file should be used for this parameter.
* @param string $header The text that should be displayed in the header of the message box.
* @param string $text The text that is displayed within the message box itself.
*/
function CreateMessageBox($msgType, $header, $text)
{
CreateRowHeader(false);
echo " <div class=\"col-sm-12 col-offset-0\">\n";
echo "<div class=\"panel";
if ($msgType == MSG_WARNING)
echo " panel-warning";
else if ($msgType == MSG_DANGER)
echo " panel-danger";
else if ($msgType == MSG_SUCCESS)
echo " panel-success";
else if ($msgType == MSG_INFO)
echo " panel-info";
echo "\"><div class=\"panel-heading\"><h3 class=\"panel-title\">" . $header . "</h3></div>" . $text . "</div>";
echo " </div>\n";
echo "</div>\n";
}
?>

166
libs/keyLib.php Normal file
View file

@ -0,0 +1,166 @@
<?php
//============================================================================
// Name : keyLib.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : Provides several functions for creating and handling keys
// for the ESE evaluation for students and tutors.
//============================================================================
// Constant for the file which contains the keys, should be used by all other scripts so it can easily be changed
define ("KEYFILE", "keys/Keys.csv");
// Constants for the different key states that are possible, should always be used when altering or checking the state of a key
define ("KEYSTATE_NONEXISTENT", "nonexistent");
define ("KEYSTATE_UNISSUED", "unissued");
define ("KEYSTATE_ISSUED", "issued");
define ("KEYSTATE_ACTIVATED", "activated");
define ("KEYSTATE_USED", "used");
/**
* Generates a key from the specified hash value.
*
* @return string
*/
function GenerateKey()
{
// create a hash using a unique id based on the servers system time and the sha1 hashing algorithm
$hash = strtoupper(hash("sha1", uniqid()));
// extract the desired number of digits out of the hash to generate the key
return substr($hash, 0, 4) . "-" . substr($hash, 4, 4) . "-" . substr($hash, 8, 4) . "-" . substr($hash, 12, 4);
//return substr($hash, 0, 2) . "-" . substr($hash, 2, 2) . "-" . substr($hash, 4, 2) . "-" . substr($hash, 6, 2);
}
/**
* Generates the specified amount of keys. Be aware that this function just
* creates an array of keys with no state assigned.
*
* @param integer $amount The amount of keys that should be generated
* @return array
*/
function GenerateKeys($amount)
{
$keys = array();
for ($i = 0; $i < $amount; $i++)
{
array_push($keys, GenerateKey());
usleep(1);
}
return array_unique($keys);
}
/**
* Generates a new key file with the specified name that contains the specified
* amount of newly generated keys.
* Returns true if the key file was created successfully, otherwise false.
*
* @param integer $keyAmount The amount of keys that should be generated.
* @param string $fileName The name of the key file that should be created.
*/
function CreateKeyFile($keyAmount, $fileName)
{
$handle = fopen($fileName, 'w');
if (!$handle)
return false;
$keys = GenerateKeys($keyAmount);
$data = "Nr;Key;Status\n";
$count = count($keys) - 1;
for ($i = 0; $i < $count; $i++)
$data = $data . $i . ";" . $keys[$i] . ";" . KEYSTATE_UNISSUED. "\n";
$data = $data . $count . ";" . $keys[$count] . ";". KEYSTATE_UNISSUED;
fwrite($handle, $data);
fclose($handle);
return true;
}
/**
* Opens the file with the specified name and reads all key data that the file contains.
* The resulting data type will be an array of arrays consisting of the key and its state.
* Returns null if the key file could not be found or read.
*
* @param string $fileName The file which should be read
* @return array
*/
function ReadKeyFile($fileName)
{
if (!file_exists($fileName))
return null;
$handle = fopen($fileName, 'r');
if (!$handle)
return null;
$data = fread($handle, filesize($fileName));
$lines = explode("\n", $data);
$keyData = array();
for ($i = 1; $i < count($lines); $i++)
{
$tmp = explode(";", $lines[$i]);
array_push($keyData, array($tmp[1], $tmp[2]));
}
return $keyData;
}
/**
* Writes the specified key data to the file with the specified name.
* The data type of the $keyData should be an array of arrays consisting of the key and its state.
* Returns true if the key file was successfully written, otherwise false.
*
* @param string $fileName The name of the file to which the key data should be written.
* @param array $keyData The key data which should be written to the file. Passed by reference.
* @return boolean
*/
function WriteKeyFile($fileName, &$keyData)
{
if (!isset($fileName) || !isset($keyData))
return false;
$handle = fopen($fileName, 'w+');
if ($handle == null)
return false;
// debug code
//echo "<script type='text/javascript'>alert('file opened');</script>";
$data = "Nr;Key;Status\n";
$count = count($keyData) - 1;
for ($i = 0; $i < $count; $i++)
$data = $data . $i . ";" . $keyData[$i][0] . ";" . $keyData[$i][1] . "\n";
$data = $data . $count . ";" . $keyData[$count][0] . ";" . $keyData[$count][1];
$res = fwrite($handle, $data);
// debug Code
//if ($res == false)
// echo "<script type='text/javascript'>alert('file not written');</script>";
//else
// echo "<script type='text/javascript'>alert('file written');</script>";
fclose($handle);
return true;
}
/**
* Get the current state of the specified key which will be one of the defines
* KEYSTATE constants.
* The data type of the key data should be an array of arrays consisting of the key and its state.
*
* @param array $keyData The key data array in which the key should be found. Passed by reference.
* @param string $key The key which state should be got. Passed by reference.
* @return integer
*/
function GetKeyState(&$keyData, &$key)
{
for ($i = 0; $i < count($keyData); $i++)
if ($key == $keyData[$i][0])
return $keyData[$i][1];
return KEYSTATE_NONEXISTENT;
}
/**
* Set the state of the specified key to the specified state.
* The data type of the $keyData should be an array of arrays consisting of the key and its state.
* Returns true if the key was found within the key data and the state has been changed, otherwise false.
*
* @param array $keyData The key data array in which the key should be found. Passed by reference.
* @param string $key The key which state should be changed.
* @param integer $newState The new state of the specified key. Must be on of the KEYSTATE constants.
* @return boolean
*/
function SetKeyState(&$keyData, &$key, $newState)
{
for ($i = 0; $i < count($keyData); $i++)
if ($key == $keyData[$i][0])
{
$keyData[$i][1] = $newState;
return true;
}
return false;
}
?>

304
libs/loggingLib.php Normal file
View file

@ -0,0 +1,304 @@
<?php
//============================================================================
// Name : loggingLib.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : Provides functions for creating, reading and appending
// log files and data for the ESE evaluation for students
// and tutors.
//============================================================================
define ("STUDENTLOGFILE", "logs/ESE2013_studentLog.txt");
define ("TUTORLOGFILE", "logs/ESE2013_tutorLog.txt");
/**
* Reads all question data out of a provided log file array that has been split by new lines.
* This function should NOT BE CALLED directly, instead the ReadLogFile function should be
* used to read a log file as a whole.
* All data is written to the specified question data array and
* True is returned if a valid question data block was found, otherwise false.
*
* @param array $lines An array of string resembling the different lines of the log file. Passed by reference.
* @param integer $index The index within the lines array by which the processing should start.
* The index is passed by reference and will be incremented by this function.
* @param array $questionData An array to which all question data is written to.
* @return boolean.
*/
function ReadLogQuestionData(&$lines, &$index, &$questionData)
{
// check if the current line is a question block
// and return false if that is not the case
if (trim($lines[$index]) != "###QuestionData###")
return false;
// the index must be incremented so the next loop starts at the right line
$index++;
while($index < count($lines))
{
// if the character '#' indicates that the question data block has been finished
// so the loop is completed
if ($lines[$index][0] == "#")
break;
// split the current line by the character ';' to get the individual data elements
$tmp = explode(";", $lines[$index]);
// set identifier is the first data element and is used to init the field of the
// current question in the questionData array
$questionData[$tmp[0]] = array();
// push all other data elements in the previously created array
for ($i = 1; $i < count($tmp); $i++)
array_push($questionData[$tmp[0]], $tmp[$i]);
// increment the index to continue with the next line of the file
$index++;
}
return true;
}
/**
* Reads all tutor data out of a provided log file array that has been split by new lines.
* This function should NOT BE CALLED directly, instead the ReadLogFile function should be
* used to read a log file as a whole.
* All data is written to the specified tutor data array.
* True is returned if a valid tutor data block was found, otherwise false.
*
* @param array $lines An array of string resembling the different lines of the log file. Passed by reference.
* @param integer $index The index within the lines array by which the processing should start.
* The index is passed by reference and will be incremented by this function.
* @param array $tutorData An array to which all tutor data is written to.
* @return boolean.
*/
function ReadLogTutorData(&$lines, &$index, &$tutorData)
{
// check if the current line is a tutor data block
// and return false if that is not the case
if (trim($lines[$index]) != "###TutorData###")
return false;
// the index must be incremented so the next loop starts at the right line
$index++;
// parse the tutor data - its basically the same as the question data
while($index < count($lines))
{
// if the character '#' indicates that the tutor data block has been finished
// so the loop is completed
if ($lines[$index][0] == "#")
break;
// split the current line by the character ';' to get the individual data elements
$tmp = explode(";", $lines[$index]);
// set identifier is the first data element and is used to init the field of the
// current tutor in the tutorData array
$tutorData[$tmp[0]] = array();
// push all other data elements in the previously created array
for ($i = 1; $i < count($tmp); $i++)
array_push($tutorData[$tmp[0]], $tmp[$i]);
// increment the index to continue with the next line of the file
$index++;
}
return true;
}
/**
* Reads all comment data out of a provided log file array that has been split by new lines.
* This function should NOT BE CALLED directly, instead the ReadLogFile function should be
* used to read a log file as a whole.
* All data is written to the specified comment data array.
* True is returned if a valid comment data block was found, otherwise false.
*
* @param array $lines An array of string resembling the different lines of the log file. Passed by reference.
* @param integer $index The index within the lines array by which the processing should start.
* The index is passed by reference and will be incremented by this function.
* @param array $commentData An array to which all comment data is written to.
* @return boolean.
*/
function ReadLogCommentData(&$lines, &$index, &$commentData)
{
// check if the current line is a comment data block
// and return false if that is not the case
if (trim($lines[$index]) != "###CommentData###")
return false;
// the index must be incremented so the next loop starts at the right line
$index++;
// the current comment that gets pushed to the commentData array
// when a comment end sequence has been found
$comment = "";
// parse the comment data
while($index < count($lines))
{
// if the line start with the character '~' the line is
// interpreted as the comment end sequence and the current
// comment is pushed at the end of the comment array
// and the loop continues with a new comment
if (trim($lines[$index]) != "" && $lines[$index][0] == "~")
{
// the last character of the comment is erased because it's
// just an unnecessary new line
array_push($commentData, substr($comment, 0, -1));
$comment = "";
}
// otherwise the current comment is simply appended by the
// current line
else
$comment = $comment . $lines[$index] . "\n";
// increment the index to continue with the next line of the file
$index++;
}
return true;
}
/**
* Reads the log file with the specified name and writes all log data to the corresponding arrays.
* Returns true if the log file has been successfully written, otherwise false.
* Is guaranteed to initialize the specified log arrays, even when the log file could not be
* read in which case they will simply be empty.
*
* @param array $questionData Will be created by this function and is passed by reference.
* Is an array of arrays that consists of the unique id, the question
* and the fields for the possible response options which contain
* the number of times that option has been selected.
* @param array $tutorData Will be created by this function and is passed by reference.
* Is an array of arrays that consists of the tutor name and the
* fields for the possible response options which contain the number
* of times that option has been selected.
* @param array $commentData Will be created by this function and is passed by reference.
* Is an array of string that resemble the different comments that
* have been made.
*/
function ReadLogFile($fileName, &$questionData, &$tutorData, &$commentData)
{
// init arrays regardless of the file not being found or eventual errors
$questionData = array();
$tutorData = array();
$commentData = array();
// return if the file does not exist
if (file_exists($fileName) == false)
return false;
// open the file and get its length
$handle = fopen($fileName, 'r');
if (!$handle)
return false;
$length = filesize($fileName);
// if the length is zero, nothing can be read, so return
if ($length == 0)
return false;
// otherwise read the file and split the string at each new line
$fileData = fread($handle, $length);
$lines = explode("\n", $fileData);
// begin parsing of the file, the beginning is the second line, because the
// first should contains the disclaimer
$index = 1;
ReadLogQuestionData($lines, $index, $questionData);
ReadLogTutorData($lines, $index, $tutorData);
ReadLogCommentData($lines, $index, $commentData);
return true;
}
/**
* Writes the specified log arrays to a log file with the specified name.
* Expects data in the same format as provided by the ReadLogFile function.
* Returns true if the file was written successfully, otherwise false.
*
* @param string $fileName The name of the file to which the log data should be written.
* @param array $questionData The question data that should be written to the log file.
* @param array $tutorData The tutor data that should be written to the log file.
* @param array $commentData The list of comments that should be written to the log file. Passed by reference.
* @return boolean
*/
function WriteLogFile($fileName, &$questionData, &$tutorData, &$commentData)
{
$handle = fopen($fileName, 'w');
if (!$handle)
return false;
// write disclaimer and question data block identifier
$fileData = "# Automatically generated file - Do not Change ! #\n###QuestionData###\n";
// write all question data to the file
foreach($questionData as $id => $entry)
{
// the order is id, question and the number of times each of the six answers was picked
$fileData = $fileData . $id . ";";
for ($i = 0; $i < 6; $i++)
$fileData = $fileData . $entry[$i] . ";";
$fileData = $fileData . $entry[6] . "\n";
}
// write tutor data block identifier
$fileData = $fileData . "###TutorData###\n";
// write all tutor data to the file
foreach($tutorData as $id => $entry)
{
// the order is tutor name and the number of times each of the six answers was picked
$fileData = $fileData . $id . ";";
for ($i = 0; $i < 5; $i++)
$fileData = $fileData . $entry[$i] . ";";
$fileData = $fileData . $entry[5] . "\n";
}
// write comment data block identifier
$fileData = $fileData . "###CommentData###";
// write comment data
foreach($commentData as $comment)
// each comment is escapd by a new line containing three tilde characters
$fileData = $fileData . "\n" . $comment . "\n~~~";
// write the generated data to the file and close it
fwrite($handle, $fileData);
fclose($handle);
return true;
}
/**
* Add the question data from the specified questionnaire form data to an existing form data array.
*
* @param array $formData The list of all form elements which for most cases will simply be the
* $_POST array that has been submitted by the questionnaire form.
* Passed by reference.
* @param array $commentData The list of existing question data that will be appended by the question
* Data of the form. Passed by reference.
*/
function AddQuestionData(&$formData, &$questionData, &$questionnaire)
{
foreach($formData as $id => $value)
{
if (!isset($questionnaire[$id]))
continue;
// get the type of the element with the same id as the form element from the questionnaire
$type = $questionnaire[$id][0];
// check if the element is a question on continue with the next one if that is not hte case
if ($type != "Question")
continue;
// if there is not field for the current element in the question dsta array, create a new
// blank field containing the question and zeros for the number of times each answer was picked
if (array_key_exists($id, $questionData) == false)
$questionData[$id] = array($questionnaire[$id][1], 0, 0, 0, 0, 0, 0);
// increment the answer that was selected in the formular by one
$questionData[$id][(int)$value]++;
}
}
/**
* Add the tutor data from the specified questionnaire form data to an existing tutor data array.
*
* @param array $formData The list of all form elements which for most cases will simply be the
* $_POST array that has been submitted by the questionnaire form.
* Passed by reference.
* @param array $commentData The list of existing tutor data that will be appended by the tutor
* Data of the form. Passed by reference.
*/
function AddTutorData(&$formData, &$tutorData)
{
// get the name of the tutor from the form
$tutorName = $formData["tutorName"];
// get the selected answer of the tutorRating from the form
$tutorValue = $formData["tutorRating"];
// if there is no field for the current tutor in the tutor array, create a new
// nlank one with zeros for the number of times each answer was picked
if (array_key_exists($tutorName, $tutorData) == false)
$tutorData[$tutorName] = array(0, 0, 0, 0, 0, 0);
// increment the answer that was selected in the form by one
$tutorData[$tutorName][$tutorValue - 1]++;
}
/**
* Add the comment data from the specified questionnaire form data to an existing comment data array.
*
* @param array $formData The list of all form elements which for most cases will simply be the
* $_POST array that has been submitted by the questionnaire form.
* Passed by reference.
* @param array $commentData The list of existing comments that will be appended by the comment
* Data of the form. Passed by reference.
*/
function AddCommentData(&$formData, &$commentData)
{
// if the comment field was filled, the comment
// array is appended by the new comment
if (array_key_exists("comment", $formData) && trim($formData["comment"]) != "")
array_push($commentData, $formData["comment"]);
}
?>

77
libs/questionnaireLib.php Normal file
View file

@ -0,0 +1,77 @@
<?php
//============================================================================
// Name : questionnaireLib.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 8-2013
// Description : Provides functions for handling questionnaire text files
// for the ESE questionnaire for students and tutors.
//============================================================================
define ("STUDENT_QUESTIONNAIRE", "questionnaires/student_questionnaire.txt");
define ("TUTOR_QUESTIONNAIRE", "questionnaires/tutor_questionnaire.txt");
// Possible Questionnaire Element Types
// Should be used by all scripts when referencing them
/**
* Headline element
* Parameter:
* - Text for the Headline
*/
define ("Q_HEADLINE", "Headline");
/**
* TextBox Element
* Parameter:
* - Label for the TextBox
*/
define ("Q_TEXTBOX", "TextBox");
/**
* Legend Element
* no Parameter
*/
define ("Q_LEGEND", "Legend");
/**
* Question Element
* Parameter:
* - Label for the Question
*/
define ("Q_QUESTION", "Question");
/**
* Comment Element
* Parameter:
* - Label for the CommentBox
*/
define ("Q_COMMENT", "Comment");
/**
* Reads the questionnaire file with the specified name and returns an array
* resembling the questionnaire data. The array consists of array indexed by
* the unique ids of the elements that was specified within the questionnaire
* file. The element arrays itself consist the type of the element, and a list
* of parameters depending on the type of element.
* If the file could not be opened or read, null is returned.
*
* @param string $fileName The name of the file that should be read.
* @return array
*/
function ReadQuestionnaireFile($fileName)
{
if (!file_exists($fileName))
return null;
$handle = fopen($fileName, 'r');
if (!$handle)
return null;
$rawData = fread($handle, filesize($fileName));
$lines = explode("\n", $rawData);
$data = array();
for ($i = 1; $i < count($lines); $i++)
if (trim($lines[$i]) != "" && $lines[$i][0] != "#")
{
$tmp = explode(";", $lines[$i]);
$entry = array();
for ($j = 1; $j < count($tmp); $j++)
array_push($entry, trim($tmp[$j]));
$data[trim($tmp[0])] = $entry;
}
return $data;
}
?>

25
menu.php Normal file
View file

@ -0,0 +1,25 @@
<?php
include_once 'libs/formLib.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation - Key Control Center</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<?php
CreateHeadline("ESE Evaluation Index Page");
CreateLink("Student Evaluation Questionnaire", "index.php");
CreateLink("Tutor Evaluation Questionnaire", "tutor_questionnaire.php");
CreateLink("Key Control Panel", "keyControlPanel.php");
CreateLink("Key Overview", "keyTable.php");
CreateLink("Evaluation analysis page", "analysis.php");
CreateLink("Generate tickets for Monday", "patronGen.php");
?>
</div>
</body>
</html>

75
patronGen.php Normal file
View file

@ -0,0 +1,75 @@
<?php
//============================================================================
// Name : patronGen.php
// Author : Patrick Reipschläger, Dirk Legler
// Version : 1.0
// Date : 10-2013
// Description : For generating the group name tickets.
//============================================================================
include_once 'libs/keyLib.php';
include_once 'libs/formLib.php';
// start a session prevent sending the same post twice
// if the user refreshes the page, it will default to the
// access code screen
//session_start();
// the key file which should be edited, either the default key file or the one that was specified
$keyFile = KEYFILE;
if (isset($_GET["keyFile"]))
$keyFile = $_GET["keyFile"];
// holds the key data, generated from the key file
$keyData = ReadKeyFile($keyFile);
// the group names and rooms for Monday and their start times for Tuesday
$patrons = array(
array("Alan Turing", "INF/E001", "09:00"),
array("Edsger W. Dijkstra", "INF/E005", "09:10"),
array("Kurt Gödel", "INF/E006", "09:20"),
array("Konrad Zuse", "INF/E007", "09:30"),
array("Donald E. Knuth", "INF/E008", "09:40"),
array("John von Neumann", "INF/E009", "09:50"),
array("Tim Berners-Lee", "INF/E010", "10:00"),
array("Ada Lovelace", "BAR/213", "10:10"),
array("Peter Chen", "BAR/106", "10:20"),
array("Richard M. Stallman", "BAR/205", "10:30"),
array("Linus Torvalds", "GÖR/127", "10:40"),
array("Noam Chomsky", "SCH/A101", "10:50"),
array("Christiane Floyd", "SCH/A107", "11:00"),
array("Stephen A. Cook", "SCH/216B", "11:10"),
array("Ken Thompson", "SCH/A185", "11:20"),
array("Marc Andreesen", "SCH/A252", "11:30"),
// we need slightly more Master tickets
array("Master Inf/MInf", "INF/E023", ""),
array("Master Inf/MInf", "INF/E023", "")
);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Namenspatronzettel</title>
<link rel="stylesheet" type="text/css" href="css/print.css" />
</head>
<body>
<div class="container">
<?php
for ($i = 0; $i < count($keyData); $i++)
{
$pno = $i%(count($patrons));
echo " <div class=\"ticket\"><div class=\"tickettext\">";
echo " <div class=\"patron\">".$patrons[$pno][0]."</div>";
echo " <div class=\"room\">Tutorium in <strong>".$patrons[$pno][1]."</strong></div>";
echo " <div class=\"time\">";
// don't display start date if there is none
echo ($patrons[$pno][2]=="")?"&nbsp;":"Einschreibestart Dienstag <strong>".$patrons[$pno][2]."</strong>";
echo "</div>";
echo " <code>".$keyData[$i][0]."</code>";
echo " </div><div class=\"ticketimg\"><img src=\"css/ese-logo.png\"/></div>";
echo " <div class=\"evalink\">ESE-Evaluation unter https://ese.ifsr.de/2013/eva/</div>";
echo "</div>";
}
?>
</div>
</body>
</html>

51
patronGenTut.php Normal file
View file

@ -0,0 +1,51 @@
<?php
//============================================================================
// Name : patronGen.php
// Author : Patrick Reipschläger, Dirk Legler
// Version : 1.0
// Date : 10-2013
// Description : For generating the group name tickets.
//============================================================================
include_once 'libs/keyLib.php';
include_once 'libs/formLib.php';
// start a session prevent sending the same post twice
// if the user refreshes the page, it will default to the
// access code screen
//session_start();
// the key file which should be edited, either the default key file or the one that was specified
$keyFile = KEYFILE;
if (isset($_GET["keyFile"]))
$keyFile = $_GET["keyFile"];
// holds the key data, generated from the key file
$keyData = ReadKeyFile($keyFile);
// the group names and rooms for Monday and their start times for Tuesday
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Namenspatronzettel</title>
<link rel="stylesheet" type="text/css" href="css/print.css" />
</head>
<body>
<div class="container">
<?php
for ($i = 0; $i < count($keyData); $i++) {
if($keyData[$i][1] == KEYSTATE_UNISSUED) {
$pno = $i%(count($patrons));
echo " <div class=\"ticket\"><div class=\"tickettext\">";
echo " <div class=\"patron\">Tutor</div>";
echo " <div class=\"room\">&nbsp;</div>";
echo " <div class=\"time\">&nbsp;</div>";
echo " <code>".$keyData[$i][0]."</code>";
echo " </div><div class=\"ticketimg\"><img src=\"css/ese-logo.png\"/></div>";
echo " <div class=\"evalink\">Tutoren-Eva unter https://ese.ifsr.de/2013/eva/tut</div>";
echo "</div>";
}
}
?>
</div>
</body>
</html>

View file

@ -0,0 +1,62 @@
# ESE Evaluation Questionnaire for Students
# -----------------------------------------------
# Syntax:
# {id}; {type}; {parameters}
#
# {id} identifier for that entry.
# IMPORTANT: The id has to be UNIQUE for every entry
# {type} can be one of the following (including parameters):
# Headline = The headline that is displayed for the questionnaire. There should only be one header.
# Takes the text of the header a parameter
# TextBox = A text box where the student has to enter a value.
# Takes the label of the text box as a parameter
# Legend = The legend that describes the rating system. There should be at least on legend per form.
# Takes no parameters
# Question = A question that has to be answered by the student.
# Takes the question as a parameter.
# Comment = A box for comments (It is assumed there is only one such box)
# Takes the label of the comment box as a parameter.
#
# If fundamental changes are made (other than changing strings or adding/removing questions)
# The files 'student_questionnaire.php' and 'student_analysis' should be checked for validity,
# because they rely on some of the ids being present
#------------------------------------------------
# -- Header ---
headline; Headline; ESE 2013
# -- personal Code --
# this is important and should stay so the student can identify himself to the system and receive his cup later on
code; TextBox; Persönlicher Code:
# -- Name of the tutor --
tutorName; TextBox; Wer war dein Namenspatron? (Nachname)
# -- Legend --
legend; Legend;
# -- Begin Questions --
tutorRating; Question; Wie fandest du das Tutorium?
meetingRating; Question; Wie hat dir der Kennenlernabend gefallen?
meetingSeminar; Question; Wie war das Seminargruppentreffen?
#speechMasterDiplom; Question; Wie war der Vortrag zum Master/Diplom?
#speechMicrosoft; Question; Wie war der Microsoft-(MSDNAA)-Vortrag?
paperChaseRating; Question; Wie fandest du die Schnitzeljagd?
clubbingRating; Question; Wie hat dir die Clubwanderung gefallen?
sppechCoditermination; Question; Wie war der Vortrag zur studentischen Mitbestimmung?
speechAbroadSemester; Question; Wie war der Vortrag zum Auslandsstudium?
speechTudias; Question; Wie war der Vortrag von TUDIAS?
eseGameRating; Question; Wie hat dir das ESE-Spiel gefallen?
eseGameEvening; Question; Wie fandest du den Spieleabend?
#movieNightRating; Question; Wie hat dir der Kino-Abend gefallen?
profIntroRating; Question; Wie war die Professorenvorstellung?
#bowlingNightRating; Question; Wie war der Billiard/Bowling-Abend für dich?
testRegisterRating; Question; Wie fandest du die Übungseinschreibung?
giftBags; Question; Wie fandest du die Tüten?
ZIH; Question; Wie hilfreich fandest du die ZIH-Broschüre?
noPanic; Question; Wie hat dir die NoPanic gefallen?
inetPresenceRating; Question; Beurteilung des Internet Auftritts
generalEseRating; Question; Was hältst du von der ESE allgemein?
# -- Comments --
comment; Comment; Kommentar:;

View file

@ -0,0 +1,46 @@
ESE Evaluation Questionnaire for Tutors
# -----------------------------------------------
# Syntax:
# {id}; {type}; {parameters}
#
# {id} identifier for that entry.
# IMPORTANT: The id has to be UNIQUE for every entry
# {type} can be one of the following (including parameters):
# Headline = The headline that is displayed for the questionnaire. There should only be one header.
# Takes the text of the header a parameter
# TextBox = A text box where the student has to enter a value.
# Takes the label of the text box as a parameter
# Legend = The legend that describes the rating system. There should be at least on legend per form.
# Takes no parameters
# Question = A question that has to be answered by the student.
# Takes the question as a parameter.
# Comment = A box for comments (It is assumed there is only one such box)
# Takes the label of the comment box as a parameter.
#
# If fundamental changes are made (other than changing strings or adding/removing questions)
# The files 'student_questionnaire.php' and 'student_analysis' should be checked for validity,
# because they rely on some of the ids being present
#------------------------------------------------
# -- Header ---
headline; Headline; ESE 2013
# -- personal Code --
# this is important and should stay so the student can identify himself to the system and receive his gift later on
code; TextBox; Persönlicher Code:
# -- Legend --
legend; Legend;
# -- Begin Questions --
planingRating; Question; Wie fandest du die Planung der ESE?
tutoriumPreparation; Question; Zufriedenheit mit Tutorien und deren Vorbereitung
paperChaseRating; Question; Wie fandest du die Schnitzeljagd?
eseGameRating; Question; Wie ist das ESE-Spiel gelaufen?
inetPresenceRating; Question; Beurteilung des Internet-Auftritts
communicationRating; Question; Zusammenarbeit und Kommunikation der Helfer
testRegisterRating; Question; Ablauf der Übungseinschreibung
generalEseRating; Question; Was hältst du von der ESE allgemein?
# -- Comments --
comment; Comment; Kommentar:;

175
tutorAnalysis.php Normal file
View file

@ -0,0 +1,175 @@
<?php
//============================================================================
// Name : analysis.php
// Author : Patrick Reipschläger
// Version : 0.5
// Date : 08-2013
// Description : Analysis a ESE Evaluation log file. The file that is analysed
// may be passed as parameter with the URL.
//============================================================================
include_once 'libs/formLib.php';
include_once 'libs/questionnaireLib.php';
include_once 'libs/loggingLib.php';
include_once 'libs/chartLib.php';
// variables for the log data
$questionData;
$tutorData;
$commentData;
// Default log file is the student log file defined in 'loggingLib.php'
$logFile = STUDENTLOGFILE;
// if a logFile parameter has been passed in the URL, than that value will
// be used instead of the default value (with the added folder name)
if (isset($_GET["logFile"]))
$logFile = "logs/" . $_GET["logFile"];
// read the existing log file, if there is no existing log file, the RadLogFile
// function guarantees the initialization of the log variables, which will
// result in the same outcome as if an empty log file is read
ReadLogFile($logFile, $questionData, $tutorData, $commentData);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation Analyse</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<?php
CreateHeadline("ESE Evaluation - Data Analysis");
// if there was any question Data in the log file, display it
if (count($questionData) > 0)
{
CreateSectionHeader("Question Evaluation");
CreateLegend();
foreach ($questionData as $question)
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
// The question itself
echo " <p class=\"lead\"><span>" . $question[0];
//average
echo "</span><span style=\"float:right;\">⌀" .
round(
($question[1]+2*$question[2]+3*$question[3]+4*$question[4]+5*$question[5])
/(array_sum(array_slice($question,1,5))),
2)
. "</span>\n";
echo "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <div class=\"row\">\n";
$width = 800;
$height = 300;
//find max of answers to set max of x-axis, max of y-axis is always seven, because there are six possibilities to answer
$values = $question;
array_shift($values);
$maxX = max($values)+1;
$maxY = 7;
$img = CreateImage($width, $height);
// the amount of answers for the different options and a nice group of bars
for ($i = 1; $i < 7; $i++)
{
echo " <div class=\"col-2\"><p class=\"lead center\">" . $question[$i] . "</p></div>\n";
$color = ImageColorAllocate($img, 255, 80+2*$question[$i], 0);
DrawBar($img, $question[$i], $maxX, $i+1, $maxY, $question[$i], $color);
}
//finish image and save it
$caption = array("N/A","--","-", "0", "+", "++");
DrawCoords($img, $maxX, $maxY, $caption);
$file=str_replace("?", "", str_replace(" ", "", $question[0]));
ImagePNG($img,"question".$file.".png");
ImageDestroy($img);
echo " </div>\n";
echo " </div>\n";
echo " <div class=\"col-sm-3\">\n";
echo " </div>\n";
echo " <div class=\"col-sm-9\">\n";
echo " <img src=\"question".$file.".png\" class=\"lead center\">";
echo " </div>\n";
echo "</div>\n";
}
}
// if there was any tutor Data in the log file, display it
if (count($tutorData) > 0)
{
CreateSectionHeader("Tutor Evaluation");
CreateLegend();
foreach ($tutorData as $tutorName => $tutor)
{
CreateRowHeader();
echo " <div class=\"col-sm-8\">\n";
// the name of the tutor
echo " <p class=\"lead\"><span>" . $tutorName . "</span>\n";
//average
echo "<span style=\"float:right;\">⌀" .
round(
($tutor[0]+2*$tutor[1]+3*$tutor[2]+4*$tutor[3]+5*$tutor[4])
/(array_sum($tutor)-$tutor[5]), 2)
. "</span>\n";
echo "</p>\n";
echo " </div>\n";
echo " <div class=\"col-sm-4\">\n";
echo " <div class=\"row\">\n";
$width = 800;
$height = 300;
//find max of answers to set max of x-axis, max of y-axis is always seven, because there are six possibilities to answer
$maxX = max($tutor)+1;
$maxY = 7;
$img = CreateImage($width, $height);
// the amount of answers for the different options and a picture
for ($i = 0; $i < 6; $i++)
{
echo " <div class=\"col-2\"><p class=\"lead center\">" . $tutor[$i] . "</p></div>\n";
$color = ImageColorAllocate($img, 255, 80+2*$tutor[$i], 0);
DrawBar($img, $tutor[$i], $maxX, $i+2, $maxY, $tutor[$i], $color);
}
//finish image and save it
$caption = array("N/A","--","-", "0", "+", "++");
DrawCoords($img, $maxX, $maxY, $caption);
$file = str_replace(" ", "", $tutorName);
ImagePNG($img,"tutor".$file.".png");
ImageDestroy($img);
echo " </div>\n";
echo " </div>\n";
echo " <div class=\"col-sm-3\">\n";
echo " </div>\n";
echo " <div class=\"col-sm-9\">\n";
echo " <img src=\"tutor".$file.".png\" class=\"lead center\">";
echo " </div>\n";
echo "</div>\n";
}
}
// if there was any comment Data in the log file, display it
if (count($commentData) > 0)
{
CreateSectionHeader("Comments");
foreach ($commentData as $comment)
// replace all new lines with html breaks to properly display multi-line comments
CreateParagraph(str_replace("\n", "<br/>\n", $comment));
}
?>
</div>
</body>
</html>

100
tutor_questionnaire.php Normal file
View file

@ -0,0 +1,100 @@
<?php
//============================================================================
// Name : tutor_questionnaire.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Description : The form that tutors have to fill in
// for the ESE evaluation.
//============================================================================
include_once 'libs/formLib.php';
include_once 'libs/questionnaireLib.php';
include_once 'libs/keyLib.php';
include_once 'libs/loggingLib.php';
// indicates if an error occurred and what error
$error = 0;
// Determines if a message box is shown, and what type of message box is shown
$keyState = "";
// load the questionnaire data
$questionnaire = ReadQuestionnaireFile(TUTOR_QUESTIONNAIRE);
// if the variable is set, the form has been posted to itself and can be validated
if (isset($_POST["submit"]))
{
// read the key
$keyData = ReadKeyFile(KEYFILE);
$keyState = GetKeyState($keyData, $_POST["code"]);
if ($keyState == KEYSTATE_ISSUED)
{
// variables for the log data, tutor data is not needed but must be present
$questionData;
$tutorData;
$commentData;
// read the existing log file, if there is no existing log file, the RadLogFile
// function guarantees the initialization of the log variables, which will
// result in the same outcome as if an empty log file is read
ReadLogFile(TUTORLOGFILE, $questionData, $tutorData, $commentData);
// add the data of the form to the existing log data
AddQuestionData($_POST, $questionData, $questionnaire);
AddCommentData($_POST, $commentData);
// write the altered data back to the log file, only change the state of the key,
// if that action was successful
if (WriteLogFile(TUTORLOGFILE, $questionData, $tutorData, $commentData))
{
SetKeyState($keyData, $_POST["code"], KEYSTATE_ACTIVATED);
WriteKeyFile(KEYFILE, $keyData);
}
// otherwise set the error flag
else
$error = 1;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ESE Evaluation für Studenten</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="container">
<form action="" method="post">
<?php
CreateQuestionnaireElement("headline", $questionnaire, $_POST);
if ($error)
CreateMessageBox(MSG_DANGER, "Achtung:", "Deine Evaluation konnte aufgrund eines internen Fehlersl eider nicht erfolgreich bearbeitet werden.<br/>Bitte versuch es später nocheinmal oder wende dich an einen der Verantwortlichen.");
else
CreateKeyMessageBox($keyState);
CreateQuestionnaireElement("code", $questionnaire, $_POST);
CreateQuestionnaireElement("legend", $questionnaire, $_POST);
CreateAllQuestionElements($questionnaire, $_POST);
CreateQuestionnaireElement("comment", $questionnaire, $_POST);
?>
<div class="row">
<input class="form-control" type="submit" name="submit" value="Absenden"/>
</div>
</form>
</div>
</body>
</html>
<?php
function CreateKeyMessageBox($keyState)
{
switch($keyState)
{
case KEYSTATE_NONEXISTENT: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code konnte nicht verifiziert werden. Bitte überprüfe deine Eingabe."); break;
case KEYSTATE_UNISSUED: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code ist ungültig."); break;
case KEYSTATE_ISSUED: CreateMessageBox(MSG_SUCCESS, "Danke!", "Der eigebene Code ist korrekt. Dein Fragebogen wurde erfolgreich übermittelt und du bist nun zum Emfang einer ESE-Tasse berechtigt."); break;
case KEYSTATE_ACTIVATED: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code ist wurde bereits zum ausfüllen eines Fragebogens verwendet. Es darf pro Student nur ein Fragebogen ausgefüllt werden."); break;
case KEYSTATE_USED: CreateMessageBox(MSG_DANGER, "Achtung!", "Der angegebene Code ist wurde bereits eingelöst. Es darf pro Student nur eine ESE-Tasse ausgegeben werden."); break;
}
}
?>