feat: questionnaire management (Fasa 6)
- QuestionnaireSetController: full CRUD + publish/archive - QuestionController: store, update, destroy, reorder - ProgramQuestionnaireController: attach, confirm, detach - Public/QuestionnaireController: show form, submit responses, double-submit guard - Views: admin questionnaire CRUD, program questionnaire assign, public form + thankyou/already Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,86 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Program;
|
||||||
|
use App\Models\ProgramQuestionnaire;
|
||||||
|
use App\Models\QuestionnaireSet;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class ProgramQuestionnaireController extends Controller
|
class ProgramQuestionnaireController extends Controller
|
||||||
{
|
{
|
||||||
//
|
public function show(Program $program): View
|
||||||
|
{
|
||||||
|
$pq = $program->questionnaire()->with('questionnaireSet.questions')->first();
|
||||||
|
|
||||||
|
$availableSets = QuestionnaireSet::where('status', 'published')
|
||||||
|
->withCount('questions')
|
||||||
|
->orderBy('title')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('admin.programs.questionnaire.show', compact('program', 'pq', 'availableSets'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attach(Request $request, Program $program): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'questionnaire_set_id' => 'required|exists:questionnaire_sets,id',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($program->questionnaire()->exists()) {
|
||||||
|
return back()->with('error', 'Program ini sudah ada soalselidik dilampirkan. Tanggalkan dahulu sebelum lampir yang baru.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$set = QuestionnaireSet::findOrFail($data['questionnaire_set_id']);
|
||||||
|
|
||||||
|
if ($set->status !== 'published') {
|
||||||
|
return back()->with('error', 'Hanya soalselidik yang diterbitkan boleh dilampirkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgramQuestionnaire::create([
|
||||||
|
'program_id' => $program->id,
|
||||||
|
'questionnaire_set_id' => $set->id,
|
||||||
|
'is_confirmed' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'Soalselidik berjaya dilampirkan. Sila sahkan sebelum program bermula.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confirm(Request $request, Program $program): RedirectResponse
|
||||||
|
{
|
||||||
|
$pq = $program->questionnaire;
|
||||||
|
|
||||||
|
if (! $pq) {
|
||||||
|
return back()->with('error', 'Tiada soalselidik untuk disahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pq->update([
|
||||||
|
'is_confirmed' => true,
|
||||||
|
'confirmed_at' => now(),
|
||||||
|
'confirmed_by' => auth()->id(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'Soalselidik telah disahkan untuk program ini.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detach(Program $program): RedirectResponse
|
||||||
|
{
|
||||||
|
$pq = $program->questionnaire;
|
||||||
|
|
||||||
|
if (! $pq) {
|
||||||
|
return back()->with('error', 'Tiada soalselidik untuk ditanggalkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pq->is_confirmed) {
|
||||||
|
$hasResponses = \App\Models\QuestionnaireResponse::where('program_id', $program->id)->exists();
|
||||||
|
if ($hasResponses) {
|
||||||
|
return back()->with('error', 'Soalselidik tidak boleh ditanggalkan kerana sudah ada respons diterima.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pq->delete();
|
||||||
|
|
||||||
|
return back()->with('success', 'Soalselidik berjaya ditanggalkan.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,87 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\QuestionnaireQuestion;
|
||||||
|
use App\Models\QuestionnaireSet;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class QuestionController extends Controller
|
class QuestionController extends Controller
|
||||||
{
|
{
|
||||||
//
|
public function store(Request $request, QuestionnaireSet $set): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'question_text' => 'required|string|max:1000',
|
||||||
|
'question_type' => 'required|in:rating,single_choice,multiple_choice,short_text,long_text',
|
||||||
|
'is_required' => 'boolean',
|
||||||
|
'options' => 'nullable|array',
|
||||||
|
'options.*' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$needsOptions = in_array($data['question_type'], ['single_choice', 'multiple_choice']);
|
||||||
|
if ($needsOptions && empty($data['options'])) {
|
||||||
|
return back()->withErrors(['options' => 'Pilihan jawapan diperlukan untuk jenis soalan ini.'])->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
$maxOrder = $set->questions()->max('sort_order') ?? 0;
|
||||||
|
|
||||||
|
$set->questions()->create([
|
||||||
|
'question_text' => $data['question_text'],
|
||||||
|
'question_type' => $data['question_type'],
|
||||||
|
'is_required' => $data['is_required'] ?? true,
|
||||||
|
'options_json' => $needsOptions ? array_values(array_filter($data['options'] ?? [])) : null,
|
||||||
|
'sort_order' => $maxOrder + 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.questionnaires.show', $set)
|
||||||
|
->with('success', 'Soalan berjaya ditambah.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, QuestionnaireQuestion $question): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'question_text' => 'required|string|max:1000',
|
||||||
|
'question_type' => 'required|in:rating,single_choice,multiple_choice,short_text,long_text',
|
||||||
|
'is_required' => 'boolean',
|
||||||
|
'options' => 'nullable|array',
|
||||||
|
'options.*' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$needsOptions = in_array($data['question_type'], ['single_choice', 'multiple_choice']);
|
||||||
|
|
||||||
|
$question->update([
|
||||||
|
'question_text' => $data['question_text'],
|
||||||
|
'question_type' => $data['question_type'],
|
||||||
|
'is_required' => $data['is_required'] ?? true,
|
||||||
|
'options_json' => $needsOptions ? array_values(array_filter($data['options'] ?? [])) : null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.questionnaires.show', $question->questionnaire_set_id)
|
||||||
|
->with('success', 'Soalan berjaya dikemaskini.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(QuestionnaireQuestion $question): RedirectResponse
|
||||||
|
{
|
||||||
|
$setId = $question->questionnaire_set_id;
|
||||||
|
$question->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.questionnaires.show', $setId)
|
||||||
|
->with('success', 'Soalan berjaya dipadam.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reorder(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'order' => 'required|array',
|
||||||
|
'order.*' => 'integer|exists:questionnaire_questions,id',
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($data['order'] as $sortOrder => $questionId) {
|
||||||
|
QuestionnaireQuestion::where('id', $questionId)
|
||||||
|
->update(['sort_order' => $sortOrder + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['ok' => true]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,63 +3,108 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\QuestionnaireSet;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class QuestionnaireSetController extends Controller
|
class QuestionnaireSetController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
public function index(Request $request): View
|
||||||
* Display a listing of the resource.
|
|
||||||
*/
|
|
||||||
public function index()
|
|
||||||
{
|
{
|
||||||
//
|
$query = QuestionnaireSet::withCount('questions')
|
||||||
|
->with('creator')
|
||||||
|
->latest();
|
||||||
|
|
||||||
|
if ($request->filled('q')) {
|
||||||
|
$query->where('title', 'like', '%' . $request->q . '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('status')) {
|
||||||
|
$query->where('status', $request->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sets = $query->paginate(20)->withQueryString();
|
||||||
|
|
||||||
|
return view('admin.questionnaires.index', compact('sets'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function create(): View
|
||||||
* Show the form for creating a new resource.
|
|
||||||
*/
|
|
||||||
public function create()
|
|
||||||
{
|
{
|
||||||
//
|
return view('admin.questionnaires.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function store(Request $request): RedirectResponse
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*/
|
|
||||||
public function store(Request $request)
|
|
||||||
{
|
{
|
||||||
//
|
$data = $request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'description' => 'nullable|string|max:1000',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['created_by'] = auth()->id();
|
||||||
|
$data['status'] = 'draft';
|
||||||
|
|
||||||
|
$set = QuestionnaireSet::create($data);
|
||||||
|
|
||||||
|
return redirect()->route('admin.questionnaires.show', $set)
|
||||||
|
->with('success', 'Set soalselidik berjaya dicipta.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function show(QuestionnaireSet $set): View
|
||||||
* Display the specified resource.
|
|
||||||
*/
|
|
||||||
public function show(string $id)
|
|
||||||
{
|
{
|
||||||
//
|
$set->load(['questions', 'creator']);
|
||||||
|
$usedInPrograms = $set->programs()->get();
|
||||||
|
|
||||||
|
return view('admin.questionnaires.show', compact('set', 'usedInPrograms'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function edit(QuestionnaireSet $set): View
|
||||||
* Show the form for editing the specified resource.
|
|
||||||
*/
|
|
||||||
public function edit(string $id)
|
|
||||||
{
|
{
|
||||||
//
|
return view('admin.questionnaires.edit', compact('set'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function update(Request $request, QuestionnaireSet $set): RedirectResponse
|
||||||
* Update the specified resource in storage.
|
|
||||||
*/
|
|
||||||
public function update(Request $request, string $id)
|
|
||||||
{
|
{
|
||||||
//
|
$data = $request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
'description' => 'nullable|string|max:1000',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$set->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('admin.questionnaires.show', $set)
|
||||||
|
->with('success', 'Set soalselidik berjaya dikemaskini.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function destroy(QuestionnaireSet $set): RedirectResponse
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*/
|
|
||||||
public function destroy(string $id)
|
|
||||||
{
|
{
|
||||||
//
|
$confirmed = $set->programQuestionnaires()->where('is_confirmed', true)->exists();
|
||||||
|
|
||||||
|
if ($confirmed) {
|
||||||
|
return back()->with('error', 'Soalselidik ini tidak boleh dipadam kerana sudah disahkan untuk program.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$set->delete();
|
||||||
|
|
||||||
|
return redirect()->route('admin.questionnaires.index')
|
||||||
|
->with('success', 'Set soalselidik berjaya dipadam.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publish(QuestionnaireSet $set): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($set->questions()->count() === 0) {
|
||||||
|
return back()->with('error', 'Tambah sekurang-kurangnya satu soalan sebelum menerbitkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$set->update(['status' => 'published']);
|
||||||
|
|
||||||
|
return back()->with('success', 'Set soalselidik diterbitkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function archive(QuestionnaireSet $set): RedirectResponse
|
||||||
|
{
|
||||||
|
$set->update(['status' => 'archived']);
|
||||||
|
|
||||||
|
return back()->with('success', 'Set soalselidik diarkibkan.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,119 @@
|
|||||||
namespace App\Http\Controllers\Public;
|
namespace App\Http\Controllers\Public;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Participant;
|
||||||
|
use App\Models\ProgramQrCode;
|
||||||
|
use App\Models\QuestionnaireResponse;
|
||||||
|
use App\Models\QuestionnaireAnswer;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class QuestionnaireController extends Controller
|
class QuestionnaireController extends Controller
|
||||||
{
|
{
|
||||||
//
|
public function show(string $qr_token, string $participant_uuid): View|RedirectResponse
|
||||||
|
{
|
||||||
|
$qrCode = ProgramQrCode::where('token', $qr_token)->where('is_active', true)->firstOrFail();
|
||||||
|
$program = $qrCode->program;
|
||||||
|
|
||||||
|
$participant = Participant::where('uuid', $participant_uuid)->firstOrFail();
|
||||||
|
|
||||||
|
// Verify participant belongs to this program
|
||||||
|
$pp = $program->programParticipants()->where('participant_id', $participant->id)->first();
|
||||||
|
abort_if(! $pp, 404);
|
||||||
|
|
||||||
|
$pq = $program->questionnaire()->with('questionnaireSet.questions')->first();
|
||||||
|
|
||||||
|
if (! $pq || ! $pq->is_confirmed) {
|
||||||
|
// No questionnaire — go straight to semak page
|
||||||
|
return redirect()->route('public.semak.show', $qr_token);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check already submitted
|
||||||
|
$alreadySubmitted = QuestionnaireResponse::where('program_id', $program->id)
|
||||||
|
->where('participant_id', $participant->id)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($alreadySubmitted) {
|
||||||
|
return view('public.questionnaire.already', compact('program', 'participant', 'qrCode'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$questions = $pq->questionnaireSet->questions;
|
||||||
|
|
||||||
|
return view('public.questionnaire.show', compact('program', 'participant', 'qrCode', 'pq', 'questions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function submit(Request $request, string $qr_token, string $participant_uuid): View|RedirectResponse
|
||||||
|
{
|
||||||
|
$qrCode = ProgramQrCode::where('token', $qr_token)->where('is_active', true)->firstOrFail();
|
||||||
|
$program = $qrCode->program;
|
||||||
|
|
||||||
|
$participant = Participant::where('uuid', $participant_uuid)->firstOrFail();
|
||||||
|
|
||||||
|
$pp = $program->programParticipants()->where('participant_id', $participant->id)->first();
|
||||||
|
abort_if(! $pp, 404);
|
||||||
|
|
||||||
|
$pq = $program->questionnaire()->with('questionnaireSet.questions')->first();
|
||||||
|
abort_if(! $pq || ! $pq->is_confirmed, 404);
|
||||||
|
|
||||||
|
// Prevent double-submit
|
||||||
|
$existing = QuestionnaireResponse::where('program_id', $program->id)
|
||||||
|
->where('participant_id', $participant->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existing) {
|
||||||
|
return view('public.questionnaire.already', compact('program', 'participant', 'qrCode'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$questions = $pq->questionnaireSet->questions;
|
||||||
|
|
||||||
|
// Validate required questions
|
||||||
|
$rules = [];
|
||||||
|
foreach ($questions as $q) {
|
||||||
|
if ($q->is_required) {
|
||||||
|
$rules['q_' . $q->id] = 'required';
|
||||||
|
} else {
|
||||||
|
$rules['q_' . $q->id] = 'nullable';
|
||||||
|
}
|
||||||
|
if ($q->question_type === 'multiple_choice') {
|
||||||
|
$rules['q_' . $q->id] = ($q->is_required ? 'required|' : 'nullable|') . 'array';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate($rules, [
|
||||||
|
'q_*.required' => 'Soalan ini wajib dijawab.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Save response
|
||||||
|
$response = QuestionnaireResponse::create([
|
||||||
|
'program_id' => $program->id,
|
||||||
|
'participant_id' => $participant->id,
|
||||||
|
'questionnaire_set_id' => $pq->questionnaire_set_id,
|
||||||
|
'submitted_at' => now(),
|
||||||
|
'ip_address' => $request->ip(),
|
||||||
|
'user_agent' => substr($request->userAgent() ?? '', 0, 500),
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($questions as $q) {
|
||||||
|
$raw = $request->input('q_' . $q->id);
|
||||||
|
|
||||||
|
if ($raw === null && ! $q->is_required) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = match ($q->question_type) {
|
||||||
|
'multiple_choice' => (array) $raw,
|
||||||
|
'rating' => (int) $raw,
|
||||||
|
default => $raw,
|
||||||
|
};
|
||||||
|
|
||||||
|
QuestionnaireAnswer::create([
|
||||||
|
'questionnaire_response_id' => $response->id,
|
||||||
|
'questionnaire_question_id' => $q->id,
|
||||||
|
'answer_value' => $value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('public.questionnaire.thankyou', compact('program', 'participant', 'qrCode'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
171
resources/views/admin/programs/questionnaire/show.blade.php
Normal file
171
resources/views/admin/programs/questionnaire/show.blade.php
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
@extends('layouts.admin')
|
||||||
|
|
||||||
|
@section('title', 'Soalselidik — ' . $program->title)
|
||||||
|
@section('header', 'Urus Soalselidik Program')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.programs.index') }}">Program</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.programs.show', $program) }}">{{ Str::limit($program->title, 30) }}</a></li>
|
||||||
|
<li class="breadcrumb-item active">Soalselidik</li>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('header-actions')
|
||||||
|
<a href="{{ route('admin.programs.show', $program) }}#tab-questionnaire" class="btn btn-sm btn-outline-secondary">
|
||||||
|
<i class="bi bi-arrow-left me-1"></i> Kembali
|
||||||
|
</a>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
{{-- Current Questionnaire --}}
|
||||||
|
<div class="col-md-7">
|
||||||
|
<div class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white py-3">
|
||||||
|
<h6 class="mb-0 fw-semibold"><i class="bi bi-clipboard2-check me-2 text-primary"></i>Soalselidik Semasa</h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
@if($pq && $pq->questionnaireSet)
|
||||||
|
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||||
|
<div>
|
||||||
|
<div class="fw-semibold">{{ $pq->questionnaireSet->title }}</div>
|
||||||
|
<div class="text-muted small">{{ $pq->questionnaireSet->questions->count() }} soalan</div>
|
||||||
|
@if($pq->questionnaireSet->description)
|
||||||
|
<div class="text-muted small mt-1">{{ $pq->questionnaireSet->description }}</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@if($pq->is_confirmed)
|
||||||
|
<span class="badge bg-success fs-6 px-3 py-2">
|
||||||
|
<i class="bi bi-check-circle me-1"></i> Disahkan
|
||||||
|
</span>
|
||||||
|
@else
|
||||||
|
<span class="badge bg-warning text-dark fs-6 px-3 py-2">
|
||||||
|
<i class="bi bi-exclamation-circle me-1"></i> Belum Disahkan
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($pq->is_confirmed)
|
||||||
|
<div class="alert alert-success small mb-3">
|
||||||
|
<i class="bi bi-info-circle me-1"></i>
|
||||||
|
Disahkan oleh <strong>{{ $pq->confirmedBy?->name ?? '—' }}</strong>
|
||||||
|
pada {{ $pq->confirmed_at?->format('d M Y, H:i') }}.
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="alert alert-warning small mb-3">
|
||||||
|
<i class="bi bi-exclamation-triangle me-1"></i>
|
||||||
|
Soalselidik perlu <strong>disahkan</strong> sebelum peserta boleh menjawab.
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="{{ route('admin.programs.questionnaire.confirm', $program) }}" class="mb-3">
|
||||||
|
@csrf
|
||||||
|
<button class="btn btn-success w-100" onclick="return confirm('Sahkan soalselidik ini untuk program?')">
|
||||||
|
<i class="bi bi-check-circle me-2"></i> Sahkan Soalselidik
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- List Questions --}}
|
||||||
|
<div class="border rounded p-3 bg-light">
|
||||||
|
<div class="small fw-medium text-muted mb-2">Senarai Soalan:</div>
|
||||||
|
@foreach($pq->questionnaireSet->questions as $q)
|
||||||
|
<div class="d-flex align-items-start gap-2 mb-2">
|
||||||
|
<span class="badge bg-secondary flex-shrink-0">{{ $loop->iteration }}</span>
|
||||||
|
<div>
|
||||||
|
<div class="small">{{ $q->question_text }}</div>
|
||||||
|
<span class="badge bg-light text-dark border" style="font-size:0.65rem;">
|
||||||
|
{{ match($q->question_type) {
|
||||||
|
'rating' => 'Rating',
|
||||||
|
'single_choice' => 'Pilihan Tunggal',
|
||||||
|
'multiple_choice' => 'Pilihan Berganda',
|
||||||
|
'short_text' => 'Teks Pendek',
|
||||||
|
'long_text' => 'Teks Panjang',
|
||||||
|
} }}
|
||||||
|
</span>
|
||||||
|
@if($q->is_required)
|
||||||
|
<span class="badge bg-danger bg-opacity-10 text-danger" style="font-size:0.65rem;">Wajib</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Detach --}}
|
||||||
|
<div class="mt-3">
|
||||||
|
<form method="POST" action="{{ route('admin.programs.questionnaire.detach', $program) }}"
|
||||||
|
onsubmit="return confirm('Tanggalkan soalselidik dari program ini?')">
|
||||||
|
@csrf @method('DELETE')
|
||||||
|
<button class="btn btn-sm btn-outline-danger">
|
||||||
|
<i class="bi bi-x-circle me-1"></i> Tanggalkan Soalselidik
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@else
|
||||||
|
<div class="text-center py-4 text-muted">
|
||||||
|
<i class="bi bi-clipboard2-x d-block fs-1 mb-3 opacity-25"></i>
|
||||||
|
<p class="mb-0">Belum ada soalselidik dilampirkan untuk program ini.</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Right: Attach New --}}
|
||||||
|
@if(! $pq)
|
||||||
|
<div class="col-md-5">
|
||||||
|
<div class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white py-3">
|
||||||
|
<h6 class="mb-0 fw-semibold"><i class="bi bi-clipboard2-plus me-2 text-success"></i>Lampir Soalselidik</h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
@if($availableSets->isEmpty())
|
||||||
|
<div class="alert alert-info small">
|
||||||
|
<i class="bi bi-info-circle me-1"></i>
|
||||||
|
Tiada set soalselidik yang diterbitkan.
|
||||||
|
<a href="{{ route('admin.questionnaires.create') }}">Buat set baru.</a>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<form method="POST" action="{{ route('admin.programs.questionnaire.attach', $program) }}">
|
||||||
|
@csrf
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-medium small">Pilih Set Soalselidik <span class="text-danger">*</span></label>
|
||||||
|
<select name="questionnaire_set_id"
|
||||||
|
class="form-select @error('questionnaire_set_id') is-invalid @enderror">
|
||||||
|
<option value="">— Pilih —</option>
|
||||||
|
@foreach($availableSets as $qs)
|
||||||
|
<option value="{{ $qs->id }}" {{ old('questionnaire_set_id') == $qs->id ? 'selected' : '' }}>
|
||||||
|
{{ $qs->title }} ({{ $qs->questions_count }} soalan)
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error('questionnaire_set_id')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="alert alert-info small">
|
||||||
|
<i class="bi bi-lightbulb me-1"></i>
|
||||||
|
Selepas lampir, anda perlu <strong>sahkan</strong> soalselidik sebelum peserta boleh menjawab.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-success w-100">
|
||||||
|
<i class="bi bi-clipboard2-plus me-2"></i> Lampir & Teruskan
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="mt-3 text-center">
|
||||||
|
<a href="{{ route('admin.questionnaires.index') }}" class="small text-muted">
|
||||||
|
<i class="bi bi-gear me-1"></i> Urus Set Soalselidik
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
50
resources/views/admin/questionnaires/create.blade.php
Normal file
50
resources/views/admin/questionnaires/create.blade.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
@extends('layouts.admin')
|
||||||
|
|
||||||
|
@section('title', 'Buat Set Soalselidik Baru')
|
||||||
|
@section('header', 'Buat Set Soalselidik')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.questionnaires.index') }}">Soalselidik</a></li>
|
||||||
|
<li class="breadcrumb-item active">Buat Baru</li>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-7">
|
||||||
|
<div class="card border-0 shadow-sm">
|
||||||
|
<div class="card-body p-4">
|
||||||
|
<form method="POST" action="{{ route('admin.questionnaires.store') }}">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-medium">Tajuk Set <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="title" value="{{ old('title') }}"
|
||||||
|
class="form-control @error('title') is-invalid @enderror"
|
||||||
|
placeholder="cth: Borang Penilaian Program 2025">
|
||||||
|
@error('title')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label fw-medium">Keterangan</label>
|
||||||
|
<textarea name="description" rows="3"
|
||||||
|
class="form-control @error('description') is-invalid @enderror"
|
||||||
|
placeholder="Keterangan ringkas tentang soalselidik ini (pilihan)">{{ old('description') }}</textarea>
|
||||||
|
@error('description')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
<i class="bi bi-check-lg me-1"></i> Simpan & Tambah Soalan
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('admin.questionnaires.index') }}" class="btn btn-outline-secondary">
|
||||||
|
Batal
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
50
resources/views/admin/questionnaires/edit.blade.php
Normal file
50
resources/views/admin/questionnaires/edit.blade.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
@extends('layouts.admin')
|
||||||
|
|
||||||
|
@section('title', 'Edit Set Soalselidik')
|
||||||
|
@section('header', 'Edit Set Soalselidik')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.questionnaires.index') }}">Soalselidik</a></li>
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.questionnaires.show', $set) }}">{{ Str::limit($set->title, 30) }}</a></li>
|
||||||
|
<li class="breadcrumb-item active">Edit</li>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-7">
|
||||||
|
<div class="card border-0 shadow-sm">
|
||||||
|
<div class="card-body p-4">
|
||||||
|
<form method="POST" action="{{ route('admin.questionnaires.update', $set) }}">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label fw-medium">Tajuk Set <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="title" value="{{ old('title', $set->title) }}"
|
||||||
|
class="form-control @error('title') is-invalid @enderror">
|
||||||
|
@error('title')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label fw-medium">Keterangan</label>
|
||||||
|
<textarea name="description" rows="3"
|
||||||
|
class="form-control @error('description') is-invalid @enderror">{{ old('description', $set->description) }}</textarea>
|
||||||
|
@error('description')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
<i class="bi bi-check-lg me-1"></i> Kemaskini
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('admin.questionnaires.show', $set) }}" class="btn btn-outline-secondary">
|
||||||
|
Batal
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
107
resources/views/admin/questionnaires/index.blade.php
Normal file
107
resources/views/admin/questionnaires/index.blade.php
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
@extends('layouts.admin')
|
||||||
|
|
||||||
|
@section('title', 'Set Soalselidik')
|
||||||
|
@section('header', 'Set Soalselidik')
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<li class="breadcrumb-item active">Soalselidik</li>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('header-actions')
|
||||||
|
<a href="{{ route('admin.questionnaires.create') }}" class="btn btn-sm btn-primary">
|
||||||
|
<i class="bi bi-plus-lg me-1"></i> Buat Set Baru
|
||||||
|
</a>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white py-3">
|
||||||
|
<form method="GET" class="row g-2 align-items-end">
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input type="text" name="q" value="{{ request('q') }}"
|
||||||
|
class="form-control form-control-sm" placeholder="Cari tajuk soalselidik...">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<select name="status" class="form-select form-select-sm">
|
||||||
|
<option value="">Semua Status</option>
|
||||||
|
<option value="draft" {{ request('status') === 'draft' ? 'selected' : '' }}>Draf</option>
|
||||||
|
<option value="published" {{ request('status') === 'published' ? 'selected' : '' }}>Diterbitkan</option>
|
||||||
|
<option value="archived" {{ request('status') === 'archived' ? 'selected' : '' }}>Diarkib</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="submit" class="btn btn-sm btn-outline-secondary">
|
||||||
|
<i class="bi bi-search"></i> Cari
|
||||||
|
</button>
|
||||||
|
@if(request()->hasAny(['q', 'status']))
|
||||||
|
<a href="{{ route('admin.questionnaires.index') }}" class="btn btn-sm btn-link text-muted">Set Semula</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle mb-0">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Tajuk</th>
|
||||||
|
<th class="text-center">Soalan</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Dicipta Oleh</th>
|
||||||
|
<th>Tarikh Cipta</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($sets as $set)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{{ route('admin.questionnaires.show', $set) }}" class="fw-medium text-decoration-none">
|
||||||
|
{{ $set->title }}
|
||||||
|
</a>
|
||||||
|
@if($set->description)
|
||||||
|
<div class="text-muted small text-truncate" style="max-width:300px;">{{ $set->description }}</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<span class="badge bg-secondary">{{ $set->questions_count }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@if($set->status === 'published')
|
||||||
|
<span class="badge bg-success">Diterbitkan</span>
|
||||||
|
@elseif($set->status === 'archived')
|
||||||
|
<span class="badge bg-secondary">Diarkib</span>
|
||||||
|
@else
|
||||||
|
<span class="badge bg-warning text-dark">Draf</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="small text-muted">{{ $set->creator?->name ?? '—' }}</td>
|
||||||
|
<td class="small text-muted">{{ $set->created_at->format('d/m/Y') }}</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<a href="{{ route('admin.questionnaires.show', $set) }}"
|
||||||
|
class="btn btn-sm btn-outline-primary">
|
||||||
|
<i class="bi bi-eye"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="text-center py-4 text-muted">
|
||||||
|
<i class="bi bi-clipboard2-x d-block fs-2 mb-2 opacity-25"></i>
|
||||||
|
Tiada set soalselidik dijumpai.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($sets->hasPages())
|
||||||
|
<div class="card-footer bg-white">
|
||||||
|
{{ $sets->links() }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
294
resources/views/admin/questionnaires/show.blade.php
Normal file
294
resources/views/admin/questionnaires/show.blade.php
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
@extends('layouts.admin')
|
||||||
|
|
||||||
|
@section('title', $set->title)
|
||||||
|
@section('header', $set->title)
|
||||||
|
|
||||||
|
@section('breadcrumb')
|
||||||
|
<li class="breadcrumb-item"><a href="{{ route('admin.questionnaires.index') }}">Soalselidik</a></li>
|
||||||
|
<li class="breadcrumb-item active">{{ Str::limit($set->title, 35) }}</li>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('header-actions')
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<a href="{{ route('admin.questionnaires.edit', $set) }}" class="btn btn-sm btn-outline-secondary">
|
||||||
|
<i class="bi bi-pencil me-1"></i> Edit
|
||||||
|
</a>
|
||||||
|
@if($set->status === 'draft')
|
||||||
|
<form method="POST" action="{{ route('admin.questionnaires.publish', $set) }}">
|
||||||
|
@csrf
|
||||||
|
<button class="btn btn-sm btn-success" onclick="return confirm('Terbitkan set soalselidik ini?')">
|
||||||
|
<i class="bi bi-send me-1"></i> Terbitkan
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@elseif($set->status === 'published')
|
||||||
|
<form method="POST" action="{{ route('admin.questionnaires.archive', $set) }}">
|
||||||
|
@csrf
|
||||||
|
<button class="btn btn-sm btn-outline-secondary" onclick="return confirm('Arkibkan set soalselidik ini?')">
|
||||||
|
<i class="bi bi-archive me-1"></i> Arkib
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="row g-4">
|
||||||
|
{{-- Left: Questions --}}
|
||||||
|
<div class="col-md-8">
|
||||||
|
|
||||||
|
{{-- Status Banner --}}
|
||||||
|
@if($set->status === 'draft')
|
||||||
|
<div class="alert alert-warning mb-3 small">
|
||||||
|
<i class="bi bi-exclamation-triangle me-2"></i>
|
||||||
|
Set ini masih dalam status <strong>Draf</strong>. Terbitkan setelah siap untuk dilampirkan ke program.
|
||||||
|
</div>
|
||||||
|
@elseif($set->status === 'archived')
|
||||||
|
<div class="alert alert-secondary mb-3 small">
|
||||||
|
<i class="bi bi-archive me-2"></i>
|
||||||
|
Set ini telah <strong>diarkibkan</strong> dan tidak boleh dilampirkan ke program baru.
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Question List --}}
|
||||||
|
<div class="card border-0 shadow-sm mb-4">
|
||||||
|
<div class="card-header bg-white d-flex justify-content-between align-items-center py-3">
|
||||||
|
<h6 class="mb-0 fw-semibold">
|
||||||
|
<i class="bi bi-list-ul me-2 text-primary"></i>Senarai Soalan
|
||||||
|
<span class="badge bg-secondary ms-2">{{ $set->questions->count() }}</span>
|
||||||
|
</h6>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($set->questions->isEmpty())
|
||||||
|
<div class="card-body text-center py-5 text-muted">
|
||||||
|
<i class="bi bi-question-circle d-block fs-1 mb-3 opacity-25"></i>
|
||||||
|
Belum ada soalan. Tambah soalan menggunakan borang di sebelah kanan.
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<ul class="list-group list-group-flush" id="questionList">
|
||||||
|
@foreach($set->questions as $q)
|
||||||
|
<li class="list-group-item py-3" data-id="{{ $q->id }}">
|
||||||
|
<div class="d-flex justify-content-between align-items-start gap-2">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<div class="d-flex align-items-center gap-2 mb-1">
|
||||||
|
<span class="badge bg-light text-dark border small">{{ $loop->iteration }}</span>
|
||||||
|
<span class="badge bg-primary bg-opacity-10 text-primary small">
|
||||||
|
{{ match($q->question_type) {
|
||||||
|
'rating' => 'Rating',
|
||||||
|
'single_choice' => 'Pilihan Tunggal',
|
||||||
|
'multiple_choice' => 'Pilihan Berganda',
|
||||||
|
'short_text' => 'Teks Pendek',
|
||||||
|
'long_text' => 'Teks Panjang',
|
||||||
|
default => $q->question_type,
|
||||||
|
} }}
|
||||||
|
</span>
|
||||||
|
@if($q->is_required)
|
||||||
|
<span class="badge bg-danger bg-opacity-10 text-danger small">Wajib</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="fw-medium">{{ $q->question_text }}</div>
|
||||||
|
@if($q->options_json)
|
||||||
|
<div class="mt-1">
|
||||||
|
@foreach($q->options_json as $opt)
|
||||||
|
<span class="badge bg-light text-dark border me-1 small">{{ $opt }}</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div class="d-flex gap-1 flex-shrink-0">
|
||||||
|
<button class="btn btn-sm btn-outline-secondary"
|
||||||
|
onclick="editQuestion({{ $q->id }}, @json($q->question_text), '{{ $q->question_type }}', {{ $q->is_required ? 'true' : 'false' }}, @json($q->options_json ?? []))">
|
||||||
|
<i class="bi bi-pencil"></i>
|
||||||
|
</button>
|
||||||
|
<form method="POST" action="{{ route('admin.questions.destroy', $q) }}"
|
||||||
|
onsubmit="return confirm('Padam soalan ini?')">
|
||||||
|
@csrf @method('DELETE')
|
||||||
|
<button class="btn btn-sm btn-outline-danger">
|
||||||
|
<i class="bi bi-trash"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Used In Programs --}}
|
||||||
|
@if($usedInPrograms->count())
|
||||||
|
<div class="card border-0 shadow-sm">
|
||||||
|
<div class="card-header bg-white py-3">
|
||||||
|
<h6 class="mb-0 fw-semibold"><i class="bi bi-diagram-3 me-2 text-secondary"></i>Digunakan Dalam Program</h6>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
@foreach($usedInPrograms as $program)
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center py-2">
|
||||||
|
<a href="{{ route('admin.programs.show', $program) }}" class="text-decoration-none small">
|
||||||
|
{{ $program->title }}
|
||||||
|
</a>
|
||||||
|
@if($program->pivot->is_confirmed ?? false)
|
||||||
|
<span class="badge bg-success">Disahkan</span>
|
||||||
|
@else
|
||||||
|
<span class="badge bg-warning text-dark">Belum Disahkan</span>
|
||||||
|
@endif
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Right: Add / Edit Question Form --}}
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="card border-0 shadow-sm sticky-top" style="top:80px;">
|
||||||
|
<div class="card-header bg-white py-3">
|
||||||
|
<h6 class="mb-0 fw-semibold" id="formTitle"><i class="bi bi-plus-circle me-2 text-primary"></i>Tambah Soalan</h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
{{-- Add Question Form --}}
|
||||||
|
<form method="POST" id="questionForm" action="{{ route('admin.questions.store', $set) }}">
|
||||||
|
@csrf
|
||||||
|
<input type="hidden" name="_method" id="formMethod" value="POST">
|
||||||
|
<input type="hidden" name="_question_id" id="questionId" value="">
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label small fw-medium">Soalan <span class="text-danger">*</span></label>
|
||||||
|
<textarea name="question_text" id="questionText" rows="3"
|
||||||
|
class="form-control form-control-sm @error('question_text') is-invalid @enderror"
|
||||||
|
placeholder="Taip soalan di sini..."></textarea>
|
||||||
|
@error('question_text')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label small fw-medium">Jenis Soalan <span class="text-danger">*</span></label>
|
||||||
|
<select name="question_type" id="questionType" class="form-select form-select-sm" onchange="toggleOptions()">
|
||||||
|
<option value="rating">Rating (1–5)</option>
|
||||||
|
<option value="single_choice">Pilihan Tunggal</option>
|
||||||
|
<option value="multiple_choice">Pilihan Berganda</option>
|
||||||
|
<option value="short_text">Teks Pendek</option>
|
||||||
|
<option value="long_text">Teks Panjang</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3 form-check">
|
||||||
|
<input type="checkbox" name="is_required" id="isRequired" class="form-check-input" value="1" checked>
|
||||||
|
<label class="form-check-label small" for="isRequired">Wajib dijawab</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="optionsSection" class="mb-3 d-none">
|
||||||
|
<label class="form-label small fw-medium">Pilihan Jawapan</label>
|
||||||
|
<div id="optionsList">
|
||||||
|
<div class="input-group input-group-sm mb-2">
|
||||||
|
<input type="text" name="options[]" class="form-control" placeholder="Pilihan 1">
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>
|
||||||
|
</div>
|
||||||
|
<div class="input-group input-group-sm mb-2">
|
||||||
|
<input type="text" name="options[]" class="form-control" placeholder="Pilihan 2">
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-sm btn-outline-secondary w-100" onclick="addOption()">
|
||||||
|
<i class="bi bi-plus me-1"></i> Tambah Pilihan
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary btn-sm w-100">
|
||||||
|
<i class="bi bi-check-lg me-1"></i> <span id="submitLabel">Tambah</span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-sm" id="cancelEdit" style="display:none;" onclick="resetForm()">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
const setId = {{ $set->id }};
|
||||||
|
const storeUrl = "{{ route('admin.questions.store', $set) }}";
|
||||||
|
const updateBase = "{{ url('admin/questions') }}/";
|
||||||
|
|
||||||
|
function toggleOptions() {
|
||||||
|
const type = document.getElementById('questionType').value;
|
||||||
|
const section = document.getElementById('optionsSection');
|
||||||
|
section.classList.toggle('d-none', !['single_choice','multiple_choice'].includes(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addOption() {
|
||||||
|
const list = document.getElementById('optionsList');
|
||||||
|
const count = list.querySelectorAll('input').length + 1;
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.className = 'input-group input-group-sm mb-2';
|
||||||
|
div.innerHTML = `<input type="text" name="options[]" class="form-control" placeholder="Pilihan ${count}">
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>`;
|
||||||
|
list.appendChild(div);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeOption(btn) {
|
||||||
|
const list = document.getElementById('optionsList');
|
||||||
|
if (list.querySelectorAll('.input-group').length > 1) {
|
||||||
|
btn.closest('.input-group').remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function editQuestion(id, text, type, required, options) {
|
||||||
|
document.getElementById('formTitle').innerHTML = '<i class="bi bi-pencil me-2 text-warning"></i>Edit Soalan';
|
||||||
|
document.getElementById('submitLabel').textContent = 'Kemaskini';
|
||||||
|
document.getElementById('cancelEdit').style.display = '';
|
||||||
|
document.getElementById('questionId').value = id;
|
||||||
|
document.getElementById('questionText').value = text;
|
||||||
|
document.getElementById('questionType').value = type;
|
||||||
|
document.getElementById('isRequired').checked = required;
|
||||||
|
|
||||||
|
const form = document.getElementById('questionForm');
|
||||||
|
form.action = updateBase + id;
|
||||||
|
document.getElementById('formMethod').value = 'PUT';
|
||||||
|
|
||||||
|
toggleOptions();
|
||||||
|
|
||||||
|
const list = document.getElementById('optionsList');
|
||||||
|
list.innerHTML = '';
|
||||||
|
if (options && options.length) {
|
||||||
|
options.forEach((opt, i) => {
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.className = 'input-group input-group-sm mb-2';
|
||||||
|
div.innerHTML = `<input type="text" name="options[]" class="form-control" value="${opt}" placeholder="Pilihan ${i+1}">
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>`;
|
||||||
|
list.appendChild(div);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
form.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetForm() {
|
||||||
|
document.getElementById('formTitle').innerHTML = '<i class="bi bi-plus-circle me-2 text-primary"></i>Tambah Soalan';
|
||||||
|
document.getElementById('submitLabel').textContent = 'Tambah';
|
||||||
|
document.getElementById('cancelEdit').style.display = 'none';
|
||||||
|
document.getElementById('questionForm').reset();
|
||||||
|
document.getElementById('questionForm').action = storeUrl;
|
||||||
|
document.getElementById('formMethod').value = 'POST';
|
||||||
|
document.getElementById('questionId').value = '';
|
||||||
|
document.getElementById('optionsSection').classList.add('d-none');
|
||||||
|
|
||||||
|
const list = document.getElementById('optionsList');
|
||||||
|
list.innerHTML = `<div class="input-group input-group-sm mb-2">
|
||||||
|
<input type="text" name="options[]" class="form-control" placeholder="Pilihan 1">
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>
|
||||||
|
</div>
|
||||||
|
<div class="input-group input-group-sm mb-2">
|
||||||
|
<input type="text" name="options[]" class="form-control" placeholder="Pilihan 2">
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
35
resources/views/public/questionnaire/already.blade.php
Normal file
35
resources/views/public/questionnaire/already.blade.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
@extends('layouts.public')
|
||||||
|
|
||||||
|
@section('title', 'Sudah Dihantar — ' . $program->title)
|
||||||
|
|
||||||
|
@section('hero')
|
||||||
|
<h4 class="mb-1">{{ $program->title }}</h4>
|
||||||
|
<div class="opacity-75 small">
|
||||||
|
<i class="bi bi-clipboard2-check me-1"></i>Borang Penilaian
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="checkin-card card p-4 text-center">
|
||||||
|
<div class="rounded-circle bg-info bg-opacity-10 d-inline-flex align-items-center justify-content-center mx-auto mb-3"
|
||||||
|
style="width:70px; height:70px;">
|
||||||
|
<i class="bi bi-info-circle-fill text-info" style="font-size:2rem;"></i>
|
||||||
|
</div>
|
||||||
|
<h5 class="fw-bold mb-2">Sudah Dihantar</h5>
|
||||||
|
<p class="text-muted small mb-4">
|
||||||
|
Maklum balas anda untuk program ini sudah pernah dihantar sebelum ini.
|
||||||
|
Setiap peserta hanya boleh menghantar satu maklum balas.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="alert alert-info text-start small mb-4">
|
||||||
|
<i class="bi bi-award me-2"></i>
|
||||||
|
Sijil Digital (eCert) akan dihantar ke emel anda setelah program tamat.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="{{ route('public.semak.show', $qrCode->token) }}" class="btn btn-outline-primary btn-sm">
|
||||||
|
<i class="bi bi-search me-1"></i> Semak Status Sijil
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
100
resources/views/public/questionnaire/show.blade.php
Normal file
100
resources/views/public/questionnaire/show.blade.php
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
@extends('layouts.public')
|
||||||
|
|
||||||
|
@section('title', 'Borang Penilaian — ' . $program->title)
|
||||||
|
|
||||||
|
@section('hero')
|
||||||
|
<h4 class="mb-1">{{ $program->title }}</h4>
|
||||||
|
<div class="opacity-75 small">
|
||||||
|
<i class="bi bi-clipboard2-check me-1"></i>Borang Penilaian Program
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="checkin-card card p-4 mb-3">
|
||||||
|
<div class="text-center mb-4">
|
||||||
|
<div class="rounded-circle bg-primary bg-opacity-10 d-inline-flex align-items-center justify-content-center mx-auto mb-3"
|
||||||
|
style="width:70px; height:70px;">
|
||||||
|
<i class="bi bi-clipboard2-check-fill text-primary" style="font-size:2rem;"></i>
|
||||||
|
</div>
|
||||||
|
<h5 class="fw-bold mb-1">{{ $pq->questionnaireSet->title }}</h5>
|
||||||
|
<p class="text-muted small mb-0">
|
||||||
|
Sila jawab semua soalan sebelum memuat turun sijil anda, {{ $participant->name }}.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="POST" action="{{ route('public.questionnaire.submit', [$qrCode->token, $participant->uuid]) }}">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
@foreach($questions as $q)
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label fw-medium">
|
||||||
|
{{ $loop->iteration }}. {{ $q->question_text }}
|
||||||
|
@if($q->is_required)
|
||||||
|
<span class="text-danger">*</span>
|
||||||
|
@endif
|
||||||
|
</label>
|
||||||
|
|
||||||
|
@error('q_' . $q->id)
|
||||||
|
<div class="text-danger small mb-1"><i class="bi bi-exclamation-circle me-1"></i>{{ $message }}</div>
|
||||||
|
@enderror
|
||||||
|
|
||||||
|
@if($q->question_type === 'rating')
|
||||||
|
<div class="d-flex gap-2 flex-wrap">
|
||||||
|
@for($i = 1; $i <= 5; $i++)
|
||||||
|
<div class="form-check form-check-inline">
|
||||||
|
<input class="form-check-input" type="radio"
|
||||||
|
name="q_{{ $q->id }}" id="q{{ $q->id }}_{{ $i }}"
|
||||||
|
value="{{ $i }}" {{ old('q_'.$q->id) == $i ? 'checked' : '' }}>
|
||||||
|
<label class="form-check-label" for="q{{ $q->id }}_{{ $i }}">
|
||||||
|
{{ $i }}
|
||||||
|
@if($i === 1) <small class="text-muted">(Sangat Tidak Setuju)</small>
|
||||||
|
@elseif($i === 5) <small class="text-muted">(Sangat Setuju)</small>
|
||||||
|
@endif
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
@endfor
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@elseif($q->question_type === 'single_choice')
|
||||||
|
@foreach($q->options_json ?? [] as $opt)
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio"
|
||||||
|
name="q_{{ $q->id }}" id="q{{ $q->id }}_{{ $loop->index }}"
|
||||||
|
value="{{ $opt }}" {{ old('q_'.$q->id) === $opt ? 'checked' : '' }}>
|
||||||
|
<label class="form-check-label" for="q{{ $q->id }}_{{ $loop->index }}">{{ $opt }}</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
@elseif($q->question_type === 'multiple_choice')
|
||||||
|
@foreach($q->options_json ?? [] as $opt)
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox"
|
||||||
|
name="q_{{ $q->id }}[]" id="q{{ $q->id }}_{{ $loop->index }}"
|
||||||
|
value="{{ $opt }}"
|
||||||
|
{{ in_array($opt, (array)(old('q_'.$q->id) ?? [])) ? 'checked' : '' }}>
|
||||||
|
<label class="form-check-label" for="q{{ $q->id }}_{{ $loop->index }}">{{ $opt }}</label>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
@elseif($q->question_type === 'short_text')
|
||||||
|
<input type="text" name="q_{{ $q->id }}"
|
||||||
|
class="form-control @error('q_'.$q->id) is-invalid @enderror"
|
||||||
|
value="{{ old('q_'.$q->id) }}"
|
||||||
|
placeholder="Jawapan anda...">
|
||||||
|
|
||||||
|
@elseif($q->question_type === 'long_text')
|
||||||
|
<textarea name="q_{{ $q->id }}" rows="4"
|
||||||
|
class="form-control @error('q_'.$q->id) is-invalid @enderror"
|
||||||
|
placeholder="Jawapan anda...">{{ old('q_'.$q->id) }}</textarea>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary w-100 btn-checkin">
|
||||||
|
<i class="bi bi-send me-2"></i>Hantar Maklum Balas
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
41
resources/views/public/questionnaire/thankyou.blade.php
Normal file
41
resources/views/public/questionnaire/thankyou.blade.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
@extends('layouts.public')
|
||||||
|
|
||||||
|
@section('title', 'Terima Kasih — ' . $program->title)
|
||||||
|
|
||||||
|
@section('hero')
|
||||||
|
<h4 class="mb-1">{{ $program->title }}</h4>
|
||||||
|
<div class="opacity-75 small">
|
||||||
|
<i class="bi bi-clipboard2-check me-1"></i>Maklum Balas Diterima
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<div class="checkin-card card p-4 text-center">
|
||||||
|
<div class="rounded-circle bg-success bg-opacity-10 d-inline-flex align-items-center justify-content-center mx-auto mb-3"
|
||||||
|
style="width:70px; height:70px;">
|
||||||
|
<i class="bi bi-heart-fill text-success" style="font-size:2rem;"></i>
|
||||||
|
</div>
|
||||||
|
<h5 class="fw-bold text-success mb-2">Terima Kasih!</h5>
|
||||||
|
<p class="text-muted small mb-4">
|
||||||
|
Maklum balas anda telah berjaya dihantar, <strong>{{ $participant->name }}</strong>.
|
||||||
|
Kami menghargai pandangan anda.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="alert alert-info text-start small mb-4">
|
||||||
|
<i class="bi bi-award me-2"></i>
|
||||||
|
<strong>Sijil Digital (eCert)</strong> anda akan dihantar ke emel
|
||||||
|
@if($participant->email)
|
||||||
|
<strong>{{ $participant->email }}</strong>
|
||||||
|
@else
|
||||||
|
yang didaftarkan
|
||||||
|
@endif
|
||||||
|
setelah program tamat.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="{{ route('public.semak.show', $qrCode->token) }}" class="btn btn-outline-primary btn-sm">
|
||||||
|
<i class="bi bi-search me-1"></i> Semak Status Sijil
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
Reference in New Issue
Block a user