diff --git a/completion/classes/form/form_trait.php b/completion/classes/form/form_trait.php index 166f010d23c..e539767d74c 100644 --- a/completion/classes/form/form_trait.php +++ b/completion/classes/form/form_trait.php @@ -207,8 +207,9 @@ trait form_trait { $completionexpectedel = 'completionexpected' . $suffix; $mform->addElement('date_time_selector', $completionexpectedel, get_string('completionexpected', 'completion'), ['optional' => true]); - $mform->addHelpButton($completionexpectedel, 'completionexpected', 'completion'); - $mform->hideIf($completionexpectedel, $completionel, 'eq', COMPLETION_TRACKING_NONE); + $a = get_string('pluginname', $modname); + $mform->addHelpButton($completionexpectedel, 'completionexpected', 'completion', '', false, $a); + $mform->hideIf($completionexpectedel, 'completion', 'eq', COMPLETION_TRACKING_NONE); } /** diff --git a/lang/en/completion.php b/lang/en/completion.php index 7242f68a62d..3e8d7bb3b74 100644 --- a/lang/en/completion.php +++ b/lang/en/completion.php @@ -91,8 +91,8 @@ $string['completionactivitydefault'] = 'Use activity default'; $string['completiondefault'] = 'Default completion tracking'; $string['completiondisabled'] = 'Disabled, not shown in activity settings'; $string['completionenabled'] = 'Enabled, control via completion and activity settings'; -$string['completionexpected'] = 'Expect completed on'; -$string['completionexpected_help'] = 'This setting specifies the date when the activity is expected to be completed. When the date is upcoming, the activity is listed in the Timeline block on the Dashboard.'; +$string['completionexpected'] = 'Set reminder in Timeline'; +$string['completionexpected_help'] = 'This allows you to set a reminder for students to work on this activity. It will appear on the Timeline block in their Dashboard as "{$a} requires action"'; $string['completionexpecteddesc'] = 'Completion expected on {$a}'; $string['completionexpectedfor'] = '{$a->instancename} should be completed'; $string['completionicons'] = 'Completion tick boxes'; diff --git a/lib/formslib.php b/lib/formslib.php index bba17179d20..2eb2f78bd0d 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -2354,12 +2354,21 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { * @param string $component component name to look the help string in * @param string $linktext optional text to display next to the icon * @param bool $suppresscheck set to true if the element may not exist + * @param string|object|array|int $a An object, string or number that can be used + * within translation strings */ - function addHelpButton($elementname, $identifier, $component = 'moodle', $linktext = '', $suppresscheck = false) { + public function addHelpButton( + $elementname, + $identifier, + $component = 'moodle', + $linktext = '', + $suppresscheck = false, + $a = null + ) { global $OUTPUT; if (array_key_exists($elementname, $this->_elementIndex)) { $element = $this->_elements[$this->_elementIndex[$elementname]]; - $element->_helpbutton = $OUTPUT->help_icon($identifier, $component, $linktext); + $element->_helpbutton = $OUTPUT->help_icon($identifier, $component, $linktext, $a); } else if (!$suppresscheck) { debugging(get_string('nonexistentformelements', 'form', $elementname)); } diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index a9090f21ab9..73480ad18e2 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -456,6 +456,11 @@ class help_icon implements renderable, templatable { */ public $linktext = null; + /** + * @var mixed An object, string or number that can be used within translation strings + */ + public $a = null; + /** * Constructor * @@ -463,10 +468,13 @@ class help_icon implements renderable, templatable { * string with _help suffix is used for the actual help text. * string with _link suffix is used to create a link to further info (if it exists) * @param string $component + * @param string|object|array|int $a An object, string or number that can be used + * within translation strings */ - public function __construct($identifier, $component) { + public function __construct($identifier, $component, $a = null) { $this->identifier = $identifier; $this->component = $component; + $this->a = $a; } /** @@ -491,7 +499,7 @@ class help_icon implements renderable, templatable { public function export_for_template(renderer_base $output) { global $CFG; - $title = get_string($this->identifier, $this->component); + $title = get_string($this->identifier, $this->component, $this->a); if (empty($this->linktext)) { $alt = get_string('helpprefix2', '', trim($title, ". \t")); @@ -499,7 +507,7 @@ class help_icon implements renderable, templatable { $alt = get_string('helpwiththis'); } - $data = get_formatted_help_string($this->identifier, $this->component, false); + $data = get_formatted_help_string($this->identifier, $this->component, false, $this->a); $data->alt = $alt; $data->icon = (new pix_icon('help', $alt, 'core', ['class' => 'iconhelp']))->export_for_template($output); diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index b1cbf57c290..59bfce5ce7d 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -2521,13 +2521,15 @@ class core_renderer extends renderer_base { * @param string $identifier The keyword that defines a help page * @param string $component component name * @param string|bool $linktext true means use $title as link text, string means link text value + * @param string|object|array|int $a An object, string or number that can be used + * within translation strings * @return string HTML fragment */ - public function help_icon($identifier, $component = 'moodle', $linktext = '') { - $icon = new help_icon($identifier, $component); + public function help_icon($identifier, $component = 'moodle', $linktext = '', $a = null) { + $icon = new help_icon($identifier, $component, $a); $icon->diag_strings(); if ($linktext === true) { - $icon->linktext = get_string($icon->identifier, $icon->component); + $icon->linktext = get_string($icon->identifier, $icon->component, $a); } else if (!empty($linktext)) { $icon->linktext = $linktext; } diff --git a/lib/upgrade.txt b/lib/upgrade.txt index b826aba2190..387c7450711 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -79,6 +79,8 @@ information provided here is intended especially for developers. * The behat step I choose "WHATEVER" in the open action menu is now compatible with action menus subpanels using the ">" symbol to suparate the item link text and subitem one. For example: - I choose "Group mode > Visible groups" in the open action menu +* addHelpButton() function has a new optional $a parameter to allow variables with translation strings. +* help_icon constructor has a new optional $a parameter to allow variables with translation strings. === 4.2 ===