mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
MDL-48984 mod_lesson: some lesson_answers answers should be plain text
Branch tables jump descriptions, short answer question answers and numerical question answers should be plain text, and no editor should be available here.
This commit is contained in:
parent
dba564c7db
commit
a1300e98bb
5 changed files with 88 additions and 19 deletions
|
@ -137,5 +137,30 @@ function xmldb_lesson_upgrade($oldversion) {
|
|||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2014122900, 'lesson');
|
||||
}
|
||||
|
||||
if ($oldversion < 2015022700) {
|
||||
|
||||
// Clean lesson answers that should be plain text.
|
||||
// Unfortunately we can't use LESSON_PAGE_XX constants here as we can't include the files.
|
||||
// 1 = LESSON_PAGE_SHORTANSWER, 8 = LESSON_PAGE_NUMERICAL, 20 = LESSON_PAGE_BRANCHTABLE.
|
||||
|
||||
$sql = 'SELECT a.*
|
||||
FROM {lesson_answers} a
|
||||
JOIN {lesson_pages} p ON p.id = a.pageid
|
||||
WHERE a.answerformat <> :format
|
||||
AND p.qtype IN (1, 8, 20)';
|
||||
$badanswers = $DB->get_recordset_sql($sql, array('format' => FORMAT_MOODLE));
|
||||
|
||||
foreach ($badanswers as $badanswer) {
|
||||
// Strip tags from answer text and convert back the format to FORMAT_MOODLE.
|
||||
$badanswer->answer = strip_tags($badanswer->answer);
|
||||
$badanswer->answerformat = FORMAT_MOODLE;
|
||||
$DB->update_record('lesson_answers', $badanswer);
|
||||
}
|
||||
|
||||
// Lesson savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2015022700, 'lesson');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue