Moodle
  1. Moodle
  2. MDL-28248

Student can not see course page with course completion block

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.3, 2.1.1, 2.2
    • Fix Version/s: 2.0.5, 2.1.2
    • Component/s: Course completion
    • Labels:
    • Testing Instructions:
      Hide

      1. Enable course completion for site and for the course,
      2. Add a "duration" criteria
      3. Add a 'course completion block' on the course page
      4. login as a student and try to open a course page

      Show
      1. Enable course completion for site and for the course, 2. Add a "duration" criteria 3. Add a 'course completion block' on the course page 4. login as a student and try to open a course page
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Reproduced only in 2.0 (2.1 works ok)
      see testing instructions

      Field "courseid" does not exist in table "user_enrolments"
      Stack trace:
      line 508 of /lib/dml/moodle_database.php: dml_exception thrown
      line 1297 of /lib/dml/moodle_database.php: call to moodle_database->where_clause()
      line 93 of /lib/completion/completion_criteria_duration.php: call to moodle_database->get_field()
      line 156 of /lib/completion/completion_criteria_duration.php: call to completion_criteria_duration->get_timeenrolled()
      line 208 of /lib/completion/completion_criteria_completion.php: call to completion_criteria_duration->get_status()
      line 145 of /blocks/completionstatus/block_completionstatus.php: call to completion_criteria_completion->get_status()
      line 280 of /blocks/moodleblock.class.php: call to block_completionstatus->get_content()
      line 232 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
      line 899 of /lib/blocklib.php: call to block_base->get_content_for_output()
      line 951 of /lib/blocklib.php: call to block_manager->create_block_contents()
      line 342 of /lib/blocklib.php: call to block_manager->ensure_content_created()
      line 7 of /theme/base/layout/general.php: call to block_manager->region_has_content()
      line 650 of /lib/outputrenderers.php: call to include()
      line 608 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      line ? of unknownfile: call to core_renderer->header()
      line 1279 of /lib/setuplib.php: call to call_user_func_array()
      line ? of unknownfile: call to bootstrap_renderer->__call()
      line 196 of /course/view.php: call to bootstrap_renderer->header()

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Michael de Raadt added a comment -

            I tried this with 2.0.2, but I wasn't able to replicate it.

            Show
            Michael de Raadt added a comment - I tried this with 2.0.2, but I wasn't able to replicate it.
            Hide
            Marina Glancy added a comment -

            Michael, I forgot to say that there should be activities in the course (changed testing instructions)

            Show
            Marina Glancy added a comment - Michael, I forgot to say that there should be activities in the course (changed testing instructions)
            Hide
            Aaron Barnes added a comment -

            This looks to be an issue with the "duration" Course Completion criteria, I'm looking into a fix now

            Show
            Aaron Barnes added a comment - This looks to be an issue with the "duration" Course Completion criteria, I'm looking into a fix now
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Sorry Aaron, I know this sounds a bit pedantic but could you change the query format from:

             
            return $DB->get_field_sql('
                SELECT
                    eu.timestart
                FROM
                    {user_enrolments} eu
                INNER JOIN
                    {enrol} e
                 ON eu.enrolid = e.id
                WHERE
                    e.courseid = ?
                AND eu.userid = ?
                ',
                array($this->course, $completion->userid)
            );
            

            to:

            return $DB->get_field_sql('
                SELECT eu.timestart
                  FROM {user_enrolments} eu
                  JOIN {enrol} e ON eu.enrolid = e.id
                 WHERE e.courseid = ?
                   AND eu.userid = ?', array($this->course, $completion->userid));
            

            It's 100% the same (but because of the not-needed INNER) and it is more "correct" from a coding style POV (readable, mainly).

            Not critical, but we should try to go that way, IMO. TIA and ciao

            Show
            Eloy Lafuente (stronk7) added a comment - Sorry Aaron, I know this sounds a bit pedantic but could you change the query format from:   return $DB->get_field_sql(' SELECT eu.timestart FROM {user_enrolments} eu INNER JOIN {enrol} e ON eu.enrolid = e.id WHERE e.courseid = ? AND eu.userid = ? ', array($this->course, $completion->userid) ); to: return $DB->get_field_sql(' SELECT eu.timestart FROM {user_enrolments} eu JOIN {enrol} e ON eu.enrolid = e.id WHERE e.courseid = ? AND eu.userid = ?', array($this->course, $completion->userid)); It's 100% the same (but because of the not-needed INNER) and it is more "correct" from a coding style POV (readable, mainly). Not critical, but we should try to go that way, IMO. TIA and ciao
            Hide
            Aaron Barnes added a comment -

            Thanks Eloy, updated with reformatted SQL.

            (new branches)

            Show
            Aaron Barnes added a comment - Thanks Eloy, updated with reformatted SQL. (new branches)
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Integrated, many thanks!

            Note: Funny to see the alias for user_enrolments being "eu", heh!

            Show
            Eloy Lafuente (stronk7) added a comment - Integrated, many thanks! Note: Funny to see the alias for user_enrolments being "eu", heh!
            Hide
            Aaron Barnes added a comment -

            Doh!

            Show
            Aaron Barnes added a comment - Doh!
            Hide
            Rajesh Taneja added a comment -

            Works Great
            Thanks for fixing this Aaron.

            Show
            Rajesh Taneja added a comment - Works Great Thanks for fixing this Aaron.
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

            Show
            Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: