supermemo / SuperMemoAssistant

A companion app for SuperMemo 17-18 which extends its functionalities through plugins.
https://www.supermemo.wiki/sma/
MIT License
195 stars 20 forks source link

A Way to define SM templates on Item(s') creation #237

Open ghost opened 3 years ago

ghost commented 3 years ago

Description

On item/Element creation the user can provide a template to map to be it the currently presented one in the SM window/the default SM template/ a template from the template registry. A prime use for this would be to map between Anki Fields to the SM templates for use in the Anki Importer.

Sketches, Videos, ...

None that I have at the moment.

Environment

This feature should be enabled on element creation, through the SMA SDK.

Motivation

Why do you want to see this feature ? Anki Cards come in all shapes and templates and the default question and answer format of SM can be disappointing and unappealing to new Users and somewhat restricting to a subset of cards particularly language learning cards.

What use cases does it support ? Anki to supermemo importer and various possible future importers.

Approximately how big percent of user base do you think would use this feature ? I guess 80% of anki users migrating to SM or students looking to use Anki as a form of question bank.

Documentation-type explanation

Explain the feature, and the steps to use it as if you were writing instructions for first-time users.

var elembldr = new ElementBuilder(ElementType.Item) ....// some functions .WithTemplate(tmplt );


- To create a Template:

// Creating a component Component mycomponent = ComponentRegistry.HTML_Component(); mycomponent.Width = 200; mycomponent.Height = 200; mycomponent.Position = (0,20); // x , y

List mycomponents = new List() {// A list of Components};

// Creating a template using the Template Builder Template tmplt = new TemplateBuilder() .Named("My New Template") .WithComponent(ComponentRegistry.HTML_Component()) // default SM components .WithComponent(mycomponent ) .WithComponents( mycomponents) .Build();


- To get a Template:

Template tmplt = TemplateRegistry.Instance.getNamedTemplate("Youtube Template");


- To add a template to the registry :

Template tmplt = .../Some created template TemplateRegistry.Instance.AddTemplate(tmplt);



#### Drawbacks
 **What potential issues should we consider ? Why should we *not* do this ?**
Perhaps Template registry needs to add the new currently defined template, or just restrict it to existing templates within the registry. Some way to ensure no corruption to the template registry can occur.
alexis- commented 3 years ago

SMA has its own template system, see "Layout" in the source code.

Your FR is still valid though. Excellent write up, by the way.