Moodle
  1. Moodle
  2. MDL-29045

Duplicate "course" ITEMTYPE in the GRADE_ITEMS table

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0.3
    • Fix Version/s: STABLE backlog
    • Component/s: Backup, Gradebook
    • Labels:
    • Environment:
      2.0.3
    • Database:
      Oracle
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      18576

      Description

      On our development server, I tried to click some quiz, but it gave me the following error message:

      Found more than one record in fetch() !

      More information about this error

      Stack trace:
      line 429 of /lib/setuplib.php: moodle_exception thrown
      line 146 of /lib/grade/grade_object.php: call to print_error()
      line 316 of /lib/grade/grade_item.php: call to grade_object::fetch_helper()
      line 947 of /lib/grade/grade_item.php: call to grade_item::fetch()
      line 352 of /lib/gradelib.php: call to grade_item::fetch_course_item()
      line 146 of /mod/quiz/view.php: call to grade_get_grades()

      After the investigation, I found, there are duplicate "course" in the ITEMTYPE field in the GRADE_ITEM table. I know for each course, there should be only one "course" ITEMTYPE in this table. I am not sure what's the reason to create multiple ones, maybe by quiz backup/import, course backup/import, etc. I would like to attach those records, and let me know if you can find anything useful.

        Activity

        Hide
        Michael de Raadt added a comment -

        Hi, Longfei.

        This sounds like it could be a problem with your database.

        Have you tried to replicate this on another server? If so, what are the replication steps?

        Show
        Michael de Raadt added a comment - Hi, Longfei. This sounds like it could be a problem with your database. Have you tried to replicate this on another server? If so, what are the replication steps?
        Hide
        Longfei Yu added a comment -

        Hmmmm... What do you mean, a problem with my database? I know it is a problem. However, I never touched (insert/delete) records in the database directly, all of the data was generated from the frontend, from the application.

        If there are any garbage data in my database, I want to say maybe there is something wrong with the application. I want to know where is wrong, that's also the reason I post this ticket. I am wondering if someone can tell something from the attachment data.

        Thanks.

        Show
        Longfei Yu added a comment - Hmmmm... What do you mean, a problem with my database? I know it is a problem. However, I never touched (insert/delete) records in the database directly, all of the data was generated from the frontend, from the application. If there are any garbage data in my database, I want to say maybe there is something wrong with the application. I want to know where is wrong, that's also the reason I post this ticket. I am wondering if someone can tell something from the attachment data. Thanks.
        Hide
        Andrew Davis added a comment -

        I am guessing however most likely the duplicate course grade item rows were added during the backup/restore process. If so this is reasonably serious as what will happen with multiple course grade items in the database is unpredictable.

        Show
        Andrew Davis added a comment - I am guessing however most likely the duplicate course grade item rows were added during the backup/restore process. If so this is reasonably serious as what will happen with multiple course grade items in the database is unpredictable.
        Hide
        Trevor Jones added a comment -

        We are experiencing something very similar that has the same effect on quiz access, see this: http://tracker.moodle.org/browse/MDL-29297

        Show
        Trevor Jones added a comment - We are experiencing something very similar that has the same effect on quiz access, see this: http://tracker.moodle.org/browse/MDL-29297
        Hide
        Andrew Davis added a comment -

        This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

        For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

        Show
        Andrew Davis added a comment - This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment
        Hide
        Jen McVicker added a comment -

        I am having the same issue, using Moodle 2.4.4. I have an external script that imports courses into moodle by essentially copying an existing course and all of its settings/assignments/etc. All is well until I edit a quiz. After that, any graded activity (assignment, quiz) throws the error "more than one record in fetch()". Prior to the edit, there is a single record in the grade_items table with the itemtype = 'course' and the iteminstance = the course ID. When the quiz is updated, the following happens: the grade_item course (itemtype="course") record is duplicated but the itemtype is set to "category", and any grade_item category (itemtype="category") records are duplicated, but the itemtype is set to "course".

        Show
        Jen McVicker added a comment - I am having the same issue, using Moodle 2.4.4. I have an external script that imports courses into moodle by essentially copying an existing course and all of its settings/assignments/etc. All is well until I edit a quiz. After that, any graded activity (assignment, quiz) throws the error "more than one record in fetch()". Prior to the edit, there is a single record in the grade_items table with the itemtype = 'course' and the iteminstance = the course ID. When the quiz is updated, the following happens: the grade_item course (itemtype="course") record is duplicated but the itemtype is set to "category", and any grade_item category (itemtype="category") records are duplicated, but the itemtype is set to "course".
        Hide
        Jen McVicker added a comment -

        Let me clarify that: actually the records are inserted as soon as you hit the "edit settings" link for the quiz. It happens BEFORE any quiz changes are saved.

        Show
        Jen McVicker added a comment - Let me clarify that: actually the records are inserted as soon as you hit the "edit settings" link for the quiz. It happens BEFORE any quiz changes are saved.
        Hide
        Jen McVicker added a comment -

        I found the error. The mdl_grade_categories data for the new course was incorrect.

        Show
        Jen McVicker added a comment - I found the error. The mdl_grade_categories data for the new course was incorrect.

          People

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

            Dates

            • Created:
              Updated: