From: toyomoyo Date: Tue, 5 Jun 2007 09:28:15 +0000 (+0000) Subject: grade import temporary buffer tables and encoding/import form changes X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4d40aa144aa33c7d3ca68beb0d21c6b252793b5a;p=moodle.git grade import temporary buffer tables and encoding/import form changes --- diff --git a/grade/import/grade_import_form.php b/grade/import/grade_import_form.php index 70b836681e..68173d7604 100755 --- a/grade/import/grade_import_form.php +++ b/grade/import/grade_import_form.php @@ -7,11 +7,16 @@ class grade_import_form extends moodleform { // course id needs to be passed for auth purposes $mform->addElement('hidden', 'id', optional_param('id')); - + $mform->addElement('header', 'general', get_string('importfile')); // file upload $mform->addElement('file', 'userfile', get_string('file')); $mform->addRule('userfile', null, 'required'); + $textlib = new textlib(); + $encodings = $textlib->get_encodings(); + $mform->addElement('select', 'encoding', get_string('encoding'), $encodings); + $options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000); + $mform->addElement('select', 'previewrows', 'Preview rows', $options); // TODO: localize $this->add_action_buttons(false, get_string('uploadgrades')); } diff --git a/lib/db/install.xml b/lib/db/install.xml index fcfa70ec80..36c1d4e317 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1386,7 +1386,7 @@ - +
@@ -1405,6 +1405,31 @@
+ + + + + + + + + + + + + + +
+ + + + + + + + + +
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 2a22813248..3a25d94e27 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1356,6 +1356,44 @@ function xmldb_main_upgrade($oldversion=0) { $result = $result && change_field_default($table, $field); } + /// new tables for import buffers + if ($result && $oldversion < 2007060502) { + + /// Define table grade_import_values to be created + $table = new XMLDBTable('grade_import_values'); + + /// Adding fields to table grade_import_values + $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('itemid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null); + $table->addFieldInfo('newgradeitem', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null); + $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('gradevalue', XMLDB_TYPE_NUMBER, '10, 5', null, XMLDB_NOTNULL, null, null, null, '0.0'); + $table->addFieldInfo('import_code', XMLDB_TYPE_INTEGER, '12', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + + /// Adding keys to table grade_import_values + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->addKeyInfo('itemid', XMLDB_KEY_FOREIGN, array('itemid'), 'grade_items', array('id')); + $table->addKeyInfo('newgradeitem', XMLDB_KEY_FOREIGN, array('newgradeitem'), 'grade_import_newitem', array('id')); + + /// Launch create table for grade_import_values + $result = $result && create_table($table); + + /// Define table grade_import_newitem to be created + $table = new XMLDBTable('grade_import_newitem'); + + /// Adding fields to table grade_import_newitem + $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('itemname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('import_cpde', XMLDB_TYPE_INTEGER, '12', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + + /// Adding keys to table grade_import_newitem + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Launch create table for grade_import_newitem + $result = $result && create_table($table); + } + + return $result; } diff --git a/lib/textlib.class.php b/lib/textlib.class.php index dd2626f81e..fb833154d4 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -332,5 +332,26 @@ class textlib { } return $str; } + + /** + * Returns encoding options for select boxes, utf-8 and platform encoding first + * @return array encodings + */ + function get_encodings() { + $encodings = array(); + $encodings['UTF-8'] = 'UTF-8'; + $winenc = strtoupper(get_string('localewincharset')); + if ($winenc != '') { + $encodings[$winenc] = $winenc; + } + $nixenc = strtoupper(get_string('oldcharset')); + $encodings[$nixenc] = $nixenc; + + foreach ($this->typo3cs->synonyms as $enc) { + $enc = strtoupper($enc); + $encodings[$enc] = $enc; + } + return $encodings; + } } ?> diff --git a/version.php b/version.php index 11f36df16f..e24ad1b58f 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007060501; // YYYYMMDD = date + $version = 2007060502; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name