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

Assignment 2.2 upgrade utility deletes outcomes data

    XMLWordPrintable

Details

    • MOODLE_23_STABLE
    • MOODLE_23_STABLE
    • MDL-36914-master
    • Hide
      1. Enable Outcomes in "Site administration" => "Advanced features"
      2. Add an outcome in "Site administration" => "Grades" => "Outcomes"
      3. Enable the "Assignment (2.2)" activity in "Site administration" => "Plugins" => "Activity modules" => "Manage activity modules"
      4. In a test course with at least one student, Go to the outcomes page in the course settings block and add the outcome to the course.
      5. Create an instance of the old "Online text" assignment, and select the new outcome in the settings page.
      6. Login as a student and make a submission
      7. Login as a teacher and grade the submission, assigning it an outcome as well.
      8. Use the assignment upgrade tool to upgrade the assignment to the new assignment module
      9. Go to the gradebook for the course and see that there is a column for the outcome and it has the assigned value for the student.
      10. Click the header for the outcome column and see that it takes you to the upgraded assignment.
      Show
      Enable Outcomes in "Site administration" => "Advanced features" Add an outcome in "Site administration" => "Grades" => "Outcomes" Enable the "Assignment (2.2)" activity in "Site administration" => "Plugins" => "Activity modules" => "Manage activity modules" In a test course with at least one student, Go to the outcomes page in the course settings block and add the outcome to the course. Create an instance of the old "Online text" assignment, and select the new outcome in the settings page. Login as a student and make a submission Login as a teacher and grade the submission, assigning it an outcome as well. Use the assignment upgrade tool to upgrade the assignment to the new assignment module Go to the gradebook for the course and see that there is a column for the outcome and it has the assigned value for the student. Click the header for the outcome column and see that it takes you to the upgraded assignment.

    Description

      The assignment 2.2 upgrade functionality doesn't seem to know about outcomes.

      Turn debugging up to Developer mode.

      In Site Administration > Advanced Features > Tick Enable Outcomes
      In Site Administration > Grades > Outcomes > click add a new outcome and create an outcome. Repeat this again to create a second outcome
      Select a course with at least one student enrolled and goto Course Administration > Outcomes > move the outcome you just created to the left to enable it for that course
      Return to the course homepage and create a new "Upload a single file" 2.2 assignment
      Enter a title and description and under Outcomes tick your new outcomes
      Open the gradebook for that assignment, select a student and click Grade.
      Assign a grade and select any value for each outcome (except of course "No outcome"). Click Save Changes

      Connect to your database and run the following SQL:
      select id, courseid, itemname, itemmodule, iteminstance, outcomeid
      from mdl_grade_items
      order by id desc
      limit 10;

      You should see some new grade_item records like those shown below (in this example I have created two outcomes)

      moodle=# select id, courseid, itemname, itemmodule, iteminstance, outcomeid from mdl_grade_items order by id desc;
       id | courseid |   itemname   | itemmodule | iteminstance | outcomeid 
      ----+----------+--------------+------------+--------------+-----------
       24 |        2 | Outcome 2    | assignment |            5 |         2
       23 |        2 | Outcome 1    | assignment |            5 |         1
       22 |        2 | Outcome test | assignment |            5 |          

      Get the mdl_grade_grade records for those grade_item records

      moodle=# select id, itemid, rawgrade, finalgrade from mdl_grade_grades order by itemid desc;
       id | itemid | rawgrade | finalgrade 
      ----+--------+----------+------------
       15 |     24 |          |    3.00000
       14 |     23 |          |    1.00000
       16 |     22 | 11.00000 |   11.00000

      Return to the assignment and click View the assignment upgrade tool and upgrade your assignment whilst you are watching the php error logs.

      You will see a notice in the error log like that shown below:

      [Wed Nov 28 09:37:13 2012] [error] [client 172.16.180.1] PHP Notice:  Error: mdb->get_record() found more than one record!<ul style="text-align: left"><li>line 1372 of /lib/dml/moodle_database.php: call to debugging()</li><li>line 1332 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()</li><li>line 1311 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()</li><li>line 234 of /mod/assign/upgradelib.php: call to moodle_database->get_record()</li><li>line 190 of /admin/tool/assignmentupgrade/locallib.php: call to assign_upgrade_manager->upgrade_assignment()</li><li>line 63 of /admin/tool/assignmentupgrade/batchupgrade.php: call to tool_assignmentupgrade_upgrade_assignment()</li></ul> in /var/moodle/www/lib/weblib.php on line 2865, referer: http://moodle.local.net/admin/tool/assignmentupgrade/listnotupgraded.php

      Re-run the SQL "select id, courseid, itemname, itemmodule, iteminstance, outcomeid from mdl_grade_items order by id desc;" and you'll see that only one of the grade items has been transferred across to the new assign module instance. The other grade_item records have been deleted along with their grade_grades records.

      Go back to the setup for the assign instance and you'll see that at least one of the previously selected outcomes is unchecked. In the grade book the value assigned to one of the outcomes will also have disappeared.

      During the assignment upgrade process the grade_items are transferred from the old assignment 2.2. course module instance to the new assign course module instance starting at line 234 in mod/assign/upgradelib.php.

      $gradeitem = $DB->get_record('grade_items', array('iteminstance'=>$oldassignment->id, 'itemmodule'=>'assignment'), 'id', IGNORE_MISSING);
      235             if ($gradeitem) {
      236                 $gradeitem->iteminstance = $newassignment->get_instance()->id;
      237                 $gradeitem->itemmodule = 'assign';
      238                 $DB->update_record('grade_items', $gradeitem);
      239             }

      That code will only ever re-associate a single grade_item record. Further down at line 289 the old course module is deleted which is where I the grade_items that have been left behind are also deleted.

      Attachments

        Activity

          People

            damyon Damyon Wiese
            nmares Nathan Mares
            Damyon Wiese Damyon Wiese
            Dan Poltawski Dan Poltawski
            Dan Poltawski Dan Poltawski
            Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Jan/13