From 2e30eaa7fa0eb259f1463189033d4e91f645d28c Mon Sep 17 00:00:00 2001 From: Artem Baranovskyi Date: Sun, 8 Sep 2024 23:25:25 +0300 Subject: [PATCH] Few Moodle coding style fixes. --- .../db/{QuizQuery.php => quizquery.php} | 2 +- ...yInterface.php => quizquery_interface.php} | 2 +- asystgrade/lib.php | 34 +++++++++---------- asystgrade/tests/quiz_api_test.php | 1 - 4 files changed, 19 insertions(+), 20 deletions(-) rename asystgrade/classes/db/{QuizQuery.php => quizquery.php} (97%) rename asystgrade/classes/db/{QuizQueryInterface.php => quizquery_interface.php} (89%) diff --git a/asystgrade/classes/db/QuizQuery.php b/asystgrade/classes/db/quizquery.php similarity index 97% rename from asystgrade/classes/db/QuizQuery.php rename to asystgrade/classes/db/quizquery.php index 92417b3..4023024 100755 --- a/asystgrade/classes/db/QuizQuery.php +++ b/asystgrade/classes/db/quizquery.php @@ -1,7 +1,7 @@ url->compare(new moodle_url('/mod/quiz/report.php'), URL_MATCH_BASE) && $slot) { - $quizQuery = new QuizQuery(); + $quizQuery = new quizquery(); if ($quizQuery->gradesExist($qid, $slot)) { error_log('Grades already exist in the database.'); @@ -113,12 +113,12 @@ function pasteGradedMarks(array $grades, array $inputNames, float $maxmark): voi /** * Processes question attempts and answers to prepare for API a data to estimate answers * - * @param QuizQuery $database + * @param quizquery $database * @param $question_attempts * @param $referenceAnswer * @return array */ -function prepare_api_data(QuizQuery $database, $question_attempts, $referenceAnswer): array +function prepare_api_data(quizquery $database, $question_attempts, $referenceAnswer): array { $studentData = []; @@ -189,16 +189,16 @@ function generate_script(array $grades, array $inputNames, float $maxmark) { /** * Autoloader registration */ -spl_autoload_register(function ($classname) { - // Check if the class name starts with our plugin's namespace - if (strpos($classname, 'local_asystgrade\\') === 0) { - // Transforming the Namespace into the Path - $classname = str_replace('local_asystgrade\\', '', $classname); - $classname = str_replace('\\', DIRECTORY_SEPARATOR, $classname); - $filepath = __DIR__ . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $classname . '.php'; - - if (file_exists($filepath)) { - require_once($filepath); - } - } -}); +//spl_autoload_register(function ($classname) { +// // Check if the class name starts with our plugin's namespace +// if (strpos($classname, 'local_asystgrade\\') === 0) { +// // Transforming the Namespace into the Path +// $classname = str_replace('local_asystgrade\\', '', $classname); +// $classname = str_replace('\\', DIRECTORY_SEPARATOR, $classname); +// $filepath = __DIR__ . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $classname . '.php'; +// +// if (file_exists($filepath)) { +// require_once($filepath); +// } +// } +//}); diff --git a/asystgrade/tests/quiz_api_test.php b/asystgrade/tests/quiz_api_test.php index 2c6988b..035b9d5 100755 --- a/asystgrade/tests/quiz_api_test.php +++ b/asystgrade/tests/quiz_api_test.php @@ -227,7 +227,6 @@ class quiz_api_test extends advanced_testcase 'referenceAnswer' => $referenceAnswer, 'studentAnswers' => $studentAnswers ]; -// var_dump($data); error_log("Data to send to API: " . print_r($data, true)); $response = $apiClient->send_data($data); -- GitLab