MDL-32690: Restore 1.9 backup into 2.X fails on missing assignment type

Solution is as follows:
* Allow unsupported subplugins to convert from Moodle1 to Moodle2
* On Moodle2 restore hide unsupported subplugins
* Graceful error message in assignment of unsupported subplugins
This commit is contained in:
Mark Nielsen
2013-08-29 08:48:39 -07:00
parent abb767192f
commit 0fc55f1d0a
6 changed files with 46 additions and 5 deletions
+6 -2
View File
@@ -9,7 +9,7 @@ class mod_assignment_mod_form extends moodleform_mod {
protected $_assignmentinstance = null;
function definition() {
global $CFG, $DB, $PAGE;
global $CFG, $DB, $PAGE, $COURSE;
$mform =& $this->_form;
// this hack is needed for different settings of each subtype
@@ -29,7 +29,11 @@ class mod_assignment_mod_form extends moodleform_mod {
$mform->setType('type', PARAM_ALPHA);
$mform->setDefault('type', $type);
require_once($CFG->dirroot.'/mod/assignment/type/'.$type.'/assignment.class.php');
$classfile = $CFG->dirroot.'/mod/assignment/type/'.$type.'/assignment.class.php';
if (!file_exists($classfile)) {
throw new moodle_exception('unsupportedsubplugin', 'assignment', new moodle_url('/course/view.php', array('id' => $COURSE->id)), $type);
}
require_once($classfile);
$assignmentclass = 'assignment_'.$type;
$assignmentinstance = new $assignmentclass();