Skip to content

Commit 213bc6e

Browse files
committed
Add delete buttons
1 parent a3ecbc5 commit 213bc6e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

edit_aitext_form.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ protected function definition_inner($mform) {
8686
, ['rows' => 10], $this->editoroptions);
8787
$mform->addElement('html', '</div>');
8888

89+
/** Add repeated sample answer options along with the field for returned responses */
8990
$mform->addElement('header', 'prompttester', get_string('prompttester', 'qtype_aitext'));
9091

9192
$answeroptions = ['maxlen' => 50, 'rows' => 6, 'size' => 30];
@@ -95,6 +96,7 @@ protected function definition_inner($mform) {
9596
$mform->createElement('textarea', 'sampleanswers', get_string('sampleanswer', 'qtype_aitext'), $answeroptions),
9697
$mform->createElement('textarea', 'sampleanswereval', get_string('sampleanswereval', 'qtype_aitext'), $evaloptions),
9798
$mform->createelement('button', 'sampleanswerbtn', get_string('sampleanswerevaluate', 'qtype_aitext')),
99+
$mform->createElement('submit', 'deletesample', 'Delete sample'),
98100
$mform->createElement('html', '<hr/>'),
99101
];
100102

@@ -165,10 +167,12 @@ protected function definition_inner($mform) {
165167
protected function get_sample_count() {
166168
if (isset($this->question->id)) {
167169
if(isset($this->question->options->sampleanswers)) {
168-
return count($this->question->options->sampleanswers);
170+
if($this->question->options->sampleanswer > 0) {
171+
return count($this->question->options->sampleanswers);
172+
}
169173
}
170174
}
171-
return 0;
175+
return 1;
172176
}
173177

174178
/**
@@ -195,6 +199,7 @@ protected function data_preprocessing($question) {
195199
$question->spellcheck = $question->options->spellcheck;
196200
// Make the count start from 0 like the repeat array elements.
197201
$question->sampleanswers = [];
202+
xdebug_break();
198203
foreach($question->options->sampleanswers as $sampleanswer) {
199204
$question->sampleanswers[] = $sampleanswer->response;
200205
}

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'qtype_aitext';
28-
$plugin->version = 2024071895;
28+
$plugin->version = 2024111900;
2929
$plugin->requires = 2020110900;
3030
$plugin->release = '0.02';
3131
$plugin->maturity = MATURITY_BETA;

0 commit comments

Comments
 (0)