3
0
Fork 0
mirror of https://github.com/fsr/eseeva synced 2025-04-28 09:28:31 +02:00

upgrades to sqlite, first step towards #2

This commit is contained in:
Lucas Woltmann 2017-01-25 18:24:31 +01:00
parent 134775b2d7
commit fe8a426334
9 changed files with 515 additions and 495 deletions

View file

@ -1,9 +1,9 @@
<?php
//============================================================================
// Name : student_questionnaire.php
// Author : Patrick Reipschläger
// Version : 1.0
// Date : 08-2013
// Author : Patrick Reipschläger, Lucas Woltmann
// Version : 2.0
// Date : 01-2017
// Description : The form that students have to fill in
// for the ESE evaluation.
//============================================================================
@ -11,7 +11,7 @@
include_once 'libs/formLib.php';
include_once 'libs/questionnaireLib.php';
include_once 'libs/keyLib.php';
include_once 'libs/loggingLib.php';
include_once 'libs/dbLib.php';
// indicates if an error occurred and what error
$error = 0;
@ -23,34 +23,29 @@
// 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"]);
// read the key state
$keyState = GetKeyState(KEYFILE, $_POST["code"]);
if ($keyState == KEYSTATE_ISSUED)
{
// variables for the log data
$questionData;
$tutorData;
$questionData = array();
$tutorData = array();
$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
// add the data of the form to the legacy data structure
AddQuestionData($_POST, $questionData, $questionnaire);
AddTutorData($_POST, $tutorData);
AddCommentData($_POST, $commentData);
// quick ~~fix~~ hack
mail("eseeva@ifsr.de", "ESEEVA2016POST", serialize($_POST));
// mail("eseeva@ifsr.de", "ESEEVA2016POST", serialize($_POST));
// write the altered data back to the log file, only change the state of the key,
// write the new data back to the database, only change the state of the key,
// if that action was successful
if (WriteLogFile(STUDENTLOGFILE, $questionData, $tutorData, $commentData))
// Uses $student=1 to imply that a student answered the questionnaire.
if (WriteLogDatabase(LOGDB, 1, $questionData, $tutorData, $commentData, $_POST["code"]))
{
SetKeyState($keyData, $_POST["code"], KEYSTATE_ACTIVATED);
if (!WriteKeyFile(KEYFILE, $keyData))
if (!SetKeyState(KEYFILE, $_POST["code"], KEYSTATE_ACTIVATED))
{
$error = 1;
}