Telegram quiz message handler but don't know how to display correct answer when answered - telegram-bot

Here is a sample of the code that I am using would be gratefully if someone can point me in the right direction.
import telebot
bot = telebot.TeleBot("API KEY")
print("Bot starting...")
#bot.message_handler(commands=['quiz'])
def quiz(message):
q = 'What is the capital of Italy?'
answers = ['Rome', 'London', 'Amsterdam']
bot.send_poll(message.chat.id, question=q, options=answers, correct_option_id=0, open_period=5)
bot.polling()
What I'm not sure about on how to make work, is once the question has been answered how to display the correct answer out of the options that are available. For Example the question above, for it to say the correct answer is "Rome" after each question.
Thank You in advance

If you pass type='quiz' to send_poll, then TG will automatically take care of that. See the official docs of sendPoll.
If you don't want to the native quiz interface of TG, you'll have to make the poll non-anonymous. In that case, you'll receive PollAnswer updates when a user makes a vote and you can respond to that update in the way that you want to.

Related

I'm tiring to create a new user in Moodle using auth_email_signup_user but I'm not sure how to format the request [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a few required custom profile fields that are date pickers and checkboxes. and I'm not sure what type to put them as in the request the only example the documentation has is one with type string. I keep getting the response
{
"exception": "invalid_parameter_exception",
"errorcode": "invalidparameter",
"message": "Invalid parameter value detected",
"debuginfo": ""
}
this is my request below:
https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=fromapp&password=FakePass123&firstname=From&lastname=App&email=fake#mailinator.com&customprofilefields[0][type]=text&customprofilefields[0][name]=profile_field_Church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=date&customprofilefields[1][name]=profile_field_DOB&customprofilefields[1][value]=2014-06-19&customprofilefields[2][type]=checkbox&customprofilefields[2][name]=profile_field_Saved&customprofilefields[2][value]=1&customprofilefields[3][type]=text&customprofilefields[3][name]=profile_field_Sex&customprofilefields[3][value]=Male&customprofilefields[4][type]=text&customprofilefields[4][name]=profile_field_phone_no&customprofilefields[4][value]=1-868-479-8661&customprofilefields[5][type]=text&customprofilefields[5][name]=profile_field_Marital&customprofilefields[5][value]=Single
I'm not sure what I need to do to make this request work and the documentation doesn't give much insight or I just haven't found it
So after playing around with the request on postman what I discovered is that the only type you need to use is string. I also discovered that for date fields the value must be unixtime and for checkboxes the value must be either 0 or 1.
https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=formapp7&password=fakepassword&firstname=From7&lastname=App7&email=fake#mailinator.com&customprofilefields[0][type]=string&customprofilefields[0][name]=profile_field_church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=string&customprofilefields[1][name]=profile_field_saved&customprofilefields[1][value]=Yes&customprofilefields[2][type]=string&customprofilefields[2][name]=profile_field_man&customprofilefields[2][value]=0&customprofilefields[3][type]=string&customprofilefields[3][name]=profile_field_born&customprofilefields[3][value]=1630813061&customprofilefields[4][type]=string&customprofilefields[4][name]=profile_field_single&customprofilefields[4][value]=Single&customprofilefields[5][type]=string&customprofilefields[5][name]=profile_field_aboutyou&customprofilefields[5][value]=Well i am new
This is an example of how a request would look where profile_field_man is a checkbox and profile_field_born is a date field. something also worth noting is that 'born' is the short name of the profile field mentioned before and the words 'profile_field_' must be prepended to it. I hope this helps anyone trying to use auth_email_signup_user

What is Context-Only in QnA Maker?

When I use QnA Maker , Ifound something named CONTEXT-ONLY . What is it used for?
Context-Only is a part of the multi-turn feature for qna-maker. When a question in the qna maker is set to 'Context-Only', a user cannot ask that question and get the answer. It can only be 'asked' as part of the multi-turn flow:
For example, I have a question called 'Shocked Pikachu!' in my qnamaker kb. If this wasn't a Context-Only, a customer could put in 'Shocked Pikachu!' and get the answer 'I'm so confused!'. But because it is Context-Only, the only way to reach this answer is to go through the first question ("What is a pokemon"), and click the "NOT FLUFFY!" follow up:
Notice that 'Shocked Pikachu!' IS listed as question, but is not available to be asked. This is typically not a good idea, you really want your prompts to match the question. I did it to show that clicking 'NOT FLUFFY' lead to that question's answer.

Get LimeSurvey not selected multiple choice answers with "N" using API Remote Control

Is it possible to get not selected answers in multiple choice question type marked with "N" when consuming Lime Survey API?
The API method export_responses gives all the question/subquestions/answers codes of user responses in bulk.
But the multiple choice question type signalizes only the selected answers with an "Y". I'd like responses bring the answers not selected with an "N" written. LimeSurvey can do that?
Example:
listTpFisioAt is the question code; text, in listTpFisioAt[text], is an option. When I consume the API to get responses I get something like this:
lisTpFisioAt[Fototerapia]
lisTpFisioAt[Termoterapia]
lisTpFisioAt[Cinesioterapia] Y
lisTpFisioAt[Eletroterapia]
lisTpFisioAt[Hidroterapia] Y
In this case user selected Cinesioterapia and Hidroterapia in Lime Survey interface.
I'd like to get:
lisTpFisioAt[Fototerapia] N
lisTpFisioAt[Termoterapia] N
lisTpFisioAt[Cinesioterapia] Y
lisTpFisioAt[Eletroterapia] N
lisTpFisioAt[Hidroterapia] Y
No, is not possible. Limesurvey fills checked options only. The other ones are left empty. You will need to fill the empty ones yourself by processing the output.
Hope it helps.
Thanks

Print scenario name when running each scenario

I want to print the name of each scenario as the test run. What can i call or do to get the name so that i can execute * print <scenario_name> ?
The answer for this post is exactly what i want to do: Print scenario name Is there a way to access the Scenario object?
As of now this is not supported, but will be easy to add. But here's the question - is this just to help you make sense of the logs ? Because if you are not using the Cucumber HTML report yet, you should - and that's what most teams are using: https://twitter.com/KarateDSL/status/899671441221623809
Refer to this discussion for more: https://stackoverflow.com/a/47555173/143475
If you still really need this, kindly raise a feature request.
Edit: this will be available in the next version: https://github.com/intuit/karate/issues/257

Loadrunner - how to parameterize changing value in VuGen for challenge questions to enter respective answers

Loadrunner - how to parameterize changing value in VuGen?
Example: Challenge questions change every time when you try to login and answers to be parameterized according to the question that is displayed.
Challenge question answer logic is that the last word of the question is the answer to be parameterized.
Example: What is your name? Here "name" is the answer for the challenge question.
My scenario is that 3 challenge questions will be populated and 3 answers to be entered, we don't know which question will be populated in what order or so...
Make all of your challenge questions and answers the same for your test users. Correlate for the question. Check for a match to the question and then set the response for the form.
"What is your name?" "Bob"
"What was the name of your first pet?" "Cat"
"What is the name of your elementary school" "My School"
...
FYI
got it solved by using array in web_reg_sav_param function
here we go...
I placed below function above the right place(refering the questions .inf position in the generation log)
web_reg_save_param("CQ",
"LB= ",
"RB=?",
"Ord=ALL",
"Search=Body",
LAST);
then replaced answers with {CQ_1},{CQ_2} and {CQ_3} since i had 3 answers(pasted 2 time each as CQ_ , as i had same answers twice)
web_submit_form("answerChallengeQuestions.faces",
"Snapshot=t74.inf",
ITEMDATA,
"Name=answerChallengeQuestions:answerPasswordBox1", "Value={CQ_1}", ENDITEM,
"Name=answerChallengeQuestions:answerTxtBox1", "Value={CQ_1}", ENDITEM,
"Name=answerChallengeQuestions:answerPasswordBox2", "Value={CQ_2}", ENDITEM,
"Name=answerChallengeQuestions:answerTxtBox2", "Value={CQ_2}", ENDITEM,
"Name=answerChallengeQuestions:answerPasswordBox3", "Value={CQ_3}", ENDITEM,
"Name=answerChallengeQuestions:answerTxtBox3", "Value={CQ_3}", ENDITEM,
Hope this helps
Thanks,
Ramanan M