Adding custom user profile fields to activity completion report

Adding custom user profile fields to activity completion report

by Muhammad Ammar` Ijaz -
Number of replies: 5

I am using moodle 3.4 and wanted my custom user profile fields to display on activity completion report. How can i achieve this?


Average of ratings: -
In reply to Muhammad Ammar` Ijaz

Re: Adding custom user profile fields to activity completion report

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can't without hacking core code - which I wouldn't recommend. 

I've written custom course reports in the past to provide Assignment reports with output like this (although - before you ask - never exactly what you want)

In reply to Howard Miller

Re: Adding custom user profile fields to activity completion report

by Colin Fraser -
Picture of Documentation writers Picture of Testers

If the fields exist in the database, then why hack core code and create a  custom report? I have never done this, but from what I recall of the database and SQL, you should be able to query to database to get all the information in a report you need. The hard part would be formatting the report in a user friendly manner I would think. The skills needed would be PHP, SQL (possibly HTML and Javascript), and understanding enough of how Moodle works to convert the report to a PDF and printing. You could start with the documentation here to try to understand how you could do that.

You could find an existing course report that does the major things, and modify that to suit your need. You could create your own course report module for whatever report you need and not just use the standard course reports. 

In reply to Colin Fraser

Re: Adding custom user profile fields to activity completion report

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I said *not* to hack core code... I suggested creating a custom report. Which is what you said. Confused...

Anyway, a custom report is basically just querying the database and so on. Moodle contains lots of stuff to do this and to format the output. It makes sense (to me anyway) to build a custom report plugin. 

In reply to Howard Miller

Re: Adding custom user profile fields to activity completion report

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Creating a new report is now hacking core code? mm My apologies, been away for most of the year. 

Oh I see, replacing the entire reporting module you mean... mmm OK, not a clever observation... sorry, Howard, just got a bit carried away.  But it could be done in a branch if the organization that is using the Moodle has the skill base to do that. Up to them really, isn't it? 

I suspect the key advice is not to change core code as any such change may have unforeseen impact on other aspects of the Moodle and the hassles that users and organizations have when updating their Moodles. Would that be right? The other side of this though is that organizations also have the opportunity to submit any such change to Moodle.org and possibly see their change become part of core, or at least be encouraged to add their change in as a plugin if it could be worked that way. Would that not also be correct? 

And Merry Xmas Howard..smile 

 

In reply to Colin Fraser

Re: Adding custom user profile fields to activity completion report

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm almost certain we are talking at cross purposes...

https://docs.moodle.org/dev/Reports

Reports are a pluggable thing. One can develop (or have developed) a report to do anything you like without going near core code. Always favour writing a custom plugin before touching core code. If writing something is unavoidable.

And a merry Xmas to you too!