FeedbackOptions = {
    Remove: 0,
    RemoveBeforeNextResponse: 1,
    DoNotRemove: 2
};
RepeatTypes = {
    RepeatFromInformation: 0,
    RepeatFromInteraction: 1,
    DoNotRepeat: 2
};
Ext.define('ResponseClass15', {
    extend: 'Ext.util.Observable',
    constructor: function(cfgXML, o, config){
        Ext.apply(this, config);
        this.addEvents({
            "responseLoaded": true,
            "responseCompleted": true
        });
        this.callParent([]);
        this.Condition = new AuthorCondition(cfgXML.getElementsByTagName('condition')[0]);
        this.HasConditon = true;
        this.id = cfgXML.getAttribute('id');
        this.LogicalOrder = new OrderClass(o.NodePath, 'Response', o.ElementSequence, this.id);
        this.FeedbackList = new ListClass(cfgXML.getElementsByTagName('list')[0], this.LogicalOrder, {});
        this.Score = XmlHelper.getIntegerAttribute(cfgXML, 'score'); // parseInt(cfgXML.getAttribute('score'));
        this.DoNotCountAttempt = XmlHelper.getBooleanAttribute(cfgXML, 'notAttempt');// cfgXML.getAttribute('notAttempt').toLowerCase() == 'true';
        this.FeedbackOption = XmlHelper.getIntegerAttribute(cfgXML, 'feedBackOption');// parseInt(cfgXML.getAttribute('feedBackOption'));
        this.RepeatType = XmlHelper.getIntegerAttribute(cfgXML, 'repeatType');// parseInt(cfgXML.getAttribute('repeatType'));
        this.ResetInteraction = XmlHelper.getBooleanAttribute(cfgXML, 'resetInteraction');// cfgXML.getAttribute('resetInteraction').toLowerCase() == 'true';
        this.IsFinished = false;
        this.RespondTime = 0;
        if (this.hasListener('responseLoaded')) {
            this.fireEvent('responseLoaded', this);
        }
    },
    isConditionMatched: function(){
        //alert(this.Condition);
        return this.Condition.isConditionMatched();
    },
    onStartShowResponse: function(){
      //  Author.log("Start response: "+this.toString());
        if (Author.CurrentStateManager.CurrentResponse) {
            var oldResponse = Author.CurrentStateManager.CurrentResponse;
            if (oldResponse.FeedbackOption == FeedbackOptions.RemoveBeforeNextResponse) {
                oldResponse.removeResponse();
            }
            else {
                alert("ResponseClass.onStartShowResponsee: should not be here.");
            }
        }
        Author.CurrentStateManager.CurrentActionPosition = -1;
        Author.CurrentStateManager.CurrentAction = null;
        Author.CurrentStateManager.CurrentList = null;
        Author.CurrentStateManager.CurrentResponse = this;
        this.IsFinished = false;
    },
    show: function(){
        this.FeedbackList.addListener('listCompleted', this.onFeedbackListCompleted, this);
        Author.DisplayManager.showList(this.FeedbackList);
    },
    onFeedbackListCompleted: function(){
        this.onResponseCompleted();
    },
    onResponseCompleted: function(){

        this.IsFinished = true;
        if (this.hasListener('responseCompleted')) {
            this.fireEvent('responseCompleted', this);
        }
    },
    removeResponse: function(){
        this.FeedbackList.removeListActions();
        Author.CurrentStateManager.CurrentResponse = null;
    },
    toString: function(){
        return Ext.String.format("Response ID: {0}\n{1}\nScore: {2}\nResetInteraction: {3}\nFeedbackOption: {4}\nRepeatType: {5}\nNotCountAttempt: {6}", this.id, this.Condition.toString(), this.Score, this.ResetInteraction, this.FeedbackOption, this.RepeatType, this.DoNotCountAttempt);
    }
});


