diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index a7ce9f2ff..33868cf56 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -2,18 +2,17 @@ name: Tests
on:
push:
- branches:
+ branches:
- main
- tc-gh-actions
pull_request:
jobs:
default:
-
name: Unit and Integration
-
- if: '! github.event.pull_request.draft'
-
+
+ if: "! github.event.pull_request.draft"
+
runs-on: ubuntu-latest
env:
@@ -28,10 +27,9 @@ jobs:
POSTGRES_DB: idiario_test
ports:
- 5432:5432
- options:
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
+ options: --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
--health-retries 3
redis:
@@ -47,10 +45,10 @@ jobs:
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
- ruby-version: '2.6.6'
- bundler: '2.4.22'
+ ruby-version: "2.6.6"
+ bundler: "2.4.22"
bundler-cache: true
- env:
+ env:
ImageOS: ubuntu20
- name: Configure database
@@ -61,7 +59,11 @@ jobs:
echo -e "
test:
secret_key_base: `bundle exec rake secret`
- redis_url: redis://localhost:6379
+ REDIS_URL: 'redis://localhost:6379/'
+ REDIS_DB_CACHE: '0'
+ REDIS_DB_SESSION: '1'
+ REDIS_DB_SIDEKIQ: '2'
+ REDIS_MODE: 'standalone'
" > config/secrets.yml
- name: Migrate
diff --git a/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs b/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs
index 9886735c9..61493a010 100644
--- a/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs
+++ b/app/assets/javascripts/templates/avaliations/avaliation_fields.jst.ejs
@@ -1,33 +1,60 @@
-
+
- |
- |
- |
- |
diff --git a/app/assets/javascripts/views/avaliations/multiple_classrooms.js b/app/assets/javascripts/views/avaliations/multiple_classrooms.js
index c03fbf39c..6fc0bf843 100644
--- a/app/assets/javascripts/views/avaliations/multiple_classrooms.js
+++ b/app/assets/javascripts/views/avaliations/multiple_classrooms.js
@@ -127,22 +127,28 @@ $(function () {
find_by_current_year: true
};
- $.getJSON(Routes.classrooms_pt_br_path(params)).always(function (data) {
- if(data.length){
+ $.getJSON(Routes.classroom_grades_classrooms_pt_br_path(params)).always(function (data) {
+
+ var classrooms = data['classroom_grades'][0];
+ var grades = data['classroom_grades'][1];
+
+ if (classrooms.length) {
$("#avaliations tr td").hide();
}
- $.each(data, function(i, classroom){
+
+ $.each(classrooms, function(i, classroom){
var element_id = new Date().getTime() + i;
var html = JST['templates/avaliations/avaliation_fields']({
- classroom_id: classroom.id,
- classroom_name: classroom.description,
- element_id: element_id
- });
+ classroom_id: classroom.id,
+ classroom_name: classroom.description,
+ grade_ids: grades.map(grade => grade.id),
+ grade_name: grades.map(grade => grade.description),
+ element_id: element_id,
+ });
$('#avaliations').append(html);
});
- $(".avaliation_multiple_creator_form_avaliations_classes .select2").select2({ data: classes_data(), multiple: true });
$('.datepicker:not([readonly]):not([disabled])').datepicker();
$('input[data-mask]').on('focus', function () {
diff --git a/app/assets/javascripts/views/descriptive_exams/form.js b/app/assets/javascripts/views/descriptive_exams/form.js
index 765c5a918..46f6ae9be 100644
--- a/app/assets/javascripts/views/descriptive_exams/form.js
+++ b/app/assets/javascripts/views/descriptive_exams/form.js
@@ -184,4 +184,6 @@ $(function () {
$step.on('change', function () {
validateExistingExams();
})
+
+ validateExistingExams();
});
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';
diff --git a/app/controllers/avaliations_controller.rb b/app/controllers/avaliations_controller.rb
index 44dc3639c..2802c6286 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
@@ -60,6 +57,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
@@ -104,9 +102,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
@@ -315,13 +317,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?
@@ -471,4 +475,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
diff --git a/app/controllers/classrooms_controller.rb b/app/controllers/classrooms_controller.rb
index 4075dde1b..4492172dc 100644
--- a/app/controllers/classrooms_controller.rb
+++ b/app/controllers/classrooms_controller.rb
@@ -6,21 +6,36 @@ def index
teacher_id = current_teacher.try(:id)
return unless teacher_id
end
+
if params[:find_by_current_year]
year = current_school_calendar.try(:year)
end
+
score_type = params[:score_type]
(params[:filter] || []).delete(:by_grade) if params.dig(:filter, :by_grade).blank?
@classrooms = apply_scopes(Classroom).ordered
- if params[:include_unity]
- @classrooms = @classrooms.includes(:unity)
- end
+
+ @classrooms = @classrooms.includes(:unity) if params[:include_unity]
@classrooms = @classrooms.by_teacher_id(teacher_id) if teacher_id
@classrooms = @classrooms.by_score_type(ScoreTypes.value_for(score_type.upcase)) if score_type
@classrooms = @classrooms.by_year(year) if year
- @classrooms = @classrooms.ordered.uniq
+ @classrooms = @classrooms.ordered.distinct
+ end
+
+ def classroom_grades
+ index
+
+ if @classrooms.any?
+ grades = @classrooms.flat_map(&:classrooms_grades).map(&:grade).uniq
+
+ render json: {
+ classroom_grades: [@classrooms, grades]
+ }
+ else
+ render json: { classroom_grades: [] }
+ end
end
def multi_grade
diff --git a/app/controllers/conceptual_exams_controller.rb b/app/controllers/conceptual_exams_controller.rb
index 3044cbdf6..a1346e215 100644
--- a/app/controllers/conceptual_exams_controller.rb
+++ b/app/controllers/conceptual_exams_controller.rb
@@ -266,7 +266,19 @@ def add_missing_disciplines
def missing_disciplines
missing_disciplines = []
- (@disciplines || []).each do |discipline|
+ grades = @classrooms.first.grades
+ current_step = [@conceptual_exam.step_number].to_s
+
+ disciplines_in_grade_ids = SchoolCalendarDisciplineGrade.where(
+ school_calendar: current_school_calendar,
+ grade: grades
+ ).pluck(:discipline_id, :steps).flat_map do |discipline_id, steps|
+ discipline_id if steps.nil? || steps.include?([current_step].to_s)
+ end.compact
+
+ filter_discipline = @disciplines.select { |d| d.id.in?(disciplines_in_grade_ids) }
+
+ (filter_discipline || []).each do |discipline|
is_missing = @conceptual_exam.conceptual_exam_values.none? do |conceptual_exam_value|
conceptual_exam_value.discipline.id == discipline.id
end
diff --git a/app/controllers/discipline_lesson_plans_controller.rb b/app/controllers/discipline_lesson_plans_controller.rb
index e0186185e..e697ad69b 100644
--- a/app/controllers/discipline_lesson_plans_controller.rb
+++ b/app/controllers/discipline_lesson_plans_controller.rb
@@ -29,16 +29,18 @@ def show
authorize @discipline_lesson_plan
- respond_with @discipline_lesson_plan do |format|
- format.pdf do
- discipline_lesson_plan_pdf = DisciplineLessonPlanPdf.build(
- current_entity_configuration,
- @discipline_lesson_plan,
- current_teacher
- )
- send_pdf(t("routes.discipline_lesson_plan"), discipline_lesson_plan_pdf.render)
- end
- end
+ respond_with @discipline_lesson_plan
+ end
+
+ def print
+ @discipline_lesson_plan = DisciplineLessonPlan.find(params[:id]).localized
+
+ discipline_lesson_plan_pdf = DisciplineLessonPlanPdf.build(
+ current_entity_configuration,
+ @discipline_lesson_plan,
+ current_teacher
+ )
+ send_pdf(t("routes.discipline_lesson_plan"), discipline_lesson_plan_pdf.render)
end
def new
diff --git a/app/controllers/disciplines_controller.rb b/app/controllers/disciplines_controller.rb
index aac97cdd8..82b9902e1 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
@@ -26,10 +26,13 @@ def index
.by_classroom_id(classroom.id)
.first
.grade_id
+
disciplines_in_grade_ids = SchoolCalendarDisciplineGrade.where(
school_calendar_id: school_calendar.id,
grade_id: student_grade_id
- ).pluck(:discipline_id)
+ ).pluck(:discipline_id, :steps).flat_map do |discipline_id, steps|
+ discipline_id if steps.nil? || steps.include?([step_number].to_s)
+ end.compact
@disciplines = @disciplines.not_grouper
.by_score_type(ScoreTypes::CONCEPT, params[:student_id])
diff --git a/app/controllers/knowledge_area_lesson_plans_controller.rb b/app/controllers/knowledge_area_lesson_plans_controller.rb
index 30265f3fb..974e48511 100644
--- a/app/controllers/knowledge_area_lesson_plans_controller.rb
+++ b/app/controllers/knowledge_area_lesson_plans_controller.rb
@@ -35,21 +35,20 @@ def show
@knowledge_area_lesson_plan = KnowledgeAreaLessonPlan.find(params[:id]).localized
authorize @knowledge_area_lesson_plan
+ @knowledge_areas = fetch_knowledge_area
- respond_with @knowledge_area_lesson_plan do |format|
- format.pdf do
- knowledge_area_lesson_plan_pdf = KnowledgeAreaLessonPlanPdf.build(
- current_entity_configuration,
- @knowledge_area_lesson_plan,
- current_teacher
- )
- send_pdf(t('routes.knowledge_area_lesson_plans'), knowledge_area_lesson_plan_pdf.render)
- end
-
- format.html do
- @knowledge_areas = fetch_knowledge_area
- end
- end
+ respond_with @knowledge_area_lesson_plan
+ end
+
+ def print
+ @knowledge_area_lesson_plan = KnowledgeAreaLessonPlan.find(params[:id]).localized
+
+ knowledge_area_lesson_plan_pdf = KnowledgeAreaLessonPlanPdf.build(
+ current_entity_configuration,
+ @knowledge_area_lesson_plan,
+ current_teacher
+ )
+ send_pdf(t('routes.knowledge_area_lesson_plans'), knowledge_area_lesson_plan_pdf.render)
end
def new
@@ -299,7 +298,7 @@ def clone_params
:classroom_id,
:start_at,
:end_at
- ])
+ ])
end
def contents
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/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
diff --git a/app/models/student_enrollment.rb b/app/models/student_enrollment.rb
index 506c8909f..b1bed5bf1 100644
--- a/app/models/student_enrollment.rb
+++ b/app/models/student_enrollment.rb
@@ -47,7 +47,6 @@ class StudentEnrollment < ActiveRecord::Base
StudentEnrollmentStatus::STUDYING,
StudentEnrollmentStatus::APPROVED,
StudentEnrollmentStatus::APPROVED_WITH_DEPENDENCY,
- StudentEnrollmentStatus::RECLASSIFIED,
StudentEnrollmentStatus::APPROVE_BY_COUNCIL,
StudentEnrollmentStatus::REPPROVED
]
diff --git a/app/models/teaching_plan.rb b/app/models/teaching_plan.rb
index a26ffb235..c6a167db4 100644
--- a/app/models/teaching_plan.rb
+++ b/app/models/teaching_plan.rb
@@ -80,7 +80,7 @@ def attachments?
def yearly?
return unless school_term_type
- SchoolTermType.where("description ILIKE 'Anual%'").where(id: school_term_type.id)
+ SchoolTermType.where("description ILIKE 'Anual%'").where(id: school_term_type.id).exists?
end
private
diff --git a/app/services/absence_count_service.rb b/app/services/absence_count_service.rb
index 1f3c95c7f..dbfa87186 100644
--- a/app/services/absence_count_service.rb
+++ b/app/services/absence_count_service.rb
@@ -36,7 +36,7 @@ def student_frequencies_in_date_range(student, classroom, start_date, end_date,
student.id,
start_date,
end_date
- )
+ ).active
end
if @do_not_send_justified_absence
diff --git a/app/services/conceptual_exam_value_creator.rb b/app/services/conceptual_exam_value_creator.rb
index 01c17e1f6..b9a940c41 100644
--- a/app/services/conceptual_exam_value_creator.rb
+++ b/app/services/conceptual_exam_value_creator.rb
@@ -13,6 +13,9 @@ def initialize(classroom_id, teacher_id, grade_id, discipline_id)
end
def create_empty
+ return if Discipline.find_by(id: discipline_id).grouper?
+ return unless disciplines_in_grade
+
conceptual_exam_values_to_create.each do |record|
student_enrollment_id = student_enrollment_id(record.student_id, classroom_id, record.recorded_at)
@@ -38,23 +41,40 @@ def create_empty
attr_accessor :teacher_id, :classroom_id, :grade_id, :discipline_id
def conceptual_exam_values_to_create
+ steps = @school_calendar_discipline_grade.steps
+ steps_number = if steps.blank?
+ nil
+ else
+ JSON.parse(steps)
+ end
+
+ query = query_teacher_discipline_classrooms
+
+ query = if steps_number
+ query.where(conceptual_exams: { classroom_id: classroom_id, step_number: steps_number })
+ else
+ query.where(conceptual_exams: { classroom_id: classroom_id })
+ end
+
+ query.select(
+ <<-SQL
+ conceptual_exams.id AS conceptual_exam_id,
+ conceptual_exams.student_id AS student_id,
+ conceptual_exams.recorded_at AS recorded_at,
+ conceptual_exams.step_number AS step_number,
+ teacher_discipline_classrooms.discipline_id AS discipline_id
+ SQL
+ )
+ end
+
+ def query_teacher_discipline_classrooms
TeacherDisciplineClassroom.joins(classroom: :conceptual_exams)
.joins(join_conceptual_exam_value)
.by_teacher_id(teacher_id)
.by_classroom(classroom_id)
.by_discipline_id(discipline_id)
.by_grade_id(grade_id)
- .where(conceptual_exams: { classroom_id: classroom_id })
.where(conceptual_exam_values: { id: nil })
- .select(
- <<-SQL
- conceptual_exams.id AS conceptual_exam_id,
- conceptual_exams.student_id AS student_id,
- conceptual_exams.recorded_at AS recorded_at,
- conceptual_exams.step_number AS step_number,
- teacher_discipline_classrooms.discipline_id AS discipline_id
- SQL
- )
end
def join_conceptual_exam_value
@@ -80,4 +100,13 @@ def exempted_discipline?(student_enrollment_id, discipline_id, step_number)
.by_step_number(step_number)
.exists?
end
+
+ def disciplines_in_grade
+ classroom = Classroom.joins(:unity).find_by(id: classroom_id)
+ school_calendar = classroom.unity.school_calendars.find_by(year: classroom.year)
+
+ @school_calendar_discipline_grade ||= SchoolCalendarDisciplineGrade.find_by(
+ school_calendar: school_calendar, grade_id: grade_id, discipline_id: discipline_id
+ )
+ end
end
diff --git a/app/services/ieducar_synchronizers/exam_rules_synchronizer.rb b/app/services/ieducar_synchronizers/exam_rules_synchronizer.rb
index 37ef0d5d6..a7a7e80ae 100644
--- a/app/services/ieducar_synchronizers/exam_rules_synchronizer.rb
+++ b/app/services/ieducar_synchronizers/exam_rules_synchronizer.rb
@@ -36,17 +36,15 @@ def update_exam_rules(exam_rules)
exam_rule_record.tipo_calculo_recuperacao_paralela.to_i ||
ParallelExamsCalculationTypes::SUBSTITUTION
+ differentiated_exam_rules << [
+ exam_rule_record.id,
+ exam_rule_record.regra_diferenciada_id
+ ]
+
if exam_rule.changed?
exam_rule.save!
update_descriptive_exams(exam_rule) if exam_rule.persisted?
end
-
- if exam_rule_record.regra_diferenciada_id.present?
- differentiated_exam_rules << [
- exam_rule_record.id,
- exam_rule_record.regra_diferenciada_id
- ]
- end
end
end
diff --git a/app/services/ieducar_synchronizers/school_calendar_discipline_grades_synchronizer.rb b/app/services/ieducar_synchronizers/school_calendar_discipline_grades_synchronizer.rb
index 8bea1a967..21f2ab3e3 100644
--- a/app/services/ieducar_synchronizers/school_calendar_discipline_grades_synchronizer.rb
+++ b/app/services/ieducar_synchronizers/school_calendar_discipline_grades_synchronizer.rb
@@ -25,42 +25,124 @@ def update_school_calendar_discipline_grade(unity_grade_discipline_years)
next if @unity.blank?
- unity_grade_discipline_year_record.series_disciplinas_anos_letivos.each do |grade_discipline_year|
- grade = grade(grade_discipline_year.serie_id)
+ school_calendar_discipline_grade_records = combine_discipline_years_and_steps(
+ unity_grade_discipline_year_record.series_disciplinas_anos_letivos,
+ unity_grade_discipline_year_record.series_disciplinas_etapas_utilizadas
+ )
+
+ school_calendar_discipline_grade_records.each do |_,record|
+ process_combined_record(record, existing_school_calendar_discipline_grade)
+ end
+ end
+
+ destroy_removed_disciplines(existing_school_calendar_discipline_grade)
+ end
+
+ def combine_discipline_years_and_steps(discipline_years, discipline_steps)
+ combined_records = {}
- next if grade.blank?
+ discipline_years.map do |discipline_year|
+ grade_api_code = discipline_year[:serie_id]
+ combined_records[grade_api_code] ||= {
+ grade_api_code: grade_api_code, disciplines: {}
+ }
- grade_discipline_year.disciplinas_anos_letivos.each do |discipline_and_years|
- discipline_api_code = discipline_and_years.to_h.keys.first.to_s
- years = discipline_and_years.to_h.values.flatten
- discipline = discipline(discipline_api_code)
+ discipline_year[:disciplinas_anos_letivos].each do |discipline_and_years|
+ discipline_api_code = discipline_and_years.to_h.keys.first.to_s.split(',').first.to_i
+ years = discipline_and_years.to_h.values.flatten
- next if discipline.blank?
+ combined_records[grade_api_code][:disciplines][discipline_api_code] ||= { years: [], steps: [] }
+ combined_records[grade_api_code][:disciplines][discipline_api_code][:years] ||= []
+ combined_records[grade_api_code][:disciplines][discipline_api_code][:years].concat(years)
+ end
+ end
- years.each do |year|
- school_calendar = SchoolCalendar.find_by(year: year, unity: @unity)
+ discipline_steps.map do |step_record|
+ grade_api_code = step_record[:serie_id]
+ combined_records[grade_api_code] ||= {
+ grade_api_code: grade_api_code, disciplines: {}
+ }
- next if school_calendar.blank?
+ step_record[:disciplinas_etapas_utilizadas].each do |discipline_and_steps|
+ discipline_api_code = discipline_and_steps.to_h.keys.first.to_s.split(',').first.to_i
+ steps_values = discipline_and_steps.to_h.values.flatten
- school_calendar_discipline_grade = SchoolCalendarDisciplineGrade.find_or_create_by(
- school_calendar_id: school_calendar.id,
- discipline_id: discipline.id,
- grade_id: grade.id
- )
+ next if steps_values.none?
- existing_school_calendar_discipline_grade << school_calendar_discipline_grade.try(:id)
- end
- end
+ steps = steps_values.first.split(',').map(&:to_i)
+
+ combined_records[grade_api_code][:disciplines][discipline_api_code] ||= { years: [], steps: [] }
+ combined_records[grade_api_code][:disciplines][discipline_api_code][:steps].concat(steps)
end
end
- destroy_removed_disciplines(existing_school_calendar_discipline_grade)
+ combined_records
+ end
+
+ def process_combined_record(record, existing_school_calendar_discipline_grade)
+ grade = find_valid_grade(record[:grade_api_code])
+
+ return if grade.blank?
+
+ record[:disciplines].each do |discipline_and_years_and_steps|
+ discipline = discipline(discipline_and_years_and_steps.first)
+
+ next if discipline.blank?
+
+ years_and_steps = discipline_and_years_and_steps.last
+
+ years_and_steps[:years].each do |year|
+ process_school_calendar(
+ year,
+ discipline,
+ grade,
+ existing_school_calendar_discipline_grade,
+ years_and_steps[:steps]
+ )
+ end
+ end
+ end
+
+ def process_school_calendar(
+ year,
+ discipline,
+ grade,
+ existing_school_calendar_discipline_grade,
+ steps
+ )
+ school_calendar = SchoolCalendar.find_by(year: year, unity: @unity)
+
+ return if school_calendar.blank?
+
+ school_calendar_discipline_grade = SchoolCalendarDisciplineGrade.find_or_initialize_by(
+ school_calendar_id: school_calendar.id,
+ discipline_id: discipline.id,
+ grade_id: grade.id
+ )
+
+ school_calendar_discipline_grade.steps = steps.presence || nil
+
+ school_calendar_discipline_grade.save if school_calendar_discipline_grade.changed?
+
+ return if school_calendar_discipline_grade.errors.any?
+
+ unless existing_school_calendar_discipline_grade.include?(school_calendar_discipline_grade.id)
+ existing_school_calendar_discipline_grade << school_calendar_discipline_grade.id
+ end
end
def destroy_removed_disciplines(existing_school_calendar_discipline_grade)
return if @unity.nil?
- SchoolCalendarDisciplineGrade.where.not(id: existing_school_calendar_discipline_grade).joins(:school_calendar)
- .where(school_calendars: { unity_id: @unity.try(:id) }).destroy_all
+ SchoolCalendarDisciplineGrade
+ .where.not(id: existing_school_calendar_discipline_grade)
+ .joins(:school_calendar)
+ .where(school_calendars: { unity_id: @unity.id })
+ .destroy_all
+ end
+
+ def find_valid_grade(grade_api_code)
+ grade = grade(grade_api_code)
+ grade.presence ? grade : nil
end
end
diff --git a/app/services/remove_daily_note_students.rb b/app/services/remove_daily_note_students.rb
index 9bf94e243..e6f4343bf 100644
--- a/app/services/remove_daily_note_students.rb
+++ b/app/services/remove_daily_note_students.rb
@@ -28,7 +28,7 @@ def call
end
def student_inactive_in_date?
- @date_avaliation < joined_at.to_date || @date_avaliation >= left_at.to_date
+ @date_avaliation < joined_at.to_date && @date_avaliation >= left_at.to_date
end
private
diff --git a/app/services/student_enrollment_classrooms_retriever.rb b/app/services/student_enrollment_classrooms_retriever.rb
index 2178a1249..b19b38662 100644
--- a/app/services/student_enrollment_classrooms_retriever.rb
+++ b/app/services/student_enrollment_classrooms_retriever.rb
@@ -99,29 +99,7 @@ def search_by_search_type(enrollment_classrooms)
def reject_duplicated_students(enrollment_classrooms)
return enrollment_classrooms if show_inactive_enrollments
- enrollment_classrooms_unique = []
-
- enrollment_classrooms.each do |enrollment_classroom|
- student_id = enrollment_classroom.student_enrollment.student_id
-
- enrollment_classrooms_for_student = enrollment_classrooms.select do |ec|
- ec.student_enrollment.student_id == student_id
- end
-
- if enrollment_classrooms_for_student.count > 1
- add_enrollment_classrooms(enrollment_classrooms_unique, enrollment_classrooms_for_student)
- else
- enrollment_classrooms_unique << enrollment_classrooms_for_student
- end
- end
-
- enrollment_classrooms_unique = enrollment_classrooms_unique.flatten
- end
-
- def add_enrollment_classrooms(enrollment_classrooms, enrollment_classrooms_for_student)
- return if enrollment_classrooms.include?(enrollment_classrooms_for_student.last)
-
- enrollment_classrooms << enrollment_classrooms_for_student.last
+ last_student_classroom = enrollment_classrooms.select{ |ec| ec.left_at.blank? }
end
def show_inactive_enrollments
diff --git a/app/services/student_enrollments_retriever.rb b/app/services/student_enrollments_retriever.rb
index 97c21020a..593d33f28 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,13 +39,18 @@ def call
.includes(:student_enrollment_classrooms)
.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(grade) if grade
+ 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)
@@ -58,7 +63,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
@@ -96,18 +101,25 @@ def search_by_search_type(student_enrollments)
def reject_duplicated_students(student_enrollments)
return student_enrollments if show_inactive_enrollments
- unique_student_enrollments = {}
-
- student_enrollments.each do |student_enrollment|
- student_id = student_enrollment.student_id
-
- unique_student_enrollments[student_id] = student_enrollment
- end
-
- unique_student_enrollments.values
+ student_enrollments = student_enrollments.status_attending
end
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.any?(&:multi_grade?)
+
+ 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/app/services/students_in_recovery_fetcher.rb b/app/services/students_in_recovery_fetcher.rb
index c81421a00..09ea553e2 100644
--- a/app/services/students_in_recovery_fetcher.rb
+++ b/app/services/students_in_recovery_fetcher.rb
@@ -85,16 +85,15 @@ def student_enrollments(classroom_grade_ids)
end
def fetch_student_enrollments(end_at, classroom_grade_ids, discipline, step, classroom)
- student_enrollments = StudentEnrollmentsRetriever.call(
+ enrollment_classrooms_list = StudentEnrollmentClassroomsRetriever.call(
classrooms: classroom,
disciplines: discipline,
start_at: step.start_at,
end_at: end_at,
classroom_grades: classroom_grade_ids,
- search_type: :by_date_range,
- left_at: true
+ search_type: :by_date_range
)
- StudentEnrollment.includes(:student).where(id: student_enrollments.map(&:id)).order('students.name ASC')
+ enrollment_classrooms_list.map{ |ec| ec[:student_enrollment]}
end
def fetch_students_in_parallel_recovery(differentiated = nil)
diff --git a/app/services/user_by_csv_creator.rb b/app/services/user_by_csv_creator.rb
index 354530a72..d9b513e22 100644
--- a/app/services/user_by_csv_creator.rb
+++ b/app/services/user_by_csv_creator.rb
@@ -1,4 +1,5 @@
class UserByCsvCreator
+ class InvalidUserError < StandardError; end
attr_reader :file, :entity_name, :send_mail, :status, :password
def initialize(options)
@@ -27,7 +28,8 @@ def create_user
entities.each do |entity|
entity.using_connection do
- create_users(entity)
+ puts "Iniciando criação de usuarios no ambiente #{entity.name}"
+ return unless create_users(entity)
puts "Usuários criados com sucesso no ambiente #{entity.name}"
end
end
@@ -46,20 +48,20 @@ def create_users(entity)
next
end
- user.login = new_user[3]
- user.email = new_user[2]
+ user.assign_attributes(login: new_user[3],
+ email: new_user[2],
+ password: password,
+ password_confirmation: password,
+ status: 'active',
+ kind: 'employee',
+ admin: true,
+ receive_news: false,
+ first_name: new_user[0],
+ last_name: new_user[1])
- user.password = password
- user.password_confirmation = password
+ user.save if user.changed?
- user.status = 'active'
- user.kind = 'employee'
- user.admin = true
- user.receive_news = false
- user.first_name = new_user[0]
- user.last_name = new_user[1]
-
- user.save! if user.changed?
+ raise invalid_user_error(user) if user.errors.any?
if set_admin_role(user) && send_mail
UserMailer.delay.by_csv(user.login, user.first_name, user.email, password, entity.domain)
@@ -70,6 +72,9 @@ def create_users(entity)
end
rescue ActiveRecord::RecordInvalid
false
+ rescue InvalidUserError => e
+ puts e.message
+ false
end
def set_admin_role(user)
@@ -96,4 +101,8 @@ def success
def error
@status = 'Não foi possível criar os usuários.'
end
+
+ def invalid_user_error(user)
+ raise InvalidUserError, "Não foi possivel criar os usuarios devido ao erro #{user.errors.messages} para o usuario #{user.login}"
+ end
end
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%>
|
diff --git a/app/views/avaliations/multiple_classrooms.html.erb b/app/views/avaliations/multiple_classrooms.html.erb
index 6d35a8998..f7754b595 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 %>
@@ -36,7 +36,7 @@
- <%= f.input :weight, required: true, input_html: { data: { inputmask: "'digits': 0" } } %>
+ <%= f.input :weight, required: true, input_html: { data: { inputmask: "'digits': 0" } } %>
@@ -94,9 +94,7 @@
<% end %>
diff --git a/app/views/discipline_lesson_plans/_resources.html.erb b/app/views/discipline_lesson_plans/_resources.html.erb
index c506ebc65..5fe4fa431 100644
--- a/app/views/discipline_lesson_plans/_resources.html.erb
+++ b/app/views/discipline_lesson_plans/_resources.html.erb
@@ -47,7 +47,7 @@
data: { original_title: t('views.index.tooltips.show') }) %>
<%= link_to(
t('helpers.links.print_html'),
- discipline_lesson_plan_path(discipline_lesson_plan, format: :pdf),
+ print_discipline_lesson_plans_path(id: discipline_lesson_plan),
class: 'btn btn-info apply_tooltip',
target: '_blank',
data: { original_title: t('views.index.tooltips.print') }) %>
diff --git a/app/views/discipline_teaching_plans/_form.html.erb b/app/views/discipline_teaching_plans/_form.html.erb
index f89d6f6bf..4c4f3f347 100644
--- a/app/views/discipline_teaching_plans/_form.html.erb
+++ b/app/views/discipline_teaching_plans/_form.html.erb
@@ -62,7 +62,7 @@
grade_id: @discipline_teaching_plan.teaching_plan.grade_id %>
<% else %>
<%= f.association :discipline, as: :select2, elements: @disciplines, user: current_user, record: f.object,
- grade_id: @discipline_teaching_plan.teaching_plan.grade_id,readonly: ['show', 'edit'].include?(action_name) %>
+ grade_id: @discipline_teaching_plan.teaching_plan.grade_id, readonly: ['show', 'edit'].include?(action_name) %>
<% end %>
@@ -81,8 +81,12 @@
- <%= teaching_plan_form.association :school_term_type_step, as: :select2, elements: [], required: true,
- readonly: action_name == 'show' %>
+ <%= teaching_plan_form.association :school_term_type_step, as: :select2,
+ input_html: { value: teaching_plan_form.object.school_term_type_step_id,
+ data: { without_json_parser: true }
+ },
+ elements: [], required: true,
+ readonly: action_name == 'show' %>
diff --git a/app/views/discipline_teaching_plans/_resources.html.erb b/app/views/discipline_teaching_plans/_resources.html.erb
index 245c0d3e9..f6cbba200 100644
--- a/app/views/discipline_teaching_plans/_resources.html.erb
+++ b/app/views/discipline_teaching_plans/_resources.html.erb
@@ -24,7 +24,7 @@
<%= discipline_teaching_plan.discipline %> |
<%= discipline_teaching_plan.thematic_unit %> |
<%= discipline_teaching_plan.teaching_plan.school_term_type %> |
- <%= discipline_teaching_plan.teaching_plan.school_term_type_step_humanize %> |
+ <%= discipline_teaching_plan.teaching_plan.school_term_type_step %> |
<%= discipline_teaching_plan.teaching_plan.decorator.author(current_teacher) %> |
<%= link_to(
diff --git a/app/views/knowledge_area_lesson_plans/_resources.html.erb b/app/views/knowledge_area_lesson_plans/_resources.html.erb
index 736948da7..1d138e343 100644
--- a/app/views/knowledge_area_lesson_plans/_resources.html.erb
+++ b/app/views/knowledge_area_lesson_plans/_resources.html.erb
@@ -53,7 +53,7 @@
data: { original_title: t('views.index.tooltips.show') }) %>
<%= link_to(
t('helpers.links.print_html'),
- knowledge_area_lesson_plan_path(knowledge_area_lesson_plan, format: :pdf),
+ print_knowledge_area_lesson_plans_path(id: knowledge_area_lesson_plan),
class: 'btn btn-info apply_tooltip',
target: '_blank',
data: { original_title: t('views.index.tooltips.print') }) %>
diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb
index 9cba79eb3..981976dc2 100644
--- a/config/initializers/redis.rb
+++ b/config/initializers/redis.rb
@@ -6,7 +6,7 @@
}
else
config_redis = {
- url: Rails.application.secrets[:REDIS_URL]
+ url: "#{Rails.application.secrets[:REDIS_URL]}#{Rails.application.secrets[:REDIS_DB_SIDEKIQ]}"
}
end
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index 408553f08..ef9a609d2 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -10,7 +10,9 @@
}
else
redis_config = {
- servers: ["#{Rails.application.secrets[:REDIS_URL]}/session"],
+ servers: [{
+ url: "#{Rails.application.secrets[:REDIS_URL]}#{Rails.application.secrets[:REDIS_DB_SESSION]}"
+ }],
expire_after: 12.hours,
key: "_#{Rails.application.class.parent_name.downcase}_session",
threadsafe: true,
diff --git a/config/locales/models/avaliation.yml b/config/locales/models/avaliation.yml
index 94818aba7..596aa8600 100644
--- a/config/locales/models/avaliation.yml
+++ b/config/locales/models/avaliation.yml
@@ -47,7 +47,7 @@ pt-BR:
cant_be_greater_than: "não pode ser maior que %{value}"
grades:
should_be_in_test_setting: 'devem estar na configuração de avaliação'
- discipline_not_in_grades: 'não tem essa disciplina nessas series'
+ discipline_not_in_grades: 'As séries selecionadas não possuem esta disciplina na grade curricular.'
errors:
avaliations:
diff --git a/config/locales/models/teaching_plan.yml b/config/locales/models/teaching_plan.yml
index fcae5b53e..1c19f9b6c 100644
--- a/config/locales/models/teaching_plan.yml
+++ b/config/locales/models/teaching_plan.yml
@@ -14,6 +14,8 @@ pt-BR:
grade_id: "Série"
school_term_type: "Tipo de período escolar"
school_term_type_step: "Período escolar"
+ school_term_type_id: "Tipo de período escolar"
+ school_term_type_step_id: "Período escolar"
objectives: "Objetivos"
objectives_tags: "Objetivos"
methodology: "Metodologia"
diff --git a/config/routes.rb b/config/routes.rb
index 14c0b6889..592232984 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -211,6 +211,7 @@
post :clone
get :teaching_plan_contents
get :teaching_plan_objectives
+ get :print
end
end
resources :knowledge_area_lesson_plans, concerns: :history do
@@ -218,6 +219,7 @@
post :clone
get :teaching_plan_contents
get :teaching_plan_objectives
+ get :print
end
end
resources :discipline_content_records, concerns: :history do
@@ -234,6 +236,7 @@
collection do
get :by_unity
get :multi_grade
+ get :classroom_grades
end
resources :students, only: [:index]
end
diff --git a/config/synchronization_configs.yml b/config/synchronization_configs.yml
index 47fa0cbe0..1ce2763c2 100644
--- a/config/synchronization_configs.yml
+++ b/config/synchronization_configs.yml
@@ -147,7 +147,8 @@ synchronizers:
by_year: true
by_unity: true
dependencies: [
- ClassroomsSynchronizer
+ ClassroomsSynchronizer,
+ SchoolCalendarDisciplineGradesSynchronizer
]
-
klass: StudentEnrollmentSynchronizer
@@ -210,6 +211,9 @@ synchronizers:
klass: SchoolCalendarDisciplineGradesSynchronizer
by_year: false
by_unity: true
+ dependents: [
+ TeacherDisciplineClassroomsSynchronizer
+ ]
dependencies: [
DisciplinesSynchronizer
]
diff --git a/db/migrate/20240529134746_add_steps_in_school_calendar_discipline_grades.rb b/db/migrate/20240529134746_add_steps_in_school_calendar_discipline_grades.rb
new file mode 100644
index 000000000..f37c1e1c1
--- /dev/null
+++ b/db/migrate/20240529134746_add_steps_in_school_calendar_discipline_grades.rb
@@ -0,0 +1,5 @@
+class AddStepsInSchoolCalendarDisciplineGrades < ActiveRecord::Migration[5.0]
+ def change
+ add_column :school_calendar_discipline_grades, :steps, :string
+ end
+end
diff --git a/spec/services/conceptual_exam_value_creator_spec.rb b/spec/services/conceptual_exam_value_creator_spec.rb
index f88f71fcf..5b31a1715 100644
--- a/spec/services/conceptual_exam_value_creator_spec.rb
+++ b/spec/services/conceptual_exam_value_creator_spec.rb
@@ -36,10 +36,25 @@
discipline: discipline.last
)
}
+ let(:school_calendar_discipline_grades) {
+ create(
+ :school_calendar_discipline_grade,
+ grade: grade.first,
+ discipline: discipline.first,
+ school_calendar: classroom.first.unity.school_calendars.first
+ )
+ create(
+ :school_calendar_discipline_grade,
+ grade: grade.first,
+ discipline: discipline.last,
+ school_calendar: classroom.first.unity.school_calendars.first
+ )
+ }
before do
teacher_discipline_classroom
conceptual_exam
+ school_calendar_discipline_grades
end
context 'when the params are incorrect' do
@@ -75,8 +90,8 @@
subject(:new_conceptual_exam) {
ConceptualExamValueCreator.create_empty_by(
classroom.first,
- grade.first,
teacher.first,
+ grade.first,
discipline.first
)
}
diff --git a/spec/services/student_enrollment_classrooms_retriever_spec.rb b/spec/services/student_enrollment_classrooms_retriever_spec.rb
index 6d37d034d..750fd7983 100644
--- a/spec/services/student_enrollment_classrooms_retriever_spec.rb
+++ b/spec/services/student_enrollment_classrooms_retriever_spec.rb
@@ -11,7 +11,7 @@
3,
classrooms_grade: classroom_grade,
joined_at: '2023-02-02',
- left_at: '2023-12-12'
+ left_at: ''
)
}
diff --git a/spec/services/student_enrollments_retriever_spec.rb b/spec/services/student_enrollments_retriever_spec.rb
index 330bbb9f3..cdd39fda1 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'
)
@@ -35,7 +35,7 @@
end
it 'should return a student_enrollment relation' do
- expect(list_student_enrollments.class).to eq(Array)
+ expect(list_student_enrollments.class).to eq(StudentEnrollment::ActiveRecord_Relation)
end
end
@@ -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,10 +318,10 @@
expect(
StudentEnrollmentsRetriever.call(
search_type: :by_date,
- classrooms: classroom_grade.classroom_id,
+ classrooms: classroom_grade.classroom,
disciplines: discipline,
date: '2023-03-03',
- grade: classroom_grade_without_liked.first
+ grades: classroom_grade_without_liked.first
)
).to be_empty
end
@@ -330,10 +330,10 @@
expect(
StudentEnrollmentsRetriever.call(
search_type: :by_date,
- classrooms: classroom_grade.classroom_id,
+ classrooms: classroom_grade.classroom,
disciplines: discipline,
date: '2023-03-03',
- grade: classroom_grade.grade_id
+ grades: classroom_grade.grade_id
)
).to include(student_enrollments.first)
end
@@ -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,64 @@
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,
+ school_calendar: classroom_grade.classroom.unity.school_calendars.first
+ )
+ }
+ let(:enrollment_classroom) {
+ student_enrollment_classrooms.last.update(
+ classrooms_grade: classrooms_grade_with_multi_grade
+ )
+ student_enrollment_classrooms.last
+ }
+
+ before do
+ classrooms_grade_with_multi_grade
+ 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: [classroom_grade.grade_id, grade.id],
+ 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
|