]> git.mjollnir.org Git - moodle.git/commitdiff
added itemtype to backup/restore, only restore a mod type gradeitem if user data...
authortoyomoyo <toyomoyo>
Wed, 30 May 2007 06:23:21 +0000 (06:23 +0000)
committertoyomoyo <toyomoyo>
Wed, 30 May 2007 06:23:21 +0000 (06:23 +0000)
backup/backuplib.php
backup/restorelib.php

index 05563c1c1167c3de4f46babb5fc9c3fe0ac14332..44c58af5488fd205c59e69f42127c297baed9f1f 100644 (file)
                 fwrite ($bf,start_tag("GRADE_ITEM",4,true)); 
                 //Output individual fields     
 
-                fwrite ($bf,full_tag("ID",5,false,$grade_item->id));                
+                fwrite ($bf,full_tag("ID",5,false,$grade_item->id));
                 fwrite ($bf,full_tag("ITEMNAME",5,false,$grade_item->itemname));
+                fwrite ($bf,full_tag("ITEMTYPE",5,false,$grade_item->itemtype));
                 fwrite ($bf,full_tag("ITEMMODULE",5,false,$grade_item->itemmodule));
                 fwrite ($bf,full_tag("ITEMINSTANCE",5,false,$grade_item->iteminstance));
                 fwrite ($bf,full_tag("ITEMNUMBER",5,false,$grade_item->itemnumber));
index 3985cb6dd113af2b9daf75c1c7e9b6ec64d66142..67ed3d6e6066b180caf6048b8c6dee2ceec6f13a 100644 (file)
                         //Get the full record from backup_ids
                         $data = backup_getid($restore->backup_unique_code,'grade_items',$rec->old_id);
                         if ($data) {
+                       
                             //Now get completed xmlized object
                             $info = $data->info;
                             //traverse_xmlize($info);                            //Debug
                             }
 
                             $dbrec->itemname = backup_todb($info['GRADE_ITEM']['#']['ITEMNAME']['0']['#']);
+                            $dbrec->itemtype = backup_todb($info['GRADE_ITEM']['#']['ITEMTYPE']['0']['#']);
                             $dbrec->itemmodule = backup_todb($info['GRADE_ITEM']['#']['ITEMMODULE']['0']['#']);
                             /// this needs to point to either the new mod id
                             /// or the category id
                             $dbrec->iteminstance = backup_todb($info['GRADE_ITEM']['#']['ITEMINSTANCE']['0']['#']);
+                            
+                            // do not restore if this grade_item is a mod, and 
+                            if ($dbrec->itemtype == 'mod') {
+                                // get the mod
+                                $mod = get_record('course_module', 'id', $dbrec->iteminstance);
+                                $modt = get_record('modules', 'id', $mod->module);
+                                if (!restore_userdata_selected($restore, $modt->name, $mod->id)) {
+                                    // module instance not restored using granular
+                                    $counteritems++;
+                                    continue;
+                                }
+                            }
+                            
                             $dbrec->itemnumber = backup_todb($info['GRADE_ITEM']['#']['ITEMNUMBER']['0']['#']);
                             $dbrec->iteminfo = backup_todb($info['GRADE_ITEM']['#']['ITEMINFO']['0']['#']);
                             $dbrec->idnumber = backup_todb($info['GRADE_ITEM']['#']['IDNUMBER']['0']['#']);