43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
|
<!DOCTYPE html>
|
||
|
|
||
|
<?php
|
||
|
|
||
|
//error_reporting(E_ALL);
|
||
|
define("FILENAME", "questions_file.nemubot");
|
||
|
|
||
|
|
||
|
include("Question.class.php");
|
||
|
include("QuestionsFile.class.php");
|
||
|
|
||
|
if (isset ($_POST['send']))
|
||
|
{
|
||
|
//Gets parameters: course, question and answers
|
||
|
$course = "";
|
||
|
$answers = array();
|
||
|
foreach ($_POST as $key => $value)
|
||
|
{
|
||
|
if ($key == "question")
|
||
|
$question = $value;
|
||
|
else if ($key == "course")
|
||
|
$course = $value;
|
||
|
else if (preg_match("#^answer#", $key) && $key != "")
|
||
|
$answers[] = $value;
|
||
|
}
|
||
|
|
||
|
//Check we have at least a question and an answer
|
||
|
if (empty($question))
|
||
|
die("Veuillez indiquer une question !");
|
||
|
else if (count($answers) <= 0)
|
||
|
die("Veuillez indiquer au moins une réponse correcte !");
|
||
|
else
|
||
|
{
|
||
|
$file = new QuestionsFile('questions.xml');
|
||
|
$id = POST_['id'];
|
||
|
$quest = $file->get_question($id);
|
||
|
$quest->setCourse($couse);
|
||
|
$quest->setQuestion($question);
|
||
|
$quest->setAnswer($answers);
|
||
|
|
||
|
// Is this enought to change the xml ?
|
||
|
$file->save();
|
||
|
?>
|