Warning: session_start(): open(/var/lib/php/sessions/sess_dnqls0vkfsn9t0c0jtrbc0lnkr, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
abstract sclass DynAskUserQuestions extends DynModule {
S question, answer;
bool speak, listen;
transient JButton btnSubmit;
start {
dm_onTopInput_q(voidfunc(S s) {
if (listen) {
if (isYes_1(s)) {
dm_hideYesPopupForComponent(btnSubmit);
submit();
ret;
}
setField(answer := s);
dm_showYesToAcceptPopupAbove(btnSubmit);
dm_sayInEnglish(s);
}
});
}
visualize {
if (empty(question)) newQuestion();
JLabel lblQ = fontSizePlus(3, makeBold(dm_fieldLabel('question)));
componentPopupMenuItem(lblQ, "Suggest question...", r {
inputText("Question", question, voidfunc(S s) {
setField(question := s)
})
});
ret withRightMargin(makeForm2(
"", withBottomMargin(15, lblQ),
"Human answer:", centerAndEastWithMargin(onEnter(dm_fieldTextField('answer), rThread submit),
btnSubmit = jbutton("Submit", rThread submit)),
"", withBottomMargin(withTopMargin(20, rightAlignedButtons(
dm_checkBox('listen), dm_checkBox('speak), "Ask me something else", rThread newQuestion)))));
}
abstract S makeAQuestion();
void newQuestion enter {
setFields(answer := "", question := makeAQuestion());
if (empty(question)) ret with infoBox("Got nothing to ask");
programLogStructure(litorderedmap(+question));
vmBus_send('showingQuestion, module(), question);
if (speak) dm_sayWithAutoLanguage_splitAtQuotes(question);
}
void submit enter {
programLogStructure(litorderedmap(+question, +answer));
vmBus_send('userAnsweredQuestion, module(), question, answer);
dm_addQAndA(question, answer);
infoBox(confirmationText());
if (speak) dm_sayInEnglish(answer);
newQuestion();
}
S confirmationText() {
ret "[saved] " + question + " => " + answer;
}
}