add the Extra field back to cloze deletions as "Back Extra"

Originally removed because some users were adding cloze deletions to
it, but removing it just replaced that problem with a new problem where
users add the field but don't add it to their card templates.
This commit is contained in:
Damien Elmes 2020-05-07 08:31:49 +10:00
parent 7bab99d873
commit 389b8a0536
3 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,7 @@ notetypes-front-field = Front
notetypes-back-field = Back
notetypes-add-reverse-field = Add Reverse
notetypes-text-field = Text
notetypes-back-extra-field = Back Extra
## Default note type names

View File

@ -142,11 +142,16 @@ mod test {
assert_eq!(&note.fields, &["one BBB", "two BBB"]);
let note2 = col.storage.get_note(note2.id)?.unwrap();
assert_eq!(&note2.fields, &["three BBB"]);
assert_eq!(&note2.fields, &["three BBB", ""]);
assert_eq!(
col.storage.field_names_for_notes(&nids)?,
vec!["Back".to_string(), "Front".into(), "Text".into()]
vec![
"Back".to_string(),
"Back Extra".into(),
"Front".into(),
"Text".into()
]
);
let cnt = col.find_and_replace(nids.clone(), "BBB", "ccc", Some("Front".into()))?;
// still 2, as the caller is expected to provide only note ids that have

View File

@ -112,8 +112,11 @@ pub(crate) fn cloze(i18n: &I18n) -> NoteType {
nt.name = i18n.tr(TR::NotetypesClozeName).into();
let text = i18n.tr(TR::NotetypesTextField);
nt.add_field(text.as_ref());
let fmt = format!("{{{{cloze:{}}}}}", text);
nt.add_template(nt.name.clone(), fmt.clone(), fmt);
let back_extra = i18n.tr(TR::NotetypesBackExtraField);
nt.add_field(back_extra.as_ref());
let qfmt = format!("{{{{cloze:{}}}}}", text);
let afmt = format!("{}<br>\n{{{{{}}}}}", qfmt, back_extra);
nt.add_template(nt.name.clone(), qfmt, afmt);
nt.config.kind = NoteTypeKind::Cloze as i32;
nt.config.css += "
.cloze {