Skip to content

Commit

Permalink
fix: recalculate values for frenquency and worloads
Browse files Browse the repository at this point in the history
  • Loading branch information
igorgoncalves committed Dec 27, 2024
1 parent 6db1b22 commit 765a3e7
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 308 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
165 changes: 96 additions & 69 deletions app/models/ClassContents.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
*/
class ClassContents extends CActiveRecord
{
/**
/**
* @return string the associated database table name
*/
*/
public function tableName()
{
{
return 'class_contents';
}
}

public function behaviors()
{
Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit 765a3e7

Please sign in to comment.