Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing cloze fails with unknown reason #103

Closed
f-dangel opened this issue Oct 26, 2022 · 10 comments
Closed

Pushing cloze fails with unknown reason #103

f-dangel opened this issue Oct 26, 2022 · 10 comments

Comments

@f-dangel
Copy link

Hi,

creating and pushing clozes stopped working for me in the latest anki version (I use anki 2.1.54 Qt5 on Ubuntu 22). It still works for Basic (and reversed card)s.

To reproduce, call anki-editor-push-notes on the following example

* Test cloze
:PROPERTIES:
:ANKI_DECK: Default
:ANKI_NOTE_TYPE: Cloze
:END:
** Text
Some note

This fails with :ANKI_FAILURE_REASON: cannot create note for unknown reason

* Test cloze
:PROPERTIES:
:ANKI_DECK: Default
:ANKI_NOTE_TYPE: Cloze
:ANKI_FAILURE_REASON: cannot create note for unknown reason
:END:
** Text
Some note

any idea how to fix this or what causes it?

Best,
Felix

@doolio
Copy link

doolio commented Oct 27, 2022

I presume you have installed via melpa? If you can check using the develop branch which introduces changes to the API it may resolve your issues. I can't say it will for sure as I'm still using Anki v2.1.15. See also #101.

@f-dangel
Copy link
Author

Hi,

thanks for the suggestion, indeed I installed via melpa. I just installed from develop (ff3230f) and checked again. Sadly, the problem persists and I get the same error message.

@orgtre
Copy link

orgtre commented Nov 3, 2022

I was receiving the same error message and believe the problem lies with Anki. When I got this message I also got the message "Cloze deletion can only be used on cloze notetypes" in the editor when trying to add a new note of type "Cloze" in Anki. The message appeared only after writing something like {{c1::test}} in the Text field and prevented me from adding the note. Do you see the same behavior?

After going to "Tools - Manage Note Types", deleting the "Cloze" note type (you could switch cards of this type to another type temporarily to avoid deleting them), and adding it back via the "Add" button and "Add: Cloze", I am not having this problem anymore. I can again create "Cloze" cards both within Anki and by pushing from anki-editor.

Maybe it was just a bug or the problem might have been related to this fact from the Anki manual:

The cloze note type is treated specially by Anki, and cannot be created based on a regular note type. If you wish to customize it, please make sure to clone the existing Cloze type instead of another type of note.

@f-dangel
Copy link
Author

f-dangel commented Nov 3, 2022

Hi, and thanks for the suggestions!

Since my workflow is completely based on anki-editor, and I have never used the {{...}} syntax before in my notes, I cannot confirm that using the syntax from within Anki causes the problem I have with creating Clozes.

I followed your suggestion to delete and add the Close note type. However, this did not solve my issue and I keep seeing the :ANKI_FAILURE_REASON: cannot create note for unknown reason.

@orgtre
Copy link

orgtre commented Nov 3, 2022

Too bad, if the problem persists I'd suggest trying to create some cloze cards within Anki to see if it works as expected there. If not you might have more luck asking for help on the Anki Forums.

I tried to reproduce your example:

* Test cloze
:PROPERTIES:
:ANKI_DECK: Default
:ANKI_NOTE_TYPE: Cloze
:END:
** Text
Some note

And indeed I also get cannot create note for unknown reason. The issue then seems to be that Anki expects Cloze cards to actually contain some cloze syntax, so instead of just writing "Some note" try "Some {{c1::note}}":

* Test cloze
:PROPERTIES:
:ANKI_DECK: Default
:ANKI_NOTE_TYPE: Cloze
:END:
** Text
Some {{c1::note}}

This note then pushes successfully for me. So the issue seems to be mainly the very uninformative error message (which we can't easily fix as anki-editor just passes on error messages from Anki/AnkiConnect). Does this solve your issue?

@doolio
Copy link

doolio commented Nov 4, 2022

The issue then seems to be that Anki expects Cloze cards to actually contain some cloze syntax

But is that really surprising? I haven't used Cloze cards as yet so never fell victim to this issue.

In any case, to add a data point to support this. I'm running:

Version 2.1.15 (442df9d6)
Qt 5.15.2 PyQt 5.15.2

And this version creates the card for the test case suggested by OP but when viewing the card instead of displaying the content it displays the following message to include some cloze deletions and a link to help on the subject.

Please edit this note and add some cloze deletions. (help)

If I view the card in the Anki browser I see the card content given in the test case.

I presume both of you are running a newer version of Anki and so the card is simply not produced if cloze deletions do not exist for a Cloze note type.

@f-dangel why do you consider the test case you provided a Cloze card if it doesn't contain any close deletions?

@f-dangel
Copy link
Author

f-dangel commented Nov 5, 2022

Hey (btw thanks a lot for your help, I really appreciate it),

in fact I am 'abusing' cloze cards as one-sided cards without hidden information (like a fact I want to be reminded of every now and then). So chances are I am using the wrong card type to achieve what I want.

Is there a card type that reflects what I am trying to achieve?

Best

@orgtre
Copy link

orgtre commented Nov 5, 2022

@doolio You're right, it's not so surprising. And yes, I'm also running Anki 2.1.54.

@f-dangel There is no built in note type with only one field/side but you can easily create one yourself within Anki (the desktop app). See this section in the manual. You'd go to Tools - Manage Note Types - Add - Add: Basic - OK. Then input a new name. Highlight the note type you just created and press Fields, highlight "Back" and press delete and save. You might then also want to click Cards and adjust the back template.

@f-dangel
Copy link
Author

f-dangel commented Nov 5, 2022

Hi again,

thank you for the description; this solves my problem:

  • I opened the Anki desktop app, navigated to Tools -> Manage Note Types, and created a new note named One side by clicking on Add, entering the name, and confirming by clicking OK.
  • Then, I configured the note type by clicking onto One side, then Fields. I removed the 2: Back field, and renamed 1: Front into 1: Text. Then, I can push notes that look as follows and do what I am trying to achieve:
* Test one side
:PROPERTIES:
:ANKI_DECK: Default
:ANKI_NOTE_TYPE: One side
:END:
** Text
Some note

Thank you very much for the quick responses.

I am not sure how relevant my use case is for others, and how to rename the issue such that it will be helpful for others in the future. Feel free to go ahead.

Best,
Felix

@f-dangel f-dangel closed this as completed Nov 5, 2022
@doolio
Copy link

doolio commented Nov 7, 2022

Glad you found a solution. I would have made the same suggestion as orgtre. I'm curious though about your rationale. I don't understand how you are testing anything with a one sided card that isn't a cloze card. That is when the card appears you see all its content.

FYI, you can also specify :ANKI_DECK: Default as a file property by placing the following somewhere at the top of your file:

#+property: ANKI_DECK Default

This can be used when all the cards in a single file will be added to the same deck. I just use one deck but separate my cards by subject area in different org files. It avoids the need for subdecks (which at one time was recommended by the Anki maintainers) but still provides a level of organisation. This line just means I don't repeat myself in every headline property drawer. I do the same for the ANKI_TAGS property. So within each headline drawer I only have the Anki related properties ANKI_NOTE_TYPE and ANKI_NOTE_ID which are generally unique for each card. You can still override individual cards at the heading level if necessary. Be sure to hit C-c C-c somewhere on this line to refresh the local contents.

I also keep anki-editor-org-tags-as-anki-tags set to nil and have a file property for org tags with at least one tag namely #+tags: fc. With this I'm experimenting using org-fc to also have my SRS fully within Emacs, yay! This works using the same cards as anki-editor and org-fc use different headline properties. I will still use Anki has it offers excellent mobile support which I think is important so I can still do my reviews when away from my computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants