diff --git a/app/Http/Controllers/DiscussionController.php b/app/Http/Controllers/Backend/Communication/DiscussionController.php similarity index 85% rename from app/Http/Controllers/DiscussionController.php rename to app/Http/Controllers/Backend/Communication/DiscussionController.php index 8698f4d..9af00d5 100644 --- a/app/Http/Controllers/DiscussionController.php +++ b/app/Http/Controllers/Backend/Communication/DiscussionController.php @@ -1,6 +1,6 @@ question_id = $request->questionId; + $option->option_text = $request->optionText; + $option->is_correct = $request->is_correct; + + if ($option->save()) { + $this->notice::success('Data Saved'); + return redirect()->route('option.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(); + } + } + + /** + * Display the specified resource. + */ + public function show(Option $option) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + $question = Question::get(); + $option = Option::findOrFail(encryptor('decrypt', $id)); + return view('backend.quiz.option.edit', compact('question', 'option')); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + try { + $option = Option::findOrFail(encryptor('decrypt', $id)); + $option->question_id = $request->questionId; + $option->option_text = $request->optionText; + $option->is_correct = $request->is_correct; + + if ($option->save()) { + $this->notice::success('Data Saved'); + return redirect()->route('option.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($id) + { + $data = Option::findOrFail(encryptor('decrypt', $id)); + if ($data->delete()) { + $this->notice::error('Data Deleted!'); + return redirect()->back(); + } + } +} diff --git a/app/Http/Controllers/Backend/Quizzes/QuestionController.php b/app/Http/Controllers/Backend/Quizzes/QuestionController.php index fe04ccc..5c73b81 100644 --- a/app/Http/Controllers/Backend/Quizzes/QuestionController.php +++ b/app/Http/Controllers/Backend/Quizzes/QuestionController.php @@ -1,6 +1,6 @@ belongsTo(Student::class); + } + + public function question() + { + return $this->belongsTo(Question::class); + } } diff --git a/app/Models/Course.php b/app/Models/Course.php index 7866a72..6f52f22 100644 --- a/app/Models/Course.php +++ b/app/Models/Course.php @@ -28,4 +28,14 @@ public function quiz() { return $this->hasMany(Quiz::class); } + + public function review() + { + return $this->hasMany(Review::class); + } + + public function discussion() + { + return $this->hasMany(Discussion::class); + } } diff --git a/app/Models/Discussion.php b/app/Models/Discussion.php index 934a571..3b757e2 100644 --- a/app/Models/Discussion.php +++ b/app/Models/Discussion.php @@ -8,4 +8,14 @@ class Discussion extends Model { use HasFactory; + + public function user() + { + return $this->belongsTo(User::class); + } + + public function course() + { + return $this->belongsTo(Course::class); + } } diff --git a/app/Models/Message.php b/app/Models/Message.php index b9f7393..ed8e137 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -8,4 +8,9 @@ class Message extends Model { use HasFactory; + + public function user() + { + return $this->belongsTo(User::class); + } } diff --git a/app/Models/Option.php b/app/Models/Option.php new file mode 100644 index 0000000..ad2c842 --- /dev/null +++ b/app/Models/Option.php @@ -0,0 +1,16 @@ +belongsTo(Question::class); + } +} diff --git a/app/Models/Question.php b/app/Models/Question.php index fdc70a3..d8c78ae 100644 --- a/app/Models/Question.php +++ b/app/Models/Question.php @@ -12,4 +12,13 @@ class Question extends Model public function quiz(){ return $this->belongsTo(Quiz::class); } + + public function option(){ + return $this->hasMany(Option::class); + } + + public function answer() + { + return $this->hasMany(Answer::class); + } } diff --git a/app/Models/Review.php b/app/Models/Review.php index b63a133..f5271e0 100644 --- a/app/Models/Review.php +++ b/app/Models/Review.php @@ -8,4 +8,14 @@ class Review extends Model { use HasFactory; + + public function student() + { + return $this->belongsTo(Student::class); + } + + public function course() + { + return $this->belongsTo(Course::class); + } } diff --git a/app/Models/Student.php b/app/Models/Student.php index c720c69..bba1a4e 100644 --- a/app/Models/Student.php +++ b/app/Models/Student.php @@ -13,4 +13,14 @@ public function role() { return $this->belongsTo(Role::class); } + + public function answer() + { + return $this->hasMany(Answer::class); + } + + public function review() + { + return $this->hasMany(Review::class); + } } diff --git a/app/Models/User.php b/app/Models/User.php index 1b864e6..0636309 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -35,4 +35,14 @@ public function role() { return $this->belongsTo(Role::class); } + + public function discussion() + { + return $this->hasMany(Discussion::class); + } + + public function message() + { + return $this->hasMany(Message::class); + } } diff --git a/database/migrations/2023_11_26_153660_create_options_table.php b/database/migrations/2023_11_26_153660_create_options_table.php new file mode 100644 index 0000000..bfac264 --- /dev/null +++ b/database/migrations/2023_11_26_153660_create_options_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('question_id')->index(); + $table->string('option_text'); + $table->boolean('is_correct')->default(false); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('options'); + } +}; diff --git a/database/migrations/2023_11_26_153719_create_answers_table.php b/database/migrations/2023_11_26_153719_create_answers_table.php index 32b337a..5ed79c1 100644 --- a/database/migrations/2023_11_26_153719_create_answers_table.php +++ b/database/migrations/2023_11_26_153719_create_answers_table.php @@ -14,7 +14,7 @@ public function up(): void Schema::create('answers', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('student_id')->index(); - $table->unsignedBigInteger('question_id')->index(); + $table->unsignedBigInteger('question_id')->index(); $table->text('answer')->nullable(); $table->timestamps(); $table->softDeletes(); diff --git a/database/migrations/2023_11_26_153735_create_reviews_table.php b/database/migrations/2023_11_26_153735_create_reviews_table.php index 8401ccd..fc9f381 100644 --- a/database/migrations/2023_11_26_153735_create_reviews_table.php +++ b/database/migrations/2023_11_26_153735_create_reviews_table.php @@ -17,7 +17,7 @@ public function up(): void $table->unsignedBigInteger('course_id')->index(); $table->integer('rating'); $table->text('comment')->nullable(); - $table->timestamps(); + $table->timestamps(); $table->softDeletes(); $table->foreign('student_id')->references('id')->on('students')->onDelete('cascade'); diff --git a/database/migrations/2023_11_26_153902_create_discussions_table.php b/database/migrations/2023_11_26_153902_create_discussions_table.php index f7f0379..bf7e945 100644 --- a/database/migrations/2023_11_26_153902_create_discussions_table.php +++ b/database/migrations/2023_11_26_153902_create_discussions_table.php @@ -21,7 +21,7 @@ public function up(): void $table->softDeletes(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade'); + $table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade'); }); } diff --git a/database/migrations/2023_11_26_153916_create_messages_table.php b/database/migrations/2023_11_26_153916_create_messages_table.php index 3ff9a8c..b7fa7b6 100644 --- a/database/migrations/2023_11_26_153916_create_messages_table.php +++ b/database/migrations/2023_11_26_153916_create_messages_table.php @@ -20,7 +20,7 @@ public function up(): void $table->softDeletes(); $table->foreign('sender_id')->references('id')->on('users')->onDelete('cascade'); - $table->foreign('receiver_id')->references('id')->on('users')->onDelete('cascade'); + $table->foreign('receiver_id')->references('id')->on('users')->onDelete('cascade'); }); } diff --git a/eLearning.sql b/eLearning.sql index f42f6fd..b389321 100644 --- a/eLearning.sql +++ b/eLearning.sql @@ -139,12 +139,21 @@ CREATE TABLE questions ( FOREIGN KEY (quiz_id) REFERENCES quizzes(id) ); +-- Introduced a new table for multiple-choice options +CREATE TABLE options ( + id INT PRIMARY KEY AUTO_INCREMENT, + question_id INT, + option_text VARCHAR(255) NOT NULL, + is_correct BOOLEAN DEFAULT false, + FOREIGN KEY (question_id) REFERENCES questions(id) +); + -- User_answers table stores user responses to quiz questions CREATE TABLE user_answers ( id INT PRIMARY KEY AUTO_INCREMENT, student_id INT, question_id INT, - answer TEXT, + answer TEXT, is_correct BOOLEAN, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (student_id) REFERENCES students(id), diff --git a/resources/views/backend/communication/discussion/index.blade.php b/resources/views/backend/communication/discussion/index.blade.php new file mode 100644 index 0000000..541bb1f --- /dev/null +++ b/resources/views/backend/communication/discussion/index.blade.php @@ -0,0 +1,109 @@ +@extends('backend.layouts.app') +@section('title', 'Discussion List') + +@push('styles') + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Discussion List

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

All Discussions List

+
+
+
+ + + + + + + + + + + + + @forelse ($discussion as $d) + + + + + + + + + @empty + + + + @endforelse + +
{{__('User')}}{{__('Role')}}{{__('Course')}}{{__('Title')}}{{__('Comment')}}{{__('Action')}}
{{$d->user?->name_en}}{{$d->user?->role?->name}}{{$d->course?->title_en}}{{$d->title}}{{$d->content}} + + +
+ @csrf + @method('DELETE') +
+

No Discussion Found

+
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/communication/message/index.blade.php b/resources/views/backend/communication/message/index.blade.php new file mode 100644 index 0000000..ea0907e --- /dev/null +++ b/resources/views/backend/communication/message/index.blade.php @@ -0,0 +1,109 @@ +@extends('backend.layouts.app') +@section('title', 'Message List') + +@push('styles') + + +@endpush + +@section('content') + +
+ +
+ +
+
+
+

Message List

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

All Messages List

+
+
+
+ + + + + + + + + + + + @forelse ($message as $m) + + + + + + + + @empty + + + + @endforelse + +
{{__('#')}}{{__('Sender')}}{{__('Receiver')}}{{__('Message')}}{{__('Action')}}
{{$m->id}}{{$m->user?->name_en}}{{$m->user?->name_en}}{{$m->content}} + + +
+ @csrf + @method('DELETE') +
+
+

No Message Found

+
+
+
+
+
+
+
+
+ +
+
+ +@endsection + +@push('scripts') + + + + +@endpush \ No newline at end of file diff --git a/resources/views/backend/course/create.blade.php b/resources/views/backend/course/courses/create.blade.php similarity index 100% rename from resources/views/backend/course/create.blade.php rename to resources/views/backend/course/courses/create.blade.php diff --git a/resources/views/backend/course/edit.blade.php b/resources/views/backend/course/courses/edit.blade.php similarity index 100% rename from resources/views/backend/course/edit.blade.php rename to resources/views/backend/course/courses/edit.blade.php diff --git a/resources/views/backend/course/index.blade.php b/resources/views/backend/course/courses/index.blade.php similarity index 100% rename from resources/views/backend/course/index.blade.php rename to resources/views/backend/course/courses/index.blade.php diff --git a/resources/views/backend/layouts/app.blade.php b/resources/views/backend/layouts/app.blade.php index 444b1ef..c16b100 100644 --- a/resources/views/backend/layouts/app.blade.php +++ b/resources/views/backend/layouts/app.blade.php @@ -230,23 +230,15 @@ class="las la-chalkboard-teacher">Instructors -
  • - -
  • Reviews
  • +
  • +
  • +
  • diff --git a/resources/views/backend/quiz/answer/index.blade.php b/resources/views/backend/quiz/answer/index.blade.php index 9fa591d..e05eb85 100644 --- a/resources/views/backend/quiz/answer/index.blade.php +++ b/resources/views/backend/quiz/answer/index.blade.php @@ -54,24 +54,25 @@ class="nav-link btn-primary">Grid {{__('Student')}} {{__('Question')}} {{__('Answer')}} - {{__('Action')}} + {{__('Action')}} - @forelse ($quiz as $q) + @forelse ($answer as $a) - {{$q->id}} - {{$q->title}} - {{$q->student?->name_en}} + {{$a->id}} + {{$a->student?->name_en}} + {{$a->question?->content}} + {{$a->answer}} - -
    @csrf @method('DELETE') @@ -80,7 +81,7 @@ class="la la-trash-o"> @empty - No Answer Found +

    No Answer Found

    @endforelse diff --git a/resources/views/backend/quiz/option/create.blade.php b/resources/views/backend/quiz/option/create.blade.php new file mode 100644 index 0000000..dcf5de5 --- /dev/null +++ b/resources/views/backend/quiz/option/create.blade.php @@ -0,0 +1,100 @@ +@extends('backend.layouts.app') +@section('title', 'Add Option') + +@push('styles') + + + +@endpush + +@section('content') + +
    + +
    + +
    +
    +
    +

    Add Option

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

    Edit Option

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

    Option List

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

    All Options List

    + + Add new +
    +
    +
    + + + + + + + + + + + + @forelse ($option as $o) + + + + + + + + @empty + + + + @endforelse + +
    {{__('#')}}{{__('Question')}}{{__('Option')}}{{__('Is Correct')}}{{__('Action')}}
    {{$o->id}}{{$o->question?->content}}{{$o->option_text}} + {{ $o->is_correct == 1 ? 'Correct' : 'Wrong' }} + + + +
    + @csrf + @method('DELETE') +
    +
    No Option Found
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + +@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 index 1de7ea1..8b317a6 100644 --- a/resources/views/backend/quiz/question/edit.blade.php +++ b/resources/views/backend/quiz/question/edit.blade.php @@ -62,7 +62,7 @@
    @@ -92,7 +93,8 @@ +
    @if($errors->has('birthDate')) {{ $errors->first('birthDate') }} @@ -117,11 +120,14 @@ class="form-control" id="">
    @@ -130,8 +136,10 @@ class="form-control" id="">
    diff --git a/resources/views/frontend/app.blade.php b/resources/views/frontend/app.blade.php index 4474b0d..0f3c797 100644 --- a/resources/views/frontend/app.blade.php +++ b/resources/views/frontend/app.blade.php @@ -3,7 +3,7 @@ - {{ENV('APP_NAME')}} | @yield('title') + {{ENV('APP_NAME')}} | @yield('title', 'Home') diff --git a/routes/web.php b/routes/web.php index e623e69..8374f28 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,18 +1,23 @@ name('permission.list'); Route::post('permission/{role}', [permission::class, 'save'])->name('permission.save'); });