summaryrefslogtreecommitdiffstats
path: root/keduca/keduca/keducaview.h
blob: aa04df5ef4582d5a6c5d352d5dd06b4254e4bcc3 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***************************************************************************
                          keducaview.h  -  description
                             -------------------
    begin                : Thu May 24 2001
    copyright            : (C) 2001 by Javier Campos
    email                : javi@asyris.org
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KEDUCAVIEW_H
#define KEDUCAVIEW_H

#include <kurl.h>

#include <tqlayout.h>
#include <tqsplitter.h>
#include <tqwidgetstack.h>

class TQTimer;
class TQTextEdit;
class TQLabel;

class KPushButton;

class FileRead;
class KQuestion;
class KGroupEduca;

/**Main view of keduca file (questions and answers)
   This is the widget for asking questions and allowing selection of answers
   as used by KEduca TestMaster (class KEduca)
 *@author Javier Campos
 */

class KEducaView : public QWidgetStack
{
    Q_OBJECT

public:
    KEducaView(TQWidget *parent=0, const char *name=0);
    ~KEducaView();
    /** Open url */
    bool openURL( const KURL &url);
    FileRead const *getKeducaFile() const {return _keducaFile; }

private:

    // Private methods

    /** Init graphical interface */
    void init();
    /** Show record, returns false if there is no record to show. */
    void showRecord();
    /** Show results */
    void showResults( const TQString &text );
    /** Set results */
    void setResults();
    /** Set results */
    TQString setFinalResult();
    /** Write settings */
    void configWrite();
    /** current results Points */
    TQString currentStatusPoints();
    /** Set HTML table view with correct and incorrect answers */
    TQString getTableQuestion( bool isCorrect, const TQString &correct, const TQString &incorrect);
    /** Define the next questions (random, secuencial) */
    bool questionNext();

    TQString getInformation();
    /** Init table with title and colspan */
    TQString insertTable( const TQString &title = "", unsigned int col=0);
    /** Insert row */
    TQString insertRow( const TQString &text, bool title, unsigned int colSpan=0 );
    TQString insertRow( const TQString &label, const TQString &field, bool formBased );
    TQString insertRow( const TQString &label1, const TQString &field1, const TQString &label2, const TQString &field2, bool formBased );
    /** Close current table */
    TQString insertTableClose();
            
    // Private attributes

    /** Widgets */
    TQLabel *_introWidget;
    TQWidget *_infoWidget, *_questionWidget, *_resultsWidget;
    /** Push Buttons */
    KPushButton *_buttonNext;
    KPushButton *_buttonSave;
    KPushButton *_buttonResultsNext; // FIXME: this is a hack
    KPushButton *_buttonStartTest;
    /** Group of answers. This is a frame an check or radio buttons. */
    KGroupEduca *_buttonGroup;
    /** KEDUCA file */
    FileRead *_keducaFile;
    /** A question text with pixmaps and movies support */
    KQuestion *_questionText;
    /** A question text with pixmaps and movies support */
    TQTextEdit *_viewResults;
    TQTextEdit *_viewInfo;
    /** Current record */
    int _keducaFileIndex;
    /** Current results */
    TQString _results;
    /** Main vbox */
    TQVBoxLayout *_vbox2;
    /** Main splitt */
    TQSplitter *_split;
    /** Current results */
    TQString _currentResults;
    /** If is init window */
    bool _isInitStatus;
    TQTimer *_timeoutTimer;
    /** Num of correct answers */
    int _correctAnswer;
    /** Number of incorrect answers */
    int _incorrectAnswer;
    /** Number of correct answers in points*/
    int _correctPoints;
    /** Number of incorrect answers in points*/
    int _incorrectPoints;
    /** Current time */
    int _currentTime;
    /** Show results when finish? */
    bool _showResultFinish;
    /** Show random questions */
    bool _showRandomQuestions;
    /** Show random answers */
    bool _showRandomAnswers;
    /** Save real order by random questions */
    TQValueList<uint> _randomQuestions;
    /** Save real order by random answers */
    TQValueList<uint> _randomAnswers;
private slots:
    /** Button Next action */
    void slotButtonNext();
    void slotButtonSave();
    void slotButtonStartTest();
    void questionTimedOut();
};

#endif