Ejemplo n.º 1
0
 public function getQuestion()
 {
     $question = null;
     if (is_int($this->question)) {
         $question = QuestionDAL::findById($this->question);
     } else {
         if (is_a($this->question, "Question")) {
             $question = $this->question;
         }
     }
     return $question;
 }
<?php

require_once 'model/DAL/ThemeDAL.php';
require_once 'model/DAL/QuestionDAL.php';
// Test the user's level of access
$role = $_SESSION['user']->getRole()->getName();
if ($role === 'Professor') {
    $_SESSION['data']['themes'] = ThemeDAL::findAll();
    $_SESSION['data']['questions'] = QuestionDAL::findAll();
    require_once 'view/menu/menu_administration.phtml';
    require_once 'view/administration/administration_survey.phtml';
} else {
    header("Location: ../home");
}
/*
	$_SESSION['data']['questions'] = QuestionDAL::findAllBySurvey($id); //Envoyer les questions du survey
	require_once 'view/menu/menu_administration.phtml';
	require_once 'view/survey.phtml';
*/
require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/ThemeDAL.php';
// OK
require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/TypeDAL.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/WebBristol/model/DAL/UserDAL.php';
// OK
// Date in a string
$now = date('Y-m-d');
// User
$user = UserDAL::findById(64);
// Theme
$theme = ThemeDAL::findById(4);
// Question
// $question = QuestionDAL::findById(21);
$question = new Question(0, 'Do you like ducks ?');
$question->setTheme($theme);
$idQuestion = QuestionDAL::flush($question);
if ($idAnswer > 0) {
    $answer->setId($idAnswer);
    $_SESSION['message']['success'] = 'Ca marche (' . $idAnswer . ')';
} else {
    $_SESSION['message']['warning'] = 'Ca a rate';
}
// Answer
$answer = new Answer(0, 'I don\'t care.', $now);
$answer->setLikert(2);
$answer->setUser($user);
$answer->setQuestion($question);
$idAnswer = AnswerDAL::flush($answer);
if ($idAnswer > 0) {
    $answer->setId($idAnswer);
    $_SESSION['message']['success'] = 'Ca marche (' . $idAnswer . ')';