Social forum
Autoview Preview for Moodle 2.0
Just checking, but are you using the Course Files Area Repository and Repository File manager on your Moodle 2 as well? If yes, can you check that the Course Files Area is 'enabled and visible' in the repository configuration. The AutoView files must be stored using these plugins, files stored in the Moodle Files DB are unlikely to work.
I still get the exact same results, no slides. One thing that is a bit confusing to me is that in Autoview, it asks for a slide URL, but has me pick a specific slide instead of an entire directory where all the slides are, why is this? Also, which slide should I select since each slide really is a set of 4 each named img00n_x.jpg where n is the slide number and x is 1-4 representing the slide resolution? Again, any help would be greatly appreciated.
= = ==> Mark
The Repository File manager is a port of the Moodle 1.x file manager and still has the same restriction, it's on my task list to add directory selection to the code, but it hasn't been done yet since it isn't a critical feature.
... /repository/coursefilearea/file.php/2/Slides/img001_1.jpg
Error: Database connection failed
It is possible that the database is overloaded or otherwise not running properly.
The site administrator should also check that the database details have been correctly specified in config.php
Warning: mysqli::close() [mysql.close]: Couldn't fetch mysqli in ... /moodle/lib/dml/mysqli_native_moodle_database.php on line 336
/repository/coursefilearea/file.php only contains one call to the Database, which I would not expect to cause a problem.
If you haven't done so already can you also turn up the debug level to developer and see if anything interesting comes out in the server logs.
Can you also let me know exactly which build of Moodle/MySQL you are using.
addSlideSource("en", new ImageSlide("Slides", ".jpg"));
As far as the other info. you asked for goes, here it is:
Moodle: 2.0.3+
MySQL: 5.0.92
Apache: 1.3.41
PHP: 5.2.17
I saw nothing interesting in the logs when I turned on debugging and set the level to developer.
Your sever setup is almost identical to mine, I have a slightly older version of MySQL but that's it.
I have found a small bug in the Repo file manager which causes an escape character to be inserted into the URL if the file chosen is 2 or more levels down within the file hierarchy. However, I don't see the offending escape character in your addSlideSource, so I don't think it is related. However, you can now download a Repo File manager update with this fix in place.
The database error is the most likely immediate cause, although this may merely be a symptom of the real underlying cause. AutoView will encounter the same error when trying to download the images, but the error is usually hidden.
I was hoping that the logs might shown an earlier error leading up to the database error.
The problem is probably in coursefilearea/file.php. There is one point in this file where i'm still using a deprecated method call to access the database, so it's possible this is the culprit. I'm going to try re-writing it and will send you an update once it's done.
Changing the "Use slash arguments" setting doesn't cause the same error to appear on my test system, so I don't think that is related.
I've also made the change to the deprecated database method, however, I don't think this line was ever being reached on your server (or mine), since it would have triggered a message saying that a deprecated method was in use, rather than the actual error you are seeing.
If you feel like making the change anyway, edit repository/coursefilearea/file.php and change the line:
if (count_records_sql($sql)) {to
if ($DB->count_records_sql($sql)) {
Just checking, do you get the database connection error for all files uploaded in the coursefilesarea, or just the .jpg images?
I found this thread on moodle.org.
http://moodle.org/mod/forum/discuss.php?d=167372
which was started by somebody reporting a similar error. It seems like they needed to put a php.ini file into multiple directories within Moodle to get DB access working across Moodle on a hosted setup. Can you try out this test script (suggested by Tim Hunt in the above link) locating it in the repository/coursefilearea/ folder, so that we can establish that the DB access is working from this directory.
<?php $link = mysqli_connect('localhost', 'my_user', 'my_password', 'my_db'); if (!$link) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . mysqli_get_host_info($link) . "\n"; mysqli_close($link); ?>
I made the change to my file.php no avail. Also, it gives the same error for any file I have tried. I have only tried Flash .swf and JPEG .jpg files though, but they both give identical results. Also, it is true that with Moodle 2.0 and the versions of "stuff" that my ISP is using, I actually have to have a php.ini file in any/all directories that access the DB. I wrote a script that copies it to each subdirectory for me because there are soooooo many of them. Going back to the logs, in looking at them and considering the fact that I set Moodle's debug level to Developer, I'm wondering if I was looking at the correct logs. I'm a developer myself and when I set a debug level that high, I usually see more info. than I did in Moodle. Where should I be looking for the debug info.? I looked at both the ISP logs files and ran the Moodle log file reports, but they looked pretty generic to me and not at a "developer" level IMO. Thanks.
PS: The test script which should have been in my earlier message is now included above if you want to give it a try.
I decided to try to help as best I can by doing a little manual debugging myself. The coursefilearea file.php file is blowing up (giving the database error above) at the require_once that I commented out below. With that commented out, it hangs at the next require_once and never comes back; all I see is the "Before 2nd require" on the screen and no error messages or image is displayed. I don't know if that helps any, but I hope so. My MySQL configuration is using sockets if that helps any (this line is in the php.ini files in each subdirectory: mysqli.default_socket = /tmp/mysql5.sock)...
// require_once('../../config.php');
echo "Before 2nd require";
require_once('../../lib/filelib.php');
echo "Before global";
global $DB;
echo "After global";
Can you see what happens if you try to access the /repository/coursefilearea/file.php page through your browser without any path information after the file.php. You should get a message No valid arguments supplied or incorrect server configuration if things are working properly.
Assuming that the above gives you the expected message, I think I now know what is going wrong. This goes back to the 'Use slash arguments' setting. I think I need to add support for this setting into the coursefilearea repository and repo file manager, since the course files area serves out files in the same way as the internal repositories, it will probably need the same fix to work properly on your server.
Can you do one final test, if you attempt to view a file through the repo file manager and then re-write the URL from something like:
http://myhost.org/repository/coursefilearea/file.php/2/img.jpg to http://myhost.org/repository/coursefilearea/file.php?file=/2/img.jpg
If that works then i'll see if I can write a proper fix into the code for the next full release.
I'm still getting the same results. However, I don't know if this is a difference between 2.0.2 and 2.0.3+, but things seem to be working now for Autoview and everything else at this point, if I leave the "Use slash arguments" unchecked. I'm going to do some more testing leaving them off, however, I am happy to keep trying/testing Autoview with them on if that will be of any help to you. Also, I may run across whatever it was that wouldn't work before and have to switch back again anyway.
"Use Slash Arguments" is going to need to stay off with your server set up, so there is no need to do any further testing with this switched on.
I suspect the underlying reason ties in to the fact that you have to have a php.ini file in every directory. When the browser requests the file:
http://mymoodle.org/repository/coursefilearea/file.php/2/myfile.html
I suspect your server is then trying to find a php.ini file in a corresponding local path, eg:
/path/to/moodle/repository/coursefilearea/file.php/2/
Which of course doesn't exist and never will, so the database access fails. Internal Moodle files are served in a very similar way from a different php script, so will probably fail for the same reason.
I have a different error now, not related to slash arguments. In playing with my existing AutoView Activity, I neglected trying to create a new one. The following error appears whenever I try to create a new Autoview Activity (with the 6-13 release):
INSERT INTO mdl_autoview (name,timemodified,course,content,summary,noframe,storage,configfile) VALUES(?,?,?,?,?,?,?,?)
[array (
0 => 'Audio Only - Session 1 Part 1',
1 => 1309376203,
2 => '2',
3 => 'Audio Only - Session 1 Part 1',
4 => '<p>Audio Only - Session 1 Part 1</p>',
5 => 0,
6 => NULL,
7 => 'Audio_Only_-_Session_1_Part_1/config.avx',
)]
- line 394 of /lib/dml/moodle_database.php: dml_write_exception thrown
- line 878 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
- line 920 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
- line 45 of /mod/autoview/lib2.php: call to mysqli_native_moodle_database->insert_record()
- line 67 of /mod/autoview/lib.php: call to autoview_insertrecord()
- line 410 of /course/modedit.php: call to autoview_add_instance()
if (is_null($CFG->autoview_storage_type))
$mainrecord->storage="";
My usual approach to audio only is to create an MP4 or FLV file from the audio (usually with a video track showing the text 'Audio Only') and then use it with one of the regular video plugins. I've never found MP3 to be a very satisfactory solution for reasons you have already discovered.
The flash plugin is supposed to be able to play MP3's, but the Flowplayer 3 flash applet used in AutoView doesn't seem to be able to cope with the MP3's i've tried with it. (Note: The audio plugin for Flowplayer 3 isn't currently included with AutoView, so it won't work at all right now).
If you switch AutoView to use FlowPlayer version 1, then MP3 will work with Flash, but you won't get the ability to move backwards/forwards in the stream until the whole file has downloaded. You can switch to FlowPlayer 1 by putting the following into the JavaScript calls box on the config page:
setFlowPlayerVersion(1);
I've been avoiding using Flash as much as possible because we want to be able to support the iPhone.
The HTML 5 video/audio support is going to be improved in the next AutoView release, the current version won't recognise MP3's, but the next release will. The HTML 5 options are currently disabled by default, but you can enable them by following the instructions here:
http://autoview.autotrain.org/mod/data/view.php?d=1&rid=55&filter=1