/*
 * Copyright (c) 2005 Absolutely Training Limited
 *  
 * Created on 07-Feb-2005
 */

// constructor


function Objectives(){
	this.id = null;
	this.success_status = null;
	this.completion_status = "unknown";
	this.description = null;
	this.score = new Score();
	this.progress_measure = null;
    
    this.type="objectives";

        this.propertiesArray = new Array("id","success_status",
            "completion_status","description", "progress_measure");
        
        this.objectsArray = new Array("score");




	this._children="id,score,success_status,completion_status,description";
	this.validator = new Validator();
};

// create and discard an initial Object to force the prototype object to be
// created in Navigator 3.

new Objectives();     

Objectives.prototype = new RTEDataObject();
Objectives.prototype.constructor = Objectives;

    /**
     * @param id The id to set. SCORN RTEDM: cmi.interactions.n.id
     */
    Objectives.prototype.setId = function(id){

	    if (this.validator.validateLongIdentifierType(id)){
		    this.id = id;
		    return VariableInfo.NO_SET_ERROR;
		    
	    } else{
		    return VariableInfo.ERROR_406;
	    }
    };

    /**
     * @param successStatus The successStatus to set.
     * @throws ScormRteDmodelException
     */
     
    Objectives.prototype.setSuccess_status = function(success_status) {
	    if (!this.validator.listContainsState(this.validator.OBJECTIVE_SUCCESS_STATUS_LIST, success_status)){
		    return VariableInfo.ERROR_406;
	    }
//		else if (this.id==null){
//		    return VariableInfo.ERROR_408;
//	    }
	    this.success_status = success_status;
	    return VariableInfo.NO_SET_ERROR;
    };

    /**
     * @param completionStatus The completionStatus to set.
     * @throws ScormRteDmodelException
     */
    Objectives.prototype.setCompletion_status = function(completion_status) {
        if (!this.validator.listContainsState(this.validator.OBJECTIVE_COMPLETION_STATUS_LIST, completion_status)){
            return VariableInfo.ERROR_406;
        }
		//else if (this.id==null){
          //  return VariableInfo.ERROR_408;
//        }
	this.completion_status = completion_status;
	return VariableInfo.NO_SET_ERROR;
    };


    /**
     * @param description The description to set. TODO: this is a localised string!
     * @throws ScormRteDmodelException
     */
    Objectives.prototype.setDescription = function(description){
//	    if (this.id==null){
//		    return VariableInfo.ERROR_408;
//	    }else 
			if (this.validator.validateLocalisedString(description)){
		    this.description = description;
		    return VariableInfo.NO_SET_ERROR;
	    } else{
		    return VariableInfo.ERROR_406;
	    }
    };

    /**
     * @param progressMeasure The progressMeasure to set.
     * @throws ScormRteDmodelException
     */

    Objectives.prototype.setProgress_measure = function(progress_measure){
//	    if (this.id==null){
//		    return VariableInfo.ERROR_408;
//	    }else 
		if (!this.validator.validateRange(progress_measure, "0", "1")){
		    return VariableInfo.ERROR_407;
	    }else if (!this.validator.validateReal(progress_measure)){
		    return VariableInfo.ERROR_406;
	    }	    
	    this.progress_measure = progress_measure;
	    return VariableInfo.NO_SET_ERROR;
    };
    
    
        /**
     * @param id The id to set. SCORN RTEDM: cmi.interactions.n.id
     */
    Objectives.prototype.setScore = function(value, variable){

	//    if (this.id==null){
//		    return VariableInfo.ERROR_408;
//	    } else{
		  	return this.score.set(variable, value);
//	    }
    };
    
    

