first
This commit is contained in:
@@ -29,9 +29,9 @@ public/build
|
||||
.phpunit.cache
|
||||
phpunit.xml
|
||||
|
||||
# Docker files (tidak perlu dalam app container)
|
||||
# Docker Compose files (tidak perlu dalam app container)
|
||||
docker-compose*.yml
|
||||
docker/
|
||||
# docker/ TIDAK diexclude — Dockerfile perlukan docker/entrypoint.sh dan docker/php/php.ini
|
||||
|
||||
# Logs & cache
|
||||
storage/logs/*
|
||||
|
||||
@@ -40,11 +40,16 @@ class ParticipantController extends Controller
|
||||
|
||||
$programParticipants = $query->paginate(20)->withQueryString();
|
||||
|
||||
$countRow = DB::table('program_participants')
|
||||
->where('program_id', $program->id)
|
||||
->selectRaw("COUNT(*) as total, SUM(is_pre_registered) as pre_registered, SUM(registration_source = 'walk_in') as walk_in, SUM(status = 'checked_in') as checked_in")
|
||||
->first();
|
||||
|
||||
$counts = [
|
||||
'total' => $program->programParticipants()->count(),
|
||||
'pre_registered' => $program->programParticipants()->where('is_pre_registered', true)->count(),
|
||||
'walk_in' => $program->programParticipants()->where('registration_source', 'walk_in')->count(),
|
||||
'checked_in' => $program->programParticipants()->where('status', 'checked_in')->count(),
|
||||
'total' => (int) ($countRow->total ?? 0),
|
||||
'pre_registered' => (int) ($countRow->pre_registered ?? 0),
|
||||
'walk_in' => (int) ($countRow->walk_in ?? 0),
|
||||
'checked_in' => (int) ($countRow->checked_in ?? 0),
|
||||
];
|
||||
|
||||
return view('admin.programs.participants.index', compact('program', 'programParticipants', 'counts'));
|
||||
|
||||
60
app/Http/Controllers/Admin/ProfileController.php
Normal file
60
app/Http/Controllers/Admin/ProfileController.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function show(): View
|
||||
{
|
||||
return view('admin.profile.show', ['user' => auth()->user()]);
|
||||
}
|
||||
|
||||
public function updateEmail(Request $request): RedirectResponse
|
||||
{
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'email' => ['required', 'email', 'max:255', 'unique:users,email,' . auth()->id()],
|
||||
], [
|
||||
'current_password.current_password' => 'Kata laluan semasa tidak betul.',
|
||||
'email.unique' => 'Alamat emel ini sudah digunakan.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator, 'email')->withInput();
|
||||
}
|
||||
|
||||
auth()->user()->update(['email' => $request->email]);
|
||||
|
||||
return back()->with('email_success', 'Alamat emel berjaya dikemaskini.');
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request): RedirectResponse
|
||||
{
|
||||
$validator = \Validator::make($request->all(), [
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'password' => ['required', 'confirmed', Password::min(8)],
|
||||
], [
|
||||
'current_password.current_password' => 'Kata laluan semasa tidak betul.',
|
||||
'password.min' => 'Kata laluan baru mestilah sekurang-kurangnya 8 aksara.',
|
||||
'password.confirmed' => 'Pengesahan kata laluan tidak sepadan.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator, 'password')->withInput();
|
||||
}
|
||||
|
||||
auth()->user()->update(['password' => Hash::make($request->password)]);
|
||||
|
||||
Auth::login(auth()->user());
|
||||
|
||||
return back()->with('password_success', 'Kata laluan berjaya ditukar.');
|
||||
}
|
||||
}
|
||||
@@ -70,13 +70,24 @@ class ProgramController extends Controller
|
||||
'questionnaire.questionnaireSet.questions',
|
||||
]);
|
||||
|
||||
// Consolidate into 2 queries instead of 6 separate COUNTs
|
||||
$ppStats = \DB::table('program_participants')
|
||||
->where('program_id', $program->id)
|
||||
->selectRaw("COUNT(*) as total, SUM(is_pre_registered) as pre_registered, SUM(registration_source = 'walk_in') as walk_in")
|
||||
->first();
|
||||
|
||||
$certStats = \DB::table('certificates')
|
||||
->where('program_id', $program->id)
|
||||
->selectRaw("COUNT(*) as total, SUM(status IN ('generated','emailed','downloaded')) as cert_generated")
|
||||
->first();
|
||||
|
||||
$stats = [
|
||||
'total_participants' => $program->programParticipants()->count(),
|
||||
'pre_registered' => $program->programParticipants()->where('is_pre_registered', true)->count(),
|
||||
'walk_in' => $program->programParticipants()->where('registration_source', 'walk_in')->count(),
|
||||
'total_participants' => (int) ($ppStats->total ?? 0),
|
||||
'pre_registered' => (int) ($ppStats->pre_registered ?? 0),
|
||||
'walk_in' => (int) ($ppStats->walk_in ?? 0),
|
||||
'total_attendances' => $program->attendances()->count(),
|
||||
'total_certificates' => $program->certificates()->count(),
|
||||
'generated_certificates'=> $program->certificates()->whereIn('status', ['generated', 'emailed', 'downloaded'])->count(),
|
||||
'total_certificates' => (int) ($certStats->total ?? 0),
|
||||
'generated_certificates' => (int) ($certStats->cert_generated ?? 0),
|
||||
];
|
||||
|
||||
return view('admin.programs.show', compact('program', 'stats'));
|
||||
|
||||
@@ -69,6 +69,23 @@ class ProgramQuestionnaireController extends Controller
|
||||
return back()->with('success', 'Soalselidik telah disahkan untuk program ini.');
|
||||
}
|
||||
|
||||
public function preview(Program $program): View|\Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$pq = $program->questionnaire()->with('questionnaireSet')->first();
|
||||
|
||||
if (! $pq || ! $pq->questionnaireSet) {
|
||||
return back()->with('error', 'Tiada soalselidik untuk dipratonton.');
|
||||
}
|
||||
|
||||
$questions = $pq->questionnaireSet->questions()
|
||||
->whereNull('parent_id')
|
||||
->with(['children' => fn($q) => $q->orderBy('sort_order')])
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
|
||||
return view('admin.programs.questionnaire.preview', compact('program', 'pq', 'questions'));
|
||||
}
|
||||
|
||||
public function detach(Program $program): RedirectResponse
|
||||
{
|
||||
$pq = $program->questionnaire;
|
||||
|
||||
@@ -13,26 +13,58 @@ class QuestionController extends Controller
|
||||
{
|
||||
public function store(Request $request, QuestionnaireSet $set): RedirectResponse
|
||||
{
|
||||
if ($request->has('options')) {
|
||||
$request->merge(['options' => array_values(array_filter($request->input('options', [])))]);
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'question_text' => 'required|string|max:1000',
|
||||
'question_type' => 'required|in:rating,single_choice,multiple_choice,short_text,long_text',
|
||||
'question_type' => 'required|in:tajuk,rating,single_choice,multiple_choice,short_text,long_text',
|
||||
'is_required' => 'boolean',
|
||||
'parent_id' => 'nullable|integer|exists:questionnaire_questions,id',
|
||||
'options' => 'nullable|array',
|
||||
'options.*' => 'required|string|max:255',
|
||||
'rating_labels' => 'nullable|array',
|
||||
'rating_labels.*' => 'nullable|string|max:100',
|
||||
]);
|
||||
|
||||
if ($data['question_type'] === 'rating') {
|
||||
if (empty($data['parent_id'])) {
|
||||
return back()->withErrors(['parent_id' => 'Soalan rating mesti diletakkan di bawah tajuk.'])->withInput();
|
||||
}
|
||||
$parent = QuestionnaireQuestion::find($data['parent_id']);
|
||||
if (! $parent || $parent->question_type !== 'tajuk') {
|
||||
return back()->withErrors(['parent_id' => 'Parent mesti jenis Tajuk.'])->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
$parentId = $data['question_type'] === 'rating' ? ($data['parent_id'] ?? null) : null;
|
||||
|
||||
$maxOrder = $set->questions()
|
||||
->when($parentId,
|
||||
fn($q) => $q->where('parent_id', $parentId),
|
||||
fn($q) => $q->whereNull('parent_id')
|
||||
)
|
||||
->max('sort_order') ?? 0;
|
||||
|
||||
$ratingLabels = null;
|
||||
if ($data['question_type'] === 'tajuk') {
|
||||
$filtered = array_filter($data['rating_labels'] ?? [], fn($v) => $v !== null && $v !== '');
|
||||
$ratingLabels = ! empty($filtered) ? $filtered : null;
|
||||
}
|
||||
|
||||
$set->questions()->create([
|
||||
'question_text' => $data['question_text'],
|
||||
'question_type' => $data['question_type'],
|
||||
'is_required' => $data['is_required'] ?? true,
|
||||
'parent_id' => $parentId,
|
||||
'is_required' => $data['question_type'] === 'tajuk' ? false : ($data['is_required'] ?? true),
|
||||
'options_json' => $needsOptions ? array_values(array_filter($data['options'] ?? [])) : null,
|
||||
'rating_labels' => $ratingLabels,
|
||||
'sort_order' => $maxOrder + 1,
|
||||
]);
|
||||
|
||||
@@ -42,21 +74,48 @@ class QuestionController extends Controller
|
||||
|
||||
public function update(Request $request, QuestionnaireQuestion $question): RedirectResponse
|
||||
{
|
||||
if ($request->has('options')) {
|
||||
$request->merge(['options' => array_values(array_filter($request->input('options', [])))]);
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'question_text' => 'required|string|max:1000',
|
||||
'question_type' => 'required|in:rating,single_choice,multiple_choice,short_text,long_text',
|
||||
'question_type' => 'required|in:tajuk,rating,single_choice,multiple_choice,short_text,long_text',
|
||||
'is_required' => 'boolean',
|
||||
'parent_id' => 'nullable|integer|exists:questionnaire_questions,id',
|
||||
'options' => 'nullable|array',
|
||||
'options.*' => 'required|string|max:255',
|
||||
'rating_labels' => 'nullable|array',
|
||||
'rating_labels.*' => 'nullable|string|max:100',
|
||||
]);
|
||||
|
||||
if ($data['question_type'] === 'rating') {
|
||||
if (empty($data['parent_id'])) {
|
||||
return back()->withErrors(['parent_id' => 'Soalan rating mesti diletakkan di bawah tajuk.'])->withInput();
|
||||
}
|
||||
$parent = QuestionnaireQuestion::find($data['parent_id']);
|
||||
if (! $parent || $parent->question_type !== 'tajuk') {
|
||||
return back()->withErrors(['parent_id' => 'Parent mesti jenis Tajuk.'])->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
$needsOptions = in_array($data['question_type'], ['single_choice', 'multiple_choice']);
|
||||
|
||||
$parentId = $data['question_type'] === 'rating' ? ($data['parent_id'] ?? null) : null;
|
||||
|
||||
$ratingLabels = null;
|
||||
if ($data['question_type'] === 'tajuk') {
|
||||
$filtered = array_filter($data['rating_labels'] ?? [], fn($v) => $v !== null && $v !== '');
|
||||
$ratingLabels = ! empty($filtered) ? $filtered : null;
|
||||
}
|
||||
|
||||
$question->update([
|
||||
'question_text' => $data['question_text'],
|
||||
'question_type' => $data['question_type'],
|
||||
'is_required' => $data['is_required'] ?? true,
|
||||
'parent_id' => $parentId,
|
||||
'is_required' => $data['question_type'] === 'tajuk' ? false : ($data['is_required'] ?? true),
|
||||
'options_json' => $needsOptions ? array_values(array_filter($data['options'] ?? [])) : null,
|
||||
'rating_labels' => $ratingLabels,
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.questionnaires.show', $question->questionnaire_set_id)
|
||||
@@ -66,6 +125,12 @@ class QuestionController extends Controller
|
||||
public function destroy(QuestionnaireQuestion $question): RedirectResponse
|
||||
{
|
||||
$setId = $question->questionnaire_set_id;
|
||||
|
||||
// Cascade-delete children if this is a tajuk (DB cascade handles it too, but be explicit)
|
||||
if ($question->question_type === 'tajuk') {
|
||||
$question->children()->delete();
|
||||
}
|
||||
|
||||
$question->delete();
|
||||
|
||||
return redirect()->route('admin.questionnaires.show', $setId)
|
||||
@@ -77,6 +142,7 @@ class QuestionController extends Controller
|
||||
$data = $request->validate([
|
||||
'order' => 'required|array',
|
||||
'order.*' => 'integer|exists:questionnaire_questions,id',
|
||||
'parent_id' => 'nullable|integer|exists:questionnaire_questions,id',
|
||||
]);
|
||||
|
||||
foreach ($data['order'] as $sortOrder => $questionId) {
|
||||
|
||||
@@ -52,10 +52,18 @@ class QuestionnaireSetController extends Controller
|
||||
|
||||
public function show(QuestionnaireSet $set): View
|
||||
{
|
||||
$set->load(['questions', 'creator']);
|
||||
$set->load('creator');
|
||||
|
||||
$topLevel = $set->questions()
|
||||
->whereNull('parent_id')
|
||||
->with(['children' => fn($q) => $q->orderBy('sort_order')])
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
|
||||
$totalCount = $set->questions()->count();
|
||||
$usedInPrograms = $set->programs()->get();
|
||||
|
||||
return view('admin.questionnaires.show', compact('set', 'usedInPrograms'));
|
||||
return view('admin.questionnaires.show', compact('set', 'topLevel', 'totalCount', 'usedInPrograms'));
|
||||
}
|
||||
|
||||
public function edit(QuestionnaireSet $set): View
|
||||
|
||||
@@ -17,7 +17,7 @@ class StatisticsController extends Controller
|
||||
{
|
||||
public function show(Program $program): View
|
||||
{
|
||||
$program->load(['attendances.participant', 'questionnaire.questionnaireSet.questions']);
|
||||
$program->load(['questionnaire.questionnaireSet.questions']);
|
||||
|
||||
// Attendance by session
|
||||
$bySession = $program->attendances()
|
||||
@@ -40,23 +40,29 @@ class StatisticsController extends Controller
|
||||
->pluck('total', 'status')
|
||||
->toArray();
|
||||
|
||||
// Response rate
|
||||
// Response rate + question stats
|
||||
$pq = $program->questionnaire;
|
||||
$responseRate = null;
|
||||
$questionStats = [];
|
||||
$totalResponses = 0;
|
||||
|
||||
if ($pq && $pq->is_confirmed) {
|
||||
$totalAttended = $program->attendances()->count();
|
||||
$totalAttended = array_sum($bySession); // reuse already-fetched data
|
||||
$totalResponses = QuestionnaireResponse::where('program_id', $program->id)->count();
|
||||
$responseRate = $totalAttended > 0 ? round($totalResponses / $totalAttended * 100) : 0;
|
||||
|
||||
// Rating question averages
|
||||
$questions = $pq->questionnaireSet->questions ?? collect();
|
||||
|
||||
// Load ALL answers in one query, group by question — avoids N+1
|
||||
$allAnswers = QuestionnaireAnswer::whereIn('questionnaire_question_id', $questions->pluck('id'))
|
||||
->get()
|
||||
->groupBy('questionnaire_question_id');
|
||||
|
||||
foreach ($questions as $q) {
|
||||
$answers = $allAnswers->get($q->id, collect());
|
||||
|
||||
if ($q->question_type === 'rating') {
|
||||
$answers = QuestionnaireAnswer::where('questionnaire_question_id', $q->id)
|
||||
->pluck('answer_value');
|
||||
$values = $answers->map(fn($v) => is_array($v) ? (int)($v[0] ?? 0) : (int)$v);
|
||||
$values = $answers->map(fn($a) => is_array($a->answer_value) ? (int) ($a->answer_value[0] ?? 0) : (int) $a->answer_value);
|
||||
$questionStats[] = [
|
||||
'id' => $q->id,
|
||||
'text' => $q->question_text,
|
||||
@@ -65,11 +71,9 @@ class StatisticsController extends Controller
|
||||
'count' => $values->count(),
|
||||
];
|
||||
} elseif (in_array($q->question_type, ['single_choice', 'multiple_choice'])) {
|
||||
$answers = QuestionnaireAnswer::where('questionnaire_question_id', $q->id)
|
||||
->pluck('answer_value');
|
||||
$counts = [];
|
||||
foreach ($answers as $val) {
|
||||
$items = is_array($val) ? $val : [$val];
|
||||
foreach ($answers as $row) {
|
||||
$items = is_array($row->answer_value) ? $row->answer_value : [$row->answer_value];
|
||||
foreach ($items as $item) {
|
||||
$counts[$item] = ($counts[$item] ?? 0) + 1;
|
||||
}
|
||||
@@ -86,14 +90,15 @@ class StatisticsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// Reuse data already computed above — no extra queries
|
||||
$summary = [
|
||||
'total_attendances' => $program->attendances()->count(),
|
||||
'pre_registered' => $program->attendances()->where('attendance_source', 'pre_registered_staff')->count(),
|
||||
'walk_in' => $program->attendances()->where('attendance_source', 'walk_in_external')->count(),
|
||||
'total_certificates' => $program->certificates()->count(),
|
||||
'generated_certs' => $program->certificates()->whereIn('status', ['generated', 'emailed', 'downloaded'])->count(),
|
||||
'downloaded_certs' => $program->certificates()->where('status', 'downloaded')->count(),
|
||||
'total_responses' => QuestionnaireResponse::where('program_id', $program->id)->count(),
|
||||
'total_attendances' => array_sum($bySession),
|
||||
'pre_registered' => $bySource['pre_registered_staff'] ?? 0,
|
||||
'walk_in' => $bySource['walk_in_external'] ?? 0,
|
||||
'total_certificates' => array_sum($certStats),
|
||||
'generated_certs' => ($certStats['generated'] ?? 0) + ($certStats['emailed'] ?? 0) + ($certStats['downloaded'] ?? 0),
|
||||
'downloaded_certs' => $certStats['downloaded'] ?? 0,
|
||||
'total_responses' => $totalResponses,
|
||||
];
|
||||
|
||||
return view('admin.programs.statistics.show', compact(
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\QuestionnaireResponse;
|
||||
use App\Models\QuestionnaireAnswer;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class QuestionnaireController extends Controller
|
||||
@@ -20,27 +21,20 @@ class QuestionnaireController extends Controller
|
||||
|
||||
$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();
|
||||
$pq = $program->questionnaire()->with('questionnaireSet')->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) {
|
||||
if (QuestionnaireResponse::where('program_id', $program->id)->where('participant_id', $participant->id)->exists()) {
|
||||
return view('public.questionnaire.already', compact('program', 'participant', 'qrCode'));
|
||||
}
|
||||
|
||||
$questions = $pq->questionnaireSet->questions;
|
||||
$questions = $this->loadHierarchical($pq);
|
||||
|
||||
return view('public.questionnaire.show', compact('program', 'participant', 'qrCode', 'pq', 'questions'));
|
||||
}
|
||||
@@ -55,38 +49,27 @@ class QuestionnaireController extends Controller
|
||||
$pp = $program->programParticipants()->where('participant_id', $participant->id)->first();
|
||||
abort_if(! $pp, 404);
|
||||
|
||||
$pq = $program->questionnaire()->with('questionnaireSet.questions')->first();
|
||||
$pq = $program->questionnaire()->with('questionnaireSet')->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) {
|
||||
if (QuestionnaireResponse::where('program_id', $program->id)->where('participant_id', $participant->id)->exists()) {
|
||||
return view('public.questionnaire.already', compact('program', 'participant', 'qrCode'));
|
||||
}
|
||||
|
||||
$questions = $pq->questionnaireSet->questions;
|
||||
$questions = $this->loadHierarchical($pq);
|
||||
$answerable = $this->flatten($questions);
|
||||
|
||||
// Validate required questions
|
||||
$rules = [];
|
||||
foreach ($questions as $q) {
|
||||
if ($q->is_required) {
|
||||
$rules['q_' . $q->id] = 'required';
|
||||
} else {
|
||||
$rules['q_' . $q->id] = 'nullable';
|
||||
}
|
||||
foreach ($answerable as $q) {
|
||||
if ($q->question_type === 'multiple_choice') {
|
||||
$rules['q_' . $q->id] = ($q->is_required ? 'required|' : 'nullable|') . 'array';
|
||||
} else {
|
||||
$rules['q_' . $q->id] = $q->is_required ? 'required' : 'nullable';
|
||||
}
|
||||
}
|
||||
|
||||
$validated = $request->validate($rules, [
|
||||
'q_*.required' => 'Soalan ini wajib dijawab.',
|
||||
]);
|
||||
$request->validate($rules, ['q_*.required' => 'Soalan ini wajib dijawab.']);
|
||||
|
||||
// Save response
|
||||
$response = QuestionnaireResponse::create([
|
||||
'program_id' => $program->id,
|
||||
'participant_id' => $participant->id,
|
||||
@@ -96,7 +79,7 @@ class QuestionnaireController extends Controller
|
||||
'user_agent' => substr($request->userAgent() ?? '', 0, 500),
|
||||
]);
|
||||
|
||||
foreach ($questions as $q) {
|
||||
foreach ($answerable as $q) {
|
||||
$raw = $request->input('q_' . $q->id);
|
||||
|
||||
if ($raw === null && ! $q->is_required) {
|
||||
@@ -118,4 +101,31 @@ class QuestionnaireController extends Controller
|
||||
|
||||
return view('public.questionnaire.thankyou', compact('program', 'participant', 'qrCode'));
|
||||
}
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
private function loadHierarchical($pq): Collection
|
||||
{
|
||||
return $pq->questionnaireSet->questions()
|
||||
->whereNull('parent_id')
|
||||
->with(['children' => fn($q) => $q->orderBy('sort_order')])
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
}
|
||||
|
||||
/** Return only answerable (non-tajuk) questions as a flat collection. */
|
||||
private function flatten(Collection $topLevel): Collection
|
||||
{
|
||||
$out = collect();
|
||||
foreach ($topLevel as $q) {
|
||||
if ($q->question_type === 'tajuk') {
|
||||
foreach ($q->children as $child) {
|
||||
$out->push($child);
|
||||
}
|
||||
} else {
|
||||
$out->push($q);
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class QuestionnaireQuestion extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'questionnaire_set_id', 'question_text', 'question_type',
|
||||
'options_json', 'is_required', 'sort_order',
|
||||
'questionnaire_set_id', 'parent_id', 'question_text', 'question_type',
|
||||
'options_json', 'rating_labels', 'is_required', 'sort_order',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'options_json' => 'array',
|
||||
'rating_labels' => 'array',
|
||||
'is_required' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
@@ -25,6 +26,16 @@ class QuestionnaireQuestion extends Model
|
||||
return $this->belongsTo(QuestionnaireSet::class);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(QuestionnaireQuestion::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(QuestionnaireQuestion::class, 'parent_id')->orderBy('sort_order');
|
||||
}
|
||||
|
||||
public function answers()
|
||||
{
|
||||
return $this->hasMany(QuestionnaireAnswer::class);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('questionnaire_questions', function (Blueprint $table) {
|
||||
$table->foreignId('parent_id')
|
||||
->nullable()
|
||||
->after('questionnaire_set_id')
|
||||
->constrained('questionnaire_questions')
|
||||
->cascadeOnDelete();
|
||||
|
||||
$table->json('rating_labels')->nullable()->after('options_json');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('questionnaire_questions', function (Blueprint $table) {
|
||||
$table->dropForeign(['parent_id']);
|
||||
$table->dropColumn(['parent_id', 'rating_labels']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE questionnaire_questions MODIFY COLUMN question_type ENUM('tajuk','rating','single_choice','multiple_choice','short_text','long_text') NOT NULL");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
DB::statement("ALTER TABLE questionnaire_questions MODIFY COLUMN question_type ENUM('rating','single_choice','multiple_choice','short_text','long_text') NOT NULL");
|
||||
}
|
||||
};
|
||||
@@ -11,14 +11,14 @@ class AdminSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
User::firstOrCreate(
|
||||
['email' => 'admin@mbip.gov.my'],
|
||||
['email' => 'saufi@mbip.gov.my'],
|
||||
[
|
||||
'name' => 'Admin eCert MBIP',
|
||||
'password' => Hash::make('Admin@MBIP2025!'),
|
||||
'password' => Hash::make('YongTauFu26'),
|
||||
'role' => 'super_admin',
|
||||
]
|
||||
);
|
||||
|
||||
$this->command->info('Admin account created: admin@mbip.gov.my / Admin@MBIP2025!');
|
||||
$this->command->info('Admin account created: saufi@mbip.gov.my / YongTauFu26');
|
||||
}
|
||||
}
|
||||
|
||||
137
resources/views/admin/profile/show.blade.php
Normal file
137
resources/views/admin/profile/show.blade.php
Normal file
@@ -0,0 +1,137 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title', 'Profil Saya')
|
||||
@section('header', 'Profil Saya')
|
||||
|
||||
@section('breadcrumb')
|
||||
<li class="breadcrumb-item active">Profil</li>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row g-4" style="max-width:760px;">
|
||||
|
||||
{{-- Account Info --}}
|
||||
<div class="col-12">
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body d-flex align-items-center gap-3 py-3">
|
||||
<div class="rounded-circle bg-primary bg-opacity-10 d-flex align-items-center justify-content-center flex-shrink-0"
|
||||
style="width:52px;height:52px;">
|
||||
<i class="bi bi-person-fill text-primary fs-4"></i>
|
||||
</div>
|
||||
<div>
|
||||
<div class="fw-semibold">{{ $user->name }}</div>
|
||||
<div class="text-muted small">{{ $user->email }}</div>
|
||||
<span class="badge {{ $user->isSuperAdmin() ? 'bg-danger' : 'bg-primary' }} mt-1">
|
||||
{{ $user->isSuperAdmin() ? 'Super Admin' : 'Admin Program' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Update Email --}}
|
||||
<div class="col-md-6">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-header bg-white py-3">
|
||||
<h6 class="mb-0 fw-semibold">
|
||||
<i class="bi bi-envelope me-2 text-primary"></i>Tukar Alamat Emel
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
@if(session('email_success'))
|
||||
<div class="alert alert-success small py-2">
|
||||
<i class="bi bi-check-circle me-1"></i>{{ session('email_success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.profile.update-email') }}">
|
||||
@csrf @method('PUT')
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-medium">Kata Laluan Semasa <span class="text-danger">*</span></label>
|
||||
<input type="password" name="current_password" autocomplete="current-password"
|
||||
class="form-control form-control-sm @error('current_password', 'email') is-invalid @enderror"
|
||||
placeholder="••••••••">
|
||||
@error('current_password', 'email')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-medium">Emel Baru <span class="text-danger">*</span></label>
|
||||
<input type="email" name="email" autocomplete="email"
|
||||
class="form-control form-control-sm @error('email', 'email') is-invalid @enderror"
|
||||
value="{{ old('email', $user->email) }}"
|
||||
placeholder="emel@contoh.com">
|
||||
@error('email', 'email')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-sm w-100">
|
||||
<i class="bi bi-check-lg me-1"></i> Kemaskini Emel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Update Password --}}
|
||||
<div class="col-md-6">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-header bg-white py-3">
|
||||
<h6 class="mb-0 fw-semibold">
|
||||
<i class="bi bi-key me-2 text-primary"></i>Tukar Kata Laluan
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
@if(session('password_success'))
|
||||
<div class="alert alert-success small py-2">
|
||||
<i class="bi bi-check-circle me-1"></i>{{ session('password_success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('admin.profile.update-password') }}">
|
||||
@csrf @method('PUT')
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-medium">Kata Laluan Semasa <span class="text-danger">*</span></label>
|
||||
<input type="password" name="current_password" autocomplete="current-password"
|
||||
class="form-control form-control-sm @error('current_password', 'password') is-invalid @enderror"
|
||||
placeholder="••••••••">
|
||||
@error('current_password', 'password')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-medium">Kata Laluan Baru <span class="text-danger">*</span></label>
|
||||
<input type="password" name="password" autocomplete="new-password"
|
||||
class="form-control form-control-sm @error('password', 'password') is-invalid @enderror"
|
||||
placeholder="Min. 8 aksara">
|
||||
@error('password', 'password')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-medium">Sahkan Kata Laluan Baru <span class="text-danger">*</span></label>
|
||||
<input type="password" name="password_confirmation" autocomplete="new-password"
|
||||
class="form-control form-control-sm"
|
||||
placeholder="••••••••">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-sm w-100">
|
||||
<i class="bi bi-check-lg me-1"></i> Tukar Kata Laluan
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
151
resources/views/admin/programs/questionnaire/preview.blade.php
Normal file
151
resources/views/admin/programs/questionnaire/preview.blade.php
Normal file
@@ -0,0 +1,151 @@
|
||||
@extends('layouts.public')
|
||||
|
||||
@section('title', 'Pratonton Soalselidik — ' . $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
|
||||
|
||||
@push('styles')
|
||||
<style>
|
||||
.preview-banner {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
background: #fff3cd;
|
||||
border-bottom: 2px solid #ffc107;
|
||||
padding: .6rem 1rem;
|
||||
text-align: center;
|
||||
font-size: .85rem;
|
||||
font-weight: 600;
|
||||
color: #664d03;
|
||||
}
|
||||
.preview-banner i { margin-right: .4rem; }
|
||||
fieldset { border: none; padding: 0; margin: 0; }
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="preview-banner">
|
||||
<i class="bi bi-eye"></i>PRATONTON ADMIN — Borang ini tidak akan dihantar
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary ms-3 py-0" onclick="window.close()">
|
||||
<i class="bi bi-x-lg me-1"></i>Tutup
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="checkin-card card p-4 mb-3 mt-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>
|
||||
@if($pq->questionnaireSet->description)
|
||||
<p class="text-muted small mb-1">{{ $pq->questionnaireSet->description }}</p>
|
||||
@endif
|
||||
<p class="text-muted small mb-0">
|
||||
Sila jawab semua soalan sebelum memuat turun sijil anda, <strong>PESERTA CONTOH</strong>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<fieldset disabled>
|
||||
|
||||
@php $qNum = 0; @endphp
|
||||
|
||||
@foreach($questions as $q)
|
||||
|
||||
@if($q->question_type === 'tajuk')
|
||||
{{-- ── Section header ─────────────────────────────── --}}
|
||||
<div class="d-flex align-items-center gap-2 mt-4 mb-3 pb-1 border-bottom">
|
||||
<span class="fw-bold text-primary">{{ $q->question_text }}</span>
|
||||
</div>
|
||||
|
||||
@foreach($q->children as $child)
|
||||
@php $qNum++ @endphp
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-medium">
|
||||
{{ $qNum }}. {{ $child->question_text }}
|
||||
@if($child->is_required)<span class="text-danger">*</span>@endif
|
||||
</label>
|
||||
<div class="d-flex gap-3 flex-wrap">
|
||||
@for($i = 1; $i <= 5; $i++)
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio"
|
||||
name="q_{{ $child->id }}" value="{{ $i }}">
|
||||
<label class="form-check-label">
|
||||
{{ $i }}
|
||||
@php $label = $q->rating_labels[$i] ?? $q->rating_labels[strval($i)] ?? ''; @endphp
|
||||
@if($label)
|
||||
<small class="text-muted d-block" style="font-size:.7rem;">({{ $label }})</small>
|
||||
@endif
|
||||
</label>
|
||||
</div>
|
||||
@endfor
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@else
|
||||
{{-- ── Standalone question ─────────────────────────── --}}
|
||||
@php $qNum++ @endphp
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-medium">
|
||||
{{ $qNum }}. {{ $q->question_text }}
|
||||
@if($q->is_required)<span class="text-danger">*</span>@endif
|
||||
</label>
|
||||
|
||||
@if($q->question_type === 'rating')
|
||||
<div class="d-flex gap-3 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 }}" value="{{ $i }}">
|
||||
<label class="form-check-label">
|
||||
{{ $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 }}" value="{{ $opt }}">
|
||||
<label class="form-check-label">{{ $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 }}[]" value="{{ $opt }}">
|
||||
<label class="form-check-label">{{ $opt }}</label>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@elseif($q->question_type === 'short_text')
|
||||
<input type="text" class="form-control" placeholder="Jawapan anda...">
|
||||
|
||||
@elseif($q->question_type === 'long_text')
|
||||
<textarea class="form-control" rows="4" placeholder="Jawapan anda..."></textarea>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
||||
</fieldset>
|
||||
|
||||
<div class="alert alert-warning d-flex align-items-center gap-2 mb-0 mt-2">
|
||||
<i class="bi bi-eye-fill flex-shrink-0"></i>
|
||||
<span class="small">Ini adalah <strong>pratonton admin</strong>. Borang ini tidak boleh dihantar.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@@ -10,9 +10,17 @@
|
||||
@endsection
|
||||
|
||||
@section('header-actions')
|
||||
<div class="d-flex gap-2">
|
||||
@if($pq && $pq->questionnaireSet)
|
||||
<a href="{{ route('admin.programs.questionnaire.preview', $program) }}" target="_blank"
|
||||
class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-eye me-1"></i> Pratonton
|
||||
</a>
|
||||
@endif
|
||||
<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>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@@ -68,25 +76,48 @@
|
||||
{{-- 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)
|
||||
@php
|
||||
$allQs = $pq->questionnaireSet->questions->sortBy('sort_order');
|
||||
$topQs = $allQs->whereNull('parent_id');
|
||||
$qNum = 0;
|
||||
@endphp
|
||||
@foreach($topQs as $q)
|
||||
@if($q->question_type === 'tajuk')
|
||||
<div class="d-flex align-items-center gap-2 mt-2 mb-1">
|
||||
<span class="badge bg-dark" style="font-size:0.6rem;">Tajuk</span>
|
||||
<div class="small fw-semibold text-dark">{{ $q->question_text }}</div>
|
||||
</div>
|
||||
@foreach($allQs->where('parent_id', $q->id)->sortBy('sort_order') as $child)
|
||||
@php $qNum++ @endphp
|
||||
<div class="d-flex align-items-start gap-2 mb-1 ps-3">
|
||||
<span class="badge bg-secondary flex-shrink-0" style="min-width:22px;font-size:0.65rem;">{{ $qNum }}</span>
|
||||
<div>
|
||||
<div class="small">{{ $child->question_text }}</div>
|
||||
<span class="badge bg-light text-dark border" style="font-size:0.6rem;">Rating 1–5</span>
|
||||
@if($child->is_required)<span class="badge bg-danger bg-opacity-10 text-danger" style="font-size:0.6rem;">Wajib</span>@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
@php $qNum++ @endphp
|
||||
<div class="d-flex align-items-start gap-2 mb-2">
|
||||
<span class="badge bg-secondary flex-shrink-0">{{ $loop->iteration }}</span>
|
||||
<span class="badge bg-secondary flex-shrink-0" style="min-width:22px;font-size:0.65rem;">{{ $qNum }}</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',
|
||||
'rating' => 'Rating 1–5',
|
||||
'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" style="font-size:0.65rem;">Wajib</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>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
@@ -31,13 +31,25 @@
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('styles')
|
||||
<style>
|
||||
.tajuk-block { border-left: 3px solid #6c757d; }
|
||||
.tajuk-header { background: #f8f9fa; }
|
||||
.children-list { border-top: 1px solid #dee2e6; }
|
||||
.children-list .list-group-item { background: #fff; }
|
||||
.children-list .list-group-item:last-child { border-bottom: 0; }
|
||||
.drag-handle { cursor: grab; color: #adb5bd; }
|
||||
.drag-handle:active { cursor: grabbing; }
|
||||
.sortable-ghost { opacity: .4; background: #e9f0ff !important; }
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@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>
|
||||
@@ -55,26 +67,104 @@
|
||||
<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>
|
||||
<span class="badge bg-secondary ms-2">{{ $totalCount }}</span>
|
||||
</h6>
|
||||
<small class="text-muted"><i class="bi bi-grip-vertical me-1"></i>Seret untuk susun semula</small>
|
||||
</div>
|
||||
|
||||
@if($set->questions->isEmpty())
|
||||
@if($totalCount === 0)
|
||||
<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)
|
||||
@foreach($topLevel as $q)
|
||||
|
||||
@if($q->question_type === 'tajuk')
|
||||
{{-- ── TAJUK BLOCK ── --}}
|
||||
<li class="list-group-item p-0 tajuk-block" data-id="{{ $q->id }}">
|
||||
{{-- Tajuk header row --}}
|
||||
<div class="tajuk-header d-flex align-items-center gap-2 px-3 py-2">
|
||||
<i class="bi bi-grip-vertical drag-handle drag-handle-top fs-5"></i>
|
||||
<span class="badge bg-dark small">Tajuk</span>
|
||||
<div class="flex-grow-1 fw-semibold">{{ $q->question_text }}</div>
|
||||
@if($q->rating_labels)
|
||||
<div class="small text-muted text-nowrap d-none d-md-block">
|
||||
@php $labels = array_filter($q->rating_labels); @endphp
|
||||
@if(!empty($labels))
|
||||
<i class="bi bi-tag me-1"></i>{{ implode(' · ', $labels) }}
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
<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), 'tajuk', false, [], null, @json($q->rating_labels ?? []))">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<form method="POST" action="{{ route('admin.questions.destroy', $q) }}"
|
||||
onsubmit="return confirm('Padam bahagian '{{ addslashes($q->question_text) }}' dan semua soalan di dalamnya?')">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{-- Rating labels pills --}}
|
||||
@if($q->rating_labels && array_filter($q->rating_labels))
|
||||
<div class="px-3 py-1 bg-light border-bottom d-flex gap-2 flex-wrap d-md-none">
|
||||
@foreach(array_filter($q->rating_labels) as $val => $lbl)
|
||||
<span class="badge bg-light text-dark border small">{{ $val }}: {{ $lbl }}</span>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
{{-- Children list --}}
|
||||
<ul class="children-list list-group list-group-flush" data-parent-id="{{ $q->id }}">
|
||||
@foreach($q->children as $child)
|
||||
<li class="list-group-item d-flex align-items-start gap-2 py-2 ps-4" data-id="{{ $child->id }}">
|
||||
<i class="bi bi-grip-vertical drag-handle drag-handle-child fs-5 mt-1"></i>
|
||||
<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">Rating 1–5</span>
|
||||
@if($child->is_required)
|
||||
<span class="badge bg-danger bg-opacity-10 text-danger small">Wajib</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="small">{{ $child->question_text }}</div>
|
||||
</div>
|
||||
<div class="d-flex gap-1 flex-shrink-0">
|
||||
<button class="btn btn-sm btn-outline-secondary"
|
||||
onclick="editQuestion({{ $child->id }}, @json($child->question_text), 'rating', {{ $child->is_required ? 'true' : 'false' }}, [], {{ $child->parent_id ?? 'null' }}, [])">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<form method="POST" action="{{ route('admin.questions.destroy', $child) }}"
|
||||
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>
|
||||
</li>
|
||||
@endforeach
|
||||
@if($q->children->isEmpty())
|
||||
<li class="list-group-item text-muted small text-center py-2 fst-italic ps-4">
|
||||
<i class="bi bi-arrow-down-short me-1"></i>Tiada soalan dalam bahagian ini
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
@else
|
||||
{{-- ── STANDALONE QUESTION ── --}}
|
||||
<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-start gap-2 flex-grow-1">
|
||||
<i class="bi bi-grip-vertical drag-handle drag-handle-top fs-5 mt-1"></i>
|
||||
<div>
|
||||
<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',
|
||||
'rating' => 'Rating 1–5',
|
||||
'single_choice' => 'Pilihan Tunggal',
|
||||
'multiple_choice' => 'Pilihan Berganda',
|
||||
'short_text' => 'Teks Pendek',
|
||||
@@ -95,21 +185,22 @@
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</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 ?? []))">
|
||||
onclick="editQuestion({{ $q->id }}, @json($q->question_text), '{{ $q->question_type }}', {{ $q->is_required ? 'true' : 'false' }}, @json($q->options_json ?? []), null, [])">
|
||||
<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>
|
||||
<button class="btn btn-sm btn-outline-danger"><i class="bi bi-trash"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@@ -143,27 +234,31 @@
|
||||
<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>
|
||||
<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="">
|
||||
|
||||
{{-- Question text --}}
|
||||
<div class="mb-3">
|
||||
<label class="form-label small fw-medium">Soalan <span class="text-danger">*</span></label>
|
||||
<label class="form-label small fw-medium">Teks Soalan / Tajuk <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>
|
||||
placeholder="Taip soalan atau nama bahagian..."></textarea>
|
||||
@error('question_text')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||
</div>
|
||||
|
||||
{{-- Question type --}}
|
||||
<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()">
|
||||
<label class="form-label small fw-medium">Jenis <span class="text-danger">*</span></label>
|
||||
<select name="question_type" id="questionType" class="form-select form-select-sm" onchange="onTypeChange()">
|
||||
<option value="tajuk">Tajuk Bahagian</option>
|
||||
<option value="rating">Rating (1–5)</option>
|
||||
<option value="single_choice">Pilihan Tunggal</option>
|
||||
<option value="multiple_choice">Pilihan Berganda</option>
|
||||
@@ -172,11 +267,41 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" name="is_required" id="isRequired" class="form-check-input" value="1" checked>
|
||||
{{-- Required (hidden for tajuk) --}}
|
||||
<div class="mb-3 form-check d-none" id="requiredSection">
|
||||
<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>
|
||||
|
||||
{{-- Parent selector (rating only) --}}
|
||||
<div id="parentSection" class="mb-3 d-none">
|
||||
<label class="form-label small fw-medium">Bahagian (Tajuk) <span class="text-danger">*</span></label>
|
||||
<select name="parent_id" id="parentId" class="form-select form-select-sm">
|
||||
<option value="">— Pilih Tajuk —</option>
|
||||
</select>
|
||||
@error('parent_id')
|
||||
<div class="text-danger small mt-1">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
{{-- Rating labels (tajuk only) --}}
|
||||
<div id="ratingLabelsSection" class="mb-3">
|
||||
<label class="form-label small fw-medium">Label Skala Rating</label>
|
||||
<div class="d-flex flex-column gap-1">
|
||||
@for ($i = 1; $i <= 5; $i++)
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text fw-bold" style="width:32px;justify-content:center;">{{ $i }}</span>
|
||||
<input type="text" name="rating_labels[{{ $i }}]" id="ratingLabel{{ $i }}"
|
||||
class="form-control"
|
||||
placeholder="{{ $i === 1 ? 'cth: Sangat Tidak Setuju' : ($i === 5 ? 'cth: Sangat Setuju' : '') }}">
|
||||
</div>
|
||||
@endfor
|
||||
</div>
|
||||
<div class="form-text">Kosongkan jika tiada label untuk nilai tersebut.</div>
|
||||
</div>
|
||||
|
||||
{{-- Options (choice types) --}}
|
||||
<div id="optionsSection" class="mb-3 d-none">
|
||||
<label class="form-label small fw-medium">Pilihan Jawapan</label>
|
||||
<div id="optionsList">
|
||||
@@ -192,13 +317,17 @@
|
||||
<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>
|
||||
@error('options')
|
||||
<div class="text-danger small mt-1">{{ $message }}</div>
|
||||
@enderror
|
||||
</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()">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" id="cancelEdit"
|
||||
style="display:none;" onclick="resetForm()">
|
||||
Batal
|
||||
</button>
|
||||
</div>
|
||||
@@ -212,15 +341,43 @@
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.3/Sortable.min.js"></script>
|
||||
<script>
|
||||
const setId = {{ $set->id }};
|
||||
const storeUrl = "{{ route('admin.questions.store', $set) }}";
|
||||
const updateBase = "{{ url('admin/questions') }}/";
|
||||
const reorderUrl = "{{ route('admin.questions.reorder') }}";
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').content;
|
||||
|
||||
function toggleOptions() {
|
||||
// Tajuk questions available as parents for rating questions
|
||||
const tajukList = @json($topLevel->where('question_type', 'tajuk')->map(fn($q) => ['id' => $q->id, 'text' => $q->question_text])->values());
|
||||
|
||||
// ── UI helpers ──────────────────────────────────────────────────────────────
|
||||
|
||||
function populateParentDropdown(selectedId) {
|
||||
const sel = document.getElementById('parentId');
|
||||
sel.innerHTML = '<option value="">— Pilih Tajuk —</option>';
|
||||
tajukList.forEach(function(t) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = t.id;
|
||||
opt.textContent = t.text;
|
||||
if (selectedId && t.id == selectedId) opt.selected = true;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
}
|
||||
|
||||
function onTypeChange() {
|
||||
const type = document.getElementById('questionType').value;
|
||||
const section = document.getElementById('optionsSection');
|
||||
section.classList.toggle('d-none', !['single_choice','multiple_choice'].includes(type));
|
||||
const isTajuk = type === 'tajuk';
|
||||
const isRating = type === 'rating';
|
||||
const isChoice = ['single_choice', 'multiple_choice'].includes(type);
|
||||
|
||||
document.getElementById('requiredSection').classList.toggle('d-none', isTajuk);
|
||||
document.getElementById('ratingLabelsSection').classList.toggle('d-none', !isTajuk);
|
||||
document.getElementById('parentSection').classList.toggle('d-none', !isRating);
|
||||
document.getElementById('optionsSection').classList.toggle('d-none', !isChoice);
|
||||
|
||||
if (isRating) populateParentDropdown(null);
|
||||
}
|
||||
|
||||
function addOption() {
|
||||
@@ -240,7 +397,7 @@ function removeOption(btn) {
|
||||
}
|
||||
}
|
||||
|
||||
function editQuestion(id, text, type, required, options) {
|
||||
function editQuestion(id, text, type, required, options, parentId, ratingLabels) {
|
||||
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 = '';
|
||||
@@ -253,18 +410,42 @@ function editQuestion(id, text, type, required, options) {
|
||||
form.action = updateBase + id;
|
||||
document.getElementById('formMethod').value = 'PUT';
|
||||
|
||||
toggleOptions();
|
||||
onTypeChange(); // show/hide sections
|
||||
|
||||
// Set parent if rating
|
||||
if (type === 'rating' && parentId) {
|
||||
populateParentDropdown(parentId);
|
||||
}
|
||||
|
||||
// Set rating labels if tajuk
|
||||
if (type === 'tajuk') {
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
const el = document.getElementById('ratingLabel' + i);
|
||||
if (el) el.value = (ratingLabels && (ratingLabels[i] || ratingLabels[String(i)])) || '';
|
||||
}
|
||||
}
|
||||
|
||||
// Options list
|
||||
const list = document.getElementById('optionsList');
|
||||
list.innerHTML = '';
|
||||
if (options && options.length) {
|
||||
options.forEach((opt, i) => {
|
||||
options.forEach(function(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);
|
||||
});
|
||||
} else {
|
||||
// Restore default empty options for choice types
|
||||
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>`;
|
||||
}
|
||||
|
||||
form.scrollIntoView({ behavior: 'smooth' });
|
||||
@@ -278,10 +459,15 @@ function resetForm() {
|
||||
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">
|
||||
// Clear rating labels
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
const el = document.getElementById('ratingLabel' + i);
|
||||
if (el) el.value = '';
|
||||
}
|
||||
document.getElementById('parentId').value = '';
|
||||
onTypeChange();
|
||||
document.getElementById('optionsList').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>
|
||||
@@ -290,5 +476,48 @@ function resetForm() {
|
||||
<button type="button" class="btn btn-outline-danger" onclick="removeOption(this)"><i class="bi bi-x"></i></button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// ── Drag & Drop ──────────────────────────────────────────────────────────────
|
||||
|
||||
function sendReorder(order, parentId) {
|
||||
fetch(reorderUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrfToken },
|
||||
body: JSON.stringify({ order: order, parent_id: parentId }),
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Init: show sections for default type (tajuk)
|
||||
onTypeChange();
|
||||
|
||||
// Top-level sortable — sorts tajuk blocks + standalone questions
|
||||
const topList = document.getElementById('questionList');
|
||||
if (topList) {
|
||||
Sortable.create(topList, {
|
||||
animation: 150,
|
||||
handle: '.drag-handle-top',
|
||||
ghostClass: 'sortable-ghost',
|
||||
onEnd: function() {
|
||||
const order = [...topList.querySelectorAll(':scope > [data-id]')].map(el => +el.dataset.id);
|
||||
sendReorder(order, null);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Per-tajuk sortable — sorts rating children within a group
|
||||
document.querySelectorAll('.children-list').forEach(function(list) {
|
||||
Sortable.create(list, {
|
||||
animation: 150,
|
||||
handle: '.drag-handle-child',
|
||||
ghostClass: 'sortable-ghost',
|
||||
onEnd: function() {
|
||||
const parentId = +list.dataset.parentId;
|
||||
const order = [...list.querySelectorAll(':scope > [data-id]')].map(el => +el.dataset.id);
|
||||
sendReorder(order, parentId);
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -1,25 +1,67 @@
|
||||
<x-guest-layout>
|
||||
<div class="mb-4 text-sm text-gray-600">
|
||||
{{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }}
|
||||
<!DOCTYPE html>
|
||||
<html lang="ms">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Terlupa Kata Laluan — eCert MBIP</title>
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<style>
|
||||
body { background: linear-gradient(135deg, #1a56a0 0%, #2563eb 100%); min-height: 100vh; }
|
||||
.card { border-radius: 1rem; border: none; box-shadow: 0 8px 32px rgba(0,0,0,0.2); max-width: 420px; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="d-flex align-items-center justify-content-center py-5">
|
||||
<div class="w-100 px-3">
|
||||
<div class="text-center mb-4">
|
||||
<i class="bi bi-award-fill text-white" style="font-size: 3rem;"></i>
|
||||
<h4 class="text-white fw-bold mt-2 mb-0">eCert MBIP</h4>
|
||||
<small class="text-white opacity-75">Sistem Pengurusan Sijil Digital</small>
|
||||
</div>
|
||||
|
||||
<!-- Session Status -->
|
||||
<x-auth-session-status class="mb-4" :status="session('status')" />
|
||||
<div class="card mx-auto">
|
||||
<div class="card-body p-4">
|
||||
<h5 class="card-title fw-semibold mb-1">Terlupa Kata Laluan?</h5>
|
||||
<p class="text-muted small mb-4">
|
||||
Masukkan alamat emel anda dan kami akan hantar pautan untuk menetapkan semula kata laluan.
|
||||
</p>
|
||||
|
||||
@if(session('status'))
|
||||
<div class="alert alert-success small">
|
||||
<i class="bi bi-check-circle me-1"></i>{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('password.email') }}">
|
||||
@csrf
|
||||
|
||||
<!-- Email Address -->
|
||||
<div>
|
||||
<x-input-label for="email" :value="__('Email')" />
|
||||
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autofocus />
|
||||
<x-input-error :messages="$errors->get('email')" class="mt-2" />
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label fw-medium">Alamat Emel</label>
|
||||
<input id="email" type="email" name="email"
|
||||
value="{{ old('email') }}" required autofocus autocomplete="email"
|
||||
class="form-control @error('email') is-invalid @enderror"
|
||||
placeholder="admin@mbip.gov.my">
|
||||
@error('email')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<x-primary-button>
|
||||
{{ __('Email Password Reset Link') }}
|
||||
</x-primary-button>
|
||||
<button type="submit" class="btn w-100 text-white fw-semibold mb-3"
|
||||
style="background: var(--mbip-primary, #1a56a0);">
|
||||
<i class="bi bi-send me-1"></i> Hantar Pautan Reset
|
||||
</button>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="{{ route('login') }}" class="small text-decoration-none text-muted">
|
||||
<i class="bi bi-arrow-left me-1"></i> Kembali ke Log Masuk
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</x-guest-layout>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center mt-3">
|
||||
<small class="text-white opacity-60">Majlis Bandaraya Ipoh Perak © {{ date('Y') }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,39 +1,83 @@
|
||||
<x-guest-layout>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ms">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Tetapkan Semula Kata Laluan — eCert MBIP</title>
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<style>
|
||||
body { background: linear-gradient(135deg, #1a56a0 0%, #2563eb 100%); min-height: 100vh; }
|
||||
.card { border-radius: 1rem; border: none; box-shadow: 0 8px 32px rgba(0,0,0,0.2); max-width: 420px; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="d-flex align-items-center justify-content-center py-5">
|
||||
<div class="w-100 px-3">
|
||||
<div class="text-center mb-4">
|
||||
<i class="bi bi-award-fill text-white" style="font-size: 3rem;"></i>
|
||||
<h4 class="text-white fw-bold mt-2 mb-0">eCert MBIP</h4>
|
||||
<small class="text-white opacity-75">Sistem Pengurusan Sijil Digital</small>
|
||||
</div>
|
||||
|
||||
<div class="card mx-auto">
|
||||
<div class="card-body p-4">
|
||||
<h5 class="card-title fw-semibold mb-1">Tetapkan Semula Kata Laluan</h5>
|
||||
<p class="text-muted small mb-4">Masukkan kata laluan baru untuk akaun anda.</p>
|
||||
|
||||
<form method="POST" action="{{ route('password.store') }}">
|
||||
@csrf
|
||||
|
||||
<!-- Password Reset Token -->
|
||||
<input type="hidden" name="token" value="{{ $request->route('token') }}">
|
||||
|
||||
<!-- Email Address -->
|
||||
<div>
|
||||
<x-input-label for="email" :value="__('Email')" />
|
||||
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus autocomplete="username" />
|
||||
<x-input-error :messages="$errors->get('email')" class="mt-2" />
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label fw-medium">Alamat Emel</label>
|
||||
<input id="email" type="email" name="email"
|
||||
value="{{ old('email', $request->email) }}" required autofocus autocomplete="username"
|
||||
class="form-control @error('email') is-invalid @enderror"
|
||||
placeholder="admin@mbip.gov.my">
|
||||
@error('email')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Password -->
|
||||
<div class="mt-4">
|
||||
<x-input-label for="password" :value="__('Password')" />
|
||||
<x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
|
||||
<x-input-error :messages="$errors->get('password')" class="mt-2" />
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label fw-medium">Kata Laluan Baru</label>
|
||||
<input id="password" type="password" name="password"
|
||||
required autocomplete="new-password"
|
||||
class="form-control @error('password') is-invalid @enderror"
|
||||
placeholder="Min. 8 aksara">
|
||||
@error('password')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<!-- Confirm Password -->
|
||||
<div class="mt-4">
|
||||
<x-input-label for="password_confirmation" :value="__('Confirm Password')" />
|
||||
|
||||
<x-text-input id="password_confirmation" class="block mt-1 w-full"
|
||||
type="password"
|
||||
name="password_confirmation" required autocomplete="new-password" />
|
||||
|
||||
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
|
||||
<div class="mb-4">
|
||||
<label for="password_confirmation" class="form-label fw-medium">Sahkan Kata Laluan Baru</label>
|
||||
<input id="password_confirmation" type="password" name="password_confirmation"
|
||||
required autocomplete="new-password"
|
||||
class="form-control @error('password_confirmation') is-invalid @enderror"
|
||||
placeholder="••••••••">
|
||||
@error('password_confirmation')
|
||||
<div class="invalid-feedback">{{ $message }}</div>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<x-primary-button>
|
||||
{{ __('Reset Password') }}
|
||||
</x-primary-button>
|
||||
<button type="submit" class="btn w-100 text-white fw-semibold mb-3"
|
||||
style="background: var(--mbip-primary, #1a56a0);">
|
||||
<i class="bi bi-key me-1"></i> Tetapkan Semula Kata Laluan
|
||||
</button>
|
||||
|
||||
<div class="text-center">
|
||||
<a href="{{ route('login') }}" class="small text-decoration-none text-muted">
|
||||
<i class="bi bi-arrow-left me-1"></i> Kembali ke Log Masuk
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</x-guest-layout>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center mt-3">
|
||||
<small class="text-white opacity-60">Majlis Bandaraya Ipoh Perak © {{ date('Y') }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -66,6 +66,12 @@
|
||||
<span class="badge {{ auth()->user()->isSuperAdmin() ? 'bg-danger' : 'bg-primary' }} mb-2 d-inline-block">
|
||||
{{ auth()->user()->isSuperAdmin() ? 'Super Admin' : 'Admin Program' }}
|
||||
</span>
|
||||
<div class="d-flex gap-2 mb-2">
|
||||
<a href="{{ route('admin.profile.show') }}"
|
||||
class="btn btn-sm btn-outline-light flex-grow-1 {{ request()->routeIs('admin.profile.*') ? 'active' : '' }}">
|
||||
<i class="bi bi-person-gear me-1"></i> Profil
|
||||
</a>
|
||||
</div>
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-sm btn-outline-light w-100">
|
||||
|
||||
@@ -26,21 +26,62 @@
|
||||
<form method="POST" action="{{ route('public.questionnaire.submit', [$qrCode->token, $participant->uuid]) }}">
|
||||
@csrf
|
||||
|
||||
@php $qNum = 0; @endphp
|
||||
|
||||
@foreach($questions as $q)
|
||||
|
||||
@if($q->question_type === 'tajuk')
|
||||
{{-- ── Section header ─────────────────────────────── --}}
|
||||
<div class="d-flex align-items-center gap-2 mt-4 mb-3 pb-1 border-bottom">
|
||||
<span class="fw-bold text-primary">{{ $q->question_text }}</span>
|
||||
</div>
|
||||
|
||||
@foreach($q->children as $child)
|
||||
@php $qNum++ @endphp
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-medium">
|
||||
{{ $loop->iteration }}. {{ $q->question_text }}
|
||||
@if($q->is_required)
|
||||
<span class="text-danger">*</span>
|
||||
{{ $qNum }}. {{ $child->question_text }}
|
||||
@if($child->is_required)<span class="text-danger">*</span>@endif
|
||||
</label>
|
||||
|
||||
@error('q_' . $child->id)
|
||||
<div class="text-danger small mb-1"><i class="bi bi-exclamation-circle me-1"></i>{{ $message }}</div>
|
||||
@enderror
|
||||
|
||||
<div class="d-flex gap-3 flex-wrap">
|
||||
@for($i = 1; $i <= 5; $i++)
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio"
|
||||
name="q_{{ $child->id }}" id="q{{ $child->id }}_{{ $i }}"
|
||||
value="{{ $i }}" {{ old('q_'.$child->id) == $i ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="q{{ $child->id }}_{{ $i }}">
|
||||
{{ $i }}
|
||||
@php $label = $q->rating_labels[$i] ?? $q->rating_labels[strval($i)] ?? ''; @endphp
|
||||
@if($label)
|
||||
<small class="text-muted d-block" style="font-size:.7rem;">({{ $label }})</small>
|
||||
@endif
|
||||
</label>
|
||||
</div>
|
||||
@endfor
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@else
|
||||
{{-- ── Standalone question ─────────────────────────── --}}
|
||||
@php $qNum++ @endphp
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-medium">
|
||||
{{ $qNum }}. {{ $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">
|
||||
<div class="d-flex gap-3 flex-wrap">
|
||||
@for($i = 1; $i <= 5; $i++)
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio"
|
||||
@@ -80,8 +121,7 @@
|
||||
@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...">
|
||||
value="{{ old('q_'.$q->id) }}" placeholder="Jawapan anda...">
|
||||
|
||||
@elseif($q->question_type === 'long_text')
|
||||
<textarea name="q_{{ $q->id }}" rows="4"
|
||||
@@ -89,6 +129,8 @@
|
||||
placeholder="Jawapan anda...">{{ old('q_'.$q->id) }}</textarea>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100 btn-checkin">
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Http\Controllers\Admin\StatisticsController;
|
||||
use App\Http\Controllers\Admin\QuestionnaireSetController;
|
||||
use App\Http\Controllers\Admin\QuestionController;
|
||||
use App\Http\Controllers\Admin\CertificateController as AdminCertificateController;
|
||||
use App\Http\Controllers\Admin\ProfileController;
|
||||
use App\Http\Controllers\Public\CheckinController;
|
||||
use App\Http\Controllers\Public\QuestionnaireController;
|
||||
use App\Http\Controllers\Public\AttendanceCheckController;
|
||||
@@ -29,6 +30,11 @@ Route::middleware(['auth', 'admin'])->prefix('admin')->name('admin.')->group(fun
|
||||
|
||||
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||
|
||||
// Profile
|
||||
Route::get('/profile', [ProfileController::class, 'show'])->name('profile.show');
|
||||
Route::put('/profile/email', [ProfileController::class, 'updateEmail'])->name('profile.update-email');
|
||||
Route::put('/profile/password', [ProfileController::class, 'updatePassword'])->name('profile.update-password');
|
||||
|
||||
// Programs
|
||||
Route::resource('programs', ProgramController::class)->parameters(['programs' => 'program:uuid']);
|
||||
Route::post('/programs/{program:uuid}/publish', [ProgramController::class, 'publish'])->name('programs.publish');
|
||||
@@ -66,6 +72,7 @@ Route::middleware(['auth', 'admin'])->prefix('admin')->name('admin.')->group(fun
|
||||
// Program Questionnaire
|
||||
Route::prefix('programs/{program:uuid}/questionnaire')->name('programs.questionnaire.')->group(function () {
|
||||
Route::get('/', [ProgramQuestionnaireController::class, 'show'])->name('show');
|
||||
Route::get('/preview', [ProgramQuestionnaireController::class, 'preview'])->name('preview');
|
||||
Route::post('/attach', [ProgramQuestionnaireController::class, 'attach'])->name('attach');
|
||||
Route::post('/confirm', [ProgramQuestionnaireController::class, 'confirm'])->name('confirm');
|
||||
Route::delete('/detach', [ProgramQuestionnaireController::class, 'detach'])->name('detach');
|
||||
|
||||
Reference in New Issue
Block a user