This repository has been archived on 2020-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
nemubot-askweb/questions.php

101 lines
2.4 KiB
PHP
Raw Normal View History

2012-05-22 09:18:26 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
</head>
2012-05-18 19:56:57 +00:00
2012-05-22 09:18:26 +00:00
<body>
2012-05-22 14:05:46 +00:00
<article id="validate">
<h2>Merci de votre participation!</h2>
<p>
Votre question a bien été ajoutée à la liste.<br/>
Elle doit maintenant être confirmée. Un email a été envoyé
à l'un des membres du chan pour qu'il valide votre question.
</p>
<p>
Vous pouvez proposer de nouvelles questions en cliquant
sur le lien ci-dessous.<br/>
<a href="index.html">Proposer une nouvelle question</a>
</p>
</article>
<p>
<h3>La partie ci dessous est uniquement réservée au debug</h3>
Merci de ne pas en tenir compte
</p>
2012-05-22 09:18:26 +00:00
<?php
error_reporting(E_ALL);
2012-05-18 20:11:42 +00:00
define("FILENAME", "questions_file.nemubot");
2012-05-22 09:18:26 +00:00
include("Question.class.php");
include("QuestionsFile.class.php");
2012-05-18 19:56:57 +00:00
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))
$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
{
$quest = Question::new_Question($question, $answers, $course);
$quest->print_test();
2012-05-18 19:56:57 +00:00
// @TODO: Create/Load a QuestionFile and add the question (it must be unique)
2012-05-22 08:00:59 +00:00
$file = new QuestionsFile('questions.xml');
$file->add_question($quest);
$file->save();
2012-05-22 07:38:37 +00:00
2012-05-22 14:05:46 +00:00
echo "<br/>";
echo "<br/> C'est ici pour valider";
echo "<br/>"
. "http://178.170.101.82/~Cccompany/nemubot_askweb/validation.php?id="
. $quest->getId();
// @TODO: Find a validator (from the list of previous senders for example?)
2012-05-22 07:38:37 +00:00
// @TODO: Update the question and save the file
2012-05-22 07:38:37 +00:00
// @TODO: Send mail to the selected validator
2012-05-21 15:10:40 +00:00
2012-05-22 14:05:46 +00:00
/* This code works, perhaps should be placed in a method in Question class?
$to = "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))
{
echo ("Email sent");
}
else
echo ("Error with the email");
//*/
}
2012-05-18 19:56:57 +00:00
}
else
header("Location: ./");
2012-05-18 19:56:57 +00:00
?>
2012-05-22 09:18:26 +00:00
</body>
</html>