I'm working with moodle 1.94. Our client runs a large primary manufacturing organisation with a number of sites.
To identify where users are located we have added an additional profile field called location in which we store the site name. This is stored in the mdl_user_info_data table.
We now require this site name to appear in the quiz results table.
I have been able to successfully add additional fields to the quiz results table and export them correctly where the field is from the mdl_user table.
However, when I join the mdl_user_info_data table I get the message "Nothing to display"
Here is the snippet for the data select from mod\quiz\report\overview\report.php
// Construct the SQL
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, ';
if ($qmsubselect) {
$select .=
"(CASE " .
" WHEN $qmsubselect THEN 1" .
" ELSE 0 " .
"END) AS gradedattempt, ";
}
$select .= 'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
'u.id AS userid, u.idnumber, u.department, u.firstname, u.lastname, u.picture, u.imagealt, uid.data, ' .
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
// This part is the same for all cases - join users and quiz_attempts tables
$from = 'FROM '.$CFG->prefix.'user u ';
$from .= 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON qa.userid = u.id AND qa.quiz = '.$quiz->id;
// This line joins mdl_user_info_data for additional fields
$from .= 'LEFT JOIN '.$CFG->prefix.'user_info_data uid ON uid.userid = u.id AND uid.fieldid =2';
When I run this select in MySQL as below it returns the correct records and data
select qa.uniqueid AS attemptuniqueid , qa.id AS attempt, u.id AS userid, u.idnumber, u.department , u.firstname, u.lastname, u.picture, u.imagealt, uid.data as 'Site Location', qa.sumgrades, qa.timefinish , qa.timestart, qa.timefinish - qa.timestart AS duration FROM mdl_user u LEFT JOIN mdl_quiz_attempts qa ON qa.userid = u.id LEFT JOIN mdl_user_info_data uid ON uid.userid = u.id and uid.fieldid=2 where qa.quiz =60 1. Is the export function expanded in moodle 2.0 to handle requests like this? 2. What is the problem with my join that causes it to return "Nothing to display"? 3. Is the problem actually in the table displaying part of the code; in that I have an incorrect reference to the new field data and this is what is causing the display to return "Nothing to display"
Cheers
Bernard
PS.. Is there any way to "watch" threads, rather than get whole "forum" updates?