Added support for getting the buttons and the estimated interval times (no tests!)
This commit is contained in:
		
							parent
							
								
									d925cddf17
								
							
						
					
					
						commit
						540d190c2a
					
				@ -319,10 +319,9 @@ class CollectionHandler(RestHandlerBase):
 | 
				
			|||||||
    #
 | 
					    #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @noReturnValue
 | 
					    @noReturnValue
 | 
				
			||||||
    def sched_reset(self, col, data, ids):
 | 
					    def reset_scheduler(self, col, data, ids):
 | 
				
			||||||
        col.sched.reset()
 | 
					        col.sched.reset()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class ImportExportHandler(RestHandlerBase):
 | 
					class ImportExportHandler(RestHandlerBase):
 | 
				
			||||||
    """Handler group for the 'collection' type, but it's not added by default."""
 | 
					    """Handler group for the 'collection' type, but it's not added by default."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -420,6 +419,22 @@ class NoteHandler(RestHandlerBase):
 | 
				
			|||||||
class DeckHandler(RestHandlerBase):
 | 
					class DeckHandler(RestHandlerBase):
 | 
				
			||||||
    """Default handler group for 'deck' type."""
 | 
					    """Default handler group for 'deck' type."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    button_labels = ['Easy', 'Good', 'Hard']
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # Code stolen from aqt/reviewer.py
 | 
				
			||||||
 | 
					    def _get_answer_buttons(self, col, card):
 | 
				
			||||||
 | 
					        l = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Put the correct number of buttons
 | 
				
			||||||
 | 
					        cnt = col.sched.answerButtons(card)
 | 
				
			||||||
 | 
					        for idx in range(0, cnt - 1):
 | 
				
			||||||
 | 
					            l.append(self.button_labels[idx])
 | 
				
			||||||
 | 
					        l.append('Again')
 | 
				
			||||||
 | 
					        l.reverse()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Loop through and add the ease and estimated time (in seconds)
 | 
				
			||||||
 | 
					        return [(ease, label, col.sched.nextIvl(card, ease)) for ease, label in enumerate(l, 1)]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def next_card(self, col, data, ids):
 | 
					    def next_card(self, col, data, ids):
 | 
				
			||||||
        deck_id = ids[1]
 | 
					        deck_id = ids[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -428,7 +443,10 @@ class DeckHandler(RestHandlerBase):
 | 
				
			|||||||
        if card is None:
 | 
					        if card is None:
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return CardHandler._serialize(card)
 | 
					        result = CardHandler._serialize(card)
 | 
				
			||||||
 | 
					        result['answer_buttons'] = self._get_answer_buttons(col, card)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CardHandler(RestHandlerBase):
 | 
					class CardHandler(RestHandlerBase):
 | 
				
			||||||
    """Default handler group for 'card' type."""
 | 
					    """Default handler group for 'card' type."""
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user