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

PHP app\Question类代码示例

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

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



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

示例1: store

 public function store(QuestionFormRequest $request)
 {
     //return $request->all();
     $slug = uniqid();
     $question = new Question(array('question' => $request->get('question'), 'option1' => $request->get('option1'), 'option2' => $request->get('option2'), 'option3' => $request->get('option3'), 'option4' => $request->get('option4'), 'slug' => $slug));
     $question->save();
     return redirect('create')->with('status', 'Your question has been saved! Its unique id is: ' . $slug);
 }
开发者ID:iqrasadra,项目名称:Project,代码行数:8,代码来源:QuestionsController.php


示例2: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Question $question)
 {
     $delete = $question->delete();
     if ($delete) {
         return 0;
     } else {
         return 1;
     }
 }
开发者ID:gugundwipermana,项目名称:laravel-serviceac,代码行数:15,代码来源:QuestionsController.php


示例3: postCreateAQuestion

 public function postCreateAQuestion(Request $request)
 {
     $question = new Question();
     $question->user_id = \Auth::user()->id;
     $question->title = $request->title;
     $question->slug = str_slug($request->title, "-");
     $question->save();
     return redirect('/questions');
 }
开发者ID:barantr90,项目名称:resmin-laravel,代码行数:9,代码来源:QuestionsController.php


示例4: syncTags

 /**
  * Sync up the list of tags in the database.
  *
  * @param Article $article
  * @param array   $tags
  */
 private function syncTags(Question $question, array $tags)
 {
     // Create new tags if needed and get ids
     $tagIds = [];
     foreach ($tags as $tag) {
         $tagId = Tag::firstOrCreate(['name' => mb_strtolower($tag, 'UTF-8')])->id;
         $tagIds[] = $tagId;
     }
     // Sync tags based on ids
     $question->tags()->sync($tagIds);
 }
开发者ID:nilstr,项目名称:stackoverflow-clone,代码行数:17,代码来源:QuestionsController.php


示例5: addTraining

 public function addTraining(Request $request)
 {
     $data = array('name' => htmlentities($request->input('title')), 'description' => htmlentities($request->input('description')), 'image' => $request->input('imagine'), 'areaType' => substr($request->input('arie'), 0, 1), 'area' => htmlentities(substr($request->input('arie'), 1)), 'locuri' => htmlentities($request->input('locuri')), 'ziua' => htmlentities($request->input('ziua')), 'ora' => htmlentities($request->input('ora')));
     $data['intrebari'] = array();
     $idIntrebare = 1;
     $intrebare = htmlentities($request->input('intrebare' . $idIntrebare));
     while (isset($intrebare)) {
         array_push($data['intrebari'], $intrebare);
         $idIntrebare++;
         $intrebare = $request->input('intrebare' . $idIntrebare);
     }
     $rules = array('name' => 'required', 'description' => 'required', 'image' => 'image', 'area' => 'exists:areas,id', 'subarea' => 'exists:subareas,id', 'locuri' => 'numeric|required', 'ziua' => 'required', 'ora' => 'required');
     if ($data['areaType'] == 's') {
         $data['subarea'] = $data['area'];
         $data['area'] = Subarea::where('id', $data['subarea'])->first()->area_id;
     } else {
         $data['subarea'] = "";
     }
     $validator = Validator::make($data, $rules);
     if (!$validator->fails()) {
         $training = new Training();
         $nameOfImage = $this->generateRandomString() . '.jpg';
         Storage::put('images/' . $nameOfImage, $data['image']);
         $training->trainer_id = Auth::user()->id;
         $training->name = $data['name'];
         $training->description = $data['description'];
         $training->image = "images/" . $nameOfImage;
         $training->area_id = $data['area'];
         $training->subarea_id = $data['subarea'];
         $training->locuri = $data['locuri'];
         $training->save();
         $group = new Group();
         $group->trainer_id = Auth::user()->id;
         $group->training_id = $training->id;
         $group->area_id = $training->area_id;
         $group->subarea_id = $training->subarea_id;
         $group->groupOrder = 1;
         $group->data = $data['ziua'];
         $group->ora = $data['ora'];
         $group->save();
         foreach ($data['intrebari'] as $intrebare) {
             $question = new Question();
             $question->training_id = $training->id;
             $question->question = $intrebare;
             $question->posted_by = Auth::user()->id;
             $question->required = 1;
             $question->save();
         }
         return redirect('/trainer');
     } else {
         return $data['areaType'];
     }
 }
开发者ID:StoianCatalin,项目名称:fiiPractic2016,代码行数:53,代码来源:TrainingController.php


示例6: testShowQuestion

 public function testShowQuestion()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $question = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $survey->save();
     $question->survey()->associate($survey)->save();
     $response = $this->call('GET', route('question.show', ['id' => $question->id]));
     $savingUrl = route('question.question_response.store', ['question_id' => $question->id], false);
     $absoluteSavingUrl = route('question.question_response.store', ['question_id' => $question->id]);
     $this->assertContains($question->body, $response->getContent());
     $this->assertContains($savingUrl . '?Kind=voice', $response->getContent());
     $this->assertNotContains($absoluteSavingUrl, $response->getContent());
 }
开发者ID:illuminate3,项目名称:automated-survey-laravel,代码行数:13,代码来源:QuestionControllerTest.php


示例7: store

 public function store(Request $request, $idTraj)
 {
     $question = new Question();
     $libQuest = $request->question;
     $question->libQuest = $libQuest;
     $question->trajet()->associate(Trajet::find($idTraj));
     $question->save();
     $trajet = Trajet::find($question->idTraj);
     $data = array("question" => $question->libQuest, "idTraj" => $question->idTraj, "mailCond" => $trajet->user->email, "nomCond" => $trajet->user->prenomMemb);
     Mail::send('recherche.question.email', $data, function ($message) use($trajet, $question) {
         $message->to($trajet->user->email, $trajet->user->prenomMemb)->subject('Vous avez reçu une question !');
     });
     return redirect()->route('detailRecherche', $idTraj);
 }
开发者ID:julie-ramadanoski,项目名称:univoiturage,代码行数:14,代码来源:QuestionController.php


示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $json = Storage::get('questions.json');
     $this->command->info($json);
     $questions = json_decode($json, true);
     foreach ($questions['questions'] as $question_keys => $question) {
         $this->command->info("Adding Question: " . $question_keys . "...");
         if ($question["type"] != "true-false") {
             $answers = $question['answers'];
             unset($question['answers']);
         }
         $q = new Question($question);
         $q->save();
         foreach ($question as $question_attribute_name => $question_attribute_value) {
             $this->command->info($question_attribute_name);
         }
         if ($q->type == "true-false") {
             $this->command->info("Adding True/False Question...");
             $answer = $question['answer'];
             $aFalse;
             $aTrue;
             if (Answer::where('text', 'true')->count() >= 1) {
                 $aTrue = Answer::where('text', 'true')->first();
             } else {
                 $aTrue = new Answer(['text' => 'true']);
                 $aTrue->save();
             }
             if (Answer::where('text', 'false')->count() >= 1) {
                 $aFalse = Answer::where('text', 'false')->first();
             } else {
                 $aFalse = new Answer(['text' => 'false']);
                 $aFalse->save();
             }
             $q->answers()->save($aFalse, ['is_correct' => $answer ? 0 : 1]);
             $q->answers()->save($aTrue, ['is_correct' => $answer ? 1 : 0]);
         } else {
             $this->command->info("Adding answers...");
             $answer_ids = array();
             foreach ($answers as $answer_index => $answer) {
                 $this->command->info("Adding " . ($answer_index + 1) . "...");
                 $a = new Answer($answer);
                 $a->save();
                 $q->answers()->save($a, ['is_correct' => $answer['is_correct'] === "false" ? 0 : 1]);
             }
         }
         $this->command->info("");
     }
 }
开发者ID:sgomez118,项目名称:ASM-Software-Management,代码行数:53,代码来源:QuestionSeeder.php


示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('questions')->truncate();
     $quiz = new Question();
     $quiz->quiz_id = 1;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded question 1';
     $quiz->save();
     $quiz = new Question();
     $quiz->quiz_id = 1;
     $quiz->user_id = 1;
     $quiz->title = 'Seeded question 2';
     $quiz->save();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
开发者ID:siderate,项目名称:banana-api,代码行数:21,代码来源:QuestionTableSeeder.php


示例10: add

 public function add(Request $request, $code)
 {
     $j = 0;
     $answer = '';
     $answer_corrected = '';
     for ($i = 1; $i <= count($request->input('variants')); $i++) {
         if ($j < count($request->input('answers'))) {
             if ($request->input('answers')[$j] == $i) {
                 $answer = $answer . ';' . "1";
                 $j++;
             } else {
                 $answer = $answer . ';' . "0";
             }
         } else {
             $answer = $answer . ';' . "0";
         }
     }
     $answer[0] = '';
     echo strlen($answer);
     for ($i = 1; $i < strlen($answer); $i++) {
         $answer_corrected = $answer_corrected . $answer[$i];
     }
     echo strlen($answer_corrected);
     $title = $request->input('variants')[0];
     for ($i = 1; $i < count($request->input('variants')); $i++) {
         $title = $title . ';' . $request->input('variants')[$i];
     }
     Question::insert(array('code' => $code, 'title' => $title, 'variants' => '', 'answer' => $answer_corrected, 'points' => $request->input('points')));
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:29,代码来源:YesNo.php


示例11: store

 public function store(QuestRequest $request)
 {
     $quest = Question::create($request->all());
     $quest->section()->attach($request->input('section'));
     flash()->success('Twoje zapytanie zostało wysłane poprawnie, oczekuj odpowiedzi na swojej skrzynce pocztowej. Zazwyczaj trwa to do 24h, pozdrawiamy, ekipa PLERP!');
     return redirect('/');
 }
开发者ID:AdrianKuriata,项目名称:projekt,代码行数:7,代码来源:QuestController.php


示例12: questions

 function questions()
 {
     $faker = Faker::create();
     foreach (range(0, 10) as $i) {
         Question::create(['body' => $faker->paragraph]);
     }
 }
开发者ID:bhasunjaya,项目名称:askpeople,代码行数:7,代码来源:DatabaseSeeder.php


示例13: index

 public function index()
 {
     $questions = Question::all();
     $tpl['user'] = \Auth::user();
     $tpl['questions'] = $questions;
     return view('home', $tpl);
 }
开发者ID:bhasunjaya,项目名称:askpeople,代码行数:7,代码来源:HomeController.php


示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 100; $i++) {
         $question = \App\Question::create(['question' => $faker->text(300), 'option_1' => $faker->text(100), 'option_2' => $faker->text(100), 'option_3' => $faker->text(100), 'option_4' => $faker->text(100), 'answer' => $faker->numberBetween(1, 4), 'user_create' => $faker->numberBetween(1, 10)]);
     }
 }
开发者ID:nghesilangthang,项目名称:simple_quiz_admin,代码行数:12,代码来源:question.php


示例15: testStoreResponse

 public function testStoreResponse()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $questionOne = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $questionTwo = new Question(['body' => 'What is that?', 'kind' => 'voice']);
     $survey->save();
     $questionOne->survey()->associate($survey)->save();
     $questionTwo->survey()->associate($survey)->save();
     $responseForQuestion = ['RecordingUrl' => '//somefake.mp3', 'CallSid' => '7h1515un1qu3', 'Kind' => 'voice'];
     $firstResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionOne->id]), $responseForQuestion);
     $routeToNextQuestion = route('question.show', ['id' => $questionTwo->id], false);
     $routeToNextQuestionAbsolute = route('question.show', ['id' => $questionTwo->id], true);
     $this->assertContains($routeToNextQuestion, $firstResponse->getContent());
     $secondResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionTwo->id]), $responseForQuestion);
     $this->assertNotContains('Redirect', $secondResponse->getContent());
 }
开发者ID:illuminate3,项目名称:automated-survey-laravel,代码行数:16,代码来源:QuestionResponseControllerTest.php


示例16: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->bind('articles', function ($id) {
         $article = Article::findOrFail($id);
         // If the owner return all articles else return only published.
         if (Auth::user() && $article->user_id === Auth::user()->id) {
             $articles = Article::findOrFail($id);
         } else {
             $articles = Article::published()->findOrFail($id);
         }
         return $articles;
     });
     $router->bind('questions', function ($id) {
         return Question::findOrFail($id);
     });
     $router->bind('answers', function ($id) {
         return Answer::findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('users', function ($id) {
         return User::findOrFail($id);
     });
 }
开发者ID:nilstr,项目名称:stackoverflow-clone,代码行数:33,代码来源:RouteServiceProvider.php


示例17: add

 public function add(Request $request, $code)
 {
     //были изменения
     $variants = $request->input('variants')[0];
     $answer = '';
     $flag = false;
     for ($i = 1; $i < count($request->input('variants')); $i++) {
         $variants = $variants . ';' . $request->input('variants')[$i];
     }
     $title = $request->input('title')[0];
     for ($i = 1; $i < count($request->input('title')); $i++) {
         $title = $title . ';' . $request->input('title')[$i];
     }
     // $j = 0;
     // while ($flag != true && $j<count($request->input('answer'))){
     // if (isset($request->input('answer')[$j])){
     // $answer = $j + 1;
     // $j++;
     // break;
     // }
     // $j++;
     // }
     $answer = $request->input('answer')[0];
     for ($i = 1; $i < count($request->input('answer')); $i++) {
         $answer = $answer . ';' . $request->input('answer')[$i];
     }
     Question::insert(array('code' => $code, 'title' => $title, 'variants' => $variants, 'answer' => $answer, 'points' => $request->input('points')));
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:28,代码来源:AccordanceTable.php


示例18: testQuestionSurveyResults

 /**
  * GET test question response index
  *
  * @return void
  */
 public function testQuestionSurveyResults()
 {
     $responseDataOne = ['kind' => 'voice', 'response' => '//faketyfake.mp3', 'call_sid' => '4l505up3run1qu3'];
     $responseDataTwo = ['kind' => 'voice', 'response' => '//somefakesound.mp3', 'call_sid' => '5up3run1qu3'];
     $question = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $question->survey()->associate($this->firstSurvey);
     $question->save();
     $question->responses()->createMany([$responseDataOne, $responseDataTwo]);
     $question->push();
     $response = $this->call('GET', route('survey.results', ['id' => $this->firstSurvey->id]));
     $this->assertEquals($response->original['responses']->count(), 2);
     $actualResponseOne = $response->original['responses']->get(0)->toArray()[0];
     $actualResponseTwo = $response->original['responses']->get(1)->toArray()[0];
     $this->assertArraySubset($responseDataOne, $actualResponseOne);
     $this->assertArraySubset($responseDataTwo, $actualResponseTwo);
 }
开发者ID:illuminate3,项目名称:automated-survey-laravel,代码行数:21,代码来源:SurveyControllerTest.php


示例19: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $student = Auth::user();
     $course_id = $request["course_id"];
     $questions = Question::where('course_id', '=', $course_id)->get();
     if (count($questions) <= 0) {
         Flash::error('There was a problem processing your request.');
         return redirect()->route('registration.index');
     }
     $question_count = 0;
     $passed_count = 0;
     foreach ($questions as $que) {
         $question_count = $question_count + 1;
         $keyword_found = 0;
         $answer_array = explode(',', $que->answers);
         $students_reply_array = explode(' ', $request[$que->id]);
         $students_reply = $request[$que->id];
         foreach ($answer_array as $keyword) {
             if (strpos($students_reply, $keyword) !== false) {
                 $keyword_found = $keyword_found + 1;
             }
         }
         if ($keyword_found == count($answer_array)) {
             $passed_count = $passed_count + 1;
         }
     }
     $percent = $passed_count / $question_count * 100;
     Exam::create(['course_id' => $course_id, 'student_id' => $student->id, 'score_percentage' => $percent]);
     Flash::success('Answer sheet submitted successfully.');
     return redirect()->route('registration.index');
 }
开发者ID:omoprodigi,项目名称:Keyword-Matching-Exam,代码行数:37,代码来源:ExaminationController.php


示例20: storeTranscription

 public function storeTranscription($surveyId, $questionId, Request $request)
 {
     $callSid = $request->input('CallSid');
     $question = Question::find($questionId);
     $questionResponse = $question->responses()->where('session_sid', $callSid)->firstOrFail();
     $questionResponse->responseTranscription()->create(['transcription' => $this->_transcriptionMessageIfCompleted($request)]);
 }
开发者ID:TwilioDevEd,项目名称:automated-survey-laravel,代码行数:7,代码来源:QuestionResponseController.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP app\Role类代码示例发布时间:2022-05-23
下一篇:
PHP app\Project类代码示例发布时间: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