Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-3876

Viewing answer in choice gives a fatal error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5.2
    • Fix Version/s: None
    • Component/s: Choice
    • Labels:
      None
    • Environment:
      Linux
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_15_STABLE

      Description

      I have a choice which is not open yet. When I click view responses and then choose a group for displaying which has no students in it, I get the following error:

      Fatal error: Unsupported operand types in /var/www/moodle/mod/choice/report.php on line 44

      The URL at which this happens is:

      mymoodle/mod/choice/report.php?id=1457&group=103

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            dougiamas Martin Dougiamas added a comment -

            From Dan Marsden (dan at digitalclay.co.nz) Monday, 15 August 2005, 05:46 AM:

            This is related to MDL-3816 - use the fix mentioned in the discussion form, also find this line in report.php:

            if (!$users)

            { print_heading(get_string(nousersyet)); print_footer($course); exit; }

            either comment out or remove exit; - this makes the error slightly tidier....

            -I'll try to get this fix in later today.

            Dan

            From Dan Marsden (dan at digitalclay.co.nz) Monday, 15 August 2005, 06:25 AM:

            fix now in head and 1.5_stable

            From Piotr Gas (gason at agh.edu.pl) Friday, 7 October 2005, 07:53 PM:

            This problem appears only when someone try to view/report choice of empty group.

            It is quite easy to solve - results from get_* functions should be cast to array type.

            Old code of report.php:

            mod/choice/report.php, line 43

            if ($currentgroup)

            { $users = get_group_users($currentgroup, u.firstname ASC, '', 'u.id, u.picture, }

            else

            { $users = get_course_users($course->id, u.firstname ASC, '', 'u.id, u.picture, u }

            New code of report.php:

            mod/choice/report.php, line 43

            if ($currentgroup)

            { $users = (array) get_group_users($currentgroup, u.firstname ASC, '', 'u.id, u.picture, }

            else

            { $users = (array) get_course_users($course->id, u.firstname ASC, '', 'u.id, u.picture, u }

            The same patch should be applied in mod/choice/view.php file (line 243).

            Of course it's also possible change get_* functions instead applied above patch.

            best regards

            Gason

            From Dan Marsden (dan at digitalclay.co.nz) Monday, 10 October 2005, 03:31 AM:

            Hi Gason,

            thanks for the details, if you have access to cvs, go ahead and commit the fix! - If you don't, I'll test it, and commit it.

            I want to move a lot more of the processing of these 2 files into functions in lib.php - I need to for the choice block to work - I've got a beta version of it working, but haven't had a chance to look at it recently!

            thanks,

            Dan

            From Dan Marsden (dan at digitalclay.co.nz) Friday, 7 April 2006, 04:43 AM:

            this should now be fine, due to other fixes made to the code in HEAD - feel free to repoen if still having difficulty

            Show
            dougiamas Martin Dougiamas added a comment - From Dan Marsden (dan at digitalclay.co.nz) Monday, 15 August 2005, 05:46 AM: This is related to MDL-3816 - use the fix mentioned in the discussion form, also find this line in report.php: if (!$users) { print_heading(get_string(nousersyet)); print_footer($course); exit; } either comment out or remove exit; - this makes the error slightly tidier.... -I'll try to get this fix in later today. Dan From Dan Marsden (dan at digitalclay.co.nz) Monday, 15 August 2005, 06:25 AM: fix now in head and 1.5_stable From Piotr Gas (gason at agh.edu.pl) Friday, 7 October 2005, 07:53 PM: This problem appears only when someone try to view/report choice of empty group. It is quite easy to solve - results from get_* functions should be cast to array type. Old code of report.php: — mod/choice/report.php, line 43 if ($currentgroup) { $users = get_group_users($currentgroup, u.firstname ASC, '', 'u.id, u.picture, } else { $users = get_course_users($course->id, u.firstname ASC, '', 'u.id, u.picture, u } — New code of report.php: — mod/choice/report.php, line 43 if ($currentgroup) { $users = (array) get_group_users($currentgroup, u.firstname ASC, '', 'u.id, u.picture, } else { $users = (array) get_course_users($course->id, u.firstname ASC, '', 'u.id, u.picture, u } — The same patch should be applied in mod/choice/view.php file (line 243). Of course it's also possible change get_* functions instead applied above patch. best regards Gason From Dan Marsden (dan at digitalclay.co.nz) Monday, 10 October 2005, 03:31 AM: Hi Gason, thanks for the details, if you have access to cvs, go ahead and commit the fix! - If you don't, I'll test it, and commit it. I want to move a lot more of the processing of these 2 files into functions in lib.php - I need to for the choice block to work - I've got a beta version of it working, but haven't had a chance to look at it recently! thanks, Dan From Dan Marsden (dan at digitalclay.co.nz) Friday, 7 April 2006, 04:43 AM: this should now be fine, due to other fixes made to the code in HEAD - feel free to repoen if still having difficulty

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: