#ifndef QUESTION_H
#define QUESTION_H
#include <QString>
#include <QStringList>
#include <QTextDocument>
#include <QTextStream>
#include <QProgressDialog>
#include <QApplication>
class PassMark;
class Question
{
public:
enum Answer { None = 0, A = 1, B = 2, C = 4, D = 8, E = 16, F = 32, G = 64, H = 128, I = 256 };
Q_DECLARE_FLAGS(Answers, Answer)
enum SelectionType { SingleSelection = 0, MultiSelection = 1 };
Q_DECLARE_FLAGS(SelectionTypeFlag, SelectionType)
Question(QString = QString());
static int answerToIndex(Answer);
static Answer indexToAnswer(int);
static int labelToIndex(const QString &);
static QString indexToLabel(int);
static QString answerToString(Answer);
static Answer convertOldAnsNumber(int);
static int convertToOldAnsNumber(int);
static QList<int> randomise(QList<Question *>, PassMark, bool, int, quint32, QProgressDialog * = NULL, QApplication * = NULL);
public slots:
QString name(); void setName(QString);
int flag(); void setFlag(int);
QString group(); void setGroup(QString);
int difficulty(); void setDifficulty(int);
QString text(); void setText(QString);
QString explanation(); void setExplanation(QString);
SelectionType selectionType(); void setSelectionType(SelectionType);
QString answer(Answer); void setAnswer(Answer, QString);
QString answerAtIndex(int); void setAnswerAtIndex(int, QString);
void addAnswer(QString); int numAnswers();
bool isAnswerCorrect(Answer); bool isAnswerAtIndexCorrect(int);
void setAnswerCorrect(Answers, bool); bool hasCorrectAnswer();
QStringList answers(); void setAnswers(QStringList);
Answer correctAnswer();
Answers correctAnswers(); void setCorrectAnswers(Answers);
private:
QString q_name;
int q_flag;
QString q_group;
int q_difficulty;
QString q_text;
QString q_explanation;
SelectionType q_selectiontype;
QStringList q_answers;
Answers q_correctanswers;
friend class QuestionItem;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Question::Answers)
Q_DECLARE_OPERATORS_FOR_FLAGS(Question::SelectionTypeFlag)
class ScoringSystem
{
protected:
void init();
public:
ScoringSystem();
ScoringSystem(QString);
void loadData(QString);
#ifdef ITESTSERVER
QString data();
#endif
float correctAnswer[3];
float incorrectAnswer[3];
float missingAnswer[3];
bool allowIncompleteAnswers;
};
#endif