Skip to content

Commit

Permalink
First code for batchmode (grade on the cron)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Aug 13, 2024
1 parent bea6124 commit d3de592
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
13 changes: 12 additions & 1 deletion question.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,22 @@ public function apply_attempt_state(question_attempt_step $step) {
* @param array $response
* @return void
*/
public function grade_response(array $response): array {
public function grade_response(array $response) {
global $DB;
if (!$this->is_complete_response($response)) {
$grade = [0 => 0, question_state::$needsgrading];
return $grade;
}

if (get_config('qtype_aitext', 'batchmode')) {
$fullaiprompt = $this->build_full_ai_prompt($response['answer'], $this->aiprompt,
$this->defaultmark, $this->markscheme);

$DB->insert_record('tool_aiconnect_queue', ['prompttext' => $fullaiprompt, 'timecreated' => time()]);
$grade = [0 => 0, question_state::$needsgrading];
return $grade;

}
$ai = new ai\ai($this->model);
if (is_array($response)) {
$fullaiprompt = $this->build_full_ai_prompt($response['answer'], $this->aiprompt,
Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ protected function prepare_response($name, question_attempt $qa,
* @return void
*/
protected function prepare_response_for_editing($name,
question_attempt_step $step, $context) {
question_attempt_step $step, $context): array {
return $step->prepare_response_files_draft_itemid_with_text(
$name, $context->id, $step->get_qt_var($name));
}
Expand Down
7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,12 @@
0, ['plain' => 'plain', 'editor' => 'editor', 'monospaced' => 'monospaced']
));

$settings->add(new admin_setting_configcheckbox(
'qtype_aitext/batchmode',
new lang_string('batchmode', 'qtype_aitext'),
new lang_string('batchmode_setting', 'qtype_aitext'),
0
));

}

2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'qtype_aitext';
$plugin->version = 2024051100;
$plugin->version = 2024051101;
$plugin->requires = 2020110900;
$plugin->release = '0.01';
$plugin->maturity = MATURITY_BETA;
Expand Down

0 comments on commit d3de592

Please sign in to comment.