diff --git a/lib/upgrade.txt b/lib/upgrade.txt index f0ee6e8b0246f..d5b605bcec32f 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -1,6 +1,10 @@ This files describes API changes in core libraries and APIs, information provided here is intended especially for developers. +=== 3.9.4 === +* New optional parameter $extracontent for print_collapsible_region_start(). This allows developers to add interactive HTML elements + (e.g. a help icon) after the collapsible region's toggle link. + === 3.9.3 === * New DML function $DB->delete_records_subquery() to delete records based on a subquery in a way that will work across databases. diff --git a/lib/weblib.php b/lib/weblib.php index c7d3d2b0bb5d9..69ee9f6f63ce2 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2436,9 +2436,11 @@ function print_collapsible_region($contents, $classes, $id, $caption, $userpref * (May be blank if you do not wish the state to be persisted. * @param boolean $default Initial collapsed state to use if the user_preference it not set. * @param boolean $return if true, return the HTML as a string, rather than printing it. + * @param string $extracontent the extra content will show next to caption, eg.Help icon. * @return string|void if $return is false, returns nothing, otherwise returns a string of HTML. */ -function print_collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false, $return = false) { +function print_collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false, $return = false, + $extracontent = null) { global $PAGE; // Work out the initial state. @@ -2458,8 +2460,11 @@ function print_collapsible_region_start($classes, $id, $caption, $userpref = '', $output .= '
'; $output .= '
'; $output .= '
'; - $output .= $caption . ' '; - $output .= '
'; + $output .= $caption . '
'; + if ($extracontent) { + $output .= html_writer::div($extracontent, 'collapsibleregionextracontent'); + } + $output .= '
'; $PAGE->requires->js_init_call('M.util.init_collapsible_region', array($id, $userpref, get_string('clicktohideshow'))); if ($return) { diff --git a/question/preview.php b/question/preview.php index ff2346c5a84fb..0d2e0192e003b 100644 --- a/question/preview.php +++ b/question/preview.php @@ -266,9 +266,8 @@ echo html_writer::end_tag('form'); // Output the technical info. -print_collapsible_region_start('', 'techinfo', get_string('technicalinfo', 'question') . - $OUTPUT->help_icon('technicalinfo', 'question'), - 'core_question_preview_techinfo_collapsed', true); +print_collapsible_region_start('', 'techinfo', get_string('technicalinfo', 'question'), + 'core_question_preview_techinfo_collapsed', true, false, $OUTPUT->help_icon('technicalinfo', 'question')); foreach ($technical as $info) { echo html_writer::tag('p', $info, array('class' => 'notifytiny')); } diff --git a/theme/boost/scss/moodle/question.scss b/theme/boost/scss/moodle/question.scss index 9a38f061cdda4..6c4acf0bd96c6 100644 --- a/theme/boost/scss/moodle/question.scss +++ b/theme/boost/scss/moodle/question.scss @@ -423,6 +423,13 @@ body.jsenabled .questionflag input[type=checkbox] { margin: 1em 0; } +#page-question-preview .collapsibleregion { + .collapsibleregioncaption, + .collapsibleregionextracontent { + display: inline-block; + } +} + // imported from quiz.css #page-mod-quiz-edit ul.slots .activityinstance { diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css index 2593230a2ff15..d06c5395719e7 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -15771,6 +15771,10 @@ body.jsenabled .questionflag input[type=checkbox] { #page-question-preview #techinfo { margin: 1em 0; } +#page-question-preview .collapsibleregion .collapsibleregioncaption, +#page-question-preview .collapsibleregion .collapsibleregionextracontent { + display: inline-block; } + #page-mod-quiz-edit ul.slots .activityinstance > a { display: flex; max-width: 100%; diff --git a/theme/classic/style/moodle.css b/theme/classic/style/moodle.css index 69b032011f8c5..e4b4abc3990e3 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -15993,6 +15993,10 @@ body.jsenabled .questionflag input[type=checkbox] { #page-question-preview #techinfo { margin: 1em 0; } +#page-question-preview .collapsibleregion .collapsibleregioncaption, +#page-question-preview .collapsibleregion .collapsibleregionextracontent { + display: inline-block; } + #page-mod-quiz-edit ul.slots .activityinstance > a { display: flex; max-width: 100%;