remove column in addiction test

This commit is contained in:
misbahsurur 2024-12-20 18:35:35 +07:00
parent 3b8990d6a3
commit 49caec88af
2 changed files with 16 additions and 26 deletions

View File

@ -37,9 +37,7 @@ public function history()
public function addiction() public function addiction()
{ {
$items = Item::with('factor') $items = Item::where('status', 'active')->get();
->get()
->groupBy('factor.name');
$likerts = Likert::orderBy('score')->get(); $likerts = Likert::orderBy('score')->get();
return view('user.addiction', compact('items', 'likerts')); return view('user.addiction', compact('items', 'likerts'));

View File

@ -20,34 +20,26 @@
<table class="table table-bordered w-100 text-wrap align-middle"> <table class="table table-bordered w-100 text-wrap align-middle">
<thead> <thead>
<tr> <tr>
<th>Factor</th>
<th class="text-center">Item</th>
<th>Item Content</th> <th>Item Content</th>
<th class="text-center">Select Answer</th> <th class="text-center">Select Answer</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach ($items as $factorName => $groupedItems) @foreach ($items as $item)
@foreach ($groupedItems as $item) <tr>
<tr> <td class="text-wrap">{{ $item->content }}</td>
@if ($loop->first) <td class="text-center">
<td rowspan="{{ $groupedItems->count() }}">{{ $factorName }}</td> <input type="hidden" name="values[]" value="{{ $item->value }}">
@endif <select name="answers[]" class="form-select" required>
<td class="text-center">{{ $item->code }}</td> <option value="" hidden>Select Answer</option>
<td class="text-wrap">{{ $item->content }}</td> @foreach ($likerts as $likert)
<td class="text-center"> <option value="{{ $likert->score }}" {{ in_array($likert->score, old('answers', [])) ? 'selected' : '' }}>
<input type="hidden" name="values[]" value="{{ $item->value }}"> {{ $likert->name }}
<select name="answers[]" class="form-select" required> </option>
<option value="" hidden>Select Answer</option> @endforeach
@foreach ($likerts as $likert) </select>
<option value="{{ $likert->score }}" {{ in_array($likert->score, old('answers', [])) ? 'selected' : '' }}> </td>
{{ $likert->name }} </tr>
</option>
@endforeach
</select>
</td>
</tr>
@endforeach
@endforeach @endforeach
</tbody> </tbody>
</table> </table>