]> git.mjollnir.org Git - moodle.git/commitdiff
added needsupdate flag into backup/restore, added a new switch for restore on/off...
authortoyomoyo <toyomoyo>
Tue, 18 Sep 2007 04:03:02 +0000 (04:03 +0000)
committertoyomoyo <toyomoyo>
Tue, 18 Sep 2007 04:03:02 +0000 (04:03 +0000)
backup/backuplib.php
backup/restore_check.html
backup/restore_form.html
backup/restorelib.php

index d3534d7e448ab582705e791fd5cade6f4d7a2f9c..a3d89ec8803bf306d0b2d8c9cf51f486818c8c0c 100644 (file)
                 fwrite ($bf,full_tag("HIDDEN",5,false,$grade_item->hidden));
                 fwrite ($bf,full_tag("LOCKED",5,false,$grade_item->locked));
                 fwrite ($bf,full_tag("LOCKTIME",5,false,$grade_item->locktime));
+                fwrite ($bf,full_tag("NEEDSUPDATE",5,false,$grade_item->needsupdate));
+                fwrite ($bf,full_tag("TIMECREATED",5,false,$grade_item->timecreated));
+                fwrite ($bf,full_tag("TIMEMODIFIED",5,false,$grade_item->timemodified));
 
                 // back up the other stuff here
                 // mod grades should only be backed up if selected
index 0456fd43475465e252568a4c75b9aae93adb6ef2..a0f3940060cb57595138153d6b37b611f68708c9 100644 (file)
         $restore_course_files = required_param('restore_course_files');
         //restore_site_files
         $restore_site_files = required_param('restore_site_files');
+        //restore_gradebook_history
+        $restore_gradebook_history = required_param('restore_gradebook_history');
         //restore_messages
         $restore_messages = required_param('restore_messages');
-
+        
         //Check we've selected a course to restore to
         $course_id = optional_param('course_id', 0, PARAM_INT);
 
         $restore->course_files=$restore_course_files;
         $restore->site_files=$restore_site_files;
         $restore->messages=$restore_messages;
+        $restore->restore_gradebook_history=$restore_gradebook_history;
         $restore->course_id=$course_id;
         //add new vars to restore object
         $restore->course_startdateoffset = $coursestartdatedateoffset;
index b3e679883566ae683798575aaa0deb19bf89f3a4..7a18c3029a53c93860f1a14c934446cac07c4f2b 100644 (file)
@@ -12,6 +12,8 @@
       error( 'course_header object missing from session' );
     }
 
+    $restore_gradebook_history =  optional_param('restore_gradebook_history', 1, PARAM_INT);
+
     //Check that we have all we need
     //backup_unique_code
     $backup_unique_code = required_param( 'backup_unique_code' );
@@ -468,7 +470,17 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
             echo "<input type=\"hidden\" name=\"restore_site_files\" value=\"0\" />";
         }
         echo "</td></tr>";
-
+        
+        // do you want grade histories to be restored?
+        echo "<tr>";
+        echo "<td align=\"right\" colspan=\"2\"><b>";
+        echo get_string ('gradebookhistories', 'grades').":";
+        echo "</b></td><td colspan=\"2\">";
+        $gradebook_history_options[0] = get_string("no");
+        $gradebook_history_options[1] = get_string("yes");
+        choose_from_menu($gradebook_history_options, "restore_gradebook_history", $restore_gradebook_history, "");
+        echo "</td></tr>";  
+        
         //Now print the Messages tr
         echo "<tr>";
         echo "<td align=\"right\" colspan=\"2\"><b>";
@@ -487,6 +499,8 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
             echo "<input type=\"hidden\" name=\"restore_messages\" value=\"0\" />";
         }
         echo "</td></tr>";
+        
+      
     }
 ?>
 </table>
index ae6e34054d05e7f2a2ec294619d350a44eecac74..0bd2c9c39c6221841042ab780e62853f022ac032 100644 (file)
                             $dbrec->grademin = backup_todb($info['GRADE_ITEM']['#']['GRADEMIN']['0']['#']);
                             /// needs to be restored first
 
-                            if ($info['GRADE_ITEM']['#']['SCALEID']['0']['#']) {
+                            if (backup_todb($info['GRADE_ITEM']['#']['SCALEID']['0']['#'])) {
                                 $scale = backup_getid($restore->backup_unique_code,"scale",backup_todb($info['GRADE_ITEM']['#']['SCALEID']['0']['#']));
                                 $dbrec->scaleid = $scale->new_id;
                             }
                             $dbrec->hidden = backup_todb($info['GRADE_ITEM']['#']['HIDDEN']['0']['#']);
                             $dbrec->locked = backup_todb($info['GRADE_ITEM']['#']['LOCKED']['0']['#']);
                             $dbrec->locktime = backup_todb($info['GRADE_ITEM']['#']['LOCKTIME']['0']['#']);
+                            $dbrec->needsupdate = backup_todb($info['GRADE_ITEM']['#']['NEEDSUPDATE']['0']['#']);
+                            $dbrec->timecreated = backup_todb($info['GRADE_ITEM']['#']['TIMECREATED']['0']['#']);
+                            $dbrec->timemodified = backup_todb($info['GRADE_ITEM']['#']['TIMEMODIFIED']['0']['#']);
 
                             // get the current sortorder, add 1 to it and use that
                             if ($lastitem = get_record_sql("SELECT sortorder, id FROM {$CFG->prefix}grade_items
                                     $grade->rawgrademax = backup_todb($ite_info['#']['RAWGRADEMAX']['0']['#']);
                                     $grade->rawgrademin = backup_todb($ite_info['#']['RAWGRADEMIN']['0']['#']);
                                     // need to find scaleid
-                                    if ($ite_info['#']['RAWSCALEID']['0']['#']) {
+                                    if (backup_todb($ite_info['#']['RAWSCALEID']['0']['#'])) {
                                         $scale = backup_getid($restore->backup_unique_code,"scale",backup_todb($ite_info['#']['RAWSCALEID']['0']['#']));
                                         $grade->rawscaleid = $scale->new_id;
                                     }
         }
 
         // process histories
-        if ($gchcount && $continue && !isset($SESSION->restore->importing)) {
+        if ($gchcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradecategoryhistory','grades').'</li>';
             }
         }
 
         // process histories
-        if ($gghcount && $continue && !isset($SESSION->restore->importing)) {
+        if ($gghcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradegradeshistory','grades').'</li>';
             }
 
         // process histories
 
-        if ($ggthcount && $continue && !isset($SESSION->restore->importing)) {
+        if ($ggthcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradegradestexthistory','grades').'</li>';
             }
         }
 
         // process histories
-        if ($gihcount && $continue && !isset($SESSION->restore->importing)) {
+        if ($gihcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradeitemshistory','grades').'</li>';
             }
         }
 
         // process histories
-        if ($gohcount && $continue && !isset($SESSION->restore->importing)) {
+        if ($gohcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) {
             if (!defined('RESTORE_SILENTLY')) {
                 echo '<li>'.get_string('gradeoutcomeshistory','grades').'</li>';
             }