MDL-68843 enrol_lti: add deleted activity warning to published tools
Adds a warning to the 'name' column of the tables, letting teachers know that the activity exposed by the method has been deleted and what their options are.
This commit is contained in:
@@ -92,7 +92,8 @@ class published_resources_table extends \table_sql {
|
||||
* @return string
|
||||
*/
|
||||
public function col_name($tool) {
|
||||
$name = helper::get_name($tool);
|
||||
$toolcontext = \context::instance_by_id($tool->contextid, IGNORE_MISSING);
|
||||
$name = $toolcontext ? helper::get_name($tool) : $this->get_deleted_activity_name_html($tool);
|
||||
|
||||
return $this->get_display_text($tool, $name);
|
||||
}
|
||||
@@ -215,9 +216,39 @@ class published_resources_table extends \table_sql {
|
||||
*/
|
||||
protected function get_display_text($tool, $text) {
|
||||
if ($tool->status != ENROL_INSTANCE_ENABLED) {
|
||||
return \html_writer::tag('span', $text, array('class' => 'dimmed_text'));
|
||||
return \html_writer::tag('div', $text, array('class' => 'dimmed_text'));
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a warning icon, with tooltip, describing enrolment instances sharing activities which have been deleted.
|
||||
*
|
||||
* @param \stdClass $tool the tool instance record.
|
||||
* @return string the HTML for the name column.
|
||||
*/
|
||||
protected function get_deleted_activity_name_html(\stdClass $tool): string {
|
||||
global $OUTPUT;
|
||||
$icon = \html_writer::tag(
|
||||
'a',
|
||||
$OUTPUT->pix_icon('enrolinstancewarning', get_string('deletedactivityalt' , 'enrol_lti'), 'enrol_lti'), [
|
||||
"class" => "btn btn-link p-0",
|
||||
"role" => "button",
|
||||
"data-container" => "body",
|
||||
"data-toggle" => "popover",
|
||||
"data-placement" => right_to_left() ? "left" : "right",
|
||||
"data-content" => get_string('deletedactivitydescription', 'enrol_lti'),
|
||||
"data-html" => "true",
|
||||
"tabindex" => "0",
|
||||
"data-trigger" => "focus"
|
||||
]
|
||||
);
|
||||
$name = \html_writer::span($icon . get_string('deletedactivity', 'enrol_lti'));
|
||||
if ($tool->name) {
|
||||
$name .= \html_writer::empty_tag('br') . \html_writer::empty_tag('br') . $tool->name;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,8 @@ class manage_table extends \table_sql {
|
||||
* @return string
|
||||
*/
|
||||
public function col_name($tool) {
|
||||
$name = helper::get_name($tool);
|
||||
$toolcontext = \context::instance_by_id($tool->contextid, IGNORE_MISSING);
|
||||
$name = $toolcontext ? helper::get_name($tool) : $this->get_deleted_activity_name_html($tool);
|
||||
|
||||
return $this->get_display_text($tool, $name);
|
||||
}
|
||||
@@ -247,9 +248,39 @@ class manage_table extends \table_sql {
|
||||
*/
|
||||
protected function get_display_text($tool, $text) {
|
||||
if ($tool->status != ENROL_INSTANCE_ENABLED) {
|
||||
return \html_writer::tag('span', $text, array('class' => 'dimmed_text'));
|
||||
return \html_writer::tag('div', $text, array('class' => 'dimmed_text'));
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a warning icon, with tooltip, describing enrolment instances sharing activities which have been deleted.
|
||||
*
|
||||
* @param \stdClass $tool the tool instance record.
|
||||
* @return string the HTML for the name column.
|
||||
*/
|
||||
protected function get_deleted_activity_name_html(\stdClass $tool): string {
|
||||
global $OUTPUT;
|
||||
$icon = \html_writer::tag(
|
||||
'a',
|
||||
$OUTPUT->pix_icon('enrolinstancewarning', get_string('deletedactivityalt' , 'enrol_lti'), 'enrol_lti'), [
|
||||
"class" => "btn btn-link p-0",
|
||||
"role" => "button",
|
||||
"data-container" => "body",
|
||||
"data-toggle" => "popover",
|
||||
"data-placement" => right_to_left() ? "left" : "right",
|
||||
"data-content" => get_string('deletedactivitydescription', 'enrol_lti'),
|
||||
"data-html" => "true",
|
||||
"tabindex" => "0",
|
||||
"data-trigger" => "focus"
|
||||
]
|
||||
);
|
||||
$name = \html_writer::span($icon . get_string('deletedactivity', 'enrol_lti'));
|
||||
if ($tool->name) {
|
||||
$name .= \html_writer::empty_tag('br') . \html_writer::empty_tag('br') . $tool->name;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ $string['copytoclipboard'] = 'Copy to clipboard';
|
||||
$string['couldnotestablishproxy'] = 'Could not establish proxy with consumer.';
|
||||
$string['customproperties'] = 'Custom properties';
|
||||
$string['deeplinkingurl'] = 'Deep linking URL';
|
||||
$string['deletedactivity'] = 'Deleted activity';
|
||||
$string['deletedactivityalt'] = 'The activity shared by this instance has been deleted';
|
||||
$string['deletedactivitydescription'] = 'The activity shared by this instance has been deleted. You can select another activity to share by editing the instance or, if no longer required, you can simply delete the instance. Deleting the instance will remove any associated user enrolments.';
|
||||
$string['deploymentadd'] = 'Add a deployment';
|
||||
$string['deploymentaddnotice'] = 'Deployment added';
|
||||
$string['deploymentdelete'] = 'Delete deployment';
|
||||
|
||||
+2
-1
@@ -475,6 +475,7 @@ function enrol_lti_extend_navigation_course($navigation, $course, $context) {
|
||||
function enrol_lti_get_fontawesome_icon_map() {
|
||||
return [
|
||||
'enrol_lti:managedeployments' => 'fa-sitemap',
|
||||
'enrol_lti:platformdetails' => 'fa-pencil-square-o'
|
||||
'enrol_lti:platformdetails' => 'fa-pencil-square-o',
|
||||
'enrol_lti:enrolinstancewarning' => 'fa-exclamation-circle text-danger',
|
||||
];
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 339 B |
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M896 128q209 0 385.5 103t279.5 279.5 103 385.5-103 385.5-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103zm128 1247v-190q0-14-9-23.5t-22-9.5h-192q-13 0-23 10t-10 23v190q0 13 10 23t23 10h192q13 0 22-9.5t9-23.5zm-2-344l18-621q0-12-10-18-10-8-24-8h-220q-14 0-24 8-10 6-10 18l17 621q0 10 10 17.5t24 7.5h185q14 0 23.5-7.5t10.5-17.5z" fill="#999"/></svg>
|
||||
|
After Width: | Height: | Size: 524 B |
Reference in New Issue
Block a user