Remove HTML tags from questions and answers
This commit is contained in:
parent
21094f4a51
commit
ed728833da
1 changed files with 25 additions and 0 deletions
|
@ -133,6 +133,31 @@ if (!$fullname) {
|
|||
$fullname = $shortname;
|
||||
}
|
||||
|
||||
$questionfile = $path . DIRECTORY_SEPARATOR . "questions.xml";
|
||||
|
||||
if (file_exists($questionfile)) {
|
||||
$questions = new DOMDocument();
|
||||
$questions->load($questionfile);
|
||||
|
||||
$questions->save($questionfile . ".bak");
|
||||
|
||||
$questionsection = $questions->documentElement->getElementsByTagName("questions")->item(0);
|
||||
|
||||
foreach ($questionsection->getElementsByTagName("question") as $question) {
|
||||
$questiontext = $question->getElementsByTagName("questiontext")->item(0);
|
||||
$newquestiontext = strip_tags(html_entity_decode($questiontext->textContent));
|
||||
$questiontext->nodeValue = htmlentities($newquestiontext, ENT_XML1);
|
||||
|
||||
foreach ($question->getElementsByTagName("answer") as $answer) {
|
||||
$answertext = $answer->getElementsByTagName("answertext")->item(0);
|
||||
$newanswertext = strip_tags(html_entity_decode($answertext->textContent));
|
||||
$answertext->nodeValue = htmlentities($newanswertext, ENT_XML1);
|
||||
}
|
||||
}
|
||||
|
||||
$questions->save($questionfile);
|
||||
}
|
||||
|
||||
if (!$course && $DB->get_record('course', array('category' => $category->id, 'shortname' => $shortname))) {
|
||||
$matches = NULL;
|
||||
preg_match('/(.*)_(\d+)$/', $shortname, $matches);
|
||||
|
|
Loading…
Reference in a new issue