Merge branch 'MDL-87658-main' of https://github.com/aanabit/moodle
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
issueNumber: MDL-87658
|
||||
notes:
|
||||
aiplacement:
|
||||
- message: >-
|
||||
A new page-level property has been added to moodle_page to indicate
|
||||
whether AI-related UI elements are preferred to be shown on a given
|
||||
page. This value acts as an advisory hint only. It does not enforce the
|
||||
visibility of AI-related UI elements globally.
|
||||
type: improved
|
||||
@@ -100,7 +100,10 @@ class assist_ui {
|
||||
if ($PAGE->context->contextlevel != CONTEXT_MODULE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the advisory AI visibility hint on the page.
|
||||
if (!$PAGE->get_ai_visibility_hint()) {
|
||||
return false;
|
||||
}
|
||||
// Check if the user has permission to use the AI service.
|
||||
return utils::is_course_assist_available();
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ class restricted_module {
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_cm($cminfo);
|
||||
$PAGE->set_secondary_navigation(false);
|
||||
$PAGE->set_ai_visibility_hint(false);
|
||||
|
||||
$restrictedclass = $format->get_output_classname('content\\cm\\restricted');
|
||||
$cmoutput = new $restrictedclass(
|
||||
|
||||
@@ -437,6 +437,16 @@ class moodle_page {
|
||||
*/
|
||||
protected bool $_showcourseindex = true;
|
||||
|
||||
/**
|
||||
* Hint indicating whether AI-related UI elements should be shown on this page.
|
||||
*
|
||||
* This value is advisory only. Individual AI placements are responsible
|
||||
* for deciding whether to respect this hint.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $aivisibilityhint = true;
|
||||
|
||||
/**
|
||||
* Force the settings menu to be displayed on this page. This will only force the
|
||||
* settings menu on an activity / resource page that is being displayed on a theme that
|
||||
@@ -2488,4 +2498,32 @@ class moodle_page {
|
||||
public function get_show_course_index(): bool {
|
||||
return $this->_showcourseindex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a hint indicating whether AI-related UI elements should be shown
|
||||
* on this page.
|
||||
*
|
||||
* This hint is not enforced globally and does not guarantee that AI UI
|
||||
* elements will be hidden or shown. Each AI placement must explicitly
|
||||
* check this value.
|
||||
*
|
||||
* @param bool $visible
|
||||
* @return void
|
||||
*/
|
||||
public function set_ai_visibility_hint(bool $visible): void {
|
||||
$this->aivisibilityhint = $visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hint indicating whether AI-related UI elements should be shown
|
||||
* on this page.
|
||||
*
|
||||
* This value does not enforce visibility. AI placements may choose whether
|
||||
* and how to respect this hint.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_ai_visibility_hint(): bool {
|
||||
return $this->aivisibilityhint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,6 +888,47 @@ final class moodle_page_test extends \advanced_testcase {
|
||||
$page->set_show_course_index(false);
|
||||
$this->assertFalse($page->get_show_course_index());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the AI visibility hint defaults to true.
|
||||
*/
|
||||
public function test_ai_visibility_hint_defaults_to_true(): void {
|
||||
$page = new moodle_page();
|
||||
|
||||
$this->assertTrue(
|
||||
$page->get_ai_visibility_hint(),
|
||||
'AI visibility hint should default to true.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the AI visibility hint can be disabled via the setter.
|
||||
*/
|
||||
public function test_ai_visibility_hint_can_be_set_to_false(): void {
|
||||
$page = new moodle_page();
|
||||
|
||||
$page->set_ai_visibility_hint(false);
|
||||
|
||||
$this->assertFalse(
|
||||
$page->get_ai_visibility_hint(),
|
||||
'AI visibility hint should be false after being explicitly disabled.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the AI visibility hint can be re-enabled via the setter.
|
||||
*/
|
||||
public function test_ai_visibility_hint_can_be_set_to_true(): void {
|
||||
$page = new moodle_page();
|
||||
|
||||
$page->set_ai_visibility_hint(false);
|
||||
$page->set_ai_visibility_hint(true);
|
||||
|
||||
$this->assertTrue(
|
||||
$page->get_ai_visibility_hint(),
|
||||
'AI visibility hint should be true after being re-enabled.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user