##firstname## tag in list template

##firstname## tag in list template

by Paul Webster -
Number of replies: 10
I am setting up my list template to be viewed horizontally (like a spreadsheet) and I want to include in my table the user's first name, as this database will be available to guests (It is a display of their weekly news and school newspaper's etc). It is our policy not to post student first and last names on the web (first names are okay).

I have tried several ways to get my list template to work. Everything seems to work except the student name.

The repeating part of my template looks like this:

<tr onmouseover="this.className='trhighlight'" onmouseout="this.className='trnormal'">
<td class="c0"><a href="##MoreURL##">Date Posted</a></td>
<td class="c1"><b><a href="##MoreURL##">Weekly News File</a></b></td>
<td class="c2"><a href="##MoreURL##">Team Members</a></td>
<td class="c3">##firstname##</td>
<td align="center" class="c4">##Edit##&nbsp;##Delete##&nbsp;##More##&nbsp;##Approve##&nbsp </td>
</tr>

When I change that "c3" data to ##user## it does display the proper first and last name but not just the first name.

I am on moodle 1.95 on a Ubuntu Linux 9.04 server.

See screenshot of my list view.

Attachment Screenshot1.jpg
Average of ratings: -
In reply to Paul Webster

Re: ##firstname## tag in list template

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - There is a good reason why the ##firstname## and ##lastname## tags are not working - the code to actually implement the replacement is simply not there. In short, this is a bug and I have filed a report in the tracker with a quick and dirty patch (in case you need to get this working right away) but please read my comments in the tracker as the patch does not respect the $CFG->forcefirstname or $CFG->forcelastname settings (if they are used on your site). Of course this may be another way of dealing with your issue as you could force the lastname of everyone on the site to be the name of your school and then just use ##user##. In any case, I am grateful to you for finding this bug. Please feel free to comment, watch, and/or vote for MDL-20199. Let me know if you have any questions. Peace - Anthony
Average of ratings: Useful (1)
In reply to Anthony Borrow

Re: ##firstname## tag in list template

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Just a quick update, that I have also submitted a proposed patch for those wishing to try it that ensures that the $CFG->forcefirstname and $CFG->forcelastname options are respected. I would invite anyone wishing to test the proposed patch at MDL-20199 to leave any comments or suggestions in the tracker. Peace - Anthony
In reply to Anthony Borrow

Re: ##firstname## tag in list template

by Paul Webster -
Thanks Anthony for your work on this. I am happy to test a patch (safely). When you refer to "$CFG->forcefirstname" is there a sitewide configuration that makes just the first names display? I am not aware of this. If so, where is it? Ideally, on a site the size of ours (250ish users) first name and last initial would work but I don't see that in the reference. We are in a pretty conservative area and it freaks people out to have student names out there on the web, even if they are hidden by password protection.

The reason it really becomes and issue in the case of this database is that we are using it to make their work public and accessible to parents, patrons, ....

Anthony, I see you have posted 3 patch files at MDL-20199 . If I wanted to implement them, what would I do? I have not installed a patch before and I didn't see a how-to link from that page. However, I am a happy learner.

FYI, my install is on Ubuntu 9.04 server and uses a mysql database.

Thanks
In reply to Paul Webster

Re: ##firstname## tag in list template

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - From Configuration_file:
// Force displayed usernames


// A little hack to anonymise user names for all students. If you set these
// then all non-teachers will always see these for every person.
// $CFG->forcefirstname = 'Bruce';
// $CFG->forcelastname = 'Simpson';
//
As you can see, in your Moodle site's config.php file you can force the lastname to 'Simpson' for all users. To get it to be the last initial, would require a little modification to the patch where we could set forcelastname to true and then do an if statement telling it to then use the first initial of the user's lastname.

I attached one quick fix and one proposed fix. The proposed fix is more in depth and I would like to have it reviewed by another developer because it modifies a commonly used function and I want to make sure it will not mess things up elsewhere.

Simply download the patch and then follow the instructions at How to apply a patch. Let me know if you have a specific question in applying the patch or run into troubles. If you are going to try one on a test server, then I would just go with the proposed fix, otherwise, I would go with the quickfix which would be a bit safer for a production server but both should be tested before being used on a production server.

Peace - Anthony
In reply to Anthony Borrow

Re: ##firstname## tag in list template

by Paul Webster -
Thanks Anthony-
I looked at how to apply a patch on a linux server and it looks like a bit of a project. I want to make sure I set up a test server first (I don't have one at the moment but I could set one up on virtualbox on my laptop.

For the quick fix, can I just edit the following lines in the config.php file?

The original is:
// Force displayed usernames
// A little hack to anonymise user names for all students. If you set these
// then all non-teachers will always see these for every person.
// $CFG->forcefirstname = 'Bruce';
// $CFG->forcelastname = 'Simpson';

If I wanted all my kids to have their last name read as MMS (for Marsing Middle School) I could take out the // and edit it to:

// Force displayed usernames
// A little hack to anonymise user names for all students. If you set these
// then all non-teachers will always see these for every person.
// $CFG->forcefirstname = 'Bruce';
$CFG->forcelastname = 'MMS';

Then their name would appear as Johnny MMS, whereas teachers names would appear normal.

If I wanted to just have first names for kids and first and last names for teachers then I could take out the // and then change it to true, like this?
// Force displayed usernames
// A little hack to anonymise user names for all students. If you set these
// then all non-teachers will always see these for every person.
$CFG->forcefirstname = true;
// $CFG->forcelastname = 'Simpson';

Is that right? I would make a backup first of the config.php file, of course.

Thanks for your help. I'm a bit of a geek but this is the first server I have managed. I just want my teachers to be able to use it well.



In reply to Paul Webster

Re: ##firstname## tag in list template

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - Keep in mind that if you use the $CFG->forcelastname = 'MMS' then all of your users (teachers and students) will have their last names displayed as 'MMS'. If you just want the user's full name to be displayed as the user's first name, then go to Site Administration -> Security -> Site policies and set Full Name Format to 'First name'. I would not use $CFG->forcefirstname = true. Moodle does not differentiate users as being either teacher or students since it is possible for someone to be a student in one context (think of someone at a University taking a doctoral level course who is also a teacher's assistant in an undergrad course). Best of luck as you learn to apply patches and work with your test server. Let us know if you have further questions. Peace - Anthony
In reply to Anthony Borrow

Re: ##firstname## tag in list template

by Paul Webster -
Thanks, the reason I asked about $CFG->forcefirstname = true is because the config.php file itself says that it makes this happen for students (but not for teachers). I thought to myself that was just what I wanted.

I tried to do this in Site Administration -> Security -> Site policies and set Full Name Format to 'First name' but that changed it for teachers too. I don't really want all my teachers to be referred to by their first names.

A workaround might be to run it this way and to go back and change each teacher's first name manually to "Mr. Smith" and "Mr. Boyd" etc. I will test it out on a virtual server first, regardless. I know how to do a backup of a course and to restore from backup from a course, once that is done. However, I would like to make an image of my entire server, if possible, to move the whole moodle config over to my test server. Do you know the location of a good how-to on imaging a whole moodle install or the whole server for that matter. I know this is way beyond the scope of this database forum.

Thanks for your help.
In reply to Paul Webster

Re: ##firstname## tag in list template

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - I can certainly see where you would get that impression from the config file and I could be wrong but as I recall based on looking at the code for the fullname function there is no checking to see if someone is listed as a teacher. I am wondering if this may be a carry over from pre-Moodle 1.7. I think it was around that time that we did away with separate tables for students and teachers. It would actually help if you could test the behavior, just temporarily and report back on how the $CFG->forcefirstname and forcelastname options actually function. I suspect we will need to change the wording in the config file so that it is more accurate. Peace - Anthony
In reply to Paul Webster

Re: ##firstname## tag in list template

by Art Lader -
Hi, Paul,

At Aiken HS, we do change each teacher's first name manually to "Mr. Smith" and "Mr. Boyd" etc. It works out pretty well.

Of course, we have fewer than 100 teachers. I cannot imagine this would be feasible for an institution with hundreds or thousands of instructors.

I know it's not an elegant solution, but until something better comes along, it is not a bad workaround for us.

Best regards,
Art


Average of ratings: Useful (1)
In reply to Art Lader

Re: ##firstname## tag in list template

by Paul Webster -
Thanks Art-
Does it make it difficult to keep track of kids when you have some names multiple times in the same class (2 Maria's, for example)?

My school is small enough that I could easily do that.