@include('admin.crud.form', [ 'action' => route('admin.questions.update', $edit_data->id), 'method' => 'PUT', 'formId' => 'edit-question-form', 'submitText' => 'Update Question', 'class' => 'ajax-crud-form', 'redirect' => route('admin.questions.index'), 'fields' => [ [ 'type' => 'select', 'name' => 'bank_id', 'id' => 'bank_id', 'label' => 'Question Bank', 'required' => true, 'options' => $question_banks->pluck('title', 'id')->toArray(), 'value' => $edit_data->bank_id, 'col' => 6 ], [ 'type' => 'hidden', 'name' => 'question_type', 'id' => 'question_type', 'value' => $edit_data->question_type ], [ 'type' => 'select', 'name' => 'course_id', 'id' => 'course_id', 'label' => 'Course', 'options' => $courses->pluck('title', 'id')->toArray(), 'value' => $edit_data->course_id, 'col' => 6 ], [ 'type' => 'select', 'name' => 'unit_id', 'id' => 'unit_id', 'label' => 'Course Unit', 'options' => [], 'value' => $edit_data->unit_id, 'col' => 6 ], [ 'type' => 'textarea', 'name' => 'question_text', 'id' => 'question_text', 'label' => 'Question Text', 'placeholder' => 'Enter the question text', 'required' => true, 'value' => $edit_data->question_text, 'col' => 12 ], [ 'type' => 'text', 'name' => 'option_a', 'id' => 'option_a', 'label' => 'Option A', 'placeholder' => 'Enter option A', 'required' => true, 'value' => $edit_data->questionOptions->where('sort_order', 1)->first()->option_text ?? '', 'col' => 6 ], [ 'type' => 'file', 'name' => 'option_a_img', 'id' => 'option_a_img', 'label' => 'Option A Image', 'accept' => 'image/*', 'presetKey' => 'option_image', 'pasteable' => true, 'col' => 6, 'value' => $edit_data->questionOptions->where('sort_order', 1)->first()->option_image_url, ], [ 'type' => 'text', 'name' => 'option_b', 'id' => 'option_b', 'label' => 'Option B', 'placeholder' => 'Enter option B', 'required' => true, 'value' => $edit_data->questionOptions->where('sort_order', 2)->first()->option_text ?? '', 'col' => 6 ], [ 'type' => 'file', 'name' => 'option_b_img', 'id' => 'option_b_img', 'label' => 'Option B Image', 'accept' => 'image/*', 'presetKey' => 'option_image', 'pasteable' => true, 'col' => 6, 'value' => $edit_data->questionOptions->where('sort_order', 2)->first()->option_image_url, ], [ 'type' => 'text', 'name' => 'option_c', 'id' => 'option_c', 'label' => 'Option C', 'placeholder' => 'Enter option C', 'required' => true, 'value' => $edit_data->questionOptions->where('sort_order', 3)->first()->option_text ?? '', 'col' => 6 ], [ 'type' => 'file', 'name' => 'option_c_img', 'id' => 'option_c_img', 'label' => 'Option C Image', 'accept' => 'image/*', 'presetKey' => 'option_image', 'pasteable' => true, 'col' => 6, 'value' => $edit_data->questionOptions->where('sort_order', 3)->first()->option_image_url, ], [ 'type' => 'text', 'name' => 'option_d', 'id' => 'option_d', 'label' => 'Option D', 'placeholder' => 'Enter option D', 'required' => true, 'value' => $edit_data->questionOptions->where('sort_order', 4)->first()->option_text ?? '', 'col' => 6 ], [ 'type' => 'file', 'name' => 'option_d_img', 'id' => 'option_d_img', 'label' => 'Option D Image', 'accept' => 'image/*', 'presetKey' => 'option_image', 'pasteable' => true, 'col' => 6, 'value' => $edit_data->questionOptions->where('sort_order', 4)->first()->option_image_url, ], [ 'type' => 'select', 'name' => 'correct_answer', 'id' => 'correct_answer', 'label' => 'Correct Answer', 'required' => true, 'options' => [ 'A' => 'Option A', 'B' => 'Option B', 'C' => 'Option C', 'D' => 'Option D' ], 'value' => $edit_data->questionOptions->where('is_correct', 1)->first() ? ($edit_data->questionOptions->where('is_correct', 1)->first()->sort_order == 1 ? 'A' : ($edit_data->questionOptions->where('is_correct', 1)->first()->sort_order == 2 ? 'B' : ($edit_data->questionOptions->where('is_correct', 1)->first()->sort_order == 3 ? 'C' : 'D'))) : 'A', 'col' => 6 ], [ 'type' => 'textarea', 'name' => 'explanation', 'id' => 'explanation', 'label' => 'Explanation', 'placeholder' => 'Enter explanation for the answer', 'value' => $edit_data->explanation, 'col' => 12 ], [ 'type' => 'number', 'name' => 'mark_correct', 'id' => 'mark_correct', 'label' => 'Correct Marks', 'placeholder' => '1.00', 'required' => true, 'min' => 0, 'step' => 0.01, 'value' => $edit_data->mark_correct, 'col' => 4 ], [ 'type' => 'number', 'name' => 'mark_wrong', 'id' => 'mark_wrong', 'label' => 'Wrong Marks', 'placeholder' => '0.00', 'required' => true, 'min' => 0, 'step' => 0.01, 'value' => $edit_data->mark_wrong, 'col' => 4 ], [ 'type' => 'hidden', 'name' => 'difficulty', 'id' => 'difficulty', 'value' => $edit_data->difficulty ], [ 'type' => 'select', 'name' => 'status', 'id' => 'status', 'label' => 'Status', 'required' => true, 'options' => [ 'active' => 'Active', 'inactive' => 'Inactive' ], 'value' => $edit_data->status, 'col' => 6 ], [ 'type' => 'number', 'name' => 'sort_order', 'id' => 'sort_order', 'label' => 'Sort Order', 'placeholder' => '0', 'min' => 0, 'value' => $edit_data->sort_order, 'col' => 6 ], [ 'type' => 'files', 'name' => 'question_images', 'id' => 'question_images', 'label' => 'Question Images', 'presetKey' => 'question_images', 'pasteable' => true, // 'multiple' => true, 'accept' => 'image/*', 'value' => $edit_data->question_images_url, 'col' => 12 ], ] ]) @push('scripts') @endpush