From cb32f175846f8a04a7e8a4b7b644c3b9ec7b2b3a Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 16 Oct 2023 17:21:55 +0100 Subject: [PATCH 1/2] MDL-79705 profilefield_checkbox: display data as simple Yes/No. --- user/profile/field/checkbox/field.class.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/user/profile/field/checkbox/field.class.php b/user/profile/field/checkbox/field.class.php index d6d9943157ccb..a6e0885f8ec26 100644 --- a/user/profile/field/checkbox/field.class.php +++ b/user/profile/field/checkbox/field.class.php @@ -14,17 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Strings for component 'profilefield_checkbox', language 'en', branch 'MOODLE_20_STABLE' - * - * @package profilefield_checkbox - * @copyright 2008 onwards Shane Elliot {@link http://pukunui.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - /** * Class profile_field_checkbox * + * @package profilefield_checkbox * @copyright 2008 onwards Shane Elliot {@link http://pukunui.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -52,10 +45,7 @@ public function edit_field_add($mform) { * @return string HTML. */ public function display_data() { - $options = new stdClass(); - $options->para = false; - $checked = intval($this->data) === 1 ? 'checked="checked"' : ''; - return ''; + return $this->data ? get_string('yes') : get_string('no'); } /** From da6ef4ac1deb704672ad462aae5a2542a196156b Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Mon, 16 Oct 2023 17:22:59 +0100 Subject: [PATCH 2/2] MDL-79705 reportbuilder: remove checkbox field callback handling. We no longer need special handling of this field type, because it now returns language strings rather than HTML markup for a checkbox element on display. --- reportbuilder/classes/local/helpers/user_profile_fields.php | 5 ++--- .../tests/local/helpers/user_profile_fields_test.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/reportbuilder/classes/local/helpers/user_profile_fields.php b/reportbuilder/classes/local/helpers/user_profile_fields.php index 6e5d419fd1dc0..36cb0276b5c5a 100644 --- a/reportbuilder/classes/local/helpers/user_profile_fields.php +++ b/reportbuilder/classes/local/helpers/user_profile_fields.php @@ -180,9 +180,8 @@ public function get_columns(): array { ->set_type($columntype) ->set_is_sortable($columntype !== column::TYPE_LONGTEXT) ->add_callback(static function($value, stdClass $row, profile_field_base $field): string { - // Special handling of checkboxes, we want to display their boolean state rather than the input element itself. - if (is_a($field, 'profile_field_checkbox')) { - return format::boolean_as_text($value); + if ($value === null) { + return ''; } $field->data = $value; diff --git a/reportbuilder/tests/local/helpers/user_profile_fields_test.php b/reportbuilder/tests/local/helpers/user_profile_fields_test.php index 44599cd499c15..c8c35f9e571e6 100644 --- a/reportbuilder/tests/local/helpers/user_profile_fields_test.php +++ b/reportbuilder/tests/local/helpers/user_profile_fields_test.php @@ -240,7 +240,7 @@ public function test_custom_report_content(): void { [ 'c0_firstname' => 'Admin', 'c1_data' => '', - 'c2_data' => 'Not set', + 'c2_data' => '', 'c3_data' => '', 'c4_data' => '', 'c5_data' => '',