desarrollosconsejeria/adtos-server/1.7-0/adtos/encuesta.pas @ 23a384b9
54e95a47 | Elisa | unit encuesta;
|
|
{$mode objfpc}{$H+}
|
|||
interface
|
|||
uses
|
|||
Math,IdURI,globales1,clequipoalumno,inicio,globales,IniFiles,Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
|||
ExtCtrls, StdCtrls, Buttons, IdCmdTCPServer, IdContext, IdCommandHandlers,
|
|||
Chart;
|
|||
type
|
|||
{ TfrmEncuesta }
|
|||
TfrmEncuesta = class(TForm)
|
|||
bchOpciones: TBarChart;
|
|||
bitPrueba: TSpeedButton;
|
|||
btnEnviar: TButton;
|
|||
btnCerrarCuestion: TButton;
|
|||
btnIndividual: TButton;
|
|||
btnResultados: TButton;
|
|||
btnOpciones: TButton;
|
|||
cboCuestion: TComboBox;
|
|||
IdCmdTCPServer1: TIdCmdTCPServer;
|
|||
imgGrafico: TImage;
|
|||
imgpresenta: TPaintBox;
|
|||
lblMenTiempo: TLabel;
|
|||
lblTiempo2: TLabel;
|
|||
pnEcuesta: TPanel;
|
|||
tmrMensaje: TTimer;
|
|||
tmrRecogida: TTimer;
|
|||
procedure bitPruebaClick(Sender: TObject);
|
|||
procedure btnCerrarCuestionClick(Sender: TObject);
|
|||
procedure btnEnviarClick(Sender: TObject);
|
|||
procedure btnIndividualClick(Sender: TObject);
|
|||
procedure btnResultadosClick(Sender: TObject);
|
|||
procedure btnOpcionesClick(Sender: TObject);
|
|||
procedure cboCuestionChange(Sender: TObject);
|
|||
procedure FormCreate(Sender: TObject);
|
|||
procedure pnEcuestaClick(Sender: TObject);
|
|||
procedure respuestaCuestionCommand(ASender: TIdCommand);
|
|||
procedure tmrMensajeTimer(Sender: TObject);
|
|||
procedure tmrRecogidaTimer(Sender: TObject);
|
|||
private
|
|||
procedure anadirRespuesta(hostalu: string; resp, tiempor: integer;//
|
|||
usuario: string);
|
|||
procedure BuscaFicheros(Ruta, Mascara: AnsiString; var Value: TStringList;
|
|||
brec: Boolean); //
|
|||
procedure comprobarClasificacion(nequ: integer); //
|
|||
procedure DrawPieSlice(myB: TBitmap; const bcolor,
|
|||
pcolor: Tcolor; const Center: TPoint; const Radius: INTEGER;
|
|||
const StartDegrees, StopDegrees: Double); //
|
|||
//funciones para leer y cargar la encuesta previamente creada
|
|||
procedure Estadisticas();//
|
|||
procedure EnviarConsulta(); //
|
|||
procedure EncuestasCrearLabels();
|
|||
function EncuestaLeerArchivo(miarchivo: string):boolean;
|
|||
procedure EncuestaMostrar();
|
|||
procedure EncuestaOcultarLabels();
|
|||
procedure EncuestaPintarCuadros(ima: TBitmap; numopc: integer);
|
|||
procedure EncuestaRecolocarLabels();
|
|||
procedure EncuestaPintarBordeOpciones(img: Tbitmap);
|
|||
procedure EncuestaMarcarCorrecta(sol: integer); //
|
|||
procedure IndividualMostrarEstadisticas(); //
|
|||
procedure IndividualPintarFondo(ima: TBitmap; numalu: integer); //
|
|||
procedure IndividualPintarCabecera(ima: TBitmap); //
|
|||
procedure IndividualPintarResultados(ima: TBitmap);//
|
|||
procedure OpcionesMostrarEstadisticas1(opciones: array of integer);
|
|||
procedure OpcionesPintarLeyendas(ima: TBitmap);
|
|||
procedure EstadisticaPintarFondo(img:TBitmap;Titulo, base: String); //
|
|||
procedure ResultadosEstadisticas(aci, fal, bla: integer); //
|
|||
procedure ResultadosPintarLeyendas(ima: TBitmap; ancho, alto: integer; //
|
|||
leyenda: array of string; colores: array of Tcolor);
|
|||
{ private declarations }
|
|||
public
|
|||
{ public declarations }
|
|||
end;
|
|||
var
|
|||
frmEncuesta: TfrmEncuesta;
|
|||
lblPregunta:Tlabel;
|
|||
lblOpcion:Array[0..5] of Tlabel;
|
|||
g_cuestion:Tcuestion;
|
|||
implementation
|
|||
var f_pintargrafico:boolean=false;
|
|||
f_contador:integer=6;
|
|||
f_respuestas_recibidas:array of integer;
|
|||
f_mostrar_clase:Boolean=false;
|
|||
f_contador_mensaje:integer;
|
|||
f_indexm: array of integer;
|
|||
f_consulta_enviada:boolean=false;
|
|||
{ TfrmEncuesta }
|
|||
procedure TfrmEncuesta.OpcionesPintarLeyendas(ima: TBitmap);
|
|||
const
|
|||
textos:array [0..1] of string=('Correcta','Incorrectas');
|
|||
var
|
|||
i:integer;
|
|||
colores:array [0..1] of TColor;
|
|||
begin
|
|||
colores[0]:=VERDE_COLOR;
|
|||
colores[1]:=ROJO_COLOR;
|
|||
with ima.Canvas do
|
|||
begin
|
|||
font.Name:='Sans';
|
|||
font.size:=9;
|
|||
for i:=0 to 1 do
|
|||
begin
|
|||
brush.color:=colores[i];
|
|||
pen.color:=colores[i];
|
|||
Rectangle(685,250+i*17,700,265+i*23);
|
|||
brush.color:=clBlack;
|
|||
Font.Color:=clBlack;
|
|||
TextOut(702,250+i*17,textos[i]);
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.OpcionesMostrarEstadisticas1( opciones:array of integer);
|
|||
var
|
|||
mcolor:TColor;
|
|||
nombre:string;
|
|||
i:integer;
|
|||
mbitmap:TBitmap;
|
|||
begin
|
|||
mbitmap:=TBitmap.create;
|
|||
EncuestaRecolocarLabels();
|
|||
try
|
|||
mbitmap.Width:=imgGrafico.Width;
|
|||
mbitmap.Height:=imgGrafico.Height;
|
|||
EstadisticaPintarFondo(mbitmap,'','');
|
|||
OpcionesPintarLeyendas(mbitmap);
|
|||
EncuestaPintarBordeOpciones(mbitmap);
|
|||
imgGrafico.Picture.Bitmap.Assign(mbitmap);
|
|||
finally
|
|||
mbitmap.free;
|
|||
end;
|
|||
imgGrafico.visible:=true;
|
|||
bchOpciones.clear;
|
|||
for i:=0 to high(opciones) do
|
|||
begin
|
|||
if i<>g_cuestion.solucion then
|
|||
begin
|
|||
mcolor:=ROJO_COLOR;
|
|||
end
|
|||
else
|
|||
begin
|
|||
mcolor:=VERDE_COLOR;
|
|||
end;
|
|||
if i=0 then nombre:=' NS/NC' else nombre:='Opción ' + inttostr(i);
|
|||
bchOpciones.AddBar(nombre,opciones[i],mcolor);
|
|||
end;
|
|||
bchOpciones.visible:=true;
|
|||
end;
|
|||
procedure TfrmEncuesta.comprobarClasificacion(nequ:integer);
|
|||
var
|
|||
j,k:integer;
|
|||
begin
|
|||
for j:=0 to high(equipoalumno) do
|
|||
begin
|
|||
if equipoalumno[nequ].tiemporespuesta<= g_cuestion.mejorestiempos[j] then
|
|||
begin
|
|||
for k:=j to high(equipoalumno) do
|
|||
begin
|
|||
if k<high(equipoalumno) then
|
|||
begin
|
|||
g_cuestion.mejoresalumnos[k+1]:=g_cuestion.mejoresalumnos[k];
|
|||
g_cuestion.mejorestiempos[k+1]:=g_cuestion.mejorestiempos[k];
|
|||
g_cuestion.mejoresequipos[k+1]:=g_cuestion.mejoresequipos[k];
|
|||
g_cuestion.mejoresrespuestas[k+1]:=g_cuestion.mejoresrespuestas[k]
|
|||
end;
|
|||
end;
|
|||
g_cuestion.mejoresalumnos[j]:=equipoalumno[nequ].NombreMonitor;
|
|||
g_cuestion.mejoresequipos[j]:=equipoalumno[nequ].ip;
|
|||
g_cuestion.mejorestiempos[j]:=equipoalumno[nequ].tiemporespuesta;
|
|||
g_cuestion.mejoresrespuestas[j]:=equipoAlumno[nequ].Respuesta;
|
|||
break;
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.anadirRespuesta(hostalu:string;resp,tiempor:integer; usuario:string);
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
for i:=0 to high(equipoalumno) do
|
|||
begin
|
|||
if (equipoalumno[i].IP=hostalu) and (equipoalumno[i].Respuesta=-2) then
|
|||
begin
|
|||
equipoalumno[i].Respuesta:=resp;
|
|||
equipoalumno[i].TiempoRespuesta:=tiempor;
|
|||
break;
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.respuestaCuestionCommand(ASender: TIdCommand);
|
|||
var
|
|||
usuario:string;
|
|||
tiempo1, respuesta:integer;
|
|||
hostalu,codigo:string;
|
|||
begin
|
|||
try
|
|||
if Assigned (ASender.Params) then
|
|||
begin
|
|||
hostalu:=TIdURI.URLDecode(Asender.Params[0]);
|
|||
codigo:= TIdURI.URLDecode(Asender.Params[1]);
|
|||
respuesta:=strtoint(TIdURI.URLDecode(Asender.Params[2]));
|
|||
tiempo1:=strtoint(TIdURI.URLDecode(Asender.Params[3]));
|
|||
usuario:=TIdURI.URLDecode(Asender.Params[4]);
|
|||
anadirRespuesta(hostalu,respuesta,tiempo1,usuario);
|
|||
f_respuestas_recibidas[respuesta]:=f_respuestas_recibidas[respuesta]+1;
|
|||
end
|
|||
except
|
|||
mensaje('orden o número de parámetros incorrecto',aceptar);
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.ResultadosPintarLeyendas(ima: TBitmap;ancho,alto:integer; leyenda:array of string; colores:array of Tcolor);
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
with ima.Canvas do
|
|||
begin
|
|||
font.Name:='Sans';
|
|||
font.size:=11;
|
|||
for i:=0 to high(leyenda) do
|
|||
begin
|
|||
brush.color:=colores[i];
|
|||
pen.color:=colores[i];
|
|||
Rectangle(520,250+i*25,540,270+i*25);
|
|||
brush.color:=clBlack;
|
|||
Font.Color:=clBlack;
|
|||
TextOut(544,250+i*25,leyenda[i]);
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.ResultadosEstadisticas(aci,fal,bla:integer);
|
|||
const
|
|||
miscolores:array[0..2] of Tcolor=($66FFCC,$7B61FF,$E5E5E5);
|
|||
textos:array [0..2] of string =('Aciertos: ', 'Fallos: ', 'NC: ');
|
|||
var
|
|||
mbitmap:TBitmap;
|
|||
i,total,unototal:integer;
|
|||
cent:TPoint;
|
|||
x0,x1:double;
|
|||
xs:array[0..3] of double;
|
|||
numopc:array[0..2] of integer;
|
|||
numopcp:array[0..2] of double;
|
|||
numopcd:array [0..2]of double;
|
|||
textoetiquetas:array [0..2] of string;
|
|||
colores:array [0..2] of Tcolor;
|
|||
pora:string;
|
|||
begin
|
|||
numopc[0]:=aci;
|
|||
numopc[1]:=fal;
|
|||
numopc[2]:=bla;
|
|||
unototal:=-1;
|
|||
bchOpciones.Visible:=false;
|
|||
EncuestaRecolocarLabels();
|
|||
mbitmap:=TBitmap.Create;
|
|||
try
|
|||
mbitmap.Width:=imgGrafico.Width;
|
|||
mbitmap.Height:=imgGrafico.Height;
|
|||
cent.x:=300; cent.y:=380;
|
|||
total:=0;
|
|||
for i:=0 to high(numopc)do
|
|||
total:=total+numopc[i];
|
|||
if total=0 then exit;
|
|||
x0:=0;x1:=0; xs[0]:=0;
|
|||
EstadisticaPintarFondo(mbitmap,'','');
|
|||
for i:=0 to high(numopc) do
|
|||
begin
|
|||
numopcd[i]:=numopc[i]*360/total;
|
|||
numopcp[i]:=numopc[i]*100/total;
|
|||
x0:=x1;
|
|||
x1:=x0+numopcd[i];
|
|||
xs[i+1]:=x1;
|
|||
pora:=FloatToStrF(numopcp[i],ffFixed,8,2);
|
|||
textoetiquetas[i]:= textos[i]+ inttostr(numopc[i])+' -> '+pora +' %';
|
|||
colores[i]:=miscolores[i];
|
|||
if numopc[i]=total then unototal:=i;
|
|||
end;
|
|||
ResultadosPintarLeyendas(mbitmap,150,100,textoetiquetas,colores);
|
|||
EncuestaPintarBordeOpciones(mbitmap);
|
|||
imgGrafico.Picture.Assign(mbitmap);
|
|||
if unototal<>-1 then
|
|||
begin
|
|||
imgGrafico.Picture.Bitmap.Canvas.Brush.color:=colores[unototal];
|
|||
imgGrafico.Picture.Bitmap.Canvas.EllipseC(cent.x,cent.y,150,150)
|
|||
end
|
|||
else
|
|||
begin
|
|||
for i:=0 to high(numopc) do
|
|||
DrawPieSlice(imgGrafico.Picture.Bitmap,colores[i],clsilver,cent,150,xs[i],xs[i+1]);
|
|||
end;
|
|||
finally
|
|||
mbitmap.free;
|
|||
end;
|
|||
end;
|
|||
Procedure TfrmEncuesta.IndividualPintarResultados(ima:TBitmap);
|
|||
const
|
|||
alto:integer=14;
|
|||
posiciones:integer=75;
|
|||
separacion:integer=200;
|
|||
var
|
|||
sep,j,i:integer;
|
|||
notas:array of array of string;
|
|||
begin
|
|||
SetLength(notas,g_num_ord_aula);
|
|||
for i:=0 to g_num_ord_aula-1 do
|
|||
begin
|
|||
SetLength(notas[i],4);
|
|||
notas[i][0]:=g_cuestion.mejoresalumnos[i];
|
|||
notas[i][1]:=g_cuestion.mejoresequipos[i];
|
|||
notas[i][2]:=inttostr(g_cuestion.mejoresrespuestas[i]);
|
|||
if notas[i][2]= '0' then notas[i][2]:='NC';
|
|||
notas[i][3]:=inttostr(g_cuestion.mejorestiempos[i]) +' s';
|
|||
end;
|
|||
with ima.Canvas do
|
|||
begin
|
|||
Font.Name:='Sanz';
|
|||
Font.Size:=10;
|
|||
Font.color:=AZUL_COLOR;
|
|||
sep:=separacion;
|
|||
for i:=0 to high(notas) do
|
|||
begin
|
|||
for j:=0 to 3 do
|
|||
begin
|
|||
if strtoint(notas[i][2])=g_cuestion.solucion then
|
|||
Font.color:=clgreen
|
|||
else
|
|||
Font.color:=clred;
|
|||
if j>1 then sep:= separacion+10 else sep:=separacion;
|
|||
TextOut(posiciones+sep*j,38+(14*i),notas[i][j]);
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
Procedure TfrmEncuesta.IndividualPintarCabecera(ima:TBitmap);
|
|||
const
|
|||
alto:integer=12;
|
|||
posiciones:integer=75;
|
|||
separacion:integer=200;
|
|||
titulos: array [0..3] of String=('Alumno','Equipo','Opción','Tiempo');
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
with ima.Canvas do
|
|||
begin
|
|||
Font.Name:='Sanz';
|
|||
Font.Size:=12;
|
|||
Font.Color:=MORADO_COLOR;
|
|||
for i:=0 to high(titulos) do
|
|||
begin
|
|||
brush.color:=clBlack;
|
|||
TextOut(posiciones+separacion*i,alto,titulos[i]);
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.IndividualPintarFondo(ima: TBitmap;numalu:integer);
|
|||
const
|
|||
colorf:array[0..1] of TColor=(clWhite,$E5E5E5);
|
|||
alto:integer=14;
|
|||
var
|
|||
c,i:integer;
|
|||
begin
|
|||
with ima.Canvas do
|
|||
begin
|
|||
for i:=0 to 36 do
|
|||
begin
|
|||
c:=i mod 2;
|
|||
brush.color:=colorf[c];
|
|||
pen.color:=colorf[c];
|
|||
Rectangle(50,25+(alto*i),ima.width-50,25+alto*(i+1));
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.IndividualMostrarEstadisticas();
|
|||
var
|
|||
mbitmap:TBitmap;
|
|||
begin
|
|||
mbitmap:=TBitmap.create;
|
|||
try
|
|||
bchOpciones.Visible:=false;
|
|||
EncuestaOcultarLabels;
|
|||
mbitmap.Width:=imgGrafico.Width;
|
|||
mbitmap.Height:=imgGrafico.Height;
|
|||
EstadisticaPintarFondo(mbitmap,'','');
|
|||
IndividualPintarFondo(mbitmap,10);
|
|||
IndividualPintarCabecera(mbitmap);
|
|||
IndividualPintarResultados(mbitmap);
|
|||
imgGrafico.Picture.Bitmap.Assign(mbitmap);
|
|||
finally
|
|||
mbitmap.free;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestaMarcarCorrecta(sol:integer);
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
for i:=0 to high(lblOpcion) do
|
|||
lblOpcion[i].font.color:=clblack;
|
|||
lblOpcion[sol-1].font.color:=VERDE_COLOR;
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestaOcultarLabels();
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
for i:=0 to high(lblOpcion) do
|
|||
lblOpcion[i].visible:=false;
|
|||
lblPregunta.visible:=false;
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestaRecolocarLabels();
|
|||
var
|
|||
s,lf,i:integer;
|
|||
x0,y0,x1,y1:integer;
|
|||
begin
|
|||
lblPregunta.font.name:='Sans';
|
|||
lblPregunta.Font.Size:=9;
|
|||
lblPregunta.SetBounds(imgGrafico.Left+20,imggrafico.top+14,780,40);
|
|||
lblpregunta.BringToFront;
|
|||
lblPregunta.visible:=true;
|
|||
s:=0;
|
|||
for i:=0 to high(lblOpcion)do
|
|||
begin
|
|||
if i mod 2=0 then
|
|||
begin
|
|||
lf:=imgGrafico.Left+40;
|
|||
s:=s+1;
|
|||
end
|
|||
else
|
|||
begin
|
|||
lf:=imgGrafico.Left+437;
|
|||
end;
|
|||
x0:=lf;
|
|||
y0:=lblpregunta.top+lblpregunta.Height+10+(lblpregunta.height +10)*(s-1);
|
|||
x1:=357;
|
|||
y1:=40;
|
|||
lblOpcion[i].font.name:='Sans';
|
|||
lblOpcion[i].Font.Size:=9;
|
|||
lblOpcion[i].Transparent:=true;
|
|||
lblOpcion[i].SetBounds(x0,y0,x1,y1);
|
|||
lblOpcion[i].visible:=false;
|
|||
end;
|
|||
if g_cuestion.numOpciones>0 then
|
|||
for i:=0 to g_cuestion.numOpciones -1 do
|
|||
lblOpcion[i].visible:=true;
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestaPintarBordeOpciones(img:Tbitmap);
|
|||
var i:integer;
|
|||
lf,tp,bd,hd:integer;
|
|||
begin
|
|||
with img.canvas do
|
|||
begin
|
|||
pen.Width:=1;
|
|||
pen.Color:=clsilver;
|
|||
brush.color:=clwhite;
|
|||
lf:=lblpregunta.left-imggrafico.left-2;
|
|||
tp:=lblpregunta.top-imggrafico.top-1;
|
|||
bd:=lf+lblPregunta.Width+2;
|
|||
hd:=tp+lblPregunta.Height+2;
|
|||
Rectangle(lf,tp,bd,hd);
|
|||
for i:=0 to g_cuestion.numOpciones-1 do
|
|||
begin
|
|||
lf:=lblopcion[i].left-imggrafico.left-2;
|
|||
tp:=lblopcion[i].top-imggrafico.top-1;
|
|||
bd:=lf+lblopcion[i].Width+8;
|
|||
hd:=tp+lblopcion[i].Height;
|
|||
Rectangle(lf,tp,bd,hd);
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.Estadisticas();
|
|||
var
|
|||
i:integer;
|
|||
porciento:integer;
|
|||
begin
|
|||
g_cuestion.numaciertos:=0;
|
|||
g_cuestion.numfallos:=0;
|
|||
g_cuestion.numblancos:=0;
|
|||
for i:=0 to High(g_cuestion.mejoresalumnos) do
|
|||
g_cuestion.mejorestiempos[i]:=g_cuestion.tiempo+1;
|
|||
lblMenTiempo.Visible:=False;
|
|||
lblTiempo2.visible:=false;
|
|||
for i:=0 to high(equipoalumno) do
|
|||
begin
|
|||
if equipoalumno[i].respuesta= 0 then
|
|||
begin
|
|||
inc(g_cuestion.numblancos)
|
|||
end
|
|||
else if equipoalumno[i].respuesta =g_cuestion.solucion then
|
|||
begin
|
|||
inc(g_cuestion.numaciertos);
|
|||
end
|
|||
else
|
|||
begin
|
|||
inc(g_cuestion.numfallos);
|
|||
end;
|
|||
comprobarClasificacion(i);
|
|||
end;
|
|||
//colocarResultadosPreguntas;
|
|||
btnIndividual.Enabled:=true;
|
|||
btnOpciones.Enabled:=true;
|
|||
btnResultados.Enabled:=true;
|
|||
EncuestaMarcarCorrecta(g_cuestion.solucion);
|
|||
btnResultadosClick(btnResultados);
|
|||
f_consulta_enviada:=false;
|
|||
end;
|
|||
procedure TfrmEncuesta.EnviarConsulta();
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
btnEnviar.enabled:=false;
|
|||
f_consulta_enviada:=true;
|
|||
f_contador:=(g_cuestion.tiempo) div 5;
|
|||
f_contador_mensaje:=g_cuestion.tiempo;
|
|||
if idCMDTCPServer1.Active=false then
|
|||
idCMDTCPServer1.Active:=true;
|
|||
for i:=0 to high(equipoalumno) do
|
|||
equipoalumno[i].Respuesta:=-2;
|
|||
setlength(f_respuestas_recibidas, g_cuestion.numOpciones+1);
|
|||
for i:=0 to high(f_respuestas_recibidas) do
|
|||
f_respuestas_recibidas[i]:=0;
|
|||
//Si un ordenador está activo ejecutamos la orden indicada
|
|||
for i:=0 to high(equipoalumno) do
|
|||
equipoalumno[i].iniciarCuestion();
|
|||
tmrRecogida.enabled:=true;
|
|||
tmrMensaje.Enabled:=true;
|
|||
lblMenTiempo.visible:=true;
|
|||
lblTiempo2.visible:=true;
|
|||
cboCuestion.Enabled:=false;
|
|||
bitPrueba.Enabled:=false;
|
|||
end;
|
|||
procedure TfrmEncuesta.cboCuestionChange(Sender: TObject);
|
|||
begin
|
|||
if cboCuestion.ItemIndex=-1 then exit;
|
|||
equipoProfesor.ArcCuestion:=equipoProfesor.DirCuestiones+PathDelim+cbocuestion.text+'.txt';
|
|||
if not FileExists(equipoProfesor.ArcCuestion) then
|
|||
begin
|
|||
Mensaje('No existe esa consulta',Aceptar);
|
|||
exit;
|
|||
end;
|
|||
if not EncuestaLeerArchivo(equipoProfesor.ArcCuestion) then exit ;
|
|||
EncuestaMostrar();
|
|||
pnEcuesta.visible:=true;
|
|||
end;
|
|||
function TfrmEncuesta.EncuestaLeerArchivo(miarchivo:string):boolean;
|
|||
var
|
|||
Mifichero:TMemIniFile;
|
|||
i:integer;
|
|||
begin
|
|||
result:=true;
|
|||
try
|
|||
Mifichero := TMemIniFile.Create(miarchivo);
|
|||
try
|
|||
with Mifichero do
|
|||
begin
|
|||
g_cuestion.numOpciones:= ReadInteger('TIPO','Numero_Opciones',4);
|
|||
g_cuestion.tiempo:=ReadInteger('TIPO','Tiempo',30);
|
|||
g_cuestion.pregunta:=TIdURI.URLDecode(ReadString('CUESTION','Pregunta',''));
|
|||
g_cuestion.solucion:=ReadInteger('TIPO','Solucion',1);
|
|||
lblPregunta.caption:=g_cuestion.pregunta;
|
|||
lblpregunta.Visible:=true;
|
|||
for i:=0 to 5 do
|
|||
lblOpcion[i].visible:=false;
|
|||
for i:=0 to g_cuestion.numOpciones-1 do
|
|||
begin
|
|||
g_cuestion.opciones[i]:=TIdURI.URLDecode(ReadString('CUESTION','Opcion_'+inttostr(i+1),''));
|
|||
lblOpcion[i].caption:=g_cuestion.opciones[i];
|
|||
lblOpcion[i].visible:=true;
|
|||
end;
|
|||
end;
|
|||
application.ProcessMessages;
|
|||
finally
|
|||
Mifichero.free;
|
|||
end;
|
|||
except
|
|||
Mensaje('Error al leer la cuestion',Aceptar);
|
|||
result:=false;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.BuscaFicheros(Ruta, Mascara : AnsiString; var Value : TStringList; brec : Boolean);
|
|||
var
|
|||
srBuscar : TSearchRec;
|
|||
iEncontrado : Integer;
|
|||
begin
|
|||
//Busca los archivos del tipo determinado por la mascara
|
|||
if Ruta[Length(Ruta)] <> '/' then Ruta := Ruta +'/';
|
|||
iEncontrado := FindFirst(Ruta+Mascara, faAnyFile-faDirectory, srBuscar);
|
|||
while iEncontrado = 0 do
|
|||
begin
|
|||
if ( srBuscar.Name <> '.' ) and ( srBuscar.Name <> '..' ) and ( srBuscar.Name <> '' ) then
|
|||
Value.Add(ExtractFileNameOnly(srBuscar.Name));
|
|||
iEncontrado := FindNext(srBuscar);
|
|||
end;
|
|||
FindClose(srBuscar);
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestasCrearLabels();
|
|||
const
|
|||
arriba:integer=40;
|
|||
alto:integer=70;
|
|||
altocuestion:integer=60;
|
|||
var
|
|||
izquierdo,ancho,i:integer;
|
|||
begin
|
|||
ancho:=imgGrafico.width -60;
|
|||
izquierdo:=30;
|
|||
lblPregunta:=Tlabel.create(self);
|
|||
//OJO DETERMINAR EL NÚEMRO DE CARACTERES
|
|||
with lblPregunta do
|
|||
begin
|
|||
font.name:='Sans';
|
|||
font.size:=11;
|
|||
width:=ancho-8;
|
|||
height:=62;
|
|||
autosize:=false;
|
|||
color:=clwhite;
|
|||
WordWrap:=true;
|
|||
Caption:='Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,';
|
|||
transparent:=true;
|
|||
Parent:=pnEcuesta;
|
|||
tag:=i;
|
|||
left:= imgGrafico.left+izquierdo+4;
|
|||
top:=imgGrafico.top + arriba+4;
|
|||
visible:=false;
|
|||
end;
|
|||
for i:=0 to 5 do
|
|||
begin
|
|||
lblOpcion[i]:=Tlabel.create(self);
|
|||
with lblOpcion[i] do
|
|||
begin
|
|||
font.name:='Sans';
|
|||
font.size:=11;
|
|||
width:=ancho-50;
|
|||
height:=42;
|
|||
autosize:=false;
|
|||
color:=clwhite;
|
|||
WordWrap:=true;
|
|||
Caption:='Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es una prueba,Esto es u u u prueba,Esto es una prueba,Esto es una prueba,Esto';
|
|||
transparent:=true;
|
|||
Parent:=pnEcuesta;
|
|||
tag:=i;
|
|||
left:= imgGrafico.left+74;
|
|||
top:=imgGrafico.top+119+altocuestion*i;
|
|||
visible:=false;
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestaPintarCuadros(ima: TBitmap;numopc:integer);
|
|||
const
|
|||
arriba:integer=40;
|
|||
alto:integer=70;
|
|||
altocuestion:integer=60;
|
|||
var
|
|||
izquierdo,ancho,i:integer;
|
|||
begin
|
|||
ancho:=imgGrafico.width -60;
|
|||
izquierdo:=30;
|
|||
with ima.Canvas do
|
|||
begin
|
|||
Font.Color:=MORADO_COLOR;
|
|||
Font.Name:='Sans';
|
|||
Font.Size:=12;
|
|||
pen.color:=AZUL_COLOR;
|
|||
brush.color:=clwhite;
|
|||
pen.Width:=1;
|
|||
Rectangle(izquierdo,arriba,izquierdo+ancho, arriba+alto);
|
|||
TextOut(izquierdo, arriba-18, 'Pregunta');
|
|||
for i:=0 to numopc-1 do
|
|||
begin
|
|||
EllipseC(izquierdo+15,140 +altocuestion*i,15,15);
|
|||
TextOut(izquierdo+10,132 +altocuestion*i,inttostr(i+1));
|
|||
Rectangle(izquierdo+40,115+altocuestion*i,izquierdo+ancho,165+altocuestion*i);
|
|||
end;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.EncuestaMostrar();
|
|||
var
|
|||
mbitmap:TBitmap;
|
|||
begin
|
|||
mbitmap:=TBitmap.create;
|
|||
try
|
|||
mbitmap.Width:=imgGrafico.Width;
|
|||
mbitmap.Height:=imgGrafico.Height;
|
|||
EstadisticaPintarFondo(mbitmap,'','Base');
|
|||
EncuestaPintarCuadros(mbitmap,g_cuestion.numOpciones);
|
|||
imgGrafico.Picture.Bitmap.Assign(mbitmap);
|
|||
finally
|
|||
mbitmap.free;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.btnEnviarClick(Sender: TObject);
|
|||
begin
|
|||
EnviarConsulta();
|
|||
lblMenTiempo.caption:='Recogiendo respuestas. Espere, por favor.';
|
|||
lblMenTiempo.visible:=true;
|
|||
lblTiempo2.visible:=true;
|
|||
end;
|
|||
procedure TfrmEncuesta.btnIndividualClick(Sender: TObject);
|
|||
begin
|
|||
IndividualMostrarEstadisticas();
|
|||
end;
|
|||
procedure TfrmEncuesta.btnResultadosClick(Sender: TObject);
|
|||
begin
|
|||
ResultadosEstadisticas(g_cuestion.numaciertos,g_cuestion.numfallos,g_cuestion.numBlancos);
|
|||
end;
|
|||
procedure TfrmEncuesta.btnOpcionesClick(Sender: TObject);
|
|||
begin
|
|||
OpcionesMostrarEstadisticas1(f_respuestas_recibidas);
|
|||
//OpcionesMostrarEstadisticas();
|
|||
end;
|
|||
procedure TfrmEncuesta.btnCerrarCuestionClick(Sender: TObject);
|
|||
begin
|
|||
if f_consulta_enviada then
|
|||
if Mensaje('Hay una encuesta activa.Se perderá¿Desea salir',sino)=2 then exit;
|
|||
btnIndividual.Enabled:=false;
|
|||
btnOpciones.Enabled:=false;
|
|||
btnResultados.Enabled:=false;
|
|||
bchOpciones.visible:=false;
|
|||
pnEcuesta.visible:=false;
|
|||
Application.ProcessMessages;
|
|||
if idCMDTCPServer1.Active=false then
|
|||
idCMDTCPServer1.Active:=true;
|
|||
close;
|
|||
end;
|
|||
procedure TfrmEncuesta.bitPruebaClick(Sender: TObject);
|
|||
var
|
|||
stream:TStringList;
|
|||
begin
|
|||
stream:=TStringList.create;
|
|||
try
|
|||
BuscaFicheros(equipoProfesor.DirCuestiones,'*.txt',stream,true);
|
|||
if stream.Count>0 then
|
|||
begin
|
|||
cboCuestion.items.Assign(stream);
|
|||
cboCuestion.visible:=true;
|
|||
//cbo;
|
|||
end
|
|||
else
|
|||
Mensaje('No hay consultas disponibles. Cree una desde la pantalla cuestiones',aceptar);
|
|||
finally
|
|||
stream.free;
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.FormCreate(Sender: TObject);
|
|||
Const
|
|||
TOPPANSIN:integer=22; LEFPANSIN:integer=23;WHIPANSIN:integer=977;HEIPANSIN:integer=660;
|
|||
begin
|
|||
setlength(g_cuestion.mejoresalumnos,g_num_ord_aula+1);
|
|||
setlength(g_cuestion.mejorestiempos,g_num_ord_aula+1);
|
|||
setlength(g_cuestion.mejoresequipos,g_num_ord_aula+1);
|
|||
setlength(g_cuestion.mejoresrespuestas,g_num_ord_aula);
|
|||
EncuestasCrearLabels();
|
|||
SetBounds(LEFPANSIN,TOPPANSIN,WHIPANSIN,HEIPANSIN);
|
|||
if not EncuestaLeerArchivo(equipoProfesor.ArcCuestion) then
|
|||
begin
|
|||
close;
|
|||
exit;
|
|||
end;
|
|||
//BorderStyle:=bsnone;
|
|||
EncuestaMostrar();
|
|||
pnEcuesta.visible:=true;
|
|||
end;
|
|||
procedure TfrmEncuesta.pnEcuestaClick(Sender: TObject);
|
|||
begin
|
|||
end;
|
|||
procedure TfrmEncuesta.tmrMensajeTimer(Sender: TObject);
|
|||
begin
|
|||
f_contador_mensaje:=f_contador_mensaje-1;
|
|||
lblTiempo2.caption:=Tiempo(f_contador_mensaje);
|
|||
if f_contador_mensaje<=0 then
|
|||
begin
|
|||
tmrMensaje.enabled:=false;
|
|||
lblMenTiempo.Caption:='Organizando resultados, espere unos segundos, por favor.'
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.tmrRecogidaTimer(Sender: TObject);
|
|||
var
|
|||
i:integer;
|
|||
todasrrecogidas:Boolean;
|
|||
begin
|
|||
todasrrecogidas:=true;
|
|||
f_contador:=f_contador-1;
|
|||
for i:=0 to high(equipoalumno) do
|
|||
if equipoalumno[i].Respuesta=-2 then
|
|||
todasrrecogidas:=false;
|
|||
if todasrrecogidas or (f_contador<=0) then
|
|||
begin
|
|||
lblMenTiempo.Caption:='Organizando resultados, espere unos segundos, por favor.';
|
|||
tmrMensaje.enabled:=false;
|
|||
tmrRecogida.enabled:=false;
|
|||
for i:=0 to High(equipoalumno) do
|
|||
if equipoalumno[i].Respuesta=-2 then
|
|||
begin
|
|||
f_respuestas_recibidas[0]:= f_respuestas_recibidas[0]+1;
|
|||
equipoalumno[i].Respuesta:=0;
|
|||
equipoAlumno[i].TiempoRespuesta:=g_cuestion.tiempo;
|
|||
end;
|
|||
Estadisticas();
|
|||
end;
|
|||
end;
|
|||
procedure TfrmEncuesta.DrawPieSlice(myB: TBitmap; const bcolor, pcolor:Tcolor; CONST Center: TPoint; CONST Radius: INTEGER; CONST StartDegrees, StopDegrees: Double);
|
|||
const
|
|||
Offset = 0; // to make 0 degrees start to the right
|
|||
var
|
|||
X1,X2,X3,X4: INTEGER;
|
|||
Y1,Y2,Y3,Y4: INTEGER;
|
|||
begin
|
|||
X1 := Center.X - Radius;
|
|||
Y1 := Center.Y - Radius;
|
|||
X2 := Center.X + Radius;
|
|||
Y2 := Center.Y + Radius;
|
|||
// negative signs on "Y" values to correct for "flip" from normal
|
|||
// math defintion for "Y" dimension
|
|||
X3 := Center.X + Round( Radius*COS( DegToRad(Offset+StartDegrees) ) );
|
|||
Y3 := Center.y - Round( Radius*SIN( DegToRad(Offset+StartDegrees) ) );
|
|||
X4 := Center.X + Round( Radius*COS( DegToRad(Offset+StopDegrees) ) );
|
|||
Y4 := Center.y - Round( Radius*SIN( DegToRad(Offset+StopDegrees) ) );
|
|||
with myb.Canvas do
|
|||
begin
|
|||
pen.width:=1;
|
|||
Brush.color:=bcolor;
|
|||
pen.Color:=pcolor;
|
|||
Pie(X1,Y1, X2,Y2, X3,Y3, X4,Y4);
|
|||
end;
|
|||
end;
|
|||
Procedure TfrmEncuesta.EstadisticaPintarFondo(img:TBitmap;Titulo,base:String);
|
|||
var
|
|||
i:integer;
|
|||
begin
|
|||
with img.Canvas do
|
|||
begin
|
|||
pen.color:=clwhite;
|
|||
brush.color:=clwhite;
|
|||
Rectangle(0,0,img.width,img.Height);
|
|||
pen.color:=$E5E5E5;
|
|||
brush.color:=$E5E5E5;
|
|||
Rectangle(5,0,img.width,img.Height-5);
|
|||
pen.color:=clsilver;
|
|||
brush.color:=clwhite;
|
|||
Rectangle(0,3,img.width-3,img.Height);
|
|||
Font.Color:=clBlack;
|
|||
//Rectangle(350,30,350+ancho,30+alto);
|
|||
Font.Name:='Sans';
|
|||
Font.Size:=8;
|
|||
TextOut(150,5,Titulo);
|
|||
end;
|
|||
end;
|
|||
initialization
|
|||
{$I encuesta.lrs}
|
|||
end.
|