From 99641061780554e4eb3e51fbb100597ac2ff8a32 Mon Sep 17 00:00:00 2001 From: Jailson Pinheiro Lima Date: Fri, 23 Jan 2026 15:03:39 -0300 Subject: [PATCH 1/2] fix: add finish action in exam time error --- app/controllers/exam_responses_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/exam_responses_controller.rb b/app/controllers/exam_responses_controller.rb index caa2bd52b..e7c6aeaf2 100644 --- a/app/controllers/exam_responses_controller.rb +++ b/app/controllers/exam_responses_controller.rb @@ -50,6 +50,7 @@ def update SysLog::Actions.log_info do "[PROVA] Não salvou resposta para user_id=#{current_user.try(:id)}, exam_response=#{params[:id]} - erro erro com data ou duração - duration_validate: #{duration_validate} - date_validate: #{date_validate} - acu: #{acu.as_json}" end + acu.finish_attempt(get_remote_ip) respond_to do |format| format.js { render :js => "validation_error('#{I18n.t('exam_responses.error.' + 'duration' + '')}');" } end From 8316a511c29ca75b38574339bb21b5888daa5e20 Mon Sep 17 00:00:00 2001 From: Bianca Date: Wed, 1 Apr 2026 14:21:33 -0300 Subject: [PATCH 2/2] fix: add finish action when interrupt uninterrupted exam --- app/assets/javascripts/exams.js.erb | 4 ++-- app/controllers/exam_responses_controller.rb | 5 +++++ app/views/exams/open.html.haml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/exams.js.erb b/app/assets/javascripts/exams.js.erb index 0b1d9af19..70863d0b1 100644 --- a/app/assets/javascripts/exams.js.erb +++ b/app/assets/javascripts/exams.js.erb @@ -20,7 +20,7 @@ function init_chronometer(page_question, total) { Timer.start(segundos); } -function save_question(duration) { +function save_question(duration, interrupt_exam=false) { Timer.pause(); var form = $('form.edit_exam_response'); @@ -30,7 +30,7 @@ function save_question(duration) { $.ajax({ url : post_url, type: request_method, - data : form_data + data : form_data + "&interrupt_exam=" + interrupt_exam }).done(function(response){ tempo(response.total_time, 1); }).fail(function(response){ diff --git a/app/controllers/exam_responses_controller.rb b/app/controllers/exam_responses_controller.rb index e7c6aeaf2..782926d30 100644 --- a/app/controllers/exam_responses_controller.rb +++ b/app/controllers/exam_responses_controller.rb @@ -31,6 +31,11 @@ def update SysLog::Actions.log_info do "[PROVA] Salvou resposta para user_id=#{current_user.try(:id)}, exam_response=#{params[:id]}" end + + if params[:interrupt_exam] == 'true' && exam.uninterrupted + @exam_response.academic_allocation_user.finish_attempt(get_remote_ip) + end + render_exam_response_success_json('updated', total_time_user) else SysLog::Actions.log_info do diff --git a/app/views/exams/open.html.haml b/app/views/exams/open.html.haml index 1439c04b6..cc95afd39 100644 --- a/app/views/exams/open.html.haml +++ b/app/views/exams/open.html.haml @@ -24,7 +24,7 @@ }); if(click_pagination==false){ window.onbeforeunload = function () { - save_question(null); + save_question(null, true); return "#{I18n.t('exams.open.refresh')}"; } }