Serious Problems with the way view.php handles resources

Serious Problems with the way view.php handles resources

by Jon Witts -
Number of replies: 31
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I have been having serious problems with the way resources are handled using view.php in the latest versions of Moodle, and it would appear I am not the only one.

I have posted in the resource forum but have got no response; also there is another user who is having exactly the same issues as me who has also received no response.

The two posts are here:

http://moodle.org/mod/forum/discuss.php?d=110034

http://moodle.org/mod/forum/discuss.php?d=98092

As far as I can tell it is down to the way that view.php is serving the files which differs from the way file.php serves the files. If we use the "direct link to file" then both PDFs and Flash animations display correctly; any other method does not work and is rendering three years worth of setting up Moodle courses a waste of time!

Does anyone know if there is a way to have resources displayed as they used to be, using file.php not view.php?
Average of ratings: -
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

You seem to be right - I tested your files (great work by the way!!!)

It might be possible to edit files of resource module (view.php and other files) or use old versions of that module but one work around could also be to use Compose a web page instead of Link to a file or web site and to put the place-holder flash inside iframe tags. Then all other flashes are loaded inside iframe but you can set size and other properties of iframe and flash inside it.

A quick test with something as simple as

<p><iframe width="800px" height="600px" src="http://pathtomoodle/file.php/2/alchemical.swf"></iframe></p>

worked nicely. Just add some more css (centered div, background for page holder page etc)
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I can't take the credit for the files - they were bought in from a third party!

I can see that working for flash files but we also have the same problem appearing for the way that view.php is handling PDF files that is also causing problems. I can't see the iframe work-around helping those issues...

A more suitable solution would be to have the option to display a resource using the old file.php method (now appearing if you set a pop-up window, as "direct link to this file")

I would need to have a look at the code to see how, if at all, this would be possible; but as it stands the change introduced with view.php is a major show stopper for us. I have over 15 courses each with around 35 flash and pdf files in them that now do not function correctly.

I will try out the iframe idea for the flash files, but it will take ages to update every single one. I would be happier if there was a way to get Moodle to handle the files in the same way as it did before.
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

Jon,

test the attached file mod/resource/type/file/resource.class.php

I changed one function - function display() - to use latest moodle 1.7 code and it worked ok with your material on my test server using file.php but I don't quarantee it is totally bug free.

Take first a backup of the original mod/resource/type/file/resource.class.php

In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Mauno,

Thanks for that! I tried it on my server and it works, in so far that it displays resources using file.php rather than view.php, and yes, the flash files work properly again.

One thing that I did notice however, is that if you select "keep navigation visible" for the resource, it does not keep the course in the navigation and just jumps straight back to the front page of Moodle.

Is it possible to have it keep the navigation visible too?

EDIT:

I have put the original file back in place for now! smile
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

I forgot to ask one important question - what version of moodle do you have?

I tested the file with 1.9.3+ (Build: 20081105) and it works here both without and with navigation (frames)...

Edit: now I see what you mean. For example course 2 should have .../course/view.php?id=2 in navigation to redirct to course 2 and not to front page. I must check how it used to work before (moodle 1.6 & 1.7)

In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
We are version 1.9.3 (Build: 20081022)
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

How about this attached file. I found the missing navigation items. Do you notice any other missing features?

In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I will upload this file to my server and give it a go. I will let you know ASAP.

Thanks for your time on this.
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I have uploaded this to my server and all appears well! big grin

I am going to ask a couple of our teachers who first noticed the problems to check their courses and let me know if everything is handling as they expect now.

Is it possible that this can get put back into the CVS so I do not have to apply this change every time I upgrade?

I am going to let the other person who had seen the issues with PDF files now about this fix you have provided as it seems to solve that problem too.

Again, thank you so much for your time on this!!!
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

Great!

Just in case I added one more navigation code from moodle 1.9.3+ although I did not notice any difference between that previous and this last version. Both seem to work with and without navigation and in popup. Anyway, here's my final version... if you notice anything sent a message...

The official version of moodle 1.9.3+ is totally different - probably people are trying to get it more like moodle 2.0 version for the coming repository changes.

Average of ratings: Useful (2)
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
OK. I have uploaded your final version and asked the three teachers who spotted the error to check their courses and let me know if they see anything incorrect. - Hopefully not! wink

Do you have a way of seeing if files of this type will operate correctly on Moodle 2.0 or is it a case of wait and see?
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -
The new repository system is still unstable so we must just wait and see. I tested quickly adding your flash files with the current version (as a new resource) and it had the same problem as moodle 1.9 has.
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
OK, I shall do a test install of version 2.0 when it is released and check before I upgrade. Hopefully it will work by the time it is released!

Thanks again for all your time on this!
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by john mcgrath -
Just to say thanks very much -  had the same probelm with flash  - Moodle 1.9.3+ replaced resource.class and worked perfectly - thnanks again
In reply to john mcgrath

Re: Serious Problems with the way view.php handles resources

by ciaran oco -
I echo that - worked great for me too. Thank you
In reply to john mcgrath

Re: Serious Problems with the way view.php handles resources

by ankit garg -
from which file we need to raplace the resource.class can you clear

Thanx in advance
In reply to ankit garg

Re: Serious Problems with the way view.php handles resources

by Ali Hastie -

Hi Ankit

I know this is so last year, go to:

mod/resource/type/file/

Above you will find resource.class.php this is the file you need to replace with the one that is attached within this forum.

Still works with 1.9.10+

Hope it helps.

Ali

Ali

In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm pretty sure this is MDL-14541. We've recently migrated to 1.9.x and have experienced the same trouble with PDF files (we don't have any .swf files in our sites).

We've tried the suggested fix there (it's a one liner!) and have successfully downloaded the problematic PDF files. We still need to check that IE 7.0 on Vista works (have already checked IE 6.0 on XP, FF 2.x and 3.x on XP and Linux) to confirm the proposed fix and commit the change into CVS.

I suspect a very similar issue is causing the .swf files not to download.

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

Hi Iñaki,

I noticed that bug but this is not exactly the same bug. MDL-14541 solves the case for normal pdf resources and I can confirm that it works on Vista (I have one).

The problem that Jon had was that place holder flash was loaded ok but the inner flash file loaded from the same folder was not rendered...

There are several media file types and this situation looks more complicated than single pdf or flash files inside object tags with params...

Attachment flashprb.gif
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -
And this is what it should look like - and what it looks like with file.php... just started to wonder if height of inner flash could shrink to 0px if it is not defined in inner flash... object tags don't necessarely know the height without help of some javascript
Attachment flash2.gif
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

Or current file might have some problems with finding the correct path for inner flash files and we might need to add

param name="base"

when flash files are embedded

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_04157

Jon has good files for testing the bug in http://moodle.org/mod/forum/discuss.php?d=110034

In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Mauno,

thanks a lot for the details. With Jon's files and the Adobe kb article I've added the lines marked below and I can play the flash embedded file as expected. I need to check that this extra parameter doesn't break non-embedded flash files (it shouldn't) before commiting the changes into CVS.

Add them in .../mod/resource/type/file/resource.class.php, around line 640 (1.9.3+ current as of today)

echo '<param name="loop" value="true" />';
echo '<param name="controller" value="true" />';
echo '<param name="scale" value="aspect" />';
echo '<param name="base" value="." />';     # <-------- This is the new line
echo '<!--[if !IE]>-->';
echo "<object type=\"application/x-shockwave-flash\" data=\"$fullurl\">";
echo '<param name="controller" value="true" />';
echo '<param name="autoplay" value="true" />';
echo '<param name="loop" value="true" />';
echo '<param name="scale" value="aspect" />';
echo '<param name="base" value="." />';     # <--------- This is the new line

Could you and Jon check that it actually fixes your problem?

Thanks again for your hard work smile

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Iñaki,

I am out of school today (working at another school for the day), but I will add this edit to my file tomorrow and let you know if it fixes the problem.

Thanks

Jon
In reply to Iñaki Arenaza

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

It does work as expected. Thank you Iñaki! smile

In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Mauno Korpelainen -

Oh, one more thing - it fixed the flash embedding problem but there is something else wrong in the current moodle 1.9.3+ resource.class.php:

Even if you leave setting "Keep page navigation visible on the same page" unchecked (should be like (1) ) the file still shows navigation like when that option is checked (2)... but that't controlled by some other tags.

And description has moved down from navigation but that's another tracker issue - http://tracker.moodle.org/browse/MDL-10021

Attachment example1.gif
In reply to Mauno Korpelainen

Re: Serious Problems with the way view.php handles resources

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm afraid this is beyond the scope of the original bug, and more importantly beyong my knowledge in that area of the code smile.

I suspect that both things (keeping navigation visible and description appearing at the bottom of the page) are related to the changes introduced with MDL-10021, but I haven't reviewed the whole changeset, so I might be wrong.

Saludos. Iñaki.

In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Nancy Webb -

I have a problem with resource link too.  The resource is an external URL, but the URL is a .pdf file.  I want it to open in a new window (it's the lab schedule) but even if it's in the Moodle window the link doesn't work.  There's just a blank space where the pdf would be.  view.php seems to be the problem.  I can force download, but then they are taken out of the Moodle class and beginning students might not know to click the back button to return to the course.

Any way I can just make the resource link open up the actual website instead of using view.php?  Yes, there is a link in the "bad" window to go to the actual file, but why make students work with something that is a bug?

In reply to Nancy Webb

Re: Serious Problems with the way view.php handles resources

by alexis alexander -
I have this same problem, but only on certain computers. I would also appreciate the fix for this.
In reply to Nancy Webb

Re: Serious Problems with the way view.php handles resources

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Installing the latest version of Moodle 1.9 should solve the problem with PDF and flash files. The fix has been included into the new versions.
In reply to Jon Witts

Re: Serious Problems with the way view.php handles resources

by Mike Jackson -

We have Moodle 1.9.3+ (Build: 20081217) and it still seems to have the problem that all old pdf resources are displayed in a new window with an annoying unsizeable "frame" (not sure what it is called, instead of opening a new window that fills properly. We have hundreds of pdf resources that I don't wish to have to go back and fix.

What I would like to be able to do is to have my pdf files open in a new window but not embedded in an html frame. Is there a fix for this, to me, retrograde step?

Suggestions?