28 nov 2023, 1:13pm
Cette révision appartient à :
Parent
8d4a622951
révision
23c4048858
@ -7,7 +7,6 @@
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Course;
|
||||
use Exception;
|
||||
use File;
|
||||
|
||||
class MaterialController extends Controller
|
||||
{
|
||||
@ -42,7 +41,7 @@ public function store(Request $request)
|
||||
$material->content_url = $request->contentURL;
|
||||
|
||||
if ($material->save()) {
|
||||
$this->notice::success('Data Saved');
|
||||
$this->notice::success('Data Saved');
|
||||
return redirect()->route('material.index');
|
||||
} else {
|
||||
$this->notice::error('Please try again');
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Backend\Quizzes;
|
||||
|
||||
use App\Models\Question;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Quiz;
|
||||
use Exception;
|
||||
|
||||
class QuestionController extends Controller
|
||||
{
|
||||
@ -13,7 +15,8 @@ class QuestionController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$question = Question::paginate(10);
|
||||
return view('backend.quiz.question.index', compact('question'));
|
||||
}
|
||||
|
||||
/**
|
||||
108
app/Http/Controllers/Backend/Quizzes/QuizController.php
Fichier normal
108
app/Http/Controllers/Backend/Quizzes/QuizController.php
Fichier normal
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Backend\Quizzes;
|
||||
|
||||
use App\Models\Quiz;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Course;
|
||||
use Exception;
|
||||
|
||||
class QuizController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$quiz = Quiz::paginate(10);
|
||||
return view('backend.quiz.index', compact('quiz'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$course = Course::get();
|
||||
return view('backend.quiz.create', compact('course'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
try {
|
||||
$quiz = new Quiz;
|
||||
$quiz->title = $request->quizTitle;
|
||||
$quiz->course_id = $request->courseId;
|
||||
|
||||
if ($quiz->save()) {
|
||||
$this->notice::success('Data Saved');
|
||||
return redirect()->route('quiz.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(Quiz $quiz)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$course = Course::get();
|
||||
$quiz = Quiz::findOrFail(encryptor('decrypt', $id));
|
||||
return view('backend.quiz.edit', compact('course', 'quiz'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$quiz = Quiz::findOrFail(encryptor('decrypt', $id));
|
||||
$quiz->title = $request->quizTitle;
|
||||
$quiz->course_id = $request->courseId;
|
||||
|
||||
if ($quiz->save()) {
|
||||
$this->notice::success('Data Saved');
|
||||
return redirect()->route('quiz.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 = Quiz::findOrFail(encryptor('decrypt', $id));
|
||||
if ($data->delete()) {
|
||||
$this->notice::error('Data Deleted!');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Quiz;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class QuizController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Quiz $quiz)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Quiz $quiz)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Quiz $quiz)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Quiz $quiz)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -23,4 +23,9 @@ public function material()
|
||||
{
|
||||
return $this->hasMany(Material::class);
|
||||
}
|
||||
|
||||
public function quiz()
|
||||
{
|
||||
return $this->hasMany(Quiz::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,4 +8,8 @@
|
||||
class Question extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function quiz(){
|
||||
return $this->belongsTo(Quiz::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,4 +8,14 @@
|
||||
class Quiz extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function course()
|
||||
{
|
||||
return $this->belongsTo(Course::class);
|
||||
}
|
||||
|
||||
public function question()
|
||||
{
|
||||
return $this->hasMany(Question::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ public function up(): void
|
||||
$table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
|
||||
@ -29,5 +29,5 @@ public function up(): void
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('questions');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -235,8 +235,8 @@ class="las la-chalkboard-teacher"></i>Instructors</a>
|
||||
<span class="nav-text">Payments</span>
|
||||
</a>
|
||||
<ul aria-expanded="false">
|
||||
<li><a href="javascript:void()"><i class="las la-circle"></i>Course Payment</a></li>
|
||||
<li><a href="javascript:void()"><i class="las la-circle"></i>subscription Payment</a></li>
|
||||
<li><a href="javascript:void()"><i class="las la-circle"></i>Course Fees</a></li>
|
||||
<li><a href="javascript:void()"><i class="las la-circle"></i>Subscription Fees</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="has-arrow" href="javascript:void()" aria-expanded="false">
|
||||
@ -244,6 +244,7 @@ class="las la-chalkboard-teacher"></i>Instructors</a>
|
||||
<span class="nav-text">Quizzes</span>
|
||||
</a>
|
||||
<ul aria-expanded="false">
|
||||
<li><a href="{{route('quiz.index')}}"><i class="las la-circle"></i>All Quizzes</a></li>
|
||||
<li><a href="javascript:void()"><i class="las la-circle"></i>Questions</a></li>
|
||||
<li><a href="javascript:void()"><i class="las la-circle"></i>Answers</a></li>
|
||||
</ul>
|
||||
|
||||
92
resources/views/backend/quiz/create.blade.php
Fichier normal
92
resources/views/backend/quiz/create.blade.php
Fichier normal
@ -0,0 +1,92 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Add Quiz')
|
||||
|
||||
@push('styles')
|
||||
<!-- Pick date -->
|
||||
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.css')}}">
|
||||
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.date.css')}}">
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="content-body">
|
||||
<!-- row -->
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row page-titles mx-0">
|
||||
<div class="col-sm-6 p-md-0">
|
||||
<div class="welcome-text">
|
||||
<h4>Add Quiz</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('quiz.index')}}">Quizzes</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('quiz.create')}}">Add Quiz</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12 col-xxl-12 col-sm-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">Basic Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route('quiz.store')}}" method="post" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Title</label>
|
||||
<input type="text" class="form-control" name="quizTitle"
|
||||
value="{{old('quizTitle')}}">
|
||||
</div>
|
||||
@if($errors->has('quizTitle'))
|
||||
<span class="text-danger"> {{ $errors->first('quizTitle') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Course</label>
|
||||
<select class="form-control" name="courseId">
|
||||
@forelse ($course as $c)
|
||||
<option value="{{$c->id}}" {{old('courseId')==$c->id?'selected':''}}>
|
||||
{{$c->title_en}}</option>
|
||||
@empty
|
||||
<option value="">No Course Found</option>
|
||||
@endforelse
|
||||
</select>
|
||||
</div>
|
||||
@if($errors->has('courseId'))
|
||||
<span class="text-danger"> {{ $errors->first('courseId') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="submit" class="btn btn-light">Cencel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<!-- pickdate -->
|
||||
<script src="{{asset('public/vendor/pickadate/picker.js')}}"></script>
|
||||
<script src="{{asset('public/vendor/pickadate/picker.time.js')}}"></script>
|
||||
<script src="{{asset('public/vendor/pickadate/picker.date.js')}}"></script>
|
||||
|
||||
<!-- Pickdate -->
|
||||
<script src="{{asset('public/js/plugins-init/pickadate-init.js')}}"></script>
|
||||
@endpush
|
||||
95
resources/views/backend/quiz/edit.blade.php
Fichier normal
95
resources/views/backend/quiz/edit.blade.php
Fichier normal
@ -0,0 +1,95 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Edit Quiz')
|
||||
|
||||
@push('styles')
|
||||
<!-- Pick date -->
|
||||
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.css')}}">
|
||||
<link rel="stylesheet" href="{{asset('public/vendor/pickadate/themes/default.date.css')}}">
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="content-body">
|
||||
<!-- row -->
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row page-titles mx-0">
|
||||
<div class="col-sm-6 p-md-0">
|
||||
<div class="welcome-text">
|
||||
<h4>Edit Quiz</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('quiz.index')}}">Quizzes</a></li>
|
||||
<li class="breadcrumb-item active"><a href="javascript:void(0);">Edit Quiz</a></li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12 col-xxl-12 col-sm-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">Basic Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route('quiz.update',encryptor('encrypt', $quiz->id))}}" method="post"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<input type="hidden" name="uptoken" value="{{encryptor('encrypt',$quiz->id)}}">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Title</label>
|
||||
<input type="text" class="form-control" name="quizTitle"
|
||||
value="{{old('quizTitle',$quiz->title)}}">
|
||||
</div>
|
||||
@if($errors->has('quizTitle'))
|
||||
<span class="text-danger"> {{ $errors->first('quizTitle') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Course</label>
|
||||
<select class="form-control" name="courseId">
|
||||
@forelse ($course as $c)
|
||||
<option value="{{$c->id}}" {{old('courseId', $quiz->course_id) ==
|
||||
$c->id?'selected':''}}>
|
||||
{{$c->title_en}}</option>
|
||||
@empty
|
||||
<option value="">No Quiz Found</option>
|
||||
@endforelse
|
||||
</select>
|
||||
</div>
|
||||
@if($errors->has('courseId'))
|
||||
<span class="text-danger"> {{ $errors->first('courseId') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
<button type="submit" class="btn btn-light">Cencel</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<!-- pickdate -->
|
||||
<script src="{{asset('public/vendor/pickadate/picker.js')}}"></script>
|
||||
<script src="{{asset('public/vendor/pickadate/picker.time.js')}}"></script>
|
||||
<script src="{{asset('public/vendor/pickadate/picker.date.js')}}"></script>
|
||||
|
||||
<!-- Pickdate -->
|
||||
<script src="{{asset('public/js/plugins-init/pickadate-init.js')}}"></script>
|
||||
@endpush
|
||||
106
resources/views/backend/quiz/index.blade.php
Fichier normal
106
resources/views/backend/quiz/index.blade.php
Fichier normal
@ -0,0 +1,106 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Quiz List')
|
||||
|
||||
@push('styles')
|
||||
<!-- Datatable -->
|
||||
<link href="{{asset('public/vendor/datatables/css/jquery.dataTables.min.css')}}" rel="stylesheet">
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="content-body">
|
||||
<!-- row -->
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row page-titles mx-0">
|
||||
<div class="col-sm-6 p-md-0">
|
||||
<div class="welcome-text">
|
||||
<h4>Quiz List</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{route('dashboard')}}">Home</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('quiz.index')}}">Quizzes</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('quiz.index')}}">All Quiz</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<ul class="nav nav-pills mb-3">
|
||||
<li class="nav-item"><a href="#list-view" data-toggle="tab"
|
||||
class="nav-link btn-primary mr-1 show active">List View</a></li>
|
||||
<li class="nav-item"><a href="javascript:void(0);" data-toggle="tab"
|
||||
class="nav-link btn-primary">Grid
|
||||
View</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="row tab-content">
|
||||
<div id="list-view" class="tab-pane fade active show col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h4 class="card-title">All Quizzes List </h4>
|
||||
<a href="{{route('quiz.create')}}" class="btn btn-primary">+ Add new</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="example3" class="display" style="min-width: 845px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{__('#')}}</th>
|
||||
<th>{{__('Quiz Title')}}</th>
|
||||
<th>{{__('Course')}}</th>
|
||||
<th>{{__('Action')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($quiz as $q)
|
||||
<tr>
|
||||
<td>{{$q->id}}</td>
|
||||
<td>{{$q->title}}</td>
|
||||
<td>{{$q->course?->title_en}}</td>
|
||||
<td>
|
||||
<a href="{{route('quiz.edit', encryptor('encrypt',$q->id))}}"
|
||||
class="btn btn-sm btn-primary" title="Edit"><i
|
||||
class="la la-pencil"></i></a>
|
||||
<a href="javascript:void(0);" class="btn btn-sm btn-danger"
|
||||
title="Delete" onclick="$('#form{{$q->id}}').submit()"><i
|
||||
class="la la-trash-o"></i></a>
|
||||
<form id="form{{$q->id}}"
|
||||
action="{{route('quiz.destroy', encryptor('encrypt',$q->id))}}"
|
||||
method="post">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<th colspan="4" class="text-center">No Quiz Found</th>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<!-- Datatable -->
|
||||
<script src="{{asset('public/vendor/datatables/js/jquery.dataTables.min.js')}}"></script>
|
||||
<script src="{{asset('public/js/plugins-init/datatables.init.js')}}"></script>
|
||||
|
||||
@endpush
|
||||
@ -11,6 +11,7 @@
|
||||
use App\Http\Controllers\Backend\Instructors\InstructorController as instructor;
|
||||
use App\Http\Controllers\Backend\Courses\CourseController as course;
|
||||
use App\Http\Controllers\Backend\Courses\MaterialController as material;
|
||||
use App\Http\Controllers\Backend\Quizzes\QuizController as quiz;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -43,6 +44,7 @@
|
||||
Route::resource('courseCategory', courseCategory::class);
|
||||
Route::resource('course', course::class);
|
||||
Route::resource('material', material::class);
|
||||
Route::resource('quiz', quiz::class);
|
||||
Route::get('permission/{role}', [permission::class, 'index'])->name('permission.list');
|
||||
Route::post('permission/{role}', [permission::class, 'save'])->name('permission.save');
|
||||
});
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user