Skip to content
Snippets Groups Projects
Commit a31c8d74 authored by Matt Petro's avatar Matt Petro
Browse files

UWMOODLE-212: Upgrading assignments to 2.3

parent a2bd39ce
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ $string['pluginname'] = 'WISC archive plugin'; ...@@ -3,6 +3,7 @@ $string['pluginname'] = 'WISC archive plugin';
$string['pluginname_desc'] = '<p>This plugin enables importing of course archives stored in server directories.</p>'; $string['pluginname_desc'] = '<p>This plugin enables importing of course archives stored in server directories.</p>';
$string['archive:anyarchive'] = 'Import any archive'; $string['archive:anyarchive'] = 'Import any archive';
$string['archive:dolocalimport'] = 'Perform native moodle import';
$string['searchcourse'] = 'Course full name'; $string['searchcourse'] = 'Course full name';
$string['searchsubject'] = 'Department'; $string['searchsubject'] = 'Department';
$string['searchcatalog'] = 'Catalog number'; $string['searchcatalog'] = 'Catalog number';
...@@ -19,8 +20,8 @@ $string['selectarchives'] = 'Select which archives to scan'; ...@@ -19,8 +20,8 @@ $string['selectarchives'] = 'Select which archives to scan';
$string['default_moodle_import_link_text'] = 'Import (current site)'; $string['default_moodle_import_link_text'] = 'Import (current site)';
// Settings string // Settings string
$string['settings_page_name'] = 'Configure WISC archive plugin'; $string['settings_page_name'] = 'WISC archive plugin';
$string['override_link_setting'] = 'Override default import url'; $string['override_link_setting'] = 'Override default import url';
$string['override_link_setting_desc'] = '<p>This setting will change the default import link in course administration to the WISC archive ' . $string['override_link_setting_desc'] = '<p>This setting will change the default import link in course administration to the WISC archive ' .
'import functionality instead the default.</p><p>For users with the local/archive:dolocalimport capability, both links will be displayed.</p>'; 'import functionality instead the default.</p><p>For users with the local/archive:dolocalimport capability, both links will be displayed.</p>';
$string['upgrade_assignment22'] = 'Automatically upgrade Moodle 2.3 assignments';
\ No newline at end of file
...@@ -85,6 +85,37 @@ function local_archive_extends_settings_navigation($settingsnav, $context){ ...@@ -85,6 +85,37 @@ function local_archive_extends_settings_navigation($settingsnav, $context){
} }
} }
/**
* Local archive cron
*/
function local_archive_cron() {
// Upgrade assignments 2.2 by cron, in case some courses have been manually restored.
mtrace('Upgrading moodle 2.2 assignments');
$output = local_archive_batch_upgrade_assignments();
mtrace($output);
mtrace('done.');
}
/**
* Batch upgrade assignment 2.2 to moodle 2.3 assign
*/
function local_archive_batch_upgrade_assignments() {
global $CFG;
if (!get_config('local_archive', 'upgrade_assignment22')) {
return;
}
// Don't want to load this unless necessary
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
$output = "";
$assignmentids = tool_assignmentupgrade_load_all_upgradable_assignmentids();
foreach ($assignmentids as $assignmentid) {
list($summary, $success, $log) = tool_assignmentupgrade_upgrade_assignment($assignmentid);
$output .= $summary->name . ': ' . ($success? 'OK': 'ERROR') . ' ' . $log . "\n";
}
return $output;
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
define('LOCAL_ARCHIVE_TEACHER_ROLE', 1); define('LOCAL_ARCHIVE_TEACHER_ROLE', 1);
require_once($CFG->dirroot.'/local/archive/lib.php');
require_once($CFG->dirroot.'/local/archive/storagetype/base.php'); require_once($CFG->dirroot.'/local/archive/storagetype/base.php');
require_once($CFG->dirroot.'/local/archive/storagetype/moodle.php'); require_once($CFG->dirroot.'/local/archive/storagetype/moodle.php');
require_once($CFG->dirroot.'/local/archive/storagetype/moodle1.php'); require_once($CFG->dirroot.'/local/archive/storagetype/moodle1.php');
...@@ -380,5 +381,9 @@ function local_archive_execute_restore($courseid, $importid, $restoretarget = ba ...@@ -380,5 +381,9 @@ function local_archive_execute_restore($courseid, $importid, $restoretarget = ba
// Delete the temp directory now // Delete the temp directory now
fulldelete($tempdestination); fulldelete($tempdestination);
}
// Upgrade any assignment 2.2 items
// This will probably fail to do anything for non-admins, so we'll rely on cron most of the time.
local_archive_batch_upgrade_assignments();
}
...@@ -24,6 +24,9 @@ if ($hassiteconfig) { ...@@ -24,6 +24,9 @@ if ($hassiteconfig) {
$settings->add(new admin_setting_configcheckbox('local_archive/enable_menu_override', get_string('override_link_setting', 'local_archive'), $settings->add(new admin_setting_configcheckbox('local_archive/enable_menu_override', get_string('override_link_setting', 'local_archive'),
get_string('override_link_setting_desc', 'local_archive'), 1)); get_string('override_link_setting_desc', 'local_archive'), 1));
$settings->add(new admin_setting_configcheckbox('local_archive/upgrade_assignment22', get_string('upgrade_assignment22', 'local_archive'),
'', 1));
$ADMIN->add('localplugins', $settings); $ADMIN->add('localplugins', $settings);
} }
\ No newline at end of file
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2014052001; $plugin->version = 2014061200;
$plugin->release = '2.2'; $plugin->release = '2.2';
$plugin->requires = 2013111801; // See http://docs.moodle.org/dev/Moodle_Versions $plugin->requires = 2013111801; // See http://docs.moodle.org/dev/Moodle_Versions
$plugin->cron = 0; $plugin->cron = 300;
$plugin->component = 'local_archive'; $plugin->component = 'local_archive';
$plugin->maturity = MATURITY_BETA; $plugin->maturity = MATURITY_BETA;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment