本文整理汇总了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')));
}
示例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')));
}
示例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')));
}
示例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')));
}
示例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')));
}
示例6: add
public function add(Request $request, $code)
{
Question::insert(array('code' => $code, 'title' => $request->input('title'), 'variants' => '', 'answer' => '', 'points' => $request->input('points')));
}