Skip to content

Commit

Permalink
Merge pull request #1 from justinhunt/main
Browse files Browse the repository at this point in the history
default AI prompt, default Marks scheme and hints to AI on total possible score. Thanks Justin, excellent contribution.
  • Loading branch information
marcusgreen authored Apr 22, 2024
2 parents c4aee33 + 77d0ea2 commit 48a9424
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions edit_aitext_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ protected function definition_inner($mform) {
$mform->addElement('textarea', 'aiprompt', get_string('aiprompt', 'qtype_aitext'),
['maxlen' => 50, 'rows' => 5, 'size' => 30]);
$mform->setType('aiprompt', PARAM_RAW);
$mform->setDefault('aiprompt', get_config('qtype_aitext', 'defaultprompt'));
$mform->addHelpButton('aiprompt', 'aiprompt', 'qtype_aitext');

$mform->addElement('textarea', 'markscheme', get_string('markscheme', 'qtype_aitext'),
['maxlen' => 50, 'rows' => 6, 'size' => 30]);
$mform->setType('markscheme', PARAM_RAW);
$mform->setDefault('markscheme', get_config('qtype_aitext', 'defaultmarksscheme'));
$mform->addHelpButton('markscheme', 'markscheme', 'qtype_aitext');

$mform->addElement('html', '<div class="hidden">');
Expand Down
10 changes: 8 additions & 2 deletions lang/en/qtype_aitext.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
$string['acceptedfiletypes_help'] = 'Accepted file types can be restricted by entering a list of file extensions. If the field is left empty, then all file types are allowed.';

$string['aiprompt'] = 'AI Prompt';
$string['aiprompt_help'] = 'A prompt for the Large Language model. For marking include "Reply in json format with a response and marks fields"';
$string['aiprompt_help'] = 'A prompt for the Ai Grader. This is the guideline that AI uses to give feedback on the student response.';
$string['answerfiles'] = 'Answer files';
$string['answertext'] = 'Answer text';
$string['attachmentsoptional'] = 'Attachments are optional';
$string['attachmentsrequired'] = 'Require attachments';
$string['cachedef_stringdata'] = 'Cachedef stringdata';
$string['defaultmarksscheme'] = 'Marks scheme';
$string['defaultmarksscheme_setting'] = 'This will be the default marks scheme for new questions. Questions authors should alter this to suit the question.';
$string['thedefaultmarksscheme'] = 'Deduct a point from the total score for each grammar or spelling mistake.';
$string['defaultprompt'] = 'AI Prompt';
$string['defaultprompt_setting'] = 'This will be the default AI prompt for new questions. It tells the AI grader how to analyse the student response. It is the guideline that AI uses to give feedback on the student response. Question authors should alter this to suit the question.';
$string['thedefaultprompt'] = 'Explain if there is anything wrong with the grammar and spelling in the text.';
$string['disclaimer'] = 'Disclaimer';
$string['disclaimer_setting'] = 'Text appended to each response indicating feedback is from a Large Language Model and not a human';
$string['attachmentsrequired_help'] = 'This option specifies the minimum number of attachments required for a response to be considered gradable.';
Expand All @@ -50,7 +56,7 @@
$string['get_llmmfeedback'] = 'Get LLM feedback';
$string['graderinfoheader'] = 'Grader information';
$string['markscheme'] = 'Mark scheme';
$string['markscheme_help'] = 'Mark scheme help';
$string['markscheme_help'] = 'This will tell the AI grader how to give a numerical grade to the student response. The total possible score is this question\'s \'Default mark\'';
$string['maxwordlimit'] = 'Maximum word limit';
$string['maxwordlimit_help'] = 'If the response requires that students enter text, this is the maximum number of words that each student will be allowed to submit.';
$string['maxwordlimitboundary'] = 'The word limit for this question is {$a->limit} words and you are attempting to submit {$a->count} words. Please shorten your response and try again.';
Expand Down
2 changes: 2 additions & 0 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function grade_response(array $response) : array {
$prompt .= $this->aiprompt;

if ($this->markscheme > '') {
//Tell the LLM how to mark the submission
$prompt .= " The total score is: $this->defaultmark .";
$prompt .= ' '.$this->markscheme;
} else {
$prompt .= ' Set marks to null in the json object.'.PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function formulation_and_controls(question_attempt $qa,
}

$files = '';
if ($question->attachments) {
if (isset($question->attachments) && $question->attachments) {
if (empty($options->readonly)) {
$files = $this->files_input($qa, $question->attachments, $options);

Expand Down
10 changes: 10 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,15 @@
new lang_string('disclaimer', 'qtype_aitext'),
new lang_string('disclaimer_setting', 'qtype_aitext'),
"(Response provided by ChatGPT)"));

$settings->add(new admin_setting_configtextarea('qtype_aitext/defaultprompt',
new lang_string('defaultprompt', 'qtype_aitext'),
new lang_string('defaultprompt_setting', 'qtype_aitext'),
new lang_string('thedefaultprompt', 'qtype_aitext')));

$settings->add(new admin_setting_configtextarea('qtype_aitext/defaultmarksscheme',
new lang_string('defaultmarksscheme', 'qtype_aitext'),
new lang_string('defaultmarksscheme_setting', 'qtype_aitext'),
new lang_string('thedefaultmarksscheme', 'qtype_aitext')));
}

0 comments on commit 48a9424

Please sign in to comment.