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

When a quiz attempt is created for another user, the first step should store the userid the attempt belongs to

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.6, 3.7.2
    • Fix Version/s: 3.9
    • Component/s: Quiz
    • Labels:

      Description

      In the question engine, each action performed on a question is stored in a 'question_attempt_step', and one of the properties of that object/db table is userid.

      The reason that user id is stored here is because of the manual grading feature. The common case is that the actions performed on a question (start, input answer, submit) are done by t the student the attempt belongs to. The one main exception is when a teacher manually grades the question, when we want to store the userid of the teacher who did the grading. That was really the only other case I was thinking of when I wrote the docs: "The user whose action lead to this state" https://github.com/moodle/moodle/blob/master/lib/db/install.xml#L1511 or "the id of the user resonsible for creating this step" https://github.com/moodle/moodle/blob/master/question/engine/questionattemptstep.php#L88

      However, a new case has arisen recently (in our plugin https://github.com/moodleou/moodle-quiz_answersheets). What happens when, as an administrative convenience, one user creates the quiz attempt for another. This never happens in standard Moodle, but the quiz API supports it (particularly after MDL-66633).

      Thinking about this in the abstract, I can construct logical arguments in favour of either point of view:

      • The admin staff actually triggered the attempt creation, therefore we should store their id.
      • The attempt was created because this student needs it. Therefore, it should be the student's id.

      From the point of view of abstract logic, I think that either argument is equally valid.

      However, the reason this is a practical issue is because qtype_coderunner does something (possibly ill-advised) with this user id. See https://github.com/trampgeek/moodle-qtype_coderunner/issues/86. Clearly, CodeRunner is expecting that the userid in the 'start_attempt' step is the user id of the user attempting the quiz. I think that this is a very natural thing to expect, and as I said above, is true for all cases where questions are use in standard Moodle.

      Hence, I created this issue.

      It is, I suppose, theoretically possible for someone to be relying on the current behaviour, but I am not aware of any examples of that, and I am struggling to think of any plausible scenarios where the current behaviour is important, so I am not worried by that.

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            timhunt Tim Hunt
            Peer reviewer:
            Huong Nguyen
            Integrator:
            Andrew Nicols
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              15/Jun/20

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 20 minutes
                20m