Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixes to restore.

  • Loading branch information...
commit d5ec0e19e67fb4ad5f01416d367f9c400e16e203 1 parent 98591c8
authored December 24, 2003

Showing 1 changed file with 54 additions and 52 deletions. Show diff stats Hide diff stats

  1. 106  mod/workshop/restorelib.php
106  mod/workshop/restorelib.php
@@ -285,67 +285,69 @@ function workshop_assessments_restore_mods($new_workshop_id, $new_submission_id,
285 285
 
286 286
         $status = true;
287 287
 
288  
-        //Get the assessments array
289  
-        $assessments = $info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'];
  288
+        //Get the assessments array (if any)
  289
+        if (isset($info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'])) {
  290
+            $assessments = $info['#']['ASSESSMENTS']['0']['#']['ASSESSMENT'];
290 291
 
291  
-        //Iterate over assessments
292  
-        for($i = 0; $i < sizeof($assessments); $i++) {
293  
-            $ass_info = $assessments[$i];
294  
-            //traverse_xmlize($ass_info);                                                                 //Debug
295  
-            //print_object ($GLOBALS['traverse_array']);                                                  //Debug
296  
-            //$GLOBALS['traverse_array']="";                                                              //Debug
  292
+            //Iterate over assessments
  293
+            for($i = 0; $i < sizeof($assessments); $i++) {
  294
+                $ass_info = $assessments[$i];
  295
+                //traverse_xmlize($ass_info);                                                                 //Debug
  296
+                //print_object ($GLOBALS['traverse_array']);                                                  //Debug
  297
+                //$GLOBALS['traverse_array']="";                                                              //Debug
297 298
 
298  
-            //We'll need this later!!
299  
-            $oldid = backup_todb($ass_info['#']['ID']['0']['#']);
300  
-            $olduserid = backup_todb($ass_info['#']['USERID']['0']['#']);
301  
-
302  
-            //Now, build the WORKSHOP_ASSESSMENTS record structure
303  
-            $assessment->workshopid = $new_workshop_id;
304  
-            $assessment->submissionid = $new_submission_id;
305  
-            $assessment->userid = backup_todb($ass_info['#']['USERID']['0']['#']);
306  
-            $assessment->timecreated = backup_todb($ass_info['#']['TIMECREATED']['0']['#']);
307  
-            $assessment->timegraded = backup_todb($ass_info['#']['TIMEGRADED']['0']['#']);
308  
-            $assessment->timeagreed = backup_todb($ass_info['#']['TIMEAGREED']['0']['#']);
309  
-            $assessment->grade = backup_todb($ass_info['#']['GRADE']['0']['#']);
310  
-            $assessment->gradinggrade = backup_todb($ass_info['#']['GRADINGGRADE']['0']['#']);
311  
-            $assessment->resubmission = backup_todb($ass_info['#']['RESUBMISSION']['0']['#']);
312  
-            $assessment->mailed = backup_todb($ass_info['#']['MAILED']['0']['#']);
313  
-            $assessment->generalcomment = backup_todb($ass_info['#']['GENERALCOMMENT']['0']['#']);
314  
-            $assessment->teachercomment = backup_todb($ass_info['#']['TEACHERCOMMENT']['0']['#']);
  299
+                //We'll need this later!!
  300
+                $oldid = backup_todb($ass_info['#']['ID']['0']['#']);
  301
+                $olduserid = backup_todb($ass_info['#']['USERID']['0']['#']);
  302
+
  303
+                //Now, build the WORKSHOP_ASSESSMENTS record structure
  304
+                $assessment->workshopid = $new_workshop_id;
  305
+                $assessment->submissionid = $new_submission_id;
  306
+                $assessment->userid = backup_todb($ass_info['#']['USERID']['0']['#']);
  307
+                $assessment->timecreated = backup_todb($ass_info['#']['TIMECREATED']['0']['#']);
  308
+                $assessment->timegraded = backup_todb($ass_info['#']['TIMEGRADED']['0']['#']);
  309
+                $assessment->timeagreed = backup_todb($ass_info['#']['TIMEAGREED']['0']['#']);
  310
+                $assessment->grade = backup_todb($ass_info['#']['GRADE']['0']['#']);
  311
+                $assessment->gradinggrade = backup_todb($ass_info['#']['GRADINGGRADE']['0']['#']);
  312
+                $assessment->resubmission = backup_todb($ass_info['#']['RESUBMISSION']['0']['#']);
  313
+                $assessment->mailed = backup_todb($ass_info['#']['MAILED']['0']['#']);
  314
+                $assessment->generalcomment = backup_todb($ass_info['#']['GENERALCOMMENT']['0']['#']);
  315
+                $assessment->teachercomment = backup_todb($ass_info['#']['TEACHERCOMMENT']['0']['#']);
315 316
 
316  
-            //We have to recode the userid field
317  
-            $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
318  
-            if ($user) {
319  
-                $assessment->userid = $user->new_id;
320  
-            }
  317
+                //We have to recode the userid field
  318
+                $user = backup_getid($restore->backup_unique_code,"user",$olduserid);
  319
+                if ($user) {
  320
+                    $assessment->userid = $user->new_id;
  321
+                }
321 322
 
322  
-            //The structure is equal to the db, so insert the workshop_assessment
323  
-            $newid = insert_record ("workshop_assessments",$assessment);
  323
+                //The structure is equal to the db, so insert the workshop_assessment
  324
+                $newid = insert_record ("workshop_assessments",$assessment);
324 325
 
325  
-            //Do some output
326  
-            if (($i+1) % 50 == 0) {
327  
-                echo ".";
328  
-                if (($i+1) % 1000 == 0) {
329  
-                    echo "<br>";
  326
+                //Do some output
  327
+                if (($i+1) % 50 == 0) {
  328
+                    echo ".";
  329
+                    if (($i+1) % 1000 == 0) {
  330
+                        echo "<br>";
  331
+                    }
  332
+                    backup_flush(300);
330 333
                 }
331  
-                backup_flush(300);
332  
-            }
333 334
 
334  
-            if ($newid) {
335  
-                //We have the newid, update backup_ids
336  
-                backup_putid($restore->backup_unique_code,"workshop_assessments",$oldid,
337  
-                             $newid);
  335
+                if ($newid) {
  336
+                    //We have the newid, update backup_ids
  337
+                    backup_putid($restore->backup_unique_code,"workshop_assessments",$oldid,
  338
+                            $newid);
338 339
 
339  
-                //Now we need to restore workshop_comments (user level table)
340  
-                if ($status) {
341  
-                    $status = workshop_comments_restore_mods ($new_workshop_id, $newid,$ass_info,$restore);
342  
-                }
343  
-                //Now we need to restore workshop_grades (user level table)   
344  
-                if ($status) {
345  
-                    $status = workshop_grades_restore_mods ($new_workshop_id, $newid,$ass_info,$restore);   
  340
+                    //Now we need to restore workshop_comments (user level table)
  341
+                    if ($status) {
  342
+                        $status = workshop_comments_restore_mods ($new_workshop_id, $newid,$ass_info,$restore);
  343
+                    }
  344
+                    //Now we need to restore workshop_grades (user level table)   
  345
+                    if ($status) {
  346
+                        $status = workshop_grades_restore_mods ($new_workshop_id, $newid,$ass_info,$restore);   
  347
+                    }
  348
+                } else {
  349
+                    $status = false;
346 350
                 }
347  
-            } else {
348  
-                $status = false;
349 351
             }
350 352
         }
351 353
 

0 notes on commit d5ec0e1

Please sign in to comment.
Something went wrong with that request. Please try again.