source: SMSSender/gateways/Schoolnet/business/deepthought/datatypes.h @ 319:1ec456878bcb

separation-frontend-backend
Last change on this file since 319:1ec456878bcb was 319:1ec456878bcb, checked in by Sämy Zehnder <saemy.zehnder@…>, 8 years ago
  • Adjusts header guards to follow common pattern based on the filename.
File size: 4.7 KB
Line 
1/*
2 Schoolnet gateway plugin - The smssender plugin for the Schoolnet sms platform.
3 Copyright (C) 2007-2014, gorrión. See http://smssender.gorrion.ch
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef SCHOOLNET_DEEPTHOUGHT_DATATYPES_H
19#define SCHOOLNET_DEEPTHOUGHT_DATATYPES_H
20
21#include <QList>
22#include <QMap>
23#include <QMetaType>
24#include <QString>
25#include <QStringList>
26
27#include <common/utils/smacros.h>
28#include <common/utils/sshared.h>
29
30namespace Schoolnet {
31namespace DeepThought {
32
33class Answer;
34class DeepThoughtAnswer;
35class DeepThoughtQuestion;
36class Question;
37
38class Question {
39public:
40    enum Status {
41        StatusAtSchoolnetChecked = 0x1,
42        AnsweredAtSchoolnet = 0x2
43        // next should be 0x4
44    };
45
46public:
47    Question();
48    virtual ~Question();
49
50    int id() const;
51    QString nrNodeGuId() const;
52    QString eventTarget() const;
53    QString language() const;
54    QString text() const;
55    QString hint() const;
56    const QList<Answer*> &answers() const;
57
58
59    void setId(int id);
60    void setNrNodeGuId(const QString& nrNodeGuId);
61    void setEventTarget(const QString& eventTarget);
62    void setLanguage(const QString& language);
63    void setText(const QString& questionText);
64    void setHint(const QString& hint);
65
66    // Takes ownership of the answers
67    void addAnswer(Answer *answer);
68    void setAnswers(const QList<Answer*> &answers);
69
70    bool hasCorrectAnswer() const;
71    Answer *correctAnswer() const;
72
73private:
74    int m_id;
75    QString m_nrNodeGuId;
76    QString m_eventTarget;
77    QString m_language;
78    QString m_text;
79    QString m_hint;
80    QList<Answer*> m_answers;
81
82    Q_DISABLE_COPY(Question)
83};
84
85
86class Answer {
87public:
88    explicit Answer(Question *question);
89    ~Answer();
90
91public:
92    Question *question() const;
93
94    QString id() const;
95    QString text() const;
96    bool isAnswered() const;
97    bool isCorrect() const;
98    bool doesDeepThoughtKnowCorrectness() const;
99
100    void setId(const QString& id);
101    void setText(const QString& answerText);
102    void setAnswered(bool answered);
103    void setCorrect(bool correct);
104    void setDeepThoughtKnowsCorrectness(bool doesHe);
105
106private:
107    Question * const m_question;
108    QString m_id;
109    QString m_text;
110    bool m_answered;
111    bool m_correct;
112    bool m_deepThoughtKnowsCorrectness;
113
114    Q_DISABLE_COPY(Answer)
115};
116
117
118class DeepThoughtQuestion {
119public:
120    DeepThoughtQuestion();
121    virtual ~DeepThoughtQuestion();
122
123public:
124    int id() const;
125    QString nrNodeGuId() const;
126    QString eventTarget() const;
127    QString language() const;
128    QString text() const;
129    QString hint() const;
130    bool isAlive() const;
131    const QList<DeepThoughtAnswer*> &answers() const;
132
133    void setId(int id);
134    void setNrNodeGuId(const QString& nrNodeGuId);
135    void setEventTarget(const QString& eventTarget);
136    void setLanguage(const QString& language);
137    void setText(const QString& questionText);
138    void setHint(const QString& hint);
139    void setIsAlive(bool isAlive);
140
141    // Takes ownership of the answers
142    void setAnswers(const QList<DeepThoughtAnswer*> &answers);
143    void addAnswer(DeepThoughtAnswer *answer);
144
145    bool hasCorrectAnswer() const;
146    DeepThoughtAnswer *correctAnswer() const;
147
148private:
149    int m_id;
150    QString m_nrNodeGuId;
151    QString m_eventTarget;
152    QString m_language;
153    QString m_text;
154    QString m_hint;
155    bool m_isAlive;
156    QList<DeepThoughtAnswer*> m_answers;
157
158    Q_DISABLE_COPY(DeepThoughtQuestion)
159};
160
161class DeepThoughtAnswer {
162    friend class FetchDataFromDeepThoughtTask; // setters
163
164public:
165    explicit DeepThoughtAnswer(const DeepThoughtQuestion& question);
166    virtual ~DeepThoughtAnswer();
167
168public:
169    const DeepThoughtQuestion &question() const;
170
171    QString id() const;
172    QString text() const;
173    bool isAnswered() const;
174    bool isCorrect() const;
175
176    void setId(const QString& id);
177    void setText(const QString& answerText);
178
179private:
180    void setAnswered(bool answered);
181    void setCorrect(bool correct);
182
183    const DeepThoughtQuestion &m_question;
184    QString m_id;
185    QString m_text;
186    bool m_answered;
187    bool m_correct;
188
189    Q_DISABLE_COPY(DeepThoughtAnswer)
190};
191
192} // namespace DeepThought
193} // namespace Schoolnet
194
195#endif /* SCHOOLNET_DEEPTHOUGHT_DATATYPES_H */
Note: See TracBrowser for help on using the repository browser.