-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanswer.h
More file actions
142 lines (121 loc) · 5.01 KB
/
answer.h
File metadata and controls
142 lines (121 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/***************************************************************************
* Copyright (C) 2003-2007 by Oliver Saal *
* osaal@gmx.de *
* http://www.oliver-saal.de/software/afutrainer/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef ANSWER_H
#define ANSWER_H
#include <qstring.h>
#include <qdom.h>
#include <qlist.h>
#include <qdatetime.h>
//! Die Klasse CAnswer speichert eine einzelne Antwort auf eine Frage
/*!
Das Schreiben und Lesen von XML-Daten wird von der Klasse CQuestion übernommen
*/
class CAnswer
{
public:
//! Standard-Konstruktor
/*! Initialisiert die Klasse, indem die Funktion clear() aufgerufen wird. */
CAnswer() { clear(); }
//! Konstruktor inkl. setzen eines Textes und ob die Antwort richtig ist
/*!
\param strText Antworttext
\param bCorrect true: Die Antwort ist korrekt
\sa m_strText, m_bIsCorrect
*/
CAnswer(const QString& strText, const bool bCorrect);
//! Standard-Destruktor
/*! In der Standard-Implementierung tut der Destruktor nichts. */
~CAnswer() {}
//! Zurücksetzen aller Werte
/*! Es werden alle Daten der Antwort gelöscht. */
void clear();
//! Überprüfen, ob die Klasse eine Antwort enthält
/*! \return true: Die Klasse ist leer und enthält keine Antwort */
inline bool isEmpty() const { return m_strText.isEmpty(); }
//! Auslesen, ob diese Antwort richtig ist
/*! \return true: Die Antwort ist richtig */
inline bool isCorrect() const { return m_bIsCorrect; }
//! Auslesen des Antworttextes
/*! \return Antworttext */
inline QString text() const { return m_strText; }
//! Setzen, ob diese Antwort richtig ist
/*!
\param bCorrect true: Die Antwort ist korrekt
\sa m_bIsCorrect
*/
inline void setCorrect (const bool bCorrect) { m_bIsCorrect = bCorrect; }
//! Setzen des Antworttextes
/*!
\param strText Antworttext
\sa m_strText
*/
inline void setText(const QString& strText) { m_strText = strText; }
//! Anhängen eines Textes an den Antworttext
/*!
\param strText Anzuhängender Text
\sa m_strText
*/
inline void appendText(const QString& strText) { m_strText += strText; }
protected:
//! Antworttext
/*!
Der Antworttext darf HTML-Code und HTML-Verweise auf Grafiken/Bilder enthalten. Bei Verweisen ist zu achten, dass kein Verzeichnis angegeben werden darf!
Default: leer
*/
QString m_strText;
//! Richtige oder falsche Antwort
/*! Default: false */
bool m_bIsCorrect;
};
//! Die Klasse CAnswerClicked speichert eine einzelne Beantwortung des Benutzers
/*!
*/
class CAnswerClicked
{
public:
//! Standard-Konstruktor
/*! Initialisiert die Klasse, indem die Funktion clear() aufgerufen wird. */
CAnswerClicked () { clear(); }
CAnswerClicked (const unsigned uAnswer, const unsigned uNeededTime)
{ m_uAnswer = uAnswer; m_dt = QDateTime::currentDateTime(); m_uNeededTime = uNeededTime; }
//! Standard-Destruktor
/*! In der Standard-Implementierung tut der Destruktor nichts. */
~CAnswerClicked () {}
//! Zurücksetzen aller Werte
/*! Es werden alle Daten auf Default-Werte zurückgesetzt. */
void clear();
inline QDateTime dateTime() const { return m_dt; }
inline unsigned neededTime() const { return m_uNeededTime; }
inline unsigned answer() const { return m_uAnswer; }
static QString answerText(const unsigned uAnswer);
QString answerText() const;
QString neededTimeText() const;
bool isCorrect(const QList<CAnswer>& listAnswer) const;
bool load (QDomElement elem);
void save (QDomElement& parent, QDomDocument& doc) const;
static QString tr (const char *sourceText, const char *comment=0);
bool operator < (const CAnswerClicked& ac) const;
protected:
QDateTime m_dt; //!< Zeitstempel der Antwort
unsigned m_uAnswer; //!< Antwort-Bitmaske
unsigned m_uNeededTime; //!< Benötigte Zeit in ms
};
#endif