Error when trying to access course categories under Add/Edit Courses

Error when trying to access course categories under Add/Edit Courses

by Jamie Pruden -
Number of replies: 4
Hi all,

We recently upgraded to 1.7.1+ and are having an odd error when trying to access the Course Categories under Add/Edit Courses in the Admin area.

I get the following error at the top of the page:

Warning: Division by zero in F:\moodle\moodle\lib\weblib.php on line 4904

followed by "Page: (Next)" (next is hyperlinked to the current page)

followed by:

Warning: Division by zero in F:\moodle\moodle\course\category.php on line 299

I am able to edit courses and do everything else I would normally do in this area, but I would really like to know what's going on that is causing the error.

In both places in the source code, there is a reference to something called

"ceil($totalcount / $perpage)"

Line 4904 from weblib.php
$lastpage = ceil($totalcount / $perpage);
Line 299 from category.php
$atlastpage = (($page + 1) == ceil($totalcount / $perpage));

So I'm thinking that this is causing the problem, but I'm not much of a PHP programmer to do the tracing to see what's the problem.

Any ideas?

thanks,
Jamie

Average of ratings: -
In reply to Jamie Pruden

Re: Error when trying to access course categories under Add/Edit Courses

by James Bond -
I get the same error! Please fix!
In reply to Jamie Pruden

Re: Error when trying to access course categories under Add/Edit Courses

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
It appears that a record is not being added to the mdl_config table during the installation. I will look into getting this fixed - it is reported as MDL-7425. The quick fix is simply to use phpmyadmin or a similar tool and insert the record manually using:

INSERT INTO mdl_config (name, value)
VALUES ('coursesperpage',20);

After that, the problem should go away. If not let me know and I will keep digging through the code. Peace - Anthony
In reply to Anthony Borrow

Re: Error when trying to access course categories under Add/Edit Courses

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
As I looked further - this is a frontpage setting. So if you go to the Site Administration block and click on the Frontpage link and the the Frontpage Settings link you should see near the bottom of the page a place to enter the number of courses per page that you wish to see. The default is 20. Save changes and the problem should be fixed without having to mess with any sql queries or phpmyadmin. Peace - Anthony