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


PHP Question::find方法代码示例

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


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

示例1: destroy

 public function destroy($id)
 {
     $question = Question::find($id);
     $question->delete();
     Session::flash('message', 'Usuário deletado com sucesso!');
     return Redirect::to('questions');
 }
开发者ID:GenteRH,项目名称:Prova-Gente-Teste,代码行数:7,代码来源:QuestionController.php

示例2: postQues

 public function postQues()
 {
     if (Session::get('currentqid') != Input::get('qid')) {
         return Response::json('error', 400);
     }
     if (Session::get('currentbatchid') != Input::get('batchid')) {
         return Response::json('error', 400);
     }
     $question = Question::find(Session::get('currentqid'));
     $question->user_id = Auth::id();
     $question->batchentry_id = Input::get('batchid');
     $question->qbodytext = Input::get('qbodytext');
     $question->aoptiontext = Input::get('aoptiontext');
     $question->boptiontext = Input::get('boptiontext');
     $question->coptiontext = Input::get('coptiontext');
     $question->doptiontext = Input::get('doptiontext');
     $question->solutiontext = Input::get('solutiontext');
     $question->exam_id = Input::get('exam_id');
     $question->exam_year = Input::get('examyear');
     $question->topic_id = Input::get('topicid');
     $question->doubt = Input::get('doubt');
     $question->page_no = Input::get('pageNo');
     $question->correctans = Input::get('correctans');
     $question->complete = 1;
     $question->save();
     return Response::json(array('flash' => 'Question id', Session::get('currentqid') . 'sucessfully updated!'), 200);
 }
开发者ID:nverdhan,项目名称:qdbwrite,代码行数:27,代码来源:TypingController.php

示例3: postSave

 public function postSave()
 {
     $postData = Input::all();
     if ($postData['formOrigin'] == "edit") {
         $rules = array('topic' => 'required', 'correct_answer' => 'required');
         $validator = Validator::make($postData, $rules);
         if ($validator->fails()) {
             return Redirect::to('backends/quizz/edit/' . $postData['id'])->withInput()->withErrors($validator);
         } else {
             $question = Question::find($postData['id']);
             $question->topic = $postData['topic'];
             $question->correct_answer = $postData['correct_answer'];
             $question->save();
             return Redirect::to('backends/quizz/edit/' . $question->id);
         }
     } else {
         $rules = array('topic' => 'required');
         $validator = Validator::make($postData, $rules);
         if ($validator->fails()) {
             return Redirect::to('backends/quizz/add')->withInput()->withErrors($validator);
         } else {
             $question = Question::create(['topic' => $postData['topic']]);
             return Redirect::to('backends/quizz/edit/' . $question->id);
         }
     }
 }
开发者ID:imranshuvo,项目名称:QuizzApps,代码行数:26,代码来源:AdminQuizzController.php

示例4: question_belongs_to_users

 private function question_belongs_to_users($id)
 {
     $question = Question::find($id);
     if ($question->user_id == Auth::user()->user_id) {
         return true;
     }
     return false;
 }
开发者ID:AnwarAbir18,项目名称:mushkil-asan,代码行数:8,代码来源:profileController.php

示例5: singleQuestion

 public function singleQuestion($qid)
 {
     $insertView = Question::find($qid);
     $currentNumberOfView = $insertView->numsofview;
     $insertView->numsofview = $currentNumberOfView + 1;
     $insertView->save();
     return View::make('questions.single-question')->with('title', 'Single Question')->with('singleQuestion', Question::find($qid));
 }
开发者ID:AnwarAbir18,项目名称:mushkil-asan,代码行数:8,代码来源:QuestionController.php

示例6: getQuestion

 public function getQuestion($id)
 {
     $i = -1;
     $question = Question::find($id);
     $choices = Choice::orderby('id')->having('question_id', '=', $id)->get();
     $choices_count = Choice::where('question_id', $id)->count();
     return View::make('admin.student.studentqcm')->with(compact('question', 'choices', 'choices_count', 'i'));
 }
开发者ID:resethread,项目名称:elycee,代码行数:8,代码来源:StudentController.php

示例7: deleteQuestions

 public function deleteQuestions($id)
 {
     $question = Question::find($id);
     Question::destroy($id);
     Session::flash('flash_msg', "La question N° " . $question->idQuestion . " a bien été supprimée.");
     Session::flash('flash_type', "success");
     return Redirect::to('/admin/questions');
 }
开发者ID:Adelinegen,项目名称:Linea,代码行数:8,代码来源:QuestionsController.php

示例8: findByPapernameAndNums

 public static function findByPapernameAndNums($paper_name, $numbers)
 {
     $paper_id = Paper::findId($paper_name);
     $qlist = Question::find(array('paper_id = :pid: AND number IN ({numbers:array})', 'bind' => array('pid' => $paper_id, 'numbers' => array_values($numbers))));
     if (count($qlist) == 0) {
         throw new Exception("Can not find any questions.");
     }
     return $qlist;
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:9,代码来源:Question.php

示例9: postEdit

 public function postEdit($id)
 {
     $question = Question::find($id);
     $question->title = Input::get('title');
     $question->question = Input::get('question');
     $question->last_session = Session::getId();
     $question->answer = Input::get('answer');
     $question->is_visible = Input::get('is_visible', '1');
     $question->pin = Input::get('pin', '0');
     $question->save();
     return Redirect::to('faq');
 }
开发者ID:gitda,项目名称:inventory2,代码行数:12,代码来源:FaqController.php

示例10: getDownvotequestion

 public function getDownvotequestion($id, $uID)
 {
     if (Auth::check() == NULL) {
         return Redirect::back()->with('alertError', "you have to be logged in to perform this action.");
     }
     //return $id . $uID;
     $data['question'] = Question::find($id);
     //return $data['question']->user_id . '==' . Auth::user()->id;
     if ($data['question']->user_id == Auth::user()->id) {
         return Redirect::back()->with('alertError', "You can not downvote your own question.");
     }
     $hasUserVoted = Qvote::where('user_id', '=', User::find(Auth::user()->id)->id)->where('question_id', '=', $id)->count();
     if ($hasUserVoted == 0) {
         $reputationTest = User::find(Auth::user()->id);
         if ($reputationTest->reputation < 125) {
             return Redirect::back()->with('alertError', "You need 125 reputation to downvote a question.");
         } else {
             $vote = new Qvote();
             $vote->user_id = User::find(Auth::user()->id)->id;
             $vote->question_id = $id;
             $vote->save();
             $userToUpdate = User::find($uID);
             $reputation = $userToUpdate->reputation;
             $reputation -= 2;
             //$userToUpdate->reputation = $reputation - 2;
             if ($reputation < 1) {
                 $userToUpdate->reputation = 1;
             } else {
                 $userToUpdate->reputation = $reputation;
             }
             $userToUpdate->save();
             $questionToDownVote = Question::find($id);
             $votes = $questionToDownVote->votes;
             $questionToDownVote->votes = $votes - 1;
             $questionToDownVote->save();
             $questionReputation = new Qreputation();
             $questionReputation->user_id = $uID;
             $questionReputation->question_id = $id;
             $questionReputation->points = "-2";
             $questionReputation->action = "downvote";
             $questionReputation->save();
             return Redirect::back();
         }
     } else {
         return Redirect::back()->with('alertError', "you have already voted this question.");
     }
 }
开发者ID:Roc4rdho,项目名称:ubexchange,代码行数:47,代码来源:VoteController.php

示例11: generateQuestionChart

 public function generateQuestionChart($question_id, $title)
 {
     $answers = Question::find($question_id)->answers;
     $content = $answers->lists('content');
     $total = 0;
     $index = 0;
     $votes = array();
     foreach ($answers as $answer) {
         $count = UserAnswer::where('answer_id', '=', $answer->id)->count();
         $total += $count;
         $votes[$index++] = $count;
     }
     $index = 0;
     $percentages = array();
     foreach ($votes as $vote) {
         $percentages[$index++] = round($vote / $total * 100, 0, PHP_ROUND_HALF_UP);
     }
     return array('title' => $title, 'xaxis' => $content, 'percentages' => $percentages, 'votes' => $votes, 'total' => $total);
 }
开发者ID:netintelpro,项目名称:laravel-app,代码行数:19,代码来源:ChartController.php

示例12: imgUpload

 public function imgUpload()
 {
     $destinationPath = 'public/Figures';
     $file = Input::file('file');
     $type = Input::get('type');
     $extension = Input::file('file')->getClientOriginalExtension();
     //extension to check if specefic file type is allowed
     $fileName = Session::get('currentqid') . '_' . $type . '_' . '1' . '.' . $extension;
     $upload_success = Input::file('file')->move($destinationPath, $fileName);
     if ($upload_success) {
         $question = Question::find(Session::get('currentqid'));
         if ($type == 'qbody') {
             $question->qbodyimgname = $fileName;
             $question->save();
         }
         if ($type == 'aopt') {
             $question->aoptionimgname = $fileName;
             $question->save();
         }
         if ($type == 'bopt') {
             $question->boptionimgname = $fileName;
             $question->save();
         }
         if ($type == 'copt') {
             $question->coptionimgname = $fileName;
             $question->save();
         }
         if ($type == 'dopt') {
             $question->doptionimgname = $fileName;
             $question->save();
         }
         if ($type == 'sol') {
             $question->solutionimgname = $fileName;
             $question->save();
         }
         return Response::json($fileName);
     } else {
         return Response::json('error', 400);
     }
 }
开发者ID:nverdhan,项目名称:qdbwrite,代码行数:40,代码来源:FileUploadController.php

示例13: postGuardar

 public function postGuardar()
 {
     $bandera = false;
     $id = Input::get('idQues');
     $ans = Input::get('res');
     $answers = Answer::all();
     $question = Question::find($id);
     $cantidad = Question::count();
     foreach ($answers as $a) {
         if ($a->id_question == $id) {
             $bandera = true;
             $answer = $a;
             break;
         }
     }
     if (!$bandera) {
         $answer = new Answer();
         $answer->id_question = $id;
         $ids = Auth::id();
         $student = Student::where('id_user', '=', $ids)->get()->first();
         $answer->id_student = $student->id;
         $answer->answer = $ans;
         $answer->result = QuestionsController::verifyAnswer($question, $ans);
         $answer->save();
     } else {
         $answer->result = QuestionsController::verifyAnswer($question, $ans);
         $answer->answer = $ans;
         $answer->save();
     }
     if ($cantidad == $id) {
         return Redirect::to('questions/exam?endTest=yes');
         //"holi ".$id." ".$ans;
     } else {
         if ($cantidad > $id) {
             return Redirect::to('questions/exam?numberQIn=' . ++$id);
         }
     }
 }
开发者ID:ReyesPedro,项目名称:PlataformaPreguntas,代码行数:38,代码来源:SolvingExamsController.php

示例14: testAction

 public function testAction()
 {
     $frontCache = new Phalcon\Cache\Frontend\Data(array("lifetime" => 172800));
     // Create the component that will cache "Data" to a "File" backend
     // Set the cache file directory - important to keep the "/" at the end of
     // of the value for the folder
     $cache = new Phalcon\Cache\Backend\File($frontCache, array("cacheDir" => "../cache/cachefile/"));
     // Try to get cached records
     $cacheKey = "questions.txt";
     if ($cache->exists($cacheKey)) {
         $questions = $cache->get($cacheKey);
         foreach ($questions as $item) {
             echo $item->topic, "<br>";
         }
     } else {
         $questions = Question::find(array("order" => "q_id"));
         // Store it in the cache
         $cache->save($cacheKey, $questions);
         echo "from db<br>";
         foreach ($questions as $item) {
             echo $item->topic, "<br>";
         }
     }
 }
开发者ID:sify21,项目名称:Question,代码行数:24,代码来源:AdminController.php

示例15: getQuestion

 public function getQuestion($id)
 {
     $question = Question::find($id);
     $fb_og = array('url' => Request::url(), 'title' => $question->content, 'description' => $question->content);
     return View::make('question')->with('question', $question);
 }
开发者ID:netintelpro,项目名称:laravel-app,代码行数:6,代码来源:PollController.php


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