eLearning WORKSHOPS

eLearning WORKSHOPS  
Usuario
Contraseña
Nueva cuenta :: Enviar contraseña
Soporte :: FAQ :: Búsqueda :: Hágase Miembro :: Recomendarnos :: Acerca de :: Contactar :: Academia de eLearning
:: Menú
:: Inicio
:: Recomendar este sitio
:: Búsqueda
:: Archivo de Noticias
:: Lo más popular
:: Tématicas
:: Acerca de este sitio

:: Recursos eLearning
:: Noticias
:: Artículos
:: Archivo de noticias
:: Encuestas
:: Calendario de Eventos
:: Docs y descargas
:: Directorio de Enlaces
:: Lista Software Libre
:: Glosario de Terminos
:: Conversando con...
:: Bolsa de Trabajo
:: Foro puntoSCORM
:: Foros eLearning
:: Academia de eLearning

:: Comunidad
Hola, Anónimo
Usuario
Contraseña
(Regístrese)

Miembros: 13695
Último: dal3-g
Nuevos hoy: 2
Nuevos ayer: 0

Usuarios online: 42
Visitantes: 42
Miembros: 0

:: Eventos eLearning
Calendario
Julio 2010
  1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
<b>Enviar Evento</b> Enviar Evento

América Latina
América del Norte
España
Europa
Online
Resto del Mundo
eLearning WORKSHOPS

:: Búsqueda

Búsqueda avanzada

:: Encuesta
¿Superaran funcionalmente los mejores LMS / Plataformas Open Source a su equivalente Propietario?
Nunca
Ya son superiores
En 6 meses
En 1 año
En 2 o más años


Resultados :: Encuestas

votos: 579 :: Comentarios: 0

Comunidad eLearning WORKSHOPS :: Comunidad de eLearning: Forums

Comunidad eLearning WORKSHOPS :: Ver tema - Un ejemplo del API SCORM en JAVA, Copiar y Pegar:-)
 FAQFAQ   BuscarBuscar   GruposGrupos   PerfilPerfil   MensajesMensajes   ConectarConectar 

Un ejemplo del API SCORM en JAVA, Copiar y Pegar:-)
Ir a página 1, 2  Siguiente
 
Publicar nuevo tema   Responder al tema    Foros de discusión -> Desarrollo LMS
Ver tema anterior :: Ver tema siguiente  
Autor Mensaje
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Vie Oct 17, 2003 7:50 pm    Asunto: Un ejemplo del API SCORM en JAVA, Copiar y Pegar:-) Responder citando

Hola a todos para otro ejemplo de API pero realizado en JAVA, solo faltaria desarrollar la parte del servidor:-)
Un Saludo
Jorge Dieguez


Cita:

import java.applet.Applet;
import java.net.*;
import java.io.*;
import java.awt.*;


public class API extends Applet
{
String m_strElement; // stores text of the SCORM
element to be set or got from the LMS
String m_strValue; // stores text values sent to
or returned by LMS
URL m_urlLMS = null; // the URL of the LMS to be
connected to
URLConnection m_urlConn; // the connection to the LMS
URL used for sending and receiving data
String m_strLastErrorNum = "0"; // stores the last error
number, as a string, set by an API call
int iInit = 0;
String sTemp;
String strURL;
public void init()
{
// Get the applet parameter, this is URL of track page
strURL = getParameter( "LMSURL" );

// create a URL from the parameter string read in
try
{
m_urlLMS = new URL(strURL);
//LMS URL created : m_urlLMS
}
catch( MalformedURLException e1 )
{
//Problem creating LMS URL
}
}


public String LMSInitialize( String strParameter )
{
String strReturn = "false";

if( connectToLMS() )
{
System.out.println(" after calling connectToLMS");
if(strParameter != null && !strParameter.trim().equals("")
&& strParameter.length() != 0)
{
m_strLastErrorNum = "201";
System.out.println(" after calling connectToLMS in
error");
}
else
{
// next call added so that the LMS itself gets
notification
if(sendData("lmsinitialize" ," ","") )
{
System.out.println( "***********calling getdata");
strReturn = getData();
if( strReturn.equalsIgnoreCase("false") || iInit ==
1 )
{
m_strLastErrorNum = "101"; //error
strReturn = "false";
}
else
{
m_strLastErrorNum = "0"; // no error
}
}
iInit = 1;
}
}
return strReturn;
}

public String LMSGetValue( String element )
{
String strBuffer = "false";

if( connectToLMS()== false )
{
return "false";
}

if( sendData( "lmsget", element.toLowerCase(), "" ) == false)
{
strBuffer = "false";
m_strLastErrorNum = "101"; //general exception
}
else
{
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "101"; //general exception
// Set return value to empty string so that SCO can
see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
else if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSGetValue: An error was
returned by the LMS.");
//Set return value to empty string so that SCO can see
there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
// Don't get error here - use LMSGetLastError
}
if( strBuffer.equalsIgnoreCase("NOT FOUND") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "301"; //general exception
// Set return value to empty string so that SCO can
see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
if( strBuffer.equalsIgnoreCase("WRITEONLY") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "404"; //general exception
// Set return value to empty string so that SCO can
see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
if( strBuffer.equalsIgnoreCase("NOT IMPLEMENTED") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "401"; //general exception
// Set return value to empty string so that SCO can
see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
else
{
if( strBuffer.equalsIgnoreCase("false"))
{
m_strLastErrorNum = "201"; // no error
}
else
{
m_strLastErrorNum = "0"; // no error
}
}
}
strBuffer = strBuffer.trim();
return strBuffer;
}

public String LMSSetValue( String element, String value )
{
String strBuffer = "false";

if( connectToLMS() == false )
{
return "false";
}
// according to the SCORM documentation, the element parmeter
(core.student.name etc.) must be in lower case
System.out.println( "calling LMSSetValue with value = " +
value + " element" + element);
if( sendData( "lmsset", element.toLowerCase(), value ) ==
false )
{
System.out.println( "Error in LMSSetValue while sending
data" );
// set the error number
//m_strLastErrorNum = "101"; //general exception
}
else
{
strBuffer = getData();
//System.out.println( "Error in LMSSetValue strBuffer = "
+ strBuffer );
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSSetValue: An error was
returned by the LMS.");
// Don't get error here - use LMSGetLastError
}
else if( strBuffer.equalsIgnoreCase("NOT IMPLEMENTED") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSSetValue: An error was
returned by the LMS.");
// Don't get error here - use LMSGetLastError
m_strLastErrorNum = "401";
}
else if( strBuffer.equalsIgnoreCase("READONLY") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSSetValue: An error was
returned by the LMS.");
// Don't get error here - use LMSGetLastError
m_strLastErrorNum = "403";
}
else
{
//the command was successful
if(strBuffer.equalsIgnoreCase("false"))
{
m_strLastErrorNum = "201";
}
else
{
m_strLastErrorNum = "0"; // no error
}
}
} return strBuffer;
}

public String LMSCommit( String strParameter )
{
// note that strParameter should be empty "" to conform to
SCORM 1.2 spec.
String strReturn;
strReturn = "false";
String strBuffer;
strBuffer = "false";

if( connectToLMS() )
{
//System.out.println( "after connectToLMS");
if(strParameter != null &&
!strParameter.trim().equals("") && strParameter.length() != 0)
{
//System.out.println( "in if wrong " + strParameter);
m_strLastErrorNum = "201";
}
else
{
//System.out.println( "in else correct " +
strParameter);
//strReturn = "true";
strParameter = " ";
//System.out.println(strParameter);
// next call added so that the LMS itself gets
notification
if(sendData("lmscommit" ," ","") )
{
//System.out.println("after sendData");
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the
LMS
m_strLastErrorNum = "101"; //general
exception
}
else if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
// Don't get error here - use LMSGetLastError
}
else
{
//the command was successful
strReturn = strBuffer;
}
}
}
}
//System.out.println( "End of LMS Commit" + strReturn );
return strReturn;
}

public String LMSFinish( String strParameter )
{
// note that strParameter should be empty "" to conform to SCORM 1.2
spec.
String strReturn = "false";
String strBuffer = "false";
strParameter = " ";
if( connectToLMS() )
{
if(strParameter != null &&
!strParameter.trim().equals(""))
{
//System.out.println( "in if wrong " + strParameter);
m_strLastErrorNum = "201";
}
else{
//strReturn = "true";
// next call added so that the LMS itself gets
notification
//if( sendData( "lmsfinish" , strParameter, "") )
if(sendData("lmsfinish" ," ","") )
{
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
// Don't get error here - use LMSGetLastError
}
else
{
//the command was successful
strReturn = strBuffer;
}
}
}
}
// }
return strReturn;
}

public String LMSGetLastError()
{
System.out.println( "LMSGetLastError called in API." +
m_strLastErrorNum);
String strLastErrorNum = "0";

if(m_strLastErrorNum.equals("0"))
{
strLastErrorNum = getLastError();
}
else
{
strLastErrorNum = m_strLastErrorNum;
}
m_strLastErrorNum = "0";
return strLastErrorNum;
}

public String LMSGetErrorString( String errorCode )
{
String strReturn = "";
Integer nError;
if(errorCode == "")
{
nError = new Integer(101);
}
else
{
nError = new Integer(errorCode);
}

switch( nError.intValue() )
{
case 0:
strReturn = "No error";
break;

case 101:
strReturn = "General Exception";
break;

case 201:
strReturn = "Invalid argument error";
break;

case 202:
strReturn = "Element cannot have children";
break;

case 203:
strReturn = "Element not an array - Cannot have
count";
break;

case 301:
strReturn = "Not initialized";
break;

case 401:
strReturn = "Not implemented error";
break;

case 402:
strReturn = "Invalid set value, element is a keyword";
break;

case 403:
strReturn = "Element is read only";
break;

case 404:
strReturn = "Element is write only";
break;

case 405:
strReturn = "Incorrect Data Type";
break;

default:
strReturn = "Unrecognised error value";
break;
}
return strReturn;
}

public String LMSGetDiagnostic(String strParam)
{
//System.out.println( "LMSGetDiagnostic called in API : " + strParam
);
String strBuffer = "";
String strSend = "";

if( connectToLMS()== false )
{
return "ERROR";
}
if( strParam.equalsIgnoreCase("") )
{
// According to the SCROM spec.:
//An empty string. This requests additional information
on the last error that occurred.
strSend = m_strLastErrorNum;
}
else
{
// otherwise just send whatever was passed in via
strParam;
strSend = strParam;
}

if( sendData( "lmsgetdiagnostic", strSend, "" ) == false)
{
strBuffer = "ERROR";
m_strLastErrorNum = "101"; //general exception
}
else
{
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
// so ask it for an error number
// Don't get error here - use LMSGetLastError
}
else

{
m_strLastErrorNum = "0"; // no error
}

}
return strBuffer;
//return "No further diagnostic information is available";
}

boolean connectToLMS()
{
System.out.println("in connectToLMS");
boolean success = false;

if( m_urlLMS == null )
{
try{
m_urlLMS = new URL(strURL);
System.out.println("error in connectToLMS m_urlLMS is
null");
//return false;
}
catch(Exception e)
{
System.out.println("error in connectToLMS m_urlLMS is
null so exception" + e.getMessage());
return false;
}
}
try
{
//URL connection channel
m_urlConn = m_urlLMS.openConnection();

//Connection to LMS opened successfully
success = true;
}
catch(IOException e)
{
System.out.println("error in connectToLMS " +
e.getMessage());
success = false;
//Error while trying to open connection
}
System.out.println("success = " + success);
return success;
}


// send data using POST mechanism
// e.g. sendData( "LMSSET", "cmi.core.score", "99" )
// or sendData( "LMSGET", "cmi.core.name" , "")
boolean sendData( String strName, String strVal1, String strVal2 )
{
System.out.println( "in sendData for sending " + strName + " "
+ strVal1 + " " + strVal2);
// Send POST output.
String strBuffer = "";

if( m_urlConn == null )
{
System.out.println("connection is null in senddata");
try{
m_urlConn = m_urlLMS.openConnection();
}
catch(Exception e){
//No connection URL
System.out.println("in catch connection is null in
senddata");
return false;
}
}

try
{
m_urlConn.setDoOutput(true);
m_urlConn.setRequestProperty("Content-type",
"application/x-www-form-urlencoded");
m_urlConn.setRequestProperty("Content-length", "" + 400);
}
catch(Exception e)
{
//IOException while trying to get an output stream
return false;
}


if(strVal1 != null && strVal1.equalsIgnoreCase("cmi.core.exit"))
{
System.out.println( "in sendData inside core.exit" + strName
+ " strVal1 = " + strVal1 + " strVal2 =" + strVal2 + "end");
strVal2 = strVal2.toString();
if((strVal2 == null) || (strVal2 == "") ||
(strVal2.length()==0))
{
System.out.println( "in if correct" );
// setting LMS data
strBuffer = strName + "=" + URLEncoder.encode(strVal1 +
"|" + " ");
}
else if (strVal2.equals("time-out") ||
strVal2.equals("suspend") || strVal2.equals("logout"))
{
System.out.println( "in else wrong" );
strBuffer = strName + "=" + URLEncoder.encode(strVal1 +
"|" + strVal2);
System.out.println( "strBuffer = " + strBuffer );
}
else
{
m_strLastErrorNum = "405";
return false;
}
}

else if(strVal1 != null &&
strVal1.equalsIgnoreCase("cmi.suspend_data") &&
strName.equalsIgnoreCase("lmsset"))
{
System.out.println( "in sendData inside
cmi.core.suspend_data" + strName );
if(strVal2 != null && strVal2.length() > 400)
{
System.out.println( "in if" );
m_strLastErrorNum = "405";
return false;
}
else
{
// setting LMS data
strBuffer = strName + "=" + URLEncoder.encode(strVal1 +
"|" + strVal2);
System.out.println( "in else strBuffer = " + strBuffer
+ " strVal2 = " + strVal2);
m_strLastErrorNum = "0";
//return true;
}
}
else if( strVal2 != "")
{
// System.out.println( "in sendData strval2 is not null " +
strName );
if( strVal1.equalsIgnoreCase("cmi.core.lesson_status"))
{
if(strVal2.equals("passed") ||
strVal2.equals("completed") || strVal2.equals("failed") ||
strVal2.equals("incomplete") || strVal2.equals("browsed"))
{
m_strLastErrorNum = "0";
}
else
{
m_strLastErrorNum = "405";
return false;
}
}
System.out.println( "strval " + strName );
if( strVal1.equalsIgnoreCase("cmi.suspend_data"))
{
if(strVal2.length() < 4097)
{
m_strLastErrorNum = "0";
}
else
{
m_strLastErrorNum = "405";
return false;
}
}
else if( strVal1.equalsIgnoreCase("cmi.core.score.raw"))
{
// System.out.println( "in sendData inside cmi.core.score.raw"
+ strName );
int iIndex = -1;
m_strLastErrorNum = "0";

iIndex = strVal2.indexOf(".");

//check for hours.. max 4 digits allowed
if(iIndex == -1)
{
if(strVal2.length() > 3)
m_strLastErrorNum = "405";
}
else
{
if(strVal2.length() > 5)
m_strLastErrorNum = "405";
else if((strVal2.length() - iIndex) > 3)
m_strLastErrorNum = "405";
}

if(strVal2.indexOf("-") != -1 )
{
m_strLastErrorNum = "405";
}

if (m_strLastErrorNum.equals("405"))
return false;
}

else if( strVal1.equalsIgnoreCase("cmi.core.session_time"))
{
// System.out.println( "in sendData inside
cmi.core.session_time" + strName );
try
{
int ihIndex = -1;
m_strLastErrorNum = "0";

ihIndex = strVal2.indexOf(":");

//check for hours.. max 4 digits allowed
if((ihIndex == -1) || (ihIndex > 4) || (ihIndex < 2))
{
m_strLastErrorNum = "405";
}
else
{
//check for mins.. 2 digits allowed
int imIndex = strVal2.indexOf(":",ihIndex + 1);
if (imIndex == -1 || (imIndex - ihIndex) != 3)
m_strLastErrorNum = "405";
else
{
//check for seconds
int isIndex = strVal2.indexOf(".",imIndex + 1);


//if miliseconds not sent
if (isIndex == -1)
{
//check for lenght of seconds
if((strVal2.length() - imIndex) != 3)
m_strLastErrorNum = "405";
}
//milisecs sent...check for length
else
{
if ((isIndex - imIndex) != 3)
m_strLastErrorNum = "405";

if ((strVal2.length() - isIndex) > 3)
{
m_strLastErrorNum = "405";
}

}
}
}
}
catch(NumberFormatException nfe)
{
m_strLastErrorNum = "101";
return false;
}

if (m_strLastErrorNum.equals("405"))
return false;
}

// setting LMS data
strBuffer = strName + "=" + URLEncoder.encode(strVal1 +
"|" + strVal2);
}

else
{
//getting LMS data
strBuffer = strName + "=" + URLEncoder.encode( strVal1 );
}

// strBuffer should now contain something like
LMSSET=cmi.core.score,99

try{
OutputStreamWriter wr = new
OutputStreamWriter(m_urlConn.getOutputStream());
wr.write(strBuffer);
wr.flush();
wr.close();
// System.out.println( "End of sendData ");
}
catch (Exception e)
{
return false;
} return true;
}

// get any data sent back from LMS
// if there is a problem the LMS should send back "lmserror"
String getData()
{
String strInputLine = "";
String strBuffer = "";
try
{
BufferedReader rd = new BufferedReader(new
InputStreamReader(m_urlConn.getInputStream()));
String line="",ln;
while ((strBuffer = rd.readLine()) != null) {
System.out.println("\n\n"+strBuffer);
strInputLine = strInputLine + strBuffer;
// Process line...
}
rd.close();
m_strLastErrorNum = "0";
}
catch(IOException ioe)
{
//IO error getting data from LMS
strInputLine = "general error in getData";
}
catch(Exception e)
{
//General error getting data from LMS
strInputLine = "general error in getdata 2nd time";
}
System.out.println( "***********end of getdata" +
strInputLine);
return strInputLine;
}

// get an error code from the LMS
String getLastError()
{
//System.out.println( "in getLastError");
String strBuffer = "101"; //default to "general exception"
code
if( !connectToLMS() )
{
return "101";
}
//System.out.println( "calling sendData from getLastError");
if( !sendData( "lmsgetlasterror", " ", "") )
{
//Error in getError while sending error request
return "101";
}
else
{
strBuffer = getData();
//API getError got the following return data from the LMS
}
//System.out.println( "end if getLastError" + strBuffer);
return strBuffer;
}
}
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Mie Mar 03, 2004 10:56 am    Asunto: Responder citando

Buenas,

he estado trabajando con la API realizada en java durante bastante tiempo, pero ahora, al ir a probar desde una maquina remota y correr un curso que ataca al LMS de mi pc... curiosamente no funciona, debe ser como si no consiguiese conectar ni nada.

a alguien le ha pasado lo mismo o se le ocurre por donde podrian ir los tiros?.

Tengo habilitado el metodo get en mi servlet y metiendo la url en el navegador remoto la cosa funciona y me muestra la pagina pero al acceder a el con la API no se que problema debe de tener...


Venga, saludos.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Mie Mar 03, 2004 11:05 am    Asunto: Responder citando

Lo que te pasara es que tu Applet esta en un dominio diferente al de servlet, ¿es posible?
Hay una serie de restricciones de seguridad que hay que tener en cuenta cuando se trabaja leyendo datos remotos.
Un Saludo
Jorge Dieguez
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Jue Mar 25, 2004 11:17 am    Asunto: Y seguimos con el API. Responder citando

Hola Jorge,

sigo por aqui peleandome con todo este jaleo intentando sacar algo en claro. Me ha surjido una duda que no se si esta implementada de forma correcta o no...

El problema es el siguiente, segun el codigo de la API cuando recibe un inicialize comprueba que sea factible en cuyo caso lo acepta y modifica el valor de la variable Init poniendolo a 1 y esto hace que si en ese momento otro alumno iniciase un curso en su pc... curiosamente esa variable Init esta como compartida por ambos y clarocomo ya esta a uno me lanza el mensaje de Conexion Ya Inicializada.

Esto deberia de ser asi?, estoy haciendome un lio?, quizas esa variable compartida de la que hablo no este en el api sino en el LMS?... aun asi creo haber probado a guardar la variable en la sesion del LMS y me seguia reportando el mismo error de ahi que piense que el problema viene de la API...

Bueno, pues eso es todo. Si no me he explicado bien dimelo y me extiendo un poco mas poniendo un ejemplo.

Saludos icon_smile.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Invitado






MensajePublicado: Jue Mar 25, 2004 11:33 am    Asunto: Responder citando

Hola
No entiendo muy bien como pueden dos alumnos conectarse a la ves en el mismo cliente, a que te refieres?
Un Saludo
Volver arriba
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Jue Mar 25, 2004 3:11 pm    Asunto: Responder citando

Pues eso es lo mismo que pensaba yo que como demonios me podian compartir variable estadno en distinto cliente, pero parece que ya tira, quizas pudo ser que inicialice el valor en la sesion pero a la hora de trabajar con el en vez de manipular el almacenado en la sesion lo que hacia era manipular el local y por eso me estaba dando problemas, pero no en la API, sino en el servlet.

Venga, pues gracias y hasta pronto icon_smile.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Invitado





MensajePublicado: Mar May 18, 2004 4:04 pm    Asunto: problemas con el API Responder citando

icon_sad.gif Hola a todos los desarrolladores de elearning, mi duda es la siguiente:

Como hago funcionar el api ya que no se que se debe setear para lanzarlo se lanzarlo pero no se que parametros hay que setear, si alguien me puede orientar se lo agradecería, desde ya muchas gracias


Saludos janover icon_arrow.gif icon_wink.gif
Volver arriba
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Mar May 18, 2004 4:22 pm    Asunto: Responder citando

Hoal, si me dices exactamente tus dudas intento ayudarte!!!!


Un Saludo
_________________
Jorge Dieguez // Moderador PuntoScorm
mi.blog - http://jdieguez.wordpress.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
Janover
Invitado





MensajePublicado: Mar May 18, 2004 4:27 pm    Asunto: problema API java Responder citando

cuando intento correo el API en un cliente me sale es to java.lang.NoClassDefFoundError: API (wrong name: api/API)

Si alguien sabe ayudeme please!!1 icon_wink.gif icon_confused.gif
Volver arriba
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Mar May 18, 2004 4:42 pm    Asunto: Responder citando

Por lo que veo ( así sin ver el código fuente), has nombrado el .java con un nombre distinto que la clase que hereda del applet, atento al las mayúsculas:-)
Suerte!!!!


Un Saludo
_________________
Jorge Dieguez // Moderador PuntoScorm
mi.blog - http://jdieguez.wordpress.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
janover
Invitado





MensajePublicado: Mar May 18, 2004 4:42 pm    Asunto: Responder citando

Por fin pude lanzar al APi hehco en java ahora verificare si existe la comunicacion con mi primer SCO ojala que resulte!!! icon_rolleyes.gif
Volver arriba
janover
Invitado





MensajePublicado: Mar May 18, 2004 5:14 pm    Asunto: Api LMS Responder citando

graciaspor las respuestas era que no le habia dado bien el CODEBASE pero ya esta ok!!!!

icon_redface.gif bueno jorge


gracias por la ayuda de todos modos!!1
Volver arriba
janover
Invitado





MensajePublicado: Mar May 18, 2004 5:30 pm    Asunto: Api LMS Responder citando

Jorge hago mi primir SCO pero no puedo comunicarme con el api me dice que no esta no lo encuentra. Eso me quiere decir que no esta bien lanzado me podrias decir si tengo que enviar algun parametro al APi o algo al lanzarlo que no se bueno ahi te envio el codigo

ejemplo :


import java.applet.Applet;
import java.net.*;
import java.io.*;
import java.awt.*;
import java.lang.*;


public class API extends Applet
{
String m_strElement; // stores text of the SCORM element to be set or got from the LMS
String m_strValue; // stores text values sent to or returned by LMS
URL m_urlLMS = null; // the URL of the LMS to be connected to
URLConnection m_urlConn; // the connection to the LMS URL used for sending and receiving data
String m_strLastErrorNum = "0"; // stores the last error number, as a string, set by an API call
int iInit = 0;
String sTemp;
String strURL;

public void init()
{
// Get the applet parameter, this is URL of track page
strURL = getParameter( "LMSURL" );

// create a URL from the parameter string read in
try
{
m_urlLMS = new URL(strURL);
//LMS URL created : m_urlLMS
}
catch( MalformedURLException e1 )
{
//Problem creating LMS URL
}
}


public String LMSInitialize( String strParameter )
{
String strReturn = "false";

if( connectToLMS() )
{
System.out.println(" after calling connectToLMS");
if(strParameter != null && !strParameter.trim().equals("")
&& strParameter.length() != 0)
{
m_strLastErrorNum = "201";
System.out.println(" after calling connectToLMS in error");
}
else
{
// next call added so that the LMS itself gets notification
if(sendData("lmsinitialize" ," ","") )
{
System.out.println( "***********calling getdata");
strReturn = getData();
if( strReturn.equalsIgnoreCase("false") || iInit == 1 )
{
m_strLastErrorNum = "101"; //error
strReturn = "false";
}
else
{
m_strLastErrorNum = "0"; // no error
}
}

iInit = 1;
}

}
return strReturn;
}


public String LMSGetValue( String element )
{
String strBuffer = "false";

if( connectToLMS()== false )
{
return "false";
}

if( sendData( "lmsget", element.toLowerCase(), "" ) == false)
{
strBuffer = "false";
m_strLastErrorNum = "101"; //general exception
}
else
{
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "101"; //general exception
// Set return value to empty string so that SCO can see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
else
if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSGetValue: An error was returned by the LMS.");
//Set return value to empty string so that SCO can see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
// Don't get error here - use LMSGetLastError
}
if( strBuffer.equalsIgnoreCase("NOT FOUND") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "301"; //general exception
// Set return value to empty string so that SCO can see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
if( strBuffer.equalsIgnoreCase("WRITEONLY") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "404"; //general exception
// Set return value to empty string so that SCO can see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
if( strBuffer.equalsIgnoreCase("NOT IMPLEMENTED") )
{
// there was a problem communicating with the LMS
m_strLastErrorNum = "401"; //general exception
// Set return value to empty string so that SCO can see there's a problem
// this is as specififed in SCORM 1.2 specification
strBuffer = "";
}
else
{
if( strBuffer.equalsIgnoreCase("false"))
{
m_strLastErrorNum = "201"; // no error
}
else
{
m_strLastErrorNum = "0"; // no error
}
}
}
strBuffer = strBuffer.trim();
return strBuffer;

}

public String LMSSetValue( String element, String value )
{
String strBuffer = "false";

if( connectToLMS() == false )
{
return "false";
}
// according to the SCORM documentation, the element parmeter (core.student.name etc.) must be in lower case
System.out.println( "calling LMSSetValue with value = " +
value + " element" + element);
if( sendData( "lmsset", element.toLowerCase(), value ) == false )
{
System.out.println( "Error in LMSSetValue while sending data" );
// set the error number
//m_strLastErrorNum = "101"; //general exception
}
else
{
strBuffer = getData();
//System.out.println( "Error in LMSSetValue strBuffer = "+ strBuffer );
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else
if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSSetValue: An error was returned by the LMS.");
// Don't get error here - use LMSGetLastError
}
else
if( strBuffer.equalsIgnoreCase("NOT IMPLEMENTED") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSSetValue: An error was returned by the LMS.");
// Don't get error here - use LMSGetLastError
m_strLastErrorNum = "401";
}
else
if( strBuffer.equalsIgnoreCase("READONLY") )
{
// there was a problem flagged by the LMS
System.out.println( "LMSSetValue: An error was returned by the LMS.");
// Don't get error here - use LMSGetLastError
m_strLastErrorNum = "403";
}
else
{
//the command was successful
if(strBuffer.equalsIgnoreCase("false"))
{
m_strLastErrorNum = "201";
}
else
{
m_strLastErrorNum = "0"; // no error
}
}
}
return strBuffer;
}

public String LMSCommit( String strParameter )
{
// note that strParameter should be empty "" to conform to SCORM 1.2 spec.
String strReturn;
strReturn = "false";
String strBuffer;
strBuffer = "false";

if( connectToLMS() )
{
//System.out.println( "after connectToLMS");
if(strParameter != null && !strParameter.trim().equals("") && strParameter.length() != 0)
{
//System.out.println( "in if wrong " + strParameter);
m_strLastErrorNum = "201";
}
else
{
//System.out.println( "in else correct " + strParameter);
//strReturn = "true";
strParameter = " ";
//System.out.println(strParameter);
// next call added so that the LMS itself gets notification
if(sendData("lmscommit" ," ","") )
{
//System.out.println("after sendData");
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else
if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
// Don't get error here - use LMSGetLastError
}
else
{
//the command was successful
strReturn = strBuffer;
}
}
}
}
//System.out.println( "End of LMS Commit" + strReturn );
return strReturn;
}

public String LMSFinish( String strParameter )
{
// note that strParameter should be empty "" to conform to SCORM 1.2 spec.
String strReturn = "false";
String strBuffer = "false";
strParameter = " ";
if( connectToLMS() )
{
if(strParameter != null && !strParameter.trim().equals(""))
{
//System.out.println( "in if wrong " + strParameter);
m_strLastErrorNum = "201";
}
else{
//strReturn = "true";
// next call added so that the LMS itself gets notification
//if( sendData( "lmsfinish" , strParameter, "") )
if(sendData("lmsfinish" ," ","") )
{
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else
if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
// Don't get error here - use LMSGetLastError
}
else
{
//the command was successful
strReturn = strBuffer;
}
}
}
}
// }
return strReturn;
}

public String LMSGetLastError()
{
System.out.println( "LMSGetLastError called in API." +
m_strLastErrorNum);
String strLastErrorNum = "0";

if(m_strLastErrorNum.equals("0"))
{
strLastErrorNum = getLastError();
}
else
{
strLastErrorNum = m_strLastErrorNum;
}
m_strLastErrorNum = "0";
return strLastErrorNum;
}

public String LMSGetErrorString( String errorCode )
{
String strReturn = "";
Integer nError;
if(errorCode == "")
{
nError = new Integer(101);
}
else
{
nError = new Integer(errorCode);
}

switch( nError.intValue() )
{
case 0:
strReturn = "No error";
break;

case 101:
strReturn = "General Exception";
break;

case 201:
strReturn = "Invalid argument error";
break;

case 202:
strReturn = "Element cannot have children";
break;

case 203:
strReturn = "Element not an array - Cannot have count";
break;

case 301:
strReturn = "Not initialized";
break;

case 401:
strReturn = "Not implemented error";
break;

case 402:
strReturn = "Invalid set value, element is a keyword";
break;

case 403:
strReturn = "Element is read only";
break;

case 404:
strReturn = "Element is write only";
break;

case 405:
strReturn = "Incorrect Data Type";
break;

default:
strReturn = "Unrecognised error value";
break;
}
return strReturn;
}

public String LMSGetDiagnostic(String strParam)
{
//System.out.println( "LMSGetDiagnostic called in API : " + strParam );
String strBuffer = "";
String strSend = "";

if( connectToLMS()== false )
{
return "ERROR";
}
if( strParam.equalsIgnoreCase("") )
{
// According to the SCROM spec.:
//An empty string. This requests additional information on the last error that occurred.
strSend = m_strLastErrorNum;
}
else
{
// otherwise just send whatever was passed in via strParam;
strSend = strParam;
}

if( sendData( "lmsgetdiagnostic", strSend, "" ) == false)
{
strBuffer = "ERROR";
m_strLastErrorNum = "101"; //general exception
}
else
{
strBuffer = getData();
if( strBuffer.equalsIgnoreCase("general error") )
{
// there was a problem comminicating with the LMS
m_strLastErrorNum = "101"; //general exception
}
else
if( strBuffer.equalsIgnoreCase("lmserror") )
{
// there was a problem flagged by the LMS
// so ask it for an error number
// Don't get error here - use LMSGetLastError
}
else
{
m_strLastErrorNum = "0"; // no error
}

}
return strBuffer;
//return "No further diagnostic information is available";
}

boolean connectToLMS()
{
System.out.println("in connectToLMS");
boolean success = false;

if( m_urlLMS == null )
{
try
{
m_urlLMS = new URL(strURL);
System.out.println("error in connectToLMS m_urlLMS is null");
//return false;
}
catch(Exception e)
{
System.out.println("error in connectToLMS m_urlLMS is null so exception" + e.getMessage());
return false;
}
}
try
{
//URL connection channel
m_urlConn = m_urlLMS.openConnection();

//Connection to LMS opened successfully
success = true;
}
catch(IOException e)
{
System.out.println("error in connectToLMS " + e.getMessage());
success = false;
//Error while trying to open connection
}
System.out.println("success = " + success);
return success;
}


// send data using POST mechanism
// e.g. sendData( "LMSSET", "cmi.core.score", "99" )
// or sendData( "LMSGET", "cmi.core.name" , "")

boolean sendData( String strName, String strVal1, String strVal2 )
{
System.out.println( "in sendData for sending " + strName + " " + strVal1 + " " + strVal2);
// Send POST output.
String strBuffer = "";

if( m_urlConn == null )
{
System.out.println("connection is null in senddata");
try
{
m_urlConn = m_urlLMS.openConnection();
}
catch(Exception e){
//No connection URL
System.out.println("in catch connection is null in senddata");
return false;
}
}

try
{
m_urlConn.setDoOutput(true);
m_urlConn.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
m_urlConn.setRequestProperty("Content-length", "" + 400);
}
catch(Exception e)
{
//IOException while trying to get an output stream
return false;
}


if(strVal1 != null && strVal1.equalsIgnoreCase("cmi.core.exit"))
{
System.out.println( "in sendData inside core.exit" + strName + " strVal1 = " + strVal1 + " strVal2 =" + strVal2 + "end");
strVal2 = strVal2.toString();
if((strVal2 == null) || (strVal2 == "") || (strVal2.length()==0))
{
System.out.println( "in if correct" );
// setting LMS data
strBuffer = strName + "=" + URLEncoder.encode(strVal1 + "|" + " ");
}
else
if (strVal2.equals("time-out") || strVal2.equals("suspend") || strVal2.equals("logout"))
{
System.out.println( "in else wrong" );
strBuffer = strName + "=" + URLEncoder.encode(strVal1 + "|" + strVal2);
System.out.println( "strBuffer = " + strBuffer );
}
else
{
m_strLastErrorNum = "405";
return false;
}
}
else
if(strVal1 != null && strVal1.equalsIgnoreCase("cmi.suspend_data") && strName.equalsIgnoreCase("lmsset"))
{
System.out.println( "in sendData inside cmi.core.suspend_data" + strName );
if(strVal2 != null && strVal2.length() > 400)
{
System.out.println( "in if" );
m_strLastErrorNum = "405";
return false;
}
else
{
// setting LMS data
strBuffer = strName + "=" + URLEncoder.encode(strVal1 + "|" + strVal2);
System.out.println( "in else strBuffer = " + strBuffer + " strVal2 = " + strVal2);
m_strLastErrorNum = "0";
//return true;
}
}
else
if( strVal2 != "")
{
// System.out.println( "in sendData strval2 is not null " + strName );
if( strVal1.equalsIgnoreCase("cmi.core.lesson_status"))
{
if(strVal2.equals("passed") || strVal2.equals("completed") || strVal2.equals("failed") || strVal2.equals("incomplete") || strVal2.equals("browsed"))
{
m_strLastErrorNum = "0";
}
else
{
m_strLastErrorNum = "405";
return false;
}
}
System.out.println( "strval " + strName );
if( strVal1.equalsIgnoreCase("cmi.suspend_data"))
{
if(strVal2.length() < 4097)
{
m_strLastErrorNum = "0";
}
else
{
m_strLastErrorNum = "405";
return false;
}
}
else
if( strVal1.equalsIgnoreCase("cmi.core.score.raw"))
{
// System.out.println( "in sendData inside cmi.core.score.raw" + strName );
int iIndex = -1;
m_strLastErrorNum = "0";

iIndex = strVal2.indexOf(".");

//check for hours.. max 4 digits allowed
if(iIndex == -1)
{
if(strVal2.length() > 3)
m_strLastErrorNum = "405";
}
else
{
if(strVal2.length() > 5)
m_strLastErrorNum = "405";
else
if((strVal2.length() - iIndex) > 3)
m_strLastErrorNum = "405";
}
if(strVal2.indexOf("-") != -1 )
{
m_strLastErrorNum = "405";
}

if (m_strLastErrorNum.equals("405"))
return false;
}

else
if( strVal1.equalsIgnoreCase("cmi.core.session_time"))
{
// System.out.println( "in sendData inside cmi.core.session_time" + strName );
try
{
int ihIndex = -1;
m_strLastErrorNum = "0";
ihIndex = strVal2.indexOf(":");
//check for hours.. max 4 digits allowed
if((ihIndex == -1) || (ihIndex > 4) || (ihIndex < 2))
{
m_strLastErrorNum = "405";
}
else
{
//check for mins.. 2 digits allowed
int imIndex = strVal2.indexOf(":",ihIndex + 1);
if (imIndex == -1 || (imIndex - ihIndex) != 3)
m_strLastErrorNum = "405";
else
{
//check for seconds
int isIndex = strVal2.indexOf(".",imIndex + 1);
//if miliseconds not sent
if (isIndex == -1)
{
//check for lenght of seconds
if((strVal2.length() - imIndex) != 3)
m_strLastErrorNum = "405";
}
//milisecs sent...check for length
else
{
if ((isIndex - imIndex) != 3)
m_strLastErrorNum = "405";

if ((strVal2.length() - isIndex) > 3)
{
m_strLastErrorNum = "405";
}

}
}
}
}
catch(NumberFormatException nfe)
{
m_strLastErrorNum = "101";
return false;
}

if (m_strLastErrorNum.equals("405"))
return false;
}

// setting LMS data
strBuffer = strName + "=" + URLEncoder.encode(strVal1 + "|" + strVal2);
}

else
{
//getting LMS data
strBuffer = strName + "=" + URLEncoder.encode( strVal1 );
}

// strBuffer should now contain something like LMSSET=cmi.core.score,99

try{
OutputStreamWriter wr = new
OutputStreamWriter(m_urlConn.getOutputStream());
wr.write(strBuffer);
wr.flush();
wr.close();
// System.out.println( "End of sendData ");
}
catch (Exception e)
{
return false;
}
return true;
}

// get any data sent back from LMS
// if there is a problem the LMS should send back "lmserror"
String getData()
{
String strInputLine = "";
String strBuffer = "";
try
{
BufferedReader rd = new BufferedReader(new
InputStreamReader(m_urlConn.getInputStream()));
String line="",ln;
while ((strBuffer = rd.readLine()) != null)
{
System.out.println("\n\n"+strBuffer);
strInputLine = strInputLine + strBuffer;
// Process line...
}
rd.close();
m_strLastErrorNum = "0";
}
catch(IOException ioe)
{
//IO error getting data from LMS
strInputLine = "general error in getData";
}
catch(Exception e)
{
//General error getting data from LMS
strInputLine = "general error in getdata 2nd time";
}
System.out.println( "***********end of getdata" + strInputLine);
return strInputLine;
}

// get an error code from the LMS
String getLastError()
{
//System.out.println( "in getLastError");
String strBuffer = "101"; //default to "general exception" code
if( !connectToLMS() )
{
return "101";
}
//System.out.println( "calling sendData from getLastError");
if( !sendData( "lmsgetlasterror", " ", "") )
{
//Error in getError while sending error request
return "101";
}
else
{
strBuffer = getData();
//API getError got the following return data from the LMS
}
//System.out.println( "end if getLastError" + strBuffer);
return strBuffer;
}
}
--------------------------

Codigo del APi y el HTML que lo despliega

es este------------------------->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>


Aqui esta el api
<APPLET CODE="API.class" CODEBASE="applet/" WIDTH=150 HEIGHT=25>
</APPLET>

</HTML>
el API.class esta en la carpeta applet y estoy desconcertado porque no me manejo mucho en el cuento de los applet pero aprendo rapido ayudame por favor si puedes!!!!!

icon_redface.gif icon_cry.gif icon_rolleyes.gif
Volver arriba
janover
Invitado





MensajePublicado: Mar May 18, 2004 11:16 pm    Asunto: API ADAPTER Responder citando

Hola denuevo , he conseguidp lanzar el APi pero el APi no consigue conectarse con el LMs es que tengo que darle algun parametro especial para conectarse ? y si es asi cual sebe ser? porque no se que URL debo pasarle especificamente una -URL al Index o a la BD o una interface previa a la BD para que el APi interactue con la BD?? icon_eek.gif
Volver arriba
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Mar May 18, 2004 11:43 pm    Asunto: Responder citando

Hola, lo bueno:-) de esta comunidad que ya hay acumulada mucha información sobre lo que necesitas, te adjunto la URL:
http://www.elearningworkshops.com/modules.php?name=Forums&file=viewtopic&t=211&highlight=post

También te recomiendo usar la herramienta de buscar dentro de los foros para poder localizar la información.

Un Saludo
_________________
Jorge Dieguez // Moderador PuntoScorm
mi.blog - http://jdieguez.wordpress.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
Invitado






MensajePublicado: Mie May 19, 2004 5:18 pm    Asunto: APi Responder citando

Hola jorge soy yo janover icon_lol.gif gracias por tu ayuda y tu experticia en este tema, me tiene muy motivado y a su vez lleno de trabajo,pero en fin vamos a lo que te iva a mencionar.
Me he dado cuenta que gracias a tu link que me enviaste por el foro he comprendido varias cosas sobre el APi!!! Una de esas cosas es que el API Adapter necesita tener implementanda un aparte en el servidor para procesar sus peticiones, me refiero a lo que mencionas en el foro de Ayuda sobre adaptar una plataforma que es "las verdaderas dificultades están en diseñar y desarrollar el lado SERVIDOR". Bueno eso me da a entender que el APi se debe conectar a un servlet, entonces mi pregunta es:

En esta parte del codigo del API en java debo darle la URL del servlet para que se connecte al api al LMS??:

icon_confused.gif
public void init()
{
// Get the applet parameter, this is URL of track page
strURL = getParameter( "LMSURL" );

// create a URL from the parameter string read in
try
{
m_urlLMS = new URL(strURL);
//LMS URL created : m_urlLMS
}
catch( MalformedURLException e1 )
{
//Problem creating LMS URL
}
}
La variable LMSURL debe ser la referencia para conectar el API al servlet, para que este procese sus peticiones? o si no lo es, ¿cual variable debo setear?, es que estoy un poco condundido ya que la programación es un poco compleja de entender.
Volver arriba
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Mie May 19, 2004 5:24 pm    Asunto: Responder citando

Hola, nadie dijo que un LMS es cosa simple:-) Animos!
>La variable LMSURL debe ser la referencia para conectar el API al >servlet, para que este procese sus peticiones?
Si en ese parametro pasas la URL del servlet,jsp, php, isapi, cgi donde se procesan las peticiones del Applet.


Un Saludo
_________________
Jorge Dieguez // Moderador PuntoScorm
mi.blog - http://jdieguez.wordpress.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
JAnover_
Invitado





MensajePublicado: Mie May 19, 2004 11:21 pm    Asunto: EL APi no se conecta con el LMS Responder citando

Hola jorge soy janover ,aun no consigo que el applet se conecte al servlet, lo configure de esta forma: icon_cry.gif

public void init()
{
// Get the applet parameter, this is URL of track page
strURL = getParameter( "http://192.168.0.138:8080/elearning/ApiLms/ServletLms.jsp");

// create a URL from the parameter string read in
try
{
m_urlLMS = new URL(strURL);
//LMS URL created : m_urlLMS
}
catch( MalformedURLException e1 )
{
//Problem creating LMS URL
}
}

mi duda es si el APi (Applet) debe estar en la misma carpeta que el srvlet que procesara sus peticiones?
estoy rpobando en una intranet !!! por eso la IP, bueno ojala me entiendas en que estoy parado!!!

No consigo que el APi se conecte al LMS. porque sera?
Volver arriba
Janover_
Invitado





MensajePublicado: Mie May 19, 2004 11:37 pm    Asunto: problema APi Responder citando

Parece que no estoy colocando bien la direccion del LMs alguien podria ayudarme con eso el codigo esta en el post de arriba!! desde ya gracias por la ayuda!
Volver arriba
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Jue May 20, 2004 3:28 pm    Asunto: Responder citando

El API.java ya se encarga el solito de recoger la url donde debe conectar. Dicha url se la has de pasar desde el fichero htm en el cual cargas el applet de tal forma que te quedaria algo similar a esto:

Código:
<applet code="API" Name="API_1484_11" id="API_1484_11" height=0 width=0>
<PARAM NAME="LMSURL" VALUE="http://localhost:8080/scorm2004/LMSClient">
</applet>


entonces al abrir el html cargaria el applet que tomaria como url de conexion el valor que observas. En este ejemplo la url de conexion seria http://localhost:8080/scorm2004/LMSClient que es un servlet que se encarga de la comunicacion entre el SCO y el LMS.

Saludos y animo.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Jue May 20, 2004 4:33 pm    Asunto: agradecimiento Responder citando

Gracias por fin logre conectarme que alivio, Ahora a probar el traspaso de datos entre el APi(Applet) y el servlet del LMS

Gracias por la ayuda Luis Felipe icon_lol.gif icon_arrow.gif

Seguire dandole con fuerza a este tema nos vemos!!! y de nuevo gracias
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Jue May 20, 2004 4:37 pm    Asunto: Ayuda con los retornos para el API Responder citando

Alguien me podria dar un ejemplo de como el servlet o lo uqe esta en el lado del servidor al cual el APi se conecta retorna un valor cuando el API se lo solicita??

Un ejemplo para desenredarme un poco !!!! quiero ver como lo hacen ustedes para retornar valores desde el LMs al API??

alguna icon_confused.gif cosa poca que sea , bueno desde ya se lo agradeceria mucho
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Vie May 21, 2004 2:22 pm    Asunto: Responder citando

Este es el metodo que yo utilizo para enviar la respuesta a la API.

Código:
public static void retorna(HttpServletResponse res, String vr)
{
   try
   {
   // Abrimos un canal de salida.
   ServletOutputStream out = res.getOutputStream();
   // y enviamos el valor,
   out.print(vr);
   // acto seguido lo cerramos.
   out.close();            
   System.out.println("Enviado " + vr);
   }
   catch (IOException e)
   // en caso de fallo intentamos enviar false.
   {
   try
   {
   ServletOutputStream out = res.getOutputStream();
   out.print("false");
   out.close();
   System.out.println("Enviando false...");
   }
   catch (IOException d)
   {
   System.out.println(d.getMessage());
   }
}
}



El primer parametro que recibe es el objeto respuesta del servlet en el cual esta el metodo y el segundo es un String que representa el valor a devolver. Espero que te sirva de ayuda.

Y no me des las gracias que para eso estamos aqui :D.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Vie May 28, 2004 5:20 pm    Asunto: Responder citando

Hola a todos algunas dudas sobre abajo del codigo estan se le agradecera la ayuda!!! icon_lol.gif
public String LMSInitialize( String strParameter )
{
String strReturn = "false";

if( connectToLMS() )
{
System.out.println(" after calling connectToLMS");
if(strParameter != null && !strParameter.trim().equals("")
&& strParameter.length() != 0)
{
m_strLastErrorNum = "201";
System.out.println(" after calling connectToLMS in error");
}
else
{
// next call added so that the LMS itself gets notification
if(sendData("lmsinitialize" ," ","") )
{
System.out.println( "***********calling getdata");
strReturn = getData();
if( strReturn.equalsIgnoreCase("false") || iInit == 1 )
{
m_strLastErrorNum = "101"; //error
strReturn = "false";
}
else
{
m_strLastErrorNum = "0"; // no error
}
}

iInit = 1;
}

}
return strReturn;
}
cuando se invoca el metodo getData() en este applet como el servlet le devuelve el valor booleano como string o boolean ??? no entendi bien luis felipe puedes ayudarme!!!!!Como hago que llego el dato que necesito merefiero, para este caso es un boolena pero se refleja con String o boolean??

Janover gracias icon_lol.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Vie May 28, 2004 6:11 pm    Asunto: Responder citando

Asi invoco el metodo luis felipe que llama a tu metodo para retornar valores al applet
ejemplo:
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String aux = req.getParameter("lmsinitialize");
if(aux==null)
{
retorna(res, "true");
}

}

esto esta en el servlet pero no me funciona?? porque sera????

en la consola del cliente me sale:

in connectToLMS

success = true

after calling connectToLMS

in sendData for sending lmsinitialize

***********calling getdata

***********end of getdatageneral error in getData

en ese orden!! si sabes podrías ayudarme!! te lo agradecería!!

bueno saludos icon_lol.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Vie May 28, 2004 8:00 pm    Asunto: Responder citando

Hola, el codigo OK solo que te falta escribir el resultado en el response(return solo devuelve el resultado de una funcion)icon_smile.gif¿no?

Un Saludo
_________________
Jorge Dieguez // Moderador PuntoScorm
mi.blog - http://jdieguez.wordpress.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Vie May 28, 2004 10:07 pm    Asunto: Responder citando

jorge hola podria ser mas explicito porque le he estado metiendo mano y no pasa nada, solo veo cosas pa sacar por HTMl pero como retorno el valor lo hago por el respond pero no se q pasa!!!

Help!!! icon_lol.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
Jorge_Dieguez
Moderador puntoSCORM
Moderador puntoSCORM


Registrado: Jul 05, 2003
Mensajes: 1433
Ubicación: Madrid / España

MensajePublicado: Sab May 29, 2004 12:22 am    Asunto: Responder citando

Hola, todo esto funciona de la siguiente manera:
- Applet hace una petición HTTP a un servador
- El servidor SERVLET responde, la respuesta de un SERVLET se hace por medio del objeto response.
- El servlet no retorna valores como una funcion(date cuenta que un servidor HTTP solo sabe responder con texto, y el cliente http(applet) solo sabe recibir texto)!, genera texto, en lugar de HTML mejor generar texto planto (tan fácil como escribir en el encabezado del response text/plain).
No se si me logro explicar¿?
Un Saludo
_________________
Jorge Dieguez // Moderador PuntoScorm
mi.blog - http://jdieguez.wordpress.com
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar e-mail
janoverr
Invitado





MensajePublicado: Dom May 30, 2004 12:44 am    Asunto: yo lo uso asi y no me resulta Responder citando

Jorge si se que es el objeto Respond es el responsable de enviar el texto al Cliente(Applet ) ok si lo se como lo captura de envio post o en get,

lo que pasa es que no pasa el dato el Servlet al Applet al applet sale que no obtuvo respuesta el metodo getData(), entonces ahi no esta funcando
asi lo envio yo en texto

Ejemplo


protected void doGet(HttpServletRequest req,
8: HttpServletResponse res)
9: throws ServletException, IOException
10: {
11: res.setContentType("text/html");
12: PrintWriter out = res.getWriter();//aqui le respondo al getData()
13: out.println("true");//mando el true
15: out.close();
16: }
bueno ahi esta el codigo
si yo entiendo
eso

si necesito saber algo solo ago un resquest.getParameter("nombre_parametro")
buenosi me entiendes ayudame porfavor!?
en mi post anterior sale el error que me tira la consola del navegador del cliente
Volver arriba
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 8:41 am    Asunto: Responder citando

A ver...

El API de Jorge se encarga de enviar datos al servlet (en nuestro caso) y este los recibe. El envio se realiza de la siguiente forma...


Parametro|valor1|valor2 (lo del valor 2 no recuerdo bien si puede existir o solo se recibe hasta el primero)

de tal forma que cuando tu Applet hace una llamada al servlet lo que le esta enviando podria ser (en el caso del initialize) lo siguiente:

lmsinitialize|

como ves tras las | no tenemos nada ya que el parametro que se ha de pasar a la llamada lmsinitialize es el caracter nulo.

Bien, lo primero que debes de entender es que no estas enviando un parametro que se llame lmsinitilize sino un parametro que es una cadena de texto y que se compone de lo siguiente:

nombre_del_parametro|valor_del_parametro|valor2_del_parametro

por lo que valores posible del parametro recibido por el servlet podrian ser:

lmsinitialize|
lmscommit|
lmsget|cmi._version
lmsset|cmi.learner_name|luis felipe

una vez explicado esto nos queda claro que cuando recibamos el texto mediante elservlet deberemos de tratarlo y cortarlo para separar los distintos valores que en el pueden venir. Para ello nos basaremos en el caracter | que nos dilimitara los diferentes valores contenidos en la cadena de texto.

Realizado esto solo tendremos que comprobar que parametro se nos ha enviado y con que valores y actuar en consecuencia dependiendo de lo que se nos haya pedido.

Espero haberme explicado bien y que te sea de ayuda, si sigues con dudas pregunta.

Hasta luego icon_smile.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 9:01 am    Asunto: Responder citando

Por cierto, los envios que realiza la funciona retorna todos se realizan en String.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Lun May 31, 2004 3:27 pm    Asunto: Re: yo lo uso asi y no me resulta Responder citando

janoverr escribió:


Ejemplo


protected void doGet(HttpServletRequest req,
8: HttpServletResponse res)
9: throws ServletException, IOException
10: {
11: res.setContentType("text/html");
12: PrintWriter out = res.getWriter();//aqui le respondo al getData()
13: out.println("true");//mando el true
15: out.close();
16: }
bueno ahi esta el codigo
si yo entiendo
eso

si necesito saber algo solo ago un resquest.getParameter("nombre_parametro")
buenosi me entiendes ayudame porfavor!?
en mi post anterior sale el error que me tira la consola del navegador del cliente


hola Luis Felipe gracias por la respuesta y me gustaria q me hecharas una mano con lo del codigo me falta validar el formato del string osea sacarle el toquen, pero me inetera ver el envio del string del servlet al api hechale un vistaso porfavor? icon_lol.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 3:46 pm    Asunto: Responder citando

El envio de datos del servlet al API se realiza mediante la funciona que ya te dije.

dentro de tu metodo doGet o doPost dependiendo el que uses cuando necesites dar una respuesta simplemente deberas realizar una llamada al metodo retorna que ya te escribi aqui.

Eso hara que que mediante el objeto de salida del servlet se etregue la cadena que le hayas pasado por el segundo parametro: valor.

No se si era esto lo que preguntabas, en caso de no serlo... explicame mejor que es lo que no te ha quedado claro.

Saludos.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Lun May 31, 2004 3:58 pm    Asunto: Responder citando

esta es la secuencia de mensajes que me envia la consola java del navegador del Cliente.

in connectToLMS

success = true

after calling connectToLMS

in sendData for sending lmsinitialize

***********calling getdata

***********end of getdatageneral error in getData

Esto me quiere decir q cuando el APi invoca el metodo getData(), el servlet no responde la petición, por lo que da a enter der por laultima linea impresa en la consola "***********end of getdatageneral error in getData", q el dato no se ha pido enviar al Applet!!! Como soluciono esto???

Gracias por tu tiempo luis icon_lol.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 4:16 pm    Asunto: Responder citando

Si te esta dando ese error es que efectivamente la API no esta obteniendo respuesta del servlet...

Por lo que creo recordar, el trozo de codigo que pusiste antes en el cual le enviabas la respuesta al API me da que lo tenias dentro del metodo

doGet

o eso creo recordar, ahora cuando postee esta respuesta me asegurare ya que mientras las escribo no me deja mirarlo. En caso de que esto fuese afirmativo deberias de cambiar tu codigo para meterlo dentro del metodo doPost del servlet ya que la API se comunica con el servlet a traves del metodo POST (o eso creo recordar).

En caso de que no hubieses escrito tu codigo dentro del metodo doGet tendras que mirar porque el servlet no entrega la respuesta al API, generalmente suele ser porque no entre dentro de la condicion que le tienes marcada (aunque creo que en tu codigo no habia condicion).

Si sigues sin conseguirlo, aqui estamos.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Lun May 31, 2004 4:22 pm    Asunto: Responder citando

Aqui esta el codigo no se porque no funciona!!!!

Pjala alguien pueda ayudarme!!!

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{

String parametro= req.getParameter("lmsinizialize");//parameter =lmsinizialize|;
StringTokenizer tokens=new StringTokenizer(parametro, "|");
String str=tokens.nextToken();
retorna(res,"true");


}

Espero que me puedan ayudar!!!!

asi llamoal retorna que implementaste luis Felipe !!!!!! no se porque no funciona!!!! icon_lol.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 4:47 pm    Asunto: Responder citando

Posiblemente te estara saltando una excepcion al recoger el parametro mediante el metodo getParameter porque es mas que posible que no exista ningun parametro con ese nombre.

Prueba a quitar todas las lienas excepto la de retorna(res, "true");

asi deberia de funcionarte.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
janover
Miembro asiduo
Miembro asiduo


Registrado: May 19, 2004
Mensajes: 35

MensajePublicado: Lun May 31, 2004 4:51 pm    Asunto: Responder citando

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{

//String parametro= req.getParameter("lmsinizialize");//parameter =lmsinizialize|;
//StringTokenizer tokens=new StringTokenizer(parametro, "|");
//String str=tokens.nextToken();
retorna(res,"true");


}
esta todo en comentarios lo unico activo es el llamado al a funcion retorna!!

nose qu epuede ser aun sale el mismo erros icon_sad.gif

in connectToLMS

success = true

after calling connectToLMS

in sendData for sending lmsinitialize

***********calling getdata

***********end of getdatageneral error in getData

help please!!!! icon_arrow.gif icon_rolleyes.gif
Volver arriba
Ver perfil de usuario Enviar mensaje privado Visitar sitio web del autor
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 5:02 pm    Asunto: Responder citando

mmmmm a simple vista no sabria decirte a que puede deberse el error, te aconsejo que intentes capturar las excepciones que ahora las estas dando como throables capturalas a ver si dan mas informacion y sino lo consigues puedes enviarme el fichero de tu servlet a luis_felipe_@hotmail.com a ver si a la noche cuando llegue a casa puedo echarle un ojo y ya te comento lo que sea.

Saludos.
Volver arriba
Ver perfil de usuario Enviar mensaje privado
luis_felipe
Miembro asiduo
Miembro asiduo


Registrado: Jan 26, 2004
Mensajes: 100

MensajePublicado: Lun May 31, 2004 5:08 pm    Asunto: Responder citando

Object Obj_temp; // Objeto para almacenacimiento o creacion temporal.

String Dato="", parametro="", valor=""; // Parametro y valor.
int indice_corte=0; // Indice para obtener el valor del parametro.

for (Enumeration Lista = req.getParameterNames(); Lista.hasMoreElements() ;)
{
Obj_temp=Lista.nextElement();
Dato=Obj_temp.toString();
}
parametro=req.getParameter(Dato);
parametro=parametro.trim();
indice_corte=parametro.indexOf("|");
if(indice_corte>0)
{
valor=parametro.substring(indice_corte+1,parametro.length());
parametro=parametro.substring(0,indice_corte);
}
System.out.println("Procesando Dato: " + Dato + " " + parametro + " " + valor);



Colocando este codigo al inicio del metodo doPost de tu servlet obtendras los parametros ya cortados y almacenados en variables separadas para luego saber si el parametro que el API ha enviado al servlet ha sido lmsinitiale

simplemente haces la comparacion parametro.equals("lmsinitialize") y en caso de que sea afirmativo respondes usando el metodo retorna(res, "true");

De esta forma deberia de funcionarte, en caso contrario ya no sabria decirte de donde puede venir el error, tendria que mirar el codigo para saberlo.


Otra cosa, debo de suponer que estas usando algun contenedor web como Tomcat o similar verdad? o como estas sirviendo el servlet?
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mostrar mensajes de anteriores:   
Publicar nuevo tema   Responder al tema    Foros de discusión -> Desarrollo LMS Todas las horas son GMT + 2 Horas
Ir a página 1, 2  Siguiente
Página 1 de 2

 
Cambiar a:  
Puede publicar nuevos temas en este foro
No puede responder a temas en este foro
No puede editar sus mensajes en este foro
No puede borrar sus mensajes en este foro
No puede votar en encuestas en este foro
 

/// eLearning WORKSHOPS :: Comunidad de eLearning
Una iniciativa de Calvet, Vila & Arriaga Consulting eLearning WORKSHOPS autoriza la reproducción de sus contenidos siempre que se cite a eLearning WORKSHOPS y se de la URL.
Todas las marcas son propiedad de sus respectivos dueños. Los artículos y comentarios son propiedad de sus autores. El resto © 2004
Calvet, Vila & Arriaga Consulting.
La Comunidad y Academia eLearning WORKSHOPS están desarrolladas enteramente con Software Libre: PHP-Nuke, Moodle, PhpBB y otros.
Moodle en CV&A