Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ipti/br.tag
Browse files Browse the repository at this point in the history
  • Loading branch information
igorgoncalves committed Dec 18, 2024
2 parents ce0a7c9 + 96b5342 commit 51beb9d
Show file tree
Hide file tree
Showing 24 changed files with 783 additions and 113 deletions.
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
## [Versão 3.91.208]
- Permitindo que o usuário de professor consiga visualizar no relatório as aulas ministradas cadastradas por outros professores

## [Versão 3.91.207]
## [Versão 3.93.210]
- Corrigindo a busca por aulas em aulas ministradas quando o usuário é um professor da educação infantil

## [Versão 3.93.209]
- Trocado "Série" por "Etapa" na Ficha de Matrícula
- O Campo 27 da Ficha de Matrícula (Autorização do Termo de Consentimento de Imagem) agora traz preenchido do cadastro do aluno

## [Versão 3.92.209]
- Corrigido o relatório de alunos por escola (Cpg, Rg e Nis), exibindo somente os alunos do ano em que o relatório foi emitido

## [Versão 3.92.208]
- Permitindo o acesso dos coordenadores pedagógicos as telas de frequência de professor e a tela de notas
- Filtrando por escola os professores que podem ser selecionados na tela de frequência de professor

## [Versão 3.92.207]
- Feito com que o aluno rematricule numa turma que havia sido transferida
- Aumentado fonte da ficha de notas
- Inserido campos no cabeçalho da ficha de notas (gênero, filiação, data de nascimento, naturalidade)
- Inserido opção pra imprimir ficha de notas com local/data ou não
- Trocado signatário de inspetor escolar para secretário escolar na ficha de notas
- Adicionado filtro de etapa para as turmas multiseriadas


## [Versão 3.90.206]
## [Versão 3.91.206]
- Corrigido erro ao carregar campo de tipo de unidade em estrutura de unidades e avaliações

## [Versão 3.91.205]
Expand Down
2 changes: 1 addition & 1 deletion app/components/utils/TagUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function isStageChildishEducation($stage){
}
public static function isMultiStage($stage){
$refMinorStages = [
'12','13','22','23','24','41','56','83', '84'
'12','13','22','23','24','56','83', '84'
];
$stages = new CList($refMinorStages, true);
return $stages->contains(strval($stage));
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/ClassesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ public function actionGetClassContents()
->queryAll();

$additionalClasses = Yii::app()->db->createCommand(
"select distinct cc.id, cp.name as cpname, ed.id as edid, ed.name as edname, cc.order, cc.content, cp.id as cpid
"select cc.id, cp.name as cpname, cp.discipline_fk ,cc.order, cc.content, cp.id as cpid
from course_class cc
join course_plan cp on cp.id = cc.course_plan_fk
join course_plan_discipline_vs_abilities dvsa on dvsa.course_class_fk = cc.id
join edcenso_discipline ed on ed.id = dvsa.discipline_fk
where cp.school_inep_fk = :school_inep_fk and cp.modality_fk = :modality_fk and cp.users_fk = :users_fk and cp.discipline_fk IS NULL
order by ed.name, cp.name"
order by cp.name"
)
->bindParam(":school_inep_fk", Yii::app()->user->school)
->bindParam(":modality_fk", $schedules[0]->classroomFk->edcenso_stage_vs_modality_fk)
Expand Down
107 changes: 83 additions & 24 deletions app/controllers/GradesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public function accessRules()
'getGradesRelease',
'getReportCardGrades',
'saveGradesReportCard',
'saveGradesRelease'
'saveGradesRelease',
'getClassroomStages'
),
'users' => array('@'),
),
Expand Down Expand Up @@ -86,14 +87,43 @@ public function actionGrades()
$criteria->params = array(':school_year' => $year, ':school_inep_fk' => $school, ':users_fk' => Yii::app()->user->loginInfos->id);

$classroom = Classroom::model()->findAll($criteria);
$classroom = CHtml::listData($classroom, 'id', 'name');
} else {
$classroom = Classroom::model()->findAll('school_year = :school_year and school_inep_fk = :school_inep_fk order by name', ['school_year' => $year, 'school_inep_fk' => $school]);
$classroom = CHtml::listData($classroom, 'id', 'name');
}

$this->render('grades', ['classrooms' => $classroom]);
}
public function actionGetClassroomStages()
{
$classroomId = Yii::app()->request->getPost("classroomId");
$classroomStage = Classroom::model()->findByPk($classroomId)->edcensoStageVsModalityFk;
$criteria = new CDbCriteria();
$criteria->alias = 'stages';
$criteria->join = 'INNER JOIN student_enrollment ON student_enrollment.edcenso_stage_vs_modality_fk = stages.id';
$criteria->join .= ' INNER JOIN classroom ON classroom.id = student_enrollment.classroom_fk';
$criteria->condition = 'classroom.id = :classroomId';
$criteria->group = 'stages.name';
$criteria->params = array(':classroomId' => $classroomId);
$stages = EdcensoStageVsModality::model()->findAll($criteria);


echo CHtml::tag('option',
array(
'value' => $classroomStage->id,
'data-classroom-stage' => '1',
),
CHtml::encode($classroomStage->name),
true
);

foreach ($stages as $stage) {
echo CHtml::tag('option', array(
'value' => $stage->id,
'data-classroom-stage' => '0',
), CHtml::encode($stage->name), true);
}

}

public function actionGetDisciplines()
{
Expand Down Expand Up @@ -131,8 +161,14 @@ public function actionGetDisciplines()
}
public function actionGetUnities()
{
$classroom = Classroom::model()->findByPk($_POST["classroom"]);
$unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk]);
$classroomId = Yii::app()->request->getPost("classroom");
$stage = Yii::app()->request->getPost("stage");
if(isset(($stage)) && $stage !== "") {
$unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $stage]);
} else {
$classroom = Classroom::model()->findByPk($classroomId);
$unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk]);
}
$result = [];

foreach ($unities as $unity) {
Expand Down Expand Up @@ -507,6 +543,7 @@ public function actionSaveGrades()
$students = Yii::app()->request->getPost("students");
$disciplineId = Yii::app()->request->getPost("discipline");
$classroomId = Yii::app()->request->getPost("classroom");
$stage = Yii::app()->request->getPost("stage");
$isConcept = Yii::app()->request->getPost("isConcept");

$transaction = Yii::app()->db->beginTransaction();
Expand Down Expand Up @@ -552,7 +589,7 @@ public function actionSaveGrades()
}
}
}
self::saveGradeResults($classroomId, $disciplineId);
self::saveGradeResults($classroomId, $disciplineId, $stage);
$transaction->commit();
header('HTTP/1.1 200 OK');
echo json_encode(["valid" => true]);
Expand All @@ -570,21 +607,21 @@ public function actionGetGrades()

Yii::import("application.domain.grades.usecases.GetStudentGradesByDisciplineUsecase");

$classroomId = (int) Yii::app()->request->getPost("classroom");
$disciplineId = (int) Yii::app()->request->getPost("discipline");
$unityId = (int) Yii::app()->request->getPost("unity");
$classroomId = Yii::app()->request->getPost("classroom");
$disciplineId = Yii::app()->request->getPost("discipline");
$unityId = Yii::app()->request->getPost("unity");
$stageId = Yii::app()->request->getPost("stage");
$isClassroomStage = Yii::app()->request->getPost("isClassroomStage");


if (!isset($classroomId) || !isset($disciplineId) || !isset($unityId)) {
throw new CHttpException(400, "Requisição mal formada, faltam dados");
}


if (!isset($classroomId) || !isset($disciplineId) || !isset($unityId)) {
throw new CHttpException(400, "Requisição mal formada, faltam dados");
if ($stageId=== "") {
$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($classroomId);
$stageId = (int) $classroom->edcenso_stage_vs_modality_fk;
}

$usecase = new GetStudentGradesByDisciplineUsecase($classroomId, $disciplineId, $unityId);
$usecase = new GetStudentGradesByDisciplineUsecase($classroomId, $disciplineId, $unityId, $stageId, $isClassroomStage);
$result = $usecase->exec();
echo CJSON::encode($result);

Expand All @@ -594,28 +631,47 @@ public function actionCalculateFinalMedia()
{
$transaction = Yii::app()->db->beginTransaction();
try {

$classroomId = Yii::app()->request->getPost("classroom");
$stage = Yii::app()->request->getPost("stage");
$disciplineId = Yii::app()->request->getPost("discipline");
$isClassroomStage = Yii::app()->request->getPost("isClassroomStage");

$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($classroomId);

if($stage==="") {
$stage = $classroom->edcenso_stage_vs_modality_fk;
}

$gradeRules = GradeRules::model()->findByAttributes([
"edcenso_stage_vs_modality_fk" => $classroom->edcenso_stage_vs_modality_fk
"edcenso_stage_vs_modality_fk" => $stage
]);

TLog::info("Começado processo de calcular média final.", ["Classroom" => $classroom->id, "GradeRules" => $gradeRules->id]);

foreach ($classroom->activeStudentEnrollments as $enrollment) {
$TotalEnrollments = $classroom->activeStudentEnrollments;
$studentEnrollments = [];
if(TagUtils::isMultiStage($classroom->edcenso_stage_vs_modality_fk) && $isClassroomStage == 0){
foreach ($TotalEnrollments as $enrollment) {
if($enrollment->edcenso_stage_vs_modality_fk == $stage){
array_push($studentEnrollments, $enrollment);
}
}
} else {
$studentEnrollments = $classroom->activeStudentEnrollments;
}
foreach ($studentEnrollments as $enrollment) {
$gradeUnities = new GetGradeUnitiesByDisciplineUsecase($gradeRules->edcenso_stage_vs_modality_fk);
$gradesStudent = $gradeUnities->exec();
$countUnities = $gradeUnities->execCount();

TLog::info("Unidades por disciplina", ["GradeUnities" => CHtml::listData($gradesStudent, 'id', 'id')]);
TLog::info("Unidades por disciplina", ["GradeUnities" => CHtml::listData($gradesStudent, 'id', 'id')]);

$gradeResult = (new GetStudentGradesResultUsecase($enrollment->id, $disciplineId))->exec();
(new CalculateFinalMediaUsecase($gradeResult, $gradeRules, $countUnities, $gradesStudent))->exec();
(new ChageStudentStatusByGradeUsecase($gradeResult, $gradeRules, $countUnities))->exec();
if($gradeRules->rule_type === "N") {
(new ChageStudentStatusByGradeUsecase($gradeResult, $gradeRules, $countUnities, $stage))->exec();
}

}
$transaction->commit();
} catch (Exception $e) {
Expand All @@ -626,20 +682,23 @@ public function actionCalculateFinalMedia()
}


public static function saveGradeResults($classroomId, $disciplineId)
public static function saveGradeResults($classroomId, $disciplineId, $stage)
{
TLog::info("Executando: SaveGradeResults.", array(
"Classroom" => $classroomId,
"Discipline" => $disciplineId
"Discipline" => $disciplineId,
"Stage" => $stage
));
$usecase = new CalculateGradeResultsUsecase(
$classroomId,
$disciplineId
$disciplineId,
$stage
);
$usecase->exec();
TLog::info("Finalizado: SaveGradeResults.", array(
"Classroom" => $classroomId,
"Discipline" => $disciplineId
"Discipline" => $disciplineId,
"Stage" => $stage
));
}
}
64 changes: 44 additions & 20 deletions app/domain/grades/usecases/CalculateConceptGradeUsecase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,38 @@
/**
* @property int $classroomId
* @property int $discipline
* @property int $stage
*/
class CalculateConceptGradeUsecase
{

private $classroomId;
private $discipline;
public function __construct($classroom, $discipline)
public function __construct($classroom, $discipline, $stage)
{
$this->classroomId = $classroom;
$this->discipline = $discipline;
$this->stage = $stage;
}

public function exec()
{
$classroom = Classroom::model()->with("activeStudentEnrollments.studentFk")->findByPk($this->classroomId);
$studentEnrollments = $classroom->activeStudentEnrollments;
$unitiesByDiscipline = $this->getGradeUnitiesByClassroomStage($this->classroomId);
$TotalEnrollments = $classroom->activeStudentEnrollments;
$studentEnrollments = [];
if(TagUtils::isMultiStage($classroom->edcenso_stage_vs_modality_fk)) {

foreach ($TotalEnrollments as $enrollment) {
if($enrollment->edcenso_stage_vs_modality_fk == $this->stage){
array_push($studentEnrollments, $enrollment);
}
}
} else {
$studentEnrollments = $classroom->activeStudentEnrollments;
$this->stage = $classroom->edcenso_stage_vs_modality_fk;

}
// $unitiesByDiscipline = $this->getGradeUnitiesByClassroomStage($this->classroomId);

foreach ($studentEnrollments as $studentEnrollment) {
$this->calculateConceptGrades($studentEnrollment, $unitiesByDiscipline, $this->discipline);
$this->calculateConceptGrades($studentEnrollment, $this->discipline);
}
}

Expand Down Expand Up @@ -69,28 +81,31 @@ private function getGradesResultForStudent($studentEnrollmentId, $disciplineId)
return $gradeResult;
}

private function calculateConceptGrades($studentEnrollment, $gradeUnities, $disciplineId)
private function calculateConceptGrades($studentEnrollment, $disciplineId)
{

$gradeResult = $this->getGradesResultForStudent($studentEnrollment->id, $disciplineId);
//notas por conceito
$hasAllGrades = true;
foreach ($gradeUnities as $unityKey => $gradeUnity) {
$grades = $this->getStudentGradesFromUnity(

$grades = $this->getStudentGrades(
$studentEnrollment->id,
$disciplineId,
$gradeUnity->id
);
foreach ($grades as $grade) {
if($grade->grade_concept_fk === null){
$hasAllGrades = false;
}
foreach ($grades as $gradeKey => $grade) {

$gradeResult["grade_concept_" . ($unityKey + 1)] = $grade->gradeConceptFk->acronym;
$gradeResult["grade_concept_" . ($gradeKey + 1)] = $grade->gradeConceptFk->acronym;

}

$gradeUnities = new GetGradeUnitiesByDisciplineUsecase($this->stage);
$numUnities = $gradeUnities->execCount();

if (!$this->hasAllGrades($numUnities, $gradeResult)) {
$hasAllGrades = false;
}


$gradeResult->situation = StudentEnrollment::STATUS_ACTIVE;

if ($hasAllGrades) {
Expand All @@ -114,7 +129,7 @@ private function calculateConceptGrades($studentEnrollment, $gradeUnities, $disc
*
* @return Grade[]
*/
private function getStudentGradesFromUnity($enrollmentId, $discipline, $unityId)
private function getStudentGrades($enrollmentId, $discipline)
{

$gradesIds = array_column(Yii::app()->db->createCommand(
Expand All @@ -123,10 +138,9 @@ private function getStudentGradesFromUnity($enrollmentId, $discipline, $unityId)
FROM grade g
join grade_unity_modality gum on g.grade_unity_modality_fk = gum.id
join grade_unity gu on gu.id= gum.grade_unity_fk
WHERE g.enrollment_fk = :enrollment_id and g.discipline_fk = :discipline_id and gu.id = :unity_id and gum.type = '" . GradeUnityModality::TYPE_COMMON . "'"
WHERE g.enrollment_fk = :enrollment_id and g.discipline_fk = :discipline_id and gum.type = '" . GradeUnityModality::TYPE_COMMON . "' and gu.type = 'UC'"
)->bindParam(":enrollment_id", $enrollmentId)
->bindParam(":discipline_id", $discipline)
->bindParam(":unity_id", $unityId)->queryAll(), "id");
->bindParam(":discipline_id", $discipline)->queryAll(), "id");

if ($gradesIds == null) {
return [];
Expand All @@ -139,4 +153,14 @@ private function getStudentGradesFromUnity($enrollmentId, $discipline, $unityId)
);
}

private function hasAllGrades($numUnities, $gradeResult)
{
for ($i = 1; $i <= $numUnities; $i++) {
if (!isset($gradeResult["grade_concept_" . $i]) || $gradeResult["grade_concept_" . $i] === "") {
return false;
}
}
return true;
}

}
Loading

0 comments on commit 51beb9d

Please sign in to comment.