Skip to content

Commit db3c4fc

Browse files
committed
If the backend is local_ai_manager and the tenant is not allowed
to use it then do not show the quesiton type as an option when creating a new question.
1 parent 7dfab70 commit db3c4fc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

classes/external.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function fetch_ai_grade_parameters(): external_function_parameters
5757
* Similar to clicking the submit button.
5858
*
5959
* @param string $response
60-
* @param integer $defaultmark
60+
* @param int $defaultmark
6161
* @param string $prompt
6262
* @param string $marksscheme
6363
* @param int $contextid the context id

questiontype.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,20 +381,22 @@ protected function export_errorcmid($cmid) {
381381
return '';
382382
}
383383
/**
384+
* The name this question should appear as in the create new question
385+
* dropdown.
386+
*
384387
* When using local_ai_manager the availability ai
385-
* is controlled by the tenant setting
388+
* is controlled by the tenant setting.
386389
*
387390
* @return mixed
388391
*/
389392
public function menu_name() {
390-
if (class_exists('\local_ai_manager\local\tenant')) {
391-
if (get_config('qtype_aitext', 'backend') === 'local_ai_manager') {
392-
$tenant = \core\di::get(\local_ai_manager\local\tenant::class);
393-
return $tenant->is_tenant_allowed() ? parent::menu_name() : '';
393+
if (get_config('qtype_aitext', 'backend') === 'local_ai_manager' && class_exists('\local_ai_manager\local\tenant')) {
394+
$tenant = \core\di::get(\local_ai_manager\local\tenant::class);
395+
if (!$tenant->is_tenant_allowed()) {
396+
return '';
394397
}
395-
} else {
396-
return parent::menu_name();
397398
}
399+
return parent::menu_name();
398400
}
399401

400402
}

0 commit comments

Comments
 (0)