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' ;
1618import Ajax from 'core/ajax' ;
1719import Log from 'core/log' ;
1820import 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 = {
4347export 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+ } ;
0 commit comments