Buscar

Ciências do Ambiente

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

/*******************************************************************************
**
** Arquivo: APIScript.js
**
** Descricao: Este arquivo eh parte da implementacao da API do WebAula Corporate
** concordante com o padrao SCORM. Ele corresponde o modulo cliente, e eh
** capaz de se cominucar com um modulo correspondente no servidor, para obter
** informacoes do banco de dados.
**
** Desenvolvido em Julho de 2002 - Zargon e-Learning
**
** Versao original: Ernani Cecon Jr.
**
*******************************************************************************/
var API = new objAPI();
var lmsError = new objError();
var lmsDataBuffer = new objDataModelBuffer();
var lmsObjectivesBuffer = new objObjectivesBuffer();
var lmsInteractionsBuffer = new objInteractionsBuffer();
var _SomenteLeitura = false; //Flag de sala de aula modo somente leitura
var _Debug = false; //Flag de debug
var isLMSInitialized = false;
var isFinishing = false; //Verificar se e necessaria a gravacao do Tempo Final do aluno no topico
var testeExiste = 0; //Var temporaria para teste
var strTotal_time;
var objAPIDadosSala; //Redirecionamento do objeto com os dados especficos do curso
var objArrTopicos;
var debugWin = null;
var debugCount = 0;
var blnErro = false
var cstUndefined = 'undefined';
var cstSim = 'S';
var cstNao = 'N';
var cstFalse = 'false';
var cstTrue = 'true';
var cstZero = '0';
var cstZeroExtenso = 'zero';
var cstUnderScore = "_";
var cstNormal = 'normal';
var cstPassed = 'passed';
var cstCompleted = 'completed';
var cstBrowse = 'browse';
var cstBrowsed = 'browsed';
var cstIncomplete = 'incomplete';
var cstFailed = 'failed';
var cstReview = 'review';
var cstNotAttempted = 'not attempted';
var cstTrueFalse = 'true-false';
var cstChoice = 'choice';
var cstFillIn = 'fill-in';
var cstMatching = 'matching';
var cstNumeric = 'numeric';
var cstLikert = 'likert';
var csPerformance = 'performance';
var cstSequencing = 'sequencing';
var cstCorrect = 'correct';
var cstWrong = 'wrong';
var cstNeutral = 'neutral';
var cstUnanparticiped = 'unanparticiped';
var cstExitMessage = "exit,message";
var cstExitNoMessage = "exit,no message";
var cstContinueMessage = "continue,message";
var cstContinueNoMessage = "continue,no message";
var cstLogout = 'logout';
var cstSuspend = 'suspend';
var cstTimeOut = 'time-out';
var cstAbreChave = '{';
var cstFechaChave = '}';
var cstT = 't';
var cstF = 'f';
var cstEspaco = ' ';
var cstMenorQue = '<'
//JSFramework
atachamentoDinamico("LEBJSFrameWork", "Recursos/JSFrameWork/JSFrameWork.js");
atachamentoDinamico("GerarLogAvaliacao", "Javascript/ValidaAvaliacao.js");
function ativarDebug() {
	_Debug = true;
	debugWin = window.open('/scormapi/debugAPI.asp', 'debugAPI', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,height=250,width=300,top=0,left=0');
}
function SalaSomenteLeitura() {
	_SomenteLeitura = true;
}
function objAPI()
{
	this.LMSInitialize = LMSInitialize;
	this.LMSFinish = LMSFinish;
	this.LMSGetValue = LMSGetValue;
	this.LMSSetValue = LMSSetValue;
	this.LMSCommit = LMSCommit;
	this.LMSGetLastError = LMSGetLastError;
	this.LMSGetErrorString = LMSGetErrorString;
	this.LMSGetDiagnostic = LMSGetDiagnostic;
}
function objError()
{
	this.errorCode = "0";
}
/************************************************************************
** Estrutura de controle dos elements do Data Model suportados pelo **
** WebAula. Para suportar um novo element, alem de sua implementacao **
** ele deve ser informado no arranjo abaixo, aumentando seu tamanho **
** na definicao e incluindo-o na lista. **
************************************************************************/
var objDataModel = new Array();
objDataModel[0] = "cmi.core._children";
objDataModel[1] = "cmi.core.student_id";
objDataModel[2] = "cmi.core.student_name";
objDataModel[3] = "cmi.core.credit";
objDataModel[4] = "cmi.core.lesson_location";
objDataModel[5] = "cmi.core.lesson_status";
objDataModel[6] = "cmi.core.lesson_mode";
objDataModel[7] = "cmi.core.entry";
objDataModel[8] = "cmi.core.exit";
objDataModel[9] = "cmi.core.score._children";
objDataModel[10] = "cmi.core.score.raw";
objDataModel[11] = "cmi.core.score.max";
objDataModel[12] = "cmi.core.score.min";
objDataModel[13] = "cmi.core.session_time";
objDataModel[14] = "cmi.core.total_time";
objDataModel[15] = "cmi.suspend_data";
objDataModel[16] = "cmi.launch_data";
objDataModel[17] = "cmi.comments";
objDataModel[18] = "cmi.comments_from_lms";
objDataModel[19] = "cmi.student_preference._children";
objDataModel[20] = "cmi.student_preference.audio";
objDataModel[21] = "cmi.student_preference.language";
objDataModel[22] = "cmi.student_preference.speed";
objDataModel[23] = "cmi.student_preference.text";
objDataModel[24] = "cmi.student_data._children";
objDataModel[25] = "cmi.student_data.mastery_score";
objDataModel[26] = "cmi.student_data.max_time_allowed";
objDataModel[27] = "cmi.student_data.time_limit_action";
objDataModel[28] = "cmi.objectives._children";
objDataModel[29] = "cmi.objectives._count";
objDataModel[30] = "cmi.objectives.n.id";
objDataModel[31] = "cmi.objectives.n.score._children";
objDataModel[32] = "cmi.objectives.n.score.raw";
objDataModel[33] = "cmi.objectives.n.score.max";
objDataModel[34] = "cmi.objectives.n.score.min";
objDataModel[35] = "cmi.objectives.n.status";
objDataModel[36] = "cmi.interactions._children";
objDataModel[37] = "cmi.interactions._count";
objDataModel[38] = "cmi.interactions.n.id";
objDataModel[39] = "cmi.interactions.n.time";
objDataModel[40] = "cmi.interactions.n.type";
objDataModel[41] = "cmi.interactions.n.weighting";
objDataModel[42] = "cmi.interactions.n.student_response";
objDataModel[43] = "cmi.interactions.n.result";
objDataModel[44] = "cmi.interactions.n.latency";
objDataModel[45] = "cmi.interactions.n.objectives._count";
objDataModel[46] = "cmi.interactions.n.objectives.m.id";
objDataModel[47] = "cmi.interactions.n.correct_responses._count";
objDataModel[48] = "cmi.interactions.n.correct_responses.m.pattern";
//Data Buffer - Objeto para gravar temporariamente os dados salvos com o
// LMSSetValue ate que seja chamado o LMSCommit.
function objDataModelBuffer()
{
	this.coreLesson_location = new tipoCampo();
	this.coreLesson_status = new tipoCampo();
	this.scoreRaw = new tipoCampo();
	this.scoreMax = new tipoCampo();
	this.scoreMin = new tipoCampo();
	this.coreExit = new tipoCampo();
	this.coreSession_time = new tipoCampo();
	this.coreTotal_time = new tipoCampo();
	this.coreEntry = new tipoCampo();
	this.suspend_data = new tipoCampo();
	this.launch_data = new tipoCampo();
	this.comments = new tipoCampo();
	this.comments_from_lms = new tipoCampo();
	this.student_dataMastery_score = new tipoCampo();
	this.student_dataMax_time_allowed = new tipoCampo();
	this.student_dataTime_limit_action = new tipoCampo();
	this.isBufferInitialized = false;
}
//Forçar postagem em caso de Erro.
function gravarDadosBuffer(arquivoXMl)
{
	if (!blnErro){
		var objXMLHTTP = rPC("/scormapi/xmlCMI.asp", "", true, escape(arquivoXMl), true);
		if(objXMLHTTP.status == 200) {
			HandlePostagemTopico(objDadosSala.codAluno, objDadosSala.codTurma);
		}
		else {
			blnErro = true;
		 alert(objIdioma("E027861"));
		 top.close();
		}
	}
	
} 
//Objeto para representar cada campo do Data Buffer
function tipoCampo()
{
	this.dirty = false;
	this.info = null;
}
//Objectives Buffer - Objeto para gravar temporariamente os dados de objetivos 
// (cmi.objectives.n.*) salvos com o LMSSetValue ate que seja chamado o LMSCommit.
function objObjectivesBuffer()
{
	//Variavel do objeto para controle. false significa que ainda nao foram modificadas 
	//informacoes neste objeto.
	this.dirty = false;
	//Arranjos para controle dos objetivos existentes
	this.id = new
Array();
	this.scoreRaw = new Array();
	this.scoreMax = new Array();
	this.scoreMin = new Array();
	this.status = new Array();
}
//Interactions Buffer - Objeto para gravar temporariamente os dados de interaes
// (cmi.interactions.n.*) salvos com o LMSSetValue ate que seja chamado o LMSCommit.
function objInteractionsBuffer()
{
	//Variavel do objeto para controle. false significa que ainda nao foram modificadas 
	//informacoes neste objeto.
	this.dirty = false;
	//Arranjos para controle dos objetivos existentes
	this.id = new Array();
	this.time = new Array();
	this.type = new Array();
	this.weighting = new Array();
	this.student_response = new Array();
	this.result = new Array();
	this.latency = new Array();
	this.objectivesId = new Array();
	this.objectivesId[0] = new Array();
	this.correct_responsesPattern = new Array();
	this.correct_responsesPattern[0] = new Array();
}
//Arranjo com os erros pre-definidos
var vetErrors = new Array(
	new Array("0","No error","A chamada anterior da funo do LMS completou com sucesso."),
	new Array("101","General Exception","Ocorreu uma exceo geral no sistema."), 
	new Array("102","Not Compatible Browser","Browser no compatvel"),
	new Array("201","Invalid argument error",""),
	new Array("202","Element cannot have children",""),
	new Array("203","Element not an array - Cannot have count",""),
	new Array("301","Not initialized","O LMS deve ser incializado com a funo LMSInitialize()."),
	new Array("401","Not implemented error","O elemento em questo no foi implementado no LMS."),
	new Array("402","Invalid set value, element is a keyword","Houve tentativa de atribuir valor a um 'keyword' (_count, _children, or _version). Isto proibido."),
	new Array("403","Element is read only","No se pode chamar a funo LMSSetValue() para o elemento em questo."),
	new Array("404","Element is write only","No se pode chamar a funo LMSGetValue() para o elemento em questo."),
	new Array("405","Incorrect Data Type",""),
	new Array("406","Erro interno do servidor","Houve um erro durante a comunicao com o servidor WebAula Corporate.")
);
/*****************************************************************************
**
** Metodo: LMSInitialize(param)
** Entrada: param - deve ser um string vazio ("") - reservado para uso futuro
** Saida: CMIBoolean (implementado com as strings abaixo)
**		"0" - LMSInitialize falhou, "1" - LMSInitialize executado com sucesso
**
** Descricao:
** Eh o metodo de inicializacao das comunicacoes API - SCO
**
*****************************************************************************/
function LMSInitialize(param)
{
	// Esta funcao precisa ser chamada por uma AU antes que outras chamadas
	// a API sejam feitas. Nao pode ser chamada mais de uma vez consecutiva
	// a menos que LMSFinish seja chamada antes.
	var objFrameWork = new LEBJSFrameWork();
	if ( _Debug )
	{
		escreveDebug("Na API: LMSInitialize");
	}
	var result = "false";
	if (objDadosSala.topicosCarregados == cstSim)
	{
		enableButtonsDelay(3000);
	}
	else
	{
		parent.frames[2].location.href = objDadosSala.urlExterno + '/saladata.asp?aluno=' + objDadosSala.codAluno + 
				'&curso=' + objDadosSala.codCurso +
				'&turma=' + objDadosSala.codTurma +
				'&demonstracao=' + objDadosSala.demonstracao +
				'&presencial=' + objDadosSala.cursoPresencial +
				'&topico=' + arrTopicos[topicoAtual].codTopico +
				'&scormcompliant=' + objDadosSala.scormCompliant +
		 '&HistoricoImportado=' + objDadosSala.historicoImportado;
	}
	// Assegura que o parametro e vazio - Especificacao da API
	if ( !objFrameWork.pIsEmpty(param) )
	{
		lmsError.errorCode = "201";
		return result;
	}
	// Checando se LMS ja esta inicializado
	if ( isLMSInitialized )
	{
 //
 // ATENÇÃO: NÃO ALTERAR A LINHA return "true";
 // O CODIGO ORIGINAL ESTÁ ABAIXO
 //lmsError.errorCode = "101";
 //
		return "true";
	} 
	else
	{
		isLMSInitialized = true;
		objAPIDadosSala = objDadosSala;
		objArrTopicos = arrTopicos[topicoAtual];
		strTotal_time = objArrTopicos.coreTotal_time;
		// Nao foram detectados erros
		lmsError.errorCode = "0";
		result = "true";
	}
	if ( _Debug )
	{
		escreveDebug("LMSInitialize() terminando");
	}
	return result;
}
/*****************************************************************************
**
** Metodo: LMSFinish
** Entrada: param - deve ser um string vazio ("") - reservado para uso futuro
** Saida: nenhuma
**
** Descricao:
** 	Assinala fim da comunicacao com o LMS
**
*****************************************************************************/
function LMSFinish(param)
{
	var objFrameWork = new LEBJSFrameWork();
	if( _Debug )
	{
		escreveDebug("Na API: LMSFinish");
	}
	var result = "false";
	isFinishing = true;
	lmsError.errorCode = "0";
	// Assegura que o parametro e vazio - Especificacao da API
	if ( !objFrameWork.pIsEmpty(param) )
	{
		lmsError.errorCode = "201";
		return result;
	}
	else
	{
		if ( isLMSInitialized )
		{
			//Gravando alteracoes pendentes no Data Buffer e gravando no Banco
			emptyString = "";
			LMSCommit(emptyString);
			isLMSInitialized = false;
			lmsDataBuffer.isBufferInitialized = false;
			//Atualizando e gravando informacoes do formulario no banco
			//carregaFrmCMI();
			result = "true";
		}
		else
		{
			//LMS nao inicializado
			lmsError.errorCode = "301";
			if( _Debug )
			{
				escreveDebug("LMS nao inicializado");
			}
			return "false";
		}
	}
	if ( _Debug )
	{
		escreveDebug("LMSFinish() terminando");
	}
	isFinishing = false;
	return result;
}
/*****************************************************************************
**
** Metodo: LMSGetValue(element)
** Entrada: element - String contendo o 'element' do CMI Data Model
** Saida: String contendo o valor do 'element' do CMI Data Model
**
** Descricao:
** 	Retorna o valor atual do 'element' do CMI Data Model armazenado pelo LMS
**
*****************************************************************************/
function LMSGetValue(element)
{
	if( _Debug )
	{
		escreveDebug("Na API: LMSGetValue: " + element);
	}
	lmsError.errorCode = "0";
	if ( !isLMSInitialized ) isLMSInitialized = true; //FORÇANDO INICIALIZAÇÃO. NÃO RETIRAR.
	if ( !isLMSInitialized )
	{
		//LMS nao inicializado
		lmsError.errorCode = "301";
		if( _Debug )
		{
			escreveDebug("LMS nao inicializado");
		}
		var emptyString = "";
		return emptyString;
	}
	if ( _Debug )
	{
		escreveDebug("Procurando o element " + element);
	}
	var pesquisa = element;
	var rtnVal = null;
	var indexObjectives = -1;
	var indexInteractions = -1;
	var indices = new Array();
	indices[0] = "n";
	indices[1] = "m";
	indexIndices = 0;
	//Tratamento da variavel pesquisa para o caso dela ser multipla (Ex.: objectives.4.id, interactions.2.objectives.3.id)
	vetPesquisa = pesquisa.split(".");
	for (i = 0; i < vetPesquisa.length; i++)
	{
		//Reconstruir nome do objeto de procura
		if (!isNaN(vetPesquisa[i]))
		{
			if ( indexObjectives != -1 )
				indexInteractions = parseFloat(vetPesquisa[i]);
			else
				indexObjectives = parseFloat(vetPesquisa[i]);
			pesquisa = "";
			for (j = 0; j < vetPesquisa.length; j++)
			{
				if (j == i)
					pesquisa = pesquisa + "." + indices[indexIndices++];
				else
					pesquisa = pesquisa + "." + vetPesquisa[j];
			}
			pesquisa = pesquisa.substring(1, pesquisa.length);
			vetPesquisa = pesquisa.split(".");
		}
	}
	if ((pos=pesquisa.indexOf("._children")) != -1)
	{
		if ( existeElement(pesquisa.substring(0,pos)) == cstTrue)
		{
			if ( existeElement(pesquisa) == cstFalse )
			{
				//Element nao pode ter filhos
				lmsError.errorCode = "202"
				rtnVal = ""
				return rtnVal;
			}
		}
	}
	if ((pos=pesquisa.indexOf("._count")) != -1)
	{
		if ( existeElement(pesquisa.substring(0,pos)) == cstTrue )
		{
if ( existeElement(pesquisa) == cstFalse )
			{
				//Element nao e vetor
				lmsError.errorCode = "203"
				rtnVal = ""
				return rtnVal;
			}
		}
	}
	if (existeElement(pesquisa) == cstFalse)
	{
		lmsError.errorCode = "201";
		rtnVal = "";
		return rtnVal;
	}
	switch (pesquisa)
	{
		case "cmi.core._children":
			rtnVal = buscaFilhos("cmi.core._children");
			break;
		case "cmi.core.student_id":
			rtnVal = objAPIDadosSala.codAluno;
			break;
		case "cmi.core.student_name":
			rtnVal = objAPIDadosSala.nomeAluno;
			break;
		case "cmi.core.credit":
			rtnVal = objArrTopicos.coreCredit;
			break;
		case "cmi.core.lesson_location":
			rtnVal = lmsDataBuffer.coreLesson_location.info;
			break;
		case "cmi.core.lesson_status":
			rtnVal = lmsDataBuffer.coreLesson_status.info;
			break;
		case "cmi.core.lesson_mode":
			rtnVal = objArrTopicos.coreLesson_mode;
			break;
		case "cmi.core.entry":
			rtnVal = lmsDataBuffer.coreEntry.info;
			break;
		case "cmi.core.exit":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.core.score._children":
			rtnVal = buscaFilhos("cmi.core.score._children");
			break;
		case "cmi.core.score.raw":
			rtnVal = lmsDataBuffer.scoreRaw.info;
			break;
		case "cmi.core.score.max":
			rtnVal = lmsDataBuffer.scoreMax.info;
			break;
		case "cmi.core.score.min":
			rtnVal = lmsDataBuffer.scoreMin.info;
			break;
		case "cmi.core.session_time":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.core.total_time":
			rtnVal = strTotal_time;
			break;
		case "cmi.suspend_data":
			rtnVal = lmsDataBuffer.suspend_data.info;
			break;
		case "cmi.launch_data":
			rtnVal = lmsDataBuffer.launch_data.info;
			break;
		case "cmi.comments":
			rtnVal = lmsDataBuffer.comments.info;
			break;
		case "cmi.comments_from_lms":
			rtnVal = lmsDataBuffer.comments_from_lms.info;
			break;
		case "cmi.student_preference._children":
			rtnVal = buscaFilhos("cmi.student_preference._children");
			break;
		case "cmi.student_preference.audio":
			rtnVal = objAPIDadosSala.student_preferenceAudio;
			break;
		case "cmi.student_preference.language":
			rtnVal = objAPIDadosSala.student_preferenceLanguage;
			break;
		case "cmi.student_preference.speed":
			rtnVal = objAPIDadosSala.student_preferenceSpeed;
			break;
		case "cmi.student_preference.text":
			rtnVal = objAPIDadosSala.student_preferenceText;
			break;
		case "cmi.student_data._children":
			rtnVal = buscaFilhos("cmi.student_data._children");
			break;
		case "cmi.student_data.mastery_score":
			rtnVal = lmsDataBuffer.student_dataMastery_score.info;
			break;
		case "cmi.student_data.max_time_allowed":
			rtnVal = lmsDataBuffer.student_dataMax_time_allowed.info;
			break;
		case "cmi.student_data.time_limit_action":
			rtnVal = lmsDataBuffer.student_dataTime_limit_action.info;
			break;
		case "cmi.objectives._children":
			rtnVal = buscaFilhos("cmi.objectives._children");
			break;
		case "cmi.objectives._count":
			rtnVal = lmsObjectivesBuffer.id.length;
			break;
		case "cmi.objectives.n.id":
			if (indexObjectives >= lmsObjectivesBuffer.id.length)
				rtnVal = "";
			else
				rtnVal = lmsObjectivesBuffer.id[indexObjectives];
			break;
		case "cmi.objectives.n.score._children":
			if (indexObjectives >= lmsObjectivesBuffer.id.length)
				rtnVal = "";
			else
				rtnVal = buscaFilhos(pesquisa);
			break;
		case "cmi.objectives.n.score.raw":
			if (indexObjectives >= lmsObjectivesBuffer.scoreRaw.length)
				rtnVal = "";
			else
				rtnVal = lmsObjectivesBuffer.scoreRaw[indexObjectives];
			break;
		case "cmi.objectives.n.score.max":
			if (indexObjectives >= lmsObjectivesBuffer.scoreMax.length)
				rtnVal = "";
			else
				rtnVal = lmsObjectivesBuffer.scoreMax[indexObjectives];
			break;
		case "cmi.objectives.n.score.min":
			if (indexObjectives >= lmsObjectivesBuffer.scoreMin.length)
				rtnVal = "";
			else
				rtnVal = lmsObjectivesBuffer.scoreMin[indexObjectives];
			break;
		case "cmi.objectives.n.status":
			if (indexObjectives >= lmsObjectivesBuffer.status.length)
				rtnVal = "";
			else
				rtnVal = lmsObjectivesBuffer.status[indexObjectives];
			break;
		
		case "cmi.interactions._children":
			rtnVal = buscaFilhos("cmi.interactions._children");
			break;
		case "cmi.interactions._count":
			rtnVal = lmsInteractionsBuffer.id.length;
			break;
		case "cmi.interactions.n.id":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.objectives._count":
			rtnVal = lmsInteractionsBuffer.objectivesId[indexObjectives].length;
			break;
		case "cmi.interactions.n.objectives.m.id":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.time":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.type":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.correct_responses._count":
			rtnVal = lmsInteractionsBuffer.correct_responsesPattern[indexObjectives].length;
			break;
		case "cmi.interactions.n.correct_responses.m.pattern":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.weighting":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.student_response":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.result":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
		case "cmi.interactions.n.latency":
			lmsError.errorCode = "404";
			rtnVal = "";
			break;
	}
	if(rtnVal != null)
	{
		if ( _Debug )
		{
			escreveDebug("LMSGetValue() encontrado!<br>" + "Retornando: "+ rtnVal);
		}
	}
	else
	{
		if ( _Debug )
		{
			escreveDebug("Element encontrado, mas com valor nulo");
		}
		rtnVal = "";
	}
	if ( _Debug )
	{
		escreveDebug("LMSGetValue terminando");
	}
	return rtnVal;
}
/*****************************************************************************
**
** Metodo: LMSSetValue(element, value)
** Entrada: element - String contendo o 'element' do CMI Data Model a ser 
** gravado. value - valor a ser aplicado ao element.
** Saida: nenhuma
**
** Descricao:
** 	Aplica o valor especificado ao element do Data Model
**
*****************************************************************************/
function LMSSetValue(element, value, blnForceSetValue)
{
	if( _Debug )
	{
		escreveDebug("Na API: LMSSetValue<br>Elemento: " + element + '<br>Valor: ' + value);
	}
	lmsError.errorCode = "0";
	if ( !isLMSInitialized ) isLMSInitialized = true; //FORÇANDO INICIALIZAÇÃO. NÃO RETIRAR.
	if ( !isLMSInitialized )
	{
		//LMS nao inicializado
		lmsError.errorCode = "301";
		if( _Debug )
		{
			escreveDebug("LMS nao inicializado");
		}
		return "false";
	}
	var pesquisa = element;
	var rtnVal = "";
	if ( _Debug )
	{
		escreveDebug("Procurando o element " + element ); 
	}
	var indexObjectives = -1;
	var indexInteractions = -1;
	var indices = new Array();
	indices[0] = "n";
	indices[1] = "m";
	indexIndices = 0;
	//Tratamento da variavel pesquisa para o caso dela ser multipla (Ex.: objectives.4.id)
	vetPesquisa = pesquisa.split(".");
	for (i = 0; i < vetPesquisa.length; i++)
	{
		//Reconstruir nome do objeto de procura
		if (!isNaN(vetPesquisa[i]))
		{
			if ( indexObjectives != -1 )
				indexInteractions = parseFloat(vetPesquisa[i]);
			else
				indexObjectives = parseFloat(vetPesquisa[i]);
			pesquisa = "";
			for (j = 0; j < vetPesquisa.length; j++)
			{
				if (j == i)
					pesquisa = pesquisa + "." + indices[indexIndices++];
				else
					pesquisa = pesquisa + "." + vetPesquisa[j];
			}
			pesquisa = pesquisa.substring(1, pesquisa.length);
			vetPesquisa = pesquisa.split(".");
		}
	}
	if (existeElement(pesquisa)
== cstFalse)
	{
		lmsError.errorCode = "201";
		rtnVal = "false";
		return rtnVal;
	}
	switch (pesquisa)
	{
		case "cmi.core._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.core.student_id":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.core.student_name":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.core.lesson_location":
			if ( !validaDataType("CMIString255",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.coreLesson_location.info = value;
				lmsDataBuffer.coreLesson_location.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.core.credit":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.core.lesson_status":
			if ( !validaDataType("CMIVocabulary",value,"status") || value == cstNotAttempted )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
			 if (!(lmsDataBuffer.coreLesson_status.info == cstCompleted || lmsDataBuffer.coreLesson_status.info == cstPassed))
				{
					lmsDataBuffer.coreLesson_status.info = value;
				}
				lmsDataBuffer.coreLesson_status.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.core.entry":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.core.score._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.core.score.raw":
			if ( (!validaDataType("CMIDecimal",value) && !validaDataType("CMIBlank",value)) || parseFloat(value) < 0 || parseFloat(value) > 100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.scoreRaw.info = value;
				lmsDataBuffer.scoreRaw.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.core.score.max":
			if ( (!validaDataType("CMIDecimal",value) && !validaDataType("CMIBlank",value)) || parseFloat(value) < 0 || parseFloat(value) > 100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.scoreMax.info = value;
				lmsDataBuffer.scoreMax.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.core.score.min":
			if ( (!validaDataType("CMIDecimal",value) && !validaDataType("CMIBlank",value)) || parseFloat(value) < 0 || parseFloat(value) > 100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.scoreMin.info = value;
				lmsDataBuffer.scoreMin.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.core.total_time":
			if (blnForceSetValue != undefined){
				strTotal_time = value;
				lmsDataBuffer.coreTotal_time.info = value;
				lmsDataBuffer.coreTotal_time.dirty = true;
				rtnVal = "true";
				break;
			}
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.core.exit":
			if ( !validaDataType("CMIVocabulary",value,"exit") )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.coreExit.info = value;
				lmsDataBuffer.coreExit.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.core.session_time":
			if ( !validaDataType("CMITimespan",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.coreSession_time.info = value;
				lmsDataBuffer.coreSession_time.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.suspend_data":
			if ( !validaDataType("CMIString4096",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsDataBuffer.suspend_data.info = value;
				lmsDataBuffer.suspend_data.dirty = true;
				rtnVal = "true";
			}
			break;
		case "cmi.launch_data":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.core.lesson_mode":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.comments":
			if ( !validaDataType("CMIString4096",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
			 var strComments = LMSGetValue("cmi.comments") + value; //Busca o valor anterior e adiciona o novo parâmetro
			 strComments = strComments.substr(0, 4096); //Certifica que o total do comentário não ultrapasse o valor máximo definido pelo Scorm
				lmsDataBuffer.comments.info = strComments; //Atualiza o buffer da sala com o comment já tratado
				lmsDataBuffer.comments.dirty = true;
				rtnVal = "true";
			}
			break;
		
		case "cmi.comments_from_lms":
			lmsError.errorCode = "403";
			rtnVal = "false"
			break;
		case "cmi.student_preference._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.student_preference.audio":
			if ( !validaDataType("CMISInteger",value) || parseFloat(value) < -1 || parseFloat(value) > 100)
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				objAPIDadosSala.student_preferenceAudio = value;
				rtnVal = "true";
			}
			break;
		
		case "cmi.student_preference.language":
			if ( !validaDataType("CMIString255",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				objAPIDadosSala.student_preferenceLanguage = value;
				rtnVal = "true";
			}
			break;
		case "cmi.student_preference.speed":
			if ( !validaDataType("CMISInteger",value) || parseFloat(value) > 100 || parseFloat(value) < -100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				objAPIDadosSala.student_preferenceSpeed = value;
				rtnVal = "true";
			}
			break;
		case "cmi.student_preference.text":
			if ( !validaDataType("CMISInteger",value) || parseFloat(value) < -1 || parseFloat(value) > 1 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				objAPIDadosSala.student_preferenceText = value;
				rtnVal = "true";
			}
			break;
		case "cmi.student_data._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.student_data.mastery_score":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.student_data.max_time_allowed":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.student_data.time_limit_action":
			lmsError.errorCode = "403";
			rtnVal = "false";
			break;
		case "cmi.objectives._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.objectives._count":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.objectives.n.id":
			if ( indexObjectives > lmsObjectivesBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIIdentifier",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsObjectivesBuffer.dirty = true;
				if (indexObjectives >= lmsObjectivesBuffer.id.length)
				{
					lmsObjectivesBuffer.scoreRaw[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMax[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMin[indexObjectives] = "";
					lmsObjectivesBuffer.status[indexObjectives] = "";
				}
				lmsObjectivesBuffer.id[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.objectives.n.score._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.objectives.n.score.raw":
			if ( indexObjectives > lmsObjectivesBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( (!validaDataType("CMIDecimal",value) && !validaDataType("CMIBlank",value)) || parseFloat(value) < 0 || parseFloat(value) > 100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsObjectivesBuffer.dirty = true;
if (indexObjectives >= lmsObjectivesBuffer.id.length)
				{
					lmsObjectivesBuffer.id[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMax[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMin[indexObjectives] = "";
					lmsObjectivesBuffer.status[indexObjectives] = "";
				}
				lmsObjectivesBuffer.scoreRaw[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.objectives.n.score.max":
			if ( indexObjectives > lmsObjectivesBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( (!validaDataType("CMIDecimal",value) && !validaDataType("CMIBlank",value)) || parseFloat(value) < 0 || parseFloat(value) > 100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsObjectivesBuffer.dirty = true;
				if (indexObjectives >= lmsObjectivesBuffer.id.length)
				{
					lmsObjectivesBuffer.id[indexObjectives] = "";
					lmsObjectivesBuffer.scoreRaw[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMin[indexObjectives] = "";
					lmsObjectivesBuffer.status[indexObjectives] = "";
				}
				lmsObjectivesBuffer.scoreMax[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.objectives.n.score.min":
			if ( indexObjectives > lmsObjectivesBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( (!validaDataType("CMIDecimal",value) && !validaDataType("CMIBlank",value)) || parseFloat(value) < 0 || parseFloat(value) > 100 )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsObjectivesBuffer.dirty = true;
				if (indexObjectives >= lmsObjectivesBuffer.id.length)
				{
					lmsObjectivesBuffer.id[indexObjectives] = "";
					lmsObjectivesBuffer.scoreRaw[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMax[indexObjectives] = "";
					lmsObjectivesBuffer.status[indexObjectives] = "";
				}
				lmsObjectivesBuffer.scoreMin[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.objectives.n.status":
			if ( indexObjectives > lmsObjectivesBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIVocabulary",value,"status") )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsObjectivesBuffer.dirty = true;
				if (indexObjectives >= lmsObjectivesBuffer.id.length)
				{
					lmsObjectivesBuffer.id[indexObjectives] = "";
					lmsObjectivesBuffer.scoreRaw[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMax[indexObjectives] = "";
					lmsObjectivesBuffer.scoreMin[indexObjectives] = "";
				}
				lmsObjectivesBuffer.status[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions._children":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.interactions._count":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.interactions.n.id":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIIdentifier",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.time[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.latency[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.id[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions.n.objectives._count":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.interactions.n.objectives.m.id":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIIdentifier",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
					lmsInteractionsBuffer.latency[indexObjectives] = value;
				}
				if ( indexInteractions > lmsInteractionsBuffer.objectivesId[indexObjectives].length )
				{
					lmsError.errorCode = "201";
					rtnVal = "false";
				}
				else
				{
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( indexInteractions >= lmsInteractionsBuffer.objectivesId[i].length )
							max = indexInteractions + 1;
						else
							max = lmsInteractionsBuffer.objectivesId[i].length;
						for ( j = 0 ; j < max ; j++ )
						{
							if ( typeof(lmsInteractionsBuffer.objectivesId[i][j]) == cstUndefined )
								lmsInteractionsBuffer.objectivesId[i][j] = "";
						}
					}
					lmsInteractionsBuffer.objectivesId[indexObjectives][indexInteractions] = value;
					rtnVal = "true";
				}
			}
			break;
		case "cmi.interactions.n.time":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMITime",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.latency[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.time[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions.n.type":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIVocabulary",value,"interaction") )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty
= true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.latency[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.type[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions.n.correct_responses._count":
			lmsError.errorCode = "402";
			rtnVal = "false";
			break;
		case "cmi.interactions.n.correct_responses.m.pattern":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIFeedback",value,lmsInteractionsBuffer.type[indexObjectives]) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
					lmsInteractionsBuffer.latency[indexObjectives] = value;
				}
				if ( indexInteractions > lmsInteractionsBuffer.correct_responsesPattern[indexObjectives].length )
				{
					lmsError.errorCode = "201";
					rtnVal = "false";
				}
				else
				{
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( indexInteractions >= lmsInteractionsBuffer.correct_responsesPattern[i].length )
							max = indexInteractions + 1;
						else
							max = lmsInteractionsBuffer.correct_responsesPattern[i].length;
						for ( j = 0 ; j < max ; j++ )
						{
							if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i][j]) == cstUndefined )
								lmsInteractionsBuffer.correct_responsesPattern[i][j] = "";
						}
					}
					lmsInteractionsBuffer.correct_responsesPattern[indexObjectives][indexInteractions] = value;
					rtnVal = "true";
				}
			}
			break;
		case "cmi.interactions.n.weighting":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIDecimal",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.latency[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.weighting[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions.n.student_response":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIFeedback",value,lmsInteractionsBuffer.type[indexObjectives]) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.latency[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.student_response[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions.n.result":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMIVocabulary",value,"result") )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					lmsInteractionsBuffer.latency[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined )
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.result[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
		case "cmi.interactions.n.latency":
			if ( indexObjectives > lmsInteractionsBuffer.id.length || indexObjectives < 0 )
			{
				lmsError.errorCode = "201";
				rtnVal = "false";
			}
			else if ( !validaDataType("CMITimespan",value) )
			{
				lmsError.errorCode = "405";
				rtnVal = "false";
			}
			else
			{
				lmsInteractionsBuffer.dirty = true;
				if (indexObjectives >= lmsInteractionsBuffer.id.length)
				{
					lmsInteractionsBuffer.id[indexObjectives] = "";
					lmsInteractionsBuffer.type[indexObjectives] = "";
					lmsInteractionsBuffer.weighting[indexObjectives] = "";
					lmsInteractionsBuffer.student_response[indexObjectives] = "";
					lmsInteractionsBuffer.result[indexObjectives] = "";
					lmsInteractionsBuffer.time[indexObjectives] = "";
					for ( i = 0 ; i <= indexObjectives ; i++ )
					{
						if ( typeof(lmsInteractionsBuffer.objectivesId[i]) == cstUndefined )
							lmsInteractionsBuffer.objectivesId[i] = new Array();
						if ( typeof(lmsInteractionsBuffer.correct_responsesPattern[i]) == cstUndefined
)
							lmsInteractionsBuffer.correct_responsesPattern[i] = new Array();
					}
				}
				lmsInteractionsBuffer.latency[indexObjectives] = value;
				rtnVal = "true";
			}
			break;
	}
	if ( _Debug )
	{
		escreveDebug("LMSSetValue() terminando...<br>" + "Retornando: "+ rtnVal);
	}
	if ( rtnVal == "true" && !lmsDataBuffer.isBufferInitialized)
	{
		lmsDataBuffer.isBufferInitialized = true;
	}
				
	return rtnVal;
}
/*****************************************************************************
**
** Metodo: LMSCommit()
** Entrada: param - deve ser um string vazio ("") - reservado para uso futuro
** Saida: nenhuma
**
** Descricao:
** 	Salva os dados que foram setados pelo LMSSetValue no banco de dados
**
*****************************************************************************/
function LMSCommit(param)
{
	var objFrameWork = new LEBJSFrameWork();
	if( _Debug )
	{
		escreveDebug("Na API: LMSCommit");
	}
	var result = "false";
	// Assegura que o parametro e vazio - Especificacao da API
	if ( !objFrameWork.pIsEmpty(param) )
	{
		lmsError.errorCode = "201";
		return result;
	}
	else
	{
		if ( !isLMSInitialized ) isLMSInitialized = true; //FORÇANDO INICIALIZAÇÃO. NÃO RETIRAR.
		if ( !isLMSInitialized )
		{
			//LMS nao inicializado
			lmsError.errorCode = "301";
			if( _Debug )
			{
				escreveDebug("LMS nao inicializado");
			}
			return result;
		}
		if ( _Debug )
		{
			var msg = "Salvando informacoes no banco de dados...<br>O buffer contem as seguintes informacoes:<br>" +
			"lesson_location: "+lmsDataBuffer.coreLesson_location.info + "<br>" +
			"coreLesson_status: "+lmsDataBuffer.coreLesson_status.info + "<br>" +
			"scoreRaw: "+lmsDataBuffer.scoreRaw.info + "<br>" +
			"scoreMax: "+lmsDataBuffer.scoreMax.info + "<br>" +
			"scoreMin: "+lmsDataBuffer.scoreMin.info + "<br>" +
			"coreExit: "+lmsDataBuffer.coreExit.info + "<br>" +
			"coreSession_time: "+lmsDataBuffer.coreSession_time.info + "<br>" +
			"suspend_data: "+lmsDataBuffer.suspend_data.info+"<br>"+
			"ObjectivesBuffer.dirty: "+lmsObjectivesBuffer.dirty+"<br>"+
			"ObjectivesBuffer._count: "+lmsObjectivesBuffer.id.length+"<br>";
			for ( I = 0 ; I < lmsObjectivesBuffer.id.length ; I++ )
			{
				msg += "ObjectivesBuffer."+I+".id: "+lmsObjectivesBuffer.id[I]+"<br>";
				msg += "ObjectivesBuffer."+I+".score.raw: "+lmsObjectivesBuffer.scoreRaw[I]+"<br>";
				msg += "ObjectivesBuffer."+I+".score.max: "+lmsObjectivesBuffer.scoreMax[I]+"<br>";
				msg += "ObjectivesBuffer."+I+".score.min: "+lmsObjectivesBuffer.scoreMin[I]+"<br>";
				msg += "ObjectivesBuffer."+I+".status: "+lmsObjectivesBuffer.status[I]+"";
			}
			escreveDebug(msg);
		}
		// Setando coreSession_time
		if (lmsDataBuffer.coreSession_time.dirty && strTotal_time != null)
		{
			//Calcular total_time
			carry = 0;
			finalresult = "";
			vetactual_total_time = strTotal_time.split(":");
			vetsession_time = lmsDataBuffer.coreSession_time.info.split(":");
			for (i = vetsession_time.length-1; i >= 0; i--)
			{
				total = parseFloat(vetactual_total_time[i]);
				session = parseFloat(vetsession_time[i]);
				subresult = total + session + carry;
				if (subresult >= 60 && i != 0)
				{
					carry = Math.floor(subresult / 60);
					subresult = Math.round((subresult - (carry * 60))*100)/100;
				}
				else
				{
					carry = 0;
				}
				if (i == vetsession_time.length-1)
				{
					//Colocar subresult com precisao de 2 casas (xx.xx segundos)
					if (subresult < 10)
						finalresult = "0" + String(subresult);
					else
						finalresult = String(subresult);
					if (finalresult.length == 2)
						finalresult = finalresult + ".00";
					if (finalresult.length == 4)
						finalresult = finalresult + "0";
					if (finalresult.length > 5)
						finalresult = finalresult.substring(0,5);
				}
				else if (i == 0)
				{
					//Colocar subresult com 4 digitos (horas)
					if (subresult < 10)
						finalresult = "000" + String(subresult) + ":" + finalresult;
					else if (subresult < 100)
						finalresult = "00" + String(subresult) + ":" + finalresult;
					else if (subresult < 1000)
						finalresult = "0" + String(subresult) + ":" + finalresult;
					else if (subresult < 9999)
						finalresult = String(subresult) + ":" + finalresult;
					else
					{
						lmsError.errorCode = "405";
						return result;
					}
				}
				else
				{
					//Colocar subresult com 2 casas normais (minutos)
					if (subresult < 10)
						finalresult = "0" + String(subresult) + ":" + finalresult;
					else
						finalresult = String(subresult) + ":" + finalresult;
				}
			}
			//Fim - calcular total_time
			lmsDataBuffer.coreTotal_time.info = finalresult.substring(0,13);
			lmsDataBuffer.coreTotal_time.dirty = true;
		}
		// Nao foram detectados erros
		lmsError.errorCode = "0";
	}
 if ((!verificaPrazo()) && (! _SomenteLeitura)) {
 if (_Debug) {
 escreveDebug("Prazo de acesso expirou");
 }
 return result;
 }
	if ( objAPIDadosSala.Gestor || carregaXMLCMI() )
	{
		result = "true";
 }
	if ( _Debug )
	{
		escreveDebug("LMSCommit terminando");
	}
	return result;
}
function verificaPrazo() {
 return true; // Para a estácio, não faz sentido verificar o acesso após o prazo porque essa situação não é utilizada.
 var cstBloqueado = "BLOQUEADO";
 var objFrameWork = new LEBJSFrameWork();
 if (objDadosSala.codAluno == cstZero || objFrameWork.pIsEmpty(objDadosSala.codAluno) ||
 objDadosSala.codTurma == cstZero || objFrameWork.pIsEmpty(objDadosSala.codTurma)
 )
 return false;
 strRetorno = rPC("/scormapi/verificaPrazoTurma.asp", "", true, "codAluno=" + objDadosSala.codAluno + "&codTurma=" + objDadosSala.codTurma);
 return (strRetorno != cstBloqueado) ? true : false;
}
/*****************************************************************************
**
** Metodo: carregaXMLCMI()
** Entrada: nenhuma
** Saida: nenhuma
**
** Descricao:
** 	Carrega os dados do buffer num arquivo XML para envio ao xmlCMI.asp
*****************************************************************************/
function carregaXMLCMI(){
	var blnAssincrono = true;
	var arquivoXMl = "";
	var contador = 0;
	var objFrameWork = new LEBJSFrameWork();
	if (objAPIDadosSala.revisar == cstSim) return true;
	if (objAPIDadosSala.topicosCarregados == cstNao)
	{
		if ( _Debug )
		{
			escreveDebug("Postagem de dados adiada em 500ms (topicos nao carregados)...");
		}
		setTimeout(function(){carregaXMLCMI();}, 500);
		return true;
	}
	window.parent.parent.salaheader.atualizaBuffer(lmsDataBuffer);
	arquivoXMl = '<?xml version="1.0" encoding="UTF-8"?>';
	if (objAPIDadosSala.codAluno == cstZero || objFrameWork.pIsEmpty(objAPIDadosSala.codAluno))
		return;
	arquivoXMl += '<dadosSala>';
	arquivoXMl += '<dadosCMI codAluno="' + objAPIDadosSala.codAluno + '" codCurso="' + objAPIDadosSala.codCurso + '"';
	arquivoXMl += ' codTurma="' + objAPIDadosSala.codTurma + '" codTopico="' + objArrTopicos.codTopico + '"';
	arquivoXMl += ' coreCredit="' + objArrTopicos.coreCredit + '">';
	arquivoXMl += '<numAcessos>' + objArrTopicos.numAcessos + '</numAcessos>';
	if (objAPIDadosSala.cursoPresencial != cstSim)
		arquivoXMl += '<percConclusao>' + objAPIDadosSala.percConclusao + '</percConclusao>';
	else
		arquivoXMl += '<percConclusao><![CDATA[Webaula-null]]></percConclusao>';
	arquivoXMl += '<cursoPresencial>' + objAPIDadosSala.cursoPresencial + '</cursoPresencial>';
	if (isFinishing)
	{
		arquivoXMl += '<isFinishing>S</isFinishing>';
		objArrTopicos.numAcessos++;
	}
	else
	{
		arquivoXMl += '<isFinishing>N</isFinishing>';
	}
	arquivoXMl += '<core>';
	if ( lmsDataBuffer.coreLesson_location.dirty )
	{
		arquivoXMl += '<lesson_location><![CDATA[' + lmsDataBuffer.coreLesson_location.info + ']]></lesson_location>';
}
	else
	{
		arquivoXMl += '<lesson_location><![CDATA[Webaula-null]]></lesson_location>';
	}
	if ( lmsDataBuffer.coreLesson_status.dirty )
	{
		arquivoXMl += '<lesson_status><![CDATA[' + lmsDataBuffer.coreLesson_status.info + ']]></lesson_status>';
	}
	else
	{
		arquivoXMl += '<lesson_status><![CDATA[Webaula-null]]></lesson_status>';
	}
	if ( lmsDataBuffer.scoreRaw.dirty )
	{
		arquivoXMl += '<scoreRaw><![CDATA[' + lmsDataBuffer.scoreRaw.info + ']]></scoreRaw>';
	}
	else
	{
		arquivoXMl += '<scoreRaw><![CDATA[Webaula-null]]></scoreRaw>';
	}
	if ( lmsDataBuffer.scoreMax.dirty )
	{
		arquivoXMl += '<scoreMax><![CDATA[' + lmsDataBuffer.scoreMax.info + ']]></scoreMax>';
	}
	else
	{
		arquivoXMl += '<scoreMax><![CDATA[Webaula-null]]></scoreMax>';
	}
	if ( lmsDataBuffer.scoreMin.dirty )
	{
		arquivoXMl += '<scoreMin><![CDATA[' + lmsDataBuffer.scoreMax.info + ']]></scoreMin>';
	}
	else
	{
		arquivoXMl += '<scoreMin><![CDATA[Webaula-null]]></scoreMin>';
	}
	arquivoXMl += '<entry>' + lmsDataBuffer.coreEntry.info + '</entry>';
	if ( lmsDataBuffer.coreExit.dirty )
	{
		arquivoXMl += '<exit><![CDATA[' + lmsDataBuffer.coreExit.info + ']]></exit>';
	}
	else
	{
		arquivoXMl += '<exit><![CDATA[Webaula-null]]></exit>';
	}
	if ( lmsDataBuffer.coreTotal_time.dirty )
	{
		arquivoXMl += '<total_time><![CDATA[' + lmsDataBuffer.coreTotal_time.info + ']]></total_time>';
		lmsDataBuffer.coreSession_time.info = '';
		lmsDataBuffer.coreSession_time.dirty = false;
	}
	else
	{
		arquivoXMl += '<total_time><![CDATA[Webaula-null]]></total_time>';
	}
	arquivoXMl += '</core>';
	if ( lmsDataBuffer.suspend_data.dirty )
	{
		arquivoXMl += '<suspend_data><![CDATA[' + lmsDataBuffer.suspend_data.info + ']]></suspend_data>';
	}
	else
	{
		arquivoXMl += '<suspend_data><![CDATA[Webaula-null]]></suspend_data>';
	}
	if ( lmsDataBuffer.comments.dirty )
	{
		arquivoXMl += '<comments><![CDATA[' + lmsDataBuffer.comments.info + ']]></comments>';
	}
	else
	{
		arquivoXMl += '<comments><![CDATA[Webaula-null]]></comments>';
	}
	arquivoXMl += '<student_preference>';
	if ( !objFrameWork.pIsEmpty(objAPIDadosSala.student_preferenceAudio) )
		arquivoXMl += '<audio><![CDATA[' + objAPIDadosSala.student_preferenceAudio + ']]></audio>';
	else
		arquivoXMl += '<audio><![CDATA[Webaula-null]]></audio>';
	
	if ( !objFrameWork.pIsEmpty(objAPIDadosSala.student_preferenceLanguage ) )
		arquivoXMl += '<language><![CDATA[' + objAPIDadosSala.student_preferenceLanguage + ']]></language>';
	else
		arquivoXMl += '<language><![CDATA[Webaula-null]]></language>';
	
	if ( !objFrameWork.pIsEmpty(objAPIDadosSala.student_preferenceSpeed ) )
		arquivoXMl += '<speed><![CDATA[' + objAPIDadosSala.student_preferenceSpeed + ']]></speed>';
	else
		arquivoXMl += '<speed><![CDATA[Webaula-null]]></speed>';
	
	if ( !objFrameWork.pIsEmpty(objAPIDadosSala.student_preferenceText ) )
		arquivoXMl += '<text><![CDATA[' + objAPIDadosSala.student_preferenceText + ']]></text>';
	else
		arquivoXMl += '<text><![CDATA[Webaula-null]]></text>';
	arquivoXMl += '</student_preference>';
	arquivoXMl += '<objectives>';
	if (lmsObjectivesBuffer.dirty)
	{
		for (i = 0; i < lmsObjectivesBuffer.id.length; i++)
		{
			arquivoXMl += '<objective>';
			var objectiveId, objectiveScoreRaw, objectiveScoreMin, objectiveScoreMax, objectiveStatus
			if ( !lmsObjectivesBuffer.id[i] || objFrameWork.pIsEmpty(lmsObjectivesBuffer.id[i]) )
				arquivoXMl += '<id><![CDATA[Webaula-null]]></id>';
			else
				arquivoXMl += '<id><![CDATA[' + lmsObjectivesBuffer.id[i] + ']]></id>';
			if ( isNaN(lmsObjectivesBuffer.scoreRaw[i]))
				arquivoXMl += '<scoreRaw><![CDATA[Webaula-null]]></scoreRaw>';
			else
				arquivoXMl += '<scoreRaw><![CDATA[' + lmsObjectivesBuffer.scoreRaw[i] + ']]></scoreRaw>';
			if ( isNaN(lmsObjectivesBuffer.scoreMin[i]))
				arquivoXMl += '<scoreMin><![CDATA[Webaula-null]]></scoreMin>';
			else
				arquivoXMl += '<scoreMin><![CDATA[' + lmsObjectivesBuffer.scoreMin[i] + ']]></scoreMin>';
			if ( isNaN(lmsObjectivesBuffer.scoreMax[i]))
				arquivoXMl += '<scoreMax><![CDATA[Webaula-null]]></scoreMax>';
			else
				arquivoXMl += '<scoreMax><![CDATA[' + lmsObjectivesBuffer.scoreMax[i] + ']]></scoreMax>';
			if ( !lmsObjectivesBuffer.status[i] || objFrameWork.pIsEmpty(lmsObjectivesBuffer.status[i]) )
				arquivoXMl += '<status><![CDATA[Webaula-null]]></status>';
			else
				arquivoXMl += '<status><![CDATA[' + lmsObjectivesBuffer.status[i] + ']]></status>';
			arquivoXMl += '</objective>';
		}
	}
	arquivoXMl += '</objectives>';
	arquivoXMl += '<interactions>';
	if (lmsInteractionsBuffer.dirty)
	{
		for ( i = 0 ; i < lmsInteractionsBuffer.id.length ; i++ )
		{
			arquivoXMl += '<interaction>';
			if ( !lmsInteractionsBuffer.id[i] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.id[i]) )
				arquivoXMl += '<id><![CDATA[Webaula-null]]></id>';
			else
				arquivoXMl += '<id><![CDATA[' + lmsInteractionsBuffer.id[i] + ']]></id>';
			if ( !lmsInteractionsBuffer.time[i] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.time[i]) )
				arquivoXMl += '<time><![CDATA[Webaula-null]]></time>';
			else
				arquivoXMl += '<time><![CDATA[' + lmsInteractionsBuffer.time[i] + ']]></time>';
			if ( !lmsInteractionsBuffer.type[i] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.type[i]) )
				arquivoXMl += '<type><![CDATA[Webaula-null]]></type>';
			else
				arquivoXMl += '<type><![CDATA[' + lmsInteractionsBuffer.type[i] + ']]></type>';
			if ( !lmsInteractionsBuffer.weighting[i] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.weighting[i]) )
				arquivoXMl += '<weighting><![CDATA[Webaula-null]]></weighting>';
			else
				arquivoXMl += '<weighting><![CDATA[' + lmsInteractionsBuffer.weighting[i] + ']]></weighting>';
			if ( !lmsInteractionsBuffer.student_response[i] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.student_response[i]) )
				arquivoXMl += '<student_response><![CDATA[Webaula-null]]></student_response>';
			else
				arquivoXMl += '<student_response><![CDATA[' + lmsInteractionsBuffer.student_response[i] + ']]></student_response>';
			if ( !lmsInteractionsBuffer.result[i] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.result[i]) )
				arquivoXMl += '<result><![CDATA[Webaula-null]]></result>';
			else
				arquivoXMl += '<result><![CDATA[' + lmsInteractionsBuffer.result[i] + ']]></result>';
			if ( !lmsInteractionsBuffer.latency[i] || typeof(resultlmsInteractionsBuffer) == cstUndefined || objFrameWork.pIsEmpty(resultlmsInteractionsBuffer.latency[i]) )
				arquivoXMl += '<latency><![CDATA[Webaula-null]]></latency>';
			else
				arquivoXMl += '<latency><![CDATA[' + lmsInteractionsBuffer.latency[i] + ']]></latency>';
			
			arquivoXMl += '<objectives>';
			for ( j = 0 ; j < lmsInteractionsBuffer.objectivesId[i].length ; j++ )
			{
				if ( !lmsInteractionsBuffer.objectivesId[i][j] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.objectivesId[i][j]) )
					arquivoXMl += '<id><![CDATA[Webaula-null]]></id>';
				else
					arquivoXMl += '<id><![CDATA[' + lmsInteractionsBuffer.objectivesId[i][j] + ']]></id>';
			}
			arquivoXMl += '</objectives>';
			arquivoXMl += '<correct_responses>';
			for ( j = 0 ; j < lmsInteractionsBuffer.correct_responsesPattern[i].length ; j++ )
			{
				if ( !lmsInteractionsBuffer.correct_responsesPattern[i][j] || objFrameWork.pIsEmpty(lmsInteractionsBuffer.correct_responsesPattern[i][j]) )
					arquivoXMl += '<pattern><![CDATA[Webaula-null]]></pattern>';
				else
					arquivoXMl += '<pattern><![CDATA[' + lmsInteractionsBuffer.correct_responsesPattern[i][j] + ']]></pattern>';
			}
			arquivoXMl += '</correct_responses>';
			arquivoXMl += '</interaction>';
		}
	}
	arquivoXMl += '</interactions>';
	arquivoXMl += '</dadosCMI>';
	with (objAPIDadosSala){
		if ( !objFrameWork.pIsEmpty(xmlAvaliacao))
		{
			arquivoXMl += xmlAvaliacao;
			xmlAvaliacao = '';
			blnAssincrono = false;
		}
		arquivoXMl
+= '</dadosSala>';
		//Codificando o XML antes da postagem
		try {
			// Registra no log a passagem por essa função
			GerarLogAvaliacao(0, codTurma, codTopico, "PASSO1", arquivoXMl);
		} catch (e) { }
	 
		try {
		 gravarDadosBuffer(arquivoXMl);
 	 
		}catch (e) { alert(e);}
	 
		 finally {
			// Registra no log a passagem por essa função
			GerarLogAvaliacao(0, codTurma, 0, "PASSO2", arquivoXMl);
		}
	}
 return true;
}
function HandlePostagemTopico(lngCodAluno, lngCodTurma) {
 try {
 //Caso exista a função que atualiza os dados na home do aluno, o passo2 será armazenado lá
 top.opener.AtualizarInformacoesCursosHome(lngCodAluno, lngCodTurma);
 } catch (e) { }
}
/*****************************************************************************
**
** Metodo: LMSGetLastError()
** Entrada: nenhuma
** Saida: String - Codigo do erro setado pela ultima funcao utilizada na API
**
** Descricao:
** 	Busca o codigo do erro setado pela funcao da API mais recentemente 
**	executada (Obs.: Cada funcao da API seta ou limpa os codigos de erros.)
**
*****************************************************************************/
function LMSGetLastError()
{
	if ( _Debug )
	{
		escreveDebug("Na API: LMSGetLastError()<br> Retornando " + lmsError.errorCode);
	}
	return lmsError.errorCode;
}
/*****************************************************************************
**
** Metodo: LMSGetErrorString(errorCode)
** Entrada: errorCode - codigo de erro para buscar descricao
** Saida: String - texto associado ao codigo de erro
**
** Descricao:
** 	Esta funcao retorna o texto associado a um codigo de erro
**
*****************************************************************************/
function LMSGetErrorString(errorCode)
{
	if ( _Debug )
	{
		escreveDebug("Na API: LMSGetErrorString()");
	}
	var i;
	for (i = 0; i < vetErrors.length; i++)
	{
		if (vetErrors[i][0] == errorCode)
			return vetErrors[i][1];
	}
	return "";
}
/*****************************************************************************
**
** Metodo: LMSGetDiagnostic( String errorCode)
** Entrada: errorCode - codigo de erro para buscar diagnostico
** Saida: String - diagnostico especifico do WebAula para o codigo do erro
**
** Descricao:
** 	Esta funcao retorna o texto de diagnostico especifico do WebAula
** para o codigo do erro
**
*****************************************************************************/
function LMSGetDiagnostic(errorCode)
{
	var objFrameWork = new LEBJSFrameWork();
	
	if ( _Debug )
	{
		escreveDebug("Na API: LMSGetDiagnostic()");
	}
	if (objFrameWork.pIsEmpty(errorCode))
	{
		var num = LMSGetLastError();
		for (i = 0; i < vetErrors.length; i++)
		{
			if (vetErrors[i][0] == num)
				return vetErrors[i][2];
		}
	}
	else
	{
		var i;
		for (i = 0; i < vetErrors.length; i++)
		{
			if (vetErrors[i][0] == errorCode)
				return vetErrors[i][2];
		}
	}
	return "";
}
/*****************************************************************************
**
** Metodo: buscaFilhos(element)
** Entrada: element - String contendo o 'element' do CMI Data Model
** Saida: String contendo os filhos do 'element' do CMI Data Model
**
** Descricao:
** 	Esta funcao retorna uma string contendo todos os filhos
** do 'element' que so suportados pelo WebAula
**
*****************************************************************************/
function buscaFilhos(element)
{
	var result, pai, i, temp, paiSuportado, indexFilhos;
	paiSuportado = false;
	pai = element.substring(0, element.length - 10);
	result = "";
	indexFilhos = pai.split(".").length;
	for (i = 0; i < objDataModel.length; i++)
	{
		if (objDataModel[i].substring(0, pai.length) == pai)
			paiSuportado = true;
		if ((objDataModel[i].substring(0, pai.length) == pai) && (objDataModel[i].substring(pai.length+1, pai.length+2) != cstUnderScore))
		{
			if (objDataModel[i].split(".")[indexFilhos] == cstNao.toLowerCase())
				indexFilhos++;
			temp = pai + "." + objDataModel[i].split(".")[indexFilhos];
			//Checar se temp ja esta no result
			if (result.indexOf(objDataModel[i].split(".")[indexFilhos]) == -1)
				result += "," + objDataModel[i].split(".")[indexFilhos];
		}
	}
	result = result.substring(1, 2 + result.length - 1);
	if (!paiSuportado)
		result = "not implemented";
	return result;
}
/*****************************************************************************
**
** Metodo: existeElement( String element)
** Entrada: element - String contendo o 'element' do CMI Data Model
** Saida: String indicando "true" caso o 'element' exista, 
** "false" caso contrrio
**
** Descricao:
** 	Esta funcao diz se o element e suportado (retorna "true")
** pelo WebAula, ou nao (retorna "false")
**
*****************************************************************************/
function existeElement(element)
{
 var existe, i, procurar, vetProcurar, j;
 existe = "false";
	for (i = 0; i < objDataModel.length; i++)
	{
 if (objDataModel[i] == element)
	{
 existe = "true";
 break;
 }
 }
 return existe;
}
/*****************************************************************************
**
** Metodo: findFrameZero(win)
** Entrada: win - um objeto Window
** Saida: caso encontre o frame "zero", retorna TRUE,
** FALSE caso contrrio
**
** Descricao:
** 	Esta funcao encontra o frame "zero" para carregamento do formulario de
** dados do CMI
**
*****************************************************************************/
function findFrameZero(win){
	if ( (win.parent != win) && (win.parent != null) )
	{
		caminho = caminho + '.parent';
		var PaginaAtual=win.parent;
		for ( i = 0 ; i < PaginaAtual.frames.length ; i++ )
		{
			if ( PaginaAtual.frames(i).name == cstZeroExtenso)
			{
				caminho = caminho + '.frames(' + i + ').location.href';
				return true;
			}
		}
		return findFrameZero(PaginaAtual);
	}
	else if ( (win.opener != null) && (typeof(win.opener) != cstUndefined) )
	{
		caminho = caminho + '.opener';
		return findFrameZero(win.opener);
	}
	else
	{
		return false;
	}
}
/*****************************************************************************
**
** Metodo: avaliaPreRequisito(indiceTopico)
** Entrada: indiceTopico - o ndice no vetor de tpicos para o tpico a ser
** avaliado
** Saida: se o tpico no tiver pr-requisitos, ou os mesmos estiverem
** completos, retorna TRUE
** seno, retorna FALSE
**
** Descricao:
** 	este mtodo busca o pr-requisito do tpico atual e o avalia, verificando
** se todos esto completos ou no
**
*****************************************************************************/
function avaliaPreRequisito(indiceTopico){
	var objFrameWork = new LEBJSFrameWork();
	var caractere;					// Caractere atual da string de pr-requisito
	var identificador;				// Identificador de tpico
	var strPreRequisito;			// String de pr-requisito do tpico atual
	var strPreRequisitoAvaliar;		// String j modificada para ser avaliada
	var strIdentificadorAvaliado;	// String contendo o resultado da avaliao do identificador
	var indiceFor;					// Varivel de lao de iterao
	var _debugPre = false;			// Indica se iremos debugar o algoritmo ou no
	var strConclusaoAposAprovacao;
	var strPontuavel;
	// Buscando Pr-Requisito
	
	strPreRequisito = arrTopicos[indiceTopico].prerequisites;
	// Se no tem pr-requisitos ou o tpico escolhido o atual, finalizamos
	if ( _debugPre )
	{
		escreveDebug("Debugando Pr-Requisitos.<br>Pr-Requisito a ser avaliado: \""+strPreRequisito+"\".");
	}
	if (indiceTopico == topicoAtual || objFrameWork.pIsEmpty(strPreRequisito))
	{
		if ( _debugPre )
		{
			escreveDebug("Ou o tpico escolhido para navegar o mesmo que o atual ou o pr-requisito vazio. Retornando...");
		}
		return true;
	}
	else
	{	// Como tem pr-requisitos,
temos que avali-los
		identificador = '';
		strPreRequisitoAvaliar = '';
		for ( indiceFor = 0 ; indiceFor < strPreRequisito.length ; indiceFor++ )
		{
			// L prximo caractere
			caractere = strPreRequisito.substring(indiceFor,indiceFor+1);
			// Remove espaos em branco
			while ( caractere == cstEspaco )
			{
				++indiceFor;
				caractere = strPreRequisito.substring(indiceFor,indiceFor+1);
			}
			// Processa o caractere lido
			if ( eOperador(caractere) )
			{
				if ( _debugPre )
				{
					escreveDebug("operador encontrado: \""+caractere+"\"");
				}
				if ( caractere == cstMenorQue )
				{
					caractere = strPreRequisito.substring(indiceFor,indiceFor+1);
					// Remove espaos em branco
					while ( caractere == cstEspaco )
					{
						++indiceFor;
						caractere = strPreRequisito.substring(indiceFor,indiceFor+1);
					}
				}
				// Avalia o pr-requisito do identificador encontrado
				if ( !objFrameWork.pIsEmpty(identificador))
				{
					if ( _debugPre )
					{
						escreveDebug("Identificador atual: \""+identificador+"\"");
					}
					indiceIdentificador = buscaIndiceTopico(identificador);
					strConclusaoAposAprovacao = arrTopicos[indiceIdentificador].ConclusaoAposAprovacao;
					strPontuavel = arrTopicos[indiceIdentificador].pontuavel;
	 if ( indiceIdentificador == -1 )
					{
						if ( _debugPre )
						{
							escreveDebug('O cadastro do contedo possui um problema nos identificadores.');
						}
						return true;
					}
					if ( indiceIdentificador == topicoAtual )
					{
						if ( _debugPre )
						{
							escreveDebug("ndice encontrado do tpico atual. Buscando dados no buffer, " + 
								 "desde que ele tenha sido inicializado, seno utiliza o array de tpicos, mesmo.");
						}
						if ( lmsDataBuffer.isBufferInitialized)
						{
		 if (strPontuavel == cstSim){
		 if (strConclusaoAposAprovacao == cstSim){
			 strIdentificadorAvaliado = (lmsDataBuffer.coreLesson_status.info == cstPassed)?'true':'false';
			 }else{
			 strIdentificadorAvaliado = (lmsDataBuffer.coreLesson_status.info == cstFailed || lmsDataBuffer.coreLesson_status.info == cstPassed || lmsDataBuffer.coreLesson_status.info == cstCompleted)?'true':'false';
			 }
							}else{
			 strIdentificadorAvaliado = (lmsDataBuffer.coreLesson_status.info == cstPassed || lmsDataBuffer.coreLesson_status.info == cstCompleted || lmsDataBuffer.coreLesson_status.info == cstFailed)?'true':'false';
							}
						}
						else
						{
		 if (strPontuavel == cstSim){
		 if (strConclusaoAposAprovacao == cstSim){
			 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed)?'true':'false';
			 }else{
			 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstFailed || arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == cstCompleted)?'true':'false';
			 }
							}else{
			 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == cstCompleted || arrTopicos[indiceIdentificador].coreLesson_status == cstFailed)?'true':'false';
							}
						}
					}
					else
					{
						if ( _debugPre )
						{
							escreveDebug("Buscando dados do identificador no arranjo de tpicos.");
						}
						strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == 'completed')?'true':'false';
					}
				}
				else
				{
					strIdentificadorAvaliado = '';
				}
				// monta a string de avaliao final
				if ( _debugPre )
				{
					escreveDebug("Adicionando a avaliao do identificador encontrado string final de avaliao, bem como do operador encontrado.");
				}
				strPreRequisitoAvaliar += strIdentificadorAvaliado + ' ';
				if ( caractere == '>' )
				{
					strPreRequisitoAvaliar += '!=' + ' ';
				}
				else if ( caractere == '=' )
				{
					strPreRequisitoAvaliar += '==' + ' ';
				}
				else if ( caractere == '~' )
				{
					strPreRequisitoAvaliar += '!' + ' ';
				}
				else
				{
					strPreRequisitoAvaliar += caractere + ' ';
				}
				// Limpa o ltimo identificador encontrado
				identificador = '';
			}
			else
			{
				// Monta o identificador
				identificador += caractere;
			}
		}
		// Avalia o ltimo identificador e retorna o resultado do pr-requisito como um todo
		if ( !objFrameWork.pIsEmpty(identificador) )
		{
			if ( _debugPre )
			{
				escreveDebug("Adicionando o ltimo identificador encontrado string de avaliao: \""+identificador+"\".");
			}
			indiceIdentificador = buscaIndiceTopico(identificador);
			strConclusaoAposAprovacao = arrTopicos[indiceIdentificador].ConclusaoAposAprovacao;
			strPontuavel = arrTopicos[indiceIdentificador].pontuavel;
 if ( indiceIdentificador == -1 )
			{
				if ( _debugPre )
				{
					escreveDebug('O cadastro do contedo possui um problema nos identificadores.');
				}
				return true;
			}
			if ( indiceIdentificador == topicoAtual )
			{
				if ( _debugPre )
				{
					escreveDebug("ndice encontrado do tpico atual. Buscando dados no buffer, " + 
						 "desde que ele tenha sido inicializado, seno utiliza o array de tpicos, mesmo.");
				}
				if ( lmsDataBuffer.isBufferInitialized)
				{
				 if (strPontuavel == cstSim){
				 if (strConclusaoAposAprovacao == cstSim){
	 strIdentificadorAvaliado = (lmsDataBuffer.coreLesson_status.info == cstPassed)?'true':'false';
	 }else{
	 strIdentificadorAvaliado = (lmsDataBuffer.coreLesson_status.info == cstFailed || lmsDataBuffer.coreLesson_status.info == cstPassed || lmsDataBuffer.coreLesson_status.info == cstCompleted)?'true':'false';
	 }
					}else{
	 strIdentificadorAvaliado = (lmsDataBuffer.coreLesson_status.info == cstPassed || lmsDataBuffer.coreLesson_status.info == cstCompleted || lmsDataBuffer.coreLesson_status.info == cstFailed)?'true':'false';
					}
				}
				else
				{
				 if (strPontuavel == cstSim){
				 if (strConclusaoAposAprovacao == cstSim){
	 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed)?'true':'false';
	 }else{
	 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstFailed || arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == cstCompleted)?'true':'false';
	 }
					}else{
	 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == cstCompleted || arrTopicos[indiceIdentificador].coreLesson_status == cstFailed)?'true':'false';
					}
				}
			}
			else
			{
				if ( _debugPre )
				{
					escreveDebug("Buscando dados do identificador no arranjo de tpicos.");
				}
				if (strPontuavel == cstSim){
			 if (strConclusaoAposAprovacao == cstSim){
				 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed)?'true':'false';
				 }else{
				 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstFailed || arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == cstCompleted)?'true':'false';
				 }
				}else{
				 strIdentificadorAvaliado = (arrTopicos[indiceIdentificador].coreLesson_status == cstPassed || arrTopicos[indiceIdentificador].coreLesson_status == cstCompleted || arrTopicos[indiceIdentificador].coreLesson_status == cstFailed)?'true':'false';
				}
			}
		}
		else
		{
			strIdentificadorAvaliado = '';
		}
		strPreRequisitoAvaliar += strIdentificadorAvaliado + ' ';
		if ( _debugPre )
		{
			escreveDebug("String de avaliao gerada!<br><br>Pr-requisito inicial: \""+strPreRequisito+"\".<br>String

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais