From edb191765df411c5dcffb56d4d2620ddef33c0db Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Tue, 7 May 2024 14:54:03 -0300 Subject: [PATCH 01/66] =?UTF-8?q?Corrige=20nomeclatura=20do=20parametro=20?= =?UTF-8?q?s=C3=A9rie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/student_enrollments_retriever.rb | 7 ++++--- spec/services/student_enrollments_retriever_spec.rb | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/services/student_enrollments_retriever.rb b/app/services/student_enrollments_retriever.rb index 97c21020a..12918ee52 100644 --- a/app/services/student_enrollments_retriever.rb +++ b/app/services/student_enrollments_retriever.rb @@ -15,7 +15,7 @@ def initialize(params) @start_at = params.fetch(:start_at, nil) @end_at = params.fetch(:end_at, nil) @year = params.fetch(:year, nil) - @grade = params.fetch(:grade, nil) + @grades = params.fetch(:grades, nil) @include_date_range = params.fetch(:include_date_range, nil) @period = params.fetch(:period, nil) @opinion_type = params.fetch(:opinion_type, nil) @@ -39,8 +39,9 @@ def call .includes(:student_enrollment_classrooms) .order('sequence ASC, students.name ASC') .active + student_enrollments = student_enrollments.by_classroom_grades(classroom_grades) if classroom_grades - student_enrollments = student_enrollments.by_grade(grade) if grade + student_enrollments = student_enrollments.by_grade(grades) if grades student_enrollments = student_enrollments.by_period(period) if period student_enrollments = student_enrollments.by_opinion_type(opinion_type, classrooms) if opinion_type student_enrollments = student_enrollments.with_recovery_note_in_step(step, discipline) if with_recovery_note_in_step @@ -58,7 +59,7 @@ def call private attr_accessor :classrooms, :disciplines, :year, :date, :start_at, :end_at, :search_type, :classroom_grades, - :include_date_range, :grade, :period, :opinion_type, :with_recovery_note_in_step, :score_type, + :include_date_range, :grades, :period, :opinion_type, :with_recovery_note_in_step, :score_type, :filter_by_left_at def ensure_has_valid_search_params diff --git a/spec/services/student_enrollments_retriever_spec.rb b/spec/services/student_enrollments_retriever_spec.rb index 330bbb9f3..b4e24385f 100644 --- a/spec/services/student_enrollments_retriever_spec.rb +++ b/spec/services/student_enrollments_retriever_spec.rb @@ -321,7 +321,7 @@ classrooms: classroom_grade.classroom_id, disciplines: discipline, date: '2023-03-03', - grade: classroom_grade_without_liked.first + grades: classroom_grade_without_liked.first ) ).to be_empty end @@ -333,7 +333,7 @@ classrooms: classroom_grade.classroom_id, disciplines: discipline, date: '2023-03-03', - grade: classroom_grade.grade_id + grades: classroom_grade.grade_id ) ).to include(student_enrollments.first) end From 9ce3e826515e9c56039f18a98e80d49c88e5ef56 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Wed, 8 May 2024 15:36:01 -0300 Subject: [PATCH 02/66] =?UTF-8?q?Cria=20fun=C3=A7=C3=B5es=20para=20impedir?= =?UTF-8?q?=20buscas=20de=20registros=20com=20datas=20invalidas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/discipline_lesson_plans/form.js | 14 +++++++++++++- .../views/knowledge_area_lesson_plans/form.js | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/views/discipline_lesson_plans/form.js b/app/assets/javascripts/views/discipline_lesson_plans/form.js index 9de7f3778..30e8fbf2d 100644 --- a/app/assets/javascripts/views/discipline_lesson_plans/form.js +++ b/app/assets/javascripts/views/discipline_lesson_plans/form.js @@ -19,8 +19,10 @@ $(function () { const copyFromObjectivesTeachingPlanAlert = document.getElementById( 'lesson_plan_copy_from_objectives_teaching_plan_alert' ); + const start_at = startAtInput.closest('div.control-group'); + const end_at = endAtInput.closest('div.control-group'); - $(".lesson_plan_attachment").on('change', onChangeFileElement); + $lesson_plan_attachment.on('change', onChangeFileElement); function onChangeFileElement() { // escopado para permitir arquivos menores que 3MB(3145728 bytes) @@ -178,6 +180,11 @@ $(function () { if (copyTeachingPlanLink) { copyTeachingPlanLink.addEventListener('click', event => { + if (start_at.classList.contains('error') || end_at.classList.contains('error')){ + flashMessages.error('É necessário preenchimento das datas válidas para realizar a cópia.'); + return false; + } + event.preventDefault(); copyFromTeachingPlanAlert.style.display = 'none'; @@ -230,6 +237,11 @@ $(function () { if (copyObjectivesTeachingPlanLink) { copyObjectivesTeachingPlanLink.addEventListener('click', event => { + if (start_at.classList.contains('error') || end_at.classList.contains('error')){ + flashMessages.error('É necessário preenchimento das datas válidas para realizar a cópia.'); + return false; + } + event.preventDefault(); copyFromObjectivesTeachingPlanAlert.style.display = 'none'; diff --git a/app/assets/javascripts/views/knowledge_area_lesson_plans/form.js b/app/assets/javascripts/views/knowledge_area_lesson_plans/form.js index dce0d7718..fe94c2a58 100644 --- a/app/assets/javascripts/views/knowledge_area_lesson_plans/form.js +++ b/app/assets/javascripts/views/knowledge_area_lesson_plans/form.js @@ -16,6 +16,8 @@ $(function () { 'lesson_plan_copy_from_objectives_teaching_plan_alert' ); const flashMessages = new FlashMessages(); + const start_at = startAtInput.closest('div.control-group'); + const end_at = endAtInput.closest('div.control-group'); $('#knowledge_area_lesson_plan_lesson_plan_attributes_contents_tags').on('change', function (e) { if (e.val.length) { @@ -97,6 +99,11 @@ $(function () { if (copyTeachingPlanLink) { copyTeachingPlanLink.addEventListener('click', event => { + if (start_at.classList.contains('error') || end_at.classList.contains('error')){ + flashMessages.error('É necessário preenchimento das datas válidas para realizar a cópia.'); + return false; + } + event.preventDefault(); copyFromTeachingPlanAlert.style.display = 'none'; @@ -146,6 +153,11 @@ $(function () { if (copyObjectivesTeachingPlanLink) { copyObjectivesTeachingPlanLink.addEventListener('click', event => { + if (start_at.classList.contains('error') || end_at.classList.contains('error')){ + flashMessages.error('É necessário preenchimento das datas válidas para realizar a cópia.'); + return false; + } + event.preventDefault(); copyFromObjectivesTeachingPlanAlert.style.display = 'none'; From 7d4f15a03ce3e363af9c99f79f2d025fac995c14 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Tue, 14 May 2024 13:15:48 -0300 Subject: [PATCH 03/66] Criado logica para filtrar as disciplinas de turmas multiseriadas --- app/services/student_enrollments_retriever.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/services/student_enrollments_retriever.rb b/app/services/student_enrollments_retriever.rb index 12918ee52..04782ec4e 100644 --- a/app/services/student_enrollments_retriever.rb +++ b/app/services/student_enrollments_retriever.rb @@ -40,13 +40,17 @@ def call .order('sequence ASC, students.name ASC') .active + # Sobrescreve as séries de turmas multisseriadas de acordo com filtro de disciplinas + new_grades = classrooms_with_multi_grades + student_enrollments = student_enrollments.by_classroom_grades(classroom_grades) if classroom_grades - student_enrollments = student_enrollments.by_grade(grades) if grades + student_enrollments = student_enrollments.by_grade(new_grades || grades) if new_grades || grades student_enrollments = student_enrollments.by_period(period) if period student_enrollments = student_enrollments.by_opinion_type(opinion_type, classrooms) if opinion_type student_enrollments = student_enrollments.with_recovery_note_in_step(step, discipline) if with_recovery_note_in_step student_enrollments = student_enrollments.by_left_at_date(end_at) if filter_by_left_at student_enrollments = search_by_dates(student_enrollments) if include_date_range + # Nao filtra as matriculas caso municipio tenha DATABASE if student_enrollments.show_as_inactive.blank? student_enrollments = search_by_search_type(student_enrollments) @@ -111,4 +115,12 @@ def reject_duplicated_students(student_enrollments) def show_inactive_enrollments @show_inactive_enrollments = GeneralConfiguration.first.show_inactive_enrollments end + + def classrooms_with_multi_grades + classrooms_array = Array(classrooms) + + return unless classrooms_array.map(&:multi_grade?).any? + + SchoolCalendarDisciplineGrade.where(grade_id: grades, discipline_id: disciplines).map(&:grade_id).uniq + end end From 0d83d2122ef46f650bd0f528ff52f9f47b6535dc Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Tue, 14 May 2024 13:16:01 -0300 Subject: [PATCH 04/66] =?UTF-8?q?Cria=20cen=C3=A1rios=20de=20teste=20para?= =?UTF-8?q?=20nova=20logica=20implementada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student_enrollments_retriever_spec.rb | 100 ++++++++++++++---- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/spec/services/student_enrollments_retriever_spec.rb b/spec/services/student_enrollments_retriever_spec.rb index b4e24385f..7ab3bf36b 100644 --- a/spec/services/student_enrollments_retriever_spec.rb +++ b/spec/services/student_enrollments_retriever_spec.rb @@ -20,7 +20,7 @@ subject(:list_student_enrollments) { StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-02-02' ) @@ -44,7 +44,7 @@ expect { StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline ) }.to raise_error(ArgumentError, 'Should define date argument on search by date') @@ -54,7 +54,7 @@ expect { StudentEnrollmentsRetriever.call( search_type: :by_date_range, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-02-02' ) @@ -92,7 +92,7 @@ subject(:list_student_enrollments) { StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-02-02' ) @@ -113,7 +113,7 @@ subject(:list_student_enrollments) { StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: [list_classrooms, classroom_grade.classroom_id], + classrooms: [list_classrooms, classroom_grade.classroom].flatten, disciplines: discipline, date: '2023-02-02' ) @@ -142,7 +142,7 @@ subject(:list_student_enrollments) { StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-02-02' ) @@ -180,7 +180,7 @@ subject(:list_student_enrollments) { StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-03-02' ) @@ -211,7 +211,7 @@ subject(:list_student_enrollments) { StudentEnrollmentsRetriever.call( search_type: :by_date_range, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, start_at: '2023-03-02', end_at: '2023-11-02' @@ -278,7 +278,7 @@ subject(:student_enrollment_retriever) { StudentEnrollmentsRetriever.call( search_type: :by_date_range, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, start_at: '2023-03-03', end_at: '2023-06-03' @@ -296,7 +296,7 @@ subject(:student_enrollment_retriever) { StudentEnrollmentsRetriever.call( search_type: :by_date_range, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, start_at: '2023-03-03', end_at: '2023-06-03' @@ -318,7 +318,7 @@ expect( StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-03-03', grades: classroom_grade_without_liked.first @@ -330,7 +330,7 @@ expect( StudentEnrollmentsRetriever.call( search_type: :by_date, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, date: '2023-03-03', grades: classroom_grade.grade_id @@ -345,7 +345,7 @@ it 'should return student_enrollments with joined_at dates after @start_at' do student_enrollments = StudentEnrollmentsRetriever.call( search_type: :by_date_range, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, start_at: '2023-03-03', end_at: '2023-06-03', @@ -365,7 +365,7 @@ expect( StudentEnrollmentsRetriever.call( search_type: :by_date_range, - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, start_at: '2023-04-20', end_at: '2023-12-03', @@ -395,7 +395,7 @@ it 'should return student_enrollment with opinion_type by step and discipline' do expect( StudentEnrollmentsRetriever.call( - classrooms: classroom_grade_with_exam_rule.classroom_id, + classrooms: classroom_grade_with_exam_rule.classroom, disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -407,7 +407,7 @@ it 'should not return student_enrollment with opinion_type by step and discipline' do expect( StudentEnrollmentsRetriever.call( - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -437,7 +437,7 @@ it 'should return student_enrollment attending the full period' do expect( StudentEnrollmentsRetriever.call( - classrooms: classroom_grade_with_period.classroom_id, + classrooms: classroom_grade_with_period.classroom, disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -449,7 +449,7 @@ it 'should not return student_enrollment attending the full period' do expect( StudentEnrollmentsRetriever.call( - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -463,7 +463,7 @@ it 'should return list of student_enrollments with score_type NUMERIC_AND_CONCEPT' do expect( StudentEnrollmentsRetriever.call( - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -483,7 +483,7 @@ expect( StudentEnrollmentsRetriever.call( - classrooms: [classroom_grade.classroom_id, classroom_grade_with_numeric.classroom_id], + classrooms: [classroom_grade.classroom, classroom_grade_with_numeric.classroom], disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -503,7 +503,7 @@ expect( StudentEnrollmentsRetriever.call( - classrooms: [classroom_grade.classroom_id, classroom_grade_with_concept.classroom_id], + classrooms: [classroom_grade.classroom, classroom_grade_with_concept.classroom], disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -515,7 +515,7 @@ it 'should return list of student_enrollments with score_type both if given nil' do expect( StudentEnrollmentsRetriever.call( - classrooms: classroom_grade.classroom_id, + classrooms: classroom_grade.classroom, disciplines: discipline, search_type: :by_date, date: '2023-03-10', @@ -526,6 +526,62 @@ end context 'when with_recovery_note_in_step params exist' + + context 'when there are classrooms with multi-grade' do + let(:grade) { create(:grade) } + let(:classrooms_grade_with_multi_grade) { + create( + :classrooms_grade, + classroom: classroom_grade.classroom, + grade: grade + ) + } + let(:school_calendar_discipline_grade) { + create( + :school_calendar_discipline_grade, + grade: grade, + discipline: discipline + ) + } + let(:enrollment_classroom) { + student_enrollment_classrooms.last.update( + classrooms_grade: classrooms_grade_with_multi_grade + ) + student_enrollment_classrooms.last + } + + before do + enrollment_classroom + school_calendar_discipline_grade + end + + subject(:student_enrollment_retriever) { + StudentEnrollmentsRetriever.call( + search_type: :by_date_range, + classrooms: classrooms_grade_with_multi_grade.classroom, + grades: [1, 2], + disciplines: discipline, + start_at: '2023-03-03', + end_at: '2023-06-03' + ) + } + + it 'overwrites the series as expected and returns student_enrollment from grade-related inclusion' do + expect(student_enrollment_retriever).to include(enrollment_classroom.student_enrollment) + + included_grades = student_enrollment_retriever + .flat_map(&:student_enrollment_classrooms) + .flat_map(&:classrooms_grade) + .map(&:grade) + + expect(included_grades).to include(grade) + end + + + it 'not returns student_enrollment from grade-related inclusion' do + expect(student_enrollment_retriever).not_to include(student_enrollments.first) + end + end end def create_student_enrollments_with_students_duplicated From 8aa9aec7ef1dfe7b8cefb9b6d0396517bf1c2834 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Tue, 14 May 2024 13:39:26 -0300 Subject: [PATCH 05/66] =?UTF-8?q?Substitui=20valor=20fixo=20de=20s=C3=A9ri?= =?UTF-8?q?e=20por=20parametro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/services/student_enrollments_retriever_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/services/student_enrollments_retriever_spec.rb b/spec/services/student_enrollments_retriever_spec.rb index 7ab3bf36b..9ec9f9930 100644 --- a/spec/services/student_enrollments_retriever_spec.rb +++ b/spec/services/student_enrollments_retriever_spec.rb @@ -551,6 +551,7 @@ } before do + classrooms_grade_with_multi_grade enrollment_classroom school_calendar_discipline_grade end @@ -559,7 +560,7 @@ StudentEnrollmentsRetriever.call( search_type: :by_date_range, classrooms: classrooms_grade_with_multi_grade.classroom, - grades: [1, 2], + grades: [classroom_grade.grade_id, grade.id], disciplines: discipline, start_at: '2023-03-03', end_at: '2023-06-03' From 9a5ce075d68c8e590cdb5185f84abfcfa43f3872 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Tue, 14 May 2024 13:51:04 -0300 Subject: [PATCH 06/66] Altera map por any para melhorar performance --- app/services/student_enrollments_retriever.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/student_enrollments_retriever.rb b/app/services/student_enrollments_retriever.rb index 04782ec4e..4f725d77c 100644 --- a/app/services/student_enrollments_retriever.rb +++ b/app/services/student_enrollments_retriever.rb @@ -119,7 +119,7 @@ def show_inactive_enrollments def classrooms_with_multi_grades classrooms_array = Array(classrooms) - return unless classrooms_array.map(&:multi_grade?).any? + return unless classrooms_array.any?(&:multi_grade?) SchoolCalendarDisciplineGrade.where(grade_id: grades, discipline_id: disciplines).map(&:grade_id).uniq end From b699ae9a11c5bd3ccd29233e826bd8eaba2597df Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Tue, 14 May 2024 16:03:51 -0300 Subject: [PATCH 07/66] =?UTF-8?q?Filtra=20vinculos=20de=20disciplinas=20e?= =?UTF-8?q?=20s=C3=A9ries=20com=20calendario=20escolar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/student_enrollments_retriever.rb | 9 ++++++++- spec/services/student_enrollments_retriever_spec.rb | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/services/student_enrollments_retriever.rb b/app/services/student_enrollments_retriever.rb index 4f725d77c..5dee67fd3 100644 --- a/app/services/student_enrollments_retriever.rb +++ b/app/services/student_enrollments_retriever.rb @@ -121,6 +121,13 @@ def classrooms_with_multi_grades return unless classrooms_array.any?(&:multi_grade?) - SchoolCalendarDisciplineGrade.where(grade_id: grades, discipline_id: disciplines).map(&:grade_id).uniq + school_calendar = classrooms_array.flat_map(&:unity).flat_map(&:school_calendars) + .detect { |sc| sc.year == classrooms_array.first.year } + + SchoolCalendarDisciplineGrade.where( + grade_id: grades, + discipline_id: disciplines, + school_calendar: school_calendar + ).map(&:grade_id).uniq end end diff --git a/spec/services/student_enrollments_retriever_spec.rb b/spec/services/student_enrollments_retriever_spec.rb index 9ec9f9930..089530aba 100644 --- a/spec/services/student_enrollments_retriever_spec.rb +++ b/spec/services/student_enrollments_retriever_spec.rb @@ -540,7 +540,8 @@ create( :school_calendar_discipline_grade, grade: grade, - discipline: discipline + discipline: discipline, + school_calendar: classroom_grade.classroom.unity.school_calendars.first ) } let(:enrollment_classroom) { From 6b77dcd5cc7397151eb9ef7d58f175fac6697866 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Wed, 15 May 2024 11:49:40 -0300 Subject: [PATCH 08/66] Cria novo parametro para filtrar disciplinas por ano --- app/controllers/avaliations_controller.rb | 7 +++++-- app/models/discipline.rb | 11 +++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/avaliations_controller.rb b/app/controllers/avaliations_controller.rb index 44dc3639c..4571dbc89 100644 --- a/app/controllers/avaliations_controller.rb +++ b/app/controllers/avaliations_controller.rb @@ -60,6 +60,7 @@ def multiple_classrooms fetch_linked_by_teacher unless current_user.current_role_is_admin_or_employee? + disciplines_for_multiple_classrooms set_avaliation_multiple_creator_by_user authorize Avaliation.new @@ -315,13 +316,15 @@ def respond_to_save def disciplines_for_multiple_classrooms if current_user.current_role_is_admin_or_employee? - return @disciplines ||= Discipline.by_unity_id(current_unity.id).by_teacher_id(current_teacher.id).ordered + return @disciplines ||= Discipline.by_unity_id(current_unity.id, current_school_year) + .by_teacher_id(current_teacher.id, current_school_year) + .ordered + end fetch_linked_by_teacher @disciplines end - helper_method :disciplines_for_multiple_classrooms def classrooms_for_multiple_classrooms return [] if @avaliation_multiple_creator_form.discipline_id.blank? diff --git a/app/models/discipline.rb b/app/models/discipline.rb index 06f1ace1a..1eb4dcdb3 100644 --- a/app/models/discipline.rb +++ b/app/models/discipline.rb @@ -18,10 +18,10 @@ class Discipline < ApplicationRecord validates :description, :api_code, :knowledge_area_id, presence: true validates :api_code, uniqueness: true - scope :by_unity_id, lambda { |unity_id| by_unity_id(unity_id) } - scope :by_teacher_id, lambda { |teacher_id| + scope :by_unity_id, lambda { |unity_id, year| by_unity_id(unity_id, year) } + scope :by_teacher_id, lambda { |teacher_id, year| joins(:teacher_discipline_classrooms).where(teacher_discipline_classrooms: - { teacher_id: teacher_id }).distinct + { teacher_id: teacher_id , year: year}).distinct } scope :by_classroom_id, lambda { |classroom_id| joins(:teacher_discipline_classrooms).where(teacher_discipline_classrooms: { classroom_id: classroom_id }).distinct @@ -58,7 +58,6 @@ class Discipline < ApplicationRecord ).distinct end } - scope :by_grade, lambda { |grade| by_grade(grade) } scope :by_classroom, lambda { |classroom| by_classroom(classroom) } scope :by_teacher_and_classroom, lambda { |teacher_id, classroom_id| joins(:teacher_discipline_classrooms).where(teacher_discipline_classrooms: { teacher_id: teacher_id, classroom_id: classroom_id }).distinct } @@ -111,7 +110,7 @@ def self.grouped_by_knowledge_area private - def self.by_unity_id(unity_id) + def self.by_unity_id(unity_id, year) joins(:teacher_discipline_classrooms).joins( arel_table.join(Classroom.arel_table) .on( @@ -120,7 +119,7 @@ def self.by_unity_id(unity_id) ) .join_sources ) - .where(classrooms: { unity_id: unity_id }) + .where(classrooms: { unity_id: unity_id, year: year}) .distinct end From 930e4c82dd065bcbfdb44625503f3a48f8c53889 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Wed, 15 May 2024 11:50:25 -0300 Subject: [PATCH 09/66] =?UTF-8?q?Corrige=20utiliza=C3=A7=C3=B5es=20do=20es?= =?UTF-8?q?copo=20enviando=20o=20novo=20parametro=20de=20ano?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/disciplines_controller.rb | 2 +- app/controllers/school_calendar_events_controller.rb | 2 +- app/controllers/teaching_plans_controller.rb | 2 +- app/inputs/select2_discipline_input.rb | 6 +++--- app/views/avaliations/multiple_classrooms.html.erb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/disciplines_controller.rb b/app/controllers/disciplines_controller.rb index aac97cdd8..036acca4a 100644 --- a/app/controllers/disciplines_controller.rb +++ b/app/controllers/disciplines_controller.rb @@ -18,7 +18,7 @@ def index step_number = step_fetcher.step_by_id(step_id).try(:step_number) exempted_discipline_ids = ExemptedDisciplinesInStep.discipline_ids(classroom.id, step_number) - @disciplines = apply_scopes(Discipline).by_teacher_id(current_teacher.id).order_by_sequence + @disciplines = apply_scopes(Discipline).by_teacher_id(current_teacher.id, current_school_year).order_by_sequence if params[:conceptual] school_calendar = step_fetcher.school_calendar diff --git a/app/controllers/school_calendar_events_controller.rb b/app/controllers/school_calendar_events_controller.rb index 69bb3a3ea..2f65472e7 100644 --- a/app/controllers/school_calendar_events_controller.rb +++ b/app/controllers/school_calendar_events_controller.rb @@ -115,7 +115,7 @@ def classrooms helper_method :classrooms def disciplines - @disciplines ||= Discipline.by_unity_id(@school_calendar.unity.id) + @disciplines ||= Discipline.by_unity_id(@school_calendar.unity.id, current_school_year) .by_classroom(@school_calendar_event.classroom_id) .grouper .ordered || [] diff --git a/app/controllers/teaching_plans_controller.rb b/app/controllers/teaching_plans_controller.rb index bdb421f75..32513efce 100644 --- a/app/controllers/teaching_plans_controller.rb +++ b/app/controllers/teaching_plans_controller.rb @@ -13,7 +13,7 @@ def index @unities = Unity.by_teacher(current_teacher.id).uniq.ordered @classrooms = Classroom.by_teacher_id(current_teacher.id).ordered - @disciplines = Discipline.by_teacher_id(current_teacher.id).ordered + @disciplines = Discipline.by_teacher_id(current_teacher.id, current_school_year).ordered end def new diff --git a/app/inputs/select2_discipline_input.rb b/app/inputs/select2_discipline_input.rb index c62701f0b..c73807f3e 100644 --- a/app/inputs/select2_discipline_input.rb +++ b/app/inputs/select2_discipline_input.rb @@ -22,11 +22,11 @@ def parse_collection elsif user.current_discipline_id? Discipline.where(id: user.current_discipline_id) elsif user.current_teacher.present? && options[:grade_id] - Discipline.by_grade(options[:grade_id]).by_teacher_id(user.current_teacher.id) + Discipline.by_grade(options[:grade_id]).by_teacher_id(user.current_teacher.id, current_school_year) elsif user.current_teacher.present? && options[:classroom_id] - Discipline.by_classroom(options[:classroom_id]).by_teacher_id(user.current_teacher.id) + Discipline.by_classroom(options[:classroom_id]).by_teacher_id(user.current_teacher.id, current_school_year) elsif user.current_unity.present? && options[:grade_id] - Discipline.by_unity_id(user.current_unity.id).by_grade(options[:grade_id]) + Discipline.by_unity_id(user.current_unity.id, current_school_year).by_grade(options[:grade_id]) end options[:elements] = disciplines.present? ? disciplines.grouped_by_knowledge_area : [] diff --git a/app/views/avaliations/multiple_classrooms.html.erb b/app/views/avaliations/multiple_classrooms.html.erb index 6d35a8998..569f16d5b 100644 --- a/app/views/avaliations/multiple_classrooms.html.erb +++ b/app/views/avaliations/multiple_classrooms.html.erb @@ -22,7 +22,7 @@ <%= f.input :unity_id, as: :select2_unity, user: current_user %>
- <%= f.input :discipline_id, as: :select2, elements: disciplines_for_multiple_classrooms %> + <%= f.input :discipline_id, as: :select2, elements: @disciplines %>
<%= f.input :test_setting_test_id, as: :select2, elements: [], required: true %> From 6891ed41c7c5236440a33e77389f0a9931b221f7 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Wed, 15 May 2024 16:28:51 -0300 Subject: [PATCH 10/66] =?UTF-8?q?Cria=20m=C3=A9todo=20para=20setar=20valor?= =?UTF-8?q?=20na=20variavel=20s=C3=A9rie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/avaliations_controller.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/avaliations_controller.rb b/app/controllers/avaliations_controller.rb index 44dc3639c..788eb060c 100644 --- a/app/controllers/avaliations_controller.rb +++ b/app/controllers/avaliations_controller.rb @@ -38,10 +38,7 @@ def new return if not_allow_numerical_exam fetch_linked_by_teacher unless current_user.current_role_is_admin_or_employee? - @grades = current_user_classroom.classrooms_grades - .by_score_type([ScoreTypes::NUMERIC, ScoreTypes::NUMERIC_AND_CONCEPT]) - .map(&:grade) - + grades @avaliation = resource @avaliation.school_calendar = current_school_calendar @avaliation.classroom = current_user_classroom @@ -104,9 +101,13 @@ def create respond_to_save else @avaliation = resource - fetch_linked_by_teacher unless current_user.current_role_is_admin_or_employee? - fetch_disciplines_by_classroom + if current_user.current_role_is_admin_or_employee? + grades + else + fetch_linked_by_teacher + end + fetch_disciplines_by_classroom test_settings render :new From 8d43ca917b2c95029228192c14a2b2f54665ef97 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Thu, 16 May 2024 10:30:10 -0300 Subject: [PATCH 11/66] =?UTF-8?q?Cria=20m=C3=A9todo=20para=20setar=20valor?= =?UTF-8?q?=20na=20variavel=20s=C3=A9rie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/avaliations_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/avaliations_controller.rb b/app/controllers/avaliations_controller.rb index 788eb060c..8c6ec0d31 100644 --- a/app/controllers/avaliations_controller.rb +++ b/app/controllers/avaliations_controller.rb @@ -472,4 +472,11 @@ def fetch_disciplines_by_classroom @disciplines = @disciplines.by_classroom_id(classrooms.map(&:id)).not_descriptor @grades = @classroom_grades.by_classroom_id(classrooms.map(&:id)).map(&:grade).uniq end + + def grades + @grades = current_user_classroom + .classrooms_grades + .by_score_type([ScoreTypes::NUMERIC, ScoreTypes::NUMERIC_AND_CONCEPT]) + .map(&:grade) + end end From aee3266599c2effc2d8362f787f4314d6a9a4d3d Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Thu, 16 May 2024 11:40:12 -0300 Subject: [PATCH 12/66] =?UTF-8?q?Ajusta=20tamanho=20de=20campos=20para=20m?= =?UTF-8?q?elhor=20leitura=20do=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/avaliations/avaliation_fields.jst.ejs | 6 +++--- app/views/avaliations/_avaliation_fields.html.erb | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs b/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs index 9886735c9..1190e580f 100644 --- a/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs +++ b/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs @@ -10,21 +10,21 @@
-
+
-
+
-
+
diff --git a/app/views/avaliations/_avaliation_fields.html.erb b/app/views/avaliations/_avaliation_fields.html.erb index e99923fea..51bc1da15 100644 --- a/app/views/avaliations/_avaliation_fields.html.erb +++ b/app/views/avaliations/_avaliation_fields.html.erb @@ -5,17 +5,20 @@ - <%= f.input :classroom, as: :string, label: false, disabled: true %> + <%= f.input :classroom, as: :string, label: false, disabled: true, + input_html: { style:'width: 400px;' }%> <% avaliation_data(f.object) %> - <%= f.input :grade_ids, as: :select2, elements: @grades.to_json, label: false, input_html: { value: @input_value }, + <%= f.input :grade_ids, as: :select2, elements: @grades.to_json, label: false, + input_html: { value: @input_value , style:'width: 500px;'}, readonly: !@is_multi, multiple: @is_multi %> - <%= f.input :test_date, as: :date, input_html: { value: f.object.localized.test_date }, label: false %> + <%= f.input :test_date, as: :date, input_html: { value: f.object.localized.test_date, style:'width: 250px;' }, + label: false%> From 675ba787ccad07701014d2d8292dbde4d2e79f33 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Thu, 16 May 2024 11:51:29 -0300 Subject: [PATCH 13/66] =?UTF-8?q?Ajusta=20template=20responsavel=20por=20r?= =?UTF-8?q?enderizar=20turmas=20series=20e=20datas=20de=20avalia=C3=A7?= =?UTF-8?q?=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avaliations/avaliation_fields.jst.ejs | 55 +++++++++++++------ 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs b/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs index 1190e580f..0c8b02419 100644 --- a/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs +++ b/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs @@ -1,33 +1,54 @@ - + -
-
-
+
+
+ + +
-