本文整理汇总了PHP中Question类的典型用法代码示例。如果您正苦于以下问题:PHP Question类的具体用法?PHP Question怎么用?PHP Question使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Question类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: faqSend
public function faqSend()
{
$question = new Question();
$input = Input::all();
$captcha_string = Input::get('g-recaptcha-response');
$captcha_response = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=6LcCwgATAAAAAKaXhPJOGPTBwX-n2-PPLZ7iupKj&response=' . $captcha_string);
$captcha_json = json_decode($captcha_response);
if ($captcha_json->success) {
$rules = ["sujetQuestion" => "required", "mail" => "required|email", "contenuQuestion" => "required"];
$messages = ["required" => ":attribute est requis pour l'envoi d'une question", "email" => "L'adresse email précisée n'est pas valide"];
$validator = Validator::make(Input::all(), $rules, $messages);
if ($validator->fails()) {
$messages = $validator->messages();
Session::flash('flash_msg', "Certains champs spécifiés sont incorrects.");
Session::flash('flash_type', "fail");
return Redirect::to(URL::previous())->withErrors($validator);
} else {
$question->fill($input)->save();
Session::flash('flash_msg', "Votre question nous est bien parvenue. Nous vous répondrons sous peu.");
Session::flash('flash_type', "success");
return Redirect::to(URL::previous());
}
} else {
Session::flash('flash_msg', "Champ de vérification incorrect ou non coché.");
Session::flash('flash_type', "fail");
return Redirect::to(URL::previous());
}
}
示例2: makeQuestion
public function makeQuestion()
{
$data = Input::all();
$rules = ['question' => 'required', 'opt1' => 'required', 'opt2' => 'required', 'opt3' => 'required'];
$validator = Validator::make($data, $rules);
if ($validator->passes()) {
$question = new Question();
$question->question = $data['question'];
if ($question->save()) {
try {
for ($i = 1; $i < 4; $i++) {
$option = new QuestionOption();
$option->question_id = $question->id;
$option->option_details = $data["opt{$i}"];
$option->option_number = $i;
$option->save();
}
} catch (Exception $e) {
Redirect::back()->withInfo('Something Interuppted');
}
} else {
Redirect::back()->withInfo('Something Interuppted');
}
return Redirect::to('adm/h');
} else {
return Redirect::back()->withErrors($validator->messages());
}
}
示例3: add_question
function add_question($node) {
$objQuestion = new Question();
$objQuestion->updateTitle(standard_text_escape($node->content));
/**
*Exercice type 1 refers to single response multiple choice question.
*Exercice type 2 refers to multiple response multiple choice question.
*QTILite allows only single response multiple choice questions.
**/
if($node->num_of_correct_answers > 1 ) {
$objQuestion->updateType(2);
} else {
$objQuestion->updateType(1);
}
$objQuestion->save();
$questionId = $objQuestion->selectId();
$objAnswer = new Answer($questionId);
$tmp_answer = array();
if($node->answers) {
foreach ($node->answers as $answer) {
$objAnswer->createAnswer($answer['answer'], $answer['correct'], $answer['feedback'], $answer['weight'], 1);
}
$objAnswer->save();
}
}
示例4: notifyNewArgument
public function notifyNewArgument(Question $q, Argument $a)
{
global $sDB, $sTimer, $sTemplate;
$sTimer->start("notifyNewArgument");
$res = $sDB->exec("SELECT `notifications`.`userId`, `notifications`.`flags`, `users`.`email`, `users`.`userName` FROM `notifications`\n LEFT JOIN `users` ON `users`.`userId` = `notifications`.`userId`\n WHERE `questionId` = '" . i($q->questionId()) . "';");
while ($row = mysql_fetch_object($res)) {
// no notifications for our own arguments.
/*if($a->userId() == $row->userId)
{
continue;
}*/
$uId = new BaseConvert($row->userId);
$qId = new BaseConvert($q->questionId());
$profileUrl = $sTemplate->getShortUrlBase() . "u" . $uId->val();
$unfollowUrl = $sTemplate->getShortUrlBase() . "f" . $qId->val();
$url = $a->shortUrl();
if (!SHORTURL_BASE) {
$profileUrl = $sTemplate->getRoot() . "user/" . $row->userId . "/";
$unfollowUrl = $sTemplate->getRoot() . "unfollow.php?qId=" . $q->questionId();
$url = $a->fullurl();
}
$subject = $sTemplate->getString("NOTIFICATION_NEW_ARGUMENT_SUBJECT");
$message = $sTemplate->getString("NOTIFICATION_NEW_ARGUMENT_BODY", array("[USERNAME]", "[AUTHOR]", "[URL]", "[QUESTION]", "[ARGUMENT]", "[UNFOLLOW_URL]", "[PROFILE_URL]"), array($row->userName, $a->author(), $url, $q->title(), $a->headline(), $unfollowUrl, $profileUrl));
$this->sendMail($row->email, "", $subject, $message);
}
$sTimer->stop("notifyNewArgument");
}
示例5: actionIndex
public function actionIndex($alias = '')
{
// Определяем, выбрана или нет категория
$category = null;
if (!empty($alias)) {
// Если выбрана категория
$category = QuestionCategory::model()->published()->findByAlias($alias);
if (is_null($category)) {
throw new CHttpException(404);
}
$page = $category;
$this->currentCategory = $category;
} else {
// Загружаем страницу "Новости"
Yii::import("application.modules.page.PageModule");
Yii::import("application.modules.page.models.Page");
$page = Page::model()->findByPath("faq");
}
// Показываем только публичные новости
$model = new Question('user_search');
$model->unsetAttributes();
// Категория
if (!empty($category)) {
$model->category_id = $category->id;
}
$dataProvider = $model->user_search();
$this->render('index', ['dataProvider' => $dataProvider, 'page' => $page, 'currentCategory' => $category]);
}
示例6: executeInjection
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeInjection(sfWebRequest $request)
{
$this->form = new InjectionForm();
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter('injection'), $request->getFiles('injection'));
if ($this->form->isValid())
{
$file = $this->form->getValue('fichier');
$file->save(sfConfig::get('sf_upload_dir').'/injection.csv');
if (($handle = fopen(sfConfig::get('sf_upload_dir').'/injection.csv', "r")) !== FALSE) {
while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
if ($data[9] != '') {
$question = new Question();
$question->setNom($data[4]);
$question->setPrenom($data[5]);
$question->setCodePostal($data[6]);
$question->setPays($data[7]);
$question->setTelephone($data[9]);
$question->setEmail($data[8]);
$question->setTexteQuestion(str_replace("\\", "", $data[3]));
// $question->setSite("lejuridique");
$question->setDateQuestion($data[2]);
$question->save();
}
}
fclose($handle);
}
}
}
}
示例7: testToString
/**
* @covers Genj\FaqBundle\Entity\Question::__toString
*/
public function testToString()
{
$question = new Question();
$question->setHeadline('John Doe');
$questionToString = (string) $question;
$this->assertEquals('John Doe', $questionToString);
}
示例8: import
public static function import($file)
{
$fd = fopen($file, 'r');
$quiz = new QuaranteDeuxCases();
$quiz->title = fgets($fd);
$quiz->filename = $file;
$quiz->savetime = filemtime($file);
$level_count = 0;
while (!feof($fd)) {
$lines = array();
while (($line = trim(fgets($fd))) != '') {
$lines[] = $line;
}
if (count($lines) > 0) {
$question = new Question();
$question->setStatement(array_shift($lines));
$question->addAnswer(implode(' ', $lines), true);
$quiz->addQuestion($question, $level_count++);
}
}
while ($level_count < 7) {
$question = new Question();
$question->setStatement('');
$question->addAnswer('', true);
$quiz->addQuestion($question, $level_count++);
}
fclose($fd);
if (!$quiz->isCompleted()) {
throw new Exception("Quiz file incomplete");
}
return $quiz;
}
示例9: store
/**
* Store a newly created post in storage.
*
* @return Response
*/
public function store()
{
$validate = Validator::make(Input::all(), Question::$rules);
if ($validate->passes()) {
//save a new Question
$question = new Question();
$question->title = Input::get('title');
$question->body = Input::get('body');
$question->user_id = Auth::id();
$question->save();
$question_id = $question->id;
//saving Tags in Tag Table
/* convert input to array */
$tags_arr = explode(',', Input::get('tag'));
/*
save in Tag table and return object for saving in
Tagmap table
*/
foreach ($tags_arr as $tag_str) {
$tag_obj = Tag::firstOrCreate(array('title' => $tag_str));
//this line will attach a tag ( insert and save automatically )
$new_question->tags()->attach($tag_obj->id);
}
return Redirect::action('QuestionController@index');
}
return Redirect::back()->withErrors($validate)->withInput();
}
示例10: parse
public function parse()
{
// 定义题型样式
$qp = $this->patterning($this->qp, 'us');
// 提取题型
$questionTextArray = array();
preg_match_all($qp, preg_replace($this->patterning(QuestionType::$PATTERNS[QuestionType::SHORT_ANSWER], 'us'), '', $this->_sectionText), $questionTextArray);
if (count($questionTextArray) == 0 || count($questionTextArray[0]) == 0) {
return null;
}
// 处理题型
$questionArray = array();
$questionDescArray = $questionTextArray[1];
// 每个问题的描述部分
$questionSetArray = $questionTextArray[2];
// 每个问题的提问部分
for ($i = 0; $i < count($questionDescArray); $i++) {
// 拆解每个题型并生成对应的Question
$question = new Question();
// 大问题部分
$question->Set_content(ext_trim($questionDescArray[$i]));
$question->Set_type(QuestionType::SHORT_ANSWER);
$question->Set_questions(array());
$subQuestionArray =& $question->Get_questions();
$questionArray[] = $question;
// 追加大问题
// 生成子问题以及选项
$questionSet = array();
preg_match_all($this->patterning(array($this->qnp, '.+?(?=(?:\\n', $this->qnp, '|$))'), 'us'), $questionSetArray[$i], $questionSet);
$questionSet = count($questionSet) > 0 ? $questionSet[0] : null;
if (!$questionSet) {
continue;
}
foreach ($questionSet as $optionText) {
$subQuestion = new Question();
// 子问题
$subQuestion->Set_content(ext_trim(preg_replace($this->patterning(array('.*?', $this->qnp), 'us'), '', $optionText)));
$subQuestion->Set_type(QuestionType::SHORT_ANSWER);
// $subQuestion->Set_options(array());
$subQuestionArray[] = $subQuestion;
// 追加子问题
// $subOptionArray = &$subQuestion->Get_options();
// // 整理每个选项组
// $optionSetTextArray = array();
// preg_match_all($this->patterning(array($this->onp, '.+?', '(?:(?=', $this->onp, ')|(?=$))'), 'us'), $optionText, $optionSetTextArray);
// foreach ($optionSetTextArray as $eachOptionTextArray) {
// foreach ($eachOptionTextArray as $eachOptionText) {
// $option = new Option();
// $option->Set_option_content(ext_trim(preg_replace($this->patterning($this->onp), '', $eachOptionText)));
// $option->Set_item_tag(preg_replace($this->patterning(array('(', $this->onp, ').+')), '$1', $eachOptionText));
// $option->Set_type(QuestionType::SHORT_ANSWER);
// $subOptionArray[] = $option;
// }
// }
}
}
// 返回结果
return $questionArray;
}
示例11: find
static function find($id)
{
$question = new Question($id);
if ($question->isError()) {
throw new RecordNotFound();
}
return $question;
}
示例12: buildDomainObject
/**
* Builds a domain object from a DB row.
* Must be overridden by child classes.
*/
protected function buildDomainObject($row)
{
$question = new Question();
$question->setIdQuestion($row['id_question']);
$question->setIdSurvey($row['id_sondage']);
$question->setLibelle($row['libelle']);
return $question;
}
示例13: delete
function delete()
{
$this->is_loggedin();
global $runtime;
$to_trash = new Question($runtime['ident']);
$to_trash->delete();
redirect('questions/all');
}
示例14: xmoney_close_clicked
function xmoney_close_clicked()
{
$dialog = new Question($this->Owner, 'Sair do X-Money?');
$result = $dialog->ask();
if ($result != Gtk::RESPONSE_YES) {
return;
}
Gtk::main_quit();
}
示例15: setQuestions
private function setQuestions()
{
$categories = new Categorie();
$questions = new Question();
$questions->readQuestions($categories->getCategories());
$tabUn = $questions->getUn();
$tabAutre = $questions->getAutre();
$this->_questions = array('lun1' => $tabUn[0], 'lautre1' => $tabAutre[0], 'lun2' => $tabUn[1], 'lautre2' => $tabAutre[1]);
}