<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\QuestionsController;
use App\Http\Controllers\TemplateController;
use App\Http\Controllers\AnswerController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
})->name('welcome');

Auth::routes();

Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

Route::get('/template', [TemplateController::class, 'index'])->name('template');
Route::get('/template_get_data', [TemplateController::class, 'template_get_data'])->name('template_get_data');
Route::get('/template_get_edit', [TemplateController::class, 'template_get_edit'])->name('template_get_edit');
Route::get('/template_get_map', [TemplateController::class, 'template_get_map'])->name('template_get_map');
Route::post('/template_store', [TemplateController::class, 'template_store'])->name('template_store');
Route::post('/template_update', [TemplateController::class, 'template_update'])->name('template_update');
Route::post('/template_delete', [TemplateController::class, 'template_delete'])->name('template_delete');
Route::post('/map_template_store', [TemplateController::class, 'map_template_store'])->name('map_template_store');
Route::post('/map_templates_delete', [TemplateController::class, 'map_templates_delete'])->name('map_templates_delete');

Route::get('/questions', [QuestionsController::class, 'index'])->name('questions');
Route::get('/questions_get_data', [QuestionsController::class, 'questions_get_data'])->name('questions_get_data');
Route::get('/questions_get_edit', [QuestionsController::class, 'questions_get_edit'])->name('questions_get_edit');
Route::post('/questions_store', [QuestionsController::class, 'questions_store'])->name('questions_store');
Route::post('/questions_update', [QuestionsController::class, 'questions_update'])->name('questions_update');
Route::post('/questions_delete', [QuestionsController::class, 'questions_delete'])->name('questions_delete');

Route::get('/answers_get_data', [AnswerController::class, 'answers_get_data'])->name('answers_get_data');
Route::post('/answers_store', [AnswerController::class, 'answers_store'])->name('answers_store');
Route::post('/answers_delete', [AnswerController::class, 'answers_delete'])->name('answers_delete');

Route::get('/questions_start_{quizId}', [TemplateController::class, 'questions_start'])->name('questions_start');
Route::get('/questions_start_{quiz_id}/next_{nextQuestionId}', [TemplateController::class, 'questions_next'])->name('questions_next');
Route::post('/check_answer', [TemplateController::class, 'check_answer'])->name('check_answer');
Route::post('/check_hint', [TemplateController::class, 'check_hint'])->name('check_hint');

Route::group(['prefix' => 'filemanager', 'middleware' => ['web', 'auth']], function () {
    \UniSharp\LaravelFilemanager\Lfm::routes();
});
