From: skodak Date: Tue, 28 Aug 2007 21:06:01 +0000 (+0000) Subject: MDL-10320 assignment types that are not installed are not restored anymore + fixed... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d515beab013b227cb258dcacd3b79f5d11840d5e;p=moodle.git MDL-10320 assignment types that are not installed are not restored anymore + fixed warning when no attempts present --- diff --git a/mod/assignment/restorelib.php b/mod/assignment/restorelib.php index 6c7648e5e4..4aae4665e4 100644 --- a/mod/assignment/restorelib.php +++ b/mod/assignment/restorelib.php @@ -79,6 +79,19 @@ } } + // skip restore of plugins that are not installed + static $plugins; + if (!isset($plugins)) { + $plugins = get_list_of_plugins('mod/assignment/type'); + } + + if (!in_array($assignment->assignmenttype, $plugins)) { + if (!defined('RESTORE_SILENTLY')) { + echo "
  • ".get_string("modulename","assignment")." \"".format_string(stripslashes($assignment->name),true)."\" - plugin '{$assignment->assignmenttype}' not available!
  • "; + } + return true; // do not fail the restore + } + //The structure is equal to the db, so insert the assignment $newid = insert_record ("assignment",$assignment); @@ -95,7 +108,7 @@ //Now check if want to restore user data and do it. if (restore_userdata_selected($restore,'assignment',$mod->id)) { //Restore assignmet_submissions - $status = assignment_submissions_restore_mods ($mod->id, $newid,$info,$restore); + $status = assignment_submissions_restore_mods($mod->id, $newid,$info,$restore) && $status; } } else { $status = false; @@ -114,8 +127,12 @@ $status = true; - //Get the submissions array - $submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION']; + //Get the submissions array - it might not be present + if (isset($info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'])) { + $submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION']; + } else { + $submissions = array(); + } //Iterate over submissions for($i = 0; $i < sizeof($submissions); $i++) {