diff --git a/qml/pages/PollCreationPage.qml b/qml/pages/PollCreationPage.qml
index 029ef34..9fb8f89 100644
--- a/qml/pages/PollCreationPage.qml
+++ b/qml/pages/PollCreationPage.qml
@@ -39,6 +39,7 @@ Dialog {
property alias quiz: quizSwitch.checked
property alias multiple: multipleSwitch.checked
property string replyToMessageId: "0"
+ property alias quizExplanation: quizExplanationTextArea.text
// poll request data end
canAccept: validationErrors.length === 0
@@ -81,6 +82,9 @@ Dialog {
if(quiz && (correctOption < 0 || correctOption > options.count - 1)) {
errors.push(qsTr("To send a quiz, you have to specify the right answer."));
}
+ if(quiz && quizExplanationTextArea.hasError) {
+ errors.push(qsTr("An explanation can be up to 200 characters long."));
+ }
if(errors.length === 0) {
validationErrorsVisible = false;
}
@@ -333,6 +337,25 @@ Dialog {
}
description: qsTr("Quizzes have one correct answer. Participants can't revoke their responses.")
}
+ TextArea {
+ id: quizExplanationTextArea
+ width: parent.width
+ opacity: pollCreationPage.quiz ? 1.0 : 0.0
+ Behavior on opacity { FadeAnimation {} }
+ height: pollCreationPage.quiz ? implicitHeight : 0
+ Behavior on height { NumberAnimation { duration: quizExplanationTextArea.focus ? 0 : 200 } }
+ visible: opacity > 0
+
+ placeholderText: qsTr("Enter an optional explanation")
+ property int charactersLeft: 200 - text.length
+ property bool hasError: charactersLeft < 0
+ color: hasError ? Theme.errorColor : Theme.highlightColor
+ label: qsTr("Shown when the user selects a wrong answer.")
+ wrapMode: TextEdit.Wrap
+ onFocusChanged: {
+ validate();
+ }
+ }
}
}
@@ -342,7 +365,7 @@ Dialog {
optionsArr.push(options.get(i).text);
}
- tdLibWrapper.sendPollMessage(chatId, pollQuestion, optionsArr, anonymous, quiz ? correctOption : -1, multiple, "0");
+ tdLibWrapper.sendPollMessage(chatId, pollQuestion, optionsArr, anonymous, quiz ? correctOption : -1, multiple, quizExplanation, "0");
}
diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp
index 5446f7e..32cd4a8 100644
--- a/src/tdlibwrapper.cpp
+++ b/src/tdlibwrapper.cpp
@@ -569,7 +569,7 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file
this->sendRequest(requestObject);
}
-void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &replyToMessageId)
+void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, const QString &replyToMessageId)
{
LOG("Sending poll message" << chatId << question << replyToMessageId);
QVariantMap requestObject;
@@ -585,6 +585,11 @@ void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &questio
if(correctOption > -1) {
pollType.insert(_TYPE, "pollTypeQuiz");
pollType.insert("correct_option_id", correctOption);
+ if(!explanation.isEmpty()) {
+ QVariantMap formattedExplanation;
+ formattedExplanation.insert("text", explanation);
+ pollType.insert("explanation", formattedExplanation);
+ }
} else {
pollType.insert(_TYPE, "pollTypeRegular");
pollType.insert("allow_multiple_answers", multiple);
diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h
index 8b1ce90..3e824b7 100644
--- a/src/tdlibwrapper.h
+++ b/src/tdlibwrapper.h
@@ -145,7 +145,7 @@ public:
Q_INVOKABLE void sendVoiceNoteMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendLocationMessage(const QString &chatId, double latitude, double longitude, double horizontalAccuracy, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId = "0");
- Q_INVOKABLE void sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &replyToMessageId = "0");
+ Q_INVOKABLE void sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, const QString &replyToMessageId = "0");
Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, bool sendCopy, bool removeCaption);
Q_INVOKABLE void getMessage(qlonglong chatId, qlonglong messageId);
Q_INVOKABLE void getCallbackQueryAnswer(const QString &chatId, const QString &messageId, const QVariantMap &payload);
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index 28add57..f9e1625 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -1064,7 +1064,7 @@
MessageVoiceNote
-
+ Sprachnotiz
@@ -1298,6 +1298,18 @@
Quizze haben eine korrekte Antwort. Teilnehmer können ihre Antwort nicht zurückziehen.
+
+
+ Geben Sie eine optionale Erklärung ein
+
+
+
+ Wird bei Auswahl einer falschen Antwort gezeigt.
+
+
+
+ Eine Erklärung kann bis zu 200 Zeichen lang sein.
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts
index 3d0fcce..1549fa9 100644
--- a/translations/harbour-fernschreiber-en.ts
+++ b/translations/harbour-fernschreiber-en.ts
@@ -1064,7 +1064,7 @@
MessageVoiceNote
-
+ Voice Note
@@ -1298,6 +1298,18 @@
Quizzes have one correct answer. Participants can't revoke their responses.
+
+
+ Enter an optional explanation
+
+
+
+ Shown when the user selects a wrong answer.
+
+
+
+ An explanation can be up to 200 characters long.
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts
index 6bd0ef7..884a257 100644
--- a/translations/harbour-fernschreiber-es.ts
+++ b/translations/harbour-fernschreiber-es.ts
@@ -1298,6 +1298,18 @@
Los interrogatorios tienen una respuesta correcta. Los participantes no pueden revocar sus respuestas.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts
index f1595d0..fea6a48 100644
--- a/translations/harbour-fernschreiber-fi.ts
+++ b/translations/harbour-fernschreiber-fi.ts
@@ -1299,6 +1299,18 @@
Visoilla on yksi oikea vastaus. Osallistujat eivät voi kumota vastaustaan.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts
index e289d2a..da3c21f 100644
--- a/translations/harbour-fernschreiber-hu.ts
+++ b/translations/harbour-fernschreiber-hu.ts
@@ -1279,6 +1279,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts
index 3feba91..074670b 100644
--- a/translations/harbour-fernschreiber-it.ts
+++ b/translations/harbour-fernschreiber-it.ts
@@ -1298,6 +1298,18 @@
I quiz hanno una sola risposta corretta. I partecipanti non possono revocare le risposte.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts
index 23e0666..f2dfcab 100644
--- a/translations/harbour-fernschreiber-pl.ts
+++ b/translations/harbour-fernschreiber-pl.ts
@@ -1317,6 +1317,18 @@
Quizy mają jedną poprawną odpowiedź. Uczestnicy nie mogą odwołać swoich odpowiedzi.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts
index 23bfce7..64287e8 100644
--- a/translations/harbour-fernschreiber-ru.ts
+++ b/translations/harbour-fernschreiber-ru.ts
@@ -1317,6 +1317,18 @@
Тесты имеют один правильный ответ. Участники не могут отозвать свои ответы.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts
index 48a27cd..7074f30 100644
--- a/translations/harbour-fernschreiber-sv.ts
+++ b/translations/harbour-fernschreiber-sv.ts
@@ -1298,6 +1298,18 @@
Frågor har ett (1) korrekt svar. Deltagarna kan inte återkalla sina svar.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts
index 40bcda9..8eba51f 100644
--- a/translations/harbour-fernschreiber-zh_CN.ts
+++ b/translations/harbour-fernschreiber-zh_CN.ts
@@ -1279,6 +1279,18 @@
Quiz 拥有一个正确选项,参与者无法撤销回答。
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index bfdd7b4..3e65ed4 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -1298,6 +1298,18 @@
Quizzes have one correct answer. Participants can't revoke their responses.
+
+
+
+
+
+
+
+
+
+
+
+
PollResultsPage