/*
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 KQTIDELIVERYENGINE_H
#define KQTIDELIVERYENGINE_H

#include <kqti_export.h>

#include <QObject>
#include <QMap>

class KQtiAssessmentTest;
class KQtiAssessmentItem;
class KQtiItemSession;
class KQtiItemBody;
class KQtiItemResult;
class KQtiAssessmentResult;

/**
 * \class KQtiDeliveryEngine
 * The process that coordinates the rendering and delivery of the Item(s) and
 * the evaluation of the responses to produce scores and Feedback.
 * 
 * Not an XML entity.
 * 
 * The delivery engine is passed a KQtiAssessmentTest. It will then (assuming
 * a non-adaptive test!) create a KQtiItemSession for each of the KQtiAssessmentItems.
 * 
 * Once the test has been started, the KQtiTestParts will be iterated through
 * (and the KQtiAssessmentSecions within therefore).
 * 
 * http://www.imsglobal.org/question/qtiv2p1pd2/imsqti_infov2p1pd2.html#section10055
 */

class KQTI_EXPORT KQtiDeliveryEngine : public QObject
{
    Q_OBJECT
    
    public:
        KQtiDeliveryEngine();
        ~KQtiDeliveryEngine();
        
        void setAssessmentTest(KQtiAssessmentTest* assessmentTest);
        
    public slots:
        void itemResult(KQtiItemResult* itemResult);
        
    protected:
        KQtiAssessmentTest* mAssessmentTest;
        KQtiAssessmentResult* assessmentResult; ///< TODO Stores info about the result for the whole test.
        
        QMap<KQtiAssessmentItem*, KQtiItemSession*> mItemSessions;
        KQtiAssessmentItem* mCurrentAssessmentItem;
        
    signals:
        void itemBody(KQtiItemBody*);
};

#endif
