Add classes to abstract Users and Courses
Can refuse a question (email the author) Can modify question before validation
This commit is contained in:
parent
6e9554e2f2
commit
42fec70edf
14 changed files with 667 additions and 401 deletions
|
@ -53,6 +53,16 @@ class Course
|
||||||
return $courses;
|
return $courses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getCourse($id, $filename = "courses.xml")
|
||||||
|
{
|
||||||
|
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
|
if (@$treeXML->load($filename))
|
||||||
|
return new Course($treeXML->getElementById($id));
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static function setCourses($courses, $filename = "courses.xml")
|
public static function setCourses($courses, $filename = "courses.xml")
|
||||||
{
|
{
|
||||||
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
include_once("User.class.php");
|
||||||
|
include_once("Course.class.php");
|
||||||
|
|
||||||
class Question
|
class Question
|
||||||
{
|
{
|
||||||
private $id;
|
private $id;
|
||||||
|
@ -9,6 +12,7 @@ class Question
|
||||||
private $added_time;
|
private $added_time;
|
||||||
private $validated = false;
|
private $validated = false;
|
||||||
private $validator = "";
|
private $validator = "";
|
||||||
|
private $writer = "";
|
||||||
|
|
||||||
public function __construct($node = null)
|
public function __construct($node = null)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +23,7 @@ class Question
|
||||||
if (intval($node->getAttribute("validated")))
|
if (intval($node->getAttribute("validated")))
|
||||||
$this->validated = true;
|
$this->validated = true;
|
||||||
$this->validator = $node->getAttribute("validator");
|
$this->validator = $node->getAttribute("validator");
|
||||||
|
$this->writer = $node->getAttribute("writer");
|
||||||
$this->question = $node->getAttribute("question");
|
$this->question = $node->getAttribute("question");
|
||||||
$this->course = $node->getAttribute("course");
|
$this->course = $node->getAttribute("course");
|
||||||
|
|
||||||
|
@ -50,20 +55,19 @@ class Question
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function regen_id()
|
|
||||||
{
|
|
||||||
$this->id = md5(time().$this->question.$this->validator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set_validator($val)
|
public function set_validator($val)
|
||||||
{
|
{
|
||||||
$this->validator = $val;
|
$this->validator = $val->getId();
|
||||||
$this->regen_id();
|
}
|
||||||
|
|
||||||
|
public function get_writer()
|
||||||
|
{
|
||||||
|
return User::getUser($this->writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_validator()
|
public function get_validator()
|
||||||
{
|
{
|
||||||
return $this->validator;
|
return User::getUser($this->validator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function print_test()
|
public function print_test()
|
||||||
|
@ -99,6 +103,7 @@ class Question
|
||||||
$qnode->setAttribute("addedtime", $this->added_time);
|
$qnode->setAttribute("addedtime", $this->added_time);
|
||||||
$qnode->setAttribute("validated", intval($this->validated));
|
$qnode->setAttribute("validated", intval($this->validated));
|
||||||
$qnode->setAttribute("validator", $this->validator);
|
$qnode->setAttribute("validator", $this->validator);
|
||||||
|
$qnode->setAttribute("writer", $this->writer);
|
||||||
$qnode->setAttribute("course", $this->course);
|
$qnode->setAttribute("course", $this->course);
|
||||||
$qnode->setAttribute("question", $this->question);
|
$qnode->setAttribute("question", $this->question);
|
||||||
|
|
||||||
|
@ -111,6 +116,9 @@ class Question
|
||||||
public function validated()
|
public function validated()
|
||||||
{
|
{
|
||||||
$this->validated = true;
|
$this->validated = true;
|
||||||
|
|
||||||
|
//Return to normal ID
|
||||||
|
$this->getNormalId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId()
|
public function getId()
|
||||||
|
@ -118,6 +126,18 @@ class Question
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getValidatorId()
|
||||||
|
{
|
||||||
|
$this->id = md5($this->added_time.$this->validator);
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNormalId()
|
||||||
|
{
|
||||||
|
$this->id = md5($this->added_time.$this->writer);
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
public function isValidated()
|
public function isValidated()
|
||||||
{
|
{
|
||||||
return $this->validated;
|
return $this->validated;
|
||||||
|
@ -125,12 +145,12 @@ class Question
|
||||||
|
|
||||||
public function getCourse()
|
public function getCourse()
|
||||||
{
|
{
|
||||||
return $this->course;
|
return Course::getCourse($this->course);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCourse($course)
|
public function setCourse($course)
|
||||||
{
|
{
|
||||||
$this->course = $course;
|
$this->course = $course->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQuestion()
|
public function getQuestion()
|
||||||
|
@ -148,17 +168,31 @@ class Question
|
||||||
return $this->answers;
|
return $this->answers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAnswersMail()
|
||||||
|
{
|
||||||
|
$str = "";
|
||||||
|
foreach($this->answers as $a)
|
||||||
|
$str .= " * ".$a."\n";
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_writer($writer)
|
||||||
|
{
|
||||||
|
$this->writer = $writer->getId();
|
||||||
|
}
|
||||||
|
|
||||||
public function setAnswer($answers)
|
public function setAnswer($answers)
|
||||||
{
|
{
|
||||||
|
$this->answers = array();
|
||||||
if (!empty($answers))
|
if (!empty($answers))
|
||||||
{
|
{
|
||||||
if (is_array($answers))
|
if (is_array($answers))
|
||||||
{
|
{
|
||||||
foreach ($answers as $ans)
|
foreach ($answers as $ans)
|
||||||
$q->answers[] = $ans;
|
$this->answers[] = $ans;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$q->answers[] = $answers;
|
$this->answers[] = $answers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
181
User.class.php
Normal file
181
User.class.php
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
private $id;
|
||||||
|
private $username;
|
||||||
|
private $password;
|
||||||
|
private $email;
|
||||||
|
private $registerdate;
|
||||||
|
private $validated = false;
|
||||||
|
|
||||||
|
public function __construct($node = null)
|
||||||
|
{
|
||||||
|
if (isset($node))
|
||||||
|
{
|
||||||
|
$this->id = $node->getAttribute("xml:id");
|
||||||
|
$this->registerdate = $node->getAttribute("registerdate");
|
||||||
|
if (intval($node->getAttribute("validated")))
|
||||||
|
$this->validated = true;
|
||||||
|
$this->username = $node->getAttribute("username");
|
||||||
|
$this->password = $node->getAttribute("password");
|
||||||
|
$this->email = $node->getAttribute("email");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function new_User($email, $username = "", $password = null)
|
||||||
|
{
|
||||||
|
$u = new User();
|
||||||
|
$u->id = sha1($email);
|
||||||
|
$u->registerdate = time();
|
||||||
|
$u->email = $email;
|
||||||
|
$u->username = $username;
|
||||||
|
if (isset($password))
|
||||||
|
$this->password = getPassword($username, $password);
|
||||||
|
|
||||||
|
return $u;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getUsers($filename = "users.xml")
|
||||||
|
{
|
||||||
|
$users = array();
|
||||||
|
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
|
if (@$treeXML->load($filename))
|
||||||
|
{
|
||||||
|
$nodes = $treeXML->getElementsByTagName("user");
|
||||||
|
foreach($nodes as $node)
|
||||||
|
{
|
||||||
|
$u = new User($node);
|
||||||
|
$users[$u->id] = $u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getValidatedUsers($filename = "users.xml")
|
||||||
|
{
|
||||||
|
$users = array();
|
||||||
|
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
|
if (@$treeXML->load($filename))
|
||||||
|
{
|
||||||
|
$nodes = $treeXML->getElementsByTagName("user");
|
||||||
|
foreach($nodes as $node)
|
||||||
|
{
|
||||||
|
$u = new User($node);
|
||||||
|
if ($u->isValidated())
|
||||||
|
$users[] = $u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getUser($id, $filename = "users.xml")
|
||||||
|
{
|
||||||
|
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
|
if (@$treeXML->load($filename))
|
||||||
|
return new User($treeXML->getElementById($id));
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setUsers($users, $filename = "users.xml")
|
||||||
|
{
|
||||||
|
$treeXML = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
$root_node = $treeXML->createElement("users");
|
||||||
|
$treeXML->appendChild($root_node);
|
||||||
|
|
||||||
|
foreach ($users as $user)
|
||||||
|
$root_node->appendChild($user->to_xml($treeXML));
|
||||||
|
|
||||||
|
$treeXML->formatOutput = true;
|
||||||
|
$treeXML->save($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function to_xml($root)
|
||||||
|
{
|
||||||
|
$qnode = $root->createElement("user");
|
||||||
|
|
||||||
|
$qnode->setAttribute("xml:id", $this->id);
|
||||||
|
$qnode->setAttribute("username", $this->username);
|
||||||
|
$qnode->setAttribute("password", intval($this->password));
|
||||||
|
$qnode->setAttribute("email", $this->email);
|
||||||
|
$qnode->setAttribute("registerdate", $this->registerdate);
|
||||||
|
$qnode->setAttribute("validated", $this->validated);
|
||||||
|
|
||||||
|
return $qnode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canConnect($password)
|
||||||
|
{
|
||||||
|
$hash = getPassword($this->username, $password);
|
||||||
|
|
||||||
|
return ($hash == $this->password);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPassword($username, $password)
|
||||||
|
{
|
||||||
|
return hash("whirlpool", $username.':'.$password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_validated($validated)
|
||||||
|
{
|
||||||
|
$this->validated = $validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsername()
|
||||||
|
{
|
||||||
|
return $this->username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail()
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isValidated()
|
||||||
|
{
|
||||||
|
return $this->validated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
$us = User::getUsers();
|
||||||
|
|
||||||
|
foreach($us as $u)
|
||||||
|
$u->set_validated(true);
|
||||||
|
User::setUsers($us);
|
||||||
|
//*/
|
||||||
|
/*
|
||||||
|
$us = User::getUsers();
|
||||||
|
|
||||||
|
$u = User::new_User("bertrand@cournaud.fr", "Cccompany");
|
||||||
|
$us[] = $u;
|
||||||
|
|
||||||
|
$u = User::new_User("colona@ycc.fr", "colona");
|
||||||
|
$us[] = $u;
|
||||||
|
|
||||||
|
$u = User::new_User("ircquizz@23.tf", "maxence23");
|
||||||
|
$us[] = $u;
|
||||||
|
|
||||||
|
$u = User::new_User("ircquizz@p0m.fr", "nemunaire");
|
||||||
|
$us[] = $u;
|
||||||
|
|
||||||
|
$u = User::new_User("quentin.courtel@epita.fr", "Bob");
|
||||||
|
$us[] = $u;
|
||||||
|
|
||||||
|
$u = User::new_User("ghost_anarky@hotmail.com", "Anarky");
|
||||||
|
$us[] = $u;
|
||||||
|
|
||||||
|
User::setUsers($us);
|
||||||
|
//*/
|
||||||
|
?>
|
|
@ -1,117 +1,101 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html><html>
|
||||||
|
<head>
|
||||||
<script language="javascript">
|
<meta charset="utf-8">
|
||||||
var nbAnswer = 1;
|
<link rel="Stylesheet" href="style.css">
|
||||||
|
<title>Every Questions (BETA)</title>
|
||||||
|
<script type="text/javascript">
|
||||||
function add()
|
function add()
|
||||||
{
|
{
|
||||||
var element = document.createElement("input");
|
var element = document.createElement("input");
|
||||||
|
|
||||||
element.setAttribute("type", "text");
|
element.setAttribute("type", "text");
|
||||||
element.setAttribute("id", "answer");
|
element.setAttribute("id", "answer");
|
||||||
element.setAttribute("name", "answer" + nbAnswer);
|
element.setAttribute("name", "answer" + nbAnswer);
|
||||||
nbAnswer++;
|
nbAnswer++;
|
||||||
element.setAttribute("placeholder", "Nouvelle réponse");
|
element.setAttribute("placeholder", "Nouvelle réponse");
|
||||||
|
|
||||||
var foo = document.getElementById("answerList");
|
var foo = document.getElementById("answerList");
|
||||||
foo.appendChild(element);
|
foo.appendChild(element);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<a href="http://www.h2g2.com" target="_blank">
|
||||||
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
||||||
|
</a>
|
||||||
|
<h1>Nemubot Questions (BETA)</h1>
|
||||||
|
</header>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include("Question.class.php");
|
include("Question.class.php");
|
||||||
include("QuestionsFile.class.php");
|
include("QuestionsFile.class.php");
|
||||||
|
|
||||||
|
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
|
|
||||||
$fileQ = new QuestionsFile("questions.xml");
|
$fileQ = new QuestionsFile("questions.xml");
|
||||||
$question = $fileQ->get_question($id);
|
$question = $fileQ->get_question($id);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf8" />
|
|
||||||
<link rel="Stylesheet" href="style.css" />
|
|
||||||
<title>Every AskWeb (BETA)</title>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<div id="main_title">
|
|
||||||
<a href="http://www.h2g2.com" target="_blank">
|
|
||||||
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
|
||||||
</a>
|
|
||||||
<h1>Nemubot AskWeb (BETA)</h1>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<section id="introduction">
|
<section id="introduction">
|
||||||
<article>
|
<article>
|
||||||
<h2>Dernière chance pour changer d'avis</h2>
|
<h2>Dernière chance pour changer d'avis</h2>
|
||||||
Voici le rappel de votre question :<br/><br/>
|
<p>
|
||||||
<?php $question->print_test(); ?>
|
<strong>Cours concerné :</strong> <?php echo $question->getCourse()->getName(); ?><br><br>
|
||||||
|
<strong>Question posée :</strong> <?php echo $question->getQuestion(); ?><br><br>
|
||||||
Vous avez la possibilité de modifier votre question avant de la
|
<strong>Réponses valides exhaustives :</strong>
|
||||||
faire valider. Faites vous plaisir.<br/>
|
</p>
|
||||||
|
<?php
|
||||||
|
echo "<ul>";
|
||||||
|
foreach($question->getAnswer() as $a)
|
||||||
|
echo "<li>".$a."</li>";
|
||||||
|
echo "</ul>";
|
||||||
|
?>
|
||||||
|
<p>
|
||||||
|
Vous avez la possibilité de modifier votre question avant de la
|
||||||
|
faire valider.<br>
|
||||||
|
Faites vous plaisir.
|
||||||
|
</p>
|
||||||
</article>
|
</article>
|
||||||
|
<article>
|
||||||
<article>
|
<h2>Modifier la question ...</h2>
|
||||||
<h2>Modifier la question... (cette partie ne fonctionn pas ...</h2>
|
<form method="post" action="questions.php">
|
||||||
<form id="formulaire" method="post" action="validateChangeQuestion.php">
|
<input type="hidden" name="id" value=<?php echo $question->getId(); ?>>
|
||||||
|
<input type="hidden" name="email" value=<?php echo $question->get_writer()->getEmail(); ?>>
|
||||||
<input type="hidden" name="id" id="id" value=<?php echo $question->getId() ?> />
|
<label for="course">De quelle matière s'agit-il ?</label><br>
|
||||||
|
|
||||||
<label for="course">De quelle matière s'agit-il ?</label><br/>
|
|
||||||
|
|
||||||
<select name="course" id="course">
|
<select name="course" id="course">
|
||||||
|
<?php
|
||||||
|
include_once("Course.class.php");
|
||||||
|
$cs = Course::getCourses();
|
||||||
|
$qc = $question->getCourse();
|
||||||
|
|
||||||
<optgroup label="Cours communs">
|
foreach($cs as $c)
|
||||||
<option value="SGBD">SGBD</option>
|
{
|
||||||
<option value="CompressionDeDonnées">
|
if ($qc->getId() == $c->getId())
|
||||||
Compression de données</option>
|
print '<option selected="selected" value="'.$c->getId().'">'.$c->getName().'</option>';
|
||||||
<option value="ProtocolesDeLiaisons">
|
else
|
||||||
Protocoles De Liaisons</option>
|
print '<option value="'.$c->getId().'">'.$c->getName().'</option>';
|
||||||
<option value="TYLA">TYLA</option>
|
}
|
||||||
<option value="ActiveDirectory">
|
|
||||||
Active Directory</option>
|
|
||||||
<option value="GrapheFlotReseau">
|
|
||||||
Graphes Flots Reseaux</option>
|
|
||||||
</optgroup>
|
|
||||||
|
|
||||||
<optgroup label="Electif">
|
?>
|
||||||
<option value="RXAN">RXAN</option>
|
|
||||||
</optgroup>
|
|
||||||
|
|
||||||
<optgroup label="TDA">
|
|
||||||
<option value="TYLA">TYLA</option>
|
|
||||||
<option value="CCMP">CCMP</option>
|
|
||||||
<option value="SLPS">SLPS</option>
|
|
||||||
<option value="FMPS">FMPS</option>
|
|
||||||
</optgroup>
|
|
||||||
|
|
||||||
<optgroup label="MTM">
|
|
||||||
<option value="ITIL">ITIL</option>
|
|
||||||
<option value="Qualite">Qualité</option>
|
|
||||||
</optgroup>
|
|
||||||
|
|
||||||
<optgroup label="Autre">
|
|
||||||
<option value="Autre" selected>Autre</option>
|
|
||||||
</optgroup>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<p id="questionPart">
|
<p id="questionPart">
|
||||||
<label id="q" for="question">
|
<label id="q" for="question">Quelle est votre question ? </label><br>
|
||||||
Quelle est votre question ? </label><br/>
|
<textarea id="question" name="question" rows="3" cols="70"><?php echo nl2br(htmlentities($question->getQuestion())); ?></textarea>
|
||||||
<textarea id="question" name="question"
|
|
||||||
rows="3" cols="70"><?php echo $question->getQuestion()?>
|
|
||||||
</textarea>
|
|
||||||
</p>
|
</p>
|
||||||
<p id="answerList">
|
<p id="answerList">
|
||||||
<label for="answer">Quelle est la réponse ? </label><br/>
|
<label for="answer">Quelle est la réponse ?</label><br>
|
||||||
<input id="answer" name="answer0" type="text" />
|
<?php
|
||||||
|
$max = 1;
|
||||||
|
foreach($question->getAnswer() as $k => $a)
|
||||||
|
{
|
||||||
|
echo '<input type="text" name="answer'.$k.'" value="'.$a.'">';
|
||||||
|
if ($max < $k)
|
||||||
|
$max = $k;
|
||||||
|
}
|
||||||
|
print '<script type="text/javascript">var nbAnswer = '.($max+1).';</script>';
|
||||||
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -121,26 +105,23 @@ $question = $fileQ->get_question($id);
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" name="send" value="Envoyer" />
|
<input type="submit" name="send" value="Envoyer" />
|
||||||
</p>
|
</p>
|
||||||
|
</form>
|
||||||
</form>
|
</article>
|
||||||
|
<article>
|
||||||
|
<h2>... ou la confirmer telle quelle !</h2>
|
||||||
</article>
|
<p>
|
||||||
|
Si la question vous semble corect, vous pouvez directement
|
||||||
<article>
|
la confirmer ici :<br>
|
||||||
<h2>... Ou la confirmer telle quelle</h2>
|
</p>
|
||||||
|
<form method="post"
|
||||||
Si la question vous semble corect, vous pouvez directement
|
class="validation"
|
||||||
la confirmer ici:<br/>
|
action="confirmation.php">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $question->getId() ?>">
|
||||||
<a href=<?php echo "http://".$_SERVER["SERVER_NAME"]
|
<input type="submit" value="Je confirme">
|
||||||
. dirname($_SERVER["REQUEST_URI"])."/confirmation.php?id="
|
</form>
|
||||||
. $question->getId() ?>>Confirmer la question</a>
|
<span style="clear: both; display: block;"></span>
|
||||||
|
</article>
|
||||||
|
|
||||||
</article>
|
|
||||||
</section>
|
</section>
|
||||||
|
<?php include('footer.html') ?>
|
||||||
<?php include('footer.html') ?>
|
</body>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -3,63 +3,53 @@
|
||||||
include("Question.class.php");
|
include("Question.class.php");
|
||||||
include("QuestionsFile.class.php");
|
include("QuestionsFile.class.php");
|
||||||
|
|
||||||
$id = $_GET['id'];
|
@$id = $_POST['id'];
|
||||||
|
|
||||||
$fileQ = new QuestionsFile("questions.xml");
|
$fileQ = new QuestionsFile("questions.xml");
|
||||||
$question = $fileQ->get_question($id);
|
$question = $fileQ->get_question($id);
|
||||||
|
|
||||||
if (!empty($question))
|
if (!empty($question))
|
||||||
{
|
{
|
||||||
$dest_mail = $question->get_validator();
|
$src_mail = $question->get_validator()->getEmail();
|
||||||
|
|
||||||
// Uncomment the following part for random email
|
//Build email list
|
||||||
|
$users = User::getValidatedUsers();
|
||||||
|
$nbUsers = count($users);
|
||||||
|
|
||||||
|
//Pick a random email
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
$file = fopen('email.txt', 'r');
|
$random = rand(1, $nbUsers)-1;
|
||||||
$number = fgets($file);
|
|
||||||
|
|
||||||
$random = rand(1, intval($number));
|
|
||||||
|
|
||||||
for ($i = 0; $i < $random; $i++)
|
|
||||||
{
|
|
||||||
$dest_mail = fgets($file);
|
|
||||||
}
|
|
||||||
fclose($file);
|
|
||||||
}
|
}
|
||||||
while ($dest_mail == $question->get_validator());
|
while ($src_mail == $users[$random]->getEmail());
|
||||||
|
|
||||||
$question->set_validator($dest_mail);
|
$random = 3;
|
||||||
echo $dest_mail;
|
|
||||||
$validationAddress = "/validation.php?id=".$question->getId();
|
$question->set_validator($users[$random]);
|
||||||
|
|
||||||
/* This code works, perhaps should be placed in a method in Question class?*/
|
|
||||||
$to = $dest_mail;
|
|
||||||
$subject = "[Nemubot] Validation d'une question";
|
$subject = "[Nemubot] Validation d'une question";
|
||||||
$headers = "From: Nemubot <bot@nemunai.re>\n";
|
$headers = "From: Nemubot <bot@nemunai.re>\n";
|
||||||
$message = "Bonjour,\n"
|
$message = "Bonjour,\n"
|
||||||
."Une nouvelle question a été proposée à Nemubot.\n\n"
|
."Une nouvelle question a été proposée à Nemubot.\n\n"
|
||||||
|
|
||||||
."Vous avez été sélectionné pour valider la question.\n\n"
|
."Vous avez été sélectionné pour valider la question.\n\n"
|
||||||
|
|
||||||
."Rappels de la questions:\n"
|
."Voici la question :\n"
|
||||||
.'Cours concerné : ' . $question->getCourse() . "\n"
|
.' - Cours concerné : ' . $question->getCourse()->getName() . "\n"
|
||||||
.'La question est : ' . $question->getQuestion() . "\n"
|
.' - Question posée : ' . $question->getQuestion() . "\n"
|
||||||
.'Les réponses sont : ' . print_r($question->getAnswer(), true) . "\n"
|
." - Les réponses valides sont :\n" . $question->getAnswersMail() . "\n"
|
||||||
|
|
||||||
|
|
||||||
."Adresse de confirmation de la question:\n"
|
."Adresse de confirmation de la question :\n"
|
||||||
. "http://".$_SERVER["SERVER_NAME"]
|
."http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"])
|
||||||
. dirname($_SERVER["REQUEST_URI"]) . $validationAddress
|
."validation.php?id=".$question->getValidatorId()
|
||||||
|
|
||||||
. "\n\n Merci beaucoup de votre participation\n"
|
."\n\nMerci beaucoup de votre participation\n"
|
||||||
|
."Cordialement,\n"
|
||||||
|
|
||||||
."Cordialement,\n\n"
|
."-- \nNemubot\nQCM accessible sur le réseau IRC rezosup, cannal #epita-qcm";
|
||||||
|
|
||||||
."-- \nNemubot.";
|
|
||||||
|
|
||||||
|
|
||||||
if ($question->mail_utf8($to, $subject, $message, $headers))
|
if ($question->mail_utf8($users[$random]->getEmail(), $subject, $message, $headers))
|
||||||
{
|
{
|
||||||
$fileQ->save();
|
$fileQ->save();
|
||||||
header("Location: ./thanksConfirmation.php");
|
header("Location: ./thanksConfirmation.php");
|
||||||
|
@ -67,9 +57,6 @@ if (!empty($question))
|
||||||
else
|
else
|
||||||
die("Une erreur s'est produite lors de l'envoie du mail");
|
die("Une erreur s'est produite lors de l'envoie du mail");
|
||||||
}
|
}
|
||||||
//*/
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
die("ID de question invalide ou déjà validé.");
|
die("ID de question invalide ou déjà validé.");
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
2
|
|
||||||
bertrand.cournaud@gmail.com
|
|
||||||
bertrand@cournaud.fr
|
|
||||||
|
|
||||||
colona@ycc.fr
|
|
||||||
ircquizz@23.tf
|
|
||||||
ircquizz@p0m.fr
|
|
||||||
quentin.courtel@epita.fr
|
|
|
@ -112,7 +112,7 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="hello">
|
<section id="hello">
|
||||||
<h2>Nouvelle question</h2>
|
<h2 id="newquestion">Nouvelle question</h2>
|
||||||
<form id="formulaire" method="post" action="questions.php">
|
<form id="formulaire" method="post" action="questions.php">
|
||||||
<section id="Form">
|
<section id="Form">
|
||||||
<aside id="info">
|
<aside id="info">
|
||||||
|
|
140
questions.php
140
questions.php
|
@ -1,51 +1,45 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
//error_reporting(E_ALL);
|
//error_reporting(E_ALL);
|
||||||
define("FILENAME", "questions_file.nemubot");
|
define("FILENAME", "questions.xml");
|
||||||
|
|
||||||
|
|
||||||
|
include("User.class.php");
|
||||||
|
include("Course.class.php");
|
||||||
include("Question.class.php");
|
include("Question.class.php");
|
||||||
include("QuestionsFile.class.php");
|
include("QuestionsFile.class.php");
|
||||||
|
|
||||||
function isInList($mail)
|
function isInUsersList($mail)
|
||||||
{
|
{
|
||||||
$file = fopen('email.txt', 'r');
|
$us = User::getUsers();
|
||||||
$number = fgets($file);
|
|
||||||
$i = 0;
|
|
||||||
$file_mail = fgets($file);
|
|
||||||
|
|
||||||
while ($i < $number)
|
foreach($us as $u)
|
||||||
{
|
{
|
||||||
if (trim($mail) == trim($file_mail))
|
if ($u->getEmail() == $mail && $u->isValidated())
|
||||||
{
|
return $u;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_mail = fgets($file);
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isInCoursesList($course)
|
||||||
|
{
|
||||||
|
return Course::getCourse($course);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change this variable depending on the server
|
// Change this variable depending on the server
|
||||||
$confirmationAddress = "confirmation.php?id=";
|
$confirmationAddress = "confirmation.php?id=";
|
||||||
|
|
||||||
if (isset ($_POST['send']))
|
if (isset($_POST['send']))
|
||||||
{
|
{
|
||||||
//Gets parameters: course, question and answers
|
//Gets parameters: course, question and answers
|
||||||
$course = "";
|
$question = $_POST["question"];
|
||||||
$answers = array();
|
$answers = array();
|
||||||
|
|
||||||
foreach ($_POST as $key => $value)
|
foreach ($_POST as $key => $value)
|
||||||
{
|
{
|
||||||
if ($key == "question")
|
if (preg_match("#^answer[0-9]+$#", $key))
|
||||||
$question = $value;
|
if (!empty($value))
|
||||||
else if ($key == "course")
|
$answers[] = $value;
|
||||||
$course = $value;
|
|
||||||
else if (preg_match("#^answer#", $key) && $key != "")
|
|
||||||
$answers[] = $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check we have at least a question and an answer
|
//Check we have at least a question and an answer
|
||||||
|
@ -53,76 +47,68 @@ if (isset ($_POST['send']))
|
||||||
die("Veuillez indiquer une question !");
|
die("Veuillez indiquer une question !");
|
||||||
else if (count($answers) <= 0)
|
else if (count($answers) <= 0)
|
||||||
die("Veuillez indiquer au moins une réponse correcte !");
|
die("Veuillez indiquer au moins une réponse correcte !");
|
||||||
else if (count($_POST['email']) <= 0 || !isInList($_POST['email']))
|
else if (empty($_POST["email"]) || ($usr = isInUsersList($_POST["email"])) == null)
|
||||||
die("Veuillez indiquer une adresse mail valide");
|
die("Veuillez indiquer une adresse électronique valide !");
|
||||||
|
else if (empty($_POST["course"]) || ($course = isInCoursesList($_POST["course"])) == null)
|
||||||
|
die("Veuillez indiquer un cours valide !");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$quest = Question::new_Question($question, $answers, $course);
|
if (!empty($_POST["id"]))
|
||||||
$quest->set_validator($_POST['email']);
|
{
|
||||||
|
$file = new QuestionsFile("questions.xml");
|
||||||
|
$quest = $file->get_question($_POST["id"]);
|
||||||
|
|
||||||
|
$quest->setQuestion($question);
|
||||||
|
$quest->setAnswer($answers);
|
||||||
|
$quest->setCourse($course);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$quest = Question::new_Question($question, $answers, $course->getId());
|
||||||
|
|
||||||
|
$file = new QuestionsFile('questions.xml');
|
||||||
|
$file->add_question($quest);
|
||||||
|
}
|
||||||
|
$quest->set_writer($usr);
|
||||||
|
$quest->set_validator($usr);
|
||||||
|
|
||||||
// @TODO: Create/Load a QuestionFile and add the question (it must be unique)
|
|
||||||
$file = new QuestionsFile('questions.xml');
|
|
||||||
$file->add_question($quest);
|
|
||||||
$file->save();
|
$file->save();
|
||||||
|
|
||||||
// @TODO: Find a validator (from the list of previous senders for example?)
|
//Send confirmation to sender
|
||||||
|
|
||||||
// @TODO: Update the question and save the file
|
|
||||||
|
|
||||||
// @TODO: Send mail to the selected validator
|
|
||||||
|
|
||||||
// Get an email from the list
|
|
||||||
|
|
||||||
/* This code works, perhaps should be placed in a method in Question class?*/
|
|
||||||
$to = $_POST['email'];
|
|
||||||
$subject = "[Nemubot] Confirmation d'une question";
|
$subject = "[Nemubot] Confirmation d'une question";
|
||||||
$headers = "From: Nemubot <bot@nemunai.re>";
|
$headers = "From: Nemubot <bot@nemunai.re>";
|
||||||
$message = "Bonjour,\n"
|
$message = "Bonjour,\n"
|
||||||
."Une nouvelle question a été proposée à Nemubot en utilisant
|
."Une nouvelle question a été proposée à Nemubot en utilisant cette \n"
|
||||||
cette adresse email.\n\n"
|
."adresse email.\n\n"
|
||||||
|
|
||||||
."Rappels de la questions:\n"
|
."Rappel de la question :\n"
|
||||||
.'Cours concerné : ' . $course . "\n"
|
." - Cours concerné : " . $course->getName() . "\n"
|
||||||
.'La question est : ' . $question . "\n"
|
." - Question posée : " . $question . "\n"
|
||||||
.'Les réponses sont : ' . print_r($answers, true) . "\n"
|
." - Les réponses valides sont :\n".$quest->getAnswersMail()."\n"
|
||||||
|
|
||||||
."Si vous avez effectivement posé cette question, merci "
|
."Si vous avez effectivement posé cette question, merci de cliquer sur \n"
|
||||||
."de cliquer sur le lien ci-dessous pour confirmer.\n"
|
."le lien ci-dessous pour confirmer.\n"
|
||||||
."Si vous ne comprenez rien à cet email ou que vous n'avez pas "
|
."Si vous ne comprenez rien à cet email ou que vous n'avez pas posté de \n"
|
||||||
."posté de nouvelles questions, vous pouvez supprimer ce message.\n\n"
|
."nouvelles questions, vous pouvez supprimer ce message.\n\n"
|
||||||
|
|
||||||
."Adresse de confirmation de la question:\n"
|
."Adresse de confirmation de la question :\n"
|
||||||
. "http://".$_SERVER["SERVER_NAME"]
|
."http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"])
|
||||||
. dirname($_SERVER["REQUEST_URI"])."/changeQuestion.php?id="
|
."changeQuestion.php?id=".$quest->getId()
|
||||||
. $quest->getId()
|
|
||||||
|
|
||||||
. "\n\n Merci beaucoup de votre participation\n"
|
. "\n\nMerci beaucoup de votre participation.\n"
|
||||||
."Cordialement,\n"
|
."Cordialement,\n"
|
||||||
|
|
||||||
."-- \nNemubot.";
|
."-- \nNemubot\nQCM accessible sur le réseau IRC rezosup, cannal #epita-qcm";
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
if ($quest->mail_utf8($to, $subject, $message, $headers))
|
if (!empty($_POST["id"]))
|
||||||
{
|
header("Location: ./changeQuestion.php?id=".$quest->getId());
|
||||||
echo ("Email sent");
|
else if ($quest->mail_utf8($usr->getEmail(), $subject, $message, $headers))
|
||||||
}
|
header("Location: ./thanks.php?id=" . $quest->getId());
|
||||||
else
|
else
|
||||||
echo ("Error with the email");
|
echo ("Une erreur s'est produite lors de l'envoi du courrier de confirmation. Veuillez contacter l'administrateur du service.");
|
||||||
//*/
|
|
||||||
}
|
}
|
||||||
header("Location: ./thanks.php?id=" . $quest->getId());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
header("Location: ./");
|
header("Location: ./");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf8" />
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
28
style.css
28
style.css
|
@ -123,6 +123,34 @@ footer a
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.validation
|
||||||
|
{
|
||||||
|
float: left;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-left: 25%;
|
||||||
|
}
|
||||||
|
form.invalidation
|
||||||
|
{
|
||||||
|
float: right;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-right: 25%;
|
||||||
|
}
|
||||||
|
form.validation input, form.invalidation input
|
||||||
|
{
|
||||||
|
border-radius: 10px;
|
||||||
|
height: 32px;
|
||||||
|
font-weight: bold;
|
||||||
|
width: 160px;
|
||||||
|
}
|
||||||
|
form.validation input
|
||||||
|
{
|
||||||
|
background: #00BB40;
|
||||||
|
}
|
||||||
|
form.invalidation input
|
||||||
|
{
|
||||||
|
background: #BB0020;
|
||||||
|
}
|
||||||
|
|
||||||
#hideShow, #hideShowExp
|
#hideShow, #hideShowExp
|
||||||
{
|
{
|
||||||
float: right;
|
float: right;
|
||||||
|
|
79
thanks.php
79
thanks.php
|
@ -1,52 +1,47 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html><html>
|
||||||
|
|
||||||
<?php
|
|
||||||
include("Question.class.php");
|
|
||||||
include("QuestionsFile.class.php");
|
|
||||||
|
|
||||||
$id = $_GET['id'];
|
|
||||||
$file = new QuestionsFile("questions.xml");
|
|
||||||
$question = $file->get_question($id);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf8" />
|
<meta charset="utf-8">
|
||||||
<link rel="Stylesheet" href="style.css" />
|
<link rel="Stylesheet" href="style.css">
|
||||||
<title>Every Questions (BETA)</title>
|
<title>Every Questions (BETA)</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<div id="main_title">
|
<a href="http://www.h2g2.com" target="_blank">
|
||||||
<a href="http://www.h2g2.com" target="_blank">
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
||||||
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
</a>
|
||||||
</a>
|
<h1>Nemubot Questions (BETA)</h1>
|
||||||
<h1>Nemubot Questions (BETA)</h1>
|
|
||||||
</div>
|
|
||||||
</header>
|
</header>
|
||||||
<section id="introduction">
|
<?php
|
||||||
<article id="validate">
|
include("Question.class.php");
|
||||||
<h2>Merci de votre participation!</h2>
|
include("QuestionsFile.class.php");
|
||||||
<p>
|
|
||||||
Votre question a bien été ajoutée à la liste.<br/>
|
|
||||||
Un email vous a été envoyé pour que vous confirmiez que
|
|
||||||
Vous êtes bien l'auteur de la question.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
$id = $_GET['id'];
|
||||||
Rappels de la question :<br/>
|
$file = new QuestionsFile("questions.xml");
|
||||||
<?php $question->print_test(); ?>
|
$question = $file->get_question($id);
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Vous pouvez proposer de nouvelles questions en cliquant
|
|
||||||
sur le lien ci-dessous.<br/>
|
|
||||||
<a href="index.php">Proposer une nouvelle question</a>
|
|
||||||
</p>
|
|
||||||
</article>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<?php include('footer.html') ?>
|
if (isset($question))
|
||||||
|
{
|
||||||
</body>
|
?>
|
||||||
|
<section id="introduction">
|
||||||
|
<article id="validate">
|
||||||
|
<h2>Merci de votre participation !</h2>
|
||||||
|
<p>
|
||||||
|
Votre question a bien été enregistrée et est en attente de
|
||||||
|
validation.<br>
|
||||||
|
Un courrier électronique vient de vous ê envoyé pour que vous
|
||||||
|
confirmiez que vous êtes bien l'auteur de la question.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Vous pouvez proposer de nouvelles questions en cliquant
|
||||||
|
<a href="./#newquestion">ici</a> !
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else
|
||||||
|
header("Location: ./");
|
||||||
|
include('footer.html') ?>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,33 +1,35 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf8" />
|
<meta charset="utf-8">
|
||||||
<link rel="Stylesheet" href="style.css" />
|
<link rel="Stylesheet" href="style.css">
|
||||||
|
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
|
||||||
|
<title>AskWeb (BETA)</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<div id="main_title">
|
<a href="http://www.h2g2.com" target="_blank">
|
||||||
<a href="http://www.h2g2.com" target="_blank">
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
||||||
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
</a>
|
||||||
</a>
|
<h1>Nemubot Questions</h1>
|
||||||
<h1>Nemubot Questions</h1>
|
</header>
|
||||||
</div>
|
<section id="introduction">
|
||||||
</header>
|
<article>
|
||||||
|
<h2>Merci de votre participation</h2>
|
||||||
<section id="introduction">
|
<p>
|
||||||
<article>
|
Votre question a bien été prise en compte.<br>
|
||||||
<h2>Merci de votre participation</h2>
|
Un courrier électronique a été envoyé à un membre aléatoire pour
|
||||||
<p>
|
qu'il valide votre question.
|
||||||
Votre question a bien été prise en compte.<br/>
|
</p>
|
||||||
Un email a été envoyé à une personne du chan pour
|
<p>
|
||||||
qu'elle valide votre question.
|
Nemubot vous remercie de l'aider à agrandir sa base de données.<br>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Nemubot vous remercie de l'aider à agrandir sa base de donnée
|
Vous pouvez proposer de nouvelles questions en cliquant
|
||||||
</p>
|
<a href="./#newquestion">ici</a> !
|
||||||
</article>
|
</p>
|
||||||
</section>
|
</article>
|
||||||
|
</section>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
74
thanksRefused.php
Normal file
74
thanksRefused.php
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="Stylesheet" href="style.css">
|
||||||
|
<title>Every Questions (BETA)</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<a href="http://www.h2g2.com" target="_blank">
|
||||||
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
||||||
|
</a>
|
||||||
|
<h1>Nemubot Questions (BETA)</h1>
|
||||||
|
</header>
|
||||||
|
<section id="introduction">
|
||||||
|
<article id="validate">
|
||||||
|
<h2><?php
|
||||||
|
include("Question.class.php");
|
||||||
|
include("QuestionsFile.class.php");
|
||||||
|
|
||||||
|
if (isset($_POST['id']))
|
||||||
|
{
|
||||||
|
$id = $_POST['id'];
|
||||||
|
$file = new QuestionsFile("questions.xml");
|
||||||
|
$question = $file->get_question($id);
|
||||||
|
|
||||||
|
if (!isset($question) || $question->isValidated())
|
||||||
|
echo 'Votre question à déjà été validée, merci de ne pas vous acharner.';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Send confirmation to sender
|
||||||
|
$subject = "[Nemubot] Refus d'une question";
|
||||||
|
$headers = "From: Nemubot <bot@nemunai.re>";
|
||||||
|
$message = "Bonjour,\n"
|
||||||
|
."L'une de vos questions proposée à Nemubot vient d'etre refusée.\n\n"
|
||||||
|
|
||||||
|
."Rappel de la question :\n"
|
||||||
|
." - Cours concerné : " . $question->getCourse()->getName() . "\n"
|
||||||
|
." - Question posée : " . $question->getQuestion() . "\n"
|
||||||
|
." - Les réponses valides sont :\n".$question->getAnswersMail()."\n"
|
||||||
|
|
||||||
|
."Vous pouvez modifier la question à cette adresse :\n"
|
||||||
|
."http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"])
|
||||||
|
."changeQuestion.php?id=".$question->getNormalId()
|
||||||
|
|
||||||
|
. "\n\nMerci beaucoup de votre participation.\n"
|
||||||
|
."Cordialement,\n"
|
||||||
|
|
||||||
|
."-- \nNemubot\nQCM accessible sur le réseau IRC rezosup, cannal #epita-qcm";
|
||||||
|
|
||||||
|
|
||||||
|
if ($question->mail_utf8($question->get_writer()->getEmail(), $subject, $message, $headers))
|
||||||
|
{
|
||||||
|
$file->save();
|
||||||
|
echo 'Question refusée !';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo ("Une erreur s'est produite lors de l'envoi du courrier de confirmation. Veuillez contacter l'administrateur du service.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
header("Location: ./");
|
||||||
|
?></h2>
|
||||||
|
<p>
|
||||||
|
La question vient d'être retournée à son auteur,
|
||||||
|
il pourra la resoumettre dès qu'il l'aura corrigée.<br><br>
|
||||||
|
|
||||||
|
<span style="text-decoration:line-through;">Amusez-vous</span> Révisez bien !
|
||||||
|
</p>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,67 +1,51 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<?php
|
|
||||||
include("Question.class.php");
|
|
||||||
include("QuestionsFile.class.php");
|
|
||||||
|
|
||||||
$id = $_GET['id'];
|
|
||||||
$file = new QuestionsFile("questions.xml");
|
|
||||||
$question = $file->get_question($id);
|
|
||||||
|
|
||||||
if ($question->isValidated() == 1)
|
|
||||||
{
|
|
||||||
$message = 'Votre question à déjà été validée'
|
|
||||||
. ' Merci de ne pas vous acharner.';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$question->validated();
|
|
||||||
$file->save();
|
|
||||||
$message = 'Question validée';
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf8" />
|
<meta charset="utf-8">
|
||||||
<link rel="Stylesheet" href="style.css" />
|
<link rel="Stylesheet" href="style.css">
|
||||||
<title>Every Questions (BETA)</title>
|
<title>Every Questions (BETA)</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<div id="main_title">
|
<a href="http://www.h2g2.com" target="_blank">
|
||||||
<a href="http://www.h2g2.com" target="_blank">
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
||||||
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
</a>
|
||||||
</a>
|
<h1>Nemubot Questions (BETA)</h1>
|
||||||
<h1>Nemubot Questions (BETA)</h1>
|
|
||||||
</div>
|
|
||||||
</header>
|
</header>
|
||||||
|
<section id="introduction">
|
||||||
|
<article id="validate">
|
||||||
|
<h2><?php
|
||||||
|
include("Question.class.php");
|
||||||
|
include("QuestionsFile.class.php");
|
||||||
|
|
||||||
<section id="introduction">
|
if (isset($_POST['id']))
|
||||||
<article id="validate">
|
{
|
||||||
|
$id = $_POST['id'];
|
||||||
|
$file = new QuestionsFile("questions.xml");
|
||||||
|
$question = $file->get_question($id);
|
||||||
|
|
||||||
<h2><?php echo $message ?></h2>
|
if (!isset($question) || $question->isValidated())
|
||||||
<p>
|
echo 'Votre question à déjà été validée, merci de ne pas vous acharner.';
|
||||||
Votre question a été validée !<br/>
|
else
|
||||||
Nemubot vous remercie de l'aider à agrandir sa base de données.<br/>
|
{
|
||||||
|
$question->validated();
|
||||||
|
$file->save();
|
||||||
|
echo 'Question validée !';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
header("Location: ./");
|
||||||
|
?></h2>
|
||||||
|
<p>
|
||||||
|
Nemubot vous remercie de l'aider à agrandir sa base de données.<br><br>
|
||||||
|
Vous pouvez vous aussi poser des questions à <a href="./" >cette adresse</a>,
|
||||||
|
où bien simplement essayer de répondre aux questions déjà posées en tapant
|
||||||
|
<code>!qcm</code> sur un cannal où nemubot est présent.<br><br>
|
||||||
|
|
||||||
Vous pouvez vous aussi poser des questions à
|
<span style="text-decoration:line-through;">Amusez-vous</span> Révisez bien !
|
||||||
<a href="index.html" >cette adresse</a>,
|
</p>
|
||||||
où bien simplement essayer de répondre aux
|
</article>
|
||||||
questions déjà posées en tapant "!qcm" sur le chan.<br/>
|
</section>
|
||||||
|
</body>
|
||||||
Amusez vous bien.
|
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
On vous rappelle quand même la question un dernière fois :<br/>
|
|
||||||
<?php $question->print_test(); ?>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
</article>
|
|
||||||
</section>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="Stylesheet" href="style.css">
|
||||||
|
<title>Every Questions (BETA)</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<a href="http://www.h2g2.com" target="_blank">
|
||||||
|
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
||||||
|
</a>
|
||||||
|
<h1>Nemubot Questions (BETA)</h1>
|
||||||
|
</header>
|
||||||
|
<?php
|
||||||
|
|
||||||
<?php
|
|
||||||
include("Question.class.php");
|
include("Question.class.php");
|
||||||
include("QuestionsFile.class.php");
|
include("QuestionsFile.class.php");
|
||||||
|
|
||||||
|
@ -9,44 +23,42 @@ $file = new QuestionsFile("questions.xml");
|
||||||
$question = $file->get_question($id);
|
$question = $file->get_question($id);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<section id="introduction">
|
||||||
<html>
|
<article>
|
||||||
<head>
|
<h2>Validation de la question</h2>
|
||||||
<meta charset="utf8" />
|
<h3>Rappel de la question</h3>
|
||||||
<link rel="Stylesheet" href="style.css" />
|
<?php
|
||||||
</head>
|
if (!isset($question))
|
||||||
<body>
|
|
||||||
|
|
||||||
<header>
|
|
||||||
<div id="main_title">
|
|
||||||
<a href="http://www.h2g2.com" target="_blank">
|
|
||||||
<img src="marvin-robot_normal.png" alt="" id="banner"/>
|
|
||||||
</a>
|
|
||||||
<h1>Nemubot Questions</h1>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<section id="introduction">
|
|
||||||
<article>
|
|
||||||
<h2>Validation de la question</h2>
|
|
||||||
<strong>Rappel de la question</strong><br/><br/>
|
|
||||||
<?php if (!$question)
|
|
||||||
{
|
|
||||||
echo "La question n'existe pas.";
|
echo "La question n'existe pas.";
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$question->print_test();
|
?>
|
||||||
|
<p>
|
||||||
echo "\n\n";
|
<strong>Cours concerné :</strong> <?php echo $question->getCourse()->getName(); ?><br><br>
|
||||||
}
|
<strong>Question posée :</strong> <?php echo $question->getQuestion(); ?><br><br>
|
||||||
?><br/>
|
<strong>Réponses valides exhaustives :</strong>
|
||||||
|
</p>
|
||||||
<a href='thanksValidation.php?id=<?php echo $question->getId() ?>'>
|
<?php
|
||||||
Valider la question
|
echo "<ul>";
|
||||||
</a>
|
foreach($question->getAnswer() as $a)
|
||||||
</article>
|
echo "<li>".$a."</li>";
|
||||||
</section>
|
echo "</ul>";
|
||||||
|
?>
|
||||||
</body>
|
<form method="post"
|
||||||
|
class="invalidation"
|
||||||
|
action="thanksRefused.php">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $question->getId() ?>">
|
||||||
|
<input type="submit" value="Refuser la question">
|
||||||
|
</form>
|
||||||
|
<form method="post"
|
||||||
|
class="validation"
|
||||||
|
action="thanksValidation.php">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $question->getId() ?>">
|
||||||
|
<input type="submit" value="Valider la question">
|
||||||
|
</form>
|
||||||
|
<span style="clear: both; display: block;"></span>
|
||||||
|
<?php } ?>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
<body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Reference in a new issue