Skip to content

[TCDA-705]Feat/Add enrollment status label to Grades view #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.89.195]
- Label de status de matricula adicionado a tela de notas

## [Versão 3.89.196]
- Correção na funcionalidade de frequência, especificamente para alunos com matrícula transferida

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,13 @@ class StudentGradesResult
private $situation;
private $unities;
private $partialRecoveries;
private $enrollmentStatus;

public function __construct($studentName, $enrollmentId)
{
$this->studentName = $studentName;
$this->enrollmentId = $enrollmentId;
$this->enrollmentStatus = StudentEnrollment::model()->findByPk($enrollmentId)->getCurrentStatus();
}

public function getStudentName()
Expand Down Expand Up @@ -539,6 +541,7 @@ public function toArray(): array
return [
'studentName' => $this->studentName,
'enrollmentId' => $this->enrollmentId,
'enrollmentStatus' => $this->enrollmentStatus,
'finalMedia' => $this->finalMedia,
'semAvarage' => $this->semAvarage,
'situation' => $this->situation,
Expand Down
2 changes: 1 addition & 1 deletion app/models/Classroom.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function relations()
'classroom_fk',
'join' => 'JOIN student_identification ON student_identification.id=student_fk',
'order' => 'daily_order ASC, student_identification.name',
'condition' => 'status IN (1, 6, 7, 8, 9, 10) or status IS NULL'
'condition' => 'status IN (1, 2, 6, 7, 8, 9, 10) or status IS NULL'
),
'activeEnrollmentsCount' => array(
self::STAT,
Expand Down
32 changes: 29 additions & 3 deletions app/modules/classdiary/services/StudentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function getFrequency($classroom_fk, $stage_fk, $discipline_fk, $date) {
foreach ($enrollments as $enrollment) {
$array["studentId"] = $enrollment->student_fk;
$array["studentName"] = $enrollment->studentFk->name;
$array["status"] = $enrollment->status;
$array["statusLabel"] = $enrollment->getCurrentStatus();
$classFault = ClassFaults::model()->find("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $schedule->id, "student_fk" => $enrollment->student_fk]);
$available = date("Y-m-d") >= Yii::app()->user->year . "-" . str_pad($schedule->month, 2, "0", STR_PAD_LEFT);
$valid = $this->verifyStatusEnrollment( $enrollment, $schedule);
Expand All @@ -54,6 +56,8 @@ public function getFrequency($classroom_fk, $stage_fk, $discipline_fk, $date) {
foreach ($enrollments as $enrollment) {
$array["studentId"] = $enrollment->student_fk;
$array["studentName"] = $enrollment->studentFk->name;$array["studentName"] = $enrollment->studentFk->name;
$array["status"] = $enrollment->status;
$array["statusLabel"] = $enrollment->getCurrentStatus();
foreach($schedule as $s) {
$classFault = ClassFaults::model()->find("schedule_fk = :schedule_fk and student_fk = :student_fk", ["schedule_fk" => $s->id, "student_fk" => $enrollment->student_fk]);
$available = date("Y-m-d") >= Yii::app()->user->year . "-" . str_pad($s->month, 2, "0", STR_PAD_LEFT);
Expand Down Expand Up @@ -83,11 +87,33 @@ public function getFrequency($classroom_fk, $stage_fk, $discipline_fk, $date) {
private function verifyStatusEnrollment($enrollment, $schedule)
{
$dateFormat = 'd/m/Y';
$dateFormat2 = 'Y-m-d';

$date = $this->gerateDate($schedule->day, $schedule->month, $schedule->year, 0);
$startDate = date_create_from_format($dateFormat, $enrollment->school_readmission_date);
$transferedDate = date_create_from_format($dateFormat, $enrollment->class_transfer_date);

$startDate = DateTime::createFromFormat($dateFormat, $enrollment->school_readmission_date);
$returnDate = DateTime::createFromFormat($dateFormat, $enrollment->class_transfer_date);

$scheduleDate = date_create_from_format($dateFormat, $date);
return !(($scheduleDate < $startDate && $scheduleDate > $transferedDate) && $enrollment->status == '13') && $enrollment->status != '2' && $enrollment->status != '11';
$transferDate = isset($enrollment->transfer_date) ? DateTime::createFromFormat($dateFormat2, $enrollment->transfer_date) : null;


switch ($enrollment->status) {
case '2': // TRANSFERIDO
$result = isset($transferDate) && $scheduleDate <= $transferDate;
break;
case '13': // Aluno saiu e retornou
$result = ($scheduleDate < $startDate && $scheduleDate > $returnDate);
break;
case '11': // DEATH
$result = false;
break;
default: // Qualquer outro status
$result = true;
break;
}

return $result;
}

private function gerateDate($day, $month, $year, $usecase){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
<?php foreach ($frequency["students"] as $f):
?>
<tr>
<td><?php echo $f["studentName"]; ?></td>
<td>
<label class="t-badge-info t-margin-none--left <?=$f['status'] == '1' || $f['status'] == '' ? 'hide' : ''; ?>">
<?= $f['statusLabel'] ?>
</label>
<?php echo $f["studentName"]; ?>
</td>
<td class='justify-content--end'>
<?php foreach ($f["schedule"] as $s):
$is_disabled = ((!$s["available"] || !$s["valid"] ) ? "disabled" : "");
Expand Down
8 changes: 8 additions & 0 deletions js/grades/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ function GradeTableBuilder(data) {
class="enrollment-id"
value="${student.enrollmentId}"
/>
${buildEnrollmentStatusLabel(student.enrollmentStatus)}
${student.studentName}
</td>
${buildUnities(
Expand Down Expand Up @@ -231,6 +232,13 @@ function GradeTableBuilder(data) {
</td>`
: ''
}

function buildEnrollmentStatusLabel(status){
return `<label class="t-badge-info t-margin-none--left ${status == 'MATRICULADO' || status == '' ? 'hide' : ''}">
${status}
</label>`;
}

function buildUnities(unities, isUnityConcept, conceptOptions) {
const unitesGrade = unities
.map((unity) => {
Expand Down