theusaf / kahoot.js-updated

Kahoot.js
MIT License
43 stars 22 forks source link

Question Events and question.answer don't work as expected all the time #8

Closed TheNoob27 closed 5 years ago

TheNoob27 commented 5 years ago

i know this might not be easy but eh lol i’ve looked through all the properties of the question object, but there was no question name and i really need that xd also the time left is always 5

theusaf commented 5 years ago

The question does not have a name. Kahoot doesn't supply that information (for relatively obvious reasons)

I do not understand what you mean by "the time left is always 5"

If you are looking for the quiz name, use the quiz object for that.

On Oct 24, 2019, at 11:56 AM, TheNoob27 notifications@github.com wrote:

i know this might not be easy but eh lol i’ve looked through all the properties of the question object, but there was no question name and i really need that xd also the time left is always 5

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

theusaf commented 5 years ago

However, you can get the answers after each question, so you could use Kahoot's API to search for the quizzes of the same name. Then you could filter them by the answers you receive.

TheNoob27 commented 5 years ago

by the time left, i mean when a question is received, one of the properties is timeLeft, which is the same when the question starts. Now that i think about it, both of them are a question object so it makes sense so that doesn’t really matter.

i know how to get the quiz name, it’s just for the questions that i need help with. Why is it not supplied for “obvious reasons”? And how would i go about with the kahoot api and finding the questions anyway?

TheNoob27 commented 5 years ago

oops

TheNoob27 commented 5 years ago

how would i use the kahoot api to get the question name

TheNoob27 commented 5 years ago

hello? ;-;

theusaf commented 5 years ago

Sorry for the late reply.

The question name is not given to the client because the client (on the website at least) has no need for it. Plus it would make bots have a huge advantage over real players. Even the quiz name is not really needed but it is included for some random reason.

As for the filtering, Kahoot has a search API (I forget the URL) but you can use my package "kahoot-search" to do it.

Then you filter the search using something like results.filter(obj=>{return obj.name == session.quiz.name}); (this code may be wrong)

After each question, you are given the answers, which allows you to filter the quizzes even more:

possibleResults.filter(a=>{ return a.answers.filter(b=>{ return b.choice == question.answer && b.correct; }).length; });

Do note that the code in this message may not be correct as it is being typed on mobile.

TheNoob27 commented 5 years ago

thank you

but just one thing, is possibleResults a variable that you defined something as, or a property?

theusaf commented 5 years ago

Possible results is a variable defined by myself as an example. It stores the quiz results from the first filter (by name) and then is used to filter even more using the answers sent to the client.

On Oct 25, 2019, at 5:21 PM, TheNoob27 notifications@github.com wrote:

thank you

but just one thing, is possibleResults a variable that you defined something as, or a property?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

TheNoob27 commented 5 years ago

ok thanks. i’ll try it now!

TheNoob27 commented 5 years ago

thank you so much, i figured it out, but could you maybe check the questionSubmit event, because that is never emitted for me. This may be because of the api but

oh well lol

also, question.answer() doesn’t always work.

one last question, are all the properties in all the objects all that is provided by kahoot?

theusaf commented 5 years ago

I'll take a look at it, but it is certainly very strange. I can sometimes reproduce the issue, and sometimes I cannot...

However, this could be due to bad coding of the website I am using...

TheNoob27 commented 5 years ago

it’s all right, you’re still accomplishing more than what i could ever lol

TheNoob27 commented 5 years ago

thank you so much, i figured it out, but could you maybe check the questionSubmit event, because that is never emitted for me. This may be because of the api but

oh well lol

also, question.answer() doesn’t always work.

one last question, are all the properties in all the objects all that is provided by kahoot?

the questionSubmit for whatever reason emit for the first time (that i know of) it seems like it’s random also. but the event isn’t as important to me than the answer function sometimes not working xd

TheNoob27 commented 5 years ago

how does .sendingAnswer work, because i tried using it to send an answer if it wasn’t sending one after the first function was called

theusaf commented 5 years ago

.sendingAnswer appears to be an unused variable that gets set to true when sending the answer and false when it was sent successfully.

I believe the issue lies within the answer submit packet. I will do some testing later.

On Oct 27, 2019, at 9:48 AM, TheNoob27 notifications@github.com wrote:

how does .sendingAnswer work, because i tried using it to send an answer if it wasn’t sending one after the first function was called

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

TheNoob27 commented 5 years ago

ok thanks

guess i’ll try a while true loop and break everything :D

TheNoob27 commented 5 years ago

ok that was a bad idea

TheNoob27 commented 5 years ago

any luck? sorry if i’m just bothering you too much xd

theusaf commented 5 years ago

I found a temporary fix, but I don't like it. It seems to send too many messages than it really needs to.