Skip to content

Commit

Permalink
Merge pull request #165 from portabilis/portabilis-patch-2024-06-19
Browse files Browse the repository at this point in the history
Portabilis patch 19/06/2024
  • Loading branch information
edersoares authored Jun 19, 2024
2 parents e9d8cf0 + e4847fe commit dfde6eb
Show file tree
Hide file tree
Showing 43 changed files with 531 additions and 229 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,60 @@
<tr class="nested-fields dynamic">
<tr class='nested-fields dynamic'>
<td>
<div class="control-group boolean optional avaliation_multiple_creator_form_avaliations_include">
<div class="controls input"><input value="0" type="hidden" name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][include]">
<label class="checkbox"><input class="boolean optional" type="checkbox" value="1" name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][include]" id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_include"><i></i></label></div>
<div class='control-group boolean optional avaliation_multiple_creator_form_avaliations_include'>
<div class='controls input'>
<input value='0' type='hidden'
name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][include]"/>
<label class='checkbox'>
<input class='boolean optional' type='checkbox'
value='1' name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][include]"
id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_include"/>
<i></i>
</label>
</div>
</div>
<div class='control-group hidden avaliation_multiple_creator_form_avaliations_classroom_id'>
<div class='controls input'>
<input class='hidden' type='hidden'
value="<%= classroom_id %>"
name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][classroom_id]"
id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_classroom_id"/>
</div>
</div>
<div class="control-group hidden avaliation_multiple_creator_form_avaliations_classroom_id">
<div class="controls input"><input class="hidden" type="hidden" value="<%= classroom_id %>" name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][classroom_id]" id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_classroom_id"></div>
<div class='control-group select2 required avaliation_multiple_creator_form_avaliations_grade_ids'>
<div class='controls input'>
<input value='<%= grade_ids %>'
class='select2 required' tabindex="-1" type='hidden'
name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][grade_ids]"
id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_grade_ids" />
</div>
</div>
</td>
<td>
<div class="control-group string required disabled">
<div class="controls input">
<input class="form-control string disabled" disabled="disabled" type="text" value="<%= classroom_name %>" />
<div class='control-group string required disabled'>
<div class='controls input'>
<input class='form-control string disabled' disabled='disabled' type='text'
value="<%= classroom_name %>" style="width: 400px;"/>
</div>
</div>
</td>
<td>
<div class="control-group select2 required avaliation_multiple_creator_form_avaliations_classes">
<div class="controls input">
<input value="" data-without-json-parser="true" data-multiple="true" class="select2 required" type="hidden" style="width: 100%;" name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][classes]" id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_classes" tabindex="-1">
<div class='control-group string required disabled'>
<div class='controls input'>
<input class='select2 required'
readonly="true" value="<%= grade_name %>" style='width: 100%;'/>
</div>
</div>
</td>
<td>
<div class="control-group date required avaliation_multiple_creator_form_avaliations_test_date">
<div class="controls input">
<div class="icon-addon">
<label for="test_date" class="fa fa-calendar"></label>
<input class="string input-small form-control datepicker date required" size="10" type="text" data-mask="99/99/9999" name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][test_date]" id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_test_date"></div>
<div class='control-group date required avaliation_multiple_creator_form_avaliations_test_date'>
<div class='controls input'>
<div class='icon-addon'>
<label for='test_date' class='fa fa-calendar'></label>
<input class='string input-small form-control datepicker date required'
size='10' type='text' data-mask='99/99/9999' style='width: 250px;'
name="avaliation_multiple_creator_form[avaliations_attributes][<%= element_id %>][test_date]"
id="avaliation_multiple_creator_form_avaliations_attributes_<%= element_id %>_test_date"/>
</div>
</div>
</div>
</td>
Expand Down
22 changes: 14 additions & 8 deletions app/assets/javascripts/views/avaliations/multiple_classrooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/views/descriptive_exams/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,6 @@ $(function () {
$step.on('change', function () {
validateExistingExams();
})

validateExistingExams();
});
14 changes: 13 additions & 1 deletion app/assets/javascripts/views/discipline_lesson_plans/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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';

Expand Down
12 changes: 12 additions & 0 deletions app/assets/javascripts/views/knowledge_area_lesson_plans/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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';

Expand Down
27 changes: 19 additions & 8 deletions app/controllers/avaliations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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
23 changes: 19 additions & 4 deletions app/controllers/classrooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/conceptual_exams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit dfde6eb

Please sign in to comment.