Skip to content
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

fix: couldn't register the class on the absent day #723

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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.81.173]
- Validações foram realizadas para impedir que professores registrem suas aulas nos dias em que estiveram ausentes

## [Versão 3.81.172]
- Adicionado Sábado letivo aos cardápios

Expand Down
24 changes: 22 additions & 2 deletions app/controllers/ClassesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,32 @@ public function actionGetClassContents()
"valid" => true,
"classContents" => $classContents,
"courseClasses" => $courseClasses,
"daysFaults" => $this->getInstructorFaultDays(Yii::app()->user->loginInfos->id)
]);
} else {
echo json_encode(["valid" => false, "error" => "Mês/Ano " . ($_POST["fundamentalMaior"] == "1" ? "e Disciplina" : "") . " sem aula no Quadro de Horário."]);
}
}

private function getInstructorFaultDays($instructorId) {
$featuresComponent = new FeaturesComponent();
$isEnable = $featuresComponent->isEnable(strtoupper(INSTANCE));

if ($isEnable) {
$command = Yii::app()->db->createCommand("
SELECT s.day
FROM instructor_faults if2
JOIN schedule s ON if2.schedule_fk = s.id
WHERE if2.instructor_fk = (SELECT id from instructor_identification ii WHERE ii.users_fk = :instructor_id);"
);

$command->bindValue(':instructor_id', $instructorId);
$daysFaults = $command->queryColumn();

return $daysFaults;
}
}

private function getSchedulesFromMajorStage($classroomId, $month, $year, $disciplineId)
{
return Schedule::model()->findAll(
Expand Down Expand Up @@ -484,8 +504,8 @@ public function actionGetFrequency()
}
array_push($students, $array);
}
echo json_encode(["valid" => true, "students" => $students, "scheduleDays"=>$scheduleDays, "schedulePerDays"=>$schedulePerDays]);

$daysFaults = $this->getInstructorFaultDays(Yii::app()->user->loginInfos->id);
echo json_encode(["valid" => true, "students" => $students, "scheduleDays" => $scheduleDays, "schedulePerDays"=>$schedulePerDays, "daysFaults" => $daysFaults]);
} else {
echo json_encode(["valid" => false, "error" => "Matricule alunos nesta turma para trazer o Quadro de Frequência."]);
}
Expand Down
2 changes: 2 additions & 0 deletions app/migrations/2024-07-11_frequency_teacher/sql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO instance_config (parameter_key,parameter_name,value)
VALUES ('MURIBECA.TAG.ONG.BR','Proibir registro de aula por professor ausente no dia da falta','1');
53 changes: 38 additions & 15 deletions app/modules/classdiary/views/default/_frequencyElementMobile.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
<?php if($frequency["valid"] == true): ?>
<div class="t-badge-info"><span class="t-info_positive t-badge-info__icon"></span>Para justificar falta e avaliação de Aluno clique no ícone </div>
<div class="t-badge-info">
<span class="t-info_positive t-badge-info__icon"></span>
Para justificar falta e avaliação de Aluno clique no ícone
</div>

<?php
$command = Yii::app()->db->createCommand("
SELECT s.day
FROM instructor_faults if2
JOIN schedule s ON if2.schedule_fk = s.id
WHERE if2.instructor_fk = (SELECT id from instructor_identification ii WHERE ii.users_fk = :instructor_id);"
);

$command->bindValue(':instructor_id', Yii::app()->user->loginInfos->id);
$daysFaults = $command->queryColumn();
$dateParts = explode('/', $date);
$usFormattedDate = $dateParts[1] . '/' . $dateParts[0] . '/' . $dateParts[2];
$dayToCheck = date('j', strtotime($usFormattedDate));

if (!in_array($dayToCheck, $daysFaults)) {
?>
<table aria-label="Tabela de alunos" class="column clearfix tag-table-secondary js-table-frequency">
<thead>
<tr>
Expand All @@ -12,19 +32,22 @@
</tr>
</thead>
<tbody>

<?php foreach ($frequency["students"] as $f):
$url_link = yii::app()->createUrl('classdiary/default/StudentClassDiary', array('student_id' => $f["studentId"], 'stage_fk' => $stage_fk, 'classroom_id' => $classroom_fk, 'schedule' => $f["schedule"]["schedule"], 'date' => $date, 'discipline_fk' => $discipline_fk, "justification" => $f["schedule"]["justification"])) ;
$is_disabled = (!$f["schedule"]["available"] ? "disabled" : "");
?>
<tr>
<td> <a class='js-justification' href='<?= $url_link ?>'><span class="t-icon-annotation t-icon "></span><?php echo $f["studentName"]; ?></a></td>
<td class='justify-content--end' <?= $is_disabled ?>><input class='js-frequency-checkbox' id="<?php echo $f["studentId"] ?>" type='checkbox' <?= $is_disabled ?> <?php echo ( $f["schedule"]["fault"] ? "checked" : "") ?>
data-studentId='<?php echo $f["studentId"] ?>' data-classroom_id='<?php echo $classroom_fk ?>' data-stage_fk='<?php echo $stage_fk ?>' data-schedule='<?php echo $f["schedule"]["schedule"]?>'/></td>
</tr>
<?php endforeach ?>
<?php foreach ($frequency["students"] as $f):
$url_link = yii::app()->createUrl('classdiary/default/StudentClassDiary', array('student_id' => $f["studentId"], 'stage_fk' => $stage_fk, 'classroom_id' => $classroom_fk, 'schedule' => $f["schedule"]["schedule"], 'date' => $date, 'discipline_fk' => $discipline_fk, "justification" => $f["schedule"]["justification"])) ;
$is_disabled = (!$f["schedule"]["available"] ? "disabled" : "");
?>
<tr>
<td> <a class='js-justification' href='<?= $url_link ?>'><span class="t-icon-annotation t-icon "></span><?php echo $f["studentName"]; ?></a></td>
<td class='justify-content--end' <?= $is_disabled ?>><input class='js-frequency-checkbox' id="<?php echo $f["studentId"] ?>" type='checkbox' <?= $is_disabled ?> <?php echo ( $f["schedule"]["fault"] ? "checked" : "") ?>
data-studentId='<?php echo $f["studentId"] ?>' data-classroom_id='<?php echo $classroom_fk ?>' data-stage_fk='<?php echo $stage_fk ?>' data-schedule='<?php echo $f["schedule"]["schedule"]?>'/></td>
</tr>
<?php endforeach ?>
</tbody>
</table>
<?php else :?>
<div class="t-badge-critical"><span class="t-info_positive t-badge-critical__icon"></span><?= $frequency["error"];?> </div>
<?php endif?>

<?php
} else {
echo '<div class="msg" style="padding: 10px;background: #eaeaf8;font-weight: bold;">Professor ausente para este dia</div>';
}
endif;
?>
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.81.172');
define("TAG_VERSION", '3.81.173');

define("YII_VERSION", Yii::getVersion());
define("BOARD_MSG", '<div class="alert alert-success">Novas atualizações no TAG. Confira clicando <a class="changelog-link" href="?r=admin/changelog">aqui</a>.</div>');
Expand Down
31 changes: 26 additions & 5 deletions js/classes/class-contents/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ function createTable(data) {
accordionHtml += `<div id='accordion' class='t-accordeon-primary' style='overflow: auto; height: 400px;'>`
$.each(data.classContents, function (day, classContent) {
let studentInputs = "";

arrayFaults = [];

if(data.daysFaults !== null){
$.each(data.daysFaults, function (index, daysFaults) {
arrayFaults.push(parseInt(daysFaults, 10));
});
}

if (Object.keys(classContent.students).length) {
$.each(classContent.students, function (index, studentArray) {
$.each(studentArray, function (index, student) {
Expand Down Expand Up @@ -42,14 +51,26 @@ function createTable(data) {
}

let head = '<th class="center vmiddle contents-day ">' + ((day < 10) ? '0' : '') + day + '</th>';
let disabledRow = (!classContent.available || arrayFaults.includes(parseInt(day, 10))) ? "disabled" : "";

let body = '<td class="t-multiselect">'
+ '<input type="hidden" class="classroom-diary-of-the-day" value="' + classContent.diary + '">'
+ studentInputs
+ '<span class="t-icon-annotation t-icon classroom-diary-button ' + (!classContent.available ? "disabled" : "") + '" data-toggle="tooltip" title="Diário"></span>'
+ '<select id="day[' + day + ']" name="day[' + day + '][]" class=" course-classes-select vmiddle" ' + (!classContent.available ? "disabled" : "") + ' multiple="yes">'
+ studentInputs;

if (disabledRow !== "disabled") {
body += '<span class="t-icon-annotation t-icon classroom-diary-button ' + (!classContent.available ? "disabled" : "") + '" data-toggle="tooltip" title="Diário"></span>';
}

body += '<select id="day[' + day + ']" name="day[' + day + '][]" class=" course-classes-select vmiddle" ' + disabledRow + ' multiple="yes">'
+ options
+ '</select>'
+ '</td>';
+ '</select>';

if (arrayFaults.includes(parseInt(day, 10))) {
body += '<div class="disabled-message">Não é possível registrar a aula, pois o professor não estava presente neste dia.</div>';
}

body += '</td>';

$('#class-contents > tbody').append('<tr class="center day-row" day="' + day + '">' + head + body + '</tr>');
let select = $("select.course-classes-select").last();
select.children("option").each(function () {
Expand Down
35 changes: 25 additions & 10 deletions js/classes/frequency/_initialization_instructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,36 @@ function generateStudentLines(data, dia, mes, ano, fundamentalMaior, monthSplit)
}, '');
}
function generateScheduleDays(data, monthSplit, fundamentalMaior) {
daysFaltsTeacher = data.daysFaults;

return data.scheduleDays.reduce((acc, scheduleDays) => {
let dia = scheduleDays.day;
let mes = monthSplit[1];
let ano = monthSplit[0];
return acc + `
<div class="ui-accordion-header justify-content--space-between">
<div>Aula do dia ${scheduleDays.date}</div>
<div>
<span class="t-icon-down_arrow arrow"></span>

if(daysFaltsTeacher.includes(dia)){
acc += `
<div class="ui-accordion-header justify-content--space-between" style="pointer-events: none;">
<div>Professor(a) ausente para o dia: ${scheduleDays.date}</div>
<div></div>
</div>
</div>
<div class='ui-accordion-content'>
<div style='width: 100%; overflow-x:auto;'>
${generateStudentLines(data, dia, mes, ano, fundamentalMaior, monthSplit)}
<div></div>`;
}else{
acc += `
<div class="ui-accordion-header justify-content--space-between">
<div>Aula do dia ${scheduleDays.date}</div>
<div>
<span class="t-icon-down_arrow arrow"></span>
</div>
</div>
</div>`;
<div>
<div'>
${generateStudentLines(data, dia, mes, ano, fundamentalMaior, monthSplit)}
</div>
</div>`;
}

return acc;
}, '');
}

Expand Down Expand Up @@ -104,6 +118,7 @@ function load() {
$(function () {
$("#accordion").accordion({
collapsible: true,
active: false,
icons: null,
});
});
Expand Down
Loading