/*
 * Copyright (c) 2005 Absolutely Training Limited
 *  
 * Created on 08-Feb-2005
 *
 * @author roberto, fritzd
 */

//init
new Interactions();  
Interactions.prototype = new RTEDataObject();
Interactions.prototype.constructor = Interactions;

 //constructor
function Interactions() {
    this.id = null;
    this.type = null;    
    this.timestamp = null;
    this.weighting = null;
    this.result = null;
    this.latency = null;
    this.learner_response = null;
    this.student_response = null;
    this.description = null;
    this.type="interactions";
    this.propertiesArray = new Array("id","type","timestamp","weighting","result","latency","learner_response","student_response", "description");
    this.objectsArray = new Array("objectives","correct_responses");
	this.propertiesArrayForTest = new Array("learner_response");
    this.objectives = new SCORMArray(new Objectives());
    this.correct_responses = new SCORMArray(new Correct_responses()); 
    this.validator = new Validator();
    this._children = "id,type,timestamp,weighting,result,latency,earner_response,description,objectives,correct_responses";
}

Interactions.prototype.setDescription = function(description){
	if (this.validator.validateLocalisedString(description)){
		this.description = description;
		return VariableInfo.NO_SET_ERROR;
	} else{
		VariableInfo.ERROR_406;
	}
};

Interactions.prototype.setLatency = function(latency){
	if (this.validator.validateTimeIntervalFormat(latency)){
		this.latency = latency;
		return VariableInfo.NO_SET_ERROR;
	} else {
		VariableInfo.ERROR_406;
	}
};

Interactions.prototype.setType = function(type){
	if (!this.validator.listContainsState(this.validator.INTERACTION_TYPE_LIST, type)) {
		return VariableInfo.ERROR_406;
	}
	this.type = type;
	return VariableInfo.NO_SET_ERROR;
};

Interactions.prototype.setId = function(id){
	if (this.validator.validateLongIdentifierType(id)){
		this.id = id;
		return VariableInfo.NO_SET_ERROR;
	} else{
		return VariableInfo.ERROR_406;
	}
};

Interactions.prototype.setTimestamp = function(timestamp) {
	if (this.validator.validateTimeFormat(timestamp)){
		this.timestamp = timestamp;
		return VariableInfo.NO_SET_ERROR;
	}else{
		VariableInfo.ERROR_406;
	}
};

Interactions.prototype.setResult = function(result){
	if (this.validator.listContainsState(this.validator.LEARNER_RESPONSE_LIST, result) && this.validator.isReal(result)) {
		this.result = result;
		return VariableInfo.NO_SET_ERROR;
	}
	return VariableInfo.ERROR_406;
};

Interactions.prototype.setStudent_response = function(student_response){
	if (this.validator.validateResponseFormat(this.type, student_response)) {
		this.student_response = student_response;
		return VariableInfo.NO_SET_ERROR;
	} else{
		return VariableInfo.ERROR_406;
	}
};

Interactions.prototype.setLearner_response = function(learner_response){
	if (this.validator.validateResponseFormat(this.type, learner_response)) {
		this.learner_response = learner_response;
		return VariableInfo.NO_SET_ERROR;
	} else{
		return VariableInfo.ERROR_406;
	}
};


Interactions.prototype.setWeighting = function(weighting){
	if (this.validator.isReal(weighting)){
		this.weighting = weighting;
		return VariableInfo.NO_SET_ERROR;
	} else{
		VariableInfo.ERROR_406;
	}
};



