Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of custom profile field textareas and user description #38

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ There are several options available to the admin from the Roster Report settings

### General

**Profile fields to display:** A newline separated list of profile fields to display. Note that custom profile fields must be entered as `profile_field_{shortname}`. The following special values are also supported:
**Profile fields to display:** A newline separated list of profile fields to display. Note that custom profile fields must be entered as `profile_field_{shortname}`. Currently this functionality supports text and textarea custom profile fields. The following special values are also supported:

* `fullname` - displays fullname according to site settings.
* `currenttime` - displays date/time in user's configured timezone (you can specify PHP strftime style formatting like so: `currenttime %l:%M %p`)
* `currenttime` - displays date/time in user's configured timezone (you can specify PHP strftime style formatting like so: `currenttime %l:%M %p`).
* `description` - description from the user's profile.

**Display name:** The display string used by the Roster Report on the front end. Will appear in the flat navigation (if enabled) and on the Roster Report page.

Expand Down Expand Up @@ -54,5 +55,13 @@ There are several options available when viewing the Roster Report:
**Size** changes the display size of the user images based on levels configured in the admin settings (see above)
**Display mode** which toggles between the regular web view and a version of the report suitable for printing

### Display User Name Pronunciation

Some schools have used the following steps to set up a system to display user-entered name pronunciation data in the Roster report.

1. Give Authenticated users the permission "View user profiles" (moodle/user:viewdetails).
2. Add "description" to the "Profile fields to display" setting in the Roster report settings page.
3. Instruct users to enter their name pronunciation into their profile description via RecordRTC. Instruct them not to enter any additional text, as this will also be displayed in the Roster report and throw off the layout. Safety rails for this feature will be forthcoming in a future release.

## Author
Charles Fulton (fultonc@lafayette.edu)
2 changes: 1 addition & 1 deletion lang/en/report_roster.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
$string['settings:flatnav_position:description'] = 'A link to the report will be added *above* the link at the top of this list.
If not found, it will try the next in the list, and so on. The first word on each line is the link identifier; everything afterward
is ignored (so that the identifiers can be labelled). The main course navigation nodes are included by default; the identifiers for
additional nodes can be obtained by looking at the `data-key` property of the relevant `<a>`.';
additional nodes can be obtained by looking at the "data-key" property of the relevant "<a>".';
$string['settings:flatnav_position:default'] = "
badgesview (Badges)
competencies (Competencies)
Expand Down
20 changes: 17 additions & 3 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,22 @@ function report_roster_process_field($field, $user) {
} else if (strpos($field, 'currenttime') === 0) {
$format = trim(str_replace('currenttime', '', $field));
return userdate(time(), $format, $user->timezone);
} else if (property_exists($user, $field) && !empty($user->{$field}) && is_string($user->{$field})) {
return $user->{$field};
} else if (property_exists($user, $field) && !empty($user->{$field})) {
if (is_string($user->{$field})) {
$output = $user->{$field};
$format = FORMAT_HTML;
} else if (is_array($user->{$field})
&& array_key_exists('text', $user->{$field})
&& array_key_exists('format', $user->{$field})
) {
$output = $user->{$field}['text'];
$format = $user->{$field}['format'];
}

$output = file_rewrite_pluginfile_urls($output, 'pluginfile.php',
\context_user::instance($user->id)->id, 'user', 'profile', null);
$output = format_text($output, $format);
return $output;
}
return false;
}
Expand Down Expand Up @@ -194,7 +208,7 @@ function report_roster_profile_fields_query() {
global $DB, $USER;

$fieldsconfig = explode("\n", get_config('report_roster', 'fields'));
$fields = user_picture::fields('u', ['username'], 0, 0, true) . ',u.timezone';
$fields = user_picture::fields('u', ['username'], 0, 0, true) . ',u.timezone,u.description';

foreach ($fieldsconfig as $field) {
$field = trim($field);
Expand Down