Moodle
  1. Moodle
  2. MDL-34164

Broken graph displayed on quiz results page

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      0. You need a quiz in separate or visible groups mode, with some attempts.

      1. Go to Quiz -> Results -> Grades in the navigation. Make sure the graph at the bottom of the page appears.

      2. Select a group, and make sure there are now two graphs.

      3. Go to Quiz -> Results -> Statistics. Make sure there is a graph at the bottom of the page.

      4. If you can be bothered, disable the GD PHP extension, and make sure the graphs are replaced by a nice message saying that GD is required (rather than just being broken images).

      Show
      0. You need a quiz in separate or visible groups mode, with some attempts. 1. Go to Quiz -> Results -> Grades in the navigation. Make sure the graph at the bottom of the page appears. 2. Select a group, and make sure there are now two graphs. 3. Go to Quiz -> Results -> Statistics. Make sure there is a graph at the bottom of the page. 4. If you can be bothered, disable the GD PHP extension, and make sure the graphs are replaced by a nice message saying that GD is required (rather than just being broken images).
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
    • Rank:
      42500

      Description

      On the quiz results page (/mod/quiz/report.php?id=60&mode=overview) I am seeing a broken image. The image URL is /mod/quiz/report/overview/overviewgraph.php?id=3 When I access that URL directly I get the error "Fatal error: Call to undefined function ImageCreate() in /home/andrew/Desktop/code/moodle/int/master/lib/graphlib.php on line 1420"

      The error is expected as I do not the the GD PHP extension installed. Its not installed by default on Ubuntu. However it would be nice if we could avoid displaying a broken image if its not installed on the server.

        Issue Links

          Activity

          Hide
          Andrew Davis added a comment -

          Turning down priority to trivial.

          Show
          Andrew Davis added a comment - Turning down priority to trivial.
          Hide
          Tim Hunt added a comment -

          I thought GD was required to install Moodle?

          Show
          Tim Hunt added a comment - I thought GD was required to install Moodle?
          Hide
          Andrew Davis added a comment -

          Its recommended but not required.

          Show
          Andrew Davis added a comment - Its recommended but not required.
          Hide
          Tim Hunt added a comment -

          Ah, I see, in report/stats there is code like

          if (empty($CFG->gdversion)) {
              echo "(".get_string("gdneed").")";
          } else {
              // ...
          }
          

          I will make a similar change in the quiz reports.

          Show
          Tim Hunt added a comment - Ah, I see, in report/stats there is code like if (empty($CFG->gdversion)) { echo "(" .get_string( "gdneed" ). ")" ; } else { // ... } I will make a similar change in the quiz reports.
          Hide
          Dan Poltawski added a comment -

          I suppose this GD requirement probably prevents Moodle from being installed on cheap hosts, but I increasingly think we should make it a requirement. (Especially for the 2.3 thumbnail generation)

          Show
          Dan Poltawski added a comment - I suppose this GD requirement probably prevents Moodle from being installed on cheap hosts, but I increasingly think we should make it a requirement. (Especially for the 2.3 thumbnail generation)
          Hide
          Dan Poltawski added a comment -

          I have created MDL-34331 for making GD a requirement.

          Show
          Dan Poltawski added a comment - I have created MDL-34331 for making GD a requirement.
          Hide
          Dan Poltawski added a comment -

          Thanks Tim, this has been integrated now.

          Show
          Dan Poltawski added a comment - Thanks Tim, this has been integrated now.
          Hide
          Michael de Raadt added a comment -

          Test result: Success!

          Tested in 2.2, 2.3 and Master.

          With GD off, the graphs were replaced by the same text as the heading above rather than an error message. I suppose that's not critical, but I thought you might want to know. I will attach a screenshot.

          Show
          Michael de Raadt added a comment - Test result: Success! Tested in 2.2, 2.3 and Master. With GD off, the graphs were replaced by the same text as the heading above rather than an error message. I suppose that's not critical, but I thought you might want to know. I will attach a screenshot.
          Hide
          Tim Hunt added a comment -

          That screen grab looks wrong. What you are seeing there is the web browser failing to display the image, and so displaying the alt text instead.

          What you should see if the lang string gdneed.

          I suspect the reason for this is that the text Moodle uses to see if gd is installed is to check $CFG->gdversion. I guess Moodle works that out on install/upgrade, and then uses the cached value. To really test this, perhaps you need to disable gd, and then delete the gdversion row from the config table?

          Show
          Tim Hunt added a comment - That screen grab looks wrong. What you are seeing there is the web browser failing to display the image, and so displaying the alt text instead. What you should see if the lang string gdneed. I suspect the reason for this is that the text Moodle uses to see if gd is installed is to check $CFG->gdversion. I guess Moodle works that out on install/upgrade, and then uses the cached value. To really test this, perhaps you need to disable gd, and then delete the gdversion row from the config table?
          Hide
          Dan Poltawski added a comment -

          *Notice*: Undefined variable: friendlyintegrator in /Users/danp/git/tokenintegrationthanks.php on line 26

          Congratulations

          {tracker.user.name}

          !

          You've made into Moodle

          {tracker.fixversion-1}

          +

          I would like to personally thank you for this contribution on behalf of all Moodle users throughout the world.

          cheers!

          {tracker.friendlyintegrator}
          Show
          Dan Poltawski added a comment - * Notice *: Undefined variable: friendlyintegrator in /Users/danp/git/tokenintegrationthanks.php on line 26 Congratulations {tracker.user.name} ! You've made into Moodle {tracker.fixversion-1} + I would like to personally thank you for this contribution on behalf of all Moodle users throughout the world. cheers! {tracker.friendlyintegrator}
          Hide
          Ryan Smith added a comment -

          I've updated to the latest 2.3.1 release that contains this fix. I'm still seeing the problem. I'm running PHP 5.4.5 (GD is enabled, of course) and I see the alt text displayed and no image.

          Show
          Ryan Smith added a comment - I've updated to the latest 2.3.1 release that contains this fix. I'm still seeing the problem. I'm running PHP 5.4.5 (GD is enabled, of course) and I see the alt text displayed and no image.
          Hide
          Tim Hunt added a comment -

          If you look at this bug closely you will see that it says Fix version/s: 2.3.2, so it should not come as a surprise that it is still broken in 2.3.1.

          Show
          Tim Hunt added a comment - If you look at this bug closely you will see that it says Fix version/s: 2.3.2, so it should not come as a surprise that it is still broken in 2.3.1.
          Hide
          Ryan Smith added a comment -

          The fix was added to MOODLE_23_STABLE 8 days ago:

          http://git.moodle.org/gw?p=moodle.git;a=commit;h=8242298e4b962d3d92776a6c96d0f41353a62ccb

          The latest weekly update to Moodle 2.3.1 came out 5 days ago, which contains the files modified by this fix:

          http://git.moodle.org/gw?p=moodle.git;a=commit;h=04de7affb6f43aaea6f14e1d25ed9872860bb430

          I update to the latest weekly each weekend.

          Show
          Ryan Smith added a comment - The fix was added to MOODLE_23_STABLE 8 days ago: http://git.moodle.org/gw?p=moodle.git;a=commit;h=8242298e4b962d3d92776a6c96d0f41353a62ccb The latest weekly update to Moodle 2.3.1 came out 5 days ago, which contains the files modified by this fix: http://git.moodle.org/gw?p=moodle.git;a=commit;h=04de7affb6f43aaea6f14e1d25ed9872860bb430 I update to the latest weekly each weekend.
          Hide
          Tim Hunt added a comment -

          In that case you are running a 2.3.1+ build. The distinction is somewhat pedantic, but that sort of precision is important when reporting bugs.

          If you have GD, then actually this bug is probably not related to what you are seeing.

          Anyway, what you need to do to diagnose this further is:

          1. Set http://docs.moodle.org/23/en/Debugging to DEVELOPER level.

          2. Go to the quiz reports, right click on the broken image, and do Open in new tab.

          3. If that displays error messages on-screen, then copy and paste them to this bug, or to a new bug report, if that seems more relevant.

          4. If you get a message about the image being corrupted, then save it to disc, rename it to .txt, open it in a text editor, and copy and paste the error messages.

          Show
          Tim Hunt added a comment - In that case you are running a 2.3.1+ build. The distinction is somewhat pedantic, but that sort of precision is important when reporting bugs. If you have GD, then actually this bug is probably not related to what you are seeing. Anyway, what you need to do to diagnose this further is: 1. Set http://docs.moodle.org/23/en/Debugging to DEVELOPER level. 2. Go to the quiz reports, right click on the broken image, and do Open in new tab. 3. If that displays error messages on-screen, then copy and paste them to this bug, or to a new bug report, if that seems more relevant. 4. If you get a message about the image being corrupted, then save it to disc, rename it to .txt, open it in a text editor, and copy and paste the error messages.
          Hide
          Ryan Smith added a comment -

          Sorry, yes, 2.3.1+.

          When the report page is visited, the error log displays:

          [Tue Jul 24 09:40:47 2012] [error] [client x.x.x.x] Premature end of script headers: overviewgraph.php, referer: http://www.website.com/moodle/mod/quiz/report.php?id=99845&mode=overview

          Right clicking on the broken image and viewing the image results in a 500 Internal Server Error on the page:

          http://www.website.com/moodle/mod/quiz/report/overview/overviewgraph.php?id=7175

          I also just tested on a clean install of Moodle 2.3.1+ and the error still occurs.

          Should I file a new bug report?

          Show
          Ryan Smith added a comment - Sorry, yes, 2.3.1+. When the report page is visited, the error log displays: [Tue Jul 24 09:40:47 2012] [error] [client x.x.x.x] Premature end of script headers: overviewgraph.php, referer: http://www.website.com/moodle/mod/quiz/report.php?id=99845&mode=overview Right clicking on the broken image and viewing the image results in a 500 Internal Server Error on the page: http://www.website.com/moodle/mod/quiz/report/overview/overviewgraph.php?id=7175 I also just tested on a clean install of Moodle 2.3.1+ and the error still occurs. Should I file a new bug report?
          Hide
          Tim Hunt added a comment -

          I am not sure this is a Moodle problem as such. Try googling that error message. E.g. http://htmlfixit.com/cgi-tutes/tutorial_Common_Web_dev_error_messages_and_what_they_mean.php#premature

          Also, try some of the other places in Moodle that output graphs, do any of them work?

          Show
          Tim Hunt added a comment - I am not sure this is a Moodle problem as such. Try googling that error message. E.g. http://htmlfixit.com/cgi-tutes/tutorial_Common_Web_dev_error_messages_and_what_they_mean.php#premature Also, try some of the other places in Moodle that output graphs, do any of them work?
          Hide
          Ryan Smith added a comment -

          Yes, the graphs on all of the activity reports work fine. Graphs in the statistic reports also work correctly.

          I did some more testing on my test VM and the problem occurs with PHP 5.4.5. I rolled back to PHP 5.3.15 and the graphs display correctly.

          Show
          Ryan Smith added a comment - Yes, the graphs on all of the activity reports work fine. Graphs in the statistic reports also work correctly. I did some more testing on my test VM and the problem occurs with PHP 5.4.5. I rolled back to PHP 5.3.15 and the graphs display correctly.
          Hide
          Matthew Davidson added a comment -

          After some testing, the problem seems to be with the line in reportlib.php, function quiz_report_grade_bands():

          unset($data[$bands]);

          There is definitely a PHP 5.4 issue here. I have made a small script to show this issue. I'll submit it to PHP to get this fixed. It has something to do with how $bands or $foo in this case is cast. It starts as a string, then becomes a double, but something is wrong with it because if you cast the variable as anything the unset() statement will work as intended. Event casting it as a double works:

          $test = array("5"=>"bar");
          $foo = "10.0000"; // gettype($foo) = "string"
          $foo /= 2; //Makes $foo = 5 but still gettype($foo) = "double"
          echo gettype($foo);
          unset($test[$foo]);

          However, if Moodle would like to be proactive in this, it could be fixed on your end by casting the variable $bands like so...

          unset($data[(int) $bands]);

          Show
          Matthew Davidson added a comment - After some testing, the problem seems to be with the line in reportlib.php, function quiz_report_grade_bands(): unset($data [$bands] ); There is definitely a PHP 5.4 issue here. I have made a small script to show this issue. I'll submit it to PHP to get this fixed. It has something to do with how $bands or $foo in this case is cast. It starts as a string, then becomes a double, but something is wrong with it because if you cast the variable as anything the unset() statement will work as intended. Event casting it as a double works: $test = array("5"=>"bar"); $foo = "10.0000"; // gettype($foo) = "string" $foo /= 2; //Makes $foo = 5 but still gettype($foo) = "double" echo gettype($foo); unset($test [$foo] ); However, if Moodle would like to be proactive in this, it could be fixed on your end by casting the variable $bands like so... unset($data [(int) $bands] );
          Hide
          Tim Hunt added a comment -

          Excellent analysis. Thank you. Please could someone open a new issue for this.

          Show
          Tim Hunt added a comment - Excellent analysis. Thank you. Please could someone open a new issue for this.
          Hide
          Ryan Smith added a comment -

          Tim, are we waiting on a Moodle developer to open a new issue? Or should we go ahead and make a new issue?

          This is a critical bug for those running a server on Windows with an Apache/mod_php configuration(the most common). Every time a quiz results page is visited, Apache crashes with a "Parent: child process exited with status 255 – Restarting." error.

          Show
          Ryan Smith added a comment - Tim, are we waiting on a Moodle developer to open a new issue? Or should we go ahead and make a new issue? This is a critical bug for those running a server on Windows with an Apache/mod_php configuration(the most common). Every time a quiz results page is visited, Apache crashes with a "Parent: child process exited with status 255 – Restarting." error.
          Hide
          Tim Hunt added a comment -

          Well, someone needs to create the issue. It does not matter who. I was hoping someone else would do it, but actually, I will do it now.

          Show
          Tim Hunt added a comment - Well, someone needs to create the issue. It does not matter who. I was hoping someone else would do it, but actually, I will do it now.
          Hide
          Tim Hunt added a comment -

          MDL-34589 now created.

          Show
          Tim Hunt added a comment - MDL-34589 now created.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: