Skip to content

Commit

Permalink
reportes x materia y generales #29
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioviera committed Feb 13, 2020
1 parent 300488d commit faf0437
Show file tree
Hide file tree
Showing 8 changed files with 682 additions and 0 deletions.
113 changes: 113 additions & 0 deletions graficos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,116 @@ FROM survey_2019 s
INNER JOIN ( SELECT i.asignatura_id as asignatura_id, COUNT(1) as total FROM incripciones i WHERE i.anio_academico = 2019 GROUP BY i.asignatura_id ) ss ON a.id = ss.asignatura_id
WHERE s.submitdate is NOT null
GROUP BY a.descripcion, p.nombre, ap.cargo, c.description, a.nivel

-- cantidad de alumnos
2018 -> 1388
2019 -> 897
2018+2019 -> 2285

xinscripciones
2018 -> 1478
2019 -> 905
2018+2019 -> 2383
SELECT i.participant_id, i.anio_academico, count(1)
FROM incripciones i
WHERE i.anio_academico = 2019
GROUP BY 1,2

-- cantidad de alumnos por carrera
SELECT ss.description, count(ss.alumno)
from (SELECT i.participant_id as alumno, c.description
FROM incripciones i
JOIN asignaturas a on i.asignatura_id = a.id
JOIN carreras c on a.carrera_id = c.id
WHERE i.anio_academico = 2019
group by 1) ss
GROUP BY 1

Ingeniería Eléctrica
145
Ingeniería en Sistemas de Información
330
Ingeniería Mecánica
197
Ingeniería Química
232

-- cantidad de alumnos por carrera y nivel
SELECT ss.description, ss.nivel, count(ss.alumno)
from (SELECT i.participant_id as alumno, c.description, a.nivel
FROM incripciones i
JOIN asignaturas a on i.asignatura_id = a.id
JOIN carreras c on a.carrera_id = c.id
WHERE i.anio_academico = 2019
group by 1) ss
GROUP BY 1, 2


"Ingeniería Eléctrica","0","8"
"Ingeniería Eléctrica","1","48"
"Ingeniería Eléctrica","2","30"
"Ingeniería Eléctrica","3","25"
"Ingeniería Eléctrica","4","14"
"Ingeniería Eléctrica","5","20"
"Ingeniería en Sistemas de Información","1","184"
"Ingeniería en Sistemas de Información","2","72"
"Ingeniería en Sistemas de Información","3","36"
"Ingeniería en Sistemas de Información","4","23"
"Ingeniería en Sistemas de Información","5","15"
"Ingeniería Mecánica","0","13"
"Ingeniería Mecánica","1","72"
"Ingeniería Mecánica","2","25"
"Ingeniería Mecánica","3","21"
"Ingeniería Mecánica","4","24"
"Ingeniería Mecánica","5","42"
"Ingeniería Química","0","8"
"Ingeniería Química","1","75"
"Ingeniería Química","2","37"
"Ingeniería Química","3","39"
"Ingeniería Química","4","33"
"Ingeniería Química","5","40"


TOKEN
[asignatura_profesor_id][dni]
GZZGSSFGKLD
41134782

-- encrypt token
SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace('41134782', '0', 'A'), '1', 'S'), '2', 'D'),'3','F'),'4','G'),'5','H'),'6','J'),'7','K'),'8','L'),'9','Z')
FROM dual

-- decrypt token
SELECT replace(replace(replace(replace(replace(replace(replace(replace(replace(replace('GSSFGKLD','A','0'),'S','1'),'D','2'),'F','3'),'G','4'),'H','5'),'J','6'),'K','7'),'L','8'),'Z','9')
FROM dual


-- cantidad de alumnos que participaron: 210
select distinct p.firstname, c.description, count(ss1.asignatura_profesor)
from participants p join
(select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.ap_encrypt,'A','0'),'S','1'),'D','2'),'F','3'),'G','4'),'H','5'),'J','6'),'K','7'),'L','8'),'Z','9') as asignatura_profesor, replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.dni_encrypt,'A','0'),'S','1'),'D','2'),'F','3'),'G','4'),'H','5'),'J','6'),'K','7'),'L','8'),'Z','9') as dni
from
(select REPLACE(t.token, RIGHT(t.token, 8), '') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt
FROM tokens_20191 t
WHERE t.usesleft = 0
union
select REPLACE(t.token, RIGHT(t.token, 8), '') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt
FROM tokens_20192 t
WHERE t.usesleft = 0
union
select REPLACE(t.token, RIGHT(t.token, 8), '') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt
FROM tokens_20193 t
WHERE t.usesleft = 0) ss ) ss1
on ss1.dni = p.dni
join carreras c on p.carrera_id = c.id
group by 1,2




-- cantidad de alumnos que participaron por carrera


-- cantidad de alumnos que participaron por carrera y nivel


98 changes: 98 additions & 0 deletions protected/controllers/ReportesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ public function actionIndex()
));
}

public function actionRespuestas($asignatura_profesor_id)
{
$asignaturaProfesor = Yii::app()->db->createCommand('SELECT p.id, ap.cargo, a.descripcion as asignatura, a.plan, p.nombre as docente, c.description as carrera, a.id as asignatura_id FROM asignatura_profesor ap JOIN asignaturas a on ap.asignatura_id = a.id JOIN profesores p on ap.profesor_id = p.id JOIN carreras c on a.carrera_id = c.id WHERE ap.id='.$asignatura_profesor_id)->queryAll();
$cargo = $asignaturaProfesor[0]['cargo'];
$surveyId = Yii::app()->params[$cargo];
$this->render('respuestas',array(
'asignaturaProfesor'=> $asignaturaProfesor,
'preguntas'=>
Yii::app()->db->createCommand('SELECT * FROM questions WHERE sid='.$surveyId.' and parent_qid = 0')->queryAll(),
'respuestas'=>
Yii::app()->db->createCommand('SELECT * FROM survey_'.$surveyId.' WHERE not(isnull(submitdate)) and asignatura_profesor_id = '.$asignatura_profesor_id)->queryAll(),
'totalEncuestas'=>
Yii::app()->db->createCommand('SELECT COUNT(1) as total FROM asignatura_profesor ap join incripciones i on ap.asignatura_id = i.asignatura_id where ap.id = '.$asignatura_profesor_id.' and i.anio_academico = 2019')->queryAll(),
)); //(235,243)
}

public function actionGenerales()
{

$this->render('generales',array(
'participacionPorCarrera'=> $this->loadParticipacionPorCarrera(),
'cantidadEncuestasPorCarrera'=> $this->loadCantidadEncuestasPorCarrera(),
));
}

public function actionAvances()
{
$arrayFinal = array();
Expand Down Expand Up @@ -229,4 +254,77 @@ function loadCandidadAlumnosPorCarreraNivel(){
return $arrayDatos;
}


function loadParticipacionPorCarrera(){
$list = Yii::app()->db->createCommand('select ssa.carrera, ssa.inscriptosPorCarrera, ssb.alumnosParticipantes
from
(select ss.carrera as carrera, count(1) as inscriptosPorCarrera from ( SELECT p.firstname as alumno, p.legajo as legajo, c.description as carrera, count(1) as inscripciones FROM participants p JOIN incripciones i on p.participant_id = i.participant_id join carreras c on p.carrera_id = c.id WHERE i.anio_academico = 2019 GROUP BY 1, 2, 3) ss group by 1) ssa
join (select ss.carrera as carrera, count(1) as alumnosParticipantes
from (
select distinct p.firstname, c.description as carrera, count(ss1.asignatura_profesor)
from participants p join
(select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.ap_encrypt,\'A\',\'0\'),\'S\',\'1\'),\'D\',\'2\'),\'F\',\'3\'),\'G\',\'4\'),\'H\',\'5\'),\'J\',\'6\'),\'K\',\'7\'),\'L\',\'8\'),\'Z\',\'9\') as asignatura_profesor, replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.dni_encrypt,\'A\',\'0\'),\'S\',\'1\'),\'D\',\'2\'),\'F\',\'3\'),\'G\',\'4\'),\'H\',\'5\'),\'J\',\'6\'),\'K\',\'7\'),\'L\',\'8\'),\'Z\',\'9\') as dni
from
(select REPLACE(t.token, RIGHT(t.token, 8), \'\') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt
FROM tokens_20191 t
WHERE t.usesleft = 0
union
select REPLACE(t.token, RIGHT(t.token, 8), \'\') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt
FROM tokens_20192 t
WHERE t.usesleft = 0
union
select REPLACE(t.token, RIGHT(t.token, 8), \'\') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt
FROM tokens_20193 t
WHERE t.usesleft = 0) ss ) ss1
on ss1.dni = p.dni
join carreras c on p.carrera_id = c.id
group by 1,2
) ss
group by 1) ssb on ssa.carrera = ssb.carrera')->queryAll();


/* Array (
[0] => Array (
[carrera] => Ingeniería Eléctrica
[inscriptosPorCarrera] => 137
[alumnosParticipantes] => 25 )
[1] => Array (
[carrera] => Ingeniería en Sistemas de Información
[inscriptosPorCarrera] => 281
[alumnosParticipantes] => 92 )
[2] => Array (
[carrera] => Ingeniería Mecánica
[inscriptosPorCarrera] => 194
[alumnosParticipantes] => 30 )
[3] => Array (
[carrera] => Ingeniería Química
[inscriptosPorCarrera] => 285
[alumnosParticipantes] => 63 )
) 1
*/
$map = [];
foreach ($list as $row) {
array_push($map, [$row['carrera'],strval($row['inscriptosPorCarrera']),strval($row['alumnosParticipantes'])]);
}

return $map;
}

function loadCantidadEncuestasPorCarrera(){
$list = Yii::app()->db->createCommand('select ssa.carrera, ssa.encuestasProfesor, ssb.encuestasAuxiliar
from
(select distinct c.description as carrera, count(ss1.asignatura_profesor) as encuestasProfesor from (select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.ap_encrypt,\'A\',\'0\'),\'S\',\'1\'),\'D\',\'2\'),\'F\',\'3\'),\'G\',\'4\'),\'H\',\'5\'),\'J\',\'6\'),\'K\',\'7\'),\'L\',\'8\'),\'Z\',\'9\') as asignatura_profesor, replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.dni_encrypt,\'A\',\'0\'),\'S\',\'1\'),\'D\',\'2\'),\'F\',\'3\'),\'G\',\'4\'),\'H\',\'5\'),\'J\',\'6\'),\'K\',\'7\'),\'L\',\'8\'),\'Z\',\'9\') as dni from (select REPLACE(t.token, RIGHT(t.token, 8), \'\') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt FROM tokens_20191 t WHERE t.usesleft = 0 ) ss ) ss1
join asignatura_profesor ap on ss1.asignatura_profesor = ap.id join asignaturas a on ap.asignatura_id = a.id join carreras c on a.carrera_id = c.id group by 1) ssa
left JOIN
(select distinct c.description as carrera, count(ss1.asignatura_profesor) as encuestasAuxiliar from (select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.ap_encrypt,\'A\',\'0\'),\'S\',\'1\'),\'D\',\'2\'),\'F\',\'3\'),\'G\',\'4\'),\'H\',\'5\'),\'J\',\'6\'),\'K\',\'7\'),\'L\',\'8\'),\'Z\',\'9\') as asignatura_profesor, replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(ss.dni_encrypt,\'A\',\'0\'),\'S\',\'1\'),\'D\',\'2\'),\'F\',\'3\'),\'G\',\'4\'),\'H\',\'5\'),\'J\',\'6\'),\'K\',\'7\'),\'L\',\'8\'),\'Z\',\'9\') as dni from (select REPLACE(t.token, RIGHT(t.token, 8), \'\') as ap_encrypt, RIGHT(t.token, 8) as dni_encrypt FROM tokens_20192 t WHERE t.usesleft = 0 ) ss ) ss1
join asignatura_profesor ap on ss1.asignatura_profesor = ap.id join asignaturas a on ap.asignatura_id = a.id join carreras c on a.carrera_id = c.id group by 1) ssb on ssa.carrera = ssb.carrera')->queryAll();

$map = [];
foreach ($list as $row) {
array_push($map, [$row['carrera'],strval($row['encuestasProfesor']),strval($row['encuestasAuxiliar'])]);
}

return $map;
}

}
Loading

0 comments on commit faf0437

Please sign in to comment.