<?php

namespace App\Http\Controllers\API\v1;

use App\Http\Controllers\BaseController;
use App\Http\Controllers\Controller;
use App\Http\Requests\QuizStoreRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

use Exception;

class QuizController extends BaseController
{
    // Take randomly five quizs for student

    public function take_quiz(Request $request,$chapId) {

        try {

            //$CurrentDb = $request->get('CurrentDb');
            // $server_response = getFromGest('chapitres/'.$chapId.'/quizs', ['bd' => substr($CurrentDb, 10)])->json();
            $server_response = reqGest('GET','chapitres/'.$chapId.'/quizs',[],2);

            if(isset($server_response['success']) && $server_response['success'] == true){

                return sendResponse($server_response['data'],$server_response['message']);

            }
            else if(isset($server_response['success']) && $server_response['success'] == false){

                return sendError($server_response['message']);

            }
        } catch (Exception $e) {
            return sendError("SERVER ERROR, PLEASE CONTACT ADMINISTRATOR", $e->getMessage(), 400);
        }
    }


}
