Course Icon on mobile not same as that in moodle

Hi Alex,
The course icon displayed on the mobile phone, after exporting the course is different from the course icon that I set in moodle.
At first, when I had like two topics, it was displaying correctly (I kept exporting the draft course for testing).
But when I kept adding more topics, a random icon from one of the activity pictures I uploaded was set, and its now being displayed as course icon on the mobile phone.
I have attached screenshots of the course icon as it appears on moodle and the mobile.


Hi @hakimks
hmmm, not quite sure what be going wrong here…

I just had a test with another course on our Digital Campus Moodle (running block version v1.1.1/2020091500) and it appears to be working OK.

Could you send me a link to the course in Moodle so I can take a look? (you can send via email if that’s better, esp if I need any username/password to see)

Cheers,
Alex

1 Like

Thanks for sending the link to the course through @hakimks.

I think I see what the problem is now… there is a space in the course icon filename.

I assume the reason it worked before is something to do with a change we made in the recent block release, so I’ve flagged as a bug for us to fix in the next sprint.

The fix for now will be to re-upload the course icon with a filename that doesn;t have spaces in it. But let me know if that works or not,
Cheers,
Alex

Thanks for the reply.
This did not solve the issue. But strangely after uploading a new icon with a filename with no spaces, it show this message at the end of the course export.Screenshot_2020-10-20 Course Case Management Guidelines for COVID-19

Thanks for letting me know… I’ll take another look…

After taking another look, unfortunately I’m still confused what’s going wrong here.

On my local Moodle (a different course) the course icon exports ok, but when I restore this specific course onto my local machine, I get the same issue that you are, with the incorrect icon. If I do a test export from your server with another course, then it exports the icon correctly.

So it doesn;t look like it’s specific to the Moodle version or the moodle-oppia block version, but I don;t have another explanation right now.

@jjoseba - do you have any ideas as to what might be going wrong here - can you test on your local Moodle too please, I put the Moodle backup file attached to the issue on Jira: https://oppia.atlassian.net/browse/OPPIA-459

In my local environment everything is working fine… to narrow the problem, can you @hakimks and @alex try to download the course manually from the Moodle block after the export process, and check if the meta>filename value in the module.xml points to the correct image? At least we can find out if the problem is happening in the export block or beyond that.

After sending the previous answer, it came to my mind what the root of the problem could be.

When the thumbnail for the images is generated, the filename is created as /images/{{id}} for both the course icon and the activity thumbnails. Could it be that in that specific case the IDs in your Moodle installation are clashing?

Following the previous answer (assuming that the error happens at Moodle level, that is the most logical), it should be easy to check if the id for the image that appears in the meta>filename value also corresponds to the ID of the activity (the latter can be checked just by accessing http://yourmoodlehost/mod/page/view.php?id={{id}}, I’m not sure how to access the internal ID of the course description.

thanks @jjoseba - but I’m not sure that’s the issue… as it’s also happening on my machine too (I backed up and restored the course locally)… here’s a extract of the meta part after exporting to Oppia package:

<meta>
<versionid>20201021115424</versionid>
<priority>0</priority>
<server>https://demo.oppia-mobile.org/</server>
<sequencing>none</sequencing>
<tags/>
<exportversion>2020091500</exportversion>
<title lang="en">
<![CDATA[ Case Management Guidelines for COVID-19 ]]>
</title>
<shortname>case-management-draft</shortname>
<description lang="en">
<![CDATA[ Case Management Guidelines for COVID-19 ]]>
</description>
<page id="44">
    <title lang="en">
    <![CDATA[ About/License ]]>
    </title>
    <image filename="/images/44.png"/>
    <location lang="en">00_44_en.html</location>
</page>
<image filename="/images/83.png"/>
<langs>
<lang>en</lang>
</langs>
</meta> 

So you can see it’s using /images/83.png as the course image, which does correspond to an activity page id - but no clue why it should be picking up this image

The course description is picked up from the mdl_course table, in this case the course id is 4, so it ought to be using that

@hakimks - would it be OK for me to pass on to Joseba the access info to your moodle, so he can take a look directly on there?

@alex yes, that is fine with me.

1 Like

Thanks @hakimks - @jjoseba I’ll email this info on to you

Accessing the Moodle I just can confirm that the IDs are clashing, so the problem is in the Moodle block. From both the mesau.net Moodle and your example, I still think that it’s happening what I mentioned. The ID it takes to generate the thumbnail filename is not the course id but an internal ID that Moodle uses to reference the context of that course instance (it’s obtained by calling context_course::instance($course->id)).

To confirm it in your example, you can access your local database and check that in the mdl_context table you’ll have a row with id 83 that in the instance_id will have the course id (4) and in the contextlevel will have a value of 50, corresponding to a course context (see https://docs.moodle.org/dev/Roles#Context). The same would apply with the mesau.net Moodle, but with the row with id 757 and instance_id of 22 (the course id in that case).

I’ll make a small PR changing the way this filename is generated, and I think that way the clash can be avoided. The strange thing is that given the chances for this to happen, we didn’t encounter this scenario before!

1 Like

Thanks @jjoseba

My guess is that the Mesau Moodle, and my Moodle are relatively new installs , so all the id numbers will be quite low still - increasing the chances of a clash. Whereas on the DC Moodle we’ve had a lot of different courses added/removed etc.

Anyway, great to catch this!

@hakimks - I’ll let you know once Joseba has sent through the PR and I’ve tested locally

Actually this is the second time I am experiencing this on the mesau moodle, and it so happens when the course has alot of topics/modules.

@hakimks - Joseba has just made an update for this issue, I tested locally and it’s fixed the issue on my local server.

The update is on the master branch of the block code, so if you’d like to have a test with this update and check that it fixes the issue on your server too. Please let me know if it’s now working correctly, or not.

Cheers,
Alex

Thanks @alex and @jjoseba. it is fixed.

2 Likes