What is the aim of this line $survey->option_name; ? It does nothing.
Sep 11, 2022
9
Level 1
Single question/ page.
Hello i have work on a Survey project and on view survey page where survey load i want to show only 1 Question. Once user choose an answer, they will allow to proceed to next Question. Currently on page will show all questions that current survey have.
public function viewsurvey(Survey $survey)
{
$survey->option_name;
return view('offerwall.view', compact('survey'));
}
<div class="mx-0 mx-sm-auto">
<div class="card">
<div class="card-header bg-primary">
<h5 class="card-title text-white mt-2" id="exampleModalLabel">{{ $survey->title }}</h5>
</div>
<div class="modal-body">
<div class="text-center">
<i class="far fa-file-alt fa-4x mb-3 text-primary"></i>
<p>
<strong>Your opinion matters</strong>
</p>
<p>
{{ $survey->description }}?
<strong>Give us your feedback.</strong>
</p>
</div>
<hr />
{!! Form::open(array('action'=>array('App\Http\Controllers\AnswerController@store', $survey->id))) !!}
@forelse ($survey->questions as $key=>$question)
<p class="flow-text">Question {{ $key+1 }} - {{ $question->title }}</p>
@if($question->question_type === 'text')
<div class="input-field col s12">
<input id="answer" class="block p-2.5 mb-2 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:outline-none" type="text" name="{{ $question->id }}[answer]">
</div>
@elseif($question->question_type === 'textarea')
<div class="input-field col s12">
<textarea id="textarea1" class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded border border-gray-300 placeholder-gray-400 focus:outline-none" name="{{ $question->id }}[answer]"></textarea>
</div>
@elseif($question->question_type === 'radio')
@foreach((array)$question->option_name as $key=>$value)
<p style="margin:0px; padding:0px;">
<input name="{{ $question->id }}[answer]" class="w-4 h-4 text-blue-600 bg-gray-100 focus:outline-none" type="radio" id="{{ $key }}" />
<label for="{{ $key }}">{{ $value }}</label>
</p>
@endforeach
@elseif($question->question_type === 'checkbox')
@foreach((array)$question->option_name as $key=>$value)
<p style="margin:0px; padding:0px;">
<input type="checkbox" id="something{{ $key }}" class="w-4 h-4 text-blue-600 bg-gray-100 focus:outline-none" name="{{ $question->id }}[answer]" />
<label for="something{{$key}}">{{ $value }}</label>
</p>
@endforeach
@endif
<div class="divider" style="margin:10px 10px;"></div>
@empty
<span class='flow-text center-align'>Nothing to show</span>
@endforelse
{{ Form::submit('Submit Survey', array('class'=>'btn waves-effect waves-light')) }}
{!! Form::close() !!}
</div>
<div class="card-footer text-end">
<button type="button" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
Please or to participate in this conversation.