From d9cbd9b41e1309e83687d9156528e6c7ab7b6aed Mon Sep 17 00:00:00 2001 From: GabrielChagas14 <84946326+GabrielChagas14@users.noreply.github.com> Date: Fri, 27 Dec 2024 08:29:05 -0300 Subject: [PATCH 1/4] fix/add-transaction-grades (#907) --- app/controllers/GradesController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/GradesController.php b/app/controllers/GradesController.php index 851838095..462380c09 100644 --- a/app/controllers/GradesController.php +++ b/app/controllers/GradesController.php @@ -546,6 +546,7 @@ public function actionSaveGrades() $stage = Yii::app()->request->getPost("stage"); $isConcept = Yii::app()->request->getPost("isConcept"); + $transaction = Yii::app()->db->beginTransaction(); try { foreach ($students as $student) { foreach ($student["grades"] as $grade) { @@ -589,10 +590,12 @@ public function actionSaveGrades() } } self::saveGradeResults($classroomId, $disciplineId, $stage); + $transaction->commit(); header('HTTP/1.1 200 OK'); echo json_encode(["valid" => true]); } catch (Exception $e) { TLog::error("Ocorreu algum erro durante a transação de SaveGrades", ["ExceptionMessage" => $e->getMessage()]); + $transaction->rollback(); throw new Exception($e->getMessage(), 500, $e); } @@ -626,6 +629,7 @@ public function actionGetGrades() public function actionCalculateFinalMedia() { + $transaction = Yii::app()->db->beginTransaction(); try { $classroomId = Yii::app()->request->getPost("classroom"); $stage = Yii::app()->request->getPost("stage"); @@ -669,7 +673,9 @@ public function actionCalculateFinalMedia() } } + $transaction->commit(); } catch (Exception $e) { + $transaction->rollback(); TLog::error("Erro ao atualizar status da matrícula", ["Exception" => $e]); } From 765a3e75650d6101f5ac375b8ea7581057a62290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gon=C3=A7alves?= Date: Fri, 27 Dec 2024 18:11:32 -0300 Subject: [PATCH 2/4] fix: recalculate values for frenquency and worloads --- CHANGELOG.md | 4 + app/models/ClassContents.php | 165 ++++++++++------- app/models/ClassFaults.php | 175 +++++++++--------- app/models/Classroom.php | 1 + app/models/StudentEnrollment.php | 153 ++++++++++----- app/repository/FormsRepository.php | 61 ++---- config.php | 2 +- .../views/forms/EnrollmentGradesReport.php | 105 +++++------ 8 files changed, 358 insertions(+), 308 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc799a695..65950c136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [Versão 3.94.214] +- Correção de Ficha de notas: Os valores de frequencia e a contagem de aulas foi revisado e foi adaptada a visualização dos dados para diferenciar +o relatório para ensino intanfil e fundamental menor do fundamental maior; + ## [Versão 3.94.213] - Controle de status a serem considerados na exportação do sagres. Por padrão apenas matriculas com status "matriculado" são envadas. No entanto, usando o diario eletronico, o status de algumas matriculas mudaram para "Aprovado", "Reprovado" e outros. Foi adicionado um controle para optar ou não por considerar esses status na exportação. - Novo campo na turma para definir o periodo da turma: Anual, 1 Semestre ou 2 Semestre; diff --git a/app/models/ClassContents.php b/app/models/ClassContents.php index cd625150e..a4855b726 100644 --- a/app/models/ClassContents.php +++ b/app/models/ClassContents.php @@ -22,13 +22,13 @@ */ class ClassContents extends CActiveRecord { - /** + /** * @return string the associated database table name - */ + */ public function tableName() - { + { return 'class_contents'; - } + } public function behaviors() { @@ -42,40 +42,40 @@ public function behaviors() ] ]; } - /** - * @return array validation rules for model attributes. - */ - public function rules() + /** + * @return array validation rules for model attributes. + */ + public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('schedule_fk, course_class_fk', 'required'), - array('schedule_fk, course_class_fk, day, month, year, classroom_fk, discipline_fk', 'numerical', 'integerOnly'=>true), - array('fkid', 'length', 'max'=>40), + array('schedule_fk, course_class_fk, day, month, year, classroom_fk, discipline_fk', 'numerical', 'integerOnly' => true), + array('fkid', 'length', 'max' => 40), array('created_at, updated_at', 'safe'), // The following rule is used by search(). // @todo Please remove those attributes that should not be searched. - array('id, schedule_fk, course_class_fk, fkid, created_at, updated_at, day, month, year, classroom_fk, discipline_fk', 'safe', 'on'=>'search'), + array('id, schedule_fk, course_class_fk, fkid, created_at, updated_at, day, month, year, classroom_fk, discipline_fk', 'safe', 'on' => 'search'), + ); + } + + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + 'courseClassFk' => array(self::BELONGS_TO, CourseClass::class, 'course_class_fk'), ); } - /** - * @return array relational rules. - */ - public function relations() - { - // NOTE: you may need to adjust the relation name and the related - // class name for the relations automatically generated below. - return array( - 'courseClassFk' => array(self::BELONGS_TO, CourseClass::class, 'course_class_fk'), - ); - } - - /** - * @return array customized attribute labels (name=>label) - */ - public function attributeLabels() + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() { return array( 'id' => 'ID', @@ -92,53 +92,54 @@ public function attributeLabels() ); } - /** - * Retrieves a list of models based on the current search/filter conditions. - * - * Typical usecase: - * - Initialize the model fields with values from filter form. - * - Execute this method to get CActiveDataProvider instance which will filter - * models according to data in model fields. - * - Pass data provider to CGridView, CListView or any similar widget. - * - * @return CActiveDataProvider the data provider that can return the models - * based on the search/filter conditions. - */ - public function search() + /** + * Retrieves a list of models based on the current search/filter conditions. + * + * Typical usecase: + * - Initialize the model fields with values from filter form. + * - Execute this method to get CActiveDataProvider instance which will filter + * models according to data in model fields. + * - Pass data provider to CGridView, CListView or any similar widget. + * + * @return CActiveDataProvider the data provider that can return the models + * based on the search/filter conditions. + */ + public function search() { - $criteria=new CDbCriteria; + $criteria = new CDbCriteria; - $criteria->compare('id',$this->id); - $criteria->compare('schedule_fk',$this->schedule_fk); - $criteria->compare('course_class_fk',$this->course_class_fk); - $criteria->compare('fkid',$this->fkid,true); - $criteria->compare('created_at',$this->created_at,true); - $criteria->compare('updated_at',$this->updated_at,true); - $criteria->compare('day',$this->day); - $criteria->compare('month',$this->month); - $criteria->compare('year',$this->year); - $criteria->compare('classroom_fk',$this->classroom_fk); - $criteria->compare('discipline_fk',$this->discipline_fk); + $criteria->compare('id', $this->id); + $criteria->compare('schedule_fk', $this->schedule_fk); + $criteria->compare('course_class_fk', $this->course_class_fk); + $criteria->compare('fkid', $this->fkid, true); + $criteria->compare('created_at', $this->created_at, true); + $criteria->compare('updated_at', $this->updated_at, true); + $criteria->compare('day', $this->day); + $criteria->compare('month', $this->month); + $criteria->compare('year', $this->year); + $criteria->compare('classroom_fk', $this->classroom_fk); + $criteria->compare('discipline_fk', $this->discipline_fk); return new CActiveDataProvider($this, array( - 'criteria'=>$criteria, + 'criteria' => $criteria, )); } - /** - * Returns the static model of the specified AR class. - * Please note that you should have this exact method in all your CActiveRecord descendants! - * @param string $className active record class name. - * @return ClassContents the static model class - */ - public static function model($className=__CLASS__) - { - return parent::model($className); - } - - public function getTotalClassesByMonth($classroomId, $month, $year, $disciplineId) { - if(!$disciplineId) { + /** + * Returns the static model of the specified AR class. + * Please note that you should have this exact method in all your CActiveRecord descendants! + * @param string $className active record class name. + * @return ClassContents the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } + + public function getTotalClassesByMonth($classroomId, $month, $year, $disciplineId) + { + if (!$disciplineId) { return Yii::app()->db->createCommand( "select count(*) from schedule sc where sc.year = :year and sc.month = :month and sc.classroom_fk = :classroom @@ -161,8 +162,34 @@ public function getTotalClassesByMonth($classroomId, $month, $year, $disciplineI ->queryScalar(); } - public function getTotalClassContentsByMonth($classroomId, $month, $year, $disciplineId) { - if(!$disciplineId) { + public function getTotalClassesMinorStage($classroomId): int + { + return Yii::app()->db->createCommand( + "select COUNT(DISTINCT CONCAT(sc.`month`, '-', sc.`day`)) from schedule sc + where sc.classroom_fk = :classroom + and sc.unavailable = 0" + ) + ->bindParam(":classroom", $classroomId) + ->queryScalar(); + + } + public function getTotalClassesByClassroomAndDiscipline($classroomId, $disciplineId): int + { + return Yii::app()->db->createCommand( + "select count(*) from class_contents cc + join schedule sc on sc.id = cc.schedule_fk + where sc.classroom_fk = :classroom + and sc.discipline_fk = :discipline and sc.unavailable = 0" + ) + ->bindParam(":classroom", $classroomId) + ->bindParam(":discipline", $disciplineId) + ->queryScalar(); + + } + + public function getTotalClassContentsByMonth($classroomId, $month, $year, $disciplineId) + { + if (!$disciplineId) { return Yii::app()->db->createCommand( "select count(*) from class_contents cc join schedule sc on sc.id = cc.schedule_fk @@ -201,7 +228,7 @@ public function buildClassContents($schedules, $students) $courseClasses = []; foreach ($schedule->classContents as $classContent) { - if(TagUtils::isInstructor() && $classContent->courseClassFk->coursePlanFk->users_fk != Yii::app()->user->loginInfos->id) { + if (TagUtils::isInstructor() && $classContent->courseClassFk->coursePlanFk->users_fk != Yii::app()->user->loginInfos->id) { continue; } diff --git a/app/models/ClassFaults.php b/app/models/ClassFaults.php index 7aad57fd4..eedc16f86 100755 --- a/app/models/ClassFaults.php +++ b/app/models/ClassFaults.php @@ -16,100 +16,103 @@ */ class ClassFaults extends CActiveRecord { - /** - * Returns the static model of the specified AR class. - * @param string $className active record class name. - * @return ClassFaults the static model class - */ - public static function model($className=__CLASS__) - { - return parent::model($className); - } + /** + * Returns the static model of the specified AR class. + * @param string $className active record class name. + * @return ClassFaults the static model class + */ + public static function model($className = __CLASS__) + { + return parent::model($className); + } - /** - * @return string the associated database table name - */ - public function tableName() - { - return 'class_faults'; - } + /** + * @return string the associated database table name + */ + public function tableName() + { + return 'class_faults'; + } - public function behaviors() { - return [ - 'CTimestampBehavior' => [ - 'class' => 'zii.behaviors.CTimestampBehavior', - 'createAttribute' => 'created_at', - 'updateAttribute' => 'updated_at', - 'setUpdateOnCreate' => true, - 'timestampExpression' => new CDbExpression('CONVERT_TZ(NOW(), "+00:00", "-03:00")'), - ], - 'afterSave'=>[ - 'class'=>'application.behaviors.CAfterSaveBehavior', - 'schoolInepId' => Yii::app()->user->school, - ], - ]; - } + public function behaviors() + { + return [ + 'CTimestampBehavior' => [ + 'class' => 'zii.behaviors.CTimestampBehavior', + 'createAttribute' => 'created_at', + 'updateAttribute' => 'updated_at', + 'setUpdateOnCreate' => true, + 'timestampExpression' => new CDbExpression('CONVERT_TZ(NOW(), "+00:00", "-03:00")'), + ], + 'afterSave' => [ + 'class' => 'application.behaviors.CAfterSaveBehavior', + 'schoolInepId' => Yii::app()->user->school, + ], + ]; + } - /** - * @return array validation rules for model attributes. - */ - public function rules() - { - // NOTE: you should only define rules for those attributes that - // will receive user inputs. - return array( - array('schedule_fk, student_fk', 'required'), - array('schedule_fk, student_fk', 'numerical', 'integerOnly'=>true), - array('justification', 'length', 'max'=>200), - // The following rule is used by search(). - // Please remove those attributes that should not be searched. - array('id, schedule_fk, student_fk', 'safe', 'on'=>'search'), - ); - } + /** + * @return array validation rules for model attributes. + */ + public function rules() + { + // NOTE: you should only define rules for those attributes that + // will receive user inputs. + return array( + array('schedule_fk, student_fk', 'required'), + array('schedule_fk, student_fk', 'numerical', 'integerOnly' => true), + array('justification', 'length', 'max' => 200), + // The following rule is used by search(). + // Please remove those attributes that should not be searched. + array('id, schedule_fk, student_fk', 'safe', 'on' => 'search'), + ); + } - /** - * @return array relational rules. - */ - public function relations() - { - // NOTE: you may need to adjust the relation name and the related - // class name for the relations automatically generated below. - return array( - 'scheduleFk' => array(self::BELONGS_TO, 'Schedule', 'schedule_fk'), - 'studentFk' => array(self::BELONGS_TO, 'StudentEnrollment', 'student_fk'), - ); - } + /** + * @return array relational rules. + */ + public function relations() + { + // NOTE: you may need to adjust the relation name and the related + // class name for the relations automatically generated below. + return array( + 'scheduleFk' => array(self::BELONGS_TO, 'Schedule', 'schedule_fk'), + 'studentFk' => array(self::BELONGS_TO, 'StudentEnrollment', 'student_fk'), + ); + } - /** - * @return array customized attribute labels (name=>label) - */ - public function attributeLabels() - { - return array( - 'id' => Yii::t('default', 'ID'), - 'schedule_fk' => Yii::t('default', 'Schedule Fk'), - 'student_fk' => Yii::t('default', 'Student Fk'), + /** + * @return array customized attribute labels (name=>label) + */ + public function attributeLabels() + { + return array( + 'id' => Yii::t('default', 'ID'), + 'schedule_fk' => Yii::t('default', 'Schedule Fk'), + 'student_fk' => Yii::t('default', 'Student Fk'), 'justification' => Yii::t('default', "Justification") - ); - } + ); + } - /** - * Retrieves a list of models based on the current search/filter conditions. - * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. - */ - public function search() - { - // Warning: Please modify the following code to remove attributes that - // should not be searched. + /** + * Retrieves a list of models based on the current search/filter conditions. + * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. + */ + public function search() + { + // Warning: Please modify the following code to remove attributes that + // should not be searched. - $criteria=new CDbCriteria; + $criteria = new CDbCriteria; + + $criteria->compare('id', $this->id); + $criteria->compare('schedule_fk', $this->schedule_fk); + $criteria->compare('student_fk', $this->student_fk); + + return new CActiveDataProvider($this, array( + 'criteria' => $criteria, + )); + } - $criteria->compare('id',$this->id); - $criteria->compare('schedule_fk',$this->schedule_fk); - $criteria->compare('student_fk',$this->student_fk); - return new CActiveDataProvider($this, array( - 'criteria'=>$criteria, - )); - } } diff --git a/app/models/Classroom.php b/app/models/Classroom.php index f4be4fd2a..98ab94390 100755 --- a/app/models/Classroom.php +++ b/app/models/Classroom.php @@ -90,6 +90,7 @@ * @property Calendar $calendarFk * @property SchoolIdentification $schoolInepFk * @property EdcensoProfessionalEducationCourse $edcensoProfessionalEducationCourseFk + * @property EdcensoStageVsModality $edcensoStageVsModalityFk * @property ClassroomHasCoursePlan[] $classroomHasCoursePlans * @property InstructorTeachingData[] $instructorTeachingDatas * @property Schedule[] $schedules diff --git a/app/models/StudentEnrollment.php b/app/models/StudentEnrollment.php index 8d300cb97..b4849cf74 100755 --- a/app/models/StudentEnrollment.php +++ b/app/models/StudentEnrollment.php @@ -261,8 +261,8 @@ public function attributeLabels() 'daily_order' => Yii::t('default', 'daily_order'), 'school-identifications' => Yii::t('default', 'School Identifications'), 'transfer_date' => Yii::t('default', 'Transfer Date'), - 'class_transfer_date' => Yii::t('default' ,'Class Transfer Date'), - 'school_readmission_date' => Yii::t('default','School Readmission Date'), + 'class_transfer_date' => Yii::t('default', 'Class Transfer Date'), + 'school_readmission_date' => Yii::t('default', 'School Readmission Date'), 'enrollment_date' => Yii::t('default', 'Enrollment Date'), ); } @@ -290,40 +290,42 @@ public function search() $criteria->compare('enrollment_id', $this->enrollment_id, true); $criteria->compare('id', $this->id); $criteria->compare('classroomFk.school_year', Yii::app()->user->year); - $criteria->compare('class_transfer_date',$this->class_transfer_date); - $criteria->compare('school_readmission_date',$this->school_readmission_date); - $criteria->compare('enrollment_date',$this->enrollment_date); + $criteria->compare('class_transfer_date', $this->class_transfer_date); + $criteria->compare('school_readmission_date', $this->school_readmission_date); + $criteria->compare('enrollment_date', $this->enrollment_date); $school = Yii::app()->user->school; $criteria->compare('t.school_inep_id_fk', $school); $criteria->addCondition('studentFk.name like "%' . $this->student_fk . '%"'); $criteria->addCondition('classroomFk.name like "%' . $this->classroom_fk . '%"'); - return new CActiveDataProvider($this, array( - 'criteria' => $criteria, - 'sort' => array( - 'attributes' => array( - 'studentFk.name' => array( - 'asc' => 'studentFk.name', - 'desc' => 'studentFk.name DESC', + return new CActiveDataProvider( + $this, + array( + 'criteria' => $criteria, + 'sort' => array( + 'attributes' => array( + 'studentFk.name' => array( + 'asc' => 'studentFk.name', + 'desc' => 'studentFk.name DESC', + ), + 'classroomFk.name' => array( + 'asc' => 'classroomFk.name', + 'desc' => 'classroomFk.name DESC', + ), + 'classroomFk.school_year' => array( + 'asc' => 'classroomFk.school_year', + 'desc' => 'classroomFk.school_year DESC', + ), + '*', + // Make all other columns sortable, too ), - 'classroomFk.name' => array( - 'asc' => 'classroomFk.name', - 'desc' => 'classroomFk.name DESC', + 'defaultOrder' => array( + 'studentFk.name' => CSort::SORT_ASC ), - 'classroomFk.school_year' => array( - 'asc' => 'classroomFk.school_year', - 'desc' => 'classroomFk.school_year DESC', - ), - '*', - // Make all other columns sortable, too - ), - 'defaultOrder' => array( - 'studentFk.name' => CSort::SORT_ASC ), - ), - 'pagination' => false - ) + 'pagination' => false + ) ); } @@ -368,6 +370,52 @@ public function getFaultsByDiscipline($disciplineId) return $faults; } + public function countFaultsDiscipline($disciplineId = null): int + { + $classroomId = $this->classroom_fk; + $studentId = $this->student_fk; + $isMinorEducation = TagUtils::isStageMinorEducation($this->classroomFk->edcensoStageVsModalityFk->edcenso_associated_stage_id); + + $command = Yii::app()->db->createCommand() + ->from('class_faults cf') + ->join('schedule s', 'cf.schedule_fk = s.id') + ->where('student_fk = :studentId and s.classroom_fk = :classroomId') + ->select('count(DISTINCT CONCAT(s.`year`, s.`month`, s.`day`))') + ->bindValues([ + ':classroomId' => $classroomId, + ':studentId' => $studentId + ]); + + if (!$isMinorEducation) { + $command = Yii::app()->db->createCommand() + ->select('COUNT(1)') + ->from('schedule t') + ->join( + '(SELECT s1.classroom_fk, s1.`day`, s1.`month`, s1.`year`, s1.discipline_fk + FROM class_faults cf + JOIN schedule s1 ON cf.schedule_fk = s1.id + WHERE s1.classroom_fk = :classroomId + AND cf.student_fk = :studentId + AND s1.discipline_fk = :disciplineId) sf', + 't.classroom_fk = sf.classroom_fk + AND sf.`month` = t.month + AND sf.`day` = t.`day` + AND sf.discipline_fk = t.discipline_fk' + ) + ->bindValues([ + ':classroomId' => $classroomId, + ':studentId' => $studentId, + ':disciplineId' => $disciplineId, + ]); + } + + return $command->queryScalar() ?? 0; + + + } + + + public function getFaultsByExam($exam) { /* @var $schoolConfiguration SchoolConfiguration */ @@ -602,8 +650,9 @@ public function getSheetGrade() return $result; } - public static function getListStatus(){ - $status = [ + public static function getListStatus() + { + $status = [ "1" => StudentEnrollment::STATUS_ACTIVE, "2" => StudentEnrollment::STATUS_TRANSFERRED, "3" => StudentEnrollment::STATUS_CANCELED, @@ -622,8 +671,9 @@ public static function getListStatus(){ return $status; } - public function getCurrentStatus(){ - $status = [ + public function getCurrentStatus() + { + $status = [ null => "", "1" => StudentEnrollment::STATUS_ACTIVE, "2" => StudentEnrollment::STATUS_TRANSFERRED, @@ -644,29 +694,36 @@ public function getCurrentStatus(){ } - public function isActive(){ + public function isActive() + { $refActiveStatus = [ - "1", "8", "10", "6", "5", null + "1", + "8", + "10", + "6", + "5", + null ]; $stages = new CList($refActiveStatus, true); return $stages->contains($this->status); } - public static function getStatusId($status){ - $statusList = [ - StudentEnrollment::STATUS_ACTIVE => "1" , - StudentEnrollment::STATUS_TRANSFERRED => "2" , - StudentEnrollment::STATUS_CANCELED => "3" , - StudentEnrollment::STATUS_ABANDONED => "4" , - StudentEnrollment::STATUS_RESTORED => "5" , - StudentEnrollment::STATUS_APPROVED => "6" , - StudentEnrollment::STATUS_APPROVEDBYCOUNCIL => "7" , - StudentEnrollment::STATUS_DISAPPROVED => "8" , - StudentEnrollment::STATUS_CONCLUDED => "9" , - StudentEnrollment::STATUS_INDETERMINED => "10" , - StudentEnrollment::STATUS_DEATH => "11" , - StudentEnrollment::STATUS_ADVANCED => "12", - StudentEnrollment::STATUS_REINTEGRATED => "13" + public static function getStatusId($status) + { + $statusList = [ + StudentEnrollment::STATUS_ACTIVE => "1", + StudentEnrollment::STATUS_TRANSFERRED => "2", + StudentEnrollment::STATUS_CANCELED => "3", + StudentEnrollment::STATUS_ABANDONED => "4", + StudentEnrollment::STATUS_RESTORED => "5", + StudentEnrollment::STATUS_APPROVED => "6", + StudentEnrollment::STATUS_APPROVEDBYCOUNCIL => "7", + StudentEnrollment::STATUS_DISAPPROVED => "8", + StudentEnrollment::STATUS_CONCLUDED => "9", + StudentEnrollment::STATUS_INDETERMINED => "10", + StudentEnrollment::STATUS_DEATH => "11", + StudentEnrollment::STATUS_ADVANCED => "12", + StudentEnrollment::STATUS_REINTEGRATED => "13" ]; return $statusList[$status]; diff --git a/app/repository/FormsRepository.php b/app/repository/FormsRepository.php index a328eb0ea..eedef15f3 100644 --- a/app/repository/FormsRepository.php +++ b/app/repository/FormsRepository.php @@ -29,35 +29,16 @@ private function contentsPerDisciplineCalculate($classroom, $disciplineId, $enro if ($totalContents == 0) { //Caso não haja preenchimento em gradeResults ou seja 0 if (TagUtils::isStageMinorEducation($classroom->edcenso_stage_vs_modality_fk)) { - $condition = 's.classroom_fk = :classroomId'; - $params = array( - ':classroomId' => $classroom->id, + $totalContents = ClassContents::model()->getTotalClassesMinorStage( + $classroom->id, + ); } else { - $condition = 's.classroom_fk = :classroomId AND s.discipline_fk = :disciplineId'; - $params = array( - ':classroomId' => $classroom->id, - ':disciplineId' => $disciplineId, + $totalContents = ClassContents::model()->getTotalClassesByClassroomAndDiscipline( + $classroom->id, + $disciplineId, ); } - $schedulesWithContent = Schedule::model()->findAll(array( - 'alias' => "s", - 'join' => 'JOIN class_contents cc ON cc.schedule_fk = s.id', - 'condition' => $condition, - 'params' => $params, - )); - foreach($schedulesWithContent as $scheduleWithContent) { - $schedules = Schedule::model()->findAll(array( - 'condition' => 'classroom_fk = :classroomId AND discipline_fk = :disciplineId and day = :day and month = :month', - 'params' => array( - ':day' => $scheduleWithContent->day, - ':month' => $scheduleWithContent->month, - ':classroomId' => $classroom->id, - ':disciplineId' => $disciplineId, - ), - )); - $totalContents += count($schedules); - } } return $totalContents; @@ -188,16 +169,9 @@ private function workloadsCalculate($schedulesPerUnityPeriods) return $workloadsPerUnity; } - private function separateBaseDisciplines($disciplineId) + private function separateBaseDisciplines($disciplineId, $isMinorEducation) { - // verifica se a disciplina faz parte da BNCC - if ($disciplineId == 6 || $disciplineId == 10 || $disciplineId == 11 || $disciplineId == 7 || - $disciplineId == 3 || $disciplineId == 5 || $disciplineId == 12 || $disciplineId == 13 || - $disciplineId == 26) - { - return true; - } - return false; + return $isMinorEducation || ($disciplineId < 99) ; } private function getPartialRecovery($stage) @@ -227,12 +201,13 @@ public function getEnrollmentGrades($enrollmentId) : array $result = array(); // array de notas $baseDisciplines = array(); // disciplinas da BNCC $diversifiedDisciplines = array(); //disciplinas diversas - $enrollment = StudentEnrollment::model()->findByPk($enrollmentId); + $enrollment = StudentEnrollment::model()->with(['classFaults', "classroomFk"])->findByPk($enrollmentId); $gradesResult = GradeResults::model()->findAllByAttributes(["enrollment_fk" => $enrollmentId]); // medias do aluno na turma $classFaults = ClassFaults::model()->findAllByAttributes(["student_fk" => $enrollment->studentFk->id]); // faltas do aluno na turma - $curricularMatrix = CurricularMatrix::model()->findAllByAttributes(["stage_fk" => $enrollment->classroomFk->edcenso_stage_vs_modality_fk, "school_year" => $enrollment->classroomFk->school_year]); // matriz da turma + $curricularMatrix = CurricularMatrix::model()->with("disciplineFk")->findAllByAttributes(["stage_fk" => $enrollment->classroomFk->edcenso_stage_vs_modality_fk, "school_year" => $enrollment->classroomFk->school_year]); // matriz da turma $unities = GradeUnity::model()->findAllByAttributes(["edcenso_stage_vs_modality_fk" => $enrollment->classroomFk->edcenso_stage_vs_modality_fk]); // unidades da turma $partialRecovery = $this->getPartialRecovery($enrollment->classroomFk->edcenso_stage_vs_modality_fk); + $isMinorEducation = TagUtils::isStageMinorEducation($enrollment->classroomFk->edcensoStageVsModalityFk->edcenso_associated_stage_id); // Ajusta ordem das unidades se houver rec. Final $recFinalIndex = array_search('RF', array_column($unities, 'type')); @@ -244,7 +219,7 @@ public function getEnrollmentGrades($enrollmentId) : array // Aqui eu separo as disciplinas da BNCC das disciplinas diversas para depois montar o cabeçalho foreach ($curricularMatrix as $matrix) { - if($this->separateBaseDisciplines($matrix->discipline_fk)) { // se for disciplina da BNCC + if($this->separateBaseDisciplines($matrix->disciplineFk->edcenso_base_discipline_fk, $isMinorEducation)) { // se for disciplina da BNCC array_push($baseDisciplines, $matrix->disciplineFk->id); }else { // se for disciplina diversa array_push($diversifiedDisciplines, $matrix->disciplineFk->id); @@ -274,7 +249,8 @@ public function getEnrollmentGrades($enrollmentId) : array // cálculo de aulas dadas $totalContentsPerDiscipline = $this->contentsPerDisciplineCalculate($enrollment->classroomFk, $discipline, $enrollment->id); - $totalFaultsPerDicipline = $this->faultsPerDisciplineCalculate($schedulesPerUnityPeriods, $discipline, $classFaults, $enrollment->id); + + $totalFaultsPerDicipline = $enrollment->countFaultsDiscipline($discipline); foreach ($gradesResult as $gradeResult) { // se existe notas para essa disciplina @@ -286,7 +262,7 @@ public function getEnrollmentGrades($enrollmentId) : array "partial_recoveries" => $partialRecovery, "total_number_of_classes" => $totalContentsPerDiscipline, "total_faults" => $totalFaultsPerDicipline, - "frequency_percentage" => (($totalContentsPerDiscipline - $totalFaultsPerDicipline) / ($totalContentsPerDiscipline ?: 1)) * 100 + "frequency_percentage" => round((($totalContentsPerDiscipline - $totalFaultsPerDicipline) / ($totalContentsPerDiscipline ?: 1)) * 100) ]); $mediaExists = true; break; // quebro o laço para diminuir a complexidade do algoritmo para O(log n)2 @@ -301,7 +277,7 @@ public function getEnrollmentGrades($enrollmentId) : array "partial_recoveries" => $partialRecovery, "total_number_of_classes" => $totalContentsPerDiscipline, "total_faults" => $totalFaultsPerDicipline, - "frequency_percentage" => (($totalContentsPerDiscipline - $totalFaultsPerDicipline) / ($totalContentsPerDiscipline ?: 1)) * 100 + "frequency_percentage" => round((($totalContentsPerDiscipline - $totalFaultsPerDicipline) / ($totalContentsPerDiscipline ?: 1)) * 100) ]); } } @@ -327,6 +303,7 @@ public function getEnrollmentGrades($enrollmentId) : array "school_days" => $schoolDaysPerUnity, "faults" => $faultsPerUnity, "workload" => $workloadPerUnity, + "isMinorEducation" => $isMinorEducation ); return $response; @@ -761,6 +738,8 @@ public function getAtaSchoolPerformance($classroomId) : array $classroom = Classroom::model()->findByPk($classroomId); + $isMinorEducation = TagUtils::isStageMinorEducation($classroom->edcensoStageVsModalityFk->edcenso_associated_stage_id); + $sql = "SELECT ed.id AS 'discipline_id', ed.name AS 'discipline_name', ed.abbreviation AS 'discipline_abbreviation' FROM curricular_matrix cm JOIN edcenso_discipline ed ON ed.id = cm.discipline_fk @@ -775,7 +754,7 @@ public function getAtaSchoolPerformance($classroomId) : array $baseDisciplines = array(); $diversifiedDisciplines = array(); foreach ($disciplines as $discipline) { - if($this->separateBaseDisciplines($discipline["discipline_id"])) { // se for disciplina da BNCC + if($this->separateBaseDisciplines($discipline["discipline_id"],$isMinorEducation)) { // se for disciplina da BNCC array_push($baseDisciplines, $discipline); }else { // se for disciplina diversa array_push($diversifiedDisciplines, $discipline); diff --git a/config.php b/config.php index 60c862795..c520f54b7 100644 --- a/config.php +++ b/config.php @@ -7,7 +7,7 @@ defined('YII_DEBUG') or define('YII_DEBUG', $debug); defined("SESSION_MAX_LIFETIME") or define('SESSION_MAX_LIFETIME', 3600); -define("TAG_VERSION", '3.94.213'); +define("TAG_VERSION", '3.94.214'); define("YII_VERSION", Yii::getVersion()); define("BOARD_MSG", '
Novas atualizações no TAG. Confira clicando aqui.
'); diff --git a/themes/default/views/forms/EnrollmentGradesReport.php b/themes/default/views/forms/EnrollmentGradesReport.php index b7387fb81..d3a701161 100755 --- a/themes/default/views/forms/EnrollmentGradesReport.php +++ b/themes/default/views/forms/EnrollmentGradesReport.php @@ -9,52 +9,23 @@ function classroomDisciplineLabelResumeArray($id) { - $disciplinas = array( - 1 => 'Química', - 2 => 'Física', - 3 => 'Matemática', - 4 => 'Biologia', - 5 => 'Ciências', - 6 => 'Português', - 7 => 'Inglês', - 8 => 'Espanhol', - 9 => 'Outro Idioma', - 10 => 'Artes', - 11 => 'Educação Física', - 12 => 'História', - 13 => 'Geografia', - 14 => 'Filosofia', - 16 => 'Informática', - 17 => 'Disc. Profissionalizante', - 20 => 'Educação Especial', - 21 => 'Sociedade e Cultura', - 23 => 'Libras', - 25 => 'Disciplinas pedagógicas', - 26 => 'Ensino religioso', - 27 => 'Língua indígena', - 28 => 'Estudos Sociais', - 29 => 'Sociologia', - 30 => 'Francês', - 99 => 'Outras Disciplinas', - 10001 => 'Redação', - 10002 => 'Linguagem oral e escrita', - 10003 => 'Natureza e sociedade', - 10004 => 'Movimento', - 10005 => 'Música', - 10006 => 'Artes visuais', - 10007 => 'Acompanhamento Pedagógico', - 10008 => 'Teatro', - 10009 => 'Canteiro Sustentável', - 10010 => 'Dança', - 10011 => 'Cordel', - 10012 => 'Física' - ); - $stage = EdcensoDiscipline::model()->findByPk($id); - return substr($stage->abbreviation ?? $stage->name, 0, 50); - + $discipline = EdcensoDiscipline::model()->findByPk($id); + return substr( empty($discipline->abbreviation) ? $discipline->name : $discipline->abbreviation, 0, 50); } $diciplinesColumnsCount = count($baseDisciplines) + count($diversifiedDisciplines); // contador com a soma do total de disciplinas da matriz + +function calculateFrequence($numClasses, $numFalts): int { + if(empty($numClasses) || is_nan($numClasses)){ + return 100; + } + + $aulasdadas = (int) $numClasses; + $faltas = (int) $numFalts; + + return round((($aulasdadas - $faltas) * 100) / $aulasdadas); +} + ?>
@@ -98,16 +69,11 @@ class="table table-bordered report-table-empty"> PARTES DO CURRÍCULO 0) { ?> - BASE - NACIONAL - COMUM - + 0) { ?> - PARTE - DIVERSIFICADA + + PARTE DIVERSIFICADA @@ -194,27 +160,39 @@ class="table table-bordered report-table-empty"> TOTAL DE AULAS DADAS - - - + + + + + + + TOTAL DE FALTAS - - - + + + + + + + FREQUÊNCIAS % - - - + + + + + + + @@ -222,6 +200,7 @@ class="table table-bordered report-table-empty">
+

* As aulas dadas na educação infantil são calculadas por dias registrados e não pelos horários

RESULTADO FINAL: _____________________________
Local e Data @@ -254,11 +233,11 @@ class="table table-bordered report-table-empty"> } .vertical-text div { - transform: translate(25px, 0px) rotate(270deg); - width: 100px; + height: 100px; line-height: 13px; margin: 0 10px 0 0; - transform-origin: bottom left; + writing-mode: sideways-lr; + text-orientation: mixed; } td { From b541d6ac2d8dc2ed1b9ff31962fb2fe142bbc4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gon=C3=A7alves?= Date: Fri, 27 Dec 2024 18:35:23 -0300 Subject: [PATCH 3/4] fix: invalidate cache assets --- app/modules/aeerecord/views/default/_form.php | 4 +- app/modules/aeerecord/views/default/admin.php | 4 +- app/modules/aeerecord/views/default/index.php | 4 +- .../classdiary/views/default/classDays.php | 2 +- .../classdiary/views/default/classDiary.php | 4 +- .../classdiary/views/default/index.php | 6 +- app/modules/dashboard/views/default/index.php | 2 +- app/modules/foods/views/default/_form.php | 4 +- .../foods/views/farmerregister/_form.php | 4 +- .../foods/views/foodinventory/_form.php | 4 +- app/modules/foods/views/foodmenu/_form.php | 6 +- .../foods/views/foodmenu/viewlunch.php | 2 +- app/modules/foods/views/foodnotice/_form.php | 6 +- app/modules/foods/views/foodrequest/_form.php | 222 +++++++++--------- .../schoolreport/views/default/frequency.php | 2 +- .../schoolreport/views/default/grades.php | 2 +- app/modules/stages/views/default/_form.php | 2 +- themes/default/views/admin/instanceConfig.php | 4 +- themes/default/views/grades/grades.php | 6 +- 19 files changed, 145 insertions(+), 145 deletions(-) diff --git a/app/modules/aeerecord/views/default/_form.php b/app/modules/aeerecord/views/default/_form.php index 5c8912abd..e9f139b46 100644 --- a/app/modules/aeerecord/views/default/_form.php +++ b/app/modules/aeerecord/views/default/_form.php @@ -7,8 +7,8 @@ $themeUrl = Yii::app()->theme->baseUrl; $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '/_initialization.js', CClientScript::POS_END); -$cs->registerScriptFile($baseScriptUrl . '/functions.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/functions.js?v='.TAG_VERSION, CClientScript::POS_END); $form=$this->beginWidget('CActiveForm', array( 'id'=>'student-aee-record-form', diff --git a/app/modules/aeerecord/views/default/admin.php b/app/modules/aeerecord/views/default/admin.php index d31ffe0c2..a47d290d7 100644 --- a/app/modules/aeerecord/views/default/admin.php +++ b/app/modules/aeerecord/views/default/admin.php @@ -11,8 +11,8 @@ $themeUrl = Yii::app()->theme->baseUrl; $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '/_initialization.js', CClientScript::POS_END); -$cs->registerScriptFile($baseScriptUrl . '/functions.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/functions.js?v='.TAG_VERSION, CClientScript::POS_END); $this->menu=array( array('label'=>'Create StudentAeeRecord', 'url'=>array('create')), diff --git a/app/modules/aeerecord/views/default/index.php b/app/modules/aeerecord/views/default/index.php index 8374846ab..4b1770267 100644 --- a/app/modules/aeerecord/views/default/index.php +++ b/app/modules/aeerecord/views/default/index.php @@ -11,8 +11,8 @@ $themeUrl = Yii::app()->theme->baseUrl; $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '/_initialization.js', CClientScript::POS_END); -$cs->registerScriptFile($baseScriptUrl . '/functions.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/functions.js?v='.TAG_VERSION, CClientScript::POS_END); $this->menu=array( array('label'=>'Create StudentAeeRecord', 'url'=>array('create')), diff --git a/app/modules/classdiary/views/default/classDays.php b/app/modules/classdiary/views/default/classDays.php index 35c56b9c7..e7e2e718a 100644 --- a/app/modules/classdiary/views/default/classDays.php +++ b/app/modules/classdiary/views/default/classDays.php @@ -6,7 +6,7 @@ ); $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '/classDays/_initialization.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/classDays/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END); ?>

diff --git a/app/modules/classdiary/views/default/classDiary.php b/app/modules/classdiary/views/default/classDiary.php index 0f10d8401..bbd0bcaf9 100644 --- a/app/modules/classdiary/views/default/classDiary.php +++ b/app/modules/classdiary/views/default/classDiary.php @@ -6,8 +6,8 @@ ); $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '/classDiary/_initialization.js', CClientScript::POS_END); -$cs->registerScriptFile($baseScriptUrl . '/classDiary/functions.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/classDiary/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/classDiary/functions.js?v='.TAG_VERSION, CClientScript::POS_END); ?>
diff --git a/app/modules/classdiary/views/default/index.php b/app/modules/classdiary/views/default/index.php index dbdb76d65..bc1ffd4ce 100644 --- a/app/modules/classdiary/views/default/index.php +++ b/app/modules/classdiary/views/default/index.php @@ -6,11 +6,11 @@ ); $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '/index/functions.js', CClientScript::POS_END); -$cs->registerScriptFile($baseScriptUrl . '/index/_initialization.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/index/functions.js?v='.TAG_VERSION, CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '/index/_initialization.js?v='.TAG_VERSION, CClientScript::POS_END); ?>

Diário de Classe

-
\ No newline at end of file +
diff --git a/app/modules/dashboard/views/default/index.php b/app/modules/dashboard/views/default/index.php index da62e1bb4..c55083c74 100644 --- a/app/modules/dashboard/views/default/index.php +++ b/app/modules/dashboard/views/default/index.php @@ -7,7 +7,7 @@ $baseScriptUrl = Yii::app()->controller->module->baseScriptUrl; $cs = Yii::app()->getClientScript(); -$cs->registerScriptFile($baseScriptUrl . '\powerbi.js', CClientScript::POS_END); +$cs->registerScriptFile($baseScriptUrl . '\powerbi.js?v='.TAG_VERSION, CClientScript::POS_END); ?>