Skip to content

Commit 16ddc04

Browse files
committed
Version bump
1 parent e14e59a commit 16ddc04

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

amd/src/editformhelper.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
// You should have received a copy of the GNU General Public License
1313
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1414

15-
import {get_strings} from 'core/str';
15+
import {
16+
get_strings
17+
} from 'core/str';
1618
import Ajax from 'core/ajax';
1719
import Log from 'core/log';
1820
import Notify from 'core/notification';
19-
import {exception as displayException} from 'core/notification';
21+
import {
22+
exception as displayException
23+
} from 'core/notification';
2024

2125
/**
2226
* Question AI Text Edit Form Helper
@@ -43,12 +47,17 @@ const Selectors = {
4347
export const init = (contextid) => {
4448

4549
// Set up strings
46-
var strings={};
47-
get_strings([
48-
{ "key": "prompttester", "component": 'qtype_aitext'},
49-
{ "key": "sampleanswerempty", "component": 'qtype_aitext'},
50+
var strings = {};
51+
get_strings([{
52+
"key": "prompttester",
53+
"component": 'qtype_aitext'
54+
},
55+
{
56+
"key": "sampleanswerempty",
57+
"component": 'qtype_aitext'
58+
},
5059

51-
]).done(function (s) {
60+
]).done(function(s) {
5261
var i = 0;
5362
strings.prompttester = s[i++];
5463
strings.sampleanswerempty = s[i++];
@@ -63,13 +72,14 @@ export const init = (contextid) => {
6372
const marksscheme = form.querySelector(Selectors.fields.markscheme);
6473
const defaultmark = form.querySelector(Selectors.fields.defaultmark);
6574

66-
if(sampleanswer.value==="" || aiprompt.value===""){
75+
if (sampleanswer.value === "" || aiprompt.value === "") {
6776
Notify.alert(strings.prompttester, strings.sampleanswerempty);
6877
return;
6978
}
7079

7180
//put spinner in place
72-
sampleanswereval.innerHTML='<i class="icon fa fa-spinner fa-spin fa-2x"></i>';
81+
// This is an alternative https://github.com/moodle/moodle/blob/main/lib/amd/src/loadingicon.js.
82+
sampleanswereval.innerHTML = '<i class="icon fa fa-spinner fa-spin fa-2x"></i>';
7383

7484
Ajax.call([{
7585
methodname: 'qtype_aitext_fetch_ai_grade',
@@ -90,5 +100,5 @@ export const init = (contextid) => {
90100
displayException(error);
91101
sampleanswereval.innerHTML = '';
92102
});
93-
});//end of click
94-
};
103+
}); //end of click
104+
};

question.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,12 @@ public function perform_request(string $prompt, string $purpose = 'feedback'): s
166166
}
167167
return $llmresponse->get_content();
168168
} else if ($backend == 'core_ai_subsystem') {
169-
global $USER;
170-
$manager = new \core_ai\manager();
169+
global $USER,$CFG, $DB;
170+
if(str_starts_with($CFG->release, '5')) {
171+
$manager = new \core_ai\manager($DB);
172+
} else {
173+
$manager = new \core_ai\manager();
174+
}
171175
$action = new \core_ai\aiactions\generate_text(
172176
contextid: $this->contextid,
173177
userid: $USER->id,

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 = 2024051110;
28+
$plugin->version = 2024071892;
2929
$plugin->requires = 2020110900;
3030
$plugin->release = '0.02';
3131
$plugin->maturity = MATURITY_BETA;

0 commit comments

Comments
 (0)