Skip to content

Commit 5575784

Browse files
committed
Merge branch 'main' into multi_response_test
2 parents 89effaf + dfb249b commit 5575784

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

question.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public function grade_response(array $response): array {
267267
*/
268268
public function build_full_ai_prompt($response, $aiprompt, $defaultmark, $markscheme): string {
269269

270-
// Check if [questiontext] is in the aiprompt and replace it with the question text
270+
// Check if [questiontext] is in the aiprompt and replace it with the question text.
271271
if (strpos($aiprompt, '[questiontext]') !== false) {
272272
$aiprompt = str_replace('[questiontext]', strip_tags($this->questiontext), $aiprompt);
273273
}

tests/question_test.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final class question_test extends \advanced_testcase {
5252
* tests will be skipped
5353
* @var bool
5454
*/
55-
protected int $islive;
55+
protected bool $islive = false;
5656

5757
/**
5858
* Config.php should include the apikey and orgid in the form
@@ -74,6 +74,7 @@ protected function setUp(): void {
7474
* Make a trivial request to the LLM to check the code works
7575
* Only designed to test the 4.5 subsystem when run locally
7676
* not when in GHA ci
77+
*
7778
* @covers \qtype_aitext\question::perform_request
7879
* @return void
7980
*/
@@ -111,6 +112,9 @@ public function test_get_question_summary(): void {
111112
*/
112113
public function test_build_full_ai_prompt(): void {
113114
$this->resetAfterTest();
115+
if (!$this->islive) {
116+
$this->markTestSkipped('No live connection to the AI system');
117+
}
114118

115119
$question = qtype_aitext_test_helper::make_aitext_question([]);
116120
set_config('prompt', 'in [responsetext] ', 'qtype_aitext');
@@ -119,6 +123,9 @@ public function test_build_full_ai_prompt(): void {
119123
set_config('jsonprompt', 'testprompt', 'qtype_aitext');
120124

121125
$response = '<p> Thank you </p>';
126+
$aiprompt = '';
127+
$defaultmark = '';
128+
$markscheme = '';
122129
$result = $question->build_full_ai_prompt($response, $aiprompt, $defaultmark, $markscheme);
123130

124131
$this->assertStringContainsString('[[ Thank you ]]', $result);
@@ -277,4 +284,4 @@ public function test_is_same_response_with_template(): void {
277284
['answer' => '0']));
278285
}
279286

280-
}
287+
}

0 commit comments

Comments
 (0)