Skip to content

Commit

Permalink
Fix/sagres componentes curriculares (#691)
Browse files Browse the repository at this point in the history
* Fix? added new inconsistencys for empty components curriculares

* Feat: added new version for changelog and config
  • Loading branch information
nathanipti committed Apr 19, 2024
1 parent a6fe75b commit c03c1ea
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [Versão 3.77.135]
- Adicionado novas inconsistências para a falta de componentes curriculasres

## [Versão 3.77.134]
- Consertado tela de frequencia para os professores
-
Expand Down
72 changes: 63 additions & 9 deletions app/modules/sagres/models/SagresConsultModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,21 +561,39 @@ public function getSchedules($classId, $month, $inepId)


$schedules = Yii::app()->db->createCommand($query)->bindValues($params)->queryAll();

$class = (object) \Classroom::model()->findByAttributes(array('id' => $classId));


if(empty($schedules)) {
$getTeachersForClass = $this->getTeachersForClass($classId);
if(empty($getTeachersForClass)) {
$inconsistencyModel = new ValidationSagresModel();
$inconsistencyModel->enrollment = '<strong>HORÁRIO<strong>';
$inconsistencyModel->enrollment = TURMA_STRONG;
$inconsistencyModel->school = $school->name;
$inconsistencyModel->description = 'Não há um quadro de horários para a turma: <strong>' . $class->name . '<strong>';
$inconsistencyModel->action = 'Adicione um quadro de horários para turma';
$inconsistencyModel->description = 'Não há professores registrados para a turma: <strong>' . $class->name . '<strong>';
$inconsistencyModel->action = 'Adicione os professores juntamente com os seus componentes curriculares';
$inconsistencyModel->identifier = '10';
$inconsistencyModel->idClass = $classId;
$inconsistencyModel->idSchool = $inepId;
$inconsistencyModel->insert();
}

if(!empty($getTeachersForClass)) {
foreach($getTeachersForClass as $teachers) {
$componentesCurriculares = $this->getComponentesCurriculares($classId, $teachers['instructor_fk']);
if(empty($componentesCurriculares)){
$inconsistencyModel = new ValidationSagresModel();
$inconsistencyModel->enrollment = TURMA_STRONG;
$inconsistencyModel->school = $school->name;
$inconsistencyModel->description = 'O professor <strong>' . $teachers['name'] . '</strong> está sem seus componentes curriculares para a turma: <strong>' . $class->name . '<strong>';
$inconsistencyModel->action = 'Adicione os componentes curriculares para o professor: <strong>' . $teachers['name'] . '</strong>';
$inconsistencyModel->identifier = '10';
$inconsistencyModel->idClass = $classId;
$inconsistencyModel->idSchool = $inepId;
$inconsistencyModel->insert();
}
}
}


foreach ($schedules as $schedule) {
$scheduleType = new HorarioTType();
Expand Down Expand Up @@ -682,7 +700,43 @@ public function getSchedules($classId, $month, $inepId)
return $scheduleList;
}

private function getComponentesCurriculares($classId, $instructorId) {
$query = "SELECT
*
FROM instructor_teaching_data itd
JOIN teaching_matrixes tm on itd.id = tm.teaching_data_fk
JOIN curricular_matrix cm on tm.curricular_matrix_fk = cm.id
JOIN classroom c on c.id = itd.classroom_id_fk
WHERE
c.id = :classId and
itd.instructor_fk = :instructorId
ORDER BY
c.create_date DESC;";
$params = [
':classId' => $classId,
':instructorId' => $instructorId
];

return Yii::app()->db->createCommand($query)->bindValues($params)->queryAll();
}

private function getTeachersForClass($classId) {
$query = "SELECT itd.instructor_fk, ii.name
FROM instructor_teaching_data itd
JOIN instructor_identification ii ON ii.id = itd.instructor_fk
JOIN classroom c ON c.id = itd.classroom_id_fk
WHERE
c.id = :classId
ORDER BY
c.create_date DESC;";
$params = [
':classId' => $classId
];

return Yii::app()->db->createCommand($query)->bindValues($params)->queryAll();
}


/**
* Calculates the start time for a given schedule and initial hour.
*
Expand Down Expand Up @@ -1061,7 +1115,7 @@ public function getEnrollments($classId, $referenceYear, $month, $finalClass, $i
$inconsistencyModel = new ValidationSagresModel();
$inconsistencyModel->enrollment = '<strong>ESTUDANTE<strong>';
$inconsistencyModel->school = $school->name;
$inconsistencyModel->description = 'Cpf do estudante é inválido';
$inconsistencyModel->description = 'Cpf do estudante é inválido: <strong>' . $cpf . '<strong>';
$inconsistencyModel->action = 'Informe um cpf válido para o estudante: <strong>' . $enrollment['name'] . '<strong>';
$inconsistencyModel->identifier = '9';
$inconsistencyModel->idStudent = $enrollment['student_fk'];
Expand All @@ -1085,7 +1139,7 @@ public function getEnrollments($classId, $referenceYear, $month, $finalClass, $i
$inconsistencyModel = new ValidationSagresModel();
$inconsistencyModel->enrollment = '<strong>ESTUDANTE<strong>';
$inconsistencyModel->school = $school->name;
$inconsistencyModel->description = 'Data no formato inválido: ' . $enrollment['birthdate'];
$inconsistencyModel->description = 'Data no formato inválido: <strong>' . $enrollment['birthdate'] . '</strong>';
$inconsistencyModel->action = 'Adicione uma data no formato válido';
$inconsistencyModel->identifier = '9';
$inconsistencyModel->idStudent = $enrollment['student_fk'];
Expand Down Expand Up @@ -1237,7 +1291,7 @@ public function getEnrollments($classId, $referenceYear, $month, $finalClass, $i
$inconsistencyModel = new ValidationSagresModel();
$inconsistencyModel->enrollment = '<strong>ESTUDANTE<strong>';
$inconsistencyModel->school = $school->name;
$inconsistencyModel->description = 'Cpf do estudante é inválido';
$inconsistencyModel->description = 'Cpf do estudante é inválido: <strong>' . $cpf . '<strong>';
$inconsistencyModel->action = 'Informe um cpf válido para o estudante: <strong>' . $enrollment['name'] . '<strong>';
$inconsistencyModel->identifier = '9';
$inconsistencyModel->idStudent = $enrollment['student_fk'];
Expand Down Expand Up @@ -1535,7 +1589,7 @@ public function validateDate($date, $format = 'Y-m-d')
}

$d = DateTime::createFromFormat($format, $dat);
if (intval($d->format('Y')) <= 1900)
if (intval($d->format('Y')) <= 1924)
return false;

return $d && $d->format($format) == $dat;
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$debug = getenv("YII_DEBUG");
defined('YII_DEBUG') or define('YII_DEBUG', $debug);

define("TAG_VERSION", '3.77.134');
define("TAG_VERSION", '3.77.135');


define("YII_VERSION", Yii::getVersion());
Expand Down

0 comments on commit c03c1ea

Please sign in to comment.