From d0bcf735aa3fd032c72643fef178a8a53513894b Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 20 Apr 2009 19:57:04 +0000 Subject: [PATCH] MDL-18910 normalised module intro and introformat --- mod/choice/db/install.xml | 2 +- mod/choice/db/upgrade.php | 2 +- mod/data/db/install.xml | 2 +- mod/data/db/upgrade.php | 2 +- mod/feedback/db/install.xml | 2 +- mod/feedback/db/upgrade.php | 8 +++----- mod/forum/db/install.xml | 2 +- mod/forum/db/upgrade.php | 2 +- mod/glossary/db/install.xml | 2 +- mod/glossary/db/upgrade.php | 2 +- mod/scorm/backuplib.php | 2 +- mod/scorm/db/install.xml | 11 ++++++----- mod/scorm/db/upgrade.php | 26 ++++++++++++++++++++++++++ mod/scorm/index.php | 5 +++-- mod/scorm/locallib.php | 3 ++- mod/scorm/mod_form.php | 8 ++++---- mod/scorm/restorelib.php | 8 ++++---- mod/scorm/version.php | 4 ++-- mod/scorm/view.php | 3 ++- 19 files changed, 62 insertions(+), 34 deletions(-) diff --git a/mod/choice/db/install.xml b/mod/choice/db/install.xml index b6f1889f34..c14ed3bfb9 100644 --- a/mod/choice/db/install.xml +++ b/mod/choice/db/install.xml @@ -10,7 +10,7 @@ - + diff --git a/mod/choice/db/upgrade.php b/mod/choice/db/upgrade.php index 2c7eb5f1ab..c636000d18 100644 --- a/mod/choice/db/upgrade.php +++ b/mod/choice/db/upgrade.php @@ -45,7 +45,7 @@ function xmldb_choice_upgrade($oldversion) { /// 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', 'intro'); + $field = new xmldb_field('format', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Launch rename field format $dbman->rename_field($table, $field, 'introformat'); diff --git a/mod/data/db/install.xml b/mod/data/db/install.xml index 7920a2f469..cca08c379e 100644 --- a/mod/data/db/install.xml +++ b/mod/data/db/install.xml @@ -10,7 +10,7 @@ - + diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 0847570abf..e4f911f79e 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -171,7 +171,7 @@ function xmldb_data_upgrade($oldversion) { /// Define field introformat to be added to data $table = new xmldb_table('data'); - $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Launch add field introformat $dbman->add_field($table, $field); diff --git a/mod/feedback/db/install.xml b/mod/feedback/db/install.xml index ae6a4e5b7e..ec3c24a378 100644 --- a/mod/feedback/db/install.xml +++ b/mod/feedback/db/install.xml @@ -10,7 +10,7 @@ - + diff --git a/mod/feedback/db/upgrade.php b/mod/feedback/db/upgrade.php index e46d9c8b77..31d0e9191e 100644 --- a/mod/feedback/db/upgrade.php +++ b/mod/feedback/db/upgrade.php @@ -268,12 +268,10 @@ function xmldb_feedback_upgrade($oldversion) { /// Define field introformat to be added to feedback $table = new xmldb_table('feedback'); - $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); - /// Conditionally launch add field introformat - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } + /// Launch add field introformat + $dbman->add_field($table, $field); /// feedback savepoint reached upgrade_mod_savepoint($result, 2009042001, 'feedback'); diff --git a/mod/forum/db/install.xml b/mod/forum/db/install.xml index d874ed514b..d07b8e5c2f 100644 --- a/mod/forum/db/install.xml +++ b/mod/forum/db/install.xml @@ -11,7 +11,7 @@ - + diff --git a/mod/forum/db/upgrade.php b/mod/forum/db/upgrade.php index 2ff19731d6..8a1e4a5842 100644 --- a/mod/forum/db/upgrade.php +++ b/mod/forum/db/upgrade.php @@ -224,7 +224,7 @@ function xmldb_forum_upgrade($oldversion) { /// Define field introformat to be added to forum $table = new xmldb_table('forum'); - $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Launch add field introformat $dbman->add_field($table, $field); diff --git a/mod/glossary/db/install.xml b/mod/glossary/db/install.xml index ee25a196ba..33ddc39055 100644 --- a/mod/glossary/db/install.xml +++ b/mod/glossary/db/install.xml @@ -10,7 +10,7 @@ - + diff --git a/mod/glossary/db/upgrade.php b/mod/glossary/db/upgrade.php index 9f24123389..6322fd8cda 100644 --- a/mod/glossary/db/upgrade.php +++ b/mod/glossary/db/upgrade.php @@ -194,7 +194,7 @@ function xmldb_glossary_upgrade($oldversion) { /// Define field introformat to be added to glossary $table = new xmldb_table('glossary'); - $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); /// Conditionally launch add field introformat if (!$dbman->field_exists($table, $field)) { diff --git a/mod/scorm/backuplib.php b/mod/scorm/backuplib.php index 0b083677ab..50921ec337 100755 --- a/mod/scorm/backuplib.php +++ b/mod/scorm/backuplib.php @@ -64,7 +64,7 @@ fwrite ($bf,full_tag('GRADEMETHOD',4,false,$scorm->grademethod)); fwrite ($bf,full_tag('LAUNCH',4,false,$scorm->launch)); fwrite ($bf,full_tag('SKIPVIEW',4,false,$scorm->skipview)); - fwrite ($bf,full_tag('SUMMARY',4,false,$scorm->summary)); + fwrite ($bf,full_tag('SUMMARY',4,false,$scorm->intro)); fwrite ($bf,full_tag('HIDEBROWSE',4,false,$scorm->hidebrowse)); fwrite ($bf,full_tag('HIDETOC',4,false,$scorm->hidetoc)); fwrite ($bf,full_tag('HIDENAV',4,false,$scorm->hidenav)); diff --git a/mod/scorm/db/install.xml b/mod/scorm/db/install.xml index 91e69572b5..b2813aaffa 100644 --- a/mod/scorm/db/install.xml +++ b/mod/scorm/db/install.xml @@ -1,5 +1,5 @@ - @@ -10,9 +10,10 @@ - - - + + + + @@ -194,4 +195,4 @@ - + \ No newline at end of file diff --git a/mod/scorm/db/upgrade.php b/mod/scorm/db/upgrade.php index aa6788f899..b05b4e3135 100644 --- a/mod/scorm/db/upgrade.php +++ b/mod/scorm/db/upgrade.php @@ -400,6 +400,32 @@ function xmldb_scorm_upgrade($oldversion) { upgrade_mod_savepoint($result, 2008090310, 'scorm'); } + if ($result && $oldversion < 2009042000) { + + /// Rename field summary on table scorm to intro + $table = new xmldb_table('scorm'); + $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'reference'); + + /// Launch rename field summary + $dbman->rename_field($table, $field, 'intro'); + + /// scorm savepoint reached + upgrade_mod_savepoint($result, 2009042000, 'scorm'); + } + + if ($result && $oldversion < 2009042001) { + + /// Define field introformat to be added to scorm + $table = new xmldb_table('scorm'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + + /// Launch add field introformat + $dbman->add_field($table, $field); + + /// scorm savepoint reached + upgrade_mod_savepoint($result, 2009042001, 'scorm'); + } + return $result; } diff --git a/mod/scorm/index.php b/mod/scorm/index.php index 41163d2197..7afbf08557 100755 --- a/mod/scorm/index.php +++ b/mod/scorm/index.php @@ -80,14 +80,15 @@ $report = scorm_grade_user($scorm, $USER->id); $reportshow = get_string('score','scorm').": ".$report; } + $options = (object)array('noclean'=>true); if (!$scorm->visible) { //Show dimmed if the mod is hidden $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)."", - format_text($scorm->summary), $reportshow); + format_text($scorm->intro, $scorm->introformat, $options), $reportshow); } else { //Show normal if the mod is visible $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)."", - format_text($scorm->summary), $reportshow); + format_text($scorm->intro, $scorm->introformat, $options), $reportshow); } } diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 0ea34b0752..35ead245d0 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -700,7 +700,8 @@ function scorm_course_format_display($user,$course) { } $colspan = ' colspan="2"'; } - $headertext .= ''.format_text(get_string('summary').':
'.$scorm->summary).''; + $options = (object)array('noclean'=>true); + $headertext .= ''.get_string('summary').':
'.format_text($scorm->intro, $scorm->introformat, $options).''; print_simple_box($headertext,'','100%'); scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%'); } else { diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php index 5dcb8c5342..33a0f097f8 100644 --- a/mod/scorm/mod_form.php +++ b/mod/scorm/mod_form.php @@ -30,10 +30,10 @@ class mod_scorm_mod_form extends moodleform_mod { $mform->addRule('name', null, 'required', null, 'client'); // Summary - $mform->addElement('htmleditor', 'summary', get_string('summary')); - $mform->setType('summary', PARAM_RAW); - $mform->addRule('summary', get_string('required'), 'required', null, 'client'); - $mform->setHelpButton('summary', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton'); + $mform->addElement('htmleditor', 'intro', get_string('summary')); + $mform->setType('intro', PARAM_RAW); + $mform->addRule('intro', get_string('required'), 'required', null, 'client'); + $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton'); // Scorm types $options = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm')); diff --git a/mod/scorm/restorelib.php b/mod/scorm/restorelib.php index 5f800f7982..a9d8362470 100755 --- a/mod/scorm/restorelib.php +++ b/mod/scorm/restorelib.php @@ -75,7 +75,7 @@ } else { $scorm->skipview = backup_todb($info['MOD']['#']['SKIPVIEW']['0']['#']); } - $scorm->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']); + $scorm->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']); $scorm->hidebrowse = backup_todb($info['MOD']['#']['HIDEBROWSE']['0']['#']); $scorm->hidetoc = backup_todb($info['MOD']['#']['HIDETOC']['0']['#']); $scorm->hidenav = backup_todb($info['MOD']['#']['HIDENAV']['0']['#']); @@ -808,18 +808,18 @@ global $CFG; $status = true; - if ($scorms = $DB->get_records('scorm', array('course'=>$restore->course_id), '', "id,summary")) { + if ($scorms = $DB->get_records('scorm', array('course'=>$restore->course_id), '', "id,intro")) { $i = 0; //Counter to send some output to the browser to avoid timeouts foreach ($scorms as $scorm) { //Increment counter $i++; - $content = $scorm->summary; + $content = $scorm->intro; $result = restore_decode_content_links_worker($content,$restore); if ($result != $content) { //Update record - $scorm->summary = $result; + $scorm->intro = $result; $status = $DB->update_record("scorm",$scorm); if (debugging()) { if (!defined('RESTORE_SILENTLY')) { diff --git a/mod/scorm/version.php b/mod/scorm/version.php index 21df95ec5c..b0eb5c3c62 100755 --- a/mod/scorm/version.php +++ b/mod/scorm/version.php @@ -10,8 +10,8 @@ // catch up now, so until 27th October please only increment in very tiny steps // in HEAD, until we get past that date.. -$module->version = 2008090310; // The (date) version of this module -$module->requires = 2008090108; // The version of Moodle that is required +$module->version = 2009042001; // The (date) version of this module +$module->requires = 2009041700; // The version of Moodle that is required $module->cron = 300; // How often should cron check this module (seconds)? ?> \ No newline at end of file diff --git a/mod/scorm/view.php b/mod/scorm/view.php index 25147a867d..29011a4055 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -75,7 +75,8 @@ if($scorm->displayattemptstatus == 1) { $attemptstatus = scorm_get_attempt_status($USER,$scorm); } - print_simple_box(format_text($scorm->summary).$attemptstatus, 'center', '70%', '', 5, 'generalbox', 'intro'); + $options = (object)array('noclean'=>true); + print_simple_box(format_text($scorm->intro, $scorm->introformat, $options).$attemptstatus, 'center', '70%', '', 5, 'generalbox', 'intro'); $scormopen = true; $timenow = time(); -- 2.39.5