File indexing completed on 2024-10-06 06:32:54

0001 // SPDX-FileCopyrightText: 2006-2010 Peter Hedlund <peter.hedlund@kdemail.net>
0002 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #pragma once
0006 
0007 #include <QString>
0008 #include <QObject>
0009 
0010 
0011 class BlankAnswer : public QObject
0012 {
0013     Q_OBJECT
0014     Q_PROPERTY(QString input READ input WRITE setInput NOTIFY inputChanged)
0015     Q_PROPERTY(bool hasBlank READ hasBlank NOTIFY inputChanged)
0016     Q_PROPERTY(QString blankedAnswer READ blankedAnswer NOTIFY inputChanged)
0017     Q_PROPERTY(QString correctAnswer READ correctAnswer NOTIFY inputChanged)
0018 
0019 public:
0020 
0021     QString input() const;
0022     void setInput(const QString &input);
0023 
0024     bool hasBlank() const;
0025 
0026     QString blankedAnswer() const;
0027 
0028     QString correctAnswer() const;
0029 
0030     static QString yourAnswerResult(const QString &givenAnswer, const QString &blankedAnswer);
0031 
0032     struct BlankResult {
0033         QString blankedAnswer;
0034         QString correctAnswer;
0035     };
0036 
0037     static BlankResult blankAnswer(const QString &input);
0038 
0039 Q_SIGNALS:
0040     void inputChanged();
0041 
0042 private:
0043 
0044     QString m_input;
0045     BlankResult m_blankResult;
0046 };