Skip to content

Commit 619eec5

Browse files
committed
Update question_test.php
Clean up the test_build_full_ai_prompt unit test
1 parent d11a4fd commit 619eec5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tests/question_test.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,30 @@ public function test_perform_request(): void {
8787
$this->assertEquals('8', $response);
8888
}
8989
/**
90-
* Check the student response gets interprolated into the prompt ready to send
90+
* Check the student response gets interpolated into the prompt ready to send
9191
* off to the LLM
9292
* @covers \qtype_aitext\question::build_full_ai_prompt
9393
*/
9494
public function test_build_full_ai_prompt() {
9595
$this->resetAfterTest(true);
9696
$question = qtype_aitext_test_helper::make_aitext_question([]);
97-
$question->questiontext = 'What is 2 * 4?';
98-
$aiprompt = "Is the a correct response to the question 'What is 2 * 4?";
97+
$question->questiontext = 'Write an English sentence in the past tense';
98+
$aiprompt = "Is the text gramatically correct?";
99+
$markscheme = 'One mark if the response is gramatically correct';
100+
$studentresponse = 'Yesterday I went to the park';
99101
$defaultmark = 1;
100-
$markscheme = 'Give one mark if the response is 8';
101-
$studentresponse = 'It is 8';
102+
102103
$result = (string) $question->build_full_ai_prompt($studentresponse, $aiprompt, $defaultmark, $markscheme);
104+
105+
// Student response is within [ ] delimters. Angle brackets might be better, e.g. <<<< >>>>.
103106
$pattern = '/\[\[' . $studentresponse . '\]\]/';
104107
$this->assertEquals(1, preg_match($pattern, $result));
108+
109+
// HTML tags should be stripped out, though that might change in the future.
110+
$this->assertStringNotContainsString('<p>', $result);
111+
112+
// Marks scheme should be in result ready to send to LLm. Though it is optional.
113+
$this->assertStringContainsString($markscheme, $result);
105114
}
106115

107116
/**

0 commit comments

Comments
 (0)