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


PHP Question::insert方法代码示例

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


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

示例1: add

 public function add(Request $request, $code)
 {
     $variants = '';
     $arr_answers = [];
     $answers = explode('|', $request->input('variants-1')[1])[0];
     for ($i = 0; $i < $request->input('number_of_blocks'); $i++) {
         for ($j = 1; $j < count($request->input('variants-' . ($i + 1))); $j++) {
             if ($i == 0 && $j == 1) {
                 $variants = explode('|', $request->input('variants-' . ($i + 1))[$j])[0];
             }
             if ($j == 1 && $i != 0) {
                 $variants = $variants . '<>' . explode('|', $request->input('variants-' . ($i + 1))[$j])[0];
             }
             if ($j != 1) {
                 $variants = $variants . ';' . $request->input('variants-' . ($i + 1))[$j];
             }
         }
         if ($i != 0) {
             $answers = $answers . ';' . explode('|', $request->input('variants-' . ($i + 1))[1])[0];
         }
         $arr_answers[$i] = $request->input('variants-' . ($i + 1))[1];
         print_r($arr_answers);
     }
     $variants = $variants . '%' . $request->input('variants-1')[0];
     for ($i = 2; $i <= $request->input('number_of_blocks'); $i++) {
         $variants = $variants . ';' . $request->input('variants-' . $i)[0];
     }
     $wet_text = $request->input('title');
     for ($i = 0; $i < count($arr_answers); $i++) {
         $wet_text = preg_replace('~' . explode('|', $arr_answers[$i])[0] . '\\|' . explode('|', $arr_answers[$i])[1] . '~', '<>', $wet_text);
     }
     Question::insert(array('code' => $code, 'title' => $wet_text, 'variants' => $variants, 'answer' => $answers, 'points' => $request->input('points')));
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:33,代码来源:FillGaps.php

示例2: 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

示例3: 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

示例4: add

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

示例5: add

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

示例6: add

 public function add(Request $request, $code)
 {
     Question::insert(array('code' => $code, 'title' => $request->input('title'), 'variants' => '', 'answer' => '', 'points' => $request->input('points')));
 }
开发者ID:mrudanov,项目名称:uirSV,代码行数:4,代码来源:JustAnswer.php


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