/*
Copyright (c) 2007 Matt Williams matt@milliams.com

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) version 3 or, at the discretion of KDE e.V. (which shall
act as a proxy as in section 14 of the GPLv3), 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, see <http://www.gnu.org/licenses/>.
*/

#ifndef KQTICHOICEINTERACTION_H
#define KQTICHOICEINTERACTION_H

#include "kqtiblockinteraction.h"

#include <kqti_export.h>

#include <QList>
#include <QDomElement>

class KQtiSimpleChoice;

/**
 * \class KQtiChoiceInteraction
 * The choice interaction presents a set of choices to the candidate. The
 * candidate's task is to select one or more of the choices, up to a maximum of
 * maxChoices. There is no corresponding minimum number of choices. The
 * interaction is always initialized with no choices selected. 
 * The choiceInteraction must be bound to a response variable with a baseType
 * of identifier and single or multiple cardinality.
 * 
 * An interaction with a number of choices. Gives radio/check boxes.
 * \todo Move prompt into its own class to avoid QPair madness
 * 
 * http://www.imsglobal.org/question/qtiv2p1pd2/imsqti_infov2p1pd2.html#element10278
 */

class KQTI_EXPORT KQtiChoiceInteraction : public KQtiBlockInteraction
{
    public:
        
        /**
         * KQtiChoiceInteraction
         * @param responseIdentifier unique identifier for this response
         * @param maxChoices maximum number of choises the user can select. 0 means no limit
         * @param shuffle should the order of the choices be shuffled
         */
        explicit KQtiChoiceInteraction(const QString& responseIdentifier=QString("RESPONSE"), int maxChoices=1, bool shuffle=false);
        explicit KQtiChoiceInteraction(const QDomElement& element);
        ~KQtiChoiceInteraction();
        
        void setMaxChoices(int maxChoices) {mMaxChoices = maxChoices;}
        int maxChoices() const {return mMaxChoices;}
        void setMinChoices(int minChoices) {mMinChoices = minChoices;}
        int minChoices() const {return mMinChoices;}
        void setShuffle(bool shuffle) {mShuffle = shuffle;}
        bool isShuffle() const {return mShuffle;}
        
        /**
         * addChoice
         * @param choice choice
         */
        void addChoice(KQtiSimpleChoice* choice);
        QList<KQtiSimpleChoice*> choices() {return mChoices;}
        
        QDomElement element() const;
        
    protected:
        QList<KQtiSimpleChoice*> mChoices;
        int mMaxChoices; //[1]
        int mMinChoices; //[1]
        bool mShuffle; //[1]
};

#endif
