Skip to content

Commit

Permalink
Mostra mensagem de erro caso o aluno tenha avaliação
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavomendess committed Jan 8, 2022
1 parent aa35a8a commit 7c2aa45
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/assets/javascripts/views/conceptual_exams/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $(function() {
show_inactive: false,
date: recorded_at
};

if (!_.isEmpty(classroom_id) && !_.isEmpty(recorded_at)) {
$.ajax({
url: Routes.by_date_student_enrollments_lists_pt_br_path({
Expand Down Expand Up @@ -324,15 +324,27 @@ $(function() {
)
).done(function(conceptual_exam_id) {
if (conceptual_exam_id) {
window.location.href = Routes.edit_conceptual_exam_pt_br_path(conceptual_exam_id);
exists_conceptual_exam(conceptual_exam_id);
} else {
flashMessages.pop('');
fetchExamRule();
removeDisciplines();
fetchDisciplines();
}
});
});

function exists_conceptual_exam(conceptual_exam_id) {
flashMessages.pop('');
removeDisciplines();
let text_step = $step.closest('div').find('#s2id_conceptual_exam_step_id').find('.select2-choice').text().trim();
let student_name = $student.closest('div').find('#s2id_conceptual_exam_student_id').find('.select2-choice').text().trim();
let redirect_link = Routes.edit_conceptual_exam_pt_br_path(conceptual_exam_id);
let message = `O(a) aluno(a) (${student_name}) já possui uma avaliação conceitual na etapa (${text_step}), para modificar a mesma clique aqui (<a href="${redirect_link}" style="color: white"><b>Avaliação</b></a>).`;

flashMessages.error(message);
}

if($('#current_action_').val() == 'new'){
$student.trigger('change');
}
Expand Down

0 comments on commit 7c2aa45

Please sign in to comment.