diff --git a/js/grade.js b/js/grade.js index 55f525840054ecc9e54606061263c224b5410abe..e56655b28e602dd4fa11d9f4696013f0a6117947 100755 --- a/js/grade.js +++ b/js/grade.js @@ -2,12 +2,6 @@ M.local_asystgrade = { init: function(Y, jsData) { const isDebuggingEnabled = true; // Set this to false in production - function log(message) { - if (isDebuggingEnabled) { - console.log(message); - } - } - window.gradeData = jsData; document.addEventListener('DOMContentLoaded', function() { const apiEndpoint = M.cfg.wwwroot + '/local/asystgrade/api.php'; @@ -30,16 +24,16 @@ M.local_asystgrade = { .then(response => response.json()) .then(data => { if (data.success && data.grades) { - log(data.grades); + console.log(data.grades); updateMarks(data.grades); } else { - error('Error in grade response:', data.error); + console.log('Error in grade response:', data.error); } // Return the data to keep the Promise chain intact return data; }) .catch(error => { - error('Error:', error); + console.log('Error:', error); // Return the error to keep the Promise chain intact throw error; }); @@ -53,7 +47,7 @@ M.local_asystgrade = { if (inputs[index]) { inputs[index].value = predictedGrade; } else { - error(`No grade input found for index: ${index}`); + console.log(`No grade input found for index: ${index}`); } }); } diff --git a/tests/quiz_api_test.php b/tests/quiz_api_test.php index 45134229a65fb37cce812888f2b3a3b56c4579c0..19e7138e15ae586edd69b07909b2e82babdce2a3 100755 --- a/tests/quiz_api_test.php +++ b/tests/quiz_api_test.php @@ -34,7 +34,6 @@ use dml_exception; use Exception; use local_asystgrade\api\client; use local_asystgrade\api\http_client; -use local_asystgrade\utils; defined('MOODLE_INTERNAL') || die(); @@ -46,6 +45,7 @@ require_once($CFG->dirroot . '/mod/quiz/tests/generator/lib.php'); /** * Class quiz_api_test * @package local_asystgrade + * @covers \local_asystgrade */ final class quiz_api_test extends advanced_testcase { @@ -68,6 +68,7 @@ final class quiz_api_test extends advanced_testcase { /** * Tests the quiz API by creating quiz attempts and validating responses. * @throws Exception + * @covers \local_asystgrade */ public function test_quiz_api(): void { global $DB; @@ -152,7 +153,7 @@ final class quiz_api_test extends advanced_testcase { * @throws coding_exception * @throws dml_exception */ - private function create_question_category(int $contextid) { + private function create_question_category(int $contextid): mixed { global $DB; $category = [ @@ -181,7 +182,7 @@ final class quiz_api_test extends advanced_testcase { * @param $context * @return mixed */ - private function create_question($questiongen, $questiondata, $category, $modifiedby, $context) { + private function create_question($questiongen, $questiondata, $category, $modifiedby, $context): mixed { return $questiongen->create_question($questiondata['qtype'], null, [ 'category' => $category->id, 'questiontext' => ['text' => $questiondata['questiontext'], 'format' => FORMAT_HTML], @@ -200,7 +201,7 @@ final class quiz_api_test extends advanced_testcase { * @return void * @throws dml_exception */ - private function add_question_to_quiz($quiz, $question) { + private function add_question_to_quiz($quiz, $question): void { global $DB; $slotdata = [ @@ -228,7 +229,7 @@ final class quiz_api_test extends advanced_testcase { * @return void * @throws dml_exception */ - private function create_quiz_attempt($quizid, $userid, $answer) { + private function create_quiz_attempt($quizid, $userid, $answer): void { global $DB; $uniqueid = $DB->get_field_sql('SELECT COALESCE(MAX(uniqueid), 0) + 1 FROM {quiz_attempts}'); @@ -258,7 +259,7 @@ final class quiz_api_test extends advanced_testcase { * @param $requestdata * @return void */ - private function send_answers_to_api($requestdata) { + private function send_answers_to_api($requestdata): void { try { $apiendpoint = utils::get_api_endpoint(); $httpclient = new http_client();