From fef0751d1af163f1a25256e0134a8f39f66eb755 Mon Sep 17 00:00:00 2001 From: Ibrahim Khail Shakil Date: Tue, 28 Nov 2023 13:54:30 +0600 Subject: [PATCH] 28 nov 2023, 1:54pm --- .../Backend/Quizzes/QuestionController.php | 57 ++++++-- .../backend/quiz/question/create.blade.php | 107 +++++++++++++++ .../backend/quiz/question/edit.blade.php | 124 ++++++++++++++++++ .../backend/quiz/question/index.blade.php | 111 ++++++++++++++++ .../views/backend/user/userProfile.blade.php | 6 - 5 files changed, 391 insertions(+), 14 deletions(-) create mode 100644 resources/views/backend/quiz/question/create.blade.php create mode 100644 resources/views/backend/quiz/question/edit.blade.php create mode 100644 resources/views/backend/quiz/question/index.blade.php diff --git a/app/Http/Controllers/Backend/Quizzes/QuestionController.php b/app/Http/Controllers/Backend/Quizzes/QuestionController.php index 1d0f674..ecfaf06 100644 --- a/app/Http/Controllers/Backend/Quizzes/QuestionController.php +++ b/app/Http/Controllers/Backend/Quizzes/QuestionController.php @@ -24,7 +24,8 @@ public function index() */ public function create() { - // + $quiz = Quiz::get(); + return view('backend.quiz.question.create', compact('quiz')); } /** @@ -32,7 +33,24 @@ public function create() */ public function store(Request $request) { - // + try { + $question = new Question; + $question->quiz_id = $request->quizId; + $question->type = $request->questionType; + $question->content = $request->questionContent; + + if ($question->save()) { + $this->notice::success('Data Saved'); + return redirect()->route('question.index'); + } else { + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } + } catch (Exception $e) { + dd($e); + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } } /** @@ -46,24 +64,47 @@ public function show(Question $question) /** * Show the form for editing the specified resource. */ - public function edit(Question $question) + public function edit($id) { - // + $quiz = Quiz::get(); + $question = Question::findOrFail(encryptor('decrypt',$id)); + return view('backend.quiz.question.create', compact('quiz')); } /** * Update the specified resource in storage. */ - public function update(Request $request, Question $question) + public function update(Request $request, $id) { - // + try { + $question = Question::findOrFail(encryptor('decrypt', $id)); + $question->quiz_id = $request->quizId; + $question->type = $request->questionType; + $question->content = $request->questionContent; + + if ($question->save()) { + $this->notice::success('Data Saved'); + return redirect()->route('question.index'); + } else { + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } + } catch (Exception $e) { + dd($e); + $this->notice::error('Please try again'); + return redirect()->back()->withInput(); + } } /** * Remove the specified resource from storage. */ - public function destroy(Question $question) + public function destroy($id) { - // + $data = Question::findOrFail(encryptor('decrypt', $id)); + if ($data->delete()) { + $this->notice::error('Data Deleted!'); + return redirect()->back(); + } } } diff --git a/resources/views/backend/quiz/question/create.blade.php b/resources/views/backend/quiz/question/create.blade.php new file mode 100644 index 0000000..ec83bb2 --- /dev/null +++ b/resources/views/backend/quiz/question/create.blade.php @@ -0,0 +1,107 @@ +@extends('backend.layouts.app') +@section('title', 'Add Question') + +@push('styles') + + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Add Question

+
+
+
+ +
+
+ +
+
+
+
+
Basic Info
+
+
+
+ @csrf +
+
+
+ + +
+ @if($errors->has('quizId')) + {{ $errors->first('quizId') }} + @endif +
+
+
+ + +
+
+
+
+ + +
+ @if($errors->has('questionContent')) + {{ $errors->first('questionContent') }} + @endif +
+
+ + +
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/quiz/question/edit.blade.php b/resources/views/backend/quiz/question/edit.blade.php new file mode 100644 index 0000000..ea3c060 --- /dev/null +++ b/resources/views/backend/quiz/question/edit.blade.php @@ -0,0 +1,124 @@ +@extends('backend.layouts.app') +@section('title', 'Edit Course Material Material') + +@push('styles') + + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Edit Course Material

+
+
+ +
+ +
+
+
+
+
Basic Info
+
+
+
+ @csrf + @method('PATCH') + +
+
+
+ + +
+ @if($errors->has('materialTitle')) + {{ $errors->first('materialTitle') }} + @endif +
+
+
+ + +
+ @if($errors->has('courseId')) + {{ $errors->first('courseId') }} + @endif +
+
+
+ + +
+ @if($errors->has('materialType')) + {{ $errors->first('materialType') }} + @endif +
+
+
+ + +
+ @if($errors->has('contentURL')) + {{ $errors->first('contentURL') }} + @endif +
+
+ + +
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/quiz/question/index.blade.php b/resources/views/backend/quiz/question/index.blade.php new file mode 100644 index 0000000..d9d864c --- /dev/null +++ b/resources/views/backend/quiz/question/index.blade.php @@ -0,0 +1,111 @@ +@extends('backend.layouts.app') +@section('title', 'Question List') + +@push('styles') + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Question List

+
+
+
+ +
+
+ +
+ +
+
+
+
+
+

All Questions List

+ + Add new +
+
+
+ + + + + + + + + + + + @forelse ($question as $q) + + + + + + + + @empty + + + + @endforelse + +
{{__('#')}}{{__('Quiz Name')}}{{__('Question Type')}}{{__('Question Content')}}{{__('Action')}}
{{$q->id}}{{$q->quiz?->title}} + {{ $q->type == 'multiple_choice' ? __('Multiple Choice') : ($q->type == 'true_false' ? + __('True False') : __('Short Answer')) }} + {{$q->questionContent}} + + +
+ @csrf + @method('DELETE') +
+
No Question Found
+
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/user/userProfile.blade.php b/resources/views/backend/user/userProfile.blade.php index fafa097..50008cf 100644 --- a/resources/views/backend/user/userProfile.blade.php +++ b/resources/views/backend/user/userProfile.blade.php @@ -51,12 +51,6 @@

Email

-