MDL-18910 normalised module intro and introformat
This commit is contained in:
@@ -60,8 +60,8 @@
|
||||
fwrite ($bf,full_tag("ID",4,false,$choice->id));
|
||||
fwrite ($bf,full_tag("MODTYPE",4,false,"choice"));
|
||||
fwrite ($bf,full_tag("NAME",4,false,$choice->name));
|
||||
fwrite ($bf,full_tag("TEXT",4,false,$choice->text));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$choice->format));
|
||||
fwrite ($bf,full_tag("TEXT",4,false,$choice->intro));
|
||||
fwrite ($bf,full_tag("FORMAT",4,false,$choice->introformat));
|
||||
fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish));
|
||||
fwrite ($bf,full_tag("SHOWRESULTS",4,false,$choice->showresults));
|
||||
fwrite ($bf,full_tag("DISPLAY",4,false,$choice->display));
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/choice/db" VERSION="20060808" COMMENT="XMLDB file for Moodle mod/choice">
|
||||
<XMLDB PATH="mod/choice/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/choice"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="choice" COMMENT="Available choices are stored here" NEXT="choice_options">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="text"/>
|
||||
<FIELD NAME="text" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="format"/>
|
||||
<FIELD NAME="format" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="text" NEXT="publish"/>
|
||||
<FIELD NAME="publish" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="format" NEXT="showresults"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="intro"/>
|
||||
<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
|
||||
<FIELD NAME="introformat" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="publish"/>
|
||||
<FIELD NAME="publish" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="showresults"/>
|
||||
<FIELD NAME="showresults" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="publish" NEXT="display"/>
|
||||
<FIELD NAME="display" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="showresults" NEXT="allowupdate"/>
|
||||
<FIELD NAME="allowupdate" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="display" NEXT="showunanswered"/>
|
||||
@@ -19,7 +22,7 @@
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timeclose"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
|
||||
@@ -56,4 +59,4 @@
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
@@ -28,6 +28,32 @@ function xmldb_choice_upgrade($oldversion) {
|
||||
|
||||
//===== 1.9.0 upgrade line ======//
|
||||
|
||||
if ($result && $oldversion < 2009042000) {
|
||||
|
||||
/// Rename field text on table choice to NEWNAMEGOESHERE
|
||||
$table = new xmldb_table('choice');
|
||||
$field = new xmldb_field('text', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
|
||||
|
||||
/// Launch rename field text
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
|
||||
/// choice savepoint reached
|
||||
upgrade_mod_savepoint($result, 2009042000, 'choice');
|
||||
}
|
||||
|
||||
if ($result && $oldversion < 2009042001) {
|
||||
|
||||
/// Rename field format on table choice to NEWNAMEGOESHERE
|
||||
$table = new xmldb_table('choice');
|
||||
$field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'text');
|
||||
|
||||
/// Launch rename field format
|
||||
$dbman->rename_field($table, $field, 'introformat');
|
||||
|
||||
/// choice savepoint reached
|
||||
upgrade_mod_savepoint($result, 2009042001, 'choice');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ class mod_choice_mod_form extends moodleform_mod {
|
||||
}
|
||||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('htmleditor', 'text', get_string('choicetext', 'choice'));
|
||||
$mform->setType('text', PARAM_RAW);
|
||||
$mform->addRule('text', null, 'required', null, 'client');
|
||||
$mform->setHelpButton('text', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
|
||||
$mform->addElement('htmleditor', 'intro', get_string('choicetext', 'choice'));
|
||||
$mform->setType('intro', PARAM_RAW);
|
||||
$mform->addRule('intro', null, 'required', null, 'client');
|
||||
$mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
|
||||
|
||||
$mform->addElement('format', 'format', get_string('format'));
|
||||
$mform->addElement('format', 'introformat', get_string('format'));
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
$repeatarray=array();
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
//Now, build the CHOICE record structure
|
||||
$choice->course = $restore->course_id;
|
||||
$choice->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
|
||||
$choice->text = backup_todb($info['MOD']['#']['TEXT']['0']['#']);
|
||||
$choice->format = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
|
||||
$choice->intro = backup_todb($info['MOD']['#']['TEXT']['0']['#']);
|
||||
$choice->introformat = backup_todb($info['MOD']['#']['FORMAT']['0']['#']);
|
||||
$choice->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']);
|
||||
$choice->showresults = isset($info['MOD']['#']['SHOWRESULTS']['0']['#'])?backup_todb($info['MOD']['#']['SHOWRESULTS']['0']['#']):'';
|
||||
$choice->display = backup_todb($info['MOD']['#']['DISPLAY']['0']['#']);
|
||||
@@ -376,7 +376,7 @@ function choice_options_restore_mods($choiceid,$info,$restore) {
|
||||
$status = true;
|
||||
|
||||
//Convert choice->text
|
||||
if ($records = $DB->get_records_sql("SELECT c.id, c.text, c.format
|
||||
if ($records = $DB->get_records_sql("SELECT c.id, c.intro, c.introformat
|
||||
FROM {choice} c, {backup_ids} b
|
||||
WHERE c.course = ? AND
|
||||
c.format = ".FORMAT_WIKI. " AND
|
||||
@@ -385,11 +385,11 @@ function choice_options_restore_mods($choiceid,$info,$restore) {
|
||||
b.new_id = c.id", array($restore->course_id, $restore->backup_unique_code))) {
|
||||
foreach ($records as $record) {
|
||||
//Rebuild wiki links
|
||||
$record->text = restore_decode_wiki_content($record->text, $restore);
|
||||
$record->intro = restore_decode_wiki_content($record->intro, $restore);
|
||||
//Convert to Markdown
|
||||
$wtm = new WikiToMarkdown();
|
||||
$record->text = $wtm->convert($record->text, $restore->course_id);
|
||||
$record->format = FORMAT_MARKDOWN;
|
||||
$record->intro = $wtm->convert($record->intro, $restore->course_id);
|
||||
$record->introformat = FORMAT_MARKDOWN;
|
||||
$status = $DB->update_record('choice', $record);
|
||||
//Do some output
|
||||
$i++;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2007101509;
|
||||
$module->requires = 2007101509; // Requires this Moodle version
|
||||
$module->version = 2009042001;
|
||||
$module->requires = 2009041700; // Requires this Moodle version
|
||||
$module->cron = 0;
|
||||
|
||||
?>
|
||||
|
||||
+3
-2
@@ -78,8 +78,9 @@
|
||||
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
if ($choice->text) {
|
||||
print_box(format_text($choice->text, $choice->format), 'generalbox', 'intro');
|
||||
if ($choice->intro) {
|
||||
$options = (object)array('noclean'=>true);
|
||||
print_box(format_text($choice->intro, $choice->introformat, $options), 'generalbox', 'intro');
|
||||
}
|
||||
|
||||
$current = false; // Initialise for later
|
||||
|
||||
Reference in New Issue
Block a user