Automatically adding picture of user to his name possible?

Automatically adding picture of user to his name possible?

by Hartmut Scherer -
Number of replies: 30
Hi all,

I would like to know if there is a way to automatically add the picture of the user to his name in a database? I searched this forum, the FAQ and some examples but I couldn't find a solution. Perhaps I overlooked some instruction. All advice appreciated.

With kind regards,

Hartmut
Average of ratings: -
In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Stuart Mealor -
Each user on a Moodle site has a profile with his/her photo.
For example, yours is:



But I don't think there is any way to add this automatically to a Moodle database activity?

It would need a field similar to ##user## returned from the database - maybe ##user_image## but this would have to be an addition to the database module.
In reply to Stuart Mealor

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -
Thank you, Stuart, for your response. Perhaps the profile picture will be added in the database module in Moodle 2.0.
In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Stuart Mealor -
You could maybe add this as a feature request in the Tracker Hartmut ?

smile
In reply to Stuart Mealor

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I like the idea of having a ##userpicture## tag available for the database activity module. I have created MDL-20053 and attached a patch which I believe is functional. Those interested in this feature are welcome to watch and/or vote for the issue. For the bold, feel free to try the patch and provide any feedback by adding a comment to the tracker. Peace - Anthony
Average of ratings: Useful (3)
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by David Bogner -
Picture of Core developers Picture of Plugin developers
Hi Anthony,

that is a great idea.

I would have another idea for the database module:
Add the possibility to assign roles to the fields so that some fields only can be filled out by teachers, after a student has created an entry or that students can edit a field the teacher provided. So you can create complex exercices.

What do you think about that?

Yours,
David
In reply to David Bogner

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
David - I always enjoy new and creative ideas. Your idea sounds interesting but I am wondering how it might actually be used. In terms of implementation, it would just be a matter of adding a field to the data_fields table. I started looking at what would be needed to require a field and this would seem to be take off on that in so far as it is a type of field that is to be completed by the teacher. Essentially we could use the data manage activity capability (or create a new one) such that if the user has that capability then they can complete it otherwise they just see the value of it. To a limited degree, this might also be accomplished by adding a field but not showing it on the add record template. The disadvantage would be that the teacher would not have an easy way of editing or adding their data since editing a record also uses the add template. I personally do not envision this being something useful in core but it could be a nice little patch. Some possible scenarios explaining how this feature could be actually beneficial may be helpful in changing that personal opinion. Peace - Anthony
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by David Bogner -
Picture of Core developers Picture of Plugin developers
Hi Anthony,

yes I think you are right, that this would not be useful for many. I was just thinking, that this could be nice for example for administration purposes. The teacher could upload a certificate to a record created by a student. Or that some information entered in a record is only visible to the teacher (confidential) but all other fields are visible for all the students, ...

But there is another point perhaps more important: I develop courses for teachers like "Learn how to use moodle in your class". I personally like the database module and use it often instead of a wiki, because it is easier to use for the students.
Nevertheless teachers do not use the database tool for one specific reason: It is too complicated to create.
The solution would be a database creation wizard (Create your database in 5 guided steps)

1) Choose the fields you need
2) Now the fields chosen appear and you are asked to choose the ones appearing in list or single view, including checkboxes for the ##user##, ##...##
Example (instead of yes/no use checkboxes)

List view
Single view
Show username
yes/no
yes/no
Show the date the record was made yes/no yes/no
Show the field "Uploaded File" yes/no yes/no
Show the field "title"
yes/no
yes/no

3) Choose display mode for list view (For 99% of the use of database 5 different display modes are enough)

First display mode: Fieldname as title of columns, records below. The teacher can choose to alter the name of the columns
TITLE
Uploaded file
Username
Date uploaded
Content of the field "title"
Uploaded file
example name
date1
Content of the field "title" Uploaded file another name
date2

Second display mode: Just group the records and display one below the other
Third display mode: Drag and drop the possible fields in a given matrix
Fourth display mode: manual template: Create your view with the editor (as it is now for html experts)
Fifth display mode: display records horizontally.

4) Choose the default display order of list view (sort by date, title, username, etc)

5) Choose style template (three styles available)

But perhaps this wizard takes too much time to program?

Another idea for the database: possibility to define certain fields as "required". Now you can submit a record with empty fields, this should not be possible if a field is required

Yours,
David

Average of ratings: Useful (1)
In reply to David Bogner

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
David - For your first use scenario of a teacher needing to give a certificate, I first thought of using the advanced upload assignment type. A student submits something and then the teacher responds by uploading a certificate. But I could see from that example how allowing certain fields to be completed by a teacher only could be helpful.

I see your ideas on templating as expanding the options for default templates. It would be nice to have that be a plugin where the wizards could just be dropped in. That would allow folks to develop options beyond some of the simple possibilities.

As for the required field, check out MDL-5583 and feel free to watch/vote for it. I started work on it but dealing with how to actually require the form became a mess and I have not had a chance to get back to it. I have a patch in MDL-11400 which creates the tick box and if I recall will highlight it so that it says it is required but it does not actually require it. Keep the ideas flowing.

Peace - Anthony
Average of ratings: Useful (1)
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by David Bogner -
Picture of Core developers Picture of Plugin developers
Hi Anthony,

yeah another ideo would be, that in the "Admin-Block->Modules->Database->Settings". The Admin of the Moodle Site can choose some database fields like skypename, username, or anything else to be displayed in the database with ##userprofilefieldname## or so. Other suggestions: subscribed courses, etc.. with ##subscribedcourses##. So for security reasons the admin can choose what the teachers can choose....

Thanks for posting the other issues, I just voted for them.

Yours,
David
In reply to David Bogner

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
David - I like this idea of being able to specify certain user profile fields. Would you mind creating that as a feature request? Peace - Anthony
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by David Bogner -
Picture of Core developers Picture of Plugin developers
Hi Anthony,

I just created a new feature request (for 2.0) for displaying any user profile fields. So everyone is invited to vite for it!
MDL-20140

Yours
David
Average of ratings: Useful (1)
In reply to David Bogner

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
David - Thanks for creating the issue - I am watching it and have voted for it. I have some ideas for implementation so if I can work up an initial patch in my spare time I will. Peace - Anthony
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -
Thank you, Anthony, for providing a patch. Sorry, that I didn't respond earlier. Although I subscribed to this forum, I have not received any forum digests. I am not sure whether I am bold enough to try out your patch, but I like the idea that it may be possible in Moodle 2.0.

With kind regards,

Hartmut
In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Hartmut - It is curious that you did not receive the post. You may also want to start by reading Development:How_to_apply_a_patch. If you have questions about how to test the patch just let me know. Peace - Anthony
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -
Anthony, thank you for the encouragement. With the help from TMD Hosting I am now able to add the user profile picture to any activity with the database activity module. Thanks again, Anthony, for providing the patch. I enjoy it.

With kind regards,

Hartmut
In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Hartmut - I am glad to hear that you were able to get the patch applied and working. Feel free to provide further feedback or let me know if you have any difficulties. Peace - Anthony
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -

Hi Anthony,

Today we updated to Moodle 1.99. When TMDHosting tried to apply the patch for adding user pictures to any database activity, they received the error message:

can't find file to patch at input line 25

Is this patch working in Moodle 1.99? How can I apply this patch to an Apache server with PHP 5.2.11?

Any help is highly appreciated.

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hartmut - I have not tried it but I did not notice any significant changes to /mod/data/lib.php that would make it not work. The patch is pretty small and simple, so you may just want to make it manually. Let me know how I can be of help. Peace - Anthony

Average of ratings: Useful (1)
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -

Thank you, Anthony, for your prompt reply and for offering your help. As I have never applied a patch in Moodle before, I will try out the patch in a test domain first.

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hartmut - Let me know how it goes and please feel free to report any problems in the tracker at MDL-20053. Peace - Anthony

In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -

Hi Anthony,

I followed your advice and added the patch manually - and it works. Thanks for your encouragement.

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Excellent! Glad to hear it works. Today you applied it manually, next time it will be with your IDE (like Eclipse) and then after that you'll be applying it via the command line. Happy Moodling! Peace - Anthony

In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -

Hi Anthony,

I would like to use ##userpicture## in Moodle 2.x.x as well, but the patch MDL-20053 works only in Moodle 1.9. Can you help me with a patch for Moodle 2.x.x?

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hartmut - I'll see if I can get MDL-20053 some attention and if I have a chance I'll work up a patch for 2.0. Peace - Anthony

In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by Hartmut Scherer -

You are fast, Anthony, and it works. Today, I applied your patch manually. Many thanks for your work.

With kind regards,

Hartmut

In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hartmut - I am glad to hear that the revised patch work and hopefully the tracker issue will be resolved soon especially as 2.1 aims to improve the various activity modules. If you need anything else just let me know. Peace - Anthony

Average of ratings: Useful (1)
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by John Fitchett -
patch works awesome! Thank you!!
In reply to Anthony Borrow

Re: Automatically adding picture of user to his name possible?

by William Lu -
Picture of Particularly helpful Moodlers
Great! It works very well on my Moodle1.9.7 and the picture links to full profile as well. Thanks a lot.
In reply to Hartmut Scherer

Re: Automatically adding picture of user to his name possible?

by J.R. Morris -
What about the same idea for the ##useremail##?
In reply to J.R. Morris

Re: Automatically adding picture of user to his name possible?

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I think that MDL-20140 would take care of making the email field available. I had commented on that issue that some care will need to be taken so as not unwittingly reveal personal information about a person that is not readily available by viewing their Moodle profile so we will need to do the same checks. You may want to watch and vote for MDL-20140. Peace - Anthony
Average of ratings: Useful (1)