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

ERROR: duplicate key value violates unique constraint "mdl_quizatte_quiuseatt_uix"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.3.6, 2.4.3
    • Fix Version/s: None
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      1. Login to Moodle as admin, change teacher role to have mod/quiz:attempt = Allow and mod/quiz:preview = Not Set.
      2. Give the teacher access to a course with a quiz to attempt.
      3. Re-login as the teacher and attempt the quiz.
      4. Finish the attempt.
      5. Quiz screen will have 'Re-attempt quiz' and show previous attempt added.
      6. Re-login as admin and change teacher role to have mod/quiz:preview = Allow.
      7. Re-login as the teacher and attempt the quiz.
      8. You will see the error because you don't have a preview attempt therefore it attempts you don't have real attempts.

      Result being something like this after code has been applied.

      Attempt State
      1 Finished
      Submitted Thursday, 28 March 2013, 11:06 AM
      Preview Finished
      Submitted Thursday, 28 March 2013, 11:19 AM

      Show
      1. Login to Moodle as admin, change teacher role to have mod/quiz:attempt = Allow and mod/quiz:preview = Not Set. 2. Give the teacher access to a course with a quiz to attempt. 3. Re-login as the teacher and attempt the quiz. 4. Finish the attempt. 5. Quiz screen will have 'Re-attempt quiz' and show previous attempt added. 6. Re-login as admin and change teacher role to have mod/quiz:preview = Allow. 7. Re-login as the teacher and attempt the quiz. 8. You will see the error because you don't have a preview attempt therefore it attempts you don't have real attempts. Result being something like this after code has been applied. Attempt State 1 Finished Submitted Thursday, 28 March 2013, 11:06 AM Preview Finished Submitted Thursday, 28 March 2013, 11:19 AM
    • Workaround:
      Hide

      Make sure role doesn't have attempt and preview capabilities enabled.

      Show
      Make sure role doesn't have attempt and preview capabilities enabled.
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      mdl38778-master

      Description

      If you have successful quiz attempts completed as a teacher then your role no longer have mod/quiz:attempt. You will get this error because attempt 1 is used for your previous attempts.

      id | userid | attempt | state | preview
      -----------------------------------
      30005 | 4103 | 1 | finished | 0
      30008 | 4103 | 2 | finished | 0
      30009 | 4103 | 3 | finished | 0
      (3 rows)

      Debug: ERROR: duplicate key value violates unique constraint "mdl_quizatte_quiuseatt_uix"
      DETAIL: Key (quiz, userid, attempt)=(4670, 4103, 1) already exists.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              tlock Tim Lock
              Participants:
              Component watchers:
              Tim Hunt, Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: