Add new pages
This commit is contained in:
parent
7d249967d6
commit
279f23e325
2 changed files with 161 additions and 0 deletions
43
validateChangeQuestion.php
Normal file
43
validateChangeQuestion.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<!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();
|
||||
?>
|
||||
Reference in a new issue