-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathexamenes.php
executable file
·502 lines (382 loc) · 20.7 KB
/
examenes.php
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<?php # POL.VirtualPol.com — Copyright (c) 2008 Javier González González <gonzo@virtualpol.com> — MIT License
function boton_cargo($value, $url, $cargo) {
$text = '';
if ($url) { $val = ' type="button" onclick="window.location.href=\'' . $url . '\';"'; }
else { $val = ' type="submit"'; }
if ($cargo) {
global $pol, $vp;
if (($cargo == 35) AND (nucleo_acceso($vp['acceso']['examenes_decano']))) { }
elseif (($cargo == 34) AND ((nucleo_acceso($vp['acceso']['examenes_profesor'])) OR (nucleo_acceso($vp['acceso']['examenes_decano'])))) { }
else { $val .= ' disabled="disabled"'; }
if ($cargo == 35) { $text = 'Decano'; }
elseif ($cargo == 34) { $text = 'Profesor'; }
}
return '<span class="amarillo"><input' . $val . ' value="' . $value . '" /> '._('Cargo requerido').': <em>' . $text . '</em></span>';
}
function shuffle_assoc($input_array){
foreach($input_array as $key => $value){
$temp_array[$value]['key'] = $key;
}
shuffle($input_array);
foreach($input_array as $key => $value){
$return_array[$temp_array[$value]['key']] = $value;
}
return $return_array;
}
// carga config
$result = mysql_query_old("SELECT valor, dato FROM config WHERE pais = '".PAIS."' AND autoload = 'no'", $link);
while ($r = mysqli_fetch_array($result)) { $pol['config'][$r['dato']] = $r['valor']; }
// INIT
if (($_GET[1] == 'editar') AND (((nucleo_acceso($vp['acceso']['examenes_decano'])) OR (nucleo_acceso($vp['acceso']['examenes_profesor']))) AND ($pol['estado'] == 'ciudadano'))) { // EDITAR
if (!$_GET[2]) { $_GET[2] = 0; }
$result = mysql_query_old("SELECT ID, user_ID, examen_ID
FROM examenes_profesores WHERE user_ID = '".$pol['user_ID']."' AND examen_ID = '".$_GET[2]."'", $link);
$acceso_profesor = false;
while ($r = mysqli_fetch_array($result)) {
$acceso_profesor = true;
}
if ((!nucleo_acceso($vp['acceso']['examenes_decano'])) AND (!$acceso_profesor)){
echo 'No tiene permiso para acceder a este examen.';
return;
}
$result = mysql_query_old("SELECT ID, titulo, descripcion, user_ID, time, nota, num_preguntas, COALESCE((SELECT id FROM cargos WHERE id = examenes.cargo_ID), '-1') as cargo_ID
FROM examenes
WHERE pais = '".PAIS."' AND ID = '".$_GET[2]."'
LIMIT 1", $link);
while($r = mysqli_fetch_array($result)){
$txt_title = _('Editar examen');
$txt_nav = array('/examenes'=>_('Exámenes'), _('Editar examen').': '.$r['titulo']);
$txt_tab = array('/cargos'=>_('Cargos'));
echo '
<h2>'._('Añadir pregunta').':</h2>
<div id="edit">
<form action="/accion/examenes/nueva-pregunta?ID='.$_GET[2].'" method="post">
<ol>
<li><b>'._('Pregunta').':</b> ('._('máximo').' 200 '._('caracteres').')<b><br />
¿<input type="text" name="pregunta" autocomplete="off" size="50" maxlength="200" />?</b></li>
<li><b>'._('Respuestas').':</b> ('._('entre').' 2 '._('y').' 4 '._('respuestas').', '._('máximo').' 100 '._('caracteres').')<br />
<input type="text" name="respuesta0" size="35" maxlength="100" autocomplete="off" style="border:2px solid grey;" /> <b>(Correcta)</b><br />
<input type="text" name="respuesta1" size="35" maxlength="100" autocomplete="off" /><br />
<input type="text" name="respuesta2" size="35" maxlength="100" autocomplete="off" /><br />
<input type="text" name="respuesta3" size="35" maxlength="100" autocomplete="off" /></li>
<li><b>'._('Tiempo para responder').':</b> <input type="text" name="tiempo" value="10" size="1" maxlength="3" style="text-align:right;" /> '._('segundos').'</li>
<li>'.boton_cargo(_('Añadir pregunta'), false, 34).'</li>
</ol>
</form>
<hr />
<h2>'._('Preguntas').':</h2>
<ol id="lista">';
$result2 = mysql_query_old("SELECT ID, examen_ID, user_ID, pregunta, respuestas, tiempo,
(SELECT nick FROM users WHERE ID = examenes_preg.user_ID LIMIT 1) AS nick
FROM examenes_preg
WHERE pais = '".PAIS."' AND examen_ID = '".$_GET[2]."'
ORDER BY time DESC", $link);
while($r2 = mysqli_fetch_array($result2)){
$respuestas = '';
$res = explode("|", $r2['respuestas']);
foreach($res as $ID => $respuesta) {
$respuestas .= '<option value="' . $ID . '">' . $respuesta . '</option>';
}
if ((nucleo_acceso($vp['acceso']['examenes_decano'])) OR ((nucleo_acceso($vp['acceso']['examenes_profesor'])) AND ($r2['user_ID'] == $pol['user_ID']))) { $boton = boton('x', '/accion/examenes/eliminar-pregunta?ID=' . $r2['ID'] . '&re_ID=' . $r['ID'], '¿Seguro que quieres ELIMINAR esta pregunta y sus respuestas?', 'small red'); } else { $boton = ''; }
echo '<li>¿'.$r2['pregunta'].'? ('.$r2['tiempo'].' seg)<br /><select name="p" style="width:60px;"><option value=""></option>'.$respuestas.'</select> '.$boton.' '.crear_link($r2['nick']).'</li>';
}
echo '</ol>';
if ($_GET[2] != 0) {
if (substr($r['cargo_ID'], 0, 1) != '-') { $readonly = ' readonly="readonly"'; } else { $readonly = ''; }
echo '<hr />
<h2>'._('Editar examen').':</h2>
<form action="/accion/examenes/editar-examen?ID=' . $r['ID'] . '" method="post">
<ol>
<li><b>'._('Titulo del examen').':</b> <input type="text" name="titulo" size="15" maxlength="30" value="' . $r['titulo'] . '"' . $readonly . ' /></li>
<li><b>'._('Temario').':</b> '._('descripción breve y precisa').' <span style="color: red">Campo requerido</span><br />
<textarea name="descripcion" style="color: green; font-weight: bold; width: 570px; height: 100px;">' . strip_tags($r['descripcion']) . '</textarea></li>
<li><b>'._('Nota para aprobar').':</b> <input type="text" name="nota" size="3" maxlength="4" value="' . $r['nota'] . '" style="text-align:right;" /></li>
<li><b>'._('Extensión').':</b> <input type="text" name="num_preguntas" size="3" maxlength="4" value="' . $r['num_preguntas'] . '" style="text-align:right;" /> '._('preguntas').'</li>
<li>'.boton_cargo(_('Editar examen'), false, 35).'</li>
</ol>
</form>';
if ((nucleo_acceso($vp['acceso']['examenes_decano'])) AND ($r['cargo_ID'] < 0)) {
$profesor_acceso = usuarios_con_privilegio('examenes_profesor');
$txt .='<hr />
<form action="/accion/examenes/anadir-acceso-profesor" method="post">
<a name="profesor"></a><span>Profesores con acceso a este examen</span>
<ul>';
error_log("SELECT e.user_ID as user_ID, u.nick as nick
FROM examenes_profesores e, users u WHERE u.ID = e.user_ID AND e.examen_ID = '".$_GET[2]."'");
$result = mysql_query_old("SELECT e.user_ID as user_ID, u.nick as nick
FROM examenes_profesores e, users u WHERE u.ID = e.user_ID AND e.examen_ID = '".$_GET[2]."'", $link);
$profesores_asociados = array();
while ($r = mysqli_fetch_array($result)) {
$txt .='<li>'.$r['nick'].' '.boton("Eliminar acceso", '/accion/examenes/eliminar-acceso-profesor/'.$_GET[2].'/'.$r['user_ID']);
$profesores_asociados[] = $r['nick'];
}
$txt .='</ul>
<span>Seleccione los profesores que tendrán acceso a este examen</span>
<select name="profesor" id="profesor">';
foreach ($profesor_acceso as $profesor){
if (!in_array($profesor, $profesores_asociados)){
$txt .='<option value="'.$profesor.'">'.$profesor.'</option>';
}
}
$txt .='</select>
<input type="hidden" name="ID" value="' . $_GET[2] . '" />
<input type="submit" value="'._('Otorgar acceso').'"/>
</form>';
$result3 = mysql_query_old("SELECT (SELECT COUNT(*) FROM examenes_preg WHERE pais = '".PAIS."' AND examen_ID = examenes.ID LIMIT 1) AS num_depreguntas
FROM examenes WHERE pais = '".PAIS."' AND ID = '" . $_GET[2] . "' LIMIT 1", $link);
while($r3 = mysqli_fetch_array($result3)){
if ($r3['num_depreguntas'] == 0) {
$txt .='<hr />
<form action="/accion/examenes/eliminar-examen" method="post">
<input type="hidden" name="ID" value="' . $_GET[2] . '" />
<input type="submit" value="'._('Eliminar examen').'"/>
</form>';
}
}
}
}
echo $txt.'</div>';
$txt_header .= '
<style type="text/css">
#edit li { margin:0 0 10px 0; }
#lista li { margin:0 0 0 0; }
</style>
';
}
} elseif (($_GET[1] == 'mis-examenes') AND ($pol['estado'] == 'ciudadano')) { // MIS EXAMENES
// load config full
$result = mysql_query_old("SELECT valor, dato FROM config WHERE pais = '".PAIS."' AND autoload = 'no'", $link);
while ($r = mysqli_fetch_array($result)) { $pol['config'][$r['dato']] = $r['valor']; }
$txt_title = _('Mis exámenes');
$txt_nav = array('/examenes'=>_('Exámenes'), _('Mis exámenes'));
$txt_tab = array('/cargos'=>_('Cargos'));
echo '<table border="0" cellspacing="0" cellpadding="2">
<tr>
<th></th>
<th>'._('Nota').'</th>
<th>'._('Examen').'</th>
<th></th>
<th>'._('Hace').'</th>
</tr>';
$result = mysql_query_old("SELECT cargo_ID, user_ID, time, aprobado, cargo, nota,
(SELECT titulo FROM examenes WHERE pais = '".PAIS."' AND cargo_ID = cargos_users.cargo_ID LIMIT 1) AS nombre_examen,
(SELECT ID FROM examenes WHERE pais = '".PAIS."' AND cargo_ID = cargos_users.cargo_ID LIMIT 1) AS examen_ID
FROM cargos_users
WHERE user_ID = '" . $pol['user_ID'] . "'
ORDER BY aprobado ASC, nota DESC", $link);
while($r = mysqli_fetch_array($result)){
if ($r['aprobado'] == 'ok') { $sello = '<img src="'.IMG.'varios/estudiado.gif" alt="Aprobado" title="Aprobado" border="0" />'; } else { $sello = ''; }
if ($r['cargo'] == 'true') { $cargo = '('._('Cargo ejercido').')'; } else { $cargo = ''; }
if (($r['cargo_ID'] <= 0) AND (time()-strtotime($r['time']) > $pol['config']['examen_repe']*6)) {
$caducar_examen = ' <form action="/accion/examenes/caducar_examen?ID='.$r['cargo_ID'].'" method="POST"><input type="hidden" name="pais" value="'.$pol['pais'].'" /><input type="submit" value="X" onclick="if (!confirm(\'¿Seguro que quieres que CADUQUE el examen de ' . $r['nombre_examen'] . '?\')) { return false; }"/></form>';
} else { $caducar_examen = ''; }
echo '<tr><td>' . $sello . '</td><td align="right"><b style="color:grey;">' . $r['nota'] . '</b></td><td><a href="/examenes/' . $r['examen_ID'] . '"><b>' . $r['nombre_examen'] . '</b></a></td><td>' . $cargo . '</td><td align="right"><acronym title="' . $r['time'] . '">' . duracion(time() - strtotime($r['time'])) . '</acronym></td><td><b>'. $caducar_examen .'</b></td></tr>';
}
echo '</table>';
} elseif (($_GET[1] == 'crear') AND ($pol['estado'] == 'ciudadano')) { // CREAR NUEVA
echo '<h1><a href="/examenes/">Examenes</a>: '._('Crear examen').'</h1>
<form action="/accion/examenes/crear" method="post">
<ol>
<li><b>'._('Examen').':</b> <input type="text" name="titulo" size="15" maxlength="30" /><br /><br /></li>
<li>' . boton_cargo(_('Crear examen'), false, 35) . '</li>
</ol>
</form>';
} elseif (($_GET[1] == 'examen') AND ($_GET[2]) AND ($_GET[2] != 0) AND ($pol['estado'] == 'ciudadano')) {
// HACER EXAMEN
$result = mysql_query_old("SELECT ID, titulo, user_ID, time, cargo_ID, nota, num_preguntas,
(SELECT time FROM cargos_users WHERE pais = '".PAIS."' AND cargo_ID = examenes.cargo_ID AND user_ID = '" . $pol['user_ID'] . "' LIMIT 1) AS fecha_ultimoexamen,
(SELECT COUNT(*) FROM examenes_preg WHERE pais = '".PAIS."' AND examen_ID = examenes.ID LIMIT 1) AS num_preguntas_especificas,
(SELECT COUNT(*) FROM examenes_preg WHERE pais = '".PAIS."' AND examen_ID = 0 LIMIT 1) AS num_preguntas_generales
FROM examenes
WHERE pais = '".PAIS."' AND ID = '".$_GET[2]."'
LIMIT 1", $link);
while($r = mysqli_fetch_array($result)){
$preguntas_disponibles = $r['num_preguntas_especificas'] + $r['num_preguntas_generales'];
$margen_ultimoexamen = strtotime($r['fecha_ultimoexamen']) + $pol['config']['examen_repe'];
if (((!$r['fecha_ultimoexamen']) OR ($margen_ultimoexamen < time())) AND ($pol['pols'] >= $pol['config']['pols_examen'])) {
// marca examen como hecho
if ($r['fecha_ultimoexamen']) {
//update
mysql_query_old("UPDATE cargos_users SET time = '" . $date . "', nota = 0.0, aprobado = 'no' WHERE cargo_ID = '" . $r['cargo_ID'] . "' AND user_ID = '" . $pol['user_ID'] . "' LIMIT 1", $link);
} else {
//insert
mysql_query_old("INSERT INTO cargos_users
(cargo_ID, pais, user_ID, time, aprobado, nota)
VALUES ('" . $r['cargo_ID'] . "', '".PAIS."', '" . $pol['user_ID'] . "', '" . $date . "', 'no', '0.0')", $link);
}
// Cobrar examen
if ($pol['config']['pols_examen'] != '0') {
pols_transferir($pol['config']['pols_examen'], $pol['user_ID'], '-1', _('Examen').': ' . $r['titulo']);
}
// EMPIEZA EXAMEN
$txt_title = _('Examen');
$txt_nav = array('/examenes'=>_('Exámenes'), $r['titulo']);
echo '<p>'._('Tienes').' <b><span class="seg"></span></b> '._('segundos').'.</p>
<table id="latabla" border="0">
<tr>
<td style="background:red;" id="t_mas" width="12" height="1"></td>
<td rowspan="2">
<div id="examen">
<form action="/accion/examenes/examinar?ID='.$_GET[2].'" method="post" id="elexamen">
<ol>';
$examen_tiempo = 0;
$respuestas_correctas = array();
$result2 = mysql_query_old("SELECT ID, examen_ID, user_ID, time, pregunta, respuestas, tiempo
FROM examenes_preg
WHERE pais = '".PAIS."' AND (examen_ID = '" . $_GET[2] . "' OR examen_ID = 0)
ORDER BY examen_ID DESC, RAND() LIMIT ".$r['num_preguntas'], $link);
echo mysqli_error($link);
while($r2 = mysqli_fetch_array($result2)){
$respuestas = '';
$res2 = [];
$res = explode("|", $r2['respuestas']);
$res2['a'] = $res[0];
$respuestas_correctas[] = md5($res[0]);
$res2['b'] = $res[1];
if ($res[2]) { $res2['c'] = $res[2]; }
if ($res[3]) { $res2['d'] = $res[3]; }
$res2 = shuffle_assoc($res2);
$examen_tiempo += $r2['tiempo'];
foreach($res2 as $ID => $respuesta) {
$respuestas .= '<input type="radio" name="respuesta'.$r2['ID'].'" value="'.md5($respuesta).'" id="respuesta'.$r2['ID'].'_'.md5($respuesta).'" /><label for="respuesta'.$r2['ID'].'_'.md5($respuesta).'">'.$respuesta.'</label><br />';
}
if ($pregs) { $pregs .= '|'; } $pregs .= $r2['ID'];
echo '<li><b>¿' . $r2['pregunta'] . '?</b><br />' . $respuestas . '</li>';
}
$examen_tiempo += 60;
$limite_tiempo = time() + $examen_tiempo;
$_SESSION['examen']['respuestas'] = $respuestas_correctas;
$_SESSION['examen']['tiempo'] = $limite_tiempo;
$_SESSION['examen']['ID'] = $_GET[2];
echo '</ol>
<input type="hidden" name="pregs" value="' . $pregs . '" />
<input type="hidden" name="tlgs" value="' . $limite_tiempo . '" />
</div>
</td>
</tr>
<tr>
<td style="background:blue;" id="t_menos"></td>
</tr>
</table>
<p>'.boton(_('Terminar examen'), 'submit', false, 'large blue').' '._('Tienes').' <b><span class="seg"></span></b> '._('segundos').'.</p>
</form>
';
$txt_header .= '
<style type="text/css">
.seg { font-size:22px; }
#examen li { margin:0 0 10px 0; }
</style>
<script type="text/javascript">
examen_tiempo = parseInt("' . $examen_tiempo . '");
examen_tiempo_total = parseInt("' . $examen_tiempo . '");
function time_refresh() {
if (examen_tiempo > 0) {
$(".seg").html(examen_tiempo);
examen_tiempo = examen_tiempo - 1;
examen_refresh = setTimeout(time_refresh, 1000);
var t = parseInt(examen_tiempo_total) - parseInt(examen_tiempo);
var porcentaje_mas = Math.floor((t * parseInt($("#latabla").height())) / parseInt(examen_tiempo_total));
$("#t_mas").attr("height", porcentaje_mas);
} else { $("#elexamen").submit(); }
}
window.onload = function(){
$(".seg").html(examen_tiempo);
examen_refresh = setTimeout(time_refresh, 1000);
}
</script>';
} else { redirect('/examenes/'.$r['ID']); }
}
} elseif (($_GET[1]) AND ($_GET[1] != 0)) { // VER EXAMEN
$result = mysql_query_old("SELECT ID, titulo, descripcion, user_ID, time, cargo_ID, nota, num_preguntas,
(SELECT COUNT(*) FROM examenes_preg WHERE pais = '".PAIS."' AND examen_ID = examenes.ID LIMIT 1) AS num_preguntas_especificas,
(SELECT time FROM cargos_users WHERE cargo_ID = examenes.cargo_ID AND user_ID = '" . $pol['user_ID'] . "' LIMIT 1) AS fecha_ultimoexamen
FROM examenes
WHERE pais = '".PAIS."' AND ID = '" . $_GET[1] . "'
LIMIT 1", $link);
while($r = mysqli_fetch_array($result)){
$txt_title = _('Examen').' '._('de').' ' . $r['titulo'];
$txt_nav = array('/examenes'=>_('Exámenes'), $r['titulo']);
$txt_tab = array('/cargos'=>_('Cargos'));
echo '<table border="0" width="100%"><tr><td valign="top" width="60%">
<fieldset><legend>'._('Temario').'</legend>
<p class="rich">'.$r['descripcion'].'</p>
</fieldset>
<p>'._('Nota mínima para aprobar').': <b class="gris">' . $r['nota'] . '</b>. '._('Examen tipo test, tiempo limitado').', <b>' . $r['num_preguntas'] . '</b> '._('preguntas').' '._('de').' '._('entre').' <b>' . $r['num_preguntas_especificas'] . '</b> '._('en').' '._('total').'.</p>
<p>'._('No podrás repetir examen hasta').' <b>' . duracion($pol['config']['examen_repe']) . '</b> '._('después').'. ';
if ($r['cargo_ID'] == 0) {
echo _('Examen sin vinculación con cargo').'.';
} else {
$result2 = mysql_query_old("SELECT nombre FROM cargos WHERE pais = '".PAIS."' AND cargo_ID = '".$r['cargo_ID']."' LIMIT 1", $link);
while($r2 = mysqli_fetch_array($result2)){ echo _('Examen vinculado al cargo').': <a href="/cargos/">' . $r2['nombre'] . '</a>.'; $cargo_nom = $r2['nombre']; }
}
echo '</p>';
$margen_ultimoexamen = strtotime($r['fecha_ultimoexamen']) + $pol['config']['examen_repe'];
if ((!$r['fecha_ultimoexamen']) OR ($margen_ultimoexamen < time())) {
echo '<p>'.boton(_('HACER EXAMEN'), '/examenes/examen/'.$r['ID'], '¿Estás preparado para EXAMINARTE?\n\nSolo podrás intentarlo UNA VEZ cada '.duracion($pol['config']['examen_repe']).'.\n\nSi ejerces el cargo y suspendes lo perderás!', 'large blue', $pol['config']['pols_examen']).' '.($cargo_nom?' [para postularse como candidato a <img src="'.IMG.'cargos/'.$r['cargo_ID'].'.gif" /> <b>'.$cargo_nom.'</b>]':'').'</p>';
} else {
echo '<p><b class="amarillo">'._('No puedes repetir el examen hasta dentro de').' '.duracion($margen_ultimoexamen - time()).'</b></p>';
}
echo '</td><td valign="top" width="40%"></td></tr></table>';
}
} else { // VER LISTA EXAMENES
$txt_title = _('Exámenes');
$txt_nav = array('/examenes'=>_('Exámenes'));
$txt_tab = array('/cargos'=>_('Cargos'));
$result = mysql_query_old("SELECT examen_ID FROM examenes_preg WHERE pais = '".PAIS."'", $link);
while($r = mysqli_fetch_array($result)){
if ($r['examen_ID'] == 0) { $num_generales++; } else { $num_especificas++; }
}
if ((nucleo_acceso($vp['acceso']['examenes_decano'])) OR (nucleo_acceso($vp['acceso']['examenes_profesor']))) { $boton = boton(_('Editar'), '/examenes/editar', false, 'small'); }
$boton = '';
echo '
<table border="0" cellspacing="0" cellpadding="2" class="pol_table">
<tr>
<th>'._('Preguntas').'</th>
<th>'._('Notas').'</th>
<th colspan="2">'._('Aprobados').'</th>
<th></th>
<th>'._('Examen').'</th>
<th class="gris">ID</th>
<th></th>
</tr>';
$result = mysql_query_old("SELECT ID, titulo, user_ID, time, cargo_ID, nota, num_preguntas,
(SELECT COUNT(*) FROM examenes_preg WHERE pais = '".PAIS."' AND examen_ID = examenes.ID LIMIT 1) AS num_preguntas_especificas,
(SELECT COUNT(*) FROM cargos_users WHERE pais = '".PAIS."' AND cargo_ID = examenes.cargo_ID) AS examinados,
(SELECT COUNT(*) FROM cargos_users WHERE pais = '".PAIS."' AND cargo_ID = examenes.cargo_ID AND aprobado = 'ok') AS aprobados
FROM examenes
WHERE pais = '".PAIS."' AND ID != 0
ORDER BY nota DESC, num_preguntas_especificas DESC", $link);
while($r = mysqli_fetch_array($result)){
if (substr($r['cargo_ID'], 0, 1) != '-') {
$result2 = mysql_query_old("SELECT nombre FROM cargos WHERE pais = '".PAIS."' AND cargo_ID = '" . $r['cargo_ID'] . "' LIMIT 1", $link);
while($r2 = mysqli_fetch_array($result2)){ $cargo = '<img src="'.IMG.'cargos/' . $r['cargo_ID'] . '.gif" title="' . $r2['nombre'] . '" />'; }
} else { $cargo = ''; }
if ((nucleo_acceso($vp['acceso']['examenes_decano'])) OR (nucleo_acceso($vp['acceso']['examenes_profesor']))) { $boton = boton(_('Editar'), '/examenes/editar/'.$r['ID'], false, 'small'); }
else { $boton = ''; }
if ($r['aprobados'] > 0) {
$aprobados = round(($r['aprobados'] * 100) / $r['examinados']) . '%';
} else { $aprobados = '0%'; }
if ((($r['num_preguntas']+$num_generales) > 0) AND (substr($r['cargo_ID'], 0, 1) == '-')) {
$url = '<a href="/examenes/'.$r['ID'].'"><b>'.$r['titulo'].'</b></a>';
} else {
$url = '<b>'.$r['titulo'].'</b>';
}
echo '<tr>
<td valign="top">' . $r['num_preguntas'] . ' de ' . $r['num_preguntas_especificas'] . '</td>
<td valign="top"><b style="color:grey;">' . $r['nota'] . '</b></td>
<td valign="top" align="right">' . $aprobados . '</td>
<td valign="top" align="right">' . $r['aprobados'] . '</td>
<td valign="top">' . $cargo . '</td>
<td valign="top">' . $url . '</td>
<td valign="top" align="right"class="gris">'.$r['ID'].'</td>
<td valign="top">' . $boton . '</td>
</tr>';
}
echo '</table>';
echo '<p><b class="big">' . ($num_generales + $num_especificas) . '</b> '._('preguntas').': <b>' . $num_especificas . '</b> '._('especificas').' + <b>' . $num_generales . '</b> '._('generales').'</p>';
if (nucleo_acceso($vp['acceso']['examenes_decano'])) { $txt_tab = array('/examenes/crear'=>_('Crear exámen')); }
}
//THEME
if (!$txt_title) { $txt_title = _('Exámenes'); }
$txt_menu = 'demo';
?>