Example #1
0
 public function getById($id)
 {
     $quiz = self::returnedQuiz(parent::getById($id));
     if ($quiz != null) {
         $managerQuestion = new QuestionManager();
         $question = $managerQuestion->getQuestionsOfQuiz($quiz->getId());
         $quiz->setQuestions($question);
     }
     return $quiz;
 }
Example #2
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
<?php

switch ($action) {
    case 'questexport':
        $questionManager = new QuestionManager($bdd);
        $questions = $questionManager->getList();
        $chemin = 'web/csv/questexport.csv';
        $delimiteur = ';';
        if ($fichier_csv = fopen($chemin, 'w+')) {
            fprintf($fichier_csv, chr(0xef) . chr(0xbb) . chr(0xbf));
            foreach ($questions as $question) {
                $questarray[] = $question->question();
                $questarray[] = $question->rep1();
                $questarray[] = $question->rep2();
                $questarray[] = $question->rep3();
                $questarray[] = $question->rep4();
                $questarray[] = $question->rep();
                fputcsv($fichier_csv, $questarray, $delimiteur);
                unset($questarray);
            }
            fclose($fichier_csv);
            ob_start();
            require_once 'view/csv/csvexport.php';
            $content = ob_get_contents();
            ob_end_clean();
            require_once 'view/layout/layout.php';
        }
        break;
    case 'questimport':
        $questionManager = new QuestionManager($bdd);
        break;
Example #4
0
 /**
  * Tag handler for all questions.
  *
  * @param array $tag_params
  * @param array $children
  */
 public function tag_QuestionList($tag_params, $children)
 {
     $manager = QuestionManager::getInstance();
     $conditions = array();
     // get items from database
     $items = $manager->getItems($manager->getFieldNames(), $conditions);
     // load template
     $template = $this->loadTemplate($tag_params, 'list_item.xml');
     if (count($items) > 0) {
         foreach ($items as $item) {
             $params = array('id' => $item->id, 'question' => $item->question, 'answer' => $item->answer, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('faq_change', 730, $this->getLanguageConstant('title_question_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('faq_delete', 400, $this->getLanguageConstant('title_question_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delete'), array('id', $item->id)))));
             $template->restoreXML();
             $template->setLocalParams($params);
             $template->parse();
         }
     }
 }
                $managerProp->delete($prop->getId());
            }
            foreach ($vv->sanitized as $key => $value) {
                $managerProp->add(new Proposition(array('content' => $vv->sanitized[$key], 'questionId' => $question->getId(), 'type' => $checked[$key])));
            }
            echo "true";
        }
    } else {
        header("HTTP/1.0 400 Bad Request");
        $tr->_e("Please fill in all fields");
    }
    exit;
}
if (isset($_POST['type']) && $_POST['type'] === "order-question") {
    if (isset($_POST['order']) && !empty($_POST['order'])) {
        $managerQuestion = new QuestionManager();
        $v = new validation();
        $v->addSource($_POST['order']);
        foreach ($_POST['order'] as $key => $value) {
            if (preg_match('/^[0-9]{1,}$/', $key)) {
                $v->addRule($key, 'numeric', true, 1, 9999999, true);
            }
        }
        $v->run();
        if (sizeof($v->errors) > 0) {
            header("HTTP/1.0 400 Bad Request");
            echo $v->getMessageErrors();
        } else {
            $re = array();
            foreach ($v->sanitized as $ordre => $id) {
                $re[$id] = $ordre + 1;
Example #6
0
<?php

switch ($action) {
    case 'index':
        /*création des tables*/
        $questionManager = new QuestionManager($bdd);
        $questionManager->createTable();
        $themeManager = new ThemeManager($bdd);
        $themeManager->createTable();
        $userManager = new UserManager($bdd);
        $userManager->createTable();
        $userRightsManager = new UserRightsManager($bdd);
        $userRightsManager->createTable();
        $tokenManager = new TokenManager($bdd);
        $tokenManager->createTable();
        /*redirection*/
        header('Location: ?controler=install&action=firstuser');
        break;
    case 'firstuser':
        $userManager = new UserManager($bdd);
        if ($userManager->count() > 0) {
            header('Location: ?controler=index');
        } else {
            if (isset($_POST['login']) && isset($_POST['pass'])) {
                $_POST['pass'] = sha1($_POST['pass']);
                $userManager = new UserManager($bdd);
                $user = new User($_POST);
                $userManager->add($user);
                $user = $userManager->get($_POST['login'], 'login');
                $userRights = new UserRights(array('userid' => $user->id(), 'adminlvl' => '4'));
                $userRightsManager = new UserRightsManager($bdd);
Example #7
0
             if ($userrep == $goodrep) {
                 $goodRepCmpt++;
             }
         }
     }
     if ($nbUserRep >= $nb_questions) {
         $questfinish = true;
     }
     ob_start();
     require_once 'view/game/questcorrect.php';
     $content = ob_get_contents();
     ob_end_clean();
     require_once 'view/layout/layout.php';
 } elseif ($_GET['mode'] == 'one') {
     //correction de la derniére question
     $questionManager = new QuestionManager($bdd);
     $questions = $questionManager->get($_SESSION['themeid'], 'themeid', TRUE);
     $goodRepCmpt = 0;
     $nbUserRep = 0;
     $questfinish = false;
     $nb_questions = count($questions);
     foreach ($questions as $question) {
         if (isset($_SESSION['userrep'][$question->id()])) {
             $nbUserRep++;
             $userrep = $_SESSION['userrep'][$question->id()];
             $goodrep = $question->rep();
             if ($userrep == $goodrep) {
                 $goodRepCmpt++;
             }
         }
     }