PHP line errors in Quiz Review

PHP line errors in Quiz Review

by Chris Harner -
Number of replies: 9
Hello, everyone.  I am using Moodle 1.6.1 and I am getting two specific errors, which appear to be some kind of function that does not exist.  I haven't worked with PHP in a long time, and I couldn't seem to find the answer anywhere in the forums.  Please take a look at them for me:

Warning: print_header_and_tabs(tabs.php) [function.print-header-and-tabs]: failed to open stream: No such file or directory in /srv/www/htdocs/moodle/mod/quiz/report/default.php on line 37

Warning: print_header_and_tabs() [function.include]: Failed opening 'tabs.php' for inclusion (include_path='/usr/share/php') in /srv/www/htdocs/moodle/mod/quiz/report/default.php on line 37

Under that, it says "1 Employee has made 1 Attempt"

I attached a screenshot of the issue.  Any thoughts would be greatly appreciated.  Thank you.
Attachment untitled.JPG
Average of ratings: -
In reply to Chris Harner

Re: PHP line errors in Quiz Review

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It is to do with how you have got PHP configured. In particular the include_path setting. This needs to include '.' in the list of paths.
In reply to Tim Hunt

Re: PHP line errors in Quiz Review

by Chris Harner -
Thanks for the response, Tim.  I also noticed my PHP version is 4.4.0, and I did download the latest package ofo php5 and installed it.  The phpinfo.php file displays that I have the old one still installed and running.  Some of the sites out there look a bit extreme to transfer .php files to .php5 and whatnot.  Any ideas how I could correct this problem without mangling my configurations?

Thanks!
In reply to Chris Harner

Re: PHP line errors in Quiz Review

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It should not matter which version of PHP you are running.

It is the option settings that control how it work that are not quite right. For more information, see http://php.net/manual/en/ini.core.php#ini.include-path
In reply to Tim Hunt

Re: PHP line errors in Quiz Review

by Chris Harner -
I believe I got it to work for now.  Thank you for all of your help.  I added two characters in the default.php file which is located in /moodle/mod/quiz/report.  It was really a simple fix.

On line 37, I changed
include('tabs.php');

to
include('./tabs.php');


Thanks again!
In reply to Chris Harner

Re: PHP line errors in Quiz Review

by Chris Harner -
Update:
I got a similar error when I went to Regrade the quiz (I really didn't want to regrade anything, I was simply clicking around looking for problems that may occur).

/moodle/mod/quiz/report/grading/report.php line 15

I changed:
require_once("editlib.php");

To:
require_once("./editlib.php");

Simply because of the fact that editlib.php is not in the same directory.  So adding "./" to the beginning of the file will make it search in high directories.

Thanks again and hopefully this is useful to someone out there new to PHP.
In reply to Chris Harner

Re: PHP line errors in Quiz Review

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Actually, the proper solution would be to make all these absolute includes, starting with $CFG->dirroot
In reply to Tim Hunt

Re: PHP line errors in Quiz Review

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

I don't understand this.

1- Why did Chris have to change include('tabs.php'); to include('./tabs.php');  and require_once("editlib.php");  To: require_once("./editlib.php"); when things work OK on my Moodle install without having to make those changes? Does Chris have a "special" install?

2- Tim, what do you mean by "the proper solution would be to make all these absolute includes, starting with $CFG->dirroot."

3- In file /moodle/mod/quiz/report/grading/report.php, why do I see 2 apparently different ways to address a library file:

  require_once("editlib.php");
  require_once($CFG->libdir.'/tablelib.php');

Does the second line refer to Tim's "proper solution"? If so, why has it not been implemented in line 1?

Yours confused surprise,

Joseph

In reply to Joseph Rézeau

Re: PHP line errors in Quiz Review

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1. In the screen shot of the error message at the start of this thread, look at the setting of include_path on that server (which is helpfully included in the error message). Compare this to the setting on your server.

3. editlib.php is in the same folder as mod/quiz/report.php, which is the top-level file that is being executed when /moodle/mod/quiz/report/grading/report.php used (think, for a moment, quite how wheird this is, for instance, the include would break if grading/report.php was included by a file in a different folder). Whereas tablelib is in a completely different folder.

2. Once you realise how bizare relative includes are in PHP (see the previous point) you will see why it might be more robust to avoid them.

4. (why has it not been done?) because the poeple who originally wrote the file, and everyone who has used it since, found that this worked, and were not aware of the potential problem. Why have I not fixed it yet? because I wanted to check what the Moodle house style was first. You will find a post from me, seeking clarification, in the general developer forum.