× Social Extensions Integration

Avatar CB in moodle

2 weeks 2 days ago
Peter
Posts: 22
More
Topic Author
Avatar CB in moodle #1
Hi Antonio,

Same problem here. I'll try to give you some more details about what i did.

I installed joomdlehooks community builder and joomdlecbprofile. I am testing with both plugins on a user with auth = joomdle.
I made a mapping on the firstname and changed it in CB, the change is visible in Moodle.
Then I changed it in Moodle. This also goes well but with 1 problem. The cbThumbPict (which is the small avatar in the Community Builder Login module) is reset to the default. The cbFullPict does not change, which is OK offcourse.
Uploading a new image in CB restored both, cbThumbPict and cbFullPict. However, the avatar in Moodle remains unchanged. There is no synchronising of the Avatar here.
Is it at all possible to synchronize the avatar? Because i don't see any mapping for that.
And second, why is the cbThumbPict changing when i only change the firstname in Moodle?

Kind regards,
Peter
2 weeks 1 day ago
Antonio Durán
Posts: 6897
More
Avatar CB in moodle #2
Hi Peter. I moved your post to a new topic, as it seems like a different issue.

I don't remember about the cbThumbPict image. I will try to replicate the issue and get back to you. I assume you are running latest CB?

> Is it at all possible to synchronize the avatar? Because i don't see any mapping for that.

Yes, avatar should be synced. There's no need to map anything for that. Try opening Moodle avatar image on its own window, and reload, as sometimes cache makes it not to change right away.
2 weeks 1 day ago
Peter
Posts: 22
More
Topic Author
Avatar CB in moodle #3
Hi Antonio,

I'm running the latest CB.

Thanks for looking into this. No, it's not a cache issue. I saw you mentioning this in a post earlier, so i've looked into that allready.
1 week 6 days ago
Antonio Durán
Posts: 6897
More
Avatar CB in moodle #4
Hi Peter.

I tested avatar sync from CB to Moodle, and it is working fine for me. Please check that you have installed and enabled Joomdlehooks CB plugin in CB.

As for the cbThumbPict: you are correct, I could replicate the issue and added some code to fix it. If you want you can write to development at joomdle and I will send you the new version, so you can test it before we release it.
4 days 13 hours ago
Peter
Posts: 22
More
Topic Author
Avatar CB in moodle #5
Antonio,

My first findings. I haven't tested custom fields in Moodle yet and I want to use them. I'll do that later.

- when changing firstname, the name remains unchanged in the header (the login in usermenu). Even after emptying the cache. Logging out and logging back in gives the correct and modified name.
- changing firstname is no longer a hassle with the avatar that is used by cb.
- uploading a new avatar in Moodle has no effect in Moodle. The old one remains. Even after emptying the cache and logging back in
- deleting an avatar and then saving it gives the default gray avatar. When i upload a new avatar after that, the old one suddenly appears again. Again, even after emptying the cache and logging back in.
- the above synchronization with CB of the avatar however is going well.

I think you have enough to think about :-)

If you have any questions or would like me to have specific mutations tested, you say so. I will.
4 days 12 hours ago
Peter
Posts: 22
More
Topic Author
Avatar CB in moodle #6
Did a bit more testing. I think that the problem is the browsercache and i have to disable browsercaching for Moodle. But i don't know if that is at all possible.
3 days 13 hours ago
Antonio Durán
Posts: 6897
More
Avatar CB in moodle #7
Hi Peter.

> uploading a new avatar in Moodle has no effect in Moodle. The old one remains. Even after emptying the cache and logging back in

It did for me, but I had to reload the image in order for it to show the new one. ie: if I right click on the image and "open image", it shows the new one.
But if I reload the profile page, old one still shows. If I open the profile page in a new tab, new pic shows :)

> deleting an avatar and then saving it gives the default gray avatar. When i upload a new avatar after that, the old one suddenly appears again. Again, even after emptying the cache and logging back in.

When I removed avatar, it correctly sets it to None in Moodle, and sets default one in CB.

When I uploaded a new one, as you say, old one showed up, but it is all caches: if I do it on a different tab, new ones shows.


I took some time to study this, as I did not understand why this happens with Joomdle users and not Moodle normal users.
I could find a problem in Joomdle code, probably due to not having a complete understanding of how this worked back in the day. After fixing it, new avatars show right away for me.

If you want to do the change, you need to edit file: moodle/auth/joomdle/auth.php
Funciton: create_joomdle_user
Change:
process_new_icon($context, 'user', 'icon', 0, $tmp_file);
$conditions = array ('id' => $user->id);

$DB->set_field('user', 'picture', 1, $conditions);

By:
$rev = (int) process_new_icon($context, 'user', 'icon', 0, $tmp_file);

$conditions = array ('id' => $user->id);
$DB->set_field('user', 'picture', $rev, $conditions);

Please test and let me know.


As for this:
- when changing firstname, the name remains unchanged in the header (the login in usermenu). Even after emptying the cache. Logging out and logging back in gives the correct and modified name.

I am not sure why this happens: when I tested, the header changed right away to reflect new name.
I only saw one strange thing with this: if you have an alternatename set in Moodle user, it will use that instead of name, so when you change name nothing happens.... not sure if it is related to your problems.
3 days 9 hours ago
Peter
Posts: 22
More
Topic Author
Avatar CB in moodle #8
The change in auth.php works. When i upload and save new image in Moodle the new one shows right away. Great work!
I changed it into another image using the profile edit function of CB. In the Moodle header the old image remains but the profile view in Moodle shows the new one. After logging out/in the new one appears.

A hint i got from Mark Johnson on one of the Moodle forums was this:

"When moodle outputs the user's avatar, it adds ?rev=123 to the URL, when 123 is the value of the picture field in the user table. If you change the user's picture, you should increment this value to prevent caching issues (since the URL is different, the browser will not use the cache)."
Might this be the hidden treasure to get it right without logging out/in?

About the aternatename in Moodle: we don't use it.

I'm perfectly happy with the results sofar because i can explain in to users. Offcourse it would be perfect when it's possible to get things right without logging out/in? Would it be possible for you to take a look at Marks hint (above)?
2 days 14 hours ago
Antonio Durán
Posts: 6897
More
Avatar CB in moodle #9
Hi Peter.

Thanks for the info. In fact, I learned about this rev funcionality yesterday, and that's what let me do the code modifications I sent you before.

> I changed it into another image using the profile edit function of CB. In the Moodle header the old image remains but the profile view in Moodle shows the new one. After logging out/in the new one appears.

I could not replicate that: I just changed image in CB, opened Moodle and see new image in header.

> About the aternatename in Moodle: we don't use it.

Just in case, check database to see if that field is not empty for your test user, or create a new test user and try again.
As I said before, for me name changes in the header as soon as I submit the profile form with the change in Moodle.
2 days 14 hours ago
Peter
Posts: 22
More
Topic Author
Avatar CB in moodle #10
OK, thanx.
Checked the database and fields for alternatename are empty.
If you can not replicate the issue then there's only this much you can do. No problem.

Which theme did you use when you tested the issue?
Cron Job Starts