Moodle
  1. Moodle
  2. MDL-26599

Mod Quiz Edit incorrectly rendering HTML layout

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.2
    • Fix Version/s: None
    • Component/s: Quiz
    • Labels:
    • Environment:
      Ubuntu 10.10, Apache, Postgres
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      16188

      Description

      Using the current release Moodle 2.0.2+ (Build: 20110223) create a new course with no quiz bank available. Create a quiz and enter as a teacher. After the redirect to mod-quiz-edit the HTML of the page will be incorrectly rendered in several areas including region-pre and footer.

      Here's the normal flow for .side-pre-only:

      page-content
        region-main-box
          region-post-box
            region-main
            region-pre
          -region-post-box
        -region-main-box
      -page-content
      

      and here's what's happening on #page-mod-quiz-edit

      page-content
        region-main-box
          region-post-box
            region-main
              region-content
              region-pre
            -region-main
          -region-post-box
        -region-main-box
      -page-content
      

      Side-pre has been nested in region-main rather than following it. The basic layout on every page looks like this:

      page
        page-header
        page-content
        page-footer
      -page
      

      but on the quiz page it looks like this:

      page
        page-header
        page-content
          region-main-box
          page-footer
        -page-content
      -page
      

      you can see that page-footer gets nested inside of page-content for some reason rather than following it. This bug affects core Moodle Themes Base and Standard, and I am assuming others.

      For more information see original thread here: http://moodle.org/mod/forum/discuss.php?d=169640

      1. edit.php.html
        165 kB
        Daniel Wahl
      1. base-mod-lesson--continue.jpg
        107 kB
      2. base-mod-lesson--edit.jpg
        111 kB
      3. line128.png
        60 kB
      4. Screen shot 2011-02-26 at 7.58.44 AM.png
        162 kB

        Activity

        Hide
        Tim Hunt added a comment -

        This is very odd. I am looking at the edit.php page of a newly created quiz in my Moodle 2.0.2+ dev install, and the HTML is correctly nested. Why is it working for me, and not you? I don't understand.

        Show
        Tim Hunt added a comment - This is very odd. I am looking at the edit.php page of a newly created quiz in my Moodle 2.0.2+ dev install, and the HTML is correctly nested. Why is it working for me, and not you? I don't understand.
        Hide
        Mary Evans added a comment -

        I'm so pleased this problem has come to light in the page-layout as used by base theme. I had the same problem in a theme I was working on last year, but because I was using another page-layout which was different than base page-layout I felt it was my theme that was the problem, and left it at that.

        This find of Daniel is wonderful, because it means that my original layout is not the problem!
        I've have attached two screen shots of the problem I had originally, but this time recreated it in Base theme. A point to notice is that this strange behaviour is in Lesson and not Quiz. This suggests to me that the problem is much wider than you may imagine.

        I'll be watching this MDL-26599 with interest.

        Show
        Mary Evans added a comment - I'm so pleased this problem has come to light in the page-layout as used by base theme. I had the same problem in a theme I was working on last year, but because I was using another page-layout which was different than base page-layout I felt it was my theme that was the problem, and left it at that. This find of Daniel is wonderful, because it means that my original layout is not the problem! I've have attached two screen shots of the problem I had originally, but this time recreated it in Base theme. A point to notice is that this strange behaviour is in Lesson and not Quiz. This suggests to me that the problem is much wider than you may imagine. I'll be watching this MDL-26599 with interest.
        Hide
        Mary Evans added a comment -

        This view shows the actual pagelayout useing FireBug note the strage nesting of region-main and region-pre inside region-main-wrap.
        Version: Moodle 2.0.2 (02242011)
        Path: moodle/mod/lesson/continue.php

        Show
        Mary Evans added a comment - This view shows the actual pagelayout useing FireBug note the strage nesting of region-main and region-pre inside region-main-wrap. Version: Moodle 2.0.2 (02242011) Path: moodle/mod/lesson/continue.php
        Hide
        Mary Evans added a comment -

        This view is of the same lesson but in edit view. This is how it should look. Note again the page-layout as seen using FireBug. Here region-main-wrap and region-pre are nested correctly inside region-post-box.

        Version: Moodle 2.0.2 (02242011)
        Path: moodle/mod/lesson/edit.php

        Show
        Mary Evans added a comment - This view is of the same lesson but in edit view. This is how it should look. Note again the page-layout as seen using FireBug. Here region-main-wrap and region-pre are nested correctly inside region-post-box. Version: Moodle 2.0.2 (02242011) Path: moodle/mod/lesson/edit.php
        Hide
        Tim Hunt added a comment -

        OK, so it definitely happens, but only intermittently.

        Bugs like that tend to be a real pain in the bum. The most useful contribution someone can make is to find a reliable way to reproduce the problem.

        Show
        Tim Hunt added a comment - OK, so it definitely happens, but only intermittently. Bugs like that tend to be a real pain in the bum. The most useful contribution someone can make is to find a reliable way to reproduce the problem.
        Hide
        Daniel Wahl added a comment -

        This is a screenshot of the footer being nested. Even though the current theme isn't 'base' the layout is from base.

        Show
        Daniel Wahl added a comment - This is a screenshot of the footer being nested. Even though the current theme isn't 'base' the layout is from base.
        Hide
        Daniel Wahl added a comment -

        Possibly since Mary can reproduce this in mod lesson edit, then it's not the renderer + quiz it's something in path-mod-*-edit

        I will try to get some sort of solid way to reproduce this, and look at other activity edit types. Tim on your setup did you have an empty question bank when you created the quiz?

        Show
        Daniel Wahl added a comment - Possibly since Mary can reproduce this in mod lesson edit, then it's not the renderer + quiz it's something in path-mod-*-edit I will try to get some sort of solid way to reproduce this, and look at other activity edit types. Tim on your setup did you have an empty question bank when you created the quiz?
        Hide
        Tim Hunt added a comment -

        I probably did have content in the question bank, but I have just tried a brand new course, in standard theme, and I still can't reproduce it.

        Show
        Tim Hunt added a comment - I probably did have content in the question bank, but I have just tried a brand new course, in standard theme, and I still can't reproduce it.
        Hide
        Mary Evans added a comment -

        I found that by changing incourse => array(),
        from
        // part of course, typical for modules - default page layout if $cm specified in require_login()
        'incourse' => array(
        'file' => 'general.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-post',
        ),

        to

        // part of course, typical for modules - default page layout if $cm specified in require_login()
        'incourse' => array(
        'file' => 'general.php',
        'regions' => array(),
        ),

        in config.php for base theme, fixed the problem in base theme, but I am not sure what repercussions this would have on other incourse pages, or themes in general.

        Interestingly enough, although the setting for incourse => array() in config.php as it is at present in base theme, shows 'side-post' as the default, and yet in the lesson page continue.php it actually shows side-pre-only as a body class as the page-layout for this page. So were else would page-layout for incourse pages be defind other than in a theme's config.php?

        Show
        Mary Evans added a comment - I found that by changing incourse => array(), from // part of course, typical for modules - default page layout if $cm specified in require_login() 'incourse' => array( 'file' => 'general.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-post', ), to // part of course, typical for modules - default page layout if $cm specified in require_login() 'incourse' => array( 'file' => 'general.php', 'regions' => array(), ), in config.php for base theme, fixed the problem in base theme, but I am not sure what repercussions this would have on other incourse pages, or themes in general. Interestingly enough, although the setting for incourse => array() in config.php as it is at present in base theme, shows 'side-post' as the default, and yet in the lesson page continue.php it actually shows side-pre-only as a body class as the page-layout for this page. So were else would page-layout for incourse pages be defind other than in a theme's config.php?
        Hide
        Sam Hemelryk added a comment -

        Just adding code tags around the classes so I could see the nesting

        Show
        Sam Hemelryk added a comment - Just adding code tags around the classes so I could see the nesting
        Hide
        Sam Hemelryk added a comment -

        Hi guys,
        I've been able to reproduce this error.
        The following is the start of the source code for a page that I reproduced the error on:

        </div><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
        <html  dir="ltr" lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
        <head> 
            <title>ART: This is a lesson</title> 
        

        Pretty obvious that the div right at the start is out of place, my guess is that there is an echo in the core renderer somewhere and it should be collected for return.
        I have a meeting right now but will investigate shortly.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Hi guys, I've been able to reproduce this error. The following is the start of the source code for a page that I reproduced the error on: </div> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > <html dir= "ltr" lang= "en" xml:lang= "en" xmlns= "http://www.w3.org/1999/xhtml" > <head> <title> ART: This is a lesson </title> Pretty obvious that the div right at the start is out of place, my guess is that there is an echo in the core renderer somewhere and it should be collected for return. I have a meeting right now but will investigate shortly. Cheers Sam
        Hide
        Tim Hunt added a comment -

        Doh! so obvious when you point it out. Welcome back Sam, and good luck on your </div> hunt.

        Show
        Tim Hunt added a comment - Doh! so obvious when you point it out. Welcome back Sam, and good luck on your </div> hunt.
        Hide
        Sam Hemelryk added a comment -

        Alright the one in the lesson module was specific to the lesson module, you can checkout the fix at https://github.com/samhemelryk/moodle/commit/9e9989d19c66b33147c8027d11a2ce0f51d76f2d

        This means the quiz problem is something separate, I'll have a quick look there now.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Alright the one in the lesson module was specific to the lesson module, you can checkout the fix at https://github.com/samhemelryk/moodle/commit/9e9989d19c66b33147c8027d11a2ce0f51d76f2d This means the quiz problem is something separate, I'll have a quick look there now. Cheers Sam
        Hide
        Daniel Wahl added a comment -

        Well I just went back to look at the quiz, and I don't see the closed div at the top, but I did turn on debugging and now I'm seeing this error:

        
        

        Debug info: ERROR: invalid input syntax for integer: ""
        SELECT q.*,c.contextid
        FROM mdl_question q,
        mdl_question_categories c
        WHERE q.id IN ($1,$2)
        AND q.category = c.id
        [array (
        0 => '',
        1 => '0',
        )]
        Stack trace:

        line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown
        line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
        line 672 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
        line 358 of /mod/quiz/editlib.php: call to pgsql_native_moodle_database->get_records_sql()
        line 518 of /mod/quiz/edit.php: call to quiz_print_question_list()

        {/code}

        so maybe this is what's setting off the problem...

        Show
        Daniel Wahl added a comment - Well I just went back to look at the quiz, and I don't see the closed div at the top, but I did turn on debugging and now I'm seeing this error: Debug info: ERROR: invalid input syntax for integer: "" SELECT q.*,c.contextid FROM mdl_question q, mdl_question_categories c WHERE q.id IN ($1,$2) AND q.category = c.id [array ( 0 => '', 1 => '0', )] Stack trace: line 391 of /lib/dml/moodle_database.php: dml_read_exception thrown line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end() line 672 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end() line 358 of /mod/quiz/editlib.php: call to pgsql_native_moodle_database->get_records_sql() line 518 of /mod/quiz/edit.php: call to quiz_print_question_list() {/code} so maybe this is what's setting off the problem...
        Hide
        Sam Hemelryk added a comment -

        Hi Daniel I was just writing a message to you
        That error that you are seeing would do it as its interrupting the page output immediately where the error occurs.
        I've just been trying to replicate this issue and have been unsuccessful however looking at the bit of code around the error you get I can see that it doesn't affect MySQL which I am using on my present system. I'm guessing it is a bug with the bit of code in editlib.php which is exploding ''`,0'' to get a list of id's.
        Tim probably best if you investigate that area. Yell out if there is anything more I can do to help.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Hi Daniel I was just writing a message to you That error that you are seeing would do it as its interrupting the page output immediately where the error occurs. I've just been trying to replicate this issue and have been unsuccessful however looking at the bit of code around the error you get I can see that it doesn't affect MySQL which I am using on my present system. I'm guessing it is a bug with the bit of code in editlib.php which is exploding ''`,0'' to get a list of id's. Tim probably best if you investigate that area. Yell out if there is anything more I can do to help. Cheers Sam
        Hide
        Mary Evans added a comment -

        Welcome back Sam...I believe CONGRATULATIONS are in order!

        Thanks for fixing this BUG in the Lesson module.

        Brilliant find!
        Cheers
        Mary

        Show
        Mary Evans added a comment - Welcome back Sam...I believe CONGRATULATIONS are in order! Thanks for fixing this BUG in the Lesson module. Brilliant find! Cheers Mary
        Hide
        Tim Hunt added a comment -

        I just did a search for

        echo\s*['"]</div>['"]
        and
        echo.*end_tag.*div

        Which should find all the places that output a close div tag on its own, and I can't find any of those that might affect the quiz. Can anyone reproduce the quiz issue? (If you can please validate the HTML and find out specifically where the error is.)

        Assigning to Sam, so he can do a pull request for his fix.

        Show
        Tim Hunt added a comment - I just did a search for echo\s* ['"] </div> ['"] and echo.*end_tag.*div Which should find all the places that output a close div tag on its own, and I can't find any of those that might affect the quiz. Can anyone reproduce the quiz issue? (If you can please validate the HTML and find out specifically where the error is.) Assigning to Sam, so he can do a pull request for his fix.
        Hide
        Daniel Wahl added a comment - - edited

        improperly nested footer source with debugging turned on. The w3c validator really doesn't like this if you try to validate it just as 4.01 transitional instead of xhtml 1.0 strict.

        Show
        Daniel Wahl added a comment - - edited improperly nested footer source with debugging turned on. The w3c validator really doesn't like this if you try to validate it just as 4.01 transitional instead of xhtml 1.0 strict.
        Hide
        Daniel Wahl added a comment -

        I think I found the offending div closing tab. It's on line 128 of the attached edit.php.html. Attached is a screenshot in gphpedit with the parent divs collapsed

        Show
        Daniel Wahl added a comment - I think I found the offending div closing tab. It's on line 128 of the attached edit.php.html. Attached is a screenshot in gphpedit with the parent divs collapsed
        Hide
        Sam Hemelryk added a comment -

        Created PULL-637 and PULL-638 to see the lesson patch integrated.

        Show
        Sam Hemelryk added a comment - Created PULL-637 and PULL-638 to see the lesson patch integrated.
        Hide
        Tim Hunt added a comment -

        Closing this as cannot reproduce.

        Show
        Tim Hunt added a comment - Closing this as cannot reproduce.

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: