diff --git a/classes/external.php b/classes/external.php index a8a4ddf..e1b110e 100644 --- a/classes/external.php +++ b/classes/external.php @@ -41,13 +41,13 @@ class qtype_aitext_external extends external_api { * * @return void */ - public static function fetch_ai_grade_parameters() { + public static function fetch_ai_grade_parameters(): external_function_parameters { return new external_function_parameters( - array('response' => new external_value(PARAM_TEXT, 'The students response to question'), + ['response' => new external_value(PARAM_TEXT, 'The students response to question'), 'defaultmark' => new external_value(PARAM_INT, 'The total possible score'), 'prompt' => new external_value(PARAM_TEXT, 'The AI Prompt'), 'marksscheme' => new external_value(PARAM_TEXT, 'The marks scheme') - ) + ] ); } @@ -62,6 +62,8 @@ public static function fetch_ai_grade_parameters() { */ public static function fetch_ai_grade($response, $defaultmark, $prompt, $marksscheme) { // Get our AI helper. + xdebug_break(); + $ai = new ai\ai(); // Build an aitext question instance so we can call the same code that the question type uses when it grades. @@ -69,7 +71,6 @@ public static function fetch_ai_grade($response, $defaultmark, $prompt, $markssc \question_bank::load_question_definition_classes($type); $aiquestion = new qtype_aitext_question(); $aiquestion->qtype = \question_bank::get_qtype('aitext'); - // Make sure we have the right data for AI to work with. if (!empty($response) && !empty($prompt) && $defaultmark > 0) { $fullaiprompt = $aiquestion->build_full_ai_prompt($response, $prompt, $defaultmark, $marksscheme); @@ -90,9 +91,9 @@ public static function fetch_ai_grade($response, $defaultmark, $prompt, $markssc * * @return void */ - public static function fetch_ai_grade_returns() { + public static function fetch_ai_grade_returns(): external_single_structure { return new external_single_structure([ - 'feedback' => new external_value(PARAM_TEXT, 'text feedback for display to student', VALUE_DEFAULT), + 'feedback' => new external_value(PARAM_CLEANHTML, 'text feedback for display to student', VALUE_DEFAULT), 'marks' => new external_value(PARAM_FLOAT, 'AI grader awarded marks for student response', VALUE_DEFAULT), ]);