-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from portabilis/portabilis-patch-2022-07-10
[1.4] Portabilis patch 10/07/2022
- Loading branch information
Showing
125 changed files
with
2,263 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function fetchStudentsInRecovery(classroom, discipline, exam_rule, step_id, recorded_at, success_callback) { | ||
if (_.isEmpty(step_id) || _.isEmpty(moment(recorded_at, 'MM-DD-YYYY')._i) || exam_rule.recovery_type === 0) { | ||
return; | ||
} | ||
|
||
$.ajax({ | ||
url: Routes.in_recovery_students_pt_br_path({ | ||
classroom_id: classroom, | ||
discipline_id: discipline, | ||
step_id: step_id, | ||
date: recorded_at, | ||
format: 'json' | ||
}), | ||
success: success_callback, | ||
error: handleFetchStudentsInRecoveryError | ||
}); | ||
} | ||
|
||
function hideNoItemMessage() { | ||
$('.no_item_found').hide(); | ||
} | ||
|
||
function loadDecimalMasks() { | ||
let numberOfDecimalPlaces = $('#recovery-diary-record-students').data('scale'); | ||
$('.nested-fields input.decimal').inputmask('customDecimal', { digits: numberOfDecimalPlaces }); | ||
} | ||
|
||
function handleFetchStudentsInRecoveryError() { | ||
flashMessages.error('Ocorreu um erro ao buscar os alunos.'); | ||
} |
35 changes: 35 additions & 0 deletions
35
app/assets/javascripts/templates/avaliation_recovery_lowest_notes/student_fields.jst.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<tr class="nested-fields" id="<%= id %>"> | ||
<td> | ||
<div class="control-group hidden avaliation_recovery_lowest_note_recovery_diary_record_students_student_id"> | ||
<div class="controls input"> | ||
<input class="hidden" type="hidden" name="avaliation_recovery_lowest_note[recovery_diary_record_attributes][students_attributes][<%= element_id %>][student_id]" id="avaliation_recovery_lowest_note_recovery_diary_record_attributes_students_attributes_<%= element_id %>_student_id" value=<%= id %>> | ||
</div> | ||
</div> | ||
|
||
<% if(exempted_from_discipline) { %> | ||
<span class="exempted-student-from-discipline">****<%= name %></span> | ||
<% } else { %> | ||
<span class="multiline"><%= name %></span> | ||
<% } %> | ||
</td> | ||
|
||
<td> | ||
<span class="current-lowest-note"> | ||
<%= lowest_note_in_step %> | ||
</span> | ||
</td> | ||
|
||
<td> | ||
<div class="control-group decimal optional school_term_recovery_diary_record_recovery_diary_record_students_score"> | ||
<label class="decimal optional control-label hidden" for="avaliation_recovery_lowest_note_recovery_diary_record_attributes_students_attributes_<%= element_id %>_score"> | ||
Nota | ||
</label> | ||
<div class="controls input"> | ||
<input class="string decimal form-control decimal form-control decimal optional" type="decimal" | ||
name="avaliation_recovery_lowest_note[recovery_diary_record_attributes][students_attributes][<%= element_id %>][score]" | ||
id="avaliation_recovery_lowest_note_recovery_diary_record_attributes_students_attributes_<%= element_id %>_score" | ||
<% if(exempted_from_discipline) { %> readonly <% } %>> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> |
210 changes: 210 additions & 0 deletions
210
app/assets/javascripts/views/avaliation_recovery_lowest_notes/form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
$(function () { | ||
'use strict'; | ||
|
||
let flashMessages = new FlashMessages(); | ||
let examRule = null; | ||
let $unity = $('#avaliation_recovery_lowest_note_recovery_diary_record_attributes_unity_id'); | ||
let $classroom = $('#avaliation_recovery_lowest_note_recovery_diary_record_attributes_classroom_id'); | ||
let $discipline = $('#avaliation_recovery_lowest_note_recovery_diary_record_attributes_discipline_id'); | ||
let $step = $('#avaliation_recovery_lowest_note_step_id'); | ||
let $recorded_at = $('#avaliation_recovery_lowest_note_recorded_at'); | ||
let $submitButton = $('input[type=submit]'); | ||
|
||
function fetchExamRule() { | ||
let classroom_id = $classroom.select2('val'); | ||
|
||
if (_.isEmpty(classroom_id)) { | ||
flashMessages.error('É necessário selecionar uma turma.'); | ||
} else { | ||
$.ajax({ | ||
url: Routes.exam_rules_pt_br_path({ classroom_id: classroom_id, format: 'json' }), | ||
success: handleFetchExamRuleSuccess, | ||
error: handleFetchExamRuleError | ||
}); | ||
} | ||
} | ||
|
||
function handleFetchExamRuleSuccess(data) { | ||
examRule = data.exam_rule; | ||
} | ||
|
||
function handleFetchExamRuleError() { | ||
flashMessages.error('Ocorreu um erro ao buscar a regra de avaliação da turma selecionada.'); | ||
} | ||
|
||
$recorded_at.on('focusin', function(){ | ||
$(this).data('oldDate', $(this).val()); | ||
}); | ||
|
||
function checkPersistedDailyNote() { | ||
let step_id = $step.select2('val'); | ||
|
||
let filter = { | ||
by_classroom_id: $classroom.select2('val'), | ||
by_unity_id: $unity.select2('val'), | ||
by_discipline_id: $discipline.select2('val'), | ||
by_step_id: step_id, | ||
with_daily_note_students: true | ||
}; | ||
|
||
if (!_.isEmpty(step_id)) { | ||
$.ajax({ | ||
url: Routes.search_daily_notes_pt_br_path({ filter: filter, format: 'json' }), | ||
success: handleFetchCheckPersistedDailyNoteSuccess, | ||
error: handleFetchCheckPersistedDailyNoteError | ||
}); | ||
} | ||
} | ||
|
||
function handleFetchCheckPersistedDailyNoteSuccess(data) { | ||
if(_.isEmpty(data.daily_notes)){ | ||
flashMessages.error('A turma selecionada não possui notas lançadas nesta etapa.'); | ||
} else { | ||
flashMessages.pop(''); | ||
let step_id = $step.select2('val'); | ||
let recorded_at = $recorded_at.val(); | ||
fetchStudents($classroom.select2('val'), $discipline.select2('val'), examRule, step_id, recorded_at); | ||
} | ||
} | ||
|
||
function fetchStudents(classroom, discipline, exam_rule, step_id, recorded_at) { | ||
if (_.isEmpty(step_id) || _.isEmpty(moment(recorded_at, 'MM-DD-YYYY')._i)) { | ||
return; | ||
} | ||
|
||
$.ajax({ | ||
url: Routes.recovery_lowest_note_students_pt_br_path({ | ||
classroom_id: classroom, | ||
discipline_id: discipline, | ||
step_id: step_id, | ||
date: recorded_at, | ||
format: 'json' | ||
}), | ||
success: studentInLowestNoteRecovery, | ||
error: handleFetchStudentsError | ||
}); | ||
} | ||
|
||
function handleFetchStudentsError() { | ||
flashMessages.error('Ocorreu um erro ao buscar os alunos.'); | ||
} | ||
|
||
function studentInLowestNoteRecovery(data) { | ||
let students = data.students; | ||
|
||
if (!_.isEmpty(students)) { | ||
let element_counter = 0; | ||
hideNoItemMessage(); | ||
|
||
$('#recovery-diary-record-students').empty(); | ||
|
||
_.each(students, function(student) { | ||
let element_id = new Date().getTime() + element_counter++; | ||
buildStudentField(element_id, student); | ||
}); | ||
|
||
loadDecimalMasks(); | ||
} else { | ||
$recorded_at.val($recorded_at.data('oldDate')); | ||
|
||
flashMessages.error('Nenhum aluno encontrado.'); | ||
} | ||
|
||
function buildStudentField(element_id, student, index = null){ | ||
let html = JST['templates/avaliation_recovery_lowest_notes/student_fields']({ | ||
id: student.id, | ||
name: student.name, | ||
lowest_note_in_step: student.lowest_note_in_step, | ||
scale: 2, | ||
element_id: element_id, | ||
exempted_from_discipline: student.exempted_from_discipline | ||
}); | ||
|
||
let $tbody = $('#recovery-diary-record-students'); | ||
|
||
if ($.isNumeric(index)) { | ||
$(html).insertAfter($tbody.children('tr')[index]); | ||
} else { | ||
$tbody.append(html); | ||
} | ||
} | ||
} | ||
|
||
function handleFetchCheckPersistedDailyNoteError() { | ||
flashMessages.error('Ocorreu um erro ao buscar as notas lançadas para esta turma nesta etapa.'); | ||
} | ||
|
||
function checkExistsRecoveryLowestNoteOnStep() { | ||
let step_id = $step.select2('val'); | ||
let classroom_id = $classroom.select2('val'); | ||
let discipline_id = $discipline.select2('val'); | ||
|
||
if (_.isEmpty(step_id)) { | ||
flashMessages.error('É necessário selecionar uma etapa.'); | ||
} else { | ||
$.ajax({ | ||
url: Routes.exists_recovery_on_step_avaliation_recovery_lowest_notes_pt_br_path({ | ||
format: 'json', | ||
classroom_id: classroom_id, | ||
step_id: step_id, | ||
discipline_id: discipline_id | ||
}), | ||
success: handleFetchCheckExistsRecoveryLowestNoteOnStepSuccess, | ||
error: handleFetchCheckExistsRecoveryLowestNoteOnStepError | ||
}); | ||
} | ||
} | ||
|
||
function handleFetchCheckExistsRecoveryLowestNoteOnStepSuccess(data) { | ||
if (data === true) { | ||
flashMessages.error('A turma selecionada já possui uma Recuperação de menor nota nesta etapa.'); | ||
} else { | ||
flashMessages.pop(''); | ||
} | ||
} | ||
|
||
function handleFetchCheckExistsRecoveryLowestNoteOnStepError() { | ||
flashMessages.error('Ocorreu um erro ao buscar as recuperações de menor nota da etapa'); | ||
} | ||
|
||
function validDateOnStep() { | ||
let recorded_at = $recorded_at.val(); | ||
let step_id = $step.select2('val'); | ||
let classroom_id = $classroom.select2('val'); | ||
|
||
$.ajax({ | ||
url: Routes.recorded_at_in_selected_step_avaliation_recovery_lowest_notes_pt_br_path({ | ||
format: 'json', | ||
classroom_id: classroom_id, | ||
step_id: step_id, | ||
recorded_at: recorded_at | ||
}), | ||
success: handleFetchRecordedAtOnStepSuccess, | ||
error: handleFetchRecordedAtOnStepError | ||
}); | ||
} | ||
|
||
function handleFetchRecordedAtOnStepSuccess(data) { | ||
if (data === true) { | ||
flashMessages.pop(''); | ||
checkPersistedDailyNote(); | ||
} else { | ||
flashMessages.error('Data deve estar dentro da etapa selecionada'); | ||
} | ||
} | ||
|
||
function handleFetchRecordedAtOnStepError() { | ||
flashMessages.error('Ocorreu um erro ao validar a data'); | ||
} | ||
|
||
$step.on('change', checkExistsRecoveryLowestNoteOnStep); | ||
|
||
$recorded_at.on('change', validDateOnStep); | ||
|
||
$submitButton.on('click', function() { | ||
$recorded_at.unbind(); | ||
}); | ||
|
||
fetchExamRule(); | ||
loadDecimalMasks(); | ||
}); |
Oops, something went wrong.