// 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'));
}
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="scaleid"/>
</KEYS>
</TABLE>
- <TABLE NAME="grade_history" COMMENT="This table keeps track of grade changes. Using this it should be possible to reconstruct the grades at any point in time in the past, or to audit grade changes over time. It should be quicker to use this table for that, rather than storing this information in the main Moodle log. Note we use itemid and userid as a key rather than grade_grade id, just in case one of the things we want to log here is the deletion of a grade entirely." PREVIOUS="grade_outcomes">
+ <TABLE NAME="grade_history" COMMENT="This table keeps track of grade changes. Using this it should be possible to reconstruct the grades at any point in time in the past, or to audit grade changes over time. It should be quicker to use this table for that, rather than storing this information in the main Moodle log. Note we use itemid and userid as a key rather than grade_grade id, just in case one of the things we want to log here is the deletion of a grade entirely." PREVIOUS="grade_outcomes" NEXT="grade_import_values">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="itemid"/>
<FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="The grade_item the grade is from" PREVIOUS="id" NEXT="userid"/>
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id" PREVIOUS="userid"/>
</KEYS>
</TABLE>
+ <TABLE NAME="grade_import_values" COMMENT="Temporary table for importing grades" PREVIOUS="grade_history" NEXT="grade_import_newitem">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="itemid"/>
+ <FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="if set, this points to existing grade_items id" PREVIOUS="id" NEXT="newgradeitem"/>
+ <FIELD NAME="newgradeitem" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="if set, points to the id of grade_import_newitem" PREVIOUS="itemid" NEXT="userid"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="newgradeitem" NEXT="gradevalue"/>
+ <FIELD NAME="gradevalue" TYPE="number" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0.0" SEQUENCE="false" ENUM="false" DECIMALS="5" COMMENT="raw grade value" PREVIOUS="userid" NEXT="import_code"/>
+ <FIELD NAME="import_code" TYPE="int" LENGTH="12" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="similar to backup_code, a unique batch code for identifying one batch of imports" PREVIOUS="gradevalue"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="itemid"/>
+ <KEY NAME="itemid" TYPE="foreign" FIELDS="itemid" REFTABLE="grade_items" REFFIELDS="id" PREVIOUS="primary" NEXT="newgradeitem"/>
+ <KEY NAME="newgradeitem" TYPE="foreign" FIELDS="newgradeitem" REFTABLE="grade_import_newitem" REFFIELDS="id" PREVIOUS="itemid"/>
+ </KEYS>
+ </TABLE>
+ <TABLE NAME="grade_import_newitem" COMMENT="temporary table for storing new grade_item names from grade import" PREVIOUS="grade_import_values">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="itemname"/>
+ <FIELD NAME="itemname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="new grade item name" PREVIOUS="id" NEXT="import_cpde"/>
+ <FIELD NAME="import_cpde" TYPE="int" LENGTH="12" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="import batch code for identification" PREVIOUS="itemname"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
+ </KEYS>
+ </TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
$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;
}
}
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;
+ }
}
?>
// 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