Can change a validated question

This commit is contained in:
Némunaire 2012-06-18 20:22:08 +02:00
parent 42fec70edf
commit 30c06c08e8
2 changed files with 40 additions and 15 deletions

View file

@ -159,8 +159,12 @@ class Question
} }
public function setQuestion($question) public function setQuestion($question)
{
if ($this->question != $question)
{ {
$this->question = $question; $this->question = $question;
$this->validated = false;
}
} }
public function getAnswer() public function getAnswer()
@ -182,8 +186,12 @@ class Question
} }
public function setAnswer($answers) public function setAnswer($answers)
{
if ($this->answers != $answers)
{ {
$this->answers = array(); $this->answers = array();
$this->validated = false;
if (!empty($answers)) if (!empty($answers))
{ {
if (is_array($answers)) if (is_array($answers))
@ -194,7 +202,7 @@ class Question
else else
$this->answers[] = $answers; $this->answers[] = $answers;
} }
}
} }
function mail_utf8($to, $subject = '(No subject)', function mail_utf8($to, $subject = '(No subject)',

View file

@ -27,19 +27,26 @@
</a> </a>
<h1>Nemubot Questions (BETA)</h1> <h1>Nemubot Questions (BETA)</h1>
</header> </header>
<section id="introduction">
<article>
<?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);
if (isset($question))
{
?> ?>
<section id="introduction"> <h2><?php
<article> if ($question->isValidated())
<h2>Dernière chance pour changer d'avis</h2> echo "Cette question a déjà été validée ; si vous la modifiez, elle devra &ecirc;tre de nouveau valid&eacute;e";
else
echo"Dernière chance pour changer d'avis";
?></h2>
<p> <p>
<strong>Cours concerné :</strong> <?php echo $question->getCourse()->getName(); ?><br><br> <strong>Cours concerné :</strong> <?php echo $question->getCourse()->getName(); ?><br><br>
<strong>Question posée :</strong> <?php echo $question->getQuestion(); ?><br><br> <strong>Question posée :</strong> <?php echo $question->getQuestion(); ?><br><br>
@ -107,6 +114,10 @@ print '<script type="text/javascript">var nbAnswer = '.($max+1).';</script>';
</p> </p>
</form> </form>
</article> </article>
<?php
if (!$question->isValidated())
{
?>
<article> <article>
<h2>... ou la confirmer telle quelle !</h2> <h2>... ou la confirmer telle quelle !</h2>
<p> <p>
@ -120,6 +131,12 @@ print '<script type="text/javascript">var nbAnswer = '.($max+1).';</script>';
<input type="submit" value="Je confirme"> <input type="submit" value="Je confirme">
</form> </form>
<span style="clear: both; display: block;"></span> <span style="clear: both; display: block;"></span>
<?php
}
}
else
header("Location: ./");
?>
</article> </article>
</section> </section>
<?php include('footer.html') ?> <?php include('footer.html') ?>