Commit ea3295d3 authored by Kaif Siddique's avatar Kaif Siddique
Browse files

Moodle405 working

parent 139eb260
......@@ -37,6 +37,15 @@ class utils {
* @throws \dml_exception
*/
public static function get_api_endpoint(): string {
return get_config('local_asystgrade', 'apiendpoint') ?? 'http://127.0.0.1:5001/api/autograde';
// $apiendpoint1 = get_config('local_asystgrade', 'apiendpoint') ?? 'http://127.0.0.1:5001/api/autograde';
// error_log("API Endpoint: " . $apiendpoint1);
//return get_config('local_asystgrade', 'apiendpoint') ?? 'http://127.0.0.1:5001/api/autograde';
$apiendpoint = get_config('local_asystgrade', 'apiendpoint');
if (empty($apiendpoint)) { // empty() returns true for empty strings, null, etc.
return 'http://127.0.0.1:5001/api/autograde';
}
return $apiendpoint;
// return 'http://193.196.54.144:5001/api/autograde';
}
}
......@@ -60,7 +60,7 @@ final class quiz_api_test extends advanced_testcase {
$this->resetAfterTest();
parent::setUp();
// Clear quiz-related tables to ensure a clean test environment.
// // // Clear quiz-related tables to ensure a clean test environment.
$DB->execute('TRUNCATE TABLE {quiz_attempts}');
$DB->execute('TRUNCATE TABLE {quiz_slots}');
}
......@@ -263,11 +263,16 @@ final class quiz_api_test extends advanced_testcase {
try {
$apiendpoint = utils::get_api_endpoint();
$httpclient = new http_client();
// // Print the API endpoint and HTTP client details.
//echo "API Endpoint: " . $apiendpoint . "\n";
//echo "HTTP Client: " . print_r($httpclient, true) . "\n";
// echo "Request Data: " . print_r($requestdata, true) . "\n";
$apiclient = client::getInstance($apiendpoint, $httpclient);
$response = $apiclient->send_data($requestdata);
//echo "Response Data: " . print_r($response, true) . "\n";
$grades = json_decode($response, true);
$this->assertNotEmpty($grades, 'API returned empty grades.');
} catch (Exception $e) {
debugging('Error: ' . $e->getMessage());
......
......@@ -24,8 +24,8 @@
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
// defined('MOODLE_INTERNAL') || die();
define('MOODLE_INTERNAL', true);
/**
* Define CLI_SCRIPT to indicate this script is being run from the command line.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment