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

Course report - participation report, breaks when selecting some English letter from the "First Name" filter

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.5, 2.1.2, 2.2
    • Fix Version/s: 2.0.6, 2.1.3
    • Component/s: Course, Logging, Reports
    • Labels:
      None
    • Testing Instructions:
      Hide

      1/ Create a course with 30 students enrolled
      2/ Do some activity
      3/ Go to course admin ► Reports ► Participation report
      4/ Display some participation records by choosing appropiate options
      5/ Filter results by firstname

      Expected result
      ------------------
      Results are displayed filtered by firstname

      Actual result
      --------------
      SQL error

      Show
      1/ Create a course with 30 students enrolled 2/ Do some activity 3/ Go to course admin ► Reports ► Participation report 4/ Display some participation records by choosing appropiate options 5/ Filter results by firstname Expected result ------------------ Results are displayed filtered by firstname Actual result -------------- SQL error
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:

      Description

      I was getting an SQL error:

      Debug info: Unknown column 'firstname' in 'where clause'
      SELECT COUNT(DISTINCT(ra.userid))
      FROM mdl_role_assignments ra
       
      WHERE ra.contextid IN (661,2524,1) AND ra.roleid = ? AND firstname LIKE ? ESCAPE '\\'
      [array (
      0 => 16,
      1 => 'A%',
      )]
      Stack trace:
      line 394 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 794 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 1280 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
      line 1355 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
      line 1526 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
      line 232 of /course/report/participation/index.php: call to moodle_database->count_records_sql()

      by added the line "JOIN

      {user} u ON u.id = ra.userid" just after line 225 that is : "FROM {role_assignments} ra"
      Issue was solved

      see full code at line 224:

       

      $countsql = "SELECT COUNT(DISTINCT(ra.userid))
      FROM {role_assignments} ra
      JOIN {user}

      u ON u.id = ra.userid
      WHERE ra.contextid $relatedcontexts AND ra.roleid = :roleid";

       

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  28/Nov/11