/***************************************************************************
 *   Copyright (C) 2007 by Kraschinski Arnold                              *
 *   arnold.kra67@gmx.de                                                   *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.           *
 ***************************************************************************/
#ifndef GAPTRAINER_H
#define GAPTRAINER_H

#include <QWidget>
#include <trainer.h>
#include <dom/dom_node.h>

class KHTMLPart;
class QWidget;

/** In this trainer exercises are presented to the user as HTML-forms. The
  * user fills the gaps and then the user input is corrected and evaluated.
  *
  * @short trainer with gaps in a html document
  * @author Kraschinski Arnold <arnold.kra67@gmx.de>
  * @version 2.00.00
  */

class GapTrainer : public Trainer  {
   Q_OBJECT
public:
    GapTrainer(QWidget *parent=0);
    ~GapTrainer();
    
    /** Prepares everything for an exercise. Load the HTML file into the
      * KHTMLPart
      *
      * @return true if the exercise is set, false if something went wrong
      */
    bool setExercise(QString exerciseFile);
    
    /** is called from qlearning when the user pressed the next button */
    virtual void next();

public slots:
    /** Receives a signal when the user changes the input line for the infinitive.
      */
    void slotVerbChanged();
    
    /** Receives a signal when the user has entered a new infinitive into the input line
      * and has pressed the enter button.
      *
      * @param QString the infinitive in the input line
      */
    void slotVerbEntered(const QString &s);
    
    /** Go on to the next verb.
      */
    virtual void slotContinue() {};
    
    /** receive one of the special characters ñ, á, é, í, ó, ú from
     * the button line. The character will be added to the active lineInput
     */
    virtual void slotChar(QString ch);
    
    void slotNodeActivated(DOM::Node node);

private:
    KHTMLPart               *m_htmlRenderer;
    QString                 m_exerciseName;
    
    /** is true if the user didn't solve everything correctly and the program showed the solution */
    bool                m_solution;
    
    /** When the user input is corrected the points the user got are stored here.
      * When the user corrects some forms afterwards and there is another correction
      * the amount of alredy obtained points is substracted.
      */
    int                 m_givenPoints;
    
    /** m_mode tells what we are doing at the moment. */
    int                 m_mode;
    static const int    EXPECTING_INPUT;
    static const int    CORRECTED;
    static const int    CORRECT_FORMS;
    static const int    SOLVED;
};

#endif // GAPTRAINER_H
