Skip to content

Commit

Permalink
Wrap multichoice feedback text with CDATA
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicceboy committed Aug 30, 2024
1 parent 2858658 commit 188170b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/question.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,19 @@ impl Question for MultiChoiceQuestion {
writer,
"correctfeedback",
TextFormat::default().into(),
|writer| write_text_tag(writer, &self.correctfeedback, false),
|writer| write_text_tag(writer, &self.correctfeedback, true),
)?;
write_named_formatted_scope(
writer,
"partiallycorrectfeedback",
TextFormat::default().into(),
|writer| write_text_tag(writer, &self.partiallycorrectfeedback, false),
|writer| write_text_tag(writer, &self.partiallycorrectfeedback, true),
)?;
write_named_formatted_scope(
writer,
"incorrectfeedback",
TextFormat::default().into(),
|writer| write_text_tag(writer, &self.incorrectfeedback, false),
|writer| write_text_tag(writer, &self.incorrectfeedback, true),
)?;
write_named_formatted_scope(writer, "answernumbering", None, |writer| {
writer.write(XmlEvent::characters(&self.answernumbering.to_string()))?;
Expand Down Expand Up @@ -492,6 +492,7 @@ mod tests {
let mut buf = String::new();
tmp_file.seek(std::io::SeekFrom::Start(0)).unwrap();
tmp_file.read_to_string(&mut buf).unwrap();
print!("{buf}");
let expected = r#"<?xml version="1.0" encoding="utf-8"?>
<question type="multichoice">
<name>
Expand Down Expand Up @@ -521,13 +522,13 @@ mod tests {
<single>true</single>
<shuffleanswers>1</shuffleanswers>
<correctfeedback format="html">
<text>Correct!</text>
<text><![CDATA[Correct!]]></text>
</correctfeedback>
<partiallycorrectfeedback format="html">
<text>Partially correct!</text>
<text><![CDATA[Partially correct!]]></text>
</partiallycorrectfeedback>
<incorrectfeedback format="html">
<text>Incorrect!</text>
<text><![CDATA[Incorrect!]]></text>
</incorrectfeedback>
<answernumbering>abc</answernumbering>
</question>"#;
Expand Down

0 comments on commit 188170b

Please sign in to comment.