mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
Added: nc for typed answers
This commit is contained in:
parent
4e8bf13813
commit
7cb7d208c6
3 changed files with 12 additions and 5 deletions
|
|
@ -307,6 +307,7 @@ message NextCardDataResponse {
|
||||||
string body_class = 6;
|
string body_class = 6;
|
||||||
bool autoplay = 7;
|
bool autoplay = 7;
|
||||||
optional string typed_answer = 12;
|
optional string typed_answer = 12;
|
||||||
|
optional string typed_answer_args = 13;
|
||||||
|
|
||||||
repeated card_rendering.AVTag question_av_tags = 8;
|
repeated card_rendering.AVTag question_av_tags = 8;
|
||||||
repeated card_rendering.AVTag answer_av_tags = 9;
|
repeated card_rendering.AVTag answer_av_tags = 9;
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,10 @@ impl crate::services::SchedulerService for Collection {
|
||||||
let mut out = None;
|
let mut out = None;
|
||||||
*text = ANSWER_REGEX
|
*text = ANSWER_REGEX
|
||||||
.replace(text, |cap: ®ex::Captures<'_>| {
|
.replace(text, |cap: ®ex::Captures<'_>| {
|
||||||
out = Some(cap[2].to_string());
|
out = Some((
|
||||||
|
cap.get(1).map(|g| g.as_str().to_string()),
|
||||||
|
cap[2].to_string(),
|
||||||
|
));
|
||||||
ANSWER_HTML
|
ANSWER_HTML
|
||||||
})
|
})
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
@ -441,12 +444,14 @@ impl crate::services::SchedulerService for Collection {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let typed_answer = typed_answer_parent_node.map(|field| {
|
let typed_answer = typed_answer_parent_node.as_ref().map(|field| {
|
||||||
let note = self.get_note(next_card.card.note_id.into()).unwrap();
|
let note = self.get_note(next_card.card.note_id.into()).unwrap();
|
||||||
let notetype = self.get_notetype(note.notetype_id.into()).unwrap().unwrap();
|
let notetype = self.get_notetype(note.notetype_id.into()).unwrap().unwrap();
|
||||||
note.fields[notetype.get_field_ord(&field).unwrap()].clone()
|
note.fields[notetype.get_field_ord(&field.1).unwrap()].clone()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dbg!(&typed_answer_parent_node);
|
||||||
|
|
||||||
Ok(NextCardDataResponse {
|
Ok(NextCardDataResponse {
|
||||||
next_card: Some(NextCardData {
|
next_card: Some(NextCardData {
|
||||||
queue: Some(queue.into()),
|
queue: Some(queue.into()),
|
||||||
|
|
@ -458,6 +463,7 @@ impl crate::services::SchedulerService for Collection {
|
||||||
answer_buttons,
|
answer_buttons,
|
||||||
autoplay: !config.inner.disable_autoplay,
|
autoplay: !config.inner.disable_autoplay,
|
||||||
typed_answer,
|
typed_answer,
|
||||||
|
typed_answer_args: typed_answer_parent_node.and_then(|v| v.0),
|
||||||
|
|
||||||
// Filled by python
|
// Filled by python
|
||||||
front: "".to_string(),
|
front: "".to_string(),
|
||||||
|
|
|
||||||
|
|
@ -137,13 +137,13 @@ export class ReviewerState {
|
||||||
}
|
}
|
||||||
|
|
||||||
async showTypedAnswer(html: string) {
|
async showTypedAnswer(html: string) {
|
||||||
if (!this._cardData?.typedAnswer) {
|
if (!this._cardData?.typedAnswer || !this._cardData.typedAnswerArgs) {
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
const compareAnswerResp = await compareAnswer({
|
const compareAnswerResp = await compareAnswer({
|
||||||
expected: this._cardData?.typedAnswer,
|
expected: this._cardData?.typedAnswer,
|
||||||
provided: this.currentTypedAnswer,
|
provided: this.currentTypedAnswer,
|
||||||
combining: false,
|
combining: !this._cardData.typedAnswerArgs.includes("nc"),
|
||||||
});
|
});
|
||||||
const display = compareAnswerResp.val;
|
const display = compareAnswerResp.val;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue