Created
November 12, 2017 11:15
-
-
Save Cyberiaaxis/9276d50e9f2892350b86256fe2766a30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ouput of request | |
"_token" => "AEVBOOFQToeqh0yhCiTdJR7peCerZeWpUAIKWwzj" | |
"category_id" => "1" | |
"topic_id" => "1" | |
"question_text" => "question" | |
"option1" => "ans1" | |
"option2" => "ans2" | |
"option3" => "ans3" | |
"option4" => "ans4" | |
"option5" => "ans5" | |
"correct" => "option3" | |
"code_snippet" => "code area" | |
"answer_explanation" => "Answer explanation*" | |
"more_info_link" => "More info link" | |
$ques = new Question(); | |
$ques->question_text = $request['question_text']; | |
$ques->code_snippet = $request['code_snippet']; | |
$ques->answer_explanation = $request['answer_explanation']; | |
$ques->more_info_link = $request['more_info_link']; | |
$ques->category_id = $request['category_id']; | |
$ques->topic_id = $request['topic_id']; | |
$ques->save(); | |
foreach ($request->input() as $key => $value) { | |
if(strpos($key, 'option') !== false && $value != '') { | |
var_dump($key); | |
$status = $request->input('correct') == $key ? 1 : 0; | |
QuestionsOption::create([ | |
'question_id' => $question->id, | |
'option' => $value, | |
'correct' => $status | |
]); | |
} | |
} | |
var_dump($key); ouput | |
i am getting this | |
/var/www/quiz/app/Http/Controllers/QuestionsController.php:82:string '_token' (length=6) | |
/var/www/quiz/app/Http/Controllers/QuestionsController.php:82:string 'category_id' (length=11) | |
/var/www/quiz/app/Http/Controllers/QuestionsController.php:82:string 'topic_id' (length=8) | |
/var/www/quiz/app/Http/Controllers/QuestionsController.php:82:string 'question_text' (length=13) | |
/var/www/quiz/app/Http/Controllers/QuestionsController.php:82:string 'option1' (length=7) | |
should be here | |
"option1" => "ans1" | |
"option2" => "ans2" | |
"option3" => "ans3" | |
"option4" => "ans4" | |
"option5" => "ans5" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment