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

Create a CLI for adding new questions #134

Open
austintackaberry opened this issue Aug 11, 2018 · 4 comments
Open

Create a CLI for adding new questions #134

austintackaberry opened this issue Aug 11, 2018 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@austintackaberry
Copy link
Owner

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 austintackaberry added enhancement New feature or request help wanted Extra attention is needed labels Aug 11, 2018
@kshitijpurwar
Copy link
Contributor

kshitijpurwar commented Oct 2, 2018

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.

@austintackaberry
Copy link
Owner Author

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?

@kshitijpurwar
Copy link
Contributor

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

@austintackaberry
Copy link
Owner Author

austintackaberry commented Oct 3, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants