diff --git a/app/Http/Controllers/QuestionController.php b/app/Http/Controllers/QuestionController.php
index 0249404b..29ad8d7e 100644
--- a/app/Http/Controllers/QuestionController.php
+++ b/app/Http/Controllers/QuestionController.php
@@ -1,6 +1,6 @@
user()) {
- $categories = ['History', 'Art', 'Geography', 'Science', 'Sports'];
- $questions = [];
-
- //getting 4 random questions from each category
+{
+ if ($request->user()) {
+ $categories = ['Art', 'History', 'Geography', 'Science', 'Sports'];
+ $questions = [];
+
+ // Check if questions are already in session
+ if ($request->session()->has('quiz_questions')) {
+ $questions = $request->session()->get('quiz_questions');
+ Log::info('Questions retrieved from session:', $questions);
+ } else {
+ // Fetching random questions from each category
foreach ($categories as $cat) {
- $query_questions = Question::inRandomOrder()->where('category', $cat)->limit(4)->get();
+ // Fetch 4 random questions from the category
+ $query_questions = Question::with(['answers', 'category'])
+ ->whereHas('category', function($query) use ($cat) {
+ $query->where('name', $cat);
+ })
+ ->inRandomOrder()
+ ->limit(4)
+ ->get();
+
+ // Add fetched questions to the main questions array
foreach ($query_questions as $qq) {
- array_push($questions, $qq);
+ $questions[] = $qq;
}
+
+ // Log the fetched questions for each category
+ Log::info('Questions fetched from category ' . $cat . ':', $query_questions->toArray());
}
- shuffle($questions);
- } else {
+ // Store questions in the session if found
+ if (!empty($questions)) {
+ $request->session()->put('quiz_questions', $questions);
+ Log::info('Questions stored in session:', $questions);
+ } else {
+ Log::error('No questions found in the database.');
+ }
}
- return view('questions.list');
- }
+ // Check if questions were fetched
+ if (empty($questions)) {
+ return view('quiz')->with('questions', []); // Return empty questions if none found
+ }
+ // Shuffle questions to randomize their order
+ shuffle($questions);
+ // Optionally take only the first 10 questions if needed
+ $questions = array_slice($questions, 0, 10);
+
+ return view('quiz', ['questions' => $questions]);
+ } else {
+ return redirect()->route('login'); // Redirect to login if not authenticated
+ }
+}
public function results(Request $request)
{
- //get quiz from DB
- $quiz = Quiz::where('id', $request->quiz)->get()->first();
- $request = $request->all();
- //makes quiz completed
- $quiz['completed'] = 1;
+ // Fetch the quiz from the database
+ $quiz = Quiz::where('id', $request->quiz)->first();
- $results = array('overall' => 0, 'art' => 0, 'geography' => 0, 'history' => 0, 'science' => 0, 'sports' => 0);
- $xp = 0;
+ // Ensure all questions are answered
+ $questions = $request->session()->get('quiz_questions'); // Retrieve the questions from session
+ $answers = $request->all();
+
+ // Validate that all questions have been answered
+ foreach ($questions as $question) {
+ if (!isset($answers[$question->id])) {
+ return back()->with('error', 'You must answer all questions before submitting.');
+ }
+ }
- //figuring out which answers are correct
- foreach ($request as $key => $value) {
+ // Mark quiz as completed
+ $quiz->completed = 1;
+
+ // Initialize results and XP tracking
+ $results = [
+ 'overall' => 0,
+ 'art' => 0,
+ 'geography' => 0,
+ 'history' => 0,
+ 'science' => 0,
+ 'sports' => 0
+ ];
+ $xp = 0; // Initialize XP variable (if applicable)
+
+ // Determine which answers are correct
+ foreach ($answers as $key => $value) {
if (is_numeric($key)) {
- $correct_answer = Answer::where('question_id', $key)->where('correct', 1)->get()->first()['answer'];
- if ($correct_answer == $value) {
- $question = Question::where('id', $key)->get()->first();
+ $correct_answer = Answer::where('question_id', $key)->where('correct', 1)->first();
+ if ($correct_answer && $correct_answer->answer == $value) { // Check if correct answer exists
+ $question = Question::find($key);
$results['overall']++;
+
+ // Increment the category score
+ $results[strtolower($question->category)]++;
}
}
}
- //adding xp to the
- Auth::user()['xp'] += $xp;
+ // Add XP to user (assuming XP needs to be updated)
+ Auth::user()->xp += $xp;
- //adding categories score to the user
- foreach ($results as $key => $value) {
- if ($key != 'overall') {
- [$correct, $total] = [explode("/", Auth::user()[$key])[0], explode("/", Auth::user()[$key])[1]];
- Auth::user()[$key] = ($correct + $value) . "/" . ($total + 4);
+ // Update user's category-specific score
+ foreach ($results as $category => $value) {
+ if ($category != 'overall') {
+ [$correct, $total] = explode("/", Auth::user()->$category); // Use property access instead of array
+ Auth::user()->$category = ($correct + $value) . "/" . ($total + 2); // 2 questions per category
}
}
- //adding xp to the user
- Auth::user()['xp'] += $xp;
-
- //save changes in DB
+ // Save the updated data
Auth::user()->save();
$quiz->save();
+ // Clear the session questions after quiz completion
+ $request->session()->forget('quiz_questions');
+ // Redirect to results page
return view('questions.results', ['results' => $results]);
}
-}
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/QuizController.php b/app/Http/Controllers/QuizController.php
index 7ed9edf3..bdfd5bfa 100644
--- a/app/Http/Controllers/QuizController.php
+++ b/app/Http/Controllers/QuizController.php
@@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use App\Models\Question; // Ensure this is included
use App\Models\Quiz;
+use App\Http\Controllers\QuestionController;
class QuizController extends Controller
{
@@ -14,102 +15,144 @@ class QuizController extends Controller
*
* @return \Illuminate\Http\Response
*/
- public function index()
+ public function index(Request $request)
{
- // Define the categories you want to include
- $categories = ['Art', 'History', 'Geography', 'Science', 'Sports'];
- $questions = [];
-
- // Fetch 4 random questions from each category
- foreach ($categories as $cat) {
- $query_questions = Question::with(['answers', 'category'])
- ->whereHas('category', function($query) use ($cat) {
- $query->where('name', $cat); // Filter by category name
- })
- ->inRandomOrder()
- ->limit(4)
- ->get();
-
- // Add fetched questions to the main questions array
- foreach ($query_questions as $qq) {
- $questions[] = $qq;
- }
- }
-
- // Shuffle questions to randomize the order
- shuffle($questions);
-
- // Take only the first 10 questions if there are more than 10
- $questions = array_slice($questions, 0, 10);
-
- return view('quiz', compact('questions'));
+ // Use QuestionController to fetch questions
+ $questionController = new QuestionController();
+ return $questionController->index($request);
}
-
- public function submit(Request $request)
- {
- // Validate that the user submitted answers for each question
- $request->validate([
- 'questions' => 'required|array|size:10', // Ensure all questions are answered and there are exactly 10 questions
- 'questions.*' => 'required|array', // Each question must have answers
- 'questions.*.*' => 'integer|exists:answers,id', // Ensure answers are valid
- ]);
- // Initialize variables for results
- $correctAnswersCount = 0;
- $totalXP = 0; // Initialize total XP awarded
- $questionsData = [];// Array to hold questions with user answers and correctness
+ public function submit(Request $request)
+ {
+ // Validate that the user submitted answers for each question
+ $request->validate([
+ 'questions' => 'required|array|size:10', // Ensure all questions are answered
+ 'questions.*' => 'required|integer|exists:answers,id', // Ensure each selected answer is valid
+ ]);
- foreach ($request->input('questions') as $questionId => $selectedAnswers) {
- $question = Question::with('answers')->find($questionId);
- $correctAnswers = $question->answers()->where('is_correct', true)->pluck('id')->toArray();
+ // Initialize variables for results
+ $correctAnswersCount = 0;
+ $totalXP = 0;
+ $questionsData = [];
- // Store question data for display
- $questionsData[$questionId] = [
- 'question' => $question->text,
- 'user_answers' => $selectedAnswers,
- 'correct_answers' => $correctAnswers,
- 'answers' => $question->answers,
- 'is_correct' => count(array_intersect($selectedAnswers, $correctAnswers)) > 0,
- ];
+ foreach ($request->input('questions') as $questionId => $selectedAnswerId) {
+ $question = Question::with('answers')->find($questionId);
+ $correctAnswers = $question->answers()->where('is_correct', true)->pluck('id')->toArray();
- // Count how many selected answers are correct
- $correctAnswersCount += count(array_intersect($selectedAnswers, $correctAnswers));
+ // Check if the selected answer is correct
+ $isCorrect = in_array($selectedAnswerId, $correctAnswers);
- // If the question is answered correctly, add the XP value to the total
- if (count(array_intersect($selectedAnswers, $correctAnswers)) > 0) {
- $totalXP += $question->xp_value; // Add the XP value for the correctly answered question
+ // Store question data for display
+ $questionsData[$questionId] = [
+ 'question' => $question->text,
+ 'user_answer' => $selectedAnswerId,
+ 'correct_answers' => $correctAnswers,
+ 'answers' => $question->answers,
+ 'is_correct' => $isCorrect,
+ ];
+
+ // If correct, increase count and XP
+ if ($isCorrect) {
+ $correctAnswersCount++;
+ $totalXP += $question->xp_value; // Ensure xp_value is a property of the Question model
+ }
}
- }
- // Store quiz results in the database
- Quiz::create([
- 'user_id' => auth()->id(),
- 'total_questions' => count($request->input('questions')),
- 'correct_answers' => $correctAnswersCount,
- 'xp_awarded' => $totalXP, // Store the total XP awarded for this quiz
- ]);
+ // Store quiz results in the database
+ Quiz::create([
+ 'user_id' => auth()->id(),
+ 'total_questions' => count($request->input('questions')),
+ 'correct_answers' => $correctAnswersCount,
+ 'xp_awarded' => $totalXP,
+ ]);
- // Update user's XP
- $user = auth()->user();
- $user->xp += $totalXP;
- $user->save();
+ // Update user's XP
+ $user = auth()->user();
+ $user->xp += $totalXP;
+ $user->save();
- // Set session variables for quiz results
- session()->flash('correct_answers', $correctAnswersCount);
- session()->flash('total_questions', count($request->input('questions')));
- session()->flash('total_xp', $totalXP);
- session(['questions_data' => $questionsData]); // Store questions data in session
+ // Set session variables for quiz results
+ session()->put('correct_answers', $correctAnswersCount);
+ session()->put('total_questions', count($request->input('questions')));
+ session()->put('total_xp', $totalXP);
+ session()->put('questions_data', $questionsData); // Store questions data in session
- return redirect()->route('quiz.results')->with('success', 'Your quiz has been submitted successfully!');
- }
+ return redirect()->route('quiz.results')->with('success', 'Your quiz has been submitted successfully!');
+ }
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
- public function results()
+ public function results(Request $request)
{
- return view('results'); // Adjust this path based on where results.blade.php is located
+ // Fetch the quiz from the database
+ $quiz = Quiz::where('id', $request->quiz)->first();
+
+ // Ensure quiz exists
+ if (!$quiz) {
+ return redirect()->route('quiz.index')->with('error', 'Quiz not found.');
+ }
+
+ // Ensure all questions have been answered
+ $questions = $request->session()->get('quiz_questions'); // Retrieve the questions from session
+ $answers = $request->all();
+
+ // Validate that all questions have been answered
+ foreach ($questions as $question) {
+ if (!isset($answers[$question->id])) {
+ return back()->with('error', 'You must answer all questions before submitting.');
+ }
+ }
+
+ // Mark quiz as completed
+ $quiz->completed = 1;
+
+ // Initialize results and XP tracking
+ $results = [
+ 'overall' => 0,
+ 'art' => 0,
+ 'geography' => 0,
+ 'history' => 0,
+ 'science' => 0,
+ 'sports' => 0
+ ];
+ $xp = 0; // Initialize XP variable
+
+ // Determine which answers are correct
+ foreach ($answers as $key => $value) {
+ if (is_numeric($key)) {
+ $correct_answer = Answer::where('question_id', $key)->where('is_correct', 1)->first();
+ if ($correct_answer && $correct_answer->text == $value) { // Check if correct answer exists
+ $question = Question::find($key);
+ $results['overall']++;
+
+ // Increment the category score
+ $results[strtolower($question->category)]++;
+ }
+ }
+ }
+
+ // Add XP to user
+ Auth::user()->xp += $xp;
+
+ // Update user's category-specific score
+ foreach ($results as $category => $value) {
+ if ($category != 'overall') {
+ [$correct, $total] = explode("/", Auth::user()->$category); // Use property access instead of array
+ Auth::user()->$category = ($correct + $value) . "/" . ($total + 2); // 2 questions per category
+ }
+ }
+
+ // Save the updated data
+ Auth::user()->save();
+ $quiz->save();
+
+ // Clear the session questions after quiz completion
+ $request->session()->forget('quiz_questions');
+
+ // Redirect to results page with the results
+ return view('questions.results', ['results' => $results, 'quiz' => $quiz]);
}
/**
diff --git a/resources/views/quiz.blade.php b/resources/views/quiz.blade.php
index bb8a1fac..1f1ac64e 100644
--- a/resources/views/quiz.blade.php
+++ b/resources/views/quiz.blade.php
@@ -16,6 +16,12 @@
@endif
+ @if (session('error'))
+
+ {{ session('error') }}
+
+ @endif
+
@if ($errors->any())
@endif
-
+
-@endsection
+@endsection
\ No newline at end of file
diff --git a/resources/views/results.blade.php b/resources/views/results.blade.php
index 83311a70..dd614fde 100644
--- a/resources/views/results.blade.php
+++ b/resources/views/results.blade.php
@@ -22,25 +22,20 @@
@foreach (session('questions_data') as $questionId => $data)
{{ $data['question'] }}
-
Your answers:
+
+
Your answer:
@php
- // Determine if the user's answer is correct
+ // Get the user's selected answer
+ $selectedAnswer = $data['answers']->firstWhere('id', $data['user_answer']);
$isAnswerCorrect = $data['is_correct'];
@endphp
- @foreach ($data['user_answers'] as $answerId)
- @php
- // Get the user's answer text
- $selectedAnswer = $data['answers']->firstWhere('id', $answerId);
- @endphp
-
-
- {{ $selectedAnswer->answer_text }} - {{ $isAnswerCorrect ? '✔️ Correct' : '❌ Incorrect' }}
-
- @endforeach
+
+ {{ $selectedAnswer->answer_text }} - {{ $isAnswerCorrect ? '✔️ Correct' : '❌ Incorrect' }}
+
@if (!$isAnswerCorrect)
-
Correct answers:
+
Correct answer(s):
@foreach ($data['correct_answers'] as $correctAnswerId)
@php
// Get the correct answer text
diff --git a/routes/web.php b/routes/web.php
index 24fcaeee..f9dc5705 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -4,7 +4,7 @@
use App\Http\Controllers\Auth\LogoutController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\LeaderboardController;
-use App\Http\Controllers\Questions\QuestionController;
+use App\Http\Controllers\QuestionController;
use App\Http\Controllers\QuizController;
use Illuminate\Support\Facades\Route;
@@ -25,9 +25,10 @@
// Apply the auth middleware here
Route::middleware(['auth'])->group(function () {
- Route::get('/quiz', [QuizController::class, 'index'])->name('quiz');
+ // Route::get('/quiz', [QuizController::class, 'index'])->name('quiz');
Route::post('/quiz/submit', [QuizController::class, 'submit'])->name('quiz.submit');
Route::get('/profile', [ProfileController::class, 'show'])->name('profile');
Route::get('/quiz/results', [QuizController::class, 'results'])->name('quiz.results');
+ Route::get('/quiz', [QuestionController::class, 'index'])->name('quiz');
});
});
diff --git a/vendor/autoload.php b/vendor/autoload.php
index d4c183a8..1cbc5ca5 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -3,8 +3,21 @@
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
- echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
- exit(1);
+ if (!headers_sent()) {
+ header('HTTP/1.1 500 Internal Server Error');
+ }
+ $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
+ if (!ini_get('display_errors')) {
+ if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
+ fwrite(STDERR, $err);
+ } elseif (!headers_sent()) {
+ echo $err;
+ }
+ }
+ trigger_error(
+ $err,
+ E_USER_ERROR
+ );
}
require_once __DIR__ . '/composer/autoload_real.php';
diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php
index afef3fa2..7824d8f7 100644
--- a/vendor/composer/ClassLoader.php
+++ b/vendor/composer/ClassLoader.php
@@ -42,35 +42,37 @@
*/
class ClassLoader
{
- /** @var ?string */
+ /** @var \Closure(string):void */
+ private static $includeFile;
+
+ /** @var string|null */
private $vendorDir;
// PSR-4
/**
- * @var array[]
- * @psalm-var array
>
+ * @var array>
*/
private $prefixLengthsPsr4 = array();
/**
- * @var array[]
- * @psalm-var array>
+ * @var array>
*/
private $prefixDirsPsr4 = array();
/**
- * @var array[]
- * @psalm-var array
+ * @var list
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
- * @var array[]
- * @psalm-var array>
+ * List of PSR-0 prefixes
+ *
+ * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
+ *
+ * @var array>>
*/
private $prefixesPsr0 = array();
/**
- * @var array[]
- * @psalm-var array
+ * @var list
*/
private $fallbackDirsPsr0 = array();
@@ -78,8 +80,7 @@ class ClassLoader
private $useIncludePath = false;
/**
- * @var string[]
- * @psalm-var array
+ * @var array
*/
private $classMap = array();
@@ -87,29 +88,29 @@ class ClassLoader
private $classMapAuthoritative = false;
/**
- * @var bool[]
- * @psalm-var array
+ * @var array
*/
private $missingClasses = array();
- /** @var ?string */
+ /** @var string|null */
private $apcuPrefix;
/**
- * @var self[]
+ * @var array
*/
private static $registeredLoaders = array();
/**
- * @param ?string $vendorDir
+ * @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
+ self::initializeIncludeClosure();
}
/**
- * @return string[]
+ * @return array>
*/
public function getPrefixes()
{
@@ -121,8 +122,7 @@ public function getPrefixes()
}
/**
- * @return array[]
- * @psalm-return array>
+ * @return array>
*/
public function getPrefixesPsr4()
{
@@ -130,8 +130,7 @@ public function getPrefixesPsr4()
}
/**
- * @return array[]
- * @psalm-return array
+ * @return list
*/
public function getFallbackDirs()
{
@@ -139,8 +138,7 @@ public function getFallbackDirs()
}
/**
- * @return array[]
- * @psalm-return array
+ * @return list
*/
public function getFallbackDirsPsr4()
{
@@ -148,8 +146,7 @@ public function getFallbackDirsPsr4()
}
/**
- * @return string[] Array of classname => path
- * @psalm-return array
+ * @return array Array of classname => path
*/
public function getClassMap()
{
@@ -157,8 +154,7 @@ public function getClassMap()
}
/**
- * @param string[] $classMap Class to filename map
- * @psalm-param array $classMap
+ * @param array $classMap Class to filename map
*
* @return void
*/
@@ -175,24 +171,25 @@ public function addClassMap(array $classMap)
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
- * @param string $prefix The prefix
- * @param string[]|string $paths The PSR-0 root directories
- * @param bool $prepend Whether to prepend the directories
+ * @param string $prefix The prefix
+ * @param list|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
+ $paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
- (array) $paths,
+ $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
- (array) $paths
+ $paths
);
}
@@ -201,19 +198,19 @@ public function add($prefix, $paths, $prepend = false)
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
- $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+ $this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
- (array) $paths,
+ $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
- (array) $paths
+ $paths
);
}
}
@@ -222,9 +219,9 @@ public function add($prefix, $paths, $prepend = false)
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
- * @param string $prefix The prefix/namespace, with trailing '\\'
- * @param string[]|string $paths The PSR-4 base directories
- * @param bool $prepend Whether to prepend the directories
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param list|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
@@ -232,17 +229,18 @@ public function add($prefix, $paths, $prepend = false)
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
+ $paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
- (array) $paths,
+ $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
- (array) $paths
+ $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@@ -252,18 +250,18 @@ public function addPsr4($prefix, $paths, $prepend = false)
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ $this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
- (array) $paths,
+ $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
- (array) $paths
+ $paths
);
}
}
@@ -272,8 +270,8 @@ public function addPsr4($prefix, $paths, $prepend = false)
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
- * @param string $prefix The prefix
- * @param string[]|string $paths The PSR-0 base directories
+ * @param string $prefix The prefix
+ * @param list|string $paths The PSR-0 base directories
*
* @return void
*/
@@ -290,8 +288,8 @@ public function set($prefix, $paths)
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
- * @param string $prefix The prefix/namespace, with trailing '\\'
- * @param string[]|string $paths The PSR-4 base directories
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param list|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
@@ -425,7 +423,8 @@ public function unregister()
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
- includeFile($file);
+ $includeFile = self::$includeFile;
+ $includeFile($file);
return true;
}
@@ -476,9 +475,9 @@ public function findFile($class)
}
/**
- * Returns the currently registered loaders indexed by their corresponding vendor directories.
+ * Returns the currently registered loaders keyed by their corresponding vendor directories.
*
- * @return self[]
+ * @return array
*/
public static function getRegisteredLoaders()
{
@@ -555,18 +554,26 @@ private function findFileWithExtension($class, $ext)
return false;
}
-}
-/**
- * Scope isolated include.
- *
- * Prevents access to $this/self from included files.
- *
- * @param string $file
- * @return void
- * @private
- */
-function includeFile($file)
-{
- include $file;
+ /**
+ * @return void
+ */
+ private static function initializeIncludeClosure()
+ {
+ if (self::$includeFile !== null) {
+ return;
+ }
+
+ /**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ *
+ * @param string $file
+ * @return void
+ */
+ self::$includeFile = \Closure::bind(static function($file) {
+ include $file;
+ }, null, null);
+ }
}
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
index 2f88cad8..6b54dcb3 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -14,10 +14,11 @@
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\LeaderboardController' => $baseDir . '/app/Http/Controllers/LeaderboardController.php',
'App\\Http\\Controllers\\ProfileController' => $baseDir . '/app/Http/Controllers/ProfileController.php',
- 'App\\Http\\Controllers\\Questions\\QuestionController' => $baseDir . '/app/Http/Controllers/Questions/QuestionController.php',
'App\\Http\\Controllers\\QuizController' => $baseDir . '/app/Http/Controllers/QuizController.php',
+ 'App\\Http\\Controllers\\UserController' => $baseDir . '/app/Http/Controllers/UserController.php',
'App\\Http\\Kernel' => $baseDir . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\Authenticate' => $baseDir . '/app/Http/Middleware/Authenticate.php',
+ 'App\\Http\\Middleware\\CheckUserLoggedIn' => $baseDir . '/app/Http/Middleware/CheckUserLoggedIn.php',
'App\\Http\\Middleware\\EncryptCookies' => $baseDir . '/app/Http/Middleware/EncryptCookies.php',
'App\\Http\\Middleware\\PreventRequestsDuringMaintenance' => $baseDir . '/app/Http/Middleware/PreventRequestsDuringMaintenance.php',
'App\\Http\\Middleware\\RedirectIfAuthenticated' => $baseDir . '/app/Http/Middleware/RedirectIfAuthenticated.php',
@@ -150,7 +151,14 @@
'Cron\\MinutesField' => $vendorDir . '/dragonmantank/cron-expression/src/Cron/MinutesField.php',
'Cron\\MonthField' => $vendorDir . '/dragonmantank/cron-expression/src/Cron/MonthField.php',
'Database\\Factories\\UserFactory' => $baseDir . '/database/factories/UserFactory.php',
+ 'Database\\Seeders\\AnswerSeeder' => $baseDir . '/database/seeders/AnswerSeeder.php',
+ 'Database\\Seeders\\CategoryScoreSeeder' => $baseDir . '/database/seeders/CategoryScoreSeeder.php',
+ 'Database\\Seeders\\CategorySeeder' => $baseDir . '/database/seeders/CategorySeeder.php',
'Database\\Seeders\\DatabaseSeeder' => $baseDir . '/database/seeders/DatabaseSeeder.php',
+ 'Database\\Seeders\\QuestionSeeder' => $baseDir . '/database/seeders/QuestionSeeder.php',
+ 'Database\\Seeders\\QuizDetailSeeder' => $baseDir . '/database/seeders/QuizDetailSeeder.php',
+ 'Database\\Seeders\\QuizSeeder' => $baseDir . '/database/seeders/QuizSeeder.php',
+ 'Database\\Seeders\\UserSeeder' => $baseDir . '/database/seeders/UserSeeder.php',
'DeepCopy\\DeepCopy' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/DeepCopy.php',
'DeepCopy\\Exception\\CloneException' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Exception/CloneException.php',
'DeepCopy\\Exception\\PropertyException' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/Exception/PropertyException.php',
diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php
index c88abbbf..4730fb07 100644
--- a/vendor/composer/autoload_psr4.php
+++ b/vendor/composer/autoload_psr4.php
@@ -7,7 +7,7 @@
return array(
'voku\\' => array($vendorDir . '/voku/portable-ascii/src/voku'),
- 'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/type-resolver/src', $vendorDir . '/phpdocumentor/reflection-docblock/src'),
+ 'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
'Whoops\\' => array($vendorDir . '/filp/whoops/src/Whoops'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'TijsVerkoyen\\CssToInlineStyles\\' => array($vendorDir . '/tijsverkoyen/css-to-inline-styles/src'),
@@ -42,7 +42,7 @@
'Psy\\' => array($vendorDir . '/psy/psysh/src'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
- 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
+ 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 46d8f7db..7ab4ad64 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -33,25 +33,18 @@ public static function getLoader()
$loader->register(true);
- $includeFiles = \Composer\Autoload\ComposerStaticInit558acd034f111c3d81d43ef348409148::$files;
- foreach ($includeFiles as $fileIdentifier => $file) {
- composerRequire558acd034f111c3d81d43ef348409148($fileIdentifier, $file);
+ $filesToLoad = \Composer\Autoload\ComposerStaticInit558acd034f111c3d81d43ef348409148::$files;
+ $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
+
+ require $file;
+ }
+ }, null, null);
+ foreach ($filesToLoad as $fileIdentifier => $file) {
+ $requireFile($fileIdentifier, $file);
}
return $loader;
}
}
-
-/**
- * @param string $fileIdentifier
- * @param string $file
- * @return void
- */
-function composerRequire558acd034f111c3d81d43ef348409148($fileIdentifier, $file)
-{
- if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
- $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
-
- require $file;
- }
-}
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 314047d7..0dfa29b5 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -190,8 +190,8 @@ class ComposerStaticInit558acd034f111c3d81d43ef348409148
'phpDocumentor\\Reflection\\' =>
array (
0 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src',
- 1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
- 2 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
+ 1 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
+ 2 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
),
'Whoops\\' =>
array (
@@ -331,8 +331,8 @@ class ComposerStaticInit558acd034f111c3d81d43ef348409148
),
'Psr\\Http\\Message\\' =>
array (
- 0 => __DIR__ . '/..' . '/psr/http-message/src',
- 1 => __DIR__ . '/..' . '/psr/http-factory/src',
+ 0 => __DIR__ . '/..' . '/psr/http-factory/src',
+ 1 => __DIR__ . '/..' . '/psr/http-message/src',
),
'Psr\\Http\\Client\\' =>
array (
@@ -538,10 +538,11 @@ class ComposerStaticInit558acd034f111c3d81d43ef348409148
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\LeaderboardController' => __DIR__ . '/../..' . '/app/Http/Controllers/LeaderboardController.php',
'App\\Http\\Controllers\\ProfileController' => __DIR__ . '/../..' . '/app/Http/Controllers/ProfileController.php',
- 'App\\Http\\Controllers\\Questions\\QuestionController' => __DIR__ . '/../..' . '/app/Http/Controllers/Questions/QuestionController.php',
'App\\Http\\Controllers\\QuizController' => __DIR__ . '/../..' . '/app/Http/Controllers/QuizController.php',
+ 'App\\Http\\Controllers\\UserController' => __DIR__ . '/../..' . '/app/Http/Controllers/UserController.php',
'App\\Http\\Kernel' => __DIR__ . '/../..' . '/app/Http/Kernel.php',
'App\\Http\\Middleware\\Authenticate' => __DIR__ . '/../..' . '/app/Http/Middleware/Authenticate.php',
+ 'App\\Http\\Middleware\\CheckUserLoggedIn' => __DIR__ . '/../..' . '/app/Http/Middleware/CheckUserLoggedIn.php',
'App\\Http\\Middleware\\EncryptCookies' => __DIR__ . '/../..' . '/app/Http/Middleware/EncryptCookies.php',
'App\\Http\\Middleware\\PreventRequestsDuringMaintenance' => __DIR__ . '/../..' . '/app/Http/Middleware/PreventRequestsDuringMaintenance.php',
'App\\Http\\Middleware\\RedirectIfAuthenticated' => __DIR__ . '/../..' . '/app/Http/Middleware/RedirectIfAuthenticated.php',
@@ -674,7 +675,14 @@ class ComposerStaticInit558acd034f111c3d81d43ef348409148
'Cron\\MinutesField' => __DIR__ . '/..' . '/dragonmantank/cron-expression/src/Cron/MinutesField.php',
'Cron\\MonthField' => __DIR__ . '/..' . '/dragonmantank/cron-expression/src/Cron/MonthField.php',
'Database\\Factories\\UserFactory' => __DIR__ . '/../..' . '/database/factories/UserFactory.php',
+ 'Database\\Seeders\\AnswerSeeder' => __DIR__ . '/../..' . '/database/seeders/AnswerSeeder.php',
+ 'Database\\Seeders\\CategoryScoreSeeder' => __DIR__ . '/../..' . '/database/seeders/CategoryScoreSeeder.php',
+ 'Database\\Seeders\\CategorySeeder' => __DIR__ . '/../..' . '/database/seeders/CategorySeeder.php',
'Database\\Seeders\\DatabaseSeeder' => __DIR__ . '/../..' . '/database/seeders/DatabaseSeeder.php',
+ 'Database\\Seeders\\QuestionSeeder' => __DIR__ . '/../..' . '/database/seeders/QuestionSeeder.php',
+ 'Database\\Seeders\\QuizDetailSeeder' => __DIR__ . '/../..' . '/database/seeders/QuizDetailSeeder.php',
+ 'Database\\Seeders\\QuizSeeder' => __DIR__ . '/../..' . '/database/seeders/QuizSeeder.php',
+ 'Database\\Seeders\\UserSeeder' => __DIR__ . '/../..' . '/database/seeders/UserSeeder.php',
'DeepCopy\\DeepCopy' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/DeepCopy.php',
'DeepCopy\\Exception\\CloneException' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Exception/CloneException.php',
'DeepCopy\\Exception\\PropertyException' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/Exception/PropertyException.php',