Just hit this problem on a new Moodle system (my first) which went live over the weekend. Students' names missing from the start of the email. And yes, it does look as if it might be happening where the student hasn't yet updated their profile.
Following addressed to Moodle programmers...
I did a grep on a string from the email ('
has updated their assignment submission for'), expecting to find a variable (uninitialised?) in front of it. Sure enough found the following in lang\en\assignment.php.
$a->username has updated their assignment submission
for '$a->assignment'
It is available here:
$a->url';
I don't know PHP at all - maybe one day - but found a quick reference card online and it told me (I think) that
$a->username is using an instance variable, username, of an instance of some class referenced by $a. (Excuse non-familiarity with PHP!)
Other code in assignment.php uses instance variables: assignment, teacher, url, username of the same object. I guess this would trigger related bugs if $a doesn't reference an object upon entry or else references an only-partly initialised object.
In fact I can see the 'wrongly-generated'(?)
URL in the same email. The code responsible is
$string['emailteachermailhtml'] = '$a->username has updated their assignment submission
for <i>'$a->assignment'</i><br /><br />
It is <a href=\"$a->url\">available on the web site</a>.';
which just happens to
create a valid HTML <a href> tag when the $a->url is empty. Perhaps this was intentional (or saved checking the integrity of $a).
There is nothing I can see in assignment.php which creates an instance and assigns it to $a, so I guess that there is an assumption(!) upon entry to assignment.php that an in-scope (global?) variable $a exists and references an instance of the right class. Could this be a dodgy assumption? (I think so - hence the missing name in the email).
Q: Where and when is (or, rather, should be!) $a set?
Q: What calls assignment.php?
Q: Wouldn't it be better (if it's possible) to pass the instance (referenced(or not!) by $a) as a parameter to assignment.php - less bug-prone than relying on variables not explicitly initialised within assignment.php (and a bit more OO / resilient)? At the least it might be good to have a comment at the top of the code stating the assumption about the value of $a upon entry.
I wonder whether this code (using $a) might have got in by being copied / pasted from somewhere else without being checked carefully?
Hopefully this might provide a clue that someone who knows PHP, Moodle design (and the OO world) might pick up. Sorry if I've made some bad guesses as a non-PHP programmer. I think I should become familiar with the bug-tracking / CVS part of Moodle at some point to check / report this properly, but no time right now. Meanwhile I found
http://moodle.org/xref/nav.html?stable/mod/assignment/lib.php.source.htmlwhich I guess is an 'official' source code reference and the same code (i.e. use of $a, not initialised in assignment) appears to exist in both the stable and development
sections. Perhaps someone who is familiar with the bug-tracking / CVS could kindly check this?
BTW, very impressed with Moodle overall so far - excellent community... destined for increasing growth and success, I suspect.
A.