blob: dcf784ef31be5e74b831d971ebc23304730eb63b (
plain)
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
|
/***************************************************************************
manage multiple choice suggestions for queries
-----------------------------------------------------------------------
begin : Mon Oct 29 18:09:29 1999
copyright : (C) 1999-2001 Ewald Arnold <kvoctrain@ewald-arnold.de>
(C) 2001 The KDE-EDU team
(C) 2005 Peter Hedlund <peter.hedlund@kdemail.net>
-----------------------------------------------------------------------
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "multiplechoice.h"
MultipleChoice::MultipleChoice (
const TQString &mc1,
const TQString &mc2,
const TQString &mc3,
const TQString &mc4,
const TQString &mc5
)
{
setMC1 (mc1);
setMC2 (mc2);
setMC3 (mc3);
setMC4 (mc4);
setMC5 (mc5);
}
bool MultipleChoice::isEmpty() const
{
return muc1.stripWhiteSpace().isEmpty()
&& muc2.stripWhiteSpace().isEmpty()
&& muc3.stripWhiteSpace().isEmpty()
&& muc4.stripWhiteSpace().isEmpty()
&& muc5.stripWhiteSpace().isEmpty();
}
void MultipleChoice::clear()
{
muc1 = "";
muc2 = "";
muc3 = "";
muc4 = "";
muc5 = "";
}
TQString MultipleChoice::mc (unsigned idx) const
{
switch (idx) {
case 0: return muc1;
case 1: return muc2;
case 2: return muc3;
case 3: return muc4;
case 4: return muc5;
}
return "";
}
unsigned MultipleChoice::size()
{
normalize();
unsigned num = 0;
if (!muc1.isEmpty() )
++num;
if (!muc2.isEmpty() )
++num;
if (!muc3.isEmpty() )
++num;
if (!muc4.isEmpty() )
++num;
if (!muc5.isEmpty() )
++num;
return num;
}
void MultipleChoice::normalize()
{
// fill from first to last
if (muc1.isEmpty()) {
muc1 = muc2;
muc2 = "";
}
if (muc2.isEmpty()) {
muc2 = muc3;
muc3 = "";
}
if (muc3.isEmpty()) {
muc3 = muc4;
muc4 = "";
}
if (muc4.isEmpty()) {
muc4 = muc5;
muc5 = "";
}
}
|