当前位置: 首页>>代码示例>>PHP>>正文


PHP Question::setQuestion方法代码示例

本文整理汇总了PHP中Question::setQuestion方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::setQuestion方法的具体用法?PHP Question::setQuestion怎么用?PHP Question::setQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Question的用法示例。


在下文中一共展示了Question::setQuestion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hydrate

 protected function hydrate(array $record) : QuestionInterface
 {
     $question = new Question();
     $question->setID($record['id']);
     $question->setName($record['name']);
     $question->setQuestion($record['question']);
     $question->setTime(new DateTimeImmutable('@' . $record['time']));
     return $question;
 }
开发者ID:LawnGnome,项目名称:questionator,代码行数:9,代码来源:QuestionRepository.php

示例2: lectureNewsYaml

/**
 * Renvoi un objet Conteneur de news
 * Les données sont stockées dans un fichier yaml, pour faire un peu standard... quand même...
 */
function lectureNewsYaml($nomFichier)
{
    // Création du conteneur à retourner
    $conteneur = new ConteneurNews();
    // Lecture du fichier yaml
    $array = Spyc::YAMLLoad($nomFichier);
    // on commence par le noeud racine: la liste des news
    foreach ($array as $noeudRacine) {
        // on chope la news
        $news = new News();
        $news->setNouvelAttribut("titre", $noeudRacine["titre"]);
        $news->setNouvelAttribut("dateDebut", $noeudRacine["dateDebut"]);
        $news->setNouvelAttribut("dateFin", $noeudRacine["dateFin"]);
        $news->setNouvelAttribut("image", $noeudRacine["image"]);
        $news->setNouvelAttribut("imageInformation", $noeudRacine["imageInformation"]);
        $news->setNouvelAttribut("important", $noeudRacine["important"]);
        $news->setNouvelAttribut("resume", isset($noeudRacine["resume"]) ? $noeudRacine["resume"] : null);
        // on chope le formulaire à saisir, s'il existe
        if (isset($noeudRacine["include"])) {
            $news->ajouteInclude($noeudRacine["include"]);
        }
        // on chope les questions si elles existent
        if (isset($noeudRacine["questions"])) {
            $questions = $noeudRacine["questions"];
            foreach ($questions as $question) {
                $questionReponse = new Question();
                $questionReponse->setQuestion($question["q"]);
                $questionReponse->setReponse(isset($question["r"]) ? $question["r"] : null);
                $questionReponse->setReponseImage(isset($question["rimg"]) ? $question["rimg"] : null);
                $news->ajouteQuestionReponse($questionReponse);
            }
        }
        // On chope les fichiers attachés, s'ils existent
        if (isset($noeudRacine["fichiersAttaches"])) {
            $fichiers = $noeudRacine["fichiersAttaches"];
            foreach ($fichiers as $fichier) {
                $fic = new FichierAttache();
                $fic->setTitre($fichier["titre"]);
                $fic->setUrlFichier($fichier["url"]);
                $news->ajouteFichierAttache($fic);
            }
        }
        $conteneur->ajouteNews($news);
    }
    return $conteneur;
}
开发者ID:spernot,项目名称:as-evan,代码行数:50,代码来源:ContextePersistance.php

示例3: newQuestion

 public function newQuestion($id)
 {
     try {
         $report = new Report($id);
         if (!$report->allowQuestion()) {
             throw new fValidationException('Not allowed to ask question.');
         }
         $category = fRequest::get('category', 'integer');
         if ($category == 0) {
             throw new fValidationException('Please choose a category.');
         }
         $question = new Question();
         $question->setUsername(fAuthorization::getUserToken());
         $question->setReportId($report->getId());
         if ($category < 0) {
             $question->setCategory($category);
         } else {
             $question->setCategory(Question::ABOUT_PROBLEM_HIDDEN);
             $problem = new Problem($category);
             $question->setProblemId($problem->getId());
         }
         $question->setAskTime(new fTimestamp());
         $question->setQuestion(trim(fRequest::get('question')));
         if (strlen($question->getQuestion()) < 10) {
             throw new fValidationException('Question too short (minimum 10 bytes).');
         }
         if (strlen($question->getQuestion()) > 500) {
             throw new fValidationException('Question too long (maximum 500 bytes).');
         }
         $question->store();
         fMessaging::create('success', 'Question saved.');
     } catch (fExpectedException $e) {
         fMessaging::create('warning', $e->getMessage());
     } catch (fUnexpectedException $e) {
         fMessaging::create('error', $e->getMessage());
     }
     Util::redirect("/contest/{$id}");
 }
开发者ID:daerduoCarey,项目名称:oj,代码行数:38,代码来源:ReportController.php

示例4: QuestionManager

         $questionManager = new QuestionManager($bdd);
         $questionManager->delete($_GET['id']);
         header('Location: ?controler=question&action=list');
     } else {
         header('Location: ?controler=question&action=list');
     }
     break;
 case 'csvImport':
     $adminLvlThisControler = 4;
     require_once 'lib/checkRights.php';
     if (isset($_POST['file']) && !empty($_POST['theme'])) {
         if ($file = fopen('web/csv/' . $_POST['file'], 'r')) {
             $questionManager = new QuestionManager($bdd);
             $question = new Question(array());
             while ($ligne = fgetcsv($file, 0, '|', '"')) {
                 $question->setQuestion(stripslashes($ligne[0]));
                 $question->setRep1($ligne[1]);
                 $question->setRep2($ligne[2]);
                 $question->setRep3($ligne[3]);
                 $question->setRep4($ligne[4]);
                 $question->setRep($ligne[5]);
                 $question->setThemeid($_POST['theme']);
                 $question->setUserid($ligne[6]);
                 $questionManager->add($question);
             }
             header('Location: ?controler=question&action=list');
         }
     } else {
         $directory = 'web/csv/';
         $files = array_diff(scandir($directory), array('..', '.'));
         $themeManager = new ThemeManager($bdd);
开发者ID:evangelion62,项目名称:Quiz,代码行数:31,代码来源:question.php


注:本文中的Question::setQuestion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。