Merge branch 'MDL-37966' of git://github.com/jonof/moodle
[moodle.git] / mod / assign / upgradelib.php
index 65e0b51..e3899dd 100644 (file)
@@ -99,6 +99,8 @@ class assign_upgrade_manager {
         $data->requireallteammemberssubmit = 0;
         $data->teamsubmissiongroupingid = 0;
         $data->blindmarking = 0;
+        $data->attemptreopenmethod = 'none';
+        $data->maxattempts = ASSIGN_UNLIMITED_ATTEMPTS;
 
         $newassignment = new assign(null, null, null);
 
@@ -247,7 +249,14 @@ class assign_upgrade_manager {
                     $grade->timemodified = $oldsubmission->timemarked;
                     $grade->timecreated = $oldsubmission->timecreated;
                     $grade->grade = $oldsubmission->grade;
-                    $grade->mailed = $oldsubmission->mailed;
+                    if ($oldsubmission->mailed) {
+                        // The mailed flag goes in the flags table.
+                        $flags = new stdClass();
+                        $flags->userid = $oldsubmission->userid;
+                        $flags->assignment = $newassignment->get_instance()->id;
+                        $flags->mailed = 1;
+                        $DB->insert_record('assign_user_flags', $flags);
+                    }
                     $grade->id = $DB->insert_record('assign_grades', $grade);
                     if (!$grade->id) {
                         $log .= get_string('couldnotinsertgrade', 'mod_assign', $grade->userid);
@@ -292,7 +301,7 @@ class assign_upgrade_manager {
 
         } catch (Exception $exception) {
             $rollback = true;
-            $log .= get_string('conversionexception', 'mod_assign', $exception->error);
+            $log .= get_string('conversionexception', 'mod_assign', $exception->getMessage());
         }
 
         if ($rollback) {