#include "FiveWin.ch"
#include "tdolphin.ch"
#include "layout.ch"
STATIC oQry, oBot, oSay, oImg, aPreg, nPre, oWnd, nTiempo
MEMVAR oApp
function Main(cGrupo)
local oMainLay, oBmp, oBmp1
local hLays := {=>}
local oFont3, i, j, aR := {}
IF IsExeRunning("EXAMEN.EXE")
MsgStop("La Aplicación ya esta en uso en esta PC","Error")
QUIT
ENDIF
oApp := TApplication():New()
oApp:oServer := Conectar()
nPre := 1
oSay := ARRAY(5)
oBot := ARRAY(3)
aPreg := {}
oQry := oApp:oServer:Query("SELECT * FROM exa_preguntas WHERE grupo = '"+cgrupo+"'")
FOR i := 1 TO 20 // Aca tenes que tener mas de 20 preguntas cargadas en la base para el grupo, sino no sale del loop.
j := nRandom( oQry:nRecCount )
DO WHILE ASCAN(aR,j) > 0
j := nRandom( oQry:nRecCount )
ENDDO
AADD(aR,j)
oQry:GoTo(j)
AADD(aPreg,{oQry:imagen,oQry:numero,oQry:pregunta,oQry:resp1,oQry:resp2,oQry:resp3,oQry:correcta,0})
NEXT i
DEFINE FONT oFont3 NAME "Calibri" size 17, 34
DEFINE BRUSH oBmp FILE "ICONOS\FONDO.BMP" RESIZE
DEFINE BRUSH oBmp1 FILE "ICONOS\FONDO1.BMP"
define window oApp:oWnd NOMINIMIZE ICON oApp:oIco
DEFINE TIMER oApp:oTimer INTERVAL 1000 ACTION Pinguear() OF oApp:oWnd
ACTIVATE TIMER oApp:oTimer
oApp:oWnd:oFont := oFont3
define layout hLays["MAIN"] of oApp:oWnd
define vertical layout hLays["H2"] of hLays["MAIN"] SIZE 250
( hLays["H2"] ):SetBrush(oBmp)
define vertical layout hLays["H3"] of hLays["MAIN"]
( hLays["H3"] ):SetBrush(oBmp1)
define horizontal layout of hLays["H2"]
define horizontal layout hLays["H1_1"] of hLays["H2"]:aHLayout[1] SIZE 950
define horizontal layout hLays["H1_2"] of hLays["H2"]:aHLayout[1]
define horizontal layout of hLays["H3"]
define horizontal layout hLays["H3_1"] of hLays["H3"]:aHLayout[1] SIZE 1300
define horizontal layout hLays["H3_2"] of hLays["H3"]:aHLayout[1]
ntiempo := 0
Imagen (hLays["H1_2"] )
Pregunta (hLays["H1_1"] )
Opciones (hLays["H3_1"] )
Avance (hLays["H3_2"] )
activate window oApp:oWnd MAXIMIZED ON init (( hLays["H1_1"] ):SetFocus())
return nil
******************************
** Mostrar Imagen
STATIC function Imagen (oWnd)
LOCAL cImagen := "NADA"
cImagen := IF(empty(aPreg[nPre,1]),cImagen,IF(FILE("ICONOS\"+alltrim(aPreg[nPre,1])+".jpg"),ALLTRIM(aPreg[nPre,1]),"SIN"))
@ 00, 00 BTNBMP oImg OF oWnd FILE "ICONOS\"+ALLTRIM(cImagen)+".JPG" SIZE 350,350 ADJUST
set layout control oImg of oWnd
return nil
******************************
** Mostrar Pregunta
STATIC function Pregunta (oWnd)
@ 05, 40 SAY oSay[1] PROMPT "Pregunta: "+chr(10)+ALLTRIM(aPreg[nPre,3]) OF oWnd SIZE 350,350 TRANSPARENT PIXEL
set layout control oSay[1] of oWnd
return nil
******************************
** Mostrar Opciones
STATIC function Opciones (oWnd)
@ 05,130 SAY oSay[2] PROMPT "1) "+ALLTRIM(aPreg[nPre,4]) SIZE 1100,300 OF oWnd PIXEL TRANSPARENT
@155,130 SAY oSay[3] PROMPT "2) "+ALLTRIM(aPreg[nPre,5]) SIZE 1100,300 OF oWnd PIXEL TRANSPARENT
@310,130 SAY oSay[4] PROMPT "3) "+ALLTRIM(aPreg[nPre,6]) SIZE 1100,300 OF oWnd PIXEL TRANSPARENT
@ 05, 15 BTNBMP oBot[1] OF oWnd FILE "ICONOS\uno.PNG" SIZE 100,100 ACTION Avanzar(1) NOBORDER ADJUST PIXEL TRANSPARENT
@155, 15 BTNBMP oBot[2] OF oWnd FILE "ICONOS\dos.PNG" SIZE 100,100 ACTION Avanzar(2) NOBORDER ADJUST PIXEL TRANSPARENT
@310, 15 BTNBMP oBot[2] OF oWnd FILE "ICONOS\tres.PNG" SIZE 100,100 ACTION Avanzar(2) NOBORDER ADJUST PIXEL TRANSPARENT
return nil
******************************
** Avance
STATIC function Avance (oWnd)
@ 10, 05 METEREX oSay[5] VAR nTiempo TOTAL 60 SIZE 60,400 OF oWnd PIXEL VERTICAL
return nil
******************************
** Mostrar Avanzar
STATIC function Avanzar (n)
LOCA cImagen := "NADA"
aPreg[nPre,8] := n
nPre ++
IF nPre > 20
oApp:oTimer:End()
Resultado()
oApp:oWnd:End()
RETURN nil
ENDIF
oSay[1]:SetText("Pregunta: "+chr(10)+aPreg[nPre,3])
oSay[2]:SetText("1) "+aPreg[nPre,4])
oSay[3]:SetText("2) "+aPreg[nPre,5])
oSay[4]:SetText("3) "+aPreg[nPre,6])
cImagen := IF(empty(aPreg[nPre,1]),cImagen,IF(FILE("ICONOS\"+alltrim(aPreg[nPre,1])+".jpg"),ALLTRIM(aPreg[nPre,1]),"SIN"))
oImg:LoadBitMaps("ICONOS\"+ALLTRIM(cImagen)+".JPG")
oImg:Refresh()
ntiempo := 0
oSay[5]:Set(ntiempo)
oSay[5]:Refresh()
RETURN nil
STATIC FUNCTION Resultado()
LOCAL nCorr := 0, nNoResp := 0,i
FOR i := 1 TO 20
IF aPreg[i,7] = aPreg[i,8]
nCorr ++
ENDIF
IF aPreg[i,8] = 0
nNoResp ++
ENDIF
NEXT i
MsgInfo("Total Preguntas: 20"+chr(10)+;
"Total Respuestas correctas: "+STR(nCorr,2)+chr(10)+;
"Total Respuestas incorrectas: "+STR(20-nCorr-nNoResp,2)+chr(10)+;
"Total Respuestas no respondidas: "+STR(nNoResp,2)+chr(10)+;
"Porcentaje respondido correctamente"+STR((nCorr/20)*100,6,2)+chr(10)+;
"Resultado del Examen:"+IF(nCorr>=14,"APROBADO","DESAPROBADO"),"Resultado del Examen")
RETURN nil
STATIC FUNCTION Pinguear()
LOCAL oQry,oError, lCerrar := .f.
IF oApp:lPingueando
RETURN nil
ENDIF
oApp:lPingueando := .t.
IF oApp:oServer <> nil
TRY
oQry := oApp:oServer:Query("SELECT 1")
IF oQry:RecCount() = 0
MsgWait("Reconectando con el servidor......")
oApp:oServer:Ping()
ELSE
oApp:oWnd:SetMsg("Pingueando...")
ENDIF
CATCH oError
MsgStop("Se perdio la conexion con el servidor, SE CERRARA EL PROGRAMA"+CHR(10)+;
"Verifique su acceso a la red antes de volver a entrar","Atencion!")
oApp:oServer:End()
lCerrar := .t.
END TRY
ENDIF
IF lCerrar
QUIT
ENDIF
IF nTiempo = 60 //Aca le doy aprox. 60 segundos para responder
Avanzar()
ENDIF
ntiempo ++
oSay[5]:Set(ntiempo)
oApp:lPingueando := .f.
RETURN nil
//----------------------------------------------------------------------------//
CLASS TApplication
DATA oWnd // Pantalla Principal
DATA oServer // Conexion con el servidor de base de datos
DATA oTimer // Timer para pinguear
DATA lPingueando//Determina si el programa esta haciendo ping
DATA oIco // Dialogo para el procesando
METHOD New() CONSTRUCTOR
ENDCLASS
//----------------------------------------------------------------//
METHOD New() CLASS TApplication
SET DATE FORMAT "DD/MM/YYYY"
SET DELETE ON
SET CONFIRM ON
SET SOFTSEEK ON
SET 3DLOOK ON
SetHandleCount(100)
SetBalloon(.t.)
D_SetCaseSensitive(.t.)
HB_LANGSELECT( 'ESWIN' )
DEFINE ICON ::oIco RESOURCE "ICONO"
// Inicializacion de valores
::lPingueando := .f.
return Self
DLL32 FUNCTION BWCCRegister( hInst AS LONG) AS WORD PASCAL LIB "BWCC32.DLL"
REQUEST HB_LANG_ESWIN
REQUEST HB_CODEPAGE_ESMWIN