Skip to content

Commit

Permalink
MDL-23204 convert text to html in quiz intro
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 16, 2010
1 parent 2af3ca5 commit 07cb667
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mod/quiz/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,21 @@ function xmldb_quiz_upgrade($oldversion) {
$table = new xmldb_table('quiz');
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');

/// Launch add field introformat
$dbman->add_field($table, $field);
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

/// set format to current
$DB->set_field('quiz', 'introformat', FORMAT_MOODLE, array());
// conditionally migrate to html format in intro
if ($CFG->texteditors !== 'textarea') {
$rs = $DB->get_recordset('quiz', array('introformat'=>FORMAT_MOODLE), '', 'id,intro,introformat');
foreach ($rs as $q) {
$q->intro = text_to_html($q->intro, false, false, true);
$q->introformat = FORMAT_HTML;
$DB->update_record('quiz', $q);
upgrade_set_timeout();
}
$rs->close();
}

/// quiz savepoint reached
upgrade_mod_savepoint(true, 2009042000, 'quiz');
Expand Down

0 comments on commit 07cb667

Please sign in to comment.