Make Profile field more visible.

Make Profile field more visible.

by Cindy Weber -
Number of replies: 8

3.11   I added a user profile field. Some students, not all, will need to fill it in with their license number. The category name is visible, but it doesn't stay open so that the students can see where to fill in their license numbers. Part of the problem is the large description box above it, which is not needed at all. 
How do I remove the description box on the profile page without impacting all of the other description boxes in the moodle, and how do I either move the new profile field into general near the top, or at least require the category to keep the choice visible? Profile field not open.

Average of ratings: -
In reply to Cindy Weber

Re: Make Profile field more visible.

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Cindy,

There are no settings for this unless such functionality is a feature available in your theme's settings.

However, it is possible to hide any fields you do not want to display using CSS. To target the description field on specific pages, start your CSS selector with the body id for that page.

Best regards,

Michael
In reply to Michael Milette

Re: Make Profile field more visible.

by Cindy Weber -
Thanks Michael! I was able to simplify the options with CSS using https://moodle.org/mod/forum/discuss.php?d=255399#p1294505 in Boost. The general category stays open, but newly created category stay closed. If I could add my option to the General section and avoid the new category all together, that would help. If the 'Collapse All' box was closer, and not so far to the right, that may help. If I would somehow link to the new box option within the course, and have the students type in their license and have it fill in automatically into the profile, that would be best. My students strugle with computers so simplicity is best.
In reply to Cindy Weber

Re: Make Profile field more visible.

by Cindy Weber -
The element that I would like to keep open is:

<legend class="ftoggler" id="yui_3_17_2_1_1640799357259_122"><a href="#" class="fheader" role="button" aria-controls="id_category_1" aria-expanded="false" id="yui_3_17_2_1_1640799357259_66">License Number</a></legend>

I am assuming that I need to change aria-expanded="false" to aria-expanded="true"
I looked around in theme/image.php and user/edit.php and couldn't come up with anything. I will change the code if I need to, but I would rather add a css fix.

It is a newly added profile field  I am trying to keep to keep open for students to fill in a license number that needs to be included on a certificate.
Profile not open.
In reply to Cindy Weber

Re: Make Profile field more visible.

by Cindy Weber -
Sorry to post again, but Michael - do you know the location of the file that I could change that would keep the boost theme additional profile field 'open' ? I 'inspected' and I searched language files and the Web, but I can't pinpoint it. I want to keep the 'license number' box open.
In reply to Cindy Weber

Re: Make Profile field more visible.

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
You can force the custom profile fields category to be expanded by default on signup page by editing login/signup-form.php

about line 93...
profile_signup_fields($mform);

ADD $mform->setExpanded('category_1');

This only affects Category id1 - this is the profile fields category. If other profile field categories are added, you will need to add to the array if they also require to be expanded by default.
Average of ratings: Useful (1)
In reply to Cindy Weber

Re: Make Profile field more visible.

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Cindy,

No need to apologize or modify any files. You can easily make additional profile field sections open by default by adding the following simple JavaScript to the Site Administration > Appearance > Additional HTML > Before Body is Closed field:

<script>
if (document.getElementById('page-login-signup')) {
   document.getElementById('id_category_1').classList.remove("collapsed");
   document.getElementById('id_category_1').classList.remove("collapsible");
}
</script>

Explanation:

  • The if line just checks to make sure you are on the sign-up page. 
  • The line that ends with "collapsed"); will expand the collapsed section.
  • The line that ends with "collapsible"); will remove the ability for the section to be collapsed again. This is optional but you did request a solution that will keep it open.

If you want to expand this on both the Sign-up page and the Edit Profile page, this can be accomplished with a slight modification to the line starting with if:

<script>
if (document.getElementById('page-login-signup') || document.getElementById('page-user-editadvanced')) {
   document.getElementById('id_category_1').classList.remove("collapsed");
   document.getElementById('id_category_1').classList.remove("collapsible");
}
</script>

If you have more than one section that you want to automatically expand, add more sets of both lines starting with document.getElementByID..., increasing the category number in each additiona set. Example:

<script>
   document.getElementById('id_category_1').classList.remove("collapsed");
   document.getElementById('id_category_1').classList.remove("collapsible");
   document.getElementById('id_category_2').classList.remove("collapsed");
   document.getElementById('id_category_2').classList.remove("collapsible");
</script>

By adding more JavaScript, you could even have it automatically do this for as many sections as there exists however I suspect this might be enough to meet your requirement and it gives you a little more control in case you don't want to expand all additional sections.

I tested this on Moodle 3.9 and 3.11 with the Boost, Classic, Trema, Moove and Adaptable themes and it seems to work. However, you may need to adapt it for other versions of Moodle and other themes.

Hope you find this helpful.

Best regards,

Michael Milette

Average of ratings: Useful (1)
In reply to Michael Milette

Re: Make Profile field more visible.

by Cindy Weber -
Michael and Jon - you are fantastic!
For this task, I used the code to keep the box visible on both the sign-up page and edit profile.

My new profile field is now open and easy to find. Thank you!
Cindy
In reply to Michael Milette

Re: Make Profile field more visible.

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Just noticed that I forgot the "if" statement in my last example. 

It should have been:

<script>
if (document.getElementById('page-login-signup') || document.getElementById('page-user-editadvanced')) {
   document.getElementById('id_category_1').classList.remove("collapsed");
   document.getElementById('id_category_1').classList.remove("collapsible");
   document.getElementById('id_category_2').classList.remove("collapsed");
   document.getElementById('id_category_2').classList.remove("collapsible");
}
</script>

Otherwise it would affect all pages.

Average of ratings: Useful (1)