austintackaberry / ydkjs-exercises

Exercises to go along with You Don't Know JavaScript
MIT License
253 stars 74 forks source link

Add explanations to existing questions #14

Closed austintackaberry closed 6 years ago

austintackaberry commented 6 years ago

The current question format is:

{
  question: String,
  answers: Array
}

but should have explanations:

{
  question: String,
  answers: Array,
  explanation: String
}

For now, the simplest solution is to just make the explanation a string. In the future we might want to make it jsx or something, so that it is more flexible.

energydev commented 6 years ago

I'd be happy to take a look at this one. It seems like a good one to do in conjunction with issue #21, which may also be changing up the format of the questions.

austintackaberry commented 6 years ago

Makes sense, it's all yours!

energydev commented 6 years ago

Some explanations could be pulled directly form the book like, the below explanation. In such cases, are we looking for such detailed explanations, and if so what kind of referencing to the book should we provide if the explanation is essentially a quote from the book?

An expression is any reference to a variable or value, or a set of variable(s) and value(s) combined with operators.

For example:

a = b * 2; This statement has four expressions in it:

2 is a literal value expression b is a variable expression, which means to retrieve its current value b 2 is an arithmetic expression, which means to do the multiplication a = b 2 is an assignment expression, which means to assign the result of the b * 2 expression to the variable a (more on assignments later)

austintackaberry commented 6 years ago

The example above is a perfect explanation. It might be valuable to the user to provide a link to that spot in the book if that's doable?

energydev commented 6 years ago

The below format for the questions has been implemented.

{ question: "How many expressions are in the following statement: a = b * 2; ?", orderedById: true, answers: [ {text: "one", id: 0}, {text: "two", id: 1}, {text: "three", id: 2}, {text: "four", id: 3} ], correctAnswerId: 3, explanation: "explain why other answers are wrong and why this answer is the best answer" },

energydev commented 6 years ago

We've got a place now for the explanations. I'll pass this on to another who would like to take on filling out the explanations in ydkjs-exercises/src/data/UpGoing/ch1.js

mdncs commented 6 years ago

I'd be happy to fill those in (maybe also providing links to the book for more info?)

austintackaberry commented 6 years ago

That would be awesome, thanks! 🙂

mdncs commented 6 years ago

No worries! Since all the questions in Ch1 link to the same page, would it be better to have the link on every question page under Chapter 1: Into Programming instead of after every explanation?

austintackaberry commented 6 years ago

Is there any way to link to a certain line in YDKJS? If so, that would be ideal, and each question would have a different link

mdncs commented 6 years ago

Can't seem to find ways to link out to a specific line unfortunately. #lineNumber in the url doesn't work and neither do named anchors for someone else's code (GitHub). An event handler to Ctrl + F the first words of the explanation might do the job? I'm learning React now so that'd take a bit of playing around with :)

nikrb commented 6 years ago

you can't afaik, only to hashed sections, e.g. https://github.com/getify/You-Dont-Know-JS/blob/master/up%20%26%20going/ch1.md#expressions

nikrb commented 6 years ago

looks like we have links to chapters, do we need individual question links?

austintackaberry commented 6 years ago

I think linking to hashed sections under the explanation would be valuable. The typical flow will be as follows:

user answers question incorrectly -> user reads explanation -> user wants to read more about the topic

Therefore, the user should be able to access YDKJS from the question page, and they should be sent as close to the topic as possible. This should really be a separate issue though.