Add ordinals to IO clozes (#2763)

Co-authored-by: Glutanimate <glutanimate@users.noreply.github.com>
This commit is contained in:
Aristotelis 2023-10-22 02:52:22 +02:00 committed by GitHub
parent f8edbcc686
commit 26b2ac4ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,12 +301,14 @@ fn reveal_cloze(
fn render_image_occlusion(text: &str, question_side: bool, active: bool, ordinal: u16) -> String {
if (question_side && active) || ordinal == 0 {
format!(
r#"<div class="cloze" {}></div>"#,
r#"<div class="cloze" data-ordinal="{}" {}></div>"#,
ordinal,
&get_image_cloze_data(text)
)
} else if !active {
format!(
r#"<div class="cloze-inactive" {}></div>"#,
r#"<div class="cloze-inactive" data-ordinal="{}" {}></div>"#,
ordinal,
&get_image_cloze_data(text)
)
} else {
@ -593,7 +595,7 @@ mod test {
true
),
format!(
r#"<div class="cloze" data-shape="rect" data-left="10.0" data-top="20" data-width="30" data-height="10" ></div>"#,
r#"<div class="cloze" data-ordinal="1" data-shape="rect" data-left="10.0" data-top="20" data-width="30" data-height="10" ></div>"#,
)
);
}