Merge remote-tracking branch 'upstream-local/clean-main' into clean-main
This commit is contained in:
@@ -27,23 +27,23 @@ class QuizController extends Controller
|
|||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
|
// 1. Validate only the text and number fields
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'title' => 'required|string|max:255',
|
'title' => 'required|string|max:255',
|
||||||
'category_id' => 'required|exists:quiz_categories,id',
|
'category_id' => 'required|exists:quiz_categories,id',
|
||||||
'year' => 'nullable|integer',
|
'year' => 'nullable|integer',
|
||||||
'type' => 'required|in:multiple_choice,descriptive,mixed',
|
'type' => 'required|in:multiple_choice,descriptive,mixed',
|
||||||
'duration_minutes' => 'required|integer|min:1',
|
'duration_minutes' => 'required|integer|min:1',
|
||||||
'has_negative_score' => 'boolean',
|
|
||||||
'is_free' => 'boolean',
|
|
||||||
'is_published' => 'boolean',
|
|
||||||
'description' => 'nullable|string',
|
'description' => 'nullable|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$validated['slug'] = Str::slug($validated['title']) . '-' . time();
|
// 2. Safely handle checkboxes and generate slug
|
||||||
|
$validated['slug'] = \Illuminate\Support\Str::slug($validated['title']) . '-' . time();
|
||||||
$validated['has_negative_score'] = $request->has('has_negative_score');
|
$validated['has_negative_score'] = $request->has('has_negative_score');
|
||||||
$validated['is_free'] = $request->has('is_free');
|
$validated['is_free'] = $request->has('is_free');
|
||||||
$validated['is_published'] = $request->has('is_published');
|
$validated['is_published'] = $request->has('is_published');
|
||||||
|
|
||||||
|
// 3. Create the quiz
|
||||||
$quiz = Quiz::create($validated);
|
$quiz = Quiz::create($validated);
|
||||||
|
|
||||||
return redirect()->route('quizzes.questions.index', $quiz->id)
|
return redirect()->route('quizzes.questions.index', $quiz->id)
|
||||||
|
|||||||
44
app/Http/Controllers/Admin/QuizSubjectController.php
Normal file
44
app/Http/Controllers/Admin/QuizSubjectController.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\QuizSubject;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class QuizSubjectController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Load subjects and count how many questions belong to each
|
||||||
|
$subjects = QuizSubject::withCount('questions')->latest()->get();
|
||||||
|
return view('admin.quiz-subjects.index', compact('subjects'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'title' => 'required|string|max:255',
|
||||||
|
]);
|
||||||
|
|
||||||
|
QuizSubject::create([
|
||||||
|
'title' => $request->title,
|
||||||
|
// Generate a unique slug for potential API/URL usage
|
||||||
|
'slug' => Str::slug($request->title) . '-' . time(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'درس با موفقیت اضافه شد.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(QuizSubject $quiz_subject)
|
||||||
|
{
|
||||||
|
// Prevent deletion if questions are already assigned to this subject
|
||||||
|
if ($quiz_subject->questions()->count() > 0) {
|
||||||
|
return back()->with('error', 'این درس دارای سوال است و نمیتواند حذف شود. ابتدا سوالات مربوطه را ویرایش یا حذف کنید.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$quiz_subject->delete();
|
||||||
|
return back()->with('success', 'درس با موفقیت حذف شد.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,6 +60,13 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a href="{{ route('quiz-subjects.index') }}" class="waves-effect">
|
||||||
|
<i class="mdi mdi-book-open-page-variant"></i>
|
||||||
|
<span>مدیریت دروس</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:%20void(0);" class="has-arrow waves-effect">
|
<a href="javascript:%20void(0);" class="has-arrow waves-effect">
|
||||||
|
|||||||
77
resources/views/admin/quiz-subjects/index.blade.php
Normal file
77
resources/views/admin/quiz-subjects/index.blade.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
@extends('admin.layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<!-- Form to Add Subject -->
|
||||||
|
<div class="col-lg-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header bg-primary text-white">
|
||||||
|
<h6 class="mb-0 text-white">افزودن درس جدید</h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul class="mb-0">
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form action="{{ route('quiz-subjects.store') }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">عنوان درس <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="title" class="form-control" value="{{ old('title') }}" placeholder="مثال: حقوق مدنی" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-success w-100">ثبت درس</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- List of Subjects -->
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title mb-4">دروس ثبت شده</h5>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>عنوان درس</th>
|
||||||
|
<th>تعداد سوالات مرتبط</th>
|
||||||
|
<th>عملیات</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($subjects as $subject)
|
||||||
|
<tr>
|
||||||
|
<td><strong>{{ $subject->title }}</strong></td>
|
||||||
|
<td>
|
||||||
|
<span class="badge bg-soft-info text-info">{{ $subject->questions_count }} سوال</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form action="{{ route('quiz-subjects.destroy', $subject->id) }}" method="POST" class="d-inline" onsubmit="return confirm('آیا از حذف این درس اطمینان دارید؟')">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-sm btn-outline-danger">حذف</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="3" class="text-center py-3">هیچ درسی یافت نشد.</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -1,80 +1,94 @@
|
|||||||
@extends('admin.layouts.app')
|
@extends('admin.layouts.app')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-primary text-white">
|
<div class="card-header bg-primary text-white">
|
||||||
<h5 class="mb-0 text-white">تعریف آزمون جدید</h5>
|
<h5 class="mb-0 text-white">تعریف آزمون جدید</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form action="{{ route('quizzes.store') }}" method="POST">
|
|
||||||
@csrf
|
|
||||||
<div class="row g-3">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<label class="form-label">عنوان آزمون <span class="text-danger">*</span></label>
|
|
||||||
<input type="text" name="title" class="form-control" placeholder="مثلاً: آزمون وکالت کانون وکلا سال ۱۴۰۲" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6">
|
<!-- Display Validation Errors if any -->
|
||||||
<label class="form-label">دستهبندی <span class="text-danger">*</span></label>
|
@if ($errors->any())
|
||||||
<select name="category_id" class="form-select" required>
|
<div class="alert alert-danger">
|
||||||
<option value="">انتخاب کنید...</option>
|
<ul class="mb-0">
|
||||||
@foreach($categories as $category)
|
@foreach ($errors->all() as $error)
|
||||||
<option value="{{ $category->id }}">{{ $category->title }}</option>
|
<li>{{ $error }}</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="col-md-4">
|
<form action="{{ route('quizzes.store') }}" method="POST">
|
||||||
<label class="form-label">سال برگزاری</label>
|
@csrf
|
||||||
<input type="number" name="year" class="form-control" placeholder="1402">
|
<div class="row g-3">
|
||||||
</div>
|
<div class="col-md-6">
|
||||||
|
<label class="form-label">عنوان آزمون <span class="text-danger">*</span></label>
|
||||||
|
<input type="text" name="title" class="form-control" value="{{ old('title') }}" placeholder="مثلاً: آزمون وکالت کانون وکلا سال ۱۴۰۲" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-6">
|
||||||
<label class="form-label">نوع سوالات <span class="text-danger">*</span></label>
|
<label class="form-label">دستهبندی <span class="text-danger">*</span></label>
|
||||||
<select name="type" class="form-select" required>
|
<select name="category_id" class="form-select" required>
|
||||||
<option value="multiple_choice">چهار گزینهای (تستی)</option>
|
<option value="">انتخاب کنید...</option>
|
||||||
<option value="descriptive">تشریحی</option>
|
@foreach($categories as $category)
|
||||||
<option value="mixed">ترکیبی</option>
|
<option value="{{ $category->id }}" {{ old('category_id') == $category->id ? 'selected' : '' }}>
|
||||||
</select>
|
{{ $category->title }}
|
||||||
</div>
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<label class="form-label">مدت زمان (دقیقه)</label>
|
<label class="form-label">سال برگزاری</label>
|
||||||
<input type="number" name="duration_minutes" class="form-control" value="60" required>
|
<input type="number" name="year" class="form-control" value="{{ old('year') }}" placeholder="1402">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-4">
|
||||||
<label class="form-label">توضیحات آزمون</label>
|
<label class="form-label">نوع سوالات <span class="text-danger">*</span></label>
|
||||||
<textarea name="description" class="form-control" rows="3" placeholder="توضیحات و راهنمای شرکت در آزمون..."></textarea>
|
<select name="type" class="form-select" required>
|
||||||
</div>
|
<option value="multiple_choice" {{ old('type') == 'multiple_choice' ? 'selected' : '' }}>چهار گزینهای (تستی)</option>
|
||||||
|
<option value="descriptive" {{ old('type') == 'descriptive' ? 'selected' : '' }}>تشریحی</option>
|
||||||
|
<option value="mixed" {{ old('type') == 'mixed' ? 'selected' : '' }}>ترکیبی</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="form-check mt-3">
|
<label class="form-label">مدت زمان (دقیقه)</label>
|
||||||
<input class="form-check-input" type="checkbox" name="has_negative_score" id="negScore" checked>
|
<input type="number" name="duration_minutes" class="form-control" value="{{ old('duration_minutes', 60) }}" required>
|
||||||
<label class="form-check-label" for="negScore">محاسبه نمره منفی (برای تستی)</label>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-12">
|
||||||
<div class="form-check mt-3">
|
<label class="form-label">توضیحات آزمون</label>
|
||||||
<input class="form-check-input" type="checkbox" name="is_free" id="isFree">
|
<textarea name="description" class="form-control" rows="3" placeholder="توضیحات و راهنمای شرکت در آزمون...">{{ old('description') }}</textarea>
|
||||||
<label class="form-check-label" for="isFree">آزمون رایگان است (بدون نیاز به اشتراک)</label>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<div class="form-check mt-3">
|
<div class="form-check mt-3">
|
||||||
<input class="form-check-input" type="checkbox" name="is_published" id="isPub" checked>
|
<input class="form-check-input" type="checkbox" name="has_negative_score" id="negScore" {{ old('has_negative_score', true) ? 'checked' : '' }}>
|
||||||
<label class="form-check-label" for="isPub">انتشار فوری روی اپلیکیشن</label>
|
<label class="form-check-label" for="negScore">محاسبه نمره منفی (برای تستی)</label>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-12 mt-4 text-end">
|
|
||||||
<a href="{{ route('quizzes.index') }}" class="btn btn-light me-2">انصراف</a>
|
|
||||||
<button type="submit" class="btn btn-success">ثبت و ورود به مرحله ثبت سوالات</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
</div>
|
<div class="col-md-4">
|
||||||
|
<div class="form-check mt-3">
|
||||||
|
<input class="form-check-input" type="checkbox" name="is_free" id="isFree" {{ old('is_free') ? 'checked' : '' }}>
|
||||||
|
<label class="form-check-label" for="isFree">آزمون رایگان است (بدون نیاز به اشتراک)</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-4">
|
||||||
|
<div class="form-check mt-3">
|
||||||
|
<input class="form-check-input" type="checkbox" name="is_published" id="isPub" {{ old('is_published', true) ? 'checked' : '' }}>
|
||||||
|
<label class="form-check-label" for="isPub">انتشار فوری روی اپلیکیشن</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 mt-4 text-end">
|
||||||
|
<a href="{{ route('quizzes.index') }}" class="btn btn-light me-2">انصراف</a>
|
||||||
|
<button type="submit" class="btn btn-success">ثبت و ورود به مرحله ثبت سوالات</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
@@ -1,140 +1,165 @@
|
|||||||
@extends('admin.layouts.app')
|
@extends('admin.layouts.app')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
<h4>مدیریت سوالات: {{ $quiz->title }}</h4>
|
<h4>مدیریت سوالات: {{ $quiz->title }}</h4>
|
||||||
<a href="{{ route('quizzes.index') }}" class="btn btn-outline-secondary">بازگشت به لیست آزمونها</a>
|
<a href="{{ route('quizzes.index') }}" class="btn btn-outline-secondary">بازگشت به لیست آزمونها</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Form to Add Question -->
|
<!-- Form to Add Question -->
|
||||||
<div class="col-lg-5">
|
<div class="col-lg-5">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-primary text-white">
|
<div class="card-header bg-primary text-white">
|
||||||
<h6 class="mb-0 text-white">افزودن سوال جدید</h6>
|
<h6 class="mb-0 text-white">افزودن سوال جدید</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form action="{{ route('quizzes.questions.store', $quiz->id) }}" method="POST">
|
|
||||||
@csrf
|
|
||||||
|
|
||||||
<div class="mb-3">
|
<!-- 🚨 Display Validation Errors Here 🚨 -->
|
||||||
<label class="form-label">نوع سوال</label>
|
@if ($errors->any())
|
||||||
<select name="type" id="questionTypeSelect" class="form-select" onchange="toggleOptionFields(this.value)">
|
<div class="alert alert-danger">
|
||||||
<option value="multiple_choice">چهار گزینهای (تستی)</option>
|
<ul class="mb-0">
|
||||||
<option value="descriptive">تشریحی</option>
|
@foreach ($errors->all() as $error)
|
||||||
</select>
|
<li>{{ $error }}</li>
|
||||||
</div>
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="mb-3">
|
<form action="{{ route('quizzes.questions.store', $quiz->id) }}" method="POST">
|
||||||
<label class="form-label">درس مربوطه</label>
|
@csrf
|
||||||
<select name="subject_id" class="form-select">
|
|
||||||
<option value="">انتخاب درس (مثلاً: حقوق مدنی)</option>
|
|
||||||
@foreach($subjects as $subject)
|
|
||||||
<option value="{{ $subject->id }}">{{ $subject->title }}</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">متن سوال / مسئله حقوقی <span class="text-danger">*</span></label>
|
<label class="form-label">نوع سوال</label>
|
||||||
<textarea name="question_text" class="form-control" rows="4" required placeholder="صورت سوال یا مسئله حقوقی را وارد کنید..."></textarea>
|
<select name="type" id="questionTypeSelect" class="form-select" onchange="toggleOptionFields(this.value)">
|
||||||
</div>
|
<option value="multiple_choice" {{ old('type') == 'multiple_choice' ? 'selected' : '' }}>چهار گزینهای (تستی)</option>
|
||||||
|
<option value="descriptive" {{ old('type') == 'descriptive' ? 'selected' : '' }}>تشریحی</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">بارم / ضریب سوال</label>
|
<label class="form-label">درس مربوطه</label>
|
||||||
<input type="number" step="0.25" name="score" class="form-control" value="1.00" required>
|
<select name="subject_id" class="form-select">
|
||||||
</div>
|
<option value="">انتخاب درس (مثلاً: حقوق مدنی)</option>
|
||||||
|
@foreach($subjects as $subject)
|
||||||
|
<option value="{{ $subject->id }}" {{ old('subject_id') == $subject->id ? 'selected' : '' }}>
|
||||||
|
{{ $subject->title }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Multiple Choice Options Box -->
|
<div class="mb-3">
|
||||||
<div id="optionsContainer">
|
<label class="form-label">متن سوال / مسئله حقوقی <span class="text-danger">*</span></label>
|
||||||
<h6 class="border-bottom pb-2 mb-3">گزینهها و انتخاب پاسخ صحیح:</h6>
|
<textarea name="question_text" class="form-control" rows="4" required placeholder="صورت سوال یا مسئله حقوقی را وارد کنید...">{{ old('question_text') }}</textarea>
|
||||||
@for($i = 0; $i < 4; $i++)
|
</div>
|
||||||
<div class="input-group mb-2">
|
|
||||||
<div class="input-group-text">
|
<div class="mb-3">
|
||||||
<input class="form-check-input mt-0" type="radio" name="correct_option" value="{{ $i }}" {{ $i == 0 ? 'checked' : '' }}>
|
<label class="form-label">بارم / ضریب سوال</label>
|
||||||
</div>
|
<input type="number" step="0.25" name="score" class="form-control" value="{{ old('score', '1.00') }}" required>
|
||||||
<input type="text" name="options[]" class="form-control" placeholder="متن گزینه {{ $i + 1 }}">
|
</div>
|
||||||
|
|
||||||
|
<!-- Multiple Choice Options Box -->
|
||||||
|
<div id="optionsContainer">
|
||||||
|
<h6 class="border-bottom pb-2 mb-3">گزینهها و انتخاب پاسخ صحیح:</h6>
|
||||||
|
@for($i = 0; $i < 4; $i++)
|
||||||
|
<div class="input-group mb-2">
|
||||||
|
<div class="input-group-text">
|
||||||
|
<!-- Keep the correct radio button checked -->
|
||||||
|
<input class="form-check-input mt-0" type="radio" name="correct_option" value="{{ $i }}" {{ old('correct_option', 0) == $i ? 'checked' : '' }}>
|
||||||
</div>
|
</div>
|
||||||
@endfor
|
<!-- Keep the typed option text -->
|
||||||
<small class="text-muted d-block mb-3">دکمه رادیویی کنار هر گزینه نشاندهنده گزینه صحیح است.</small>
|
<input type="text" name="options[]" class="form-control" value="{{ old('options.'.$i) }}" placeholder="متن گزینه {{ $i + 1 }}">
|
||||||
</div>
|
</div>
|
||||||
|
@endfor
|
||||||
|
<small class="text-muted d-block mb-3">دکمه رادیویی کنار هر گزینه نشاندهنده گزینه صحیح است.</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">پاسخ تشریحی و مستندات مواد قانونی</label>
|
<label class="form-label">پاسخ تشریحی و مستندات مواد قانونی</label>
|
||||||
<textarea name="solution_explanation" class="form-control" rows="3" placeholder="توضیح پاسخ، استدلال و مواد قانونی مربوطه..."></textarea>
|
<textarea name="solution_explanation" class="form-control" rows="3" placeholder="توضیح پاسخ، استدلال و مواد قانونی مربوطه...">{{ old('solution_explanation') }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-success w-100">افزودن سوال</button>
|
<button type="submit" class="btn btn-success w-100">افزودن سوال</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Questions List -->
|
<!-- Questions List -->
|
||||||
<div class="col-lg-7">
|
<div class="col-lg-7">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-dark text-white">
|
<div class="card-header bg-dark text-white">
|
||||||
<h6 class="mb-0 text-white">سوالات ثبت شده ({{ $quiz->questions->count() }})</h6>
|
<h6 class="mb-0 text-white">سوالات ثبت شده ({{ $quiz->questions->count() }})</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@forelse($quiz->questions as $index => $question)
|
@forelse($quiz->questions as $index => $question)
|
||||||
<div class="border rounded p-3 mb-3 bg-light">
|
<div class="border rounded p-3 mb-3 bg-light">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||||
<span class="badge bg-secondary">سوال شماره {{ $index + 1 }}</span>
|
<span class="badge bg-secondary">سوال شماره {{ $index + 1 }}</span>
|
||||||
<div>
|
<div>
|
||||||
@if($question->subject)
|
@if($question->subject)
|
||||||
<span class="badge bg-info me-1">{{ $question->subject->title }}</span>
|
<span class="badge bg-info me-1">{{ $question->subject->title }}</span>
|
||||||
@endif
|
@endif
|
||||||
<span class="badge bg-{{ $question->type === 'multiple_choice' ? 'primary' : 'warning' }}">
|
<span class="badge bg-{{ $question->type === 'multiple_choice' ? 'primary' : 'warning' }}">
|
||||||
{{ $question->type === 'multiple_choice' ? 'تستی' : 'تشریحی' }}
|
{{ $question->type === 'multiple_choice' ? 'تستی' : 'تشریحی' }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="fw-bold mb-2">{{ $question->question_text }}</p>
|
|
||||||
|
|
||||||
@if($question->type === 'multiple_choice')
|
|
||||||
<div class="row g-2 mb-2">
|
|
||||||
@foreach($question->options as $optIndex => $option)
|
|
||||||
<div class="col-6">
|
|
||||||
<div class="p-2 border rounded {{ $option->is_correct ? 'bg-success text-white fw-bold' : 'bg-white' }}">
|
|
||||||
{{ $optIndex + 1 }}) {{ $option->option_text }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if($question->solution_explanation)
|
|
||||||
<div class="alert alert-secondary py-2 px-3 mt-2 mb-0 font-size-13">
|
|
||||||
<strong>پاسخ تشریحی / مستند قانون:</strong> {{ $question->solution_explanation }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<div class="text-end mt-2">
|
|
||||||
<form action="{{ route('questions.destroy', $question->id) }}" method="POST" class="d-inline" onsubmit="return confirm('آیا این سوال حذف شود؟')">
|
|
||||||
@csrf
|
|
||||||
@method('DELETE')
|
|
||||||
<button class="btn btn-sm btn-outline-danger">حذف سوال</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@empty
|
|
||||||
<p class="text-center text-muted py-4">هنوز سوالی برای این آزمون ثبت نشده است.</p>
|
<p class="fw-bold mb-2">{{ $question->question_text }}</p>
|
||||||
@endforelse
|
|
||||||
</div>
|
@if($question->type === 'multiple_choice')
|
||||||
|
<div class="row g-2 mb-2">
|
||||||
|
@foreach($question->options as $optIndex => $option)
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="p-2 border rounded {{ $option->is_correct ? 'bg-success text-white fw-bold' : 'bg-white' }}">
|
||||||
|
{{ $optIndex + 1 }}) {{ $option->option_text }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if($question->solution_explanation)
|
||||||
|
<div class="alert alert-secondary py-2 px-3 mt-2 mb-0 font-size-13">
|
||||||
|
<strong>پاسخ تشریحی / مستند قانون:</strong> {{ $question->solution_explanation }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="text-end mt-2">
|
||||||
|
<form action="{{ route('questions.destroy', $question->id) }}" method="POST" class="d-inline" onsubmit="return confirm('آیا این سوال حذف شود؟')">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button class="btn btn-sm btn-outline-danger">حذف سوال</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<p class="text-center text-muted py-4">هنوز سوالی برای این آزمون ثبت نشده است.</p>
|
||||||
|
@endforelse
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
@endsection
|
||||||
function toggleOptionFields(type) {
|
|
||||||
const container = document.getElementById('optionsContainer');
|
@section('scripts')
|
||||||
if (type === 'descriptive') {
|
<script>
|
||||||
container.style.display = 'none';
|
// Run this immediately on page load to check if we should hide options
|
||||||
} else {
|
// in case the page reloads with old('type') set to 'descriptive'
|
||||||
container.style.display = 'block';
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
}
|
var typeSelect = document.getElementById('questionTypeSelect');
|
||||||
}
|
toggleOptionFields(typeSelect.value);
|
||||||
</script>
|
});
|
||||||
|
|
||||||
|
function toggleOptionFields(type) {
|
||||||
|
const container = document.getElementById('optionsContainer');
|
||||||
|
if (type === 'descriptive') {
|
||||||
|
container.style.display = 'none';
|
||||||
|
} else {
|
||||||
|
container.style.display = 'block';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
@@ -33,6 +33,7 @@ use App\Http\Controllers\Admin\TicketController;
|
|||||||
use App\Http\Controllers\Admin\DashboardController;
|
use App\Http\Controllers\Admin\DashboardController;
|
||||||
use App\Http\Controllers\Admin\QuizController;
|
use App\Http\Controllers\Admin\QuizController;
|
||||||
use App\Http\Controllers\Admin\QuizCategoryController;
|
use App\Http\Controllers\Admin\QuizCategoryController;
|
||||||
|
use App\Http\Controllers\Admin\QuizSubjectController;
|
||||||
|
|
||||||
Route::get('payment/callback', [PayController::class, 'callback']);
|
Route::get('payment/callback', [PayController::class, 'callback']);
|
||||||
|
|
||||||
@@ -78,5 +79,7 @@ Route::middleware(['auth', config('jetstream.auth_session')])->group(function ()
|
|||||||
Route::delete('questions/{question}', [QuizController::class, 'destroyQuestion'])->name('questions.destroy');
|
Route::delete('questions/{question}', [QuizController::class, 'destroyQuestion'])->name('questions.destroy');
|
||||||
Route::resource('quiz-categories', QuizCategoryController::class)->except(['create', 'show', 'edit', 'update']);
|
Route::resource('quiz-categories', QuizCategoryController::class)->except(['create', 'show', 'edit', 'update']);
|
||||||
|
|
||||||
|
Route::resource('quiz-subjects', QuizSubjectController::class)->except(['create', 'show', 'edit', 'update']);
|
||||||
|
|
||||||
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user