You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
66 lines
1.8 KiB
![]()
9 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
![]()
9 years ago
|
|
||
![]()
9 years ago
|
/**
|
||
|
* Import a backup from moodle system.
|
||
|
*
|
||
|
* @author José Loguercio <jose.loguercio@beeznest.com>
|
||
|
*/
|
||
![]()
9 years ago
|
require_once __DIR__.'/../inc/global.inc.php';
|
||
![]()
9 years ago
|
|
||
|
$current_course_tool = TOOL_COURSE_MAINTENANCE;
|
||
|
api_protect_course_script(true);
|
||
|
|
||
|
// Check access rights (only teachers are allowed here)
|
||
|
if (!api_is_allowed_to_edit()) {
|
||
|
api_not_allowed(true);
|
||
|
}
|
||
|
|
||
![]()
7 years ago
|
api_set_more_memory_and_time_limits();
|
||
![]()
9 years ago
|
|
||
|
// Section for the tabs
|
||
|
$this_section = SECTION_COURSES;
|
||
|
|
||
|
// Breadcrumbs
|
||
![]()
8 years ago
|
$interbreadcrumb[] = [
|
||
![]()
9 years ago
|
'url' => api_get_path(WEB_CODE_PATH).'course_info/maintenance.php?'.api_get_cidreq(),
|
||
![]()
6 years ago
|
'name' => get_lang('Backup'),
|
||
![]()
8 years ago
|
];
|
||
![]()
9 years ago
|
|
||
![]()
8 years ago
|
$form = new FormValidator('import_moodle', 'post', api_get_self().'?'.api_get_cidreq());
|
||
![]()
6 years ago
|
$form->addFile('moodle_file', get_lang('Moodle course file'));
|
||
![]()
9 years ago
|
$form->addButtonImport(get_lang('Import'));
|
||
|
|
||
|
if ($form->validate()) {
|
||
![]()
9 years ago
|
$file = $_FILES['moodle_file'];
|
||
![]()
7 years ago
|
|
||
![]()
9 years ago
|
$moodleImport = new MoodleImport();
|
||
![]()
9 years ago
|
|
||
![]()
7 years ago
|
try {
|
||
|
$responseImport = $moodleImport->import($file);
|
||
![]()
9 years ago
|
|
||
![]()
9 years ago
|
Display::addFlash(
|
||
![]()
7 years ago
|
Display::return_message(
|
||
![]()
6 years ago
|
get_lang('Moodle course fileImportedSuccessfully'),
|
||
![]()
7 years ago
|
'success'
|
||
|
)
|
||
![]()
9 years ago
|
);
|
||
![]()
7 years ago
|
} catch (Exception $exception) {
|
||
![]()
9 years ago
|
Display::addFlash(
|
||
![]()
7 years ago
|
Display::return_message($exception->getMessage(), 'error')
|
||
![]()
9 years ago
|
);
|
||
![]()
9 years ago
|
}
|
||
![]()
9 years ago
|
}
|
||
|
|
||
![]()
6 years ago
|
$template = new Template(get_lang('Import from Moodle'));
|
||
|
$infoMsg = Display::return_message(get_lang('Import from MoodleInstructions'), 'normal', false);
|
||
![]()
9 years ago
|
$template->assign('info_msg', $infoMsg);
|
||
|
$template->assign('form', $form->returnForm());
|
||
![]()
3 years ago
|
$templateName = $template->get_template('course_copy/import_moodle.tpl');
|
||
![]()
9 years ago
|
$content = $template->fetch($templateName);
|
||
![]()
9 years ago
|
|
||
![]()
6 years ago
|
$template->assign('header', get_lang('Import from Moodle'));
|
||
![]()
9 years ago
|
$template->assign('content', $content);
|
||
|
|
||
![]()
9 years ago
|
$template->display_one_col_template();
|