• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Question类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Question类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
     }
 }
开发者ID:Adelinegen,项目名称:Linea,代码行数:28,代码来源:FaqController.php


示例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());
     }
 }
开发者ID:nayeemjoy,项目名称:maskcamp,代码行数:28,代码来源:AdminController.php


示例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();
	}
}
开发者ID:nikosv,项目名称:openeclass,代码行数:31,代码来源:imsqtilib.php


示例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");
 }
开发者ID:PiratenparteiHessen,项目名称:wikiarguments,代码行数:27,代码来源:notificationMgr.php


示例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]);
 }
开发者ID:kuzmina-mariya,项目名称:4seasons,代码行数:28,代码来源:FaqController.php


示例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);
			}		  
		}
    }
	
  }
开发者ID:nacef,项目名称:juriste,代码行数:38,代码来源:actions.class.php


示例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);
 }
开发者ID:poldotz,项目名称:GenjFaqBundle,代码行数:10,代码来源:QuestionTest.php


示例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;
 }
开发者ID:etbh,项目名称:g2l2quizmanager,代码行数:32,代码来源:QuaranteDeuxCases.php


示例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();
 }
开发者ID:ayooby,项目名称:whatisit,代码行数:32,代码来源:QuestionController.php


示例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;
 }
开发者ID:rcom10002,项目名称:codeslab,代码行数:59,代码来源:question_short_answer_processor.class.php


示例11: find

 static function find($id)
 {
     $question = new Question($id);
     if ($question->isError()) {
         throw new RecordNotFound();
     }
     return $question;
 }
开发者ID:swindhab,项目名称:CliqrPlugin,代码行数:8,代码来源:Question.php


示例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;
 }
开发者ID:jdelvecchio,项目名称:forms,代码行数:12,代码来源:QuestionDAO.php


示例13: delete

 function delete()
 {
     $this->is_loggedin();
     global $runtime;
     $to_trash = new Question($runtime['ident']);
     $to_trash->delete();
     redirect('questions/all');
 }
开发者ID:stas,项目名称:bebuntu,代码行数:8,代码来源:questions-controller.php


示例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();
 }
开发者ID:eneiasramos,项目名称:xmoney,代码行数:9,代码来源:notebook.php


示例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]);
 }
开发者ID:thecampagnards,项目名称:Projet-BurgerQuiz,代码行数:9,代码来源:partie.class.php


示例16: makeNewQues

 public function makeNewQues($batchid)
 {
     $question = new Question();
     $question->user_id = Auth::id();
     $question->batchentry_id = $batchid;
     $question->complete = 0;
     $question->save();
     Session::put('currentqid', $question->id);
     return $question->id;
 }
开发者ID:nverdhan,项目名称:qdbwrite,代码行数:10,代码来源:Question.php


示例17: delete_event

 function delete_event()
 {
     $dialog = new Question($this->Owner, 'Sair do X-Money?');
     $result = $dialog->ask();
     if ($result == Gtk::RESPONSE_YES) {
         exit(0);
     } else {
         return true;
     }
 }
开发者ID:eneiasramos,项目名称:xmoney,代码行数:10,代码来源:janela_principal.php


示例18: render

 function render()
 {
     $this->title = __('Answers the Question of the Day');
     $question = new Question();
     $params = array('cnt' => FALSE, 'show' => 1, 'page' => 1, 'is_active' => 1, 'sort_by' => 'changed', 'direction' => 'DESC');
     $data = $question->load_many($params);
     $this->links = objtoarray($data);
     $this->inner_HTML = $this->generate_inner_html();
     $network_stats = parent::render();
     return $network_stats;
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:11,代码来源:QuestionsModule.php


示例19: store

 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['title' => 'required|max:150', 'description' => 'required']);
     if ($validator->fails()) {
         return response()->json($validator->errors(), 400);
     } else {
         $question = new Question(['title' => $request->title, 'description' => $request->description, 'user_id' => Auth::user()->id]);
         $question->save();
         return response()->json($question, 201);
     }
 }
开发者ID:AlMos321,项目名称:laravel,代码行数:17,代码来源:SerialController.php


示例20: admin_add_question

 public function admin_add_question()
 {
     $question = null;
     if (array_key_exists('question', $_POST)) {
         $question = new Question($this->question_collection, $_POST['question']);
         $question->save();
         header("Location: /?p=admin");
     }
     $this->load_template('admin/add_question');
     return $this->render($question);
 }
开发者ID:xwiz,项目名称:personality-quiz,代码行数:11,代码来源:app.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP QuestionAttribute类代码示例发布时间:2022-05-23
下一篇:
PHP Querys类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap