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

#include "kqtiassessmenttest.h"
#include "kqtiassessmentitem.h"
#include "kqtichoiceinteraction.h"
#include "kqtiresponsedeclaration.h"
#include "kqtiitembody.h"
#include "kqtimapping.h"

#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>

#include <KUrl>

#include "keducabuilder.h"

static const char version[]     = "2.0";

int main(int argc, char *argv[])
{
    KAboutData aboutData( "keducabuilder", 0, ki18n("KEducaBuilder"), version,
                          ki18n("Test builder for IMS QTI Exams"),
                          KAboutData::License_GPL,
                          ki18n("Copyright 2007, Matt Williams"));
    aboutData.addAuthor(ki18n("Matt Williams"), ki18n("Original Author"), "matt@milliams.com");
    KCmdLineArgs::init( argc, argv, &aboutData );

    KCmdLineOptions options;
    options.add("+file", ki18n("File to load"));
    KCmdLineArgs::addCmdLineOptions( options );
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    KApplication app;

    KEducaBuilder *KEducaEditorMainWindow = new KEducaBuilder;
    KEducaEditorMainWindow->show();

    /*KQtiAssessmentItem item("Test 1");

    KQtiChoiceInteraction* choices = new KQtiChoiceInteraction();
    choices->setPrompt("This is the question?");
    choices->appendChoice("Choice1", "This is possible answer 1");
    choices->appendChoice("Choice2", "This is possible answer 2");
    choices->appendChoice("Choice3", "This is possible answer 3");
    KQtiItemBody* itemBody = new KQtiItemBody();
    itemBody->setBlock(choices);
    item.addItemBody(itemBody);

    KQtiResponseDeclaration* answers = new KQtiResponseDeclaration();
    answers->addCorrectResponse("Choice1");
    item.addResponseDeclaration(answers);
    
    item.saveToFile(KUrl("file:///home/matt/qti.xml"));
    
    
    
    KQtiAssessmentItem item2("Test 2");

    KQtiChoiceInteraction* choices2 = new KQtiChoiceInteraction();
    choices2->setPrompt("This is the question2?");
    choices2->appendChoice("Choice1", "This is possible answer 1");
    choices2->appendChoice("Choice2", "This is possible answer 2");
    choices2->appendChoice("Choice3", "This is possible answer 3");
    choices2->appendChoice("Choice4", "This is possible answer 4");
    choices2->appendChoice("Choice5", "This is possible answer 5");
    KQtiItemBody* itemBody2 = new KQtiItemBody();
    itemBody2->setBlock(choices2);
    item2.addItemBody(itemBody2);

    KQtiResponseDeclaration* answers2 = new KQtiResponseDeclaration();
    answers2->addCorrectResponse("Choice1");
    answers2->addCorrectResponse("Choice2");
    KQtiMapping* mapping2 = new KQtiMapping(0, 2);
    mapping2->add("Choice1", 1);
    mapping2->add("Choice2", 1);
    answers2->setMapping(mapping2);
    item2.addResponseDeclaration(answers2);
    
    item2.saveToFile(KUrl("file:///home/matt/qti.xml"));*/
    
    
    /*QDomDocument* testDoc = new QDomDocument();
    testDoc->setContent(QString("<assessmentTest title=\"Test 2\" identifier=\"Test1\">"
             "<testPart navigationMode=\"linear\" submissionMode=\"individual\">"
              "<assessmentSection identifier=\"sectionA\" title=\"Section A\">"
               "<assessmentItemRef identifier=\"item1\" href=\"item1.xml\">"
              "</assessmentSection>"
             "</testPart>"
            "</assessmentTest>"), false);
    KQtiAssessmentTest test1(testDoc);
    test1.saveToFile();
    
    
    QDomDocument* itemDoc3 = new QDomDocument();
    itemDoc3->setContent(QString("<assessmentItem title=\"Test 2\" >"
             "<responseDeclaration identifier=\"RESPONSE\" baseType=\"identifier\" cardinality=\"single\" >"
              "<correctResponse>"
               "<value>Choice1</value>"
               "<value>Choice2</value>"
              "</correctResponse>"
              "<mapping upperBound=\"2\" defaultValue=\"0\" lowerBound=\"0\" >"
               "<mapEntry mappedValue=\"1\" mapKey=\"Choice1\" />"
               "<mapEntry mappedValue=\"1\" mapKey=\"Choice2\" />"
              "</mapping>"
             "</responseDeclaration>"
             "<itemBody>"
              "<choiceInteraction maxChoices=\"1\" responseIdentifier=\"RESPONSE\" shuffle=\"false\" >"
               "<prompt>This is the question2?</prompt>"
               "<simpleChoice identifier=\"Choice1\" >This is possible answer 1</simpleChoice>"
               "<simpleChoice identifier=\"Choice2\" >This is possible answer 2</simpleChoice>"
               "<simpleChoice identifier=\"Choice3\" >This is possible answer 3</simpleChoice>"
               "<simpleChoice identifier=\"Choice4\" >This is possible answer 2</simpleChoice>"
               "<simpleChoice identifier=\"Choice5\" >This is possible answer 3</simpleChoice>"
              "</choiceInteraction>"
             "</itemBody>"
            "</assessmentItem>"), false);
    KQtiAssessmentItem item3(itemDoc3);
    item3.saveToFile(KUrl("file:///home/matt/qti.xml"));*/

    args->clear();

    return app.exec();
}
