Skip to content

Commit

Permalink
Merge branch 'main' into batchmode
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Aug 22, 2024
2 parents d3de592 + b5aba4e commit 3d87978
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ jobs:
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
coverage: none

- name: Install NVM and Node
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 20
nvm use 20
- name: Deploy moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
Expand Down
20 changes: 17 additions & 3 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,28 @@ public function grade_response(array $response) {
$fraction = $contentobject->marks / $this->defaultmark;
$grade = [$fraction, question_state::graded_state_for_fraction($fraction)];
}
// The -aicontent data is used in question preview. Only needs to happen in preview.
$this->insert_feedback_and_prompt($fullaiprompt, $contentobject);

return $grade;
}
/**
* Inserts the AI feedback and prompt into the attempt step data.
*
* This method is used to insert the AI generated prompt and feedback
* into the attempt step data, which is used during question preview.
* It also adds the feedback as a comment in HTML format.
*
* @param string $fullaiprompt The full AI-generated prompt.
* @param object $contentobject An object containing the feedback.
* @return void
*/
public function insert_feedback_and_prompt($fullaiprompt, $contentobject): void {
// The -aicontent data is used in question preview. Only needs to happen in preview.
$this->insert_attempt_step_data('-aiprompt', $fullaiprompt);
$this->insert_attempt_step_data('-aicontent', $contentobject->feedback);

$this->insert_attempt_step_data('-comment', $contentobject->feedback);
$this->insert_attempt_step_data('-commentformat', FORMAT_HTML);

return $grade;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Test helpers for the aitext question type.
*
* @package qtype_aitext
* @copyright 2013 The Open University
* @copyright 2024 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand All @@ -27,7 +27,7 @@
/**
* Test helper class for the aitext question type.
*
* @copyright 2013 The Open University
* @copyright 2024 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_aitext_test_helper extends question_test_helper {
Expand Down

0 comments on commit 3d87978

Please sign in to comment.