28 nov 2023, 1:54pm
Cette révision appartient à :
Parent
23c4048858
révision
fef0751d1a
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
107
resources/views/backend/quiz/question/create.blade.php
Fichier normal
107
resources/views/backend/quiz/question/create.blade.php
Fichier normal
@ -0,0 +1,107 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Add Question')
|
||||
|
||||
@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 Question</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('question.index')}}">Questions</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('question.create')}}">Add Question</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('question.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">Quiz</label>
|
||||
<select class="form-control" name="quizId">
|
||||
@forelse ($short_answer as $q)
|
||||
<option value="{{$q->id}}" {{old('quizId')==$q->id?'selected':''}}>
|
||||
{{$q->quizTitle}}</option>
|
||||
@empty
|
||||
<option value="">No Quiz Found</option>
|
||||
@endforelse
|
||||
</select>
|
||||
</div>
|
||||
@if($errors->has('quizId'))
|
||||
<span class="text-danger"> {{ $errors->first('quizId') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Question Type</label>
|
||||
<select class="form-control" name="questionType">
|
||||
<option value="multiple_choice" @if(old('questionType')=='multiple_choice' ) selected @endif>
|
||||
Multiple Choice
|
||||
</option>
|
||||
<option value="true_false" @if(old('questionType')=='true_false' ) selected
|
||||
@endif>True False
|
||||
</option>
|
||||
<option value="short_answer" @if(old('questionType')=='short_answer' ) selected @endif>Short Answer
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Question Content</label>
|
||||
<textarea class="form-control"
|
||||
name="questionContent">{{old('questionContent')}}</textarea>
|
||||
</div>
|
||||
@if($errors->has('questionContent'))
|
||||
<span class="text-danger"> {{ $errors->first('questionContent') }}</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
|
||||
124
resources/views/backend/quiz/question/edit.blade.php
Fichier normal
124
resources/views/backend/quiz/question/edit.blade.php
Fichier normal
@ -0,0 +1,124 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Edit Course Material Material')
|
||||
|
||||
@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 Course Material</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('material.index')}}">Course Materials</a></li>
|
||||
<li class="breadcrumb-item active"><a href="javascript:void(0);">Edit Course Material</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('material.update',encryptor('encrypt', $material->id))}}" method="post"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<input type="hidden" name="uptoken" value="{{encryptor('encrypt',$material->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="materialTitle"
|
||||
value="{{old('materialTitle',$material->title)}}">
|
||||
</div>
|
||||
@if($errors->has('materialTitle'))
|
||||
<span class="text-danger"> {{ $errors->first('materialTitle') }}</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', $material->course_id) ==
|
||||
$c->id?'selected':''}}>
|
||||
{{$c->title_en}}</option>
|
||||
@empty
|
||||
<option value="">No Course Material Material Found</option>
|
||||
@endforelse
|
||||
</select>
|
||||
</div>
|
||||
@if($errors->has('courseId'))
|
||||
<span class="text-danger"> {{ $errors->first('courseId') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Material Type</label>
|
||||
<select class="form-control" name="materialType">
|
||||
<option value="video" @if(old('materialType', $material->type)=='video' ) selected
|
||||
@endif>Video
|
||||
</option>
|
||||
<option value="document" @if(old('materialType', $material->type)=='document' ) selected
|
||||
@endif>Document
|
||||
</option>
|
||||
<option value="quiz" @if(old('materialType', $material->type)
|
||||
=='quiz' )
|
||||
selected @endif>Quiz</option>
|
||||
</select>
|
||||
</div>
|
||||
@if($errors->has('materialType'))
|
||||
<span class="text-danger"> {{ $errors->first('materialType') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Content Url</label>
|
||||
<textarea class="form-control"
|
||||
name="contentURL">{{old('contentURL',$material->content_url)}}</textarea>
|
||||
</div>
|
||||
@if($errors->has('contentURL'))
|
||||
<span class="text-danger"> {{ $errors->first('contentURL') }}</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
|
||||
111
resources/views/backend/quiz/question/index.blade.php
Fichier normal
111
resources/views/backend/quiz/question/index.blade.php
Fichier normal
@ -0,0 +1,111 @@
|
||||
@extends('backend.layouts.app')
|
||||
@section('title', 'Question 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>Question 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('question.index')}}">Questions</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{route('question.index')}}">All Question</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 Questions List </h4>
|
||||
<a href="{{route('question.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 Name')}}</th>
|
||||
<th>{{__('Question Type')}}</th>
|
||||
<th>{{__('Question Content')}}</th>
|
||||
<th>{{__('Action')}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse ($question as $q)
|
||||
<tr>
|
||||
<td>{{$q->id}}</td>
|
||||
<td>{{$q->quiz?->title}}</td>
|
||||
<td>
|
||||
{{ $q->type == 'multiple_choice' ? __('Multiple Choice') : ($q->type == 'true_false' ?
|
||||
__('True False') : __('Short Answer')) }}
|
||||
</td>
|
||||
<td>{{$q->questionContent}}</td>
|
||||
<td>
|
||||
<a href="{{route('question.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('question.destroy', encryptor('encrypt',$q->id))}}"
|
||||
method="post">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<th colspan="5" class="text-center">No Question 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
|
||||
@ -51,12 +51,6 @@
|
||||
<p>Email</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="col-xl-4 col-sm-4 prf-col">
|
||||
<div class="profile-call">
|
||||
<h4 class="text-muted">(+1) 321-837-1030</h4>
|
||||
<p>Phone No.</p>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user