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

Assignment ID number field changing when student submits assignment

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9.7
    • Fix Version/s: 1.9.9
    • Component/s: Assignment (2.2)
    • Labels:
      None
    • Environment:
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      I've noticed a bug where if you set an ID in the Common Module settings portion of an advanced file upload assignment's settings page, the ID of the corresponding gradebook item gets overwritten with a number when a student submits an assignment.

      For example, say you made an advanced upload assignment and set the ID number field to "asdf". If you go to the gradebook (categories and Items - simple view) and click edit on the grade item for the assignment, you can see that the ID will be "asdf" as expected. Next, you then log in as a student and submit a file for marking on the assignment. Then, log back in as a teacher and go back to the gradebook (categories and items - simple view). if you click edit on the assignment grade item now, you will see that the ID field has been replaced by a number. This also affects XML exports from the gradebook too, as the grade items for the affected assignment will have the wrong ID in the xml export. Interestingly, if you open the assignment's settings page and save it again, the ID in the gradebook will be reset to the correct value.

      I did some digging and found that the new ID number that was showing up in the gradebook comes from the mdl_course_modules table. Instead of the grade item having mdl_course_modules.idnumber (which holds the value that you entered on the assignment settings page), it has mdl_course_modules.id (which is the auto-generated course module id number).

      Looking through the code, I found in mod/assignment/lib.php at line 74,in the assignment class constructor, you have:

      $this->assignment->cmidnumber = $this->cm->id; // compatibility with modedit assignment obj
      $this->assignment->courseid = $this->course->id; // compatibility with modedit assignment obj

      The fix that I have tried so far is to change this to:

      $this->assignment->cmidnumber = $this->cm->idnumber; // compatibility with modedit assignment obj
      $this->assignment->courseid = $this->course->id; // compatibility with modedit assignment obj

      This corrects the problem, but I haven't tested it thoroughly as of yet.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            skodak Petr Skoda added a comment -

            big thanks for the report and patch!
            this problem was already reported before, but I was not able to reproduce it, this should finally solve it

            Petr

            Show
            skodak Petr Skoda added a comment - big thanks for the report and patch! this problem was already reported before, but I was not able to reproduce it, this should finally solve it Petr
            Hide
            shirai Tatsuya Shirai added a comment -

            Hi, Pert!

            Notice messages are displayed when we display list of assingment, for example, http://www.yourdomain.com/moodle/mod/assignment/index.php?id=3

            Notice: Undefined property: object::$idnumber in /var/www/html/mech/moodle/mod/assignment/lib.php on line 74

            Notice: Undefined property: object::$idnumber in /var/www/html/mech/moodle/mod/assignment/lib.php on line 74

            Notice: Undefined property: object::$idnumber in /var/www/html/mech/moodle/mod/assignment/lib.php on line 74
            .....

            if (empty($this->cm->idnumber)) $this->cm->idnumber = null; // (Add this statement ! )
            $this->assignment->cmidnumber = $this->cm->idnumber; // compatibility with modedit assignment obj
            $this->assignment->courseid = $this->course->id; // compatibility with modedit assignment obj

            I think that need to check $this->cm->idnumber is defined or not.

            Show
            shirai Tatsuya Shirai added a comment - Hi, Pert! Notice messages are displayed when we display list of assingment, for example, http://www.yourdomain.com/moodle/mod/assignment/index.php?id=3 Notice: Undefined property: object::$idnumber in /var/www/html/mech/moodle/mod/assignment/lib.php on line 74 Notice: Undefined property: object::$idnumber in /var/www/html/mech/moodle/mod/assignment/lib.php on line 74 Notice: Undefined property: object::$idnumber in /var/www/html/mech/moodle/mod/assignment/lib.php on line 74 ..... if (empty($this->cm->idnumber)) $this->cm->idnumber = null; // (Add this statement ! ) $this->assignment->cmidnumber = $this->cm->idnumber; // compatibility with modedit assignment obj $this->assignment->courseid = $this->course->id; // compatibility with modedit assignment obj I think that need to check $this->cm->idnumber is defined or not.
            Hide
            skodak Petr Skoda added a comment -

            the proposed patch looks wrong, because the missing cm->idnumber is probably coming from the get_fast_modinfo()

            Show
            skodak Petr Skoda added a comment - the proposed patch looks wrong, because the missing cm->idnumber is probably coming from the get_fast_modinfo()
            Hide
            skodak Petr Skoda added a comment -

            hack committed into 1.9.x, it will be in next weekly build, sorry for the regression...

            Show
            skodak Petr Skoda added a comment - hack committed into 1.9.x, it will be in next weekly build, sorry for the regression...
            Hide
            skodak Petr Skoda added a comment -

            thanks a lot for the report!

            Show
            skodak Petr Skoda added a comment - thanks a lot for the report!
            Hide
            mudrd8mz David Mudrak added a comment -

            Petr, I got a report from a Czech user that might be a regression of this. After their upgrade to 1.9.9+ they started to get

            Notice: Undefined property: object::$idnumber in /data/www/trebesin.info/moodle.trebesin.info/mod/assignment/lib.php on line 74

            but only for Students and Guests. If the user is Teacher or Admin, there is no error message. See http://moodle.cz/mod/forum/discuss.php?d=3321 for the report.

            Show
            mudrd8mz David Mudrak added a comment - Petr, I got a report from a Czech user that might be a regression of this. After their upgrade to 1.9.9+ they started to get Notice: Undefined property: object::$idnumber in /data/www/trebesin.info/moodle.trebesin.info/mod/assignment/lib.php on line 74 but only for Students and Guests. If the user is Teacher or Admin, there is no error message. See http://moodle.cz/mod/forum/discuss.php?d=3321 for the report.
            Hide
            mudrd8mz David Mudrak added a comment -

            Oh, it is already reported as MDL-24110 and linked.

            Show
            mudrd8mz David Mudrak added a comment - Oh, it is already reported as MDL-24110 and linked.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  8/Jun/10