mirror of
https://github.com/moodle/moodle.git
synced 2025-02-15 21:36:58 +01:00
This commit includes: - leap2a portfolio format, and xml writer - proof of concept implementation in forum and assignment modules - a lot of refactoring of the portfolio formats in general: - addition of "abstract" formats - this is necessary for plugins to be able to support groups of formats - addition of the idea of portfolio formats conflicting with eachother - eg richhtml & plainhtml it touches modules other than assignment and forum, because the format api changed and now each place in moodle that exports portfolio content has to deal with the formats it supports slightly differently. At the moment the Mahara portfolio still doesn't support this format, because I haven't done the Mahara side yet. The "file download" plugin supports it though. Still todo: - Add support for the other places in Moodle (glossary, data, etc) - Write tests, once the rest of the portfolio tests have been updated to use the new DB mocking stuff - Fix a bunch of TODOs
79 lines
3.8 KiB
PHP
79 lines
3.8 KiB
PHP
<?php
|
|
|
|
if (!defined('MOODLE_INTERNAL')) {
|
|
die('Direct access to this script is forbidden!');
|
|
}
|
|
require_once($CFG->libdir . '/formslib.php');
|
|
require_once($CFG->libdir . '/csvlib.class.php');
|
|
|
|
class mod_data_export_form extends moodleform {
|
|
var $_datafields = array();
|
|
var $_cm;
|
|
|
|
// @param string $url: the url to post to
|
|
// @param array $datafields: objects in this database
|
|
function mod_data_export_form($url, $datafields, $cm) {
|
|
$this->_datafields = $datafields;
|
|
$this->_cm = $cm;
|
|
parent::moodleform($url);
|
|
}
|
|
|
|
function definition() {
|
|
global $CFG;
|
|
$mform =& $this->_form;
|
|
$mform->addElement('header', 'notice', get_string('chooseexportformat', 'data'));
|
|
$choices = csv_import_reader::get_delimiter_list();
|
|
$key = array_search(';', $choices);
|
|
if (! $key === FALSE) {
|
|
// array $choices contains the semicolon -> drop it (because its encrypted form also contains a semicolon):
|
|
unset($choices[$key]);
|
|
}
|
|
$typesarray = array();
|
|
$typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv');
|
|
$typesarray[] = &MoodleQuickForm::createElement('select', 'delimiter_name', null, $choices);
|
|
$typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls');
|
|
$typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('ods', 'data'), 'ods');
|
|
if ($CFG->enableportfolios) {
|
|
$typesarray[] = &MoodleQuickForm::createElement('radio', 'exporttype', null, get_string('format_leap2a', 'portfolio'), 'leap2a');
|
|
}
|
|
$mform->addGroup($typesarray, 'exportar', '', array(''), false);
|
|
$mform->addRule('exportar', null, 'required');
|
|
$mform->setDefault('exporttype', 'csv');
|
|
if (array_key_exists('cfg', $choices)) {
|
|
$mform->setDefault('delimiter_name', 'cfg');
|
|
} else if (get_string('listsep') == ';') {
|
|
$mform->setDefault('delimiter_name', 'semicolon');
|
|
} else {
|
|
$mform->setDefault('delimiter_name', 'comma');
|
|
}
|
|
$mform->addElement('header', 'notice', get_string('chooseexportfields', 'data'));
|
|
foreach($this->_datafields as $field) {
|
|
if($field->text_export_supported()) {
|
|
$mform->addElement('advcheckbox', 'field_'.$field->field->id, '<div title="' . s($field->field->description) . '">' . $field->field->name . '</div>', ' (' . $field->name() . ')', array('group'=>1));
|
|
$mform->setDefault('field_'.$field->field->id, 1);
|
|
} else {
|
|
$a = new object;
|
|
$a->fieldtype = $field->name();
|
|
$mform->addElement('static', 'unsupported'.$field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a));
|
|
}
|
|
}
|
|
$this->add_checkbox_controller(1, null, null, 1);
|
|
require_once($CFG->libdir . '/portfoliolib.php');
|
|
if ($CFG->enableportfolios && has_capability('mod/data:exportallentries', get_context_instance(CONTEXT_MODULE, $this->_cm->id))) {
|
|
if ($portfoliooptions = portfolio_instance_select(
|
|
portfolio_instances(),
|
|
call_user_func(array('data_portfolio_caller', 'base_supported_formats')),
|
|
'data_portfolio_caller', null, '', true, true)) {
|
|
$mform->addElement('header', 'notice', get_string('portfolionotfile', 'data') . ':');
|
|
$portfoliooptions[0] = get_string('none');
|
|
ksort($portfoliooptions);
|
|
$mform->addElement('select', 'portfolio', get_string('portfolio', 'portfolio'), $portfoliooptions);
|
|
}
|
|
}
|
|
$this->add_action_buttons(true, get_string('exportdatabaserecords', 'data'));
|
|
}
|
|
|
|
}
|
|
|
|
|