#include "singlechoice.h"
#include <QDomNode>
#include <iostream>

SingleChoice::SingleChoice()
    : Question("single_choice")
{
}

bool SingleChoice::loadFromNode(const QDomNode& node)
{
    Question::loadFromNode(node);
    QDomNode NodeOptions = node.firstChildElement("options");
    for ( QDomNode OptionsChild = NodeOptions.firstChild(); ! OptionsChild.isNull(); OptionsChild = OptionsChild.nextSibling() )
    {
        //QDomElement element = child.toElement();
        if ( OptionsChild.isNull() ) continue;

        if ( OptionsChild.nodeName() == "option" )
        options.push_back(OptionsChild.toElement().text());
    }
    return true;
}

void SingleChoice::print() const
{
    Question::print();
    for(int i = 0 ; i < options.size(); ++i)
    {
        std::cout << qPrintable(options[i]) << std::endl;

    }
}

QVector<QString> *SingleChoice::getOptions()
{
    return &options;
}

