GB export to excel doesn't include all mandatory fields

GB export to excel doesn't include all mandatory fields

by Chad Outten -
Number of replies: 14
Hello All,

At present, GB allows teacher or admin to export data with grade items and following user related fields: firstname, surname, ID, institution, department and email.

Institution and department are optional user profile fields and I know that these language strings can be edited via Site Admin block > Language > Language editing.

It would be useful to be able to export data from other profile fields including city/town and country. The default export contains optional profile fields, yet omits mandatory fields. Any ideas for a workaround that does not involve hacking core code?

Fyi - I suggested this feature improvement some time ago over at tracker. If you think the ability to include all mandatory fields in GB export file would be useful, pls vote and watch the issue.

http://tracker.moodle.org/browse/MDL-21572
In reply to Chad Outten

Re: GB export to excel doesn't include all mandatory fields

by Bob Puffer -
The function grade, load_final_grades(), in /report/grader/lib.php is where the fields get loaded into the object that eventually gets exported.

Adding the columns would occur in grade/export/xls/grade_export_xls.php
In reply to Bob Puffer

Re: GB export to excel doesn't include all mandatory fields

by Chad Outten -
@Bob: thanks for the pointer. works nicely. i was able to replace 'institution' and 'department' fields and add 'city' and 'country' fields to GB export via this small hack to grade_export_xls.php.

I noticed the tracker issue has now been assigned, so hopefully this finds it way into core Moodle.

---

/// Print names of all the fields
$myxls->write_string(0,0,get_string("firstname"));
$myxls->write_string(0,1,get_string("lastname"));
$myxls->write_string(0,2,get_string("idnumber"));
$myxls->write_string(0,3,get_string("city"));
$myxls->write_string(0,4,get_string("country"));
$myxls->write_string(0,5,get_string("email"));
$pos=6;

/// Print all the lines of data.
$i = 0;
$geub = new grade_export_update_buffer();
$gui = new graded_users_iterator($this->course, $this->columns, $this->groupid);
$gui->init();
while ($userdata = $gui->next_user()) {
$i++;
$user = $userdata->user;

$myxls->write_string($i,0,$user->firstname);
$myxls->write_string($i,1,$user->lastname);
$myxls->write_string($i,2,$user->idnumber);
$myxls->write_string($i,3,$user->city);
$myxls->write_string($i,4,$user->country);
$myxls->write_string($i,5,$user->email);
$j=6;
In reply to Chad Outten

Re: GB export to excel doesn't include all mandatory fields

by Matt Ladwig -

I tried the same thing, but it did not work. Thoughts?

I would also like to do it with fields that I have created.

In reply to Matt Ladwig

Re: GB export to excel doesn't include all mandatory fields

by Matt Ladwig -

Correction, it worked. However, I would like to do the same with a field that I created.

I have a field called 'daytimeroom'. Instead of changing the above to 'city', I tried putting 'daytimeroom' and 'profile_field_daytimeroom'. Neither seem to work.

 

In reply to Matt Ladwig

Re: GB export to excel doesn't include all mandatory fields

by Daniel Lombardo -

Thanks community,

Was a solution found? I am also looking for this modification to the grade export.

Cheers

D

In reply to Chad Outten

Re: GB export to excel doesn't include all mandatory fields

by Daniel Lombardo -

Thanks, this helped me. Moodle 2.3

I want to export both group names and some custom user profile fields. My level of Moodle knowledge is too limited to know how to tell grade_export_xls.php where to find it. I tried replacing 'department' with 'group,' it updated the column correctly, but it mustn't be the associated field because it exported null in each cell.

'city' worked and pulled the city name from the profiles,

groupname, group1, and several others did not work, they displayed the string surrounded by double square brackets in the column heading. Don't know what this means - I presume it means it doesn't exist in the table where it is looking.

It would also be useful to export some custom user profile fields but they appear in the same way; surrounded by square brackets in the column heading instead of the field name - ie. 'idnumber' appears as ID Number, 'department' appears as Department, 'group' appeared as Group, etc. but not the custom fields I try to add to grade_export_xls.php my assignment is a fail thus far. Any help or a link to to tutorials on how to modify the file to retrieve the custom fields would be nice. I know it can be done.

Cheers

In reply to Daniel Lombardo

Re: GB export to excel doesn't include all mandatory fields

by Faizal R -

Do you found any solution yet? I'm also try replace department with m custom id unique shortname but it does not work.

Btw what type of info that ID Number pull from? Also from student profile, I dont see any department or institution.

In reply to Faizal R

Re: grade export in 2.4 can include user profile fields

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Just to update this thread, in Moodle 2.4 onwards, an administrator can specify user profile fields and custom profile fields to be included in the grade export in Site administration > Grades > General settings.

In reply to Helen Foster

Re: grade export in 2.4 can include user profile fields

by Danniel Fred -

but i can't find this options in my moodle isntallation 2.4 site administration > grades > general settings... there isn't such option!! please adivse

In reply to Helen Foster

Re: grade export in 2.4 can include user profile fields

by Danniel Fred -

Helen,

Are you sure please? I can't get this working, please help

In reply to Danniel Fred

Re: grade export in 2.4 can include user profile fields

by Phil Coultier -

Hi 'its me',

The option is there for me, it looks like this:

Moodle v 2.5 (Build: 20130514)

 

In reply to Phil Coultier

Re: grade export in 2.4 can include user profile fields

by Danniel Fred -

well, thanks, i have such field and it is working fine for original fields like name, ID number and so on

i have the other field below which is supposed to be the one to select from the list of your custom profile fields such as in our case we have fields "class" and "year"

i tried to add "class,year" in that box of custom profile and even exported the gb didn't work, nothing new, tried to add customeprofile_class also didn't work

any clue?

In reply to Danniel Fred

Re: grade export in 2.4 can include user profile fields

by Shane Dodd -

I had a similar issue and realized I hadn't enter the "short" name for the field.  Mine was a field called "Company" that I had short named "comp"  When I entered the value in the other field, I put "company" instead of "comp"  When I changed this, it worked .  Hope that helps!

In reply to Shane Dodd

Re: grade export in 2.4 can include user profile fields

by Brent Sawatzky -

Did this feature stop working in later versions?  I'm running 2.6 and am trying to use this feature.  In the export (and preview), it shows the heading (so it recognizes the existence of the field) but the column is empty.  I tried it with a few different "user profile fields" and they all show empty.  Thank you