1
0
tinklu-it-projektas/resources/views/tests/edit.blade.php

148 lines
7.2 KiB
PHP

<x-app-layout>
<div class="max-w-2xl mx-auto p-4 sm:p-6 lg:p-8">
<form method="POST" action="{{ route('tests.update', $test) }}">
@csrf
@method("patch")
<div class="flex flex-col gap-1">
<x-input-label>{{ __("Name") }}</x-input-label>
<x-text-input name="name" placeholder="{{ __('Name') }}" value="{{ old('name', $test->name) }}" />
<x-input-error :messages="$errors->get('name')" class="mt-2" />
</div>
<div class="mt-4 space-x-2">
<x-primary-button>{{ __("Save") }}</x-primary-button>
<a href="{{ route('tests.index') }}">{{ __("Cancel") }}</a>
</div>
</form>
<hr class="mt-6 mb-6">
<div>
<h2 class="text-center text-lg font-medium">{{ __("Questions") }}</h2>
<form method="POST" action="{{ route('questions.store') }}">
@csrf
<div class="flex flex-col gap-1">
<x-question-fields
:test_id="$test->id"
/>
</div>
<div class="mt-4 space-x-2">
<x-primary-button>{{ __("Add question") }}</x-primary-button>
</div>
</form>
<table class="mt-6 border border-gray-300 w-full text-left">
<tr>
<th class="border border-gray-300 p-1">{{ __("Question") }}</th>
<th class="border border-gray-300 p-1">{{ __("Answer") }}</th>
<th class="border border-gray-300 p-1">{{ __("Points") }}</th>
<th class="border border-gray-300 p-1"></th>
</tr>
@foreach ($questions as $question)
<tr>
<td class="border border-gray-300 p-1">{{ $question->question }}</td>
<td class="border border-gray-300 p-1">{{ $question->answer }}</td>
<td class="border border-gray-300 p-1">{{ $question->points }}</td>
<td class="border border-gray-300 p-1">
<x-dropdown>
<x-slot name="trigger">
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path d="M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM16 12a2 2 0 100-4 2 2 0 000 4z" />
</svg>
</button>
</x-slot>
<x-slot name="content">
<x-dropdown-link :href="route('questions.edit', $question)">
{{ __("Edit") }}
</x-dropdown-link>
<form method="POST" action="{{ route("questions.destroy", $question) }}">
@csrf
@method("delete")
<x-dropdown-link :href="route('questions.destroy', $question)" onclick="event.preventDefault(); this.closest('form').submit();">
{{ __("Delete") }}
</x-dropdown-link>
</form>
</x-slot>
</x-dropdown>
</td>
</tr>
@endforeach
</table>
</div>
<hr class="mt-6 mb-6">
<div>
<h2 class="text-center text-lg font-medium">{{ __("Assigned students") }}</h2>
<form method="POST" action="{{ route('assigned_tests.store') }}">
@csrf
<div class="flex flex-col gap-1">
<input type="hidden" value="{{ $test->id }}" name="test_id">
<x-input-label>{{ __("Student") }}</x-input-label>
<x-select name="student_id" id="student_id">
@if (sizeof($students) == 0)
<option selected disabled hidden>{{ __("-- Empty --") }}</option>
@endif
@foreach ($students as $student)
<option value="{{$student['id']}}" {{ old("student") == $student['id'] ? "selected" : "" }} >{{ $student['name'] }}</option>
@endforeach
</x-select>
</div>
<div class="mt-4 space-x-2">
<x-primary-button :disabled="sizeof($students) == 0">{{ __("Add student") }}</x-primary-button>
</div>
</form>
<table class="mt-6 border border-gray-300 w-full text-left">
<tr>
<th class="border border-gray-300 p-1">{{ __("Student") }}</th>
<th class="border border-gray-300 p-1">{{ __("Can take test") }}</th>
<th class="border border-gray-300 p-1"></th>
</tr>
@foreach ($assigned_students as $student)
<tr>
<td class="border border-gray-300 p-1">{{ $student->name }}</td>
<td class="border border-gray-300 p-1">{{ __($student->allowed ? "Yes" : "No") }}</td>
<td class="border border-gray-300 p-1">
<x-dropdown>
<x-slot name="trigger">
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path d="M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM16 12a2 2 0 100-4 2 2 0 000 4z" />
</svg>
</button>
</x-slot>
<x-slot name="content">
@if (!$student->allowed)
<x-dropdown-link :href="route('assigned_tests.edit', $student)">
{{ __("Allow to take test") }}
</x-dropdown-link>
@endif
<form method="POST" action="{{ route("assigned_tests.destroy", $student) }}">
@csrf
@method("delete")
<x-dropdown-link :href="route('assigned_tests.destroy', $student)" onclick="event.preventDefault(); this.closest('form').submit();">
{{ __("Delete") }}
</x-dropdown-link>
</form>
</x-slot>
</x-dropdown>
</td>
</tr>
@endforeach
</table>
</div>
<hr class="mt-6 mb-6">
<div>
<h2 class="text-center text-lg font-medium">{{ __("Test results") }}</h2>
</div>
</div>
</x-app-layout>