public function postSave(Request $request){//создание и обновление,
if($request->has('update')){//обновляем
$question = Question::find($request->input('update'));
$question->title = $request->input('title');
$question->description = $request->input('description');
// сделать добавление меток
if($request->has('teg')){
//сохраняем новые связи
$question->tegs()->sync($request->input('teg'));
}
$question->save();
return redirect('questions')->with('message','Вопрос обновлен');
}else{//сохраняем новый вопрос
//if validation
//сохранить не удалось, ошибки при валидации return redirect()->back()->withInput()->withErrors($validator);
//}else{//сохраняем, валидация прошла
$question = Question::create([
'user_id' => $this->user->id,
'title' => $request->input('title'),
'description' => $request->input('description')
]);
//сохраняем, но проверить чтобы были метки
 
$question->tegs()->attach($request->input('teg'));

Subscribe::create([
'question_id' => $question->id,
'user_id'=>$this->user->id
]);
return redirect('questions')
->with('message','¬аш вопрос сохранен, когда будет ответ вам на почту придет уведомление.');
//}
}
}//end postSave
 public function run()
 {
     DB::table("questions")->delete();
     Question::create(['quiz_id' => 1, 'question' => 'A program that can copy itself and infect a computer without the permission or knowledge of the owner is called what?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of these is a correct format of IP address?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which was the first web browser?']);
     Question::create(['quiz_id' => 1, 'question' => 'It is a small piece of text stored on a user\'s computer by a web browser for maintaining the state. What we are talking about?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of these is a correct format of Email address?']);
     Question::create(['quiz_id' => 1, 'question' => 'What does HTTP stands for?']);
     Question::create(['quiz_id' => 1, 'question' => 'In computers, what is the smallest and basic unit of information storage?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which company is nicknamed "Big Blue"?']);
     Question::create(['quiz_id' => 1, 'question' => 'What is JVM?']);
     Question::create(['quiz_id' => 1, 'question' => 'What is Windows XP?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of the following is responsible for the management and coordination of activities and the sharing of the resources of the computer?']);
     Question::create(['quiz_id' => 1, 'question' => 'WAV file format is associated with what type of files?']);
     Question::create(['quiz_id' => 1, 'question' => 'What is a Compiler?']);
     Question::create(['quiz_id' => 1, 'question' => 'Machine language is also known as']);
     Question::create(['quiz_id' => 1, 'question' => 'What does FTP stand for?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which company acquired Sun Microsystems on January 27, 2010?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which was the first ever web server software?']);
     Question::create(['quiz_id' => 1, 'question' => 'What does BCC means in EMail?']);
     Question::create(['quiz_id' => 1, 'question' => 'MS-Word is an example of']);
     Question::create(['quiz_id' => 1, 'question' => 'Who is known as the father of the Java programming language?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which software application is used for accessing sites or information on a network (as the World Wide Web)?']);
     Question::create(['quiz_id' => 1, 'question' => 'What are the two broad categories of software?']);
     Question::create(['quiz_id' => 1, 'question' => 'One kilobyte contains how many bytes?']);
     Question::create(['quiz_id' => 1, 'question' => 'In computers, a collection of row data is known as what?']);
     Question::create(['quiz_id' => 1, 'question' => 'Who Owns the Internet?']);
     Question::create(['quiz_id' => 1, 'question' => 'What is the shortcut key of printing a document for computer having windows?']);
     Question::create(['quiz_id' => 1, 'question' => 'It is defined as the period of time that a unique user interacts with a Web application. What we are talking about?']);
     Question::create(['quiz_id' => 1, 'question' => 'Java is a']);
     Question::create(['quiz_id' => 1, 'question' => 'In computers, \'.TMP\' extension refers usually to what kind of file?']);
     Question::create(['quiz_id' => 1, 'question' => 'The way of manipulating data into information is called']);
     Question::create(['quiz_id' => 1, 'question' => 'What Does BIOS Stand For?']);
     Question::create(['quiz_id' => 1, 'question' => 'Abbreviate \'LAN\' in computer networks']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of the following performs modulation and demodulation?']);
     Question::create(['quiz_id' => 1, 'question' => 'In windows computers, MPEG extension refers to what kind of file?']);
     Question::create(['quiz_id' => 1, 'question' => 'Memory management is a feature of']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of the following is not a storage device?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of these is the first web-based e-mail service?']);
     Question::create(['quiz_id' => 1, 'question' => 'The Specially designed computers to perform very complex calculations extremely rapidly are called as']);
     Question::create(['quiz_id' => 1, 'question' => 'A bus is a / an']);
     Question::create(['quiz_id' => 1, 'question' => 'How many layers are described in networking?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of the following is not a web server?']);
     Question::create(['quiz_id' => 1, 'question' => 'What was the first general-purpose electronic computer?']);
     Question::create(['quiz_id' => 1, 'question' => 'What is CGI?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which of the following is not a database?']);
     Question::create(['quiz_id' => 1, 'question' => 'The term \'Pentium\' is related to what?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which supercomputer is developed by the Indian Scientists?']);
     Question::create(['quiz_id' => 1, 'question' => 'Check the odd term out']);
     Question::create(['quiz_id' => 1, 'question' => 'What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?']);
     Question::create(['quiz_id' => 1, 'question' => 'When does the code block following while(x<100) execute?']);
     Question::create(['quiz_id' => 1, 'question' => 'Which is not a loop structure?']);
     Question::create(['question' => 'A for?', 'quiz_id' => 2]);
     Question::create(['question' => 'B for?', 'quiz_id' => 4]);
     Question::create(['question' => 'C for?', 'quiz_id' => 2]);
     Question::create(['question' => 'D for?', 'quiz_id' => 3]);
     Question::create(['question' => 'E for?', 'quiz_id' => 3]);
     Question::create(['question' => 'F for?', 'quiz_id' => 4]);
 }
Esempio n. 3
0
 protected function create($values)
 {
     $data = [];
     foreach ($this->structure as $i => $key) {
         $data[$key] = $values[$i];
     }
     Question::create($data);
 }
 public function run()
 {
     Question::truncate();
     $faker = Faker\Factory::create();
     $authorIds = User::lists('id');
     for ($i = 0; $i < 10; $i++) {
         Question::create(['desc' => $faker->sentence, 'type' => $faker->word, 'status' => $faker->randomElement(array(0, 1)), 'author_id' => $faker->randomElement($authorIds)]);
     }
 }
 function createQuestion(QuestionRequest $request)
 {
     // Double check to make sure the current user is authorized to do this...
     $this->authorize('create-question');
     $input = $request->all();
     $question = Question::create($input);
     $request->session()->flash('success', 'Your question has been created.');
     return redirect('/questions');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     if (!$request->input('question_title') || !$request->input('question_type')) {
         return $this->respondUnprocessed();
     }
     Question::create(['question_title' => $request->input('question_title'), 'question_type' => $request->input('question_type'), 'fact_id' => $request->input('fact_id')]);
     return $this->respondCreated("Data successfully created");
 }
 public function insertAnswerAsFactWithQuestion($answer, $question = null)
 {
     $fact_id = Fact::create(['user_id' => $this->user_id, 'fact' => $answer])->id;
     if (!is_null($question)) {
         if ($question == 4) {
             $question_type = 8;
             $question_title = 'Have you applied this in your life? Make plans to';
         } elseif ($question == 3) {
             $question_type = 7;
             $question_title = 'Can you extend on this previous thought?';
         }
         Question::create(['fact_id' => $fact_id, 'question_title' => $question_title, 'question_type' => $question_type]);
     }
 }
 public function store(QuestionRequest $request)
 {
     $q = Question::create($request->all());
     $correct_answer_id;
     foreach ($request['options'] as $option) {
         $o = Option::create(['option' => $option['option'], 'question_id' => $q->id]);
         if ($request['correct_answer_id'] == $option['id']) {
             $correct_answer_id = $o->id;
         }
     }
     if ($request['correct_answer_id']) {
         CorrectAnswer::create(['question_id' => $q->id, 'option_id' => $correct_answer_id]);
     }
     return $q->toJson();
 }
Esempio n. 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $Role1 = \App\Models\Role::create(['title' => 'Пользователь', 'default' => true]);
     $Role2 = \App\Models\Role::create(['title' => 'Администратор', 'admin' => true]);
     \App\Models\Group::create(['title' => 'КИТ-10']);
     $Group1 = \App\Models\Group::create(['title' => 'КИТ-10']);
     \App\Models\Group::create(['title' => 'КИТ-20']);
     $Group2 = \App\Models\Group::create(['title' => 'КИТ-30']);
     \App\Models\Group::create(['title' => 'КИТ-40']);
     \App\User::create(['first_name' => 'Admin', 'last_name' => 'Admin', 'second_name' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt('admin'), 'group_id' => $Group2->id, 'role_id' => $Role2->id]);
     \App\User::create(['first_name' => 'Test first name', 'last_name' => 'Test last name', 'second_name' => 'Test second name', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'group_id' => $Group1->id, 'role_id' => $Role1->id]);
     \Illuminate\Support\Facades\DB::table('type_question')->insert([['title' => 'radio'], ['title' => 'checkbox']]);
     $Prototype = \App\Models\Prototype::create(['title' => 'Тест по биологии', 'time' => 40, 'count_questions' => 5]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Сколько лап у ежа?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '4', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '6', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Много', 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какая длина хобота у слона?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => 'У слона нет хобота', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '2 метра', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Зависит от возраста', 'right' => true, 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Сколько рёбер у человека?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '12 пар', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Кто такой человек?', 'right' => true, 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какие типы данных из перечисленных есть в PHP?', 'type' => 'checkbox']);
     $Answer = \App\Models\Answer::create(['text' => 'Integer', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Float', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'String', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Char', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Array', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => 'Callbacks / Callables', 'right' => true, 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какой оператор выполняет строгое сравнение?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '==', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '===', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '&', 'question_id' => $Question->id]);
     $Question = \App\Models\Question::create(['prototype_id' => $Prototype->id, 'text' => 'Какой оператор не правильный?', 'type' => 'radio']);
     $Answer = \App\Models\Answer::create(['text' => '$a and $b', 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '$a or $b', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '! $a', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '$a => $b', 'right' => true, 'question_id' => $Question->id]);
     $Answer = \App\Models\Answer::create(['text' => '$a <= $b', 'right' => true, 'question_id' => $Question->id]);
     // $this->call('UserTableSeeder');
 }