コード例 #1
0
ファイル: quiz.php プロジェクト: puring0815/OpenKore
 /**
  * Start the controller.
  */
 public function start()
 {
     global $template;
     if ($this->dataSubmitted()) {
         $this->validateInput();
     }
     try {
         $model = new QuizModel($this->getLanguage());
     } catch (QuizSourceParseException $e) {
         message_die(GENERAL_ERROR, "An internal error occured while parsing the quiz file: " . $e->getMessage() . "<br>\n" . "Please contact an administrator.");
     } catch (QuizIllegalLanguageException $e) {
         message_die(GENERAL_ERROR, "Illegal language specified: " . htmlspecialchars($this->getLanguage()));
     }
     $this->model = $model;
     if ($this->dataSubmitted()) {
         $this->validateInput2();
         $this->selectItems(explode(',', $_POST['questions']));
     } else {
         $model->selectRandomItems(QuizModel::NUM_ITEMS);
     }
     if ($model->done()) {
         $this->validateRedirectionInput();
         $model->saveUserSetting();
         $this->completed();
     } else {
         $this->view = new QuizView($model, $template, !$this->dataSubmitted());
     }
 }