/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($id) { $disciplina_id = $id; $perguntas = Pergunta::perguntaComDisciplina($disciplina_id); $videos = Video::videoComDisciplina($disciplina_id); $arquivos = Arquivo::arquivoComDisciplina($disciplina_id); return view('admin.tabela', ['disciplina_id' => $disciplina_id, 'perguntas' => $perguntas, 'videos' => $videos, 'arquivos' => $arquivos]); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request, $id) { $attributes = []; for ($i = 0; $i < count($request->input('pergunta')); $i++) { $array = ['pergunta' => $request->input('pergunta')[$i], 'disciplina_id' => $id]; array_push($attributes, $array); } foreach ($attributes as $attributes) { $perguntaCadastrada = Pergunta::create($attributes); } if ($perguntaCadastrada) { return \Redirect::to('/intranet/admin/tabela/' . $id)->with('mensagem', '<div class="card-panel light-green darken-1" style="color: #FFF">Cadastrado com Sucesso !</div>'); } else { return \Redirect::to('/intranet/admin/tabela/' . $id)->with('mensagem', '<div class="card-panel red darken-1" style="color: #FFF">Ocorreu um erro interno ao fazer o cadastro, tente novamente mais tarde.</div>'); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($id) { $buscaPerguntas = Pergunta::where('disciplina_id', $id)->orderByRaw('RAND()')->limit(10)->get(); $perguntas = array(); foreach ($buscaPerguntas as $bp) { for ($i = 0; $i < count($buscaPerguntas); $i++) { $array = ['id_pergunta' => $bp->id, 'pergunta' => $bp->pergunta, 'opcoes' => array()]; $opcoes = []; $buscaOpcoes = Opcao::where('pergunta_id', $bp->id)->orderByRaw('RAND()')->get(); foreach ($buscaOpcoes as $bo) { array_push($array['opcoes'], array('id' => $bo->id, 'opcao' => $bo->opcao)); if ($bo->correta == 1) { $array['correta'] = $bo->opcao; } } } array_push($perguntas, $array); } return view('user.simulado', ['perguntas' => $perguntas, 'disciplina_id' => $id]); }