From 0ab0a293a8996f7833703e27ff3512c04ac55d98 Mon Sep 17 00:00:00 2001 From: sangnguyen2601 Date: Mon, 9 Nov 2020 15:47:14 +0700 Subject: [PATCH] MDL-70094 Question: Technical info section expands if click help icon --- lib/upgrade.txt | 4 ++++ lib/weblib.php | 11 ++++++++--- question/preview.php | 5 ++--- theme/boost/scss/moodle/question.scss | 7 +++++++ theme/boost/style/moodle.css | 4 ++++ theme/classic/style/moodle.css | 4 ++++ 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 60b2b8c2708..77cd8f579c7 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.10.1 === +* 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.10 === * PHPUnit has been upgraded to 8.5. That comes with a few changes: - Breaking change: All the "template methods" (setUp(), tearDown()...) now require to return void. This implies diff --git a/lib/weblib.php b/lib/weblib.php index 42518461eb6..a2ba0c34d91 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2441,9 +2441,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. @@ -2463,8 +2465,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 ff2346c5a84..0d2e0192e00 100644 --- a/question/preview.php +++ b/question/preview.php @@ -266,9 +266,8 @@ echo html_writer::end_tag('div'); 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 06e97bfbffb..ea0931a26b7 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 5379e2f690f..59d3819984c 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -15820,6 +15820,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 5fd375cfde5..56c28d1ad9d 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -16041,6 +16041,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%; -- 2.11.4.GIT