MDL-40962 assign: Fix alternate name field warnings in assign

This commit is contained in:
Ankit Agarwal 2013-10-01 14:12:20 +08:00
parent c78fdd8db3
commit 5c7ec9f6f8
2 changed files with 17 additions and 3 deletions

View File

@ -490,6 +490,7 @@ function assign_print_overview($courses, &$htmlarray) {
* @param mixed $course the course to print activity for
* @param bool $viewfullnames boolean to determine whether to show full names or not
* @param int $timestart the time the rendering started
* @return bool true if activity was printed, false otherwise.
*/
function assign_print_recent_activity($course, $viewfullnames, $timestart) {
global $CFG, $USER, $DB, $OUTPUT;
@ -497,8 +498,9 @@ function assign_print_recent_activity($course, $viewfullnames, $timestart) {
// Do not use log table if possible, it may be huge.
$dbparams = array($timestart, $course->id, 'assign');
if (!$submissions = $DB->get_records_sql('SELECT asb.id, asb.timemodified, cm.id AS cmid, asb.userid,
u.firstname, u.lastname, u.email, u.picture
$namefields = user_picture::fields('u', null, 'userid');
if (!$submissions = $DB->get_records_sql("SELECT asb.id, asb.timemodified, cm.id AS cmid,
$namefields
FROM {assign_submission} asb
JOIN {assign} a ON a.id = asb.assignment
JOIN {course_modules} cm ON cm.instance = a.id
@ -507,7 +509,7 @@ function assign_print_recent_activity($course, $viewfullnames, $timestart) {
WHERE asb.timemodified > ? AND
a.course = ? AND
md.name = ?
ORDER BY asb.timemodified ASC', $dbparams)) {
ORDER BY asb.timemodified ASC", $dbparams)) {
return false;
}

View File

@ -73,6 +73,18 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
assign_print_recent_activity($this->course, true, time() - 3600);
}
/** Make sure fullname dosn't trigger any warnings when assign_print_recent_activity is triggered. */
public function test_print_recent_activity_fullname() {
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();
$assign->get_user_submission($this->students[0]->id, true);
$this->expectOutputRegex('/submitted:/');
set_config('fullnamedisplay', 'firstname, lastnamephonetic');
assign_print_recent_activity($this->course, false, time() - 3600);
}
public function test_assign_get_recent_mod_activity() {
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();