ydkjs-exercises icon indicating copy to clipboard operation
ydkjs-exercises copied to clipboard

Create a CLI for adding new questions

Open austintackaberry opened this issue 6 years ago • 4 comments

The CLI would guide you through creating a new question, create ids for you, and then add the question to the correct file. This isn't super important, but it would be a fun project!

austintackaberry avatar Aug 11 '18 06:08 austintackaberry

I would like to work on this project. I have come up with some points that need to be discussed.

  • It would be better if we have the data in JSON format rather than JS using module.exports. Would prevent us from using hacks while we add the questions.

  • I looked at the questions and some of them can get quite complicated. I don't think we would be able to create a persistent storage (if someone quits the cli midway) and also provide a rich editor experience to make questions. A better and easier approach to just add a prefilled question template to the concerned file taking inputs such as book, chapter name, number of options etc.

Or maybe we can ask if user wants to add a template or complete question through cli (for those who can work on vim). If user chooses cli then we can use Inquirer editor capability which might open vim.

kshitijpurwar avatar Oct 02 '18 06:10 kshitijpurwar

Yeah, maybe it would be better to just have a questionTemplate.json file that had all the required fields and comments about how to use them appropriately?

austintackaberry avatar Oct 02 '18 16:10 austintackaberry

It is a good idea to let someone get started by using the questionTemplate .json template but in long term it would be tedious for someone who intends to add a lot of questions (like me 😄 ).

My approach is to add a CLI question template generator which prompts user to

  1. Select from list of books (upGoing, ES6Beyond etc) - select from list
  2. Then Chapter number - select from list
  3. shouldBeRandomized - (y/n) - boolean
  4. Number of choices - ( 2 < integer input < 4)
  5. Correct choice - int
  6. Show the template and confirm?

Now after taking all the inputs the generator automatically puts the template along with questionId etc in the corresponding file, and prints the location of the file or maybe opens the file in the editor.

Once we achieve this, we can make a extend it's capabilities to add a complete question without going to editor according to feedback from the community.

The problem we will encounter is that when we add the template text to the JS file, we will have to do some hacky text manipulation ( not the most elegant way to do this ) which we can avoid if convert all the data files to JSON

kshitijpurwar avatar Oct 03 '18 07:10 kshitijpurwar

Ooh I like this! I agree that JSON is probably better. My only concern that I can think of right now of switching everything to JSON is that you can't use template literals in JSON. We rely pretty heavily on template literals for our questions that have code blocks.

I understand that template literals are just plain old strings under the hood, but it would be a bit of a pain to use plain old strings instead of template literals for code blocks.

austintackaberry avatar Oct 03 '18 08:10 austintackaberry