El archivo conf_eval.php, es en donde genero en forma dinamica un formulario que contiene una tabla con evaluaciones.
Las evaluaciones pueden ser "Certamenes, Test, Cuestionario, Disertacion, Proyecto, Tarea, Investigacion". Dentro de cada tipo de evaluacion pueden haber N evaluaciones, es decir, puedo tener 3 Certamenes, 5 Test, 1 Cuestionario, etc.
Genero tantos casilleros como evaluaciones existan, y en cada casillero voy a escribir un numero que representa el porcentaje de ponderación respecto de la nota final.
Cuando cargo el archivo conf_eval.php almaceno en un arreglo los identificadores de cada evaluacion, de forma de poder saber de que tipo es y a que curso pertenece.
Hasta el momento esta todo bien, genero los casilleros de texto necesarios para cada tipo de evaluacion y para cada cantidad de evalaciones.
Mi problema es el sgte:
Como logro relacionar cada casillero de texto con su respectiva evalacion, de forma de que, por ejemplo, el casillero cert1 corresponda realmente a la ponderacion para el certamen 1. Supongamos que el Certamen 1 tiene un id = 5, necesito almacenar "cert1 y el valor del text y tambien el id =5"
Aca esta el codigo:
Código PHP:
require "../include/global_login.php";
require "../include/colors.php";
$eval=explode(",",$id_eval);
//eval es un array en donde tengo los id de cada evaluacion
$maximo=0;
$cc=0;$tt=0;$cues=0;$diser=0;$proy=0;$tar=0;$inv=0;
$certamen=0;$test=0;$cuestionario=0;$disertacion=0;$proyecto=0;$tarea=0;$investigacion=0;
$consulta=mysql_query("select id_eval,id_tipo,id_curso from evaluaciones where id_curso='".$curso."'");
$total_eval=mysql_num_rows($consulta);
while($row=mysql_fetch_array($consulta))
{
if($row["id_tipo"]==1){
$certamen=$certamen+1;
$cc=1;
if($certamen>$maximo)
$maximo=$certamen;
}
if($row["id_tipo"]==2){
$test=$test+1;
$tt=1;
if($test>$maximo)
$maximo=$test;
}
if($row["id_tipo"]==3){
$cuestionario=$cuestionario+1;
$cues=1;
if($cuestionario>$maximo)
$maximo=$cuestionario;
}
if($row["id_tipo"]==4){
$disertacion=$disertacion+1;
$diser=1;
if($disertacion>$maximo)
$maximo=$disertacion;
}
if($row["id_tipo"]==5){
$proyecto=$proyecto+1;
$proy=1;
if($proyecto>$maximo)
$maximo=$proyecto;
}
if($row["id_tipo"]==6){
$tarea=$tarea+1;
$tar=1;
if($tarea>$maximo)
$maximo=$tarea;
}
if($row["id_tipo"]==7){
$investigacion=$investigacion+1;
$inv=1;
if($investigacion>$maximo)
$maximo=$investigacion;
}
}
//total_text variable para saber cuantos text box debo crear
$total_text=$certamen+$test+$cuestionario+$disertacion+$proyecto+$tarea+$investigacion+$cc+$tt+$cues+$diser+$proy+$tar+$inv;
echo "Total Text Box ==>:"; echo $total_text;echo "<br>";
echo "Maximo ==>:"; echo $maximo;
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../estilos.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
function sumar(){
maximo=100;
total=0;
bb=b;
for(a=0;a<<? echo $total_text; ?>;a++){
document.forms[0].elements[a].value=document.forms[0].elements[a].value.split(",").join(".");
if (!isNaN(document.forms[0].elements[a].value)){
pepe=new Number(document.forms[0].elements[a].value);
total=total+pepe;
if(total>maximo)
{alert("El Valor sobrepasa el maximo permitido");
return;
}
else{
document.forms[0].elements["total"].value=total;
}
}
else{document.forms[0].elements[a].value=0}
}
}
}
//-->
</script>
</head>
<body>
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr bgcolor="#5c60a5">
<td height="18" class="mainwhite"> <table width="100%" border="0" cellspacing="0" background="../images/fonditoforotop.gif">
<tr>
<td width="91%" class="titulo"><img src="../images/recursosgr.gif" width="50" height="50">Informacion
de Evaluaciones</td>
<td width="9%" valign="top"><div align="right"><a href="javascript:history.go(-1)" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','../images/forotopizout.gif',1)"><img src="../images/forotopiz.gif" alt="Volver..." name="Image3" width="99" height="50" border="0"></a></div></td>
</tr>
</table>
<p> <img src="../images/fl.gif" width="5" height="10" alt="" border="0">
<b class="foroplat">Configuracion de Evaluaciones</b></p></td>
<td class="mainwhite"> </td>
<td class="mainwhite"> </td>
<td width="1%" valign="top" class="mainwhite"> <div align="right"><img src="../images/esqizsup.gif" width="18" height="18"></div></td>
</tr>
<tr bgcolor="#A8EAFF">
<td height="18" colspan="4" class="mainwhite"> </td>
</tr>
</table>
<p class="titulo">Usted tiene <? echo $total_eval;?> evaluaciones en este curso
</p>
<form name="form1" method="post" action="grabar_conf.php">
<table width="36%" border="1">
<tr class="numeros">
<td width="10%">Cantidad</td>
<td width="90%" class="numeros">Tipo de Evaluacion</td>
<? for ($k=1;$k<=$maximo;$k++)
{
?> <td width="90%"> <? echo "Eval. nº";echo " ";echo $k;echo "</td>";
} ?>
<td width="90%">Total Por Eval</td>
</tr>
<tr class="menux">
<td><? echo $certamen;?></td>
<td>Certamenes</td>
<? if ($certamen>0){
for($j=0;$j<=$maximo;$j++)
{
if($j<$certamen){ ?>
<td><input name="cert<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="cert_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
<tr class="menux">
<td><? echo $test;?></td>
<td>Test</td>
<? if ($test>0) {
for($j=0;$j<=$maximo;$j++)
{
if($j<$test){?>
<td><input name="test<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{ ?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="test_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
<tr class="menux">
<td><? echo $cuestionario;?></td>
<td>Cuestionarios</td>
<? if ($cuestionario>0) {
for($j=0;$j<=$maximo;$j++)
{
if($j<$cuestionario){
echo "<td>";?> <input name="cuestionario<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="cuestionario_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
<tr class="menux">
<td><? echo $disertacion;?></td>
<td>Disertaciones</td>
<? if ($disertacion>0) {
for($j=0;$j<=$maximo;$j++)
{
if($j<$disertacion){
echo "<td>";?> <input name="disertacion<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{ ?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="disertacion_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
<tr class="menux">
<td><? echo $proyecto;?></td>
<td>Proyectos</td>
<? if ($proyecto>0) {
for($j=0;$j<=$maximo;$j++)
{
if($j<$proyecto){
echo "<td>";?> <input name="proyecto<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="proyecto_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
<tr class="menux">
<td><? echo $tarea;?></td>
<td>Tareas</td>
<? if ($tarea>0) {
for($j=0;$j<=$maximo;$j++)
{
if($j<$tarea){
echo "<td>";?> <input name="tarea<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{ ?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="tarea_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
<tr class="menux">
<td><? echo $investigacion;?></td>
<td>Investigaciones</td>
<? if ($investigacion>0) {
for($j=0;$j<=$maximo;$j++)
{
if($j<$investigacion){
echo "<td>";?> <input name="investigacion<? echo $j;?>" type="text" value="" size="3" maxlength="3"></td>
<? }
else
{ ?>
<td> </td>
<? }
if ($j==$maximo)
{?>
<td><input name="investigacion_total" type="text" size="3" maxlength="3" onkeyup=sumar()></td>
<? }
}
}
?>
</tr>
</table>
<p class="titulo"> Total %
<input name="total" type="text" size="3" maxlength="3" readonly>
</p>
<p class="titulo">
<input name="enviar" type="submit" id="enviar" value="Envar">
<input type="reset" name="Reset" value="Limpiar">
</p>
</form>
</body>
</html>
Salu2