Skip to content

Commit ff2539b

Browse files
committed
fix unit test & remove double space
1 parent 58d4934 commit ff2539b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

classes/local/question_generator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ public function generate_question(stdClass $dataobject, bool $sendexistingquesti
107107
switch ($dataobject->mode) {
108108
case story_form::QUESTIONGEN_MODE_TOPIC:
109109
$storyprompt =
110-
$modeheader . ' TOPIC\n' .
110+
$modeheader . 'TOPIC\n' .
111111
'Create a question about the following topic. Use your own training data to generate it: "' .
112112
$story . '"';
113113
break;
114114
case story_form::QUESTIONGEN_MODE_STORY:
115115
case story_form::QUESTIONGEN_MODE_COURSECONTENTS:
116116
$storyprompt =
117-
$modeheader . ' COURSE CONTENTS\n' .
117+
$modeheader . 'COURSE CONTENTS\n' .
118118
'Create a question from the following contents. ' .
119119
'Only use this content and do not use any training data: "' .
120120
$story .

tests/local/question_generator_test.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function test_generate_question(): void {
7171
$this->assertEquals($presetjson->primer, $questionobject->primer);
7272
$this->assertEquals($presetjson->instructions, $questionobject->instructions);
7373
$this->assertEquals($presetjson->example, $questionobject->example);
74-
$expectedstoryprompt = 'Create a question about the following topic. Use your own training data to generate it: "' .
74+
$expectedstoryprompt = '\n\n## QUESTION GENERATION MODE - TOPIC\n' .
75+
'Create a question about the following topic. Use your own training data to generate it: "' .
7576
$dataobject->story . '"';
7677
$this->assertEquals($expectedstoryprompt, $questionobject->storyprompt);
7778
$this->assertEmpty($questionobject->questiontextsinqbankprompt);
@@ -110,11 +111,12 @@ public function test_generate_question(): void {
110111
$this->assertEquals($presetjson->primer, $questionobject->primer);
111112
$this->assertEquals($presetjson->instructions, $questionobject->instructions);
112113
$this->assertEquals($presetjson->example, $questionobject->example);
113-
$expectedstoryprompt = 'Create a question about the following topic. Use your own training data to generate it: "' .
114+
$expectedstoryprompt = '\n\n## QUESTION GENERATION MODE - TOPIC\n' .
115+
'Create a question about the following topic. Use your own training data to generate it: "' .
114116
$dataobject->story . '"';
115117
$this->assertEquals($expectedstoryprompt, $questionobject->storyprompt);
116-
$this->assertStringContainsString('The question that will be generated by you has to be different '
117-
. 'from all of the following questions in this JSON string: "', $questionobject->questiontextsinqbankprompt);
118+
$this->assertStringContainsString('The question that will be generated by you has to be different from'
119+
. 'all the questions in this JSON string:\n"', $questionobject->questiontextsinqbankprompt);
118120
$this->assertStringContainsString('Test question 1', $questionobject->questiontextsinqbankprompt);
119121
$this->assertStringContainsString('Write some intelligent stuff', $questionobject->questiontextsinqbankprompt);
120122
$this->assertStringContainsString('Test question 2', $questionobject->questiontextsinqbankprompt);
@@ -133,7 +135,7 @@ public function test_generate_question(): void {
133135
$this->assertEquals($presetjson->primer, $questionobject->primer);
134136
$this->assertEquals($presetjson->instructions, $questionobject->instructions);
135137
$this->assertEquals($presetjson->example, $questionobject->example);
136-
$expectedstoryprompt = 'Create a question from the following contents. '
138+
$expectedstoryprompt = '\n\n## QUESTION GENERATION MODE - COURSE CONTENTS\nCreate a question from the following contents. '
137139
. 'Only use this content and do not use any training data: "' . $dataobject->story . '"';
138140
$this->assertEquals($expectedstoryprompt, $questionobject->storyprompt);
139141
$this->assertEmpty($questionobject->questiontextsinqbankprompt);
@@ -148,7 +150,7 @@ public function test_generate_question(): void {
148150
$this->assertEquals($presetjson->primer, $questionobject->primer);
149151
$this->assertEquals($presetjson->instructions, $questionobject->instructions);
150152
$this->assertEquals($presetjson->example, $questionobject->example);
151-
$expectedstoryprompt = 'Create a question from the following contents. '
153+
$expectedstoryprompt = '\n\n## QUESTION GENERATION MODE - COURSE CONTENTS\nCreate a question from the following contents. '
152154
. 'Only use this content and do not use any training data: "' . $dataobject->story . '"';
153155
$this->assertEquals($expectedstoryprompt, $questionobject->storyprompt);
154156
$this->assertEmpty($questionobject->questiontextsinqbankprompt);

0 commit comments

Comments
 (0)