Fix simples errors in the two classes
JavaScript now generates inputs with a unique name Add todo in questions.php and manage multiple answers; start using Question class
This commit is contained in:
parent
91d2b8471c
commit
48a77a0d10
4 changed files with 76 additions and 35 deletions
|
|
@ -2,24 +2,46 @@
|
|||
|
||||
define("FILENAME", "questions_file.nemubot");
|
||||
|
||||
include("Question.class.php");
|
||||
|
||||
if (isset ($_POST['send']))
|
||||
{
|
||||
if (empty($_POST['question']) || empty($_POST['answer']))
|
||||
//Gets parameters: course, question and answers
|
||||
$course = "";
|
||||
$answers = array();
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
echo "Il manque la question ou la réponse !";
|
||||
if ($key == "question")
|
||||
$question = $value;
|
||||
else if ($key == "course")
|
||||
$course = $value;
|
||||
else if (preg_match("#^answer#", $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
|
||||
{
|
||||
$question = $_POST['question'];
|
||||
$answer = $_POST['answer'];
|
||||
$quest = Question::new_Question($question, $answers, $course);
|
||||
$quest->print_test();
|
||||
|
||||
echo 'La question est : ' . $question . "<br/>";
|
||||
echo 'La réponse est : ' . $answer;
|
||||
// @TODO: Create/Load a QuestionFile and add the question (it must be unique)
|
||||
|
||||
// @TODO: Find a validator (from the list of previous senders for example?)
|
||||
|
||||
// @TODO: Update the question and save the file
|
||||
|
||||
// @TODO: Send mail to the selected validator
|
||||
|
||||
/* This code works, perhaps should be placed in a method in Question class?
|
||||
$to = "bertrand.cournaud@gmail.com";
|
||||
$subject = "Nemubot";
|
||||
$message = "Ceci est un test";
|
||||
$headers = "From: bertrand.cournaud@gmail.com";
|
||||
$subject = "[Nemubot] Validation d'une question";
|
||||
$headers = "From: Nemubot <bot@nemunai.re>";
|
||||
$message = "Bonjour,\n";
|
||||
|
||||
if (mail($to, $subject, $message, $headers))
|
||||
{
|
||||
|
|
@ -27,7 +49,10 @@ if (isset ($_POST['send']))
|
|||
}
|
||||
else
|
||||
echo ("Error with the email");
|
||||
//*/
|
||||
}
|
||||
}
|
||||
else
|
||||
header("Location: ./");
|
||||
|
||||
?>
|
||||
|
|
|
|||
Reference in a new issue