/**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     //create base question for each question
     // TODO this should actually be an event
     $fact_id = $this->fact->id;
     $questions = [['fact_id' => $fact_id, 'question_title' => 'Can you create a question from this fact?', 'question_type' => 1], ['fact_id' => $fact_id, 'question_title' => 'Can you Write this idea in your own words?', 'question_type' => 2], ['fact_id' => $fact_id, 'question_title' => 'Can you write a paragraph about this idea and its related implications? Remember to save it!', 'question_type' => 3], ['fact_id' => $fact_id, 'question_title' => 'How can this idea be used in your life?', 'question_type' => 4], ['fact_id' => $fact_id, 'question_title' => 'Can you find a related idea to this fact?', 'question_type' => 5], ['fact_id' => $fact_id, 'question_title' => 'Can you give an example in recent new or history related to this idea?', 'question_type' => 6], ['fact_id' => $fact_id, 'question_title' => 'What is one key term or phrase that you can later define', 'question_type' => 7], ['fact_id' => $fact_id, 'question_title' => 'How can you take action on this idea right this moment?', 'question_type' => 8], ['fact_id' => $fact_id, 'question_title' => 'What would be the potential significance of this idea in the future', 'question_type' => 9], ['fact_id' => $fact_id, 'question_title' => 'What is the significance of this idea in other places of the world', 'question_type' => 10], ['fact_id' => $fact_id, 'question_title' => 'How would you think of this idea if you were not you? If you were a women, white, etc.', 'question_type' => 11], ['fact_id' => $fact_id, 'question_title' => 'Name one person you idolize. How would they interpret and use this idea', 'question_type' => 12], ['fact_id' => $fact_id, 'question_title' => 'What are some ideas that build up this idea ', 'question_type' => 13], ['fact_id' => $fact_id, 'question_title' => 'Name one field you have interest in? How would they take advantage of this idea', 'question_type' => 14], ['fact_id' => $fact_id, 'question_title' => 'How can you use this idea in relation to your strengths?', 'question_type' => 15], ['fact_id' => $fact_id, 'question_title' => 'Can you prove this idea false?', 'question_type' => 16], ['fact_id' => $fact_id, 'question_title' => 'Is there an opposite to this idea?', 'question_type' => 17], ['fact_id' => $fact_id, 'question_title' => 'What if this idea was in a vacuum and had no constraints? What would be the effect?', 'question_type' => 19], ['fact_id' => $fact_id, 'question_title' => 'What would this idea be link if it exaggerated?', 'question_type' => 20], ['fact_id' => $fact_id, 'question_title' => 'What would this idea be like if it was minimized', 'question_type' => 21], ['fact_id' => $fact_id, 'question_title' => 'How can this idea relate to your goals in life', 'question_type' => 22], ['fact_id' => $fact_id, 'question_title' => 'Is this an idea that would be accepted or rejected by society', 'question_type' => 23], ['fact_id' => $fact_id, 'question_title' => 'What would be the effects if everybody accepted this idea as universal truth', 'question_type' => 24], ['fact_id' => $fact_id, 'question_title' => 'If you discovered this idea for yourself, what would it be worth to everybody else?', 'question_type' => 25], ['fact_id' => $fact_id, 'question_title' => 'How can this idea be used to prepare for future?', 'question_type' => 26], ['fact_id' => $fact_id, 'question_title' => 'How can this idea be used to provide a better world?', 'question_type' => 27], ['fact_id' => $fact_id, 'question_title' => 'How can this idea set you apart from most people', 'question_type' => 28], ['fact_id' => $fact_id, 'question_title' => 'How can remember this idea for future?', 'question_type' => 29], ['fact_id' => $fact_id, 'question_title' => 'Slowly re-read this idea', 'question_type' => 30], ['fact_id' => $fact_id, 'question_title' => 'Defend the merit of this idea.', 'question_type' => 31], ['fact_id' => $fact_id, 'question_title' => 'Can you provide an alternative interpretation of this idea', 'question_type' => 32]];
     Question::insert($questions);
 }
 public function testIf_fact_and_question_returned()
 {
     //arrange
     $fact_id = Fact::create(['user_id' => 1, 'fact' => 'I hope you learn to make it on your own'])->id;
     $questions = $this->getSampleQuestions($fact_id);
     Question::insert($questions);
     //act
     $questionRandomizer = new QuestionSelector();
     $fact_with_question = $questionRandomizer->getRandomQuestion($fact_id);
     //assert
     $this->assertArrayHasKeys(['fact_id', 'user_id', 'question_title', 'question_type', 'fact'], $fact_with_question);
 }
 public function insertAnswerAsFactWithDefaultQuestions($answer)
 {
     $fact_id = Fact::create(['user_id' => $this->user_id, 'fact' => $answer])->id;
     $questions = [['fact_id' => $fact_id, 'question_title' => 'Can you create a test question from this fact?', 'question_type' => 1], ['fact_id' => $fact_id, 'question_title' => 'Write this fact in your own words', 'question_type' => 2], ['fact_id' => $fact_id, 'question_title' => 'Write a paragraph about the fact and its related implications', 'question_type' => 3], ['fact_id' => $fact_id, 'question_title' => 'How can you apply this to your day, or life in general?', 'question_type' => 4], ['fact_id' => $fact_id, 'question_title' => 'Can you find a related fact to this fact', 'question_type' => 5]];
     Question::insert($questions);
 }
Beispiel #4
0
 /**
  *excel试题处理并入库
  */
 public function excel_insert($path, $e_id)
 {
     $objPHPExcel = \PHPExcel_IOFactory::load($path);
     $data = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
     //print_R($data);die;
     unset($data[1]);
     $arr = array();
     $aa = '0';
     foreach ($data as $k => &$val) {
         //所有值为空
         if (trim($val['A']) == '' && trim($val['B']) == '' && trim($val['C']) == '' && trim($val['D']) == '' && trim($val['E']) == '') {
             unset($data[$k]);
             continue;
         }
         //取判断题
         if ($val['B'] == '判断题') {
             $arr[$k]['knowledge'] = '';
             $arr[$k]['q_type'] = $val['B'];
             $arr[$k]['q_title'] = $val['C'];
             $arr[$k]['q_choose'] = $val['D'];
             $arr[$k]['addtime'] = time();
             $arr[$k]['e_id'] = $e_id;
             continue;
         }
         //取选择题
         if ($val['B'] == '选择题') {
             $arr[$k]['knowledge'] = $val['A'];
             $arr[$k]['q_type'] = $val['B'];
             $arr[$k]['q_title'] = $val['C'];
             $arr[$k]['addtime'] = time();
             $arr[$k]['e_id'] = $e_id;
             $aa = $k;
             continue;
         } else {
             if ($aa == '0') {
                 continue;
             }
             if (!isset($arr[$aa]['q_choose'])) {
                 $arr[$aa]['q_choose'] = '';
             }
             $arr[$aa]['q_choose'] .= $val['D'] . md5('key1') . $val['E'] . MD5('key2');
         }
     }
     //print_R($arr);die;
     //入库
     foreach ($arr as $val) {
         $question_model = new Question();
         $question_model->q_type = $val['q_type'];
         $question_model->knowledge = $val['knowledge'];
         $question_model->q_title = $val['q_title'];
         $question_model->q_choose = $val['q_choose'];
         $question_model->addtime = $val['addtime'];
         $question_model->e_id = $val['e_id'];
         $question_model->insert();
     }
     return count($arr);
 }