From d0c5f57299a743af60408a2dd605ae990b67af88 Mon Sep 17 00:00:00 2001 From: Daniel Dervishi Date: Fri, 21 Jul 2023 15:34:39 -0400 Subject: [PATCH] Addressed https://github.com/MarkUsProject/Markus/pull/6642#discussion_r1268810530 --- .../Components/Modals/filter_modal.jsx | 22 ++----------------- .../javascripts/Components/Result/result.jsx | 2 +- .../__tests__/filter_modal.test.jsx | 2 +- app/models/grouping.rb | 8 +++---- spec/controllers/results_controller_spec.rb | 6 ++--- 5 files changed, 11 insertions(+), 29 deletions(-) diff --git a/app/assets/javascripts/Components/Modals/filter_modal.jsx b/app/assets/javascripts/Components/Modals/filter_modal.jsx index 9a20f99746..3f933afe1b 100644 --- a/app/assets/javascripts/Components/Modals/filter_modal.jsx +++ b/app/assets/javascripts/Components/Modals/filter_modal.jsx @@ -4,24 +4,6 @@ import {MultiSelectDropdown} from "../../DropDownMenu/MultiSelectDropDown"; import {SingleSelectDropDown} from "../../DropDownMenu/SingleSelectDropDown"; import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"; -const INITIAL_MODAL_STATE = { - currentOrderBy: I18n.t("activerecord.attributes.group.group_name"), - currentAscBool: true, - currentAnnotationValue: "", - currentSectionValue: "", - currentMarkingStateValue: "", - currentTas: [], - currentTags: [], - currentTotalMarkRange: { - min: "", - max: "", - }, - currentTotalExtraMarkRange: { - min: "", - max: "", - }, -}; - export class FilterModal extends React.Component { constructor(props) { super(props); @@ -271,11 +253,11 @@ export class FilterModal extends React.Component {

{I18n.t("activerecord.models.section.one")}

{ this.props.mutateFilterData({ ...this.props.filterData, - sectionValue: selection, + section: selection, }); }} defaultValue={""} diff --git a/app/assets/javascripts/Components/Result/result.jsx b/app/assets/javascripts/Components/Result/result.jsx index 0d6110e799..6f829f164f 100644 --- a/app/assets/javascripts/Components/Result/result.jsx +++ b/app/assets/javascripts/Components/Result/result.jsx @@ -23,7 +23,7 @@ const INITIAL_FILTER_MODAL_STATE = { annotationValue: "", tas: [], tags: [], - sectionValue: "", + section: "", markingStateValue: "", totalMarkRange: { min: "", diff --git a/app/assets/javascripts/Components/__tests__/filter_modal.test.jsx b/app/assets/javascripts/Components/__tests__/filter_modal.test.jsx index 220407fb22..58ff8f6420 100644 --- a/app/assets/javascripts/Components/__tests__/filter_modal.test.jsx +++ b/app/assets/javascripts/Components/__tests__/filter_modal.test.jsx @@ -22,7 +22,7 @@ describe("FilterModal", () => { annotationValue: "", tas: ["a", "b"], tags: ["a", "b"], - sectionValue: "", + section: "", markingStateValue: "", totalMarkRange: { min: "", diff --git a/app/models/grouping.rb b/app/models/grouping.rb index 3699575b27..18c624cdfe 100644 --- a/app/models/grouping.rb +++ b/app/models/grouping.rb @@ -745,8 +745,8 @@ def get_random_incomplete(current_role) # +filter_data+ is not nil. # +filter_data['annotationValue']+ is a string specifying some annotation text to filter by. To avoid this filtering # option don't set +filter_data['annotationValue']+ (or set it to nil/''). - # +filter_data['sectionValue']+ is a string specifying the name of the section to filter by. To avoid this filtering - # option don't set +filter_data['sectionValue']+ (or set it to nil/''). + # +filter_data['section']+ is a string specifying the name of the section to filter by. To avoid this filtering + # option don't set +filter_data['section']+ (or set it to nil/''). # +filter_data['markingStateValue']+ is a string specifying the marking state to filter by; valid strings # include "Remark Requested", "Released", "Complete" and "In Progress". To avoid this filtering # option don't set +filter_data['markingStateValue']+ (or set it to nil/''). @@ -767,8 +767,8 @@ def filter_results(current_role, results, filter_data) .where('annotation_texts.content LIKE ?', "%#{AnnotationText.sanitize_sql_like(filter_data['annotationValue'])}%") end - if filter_data['sectionValue'].present? - results = results.joins(grouping: :section).where('section.name': filter_data['sectionValue']) + if filter_data['section'].present? + results = results.joins(grouping: :section).where('section.name': filter_data['section']) end if filter_data['markingStateValue'].present? remark_results = results.where.not('results.remark_request_submitted_at': nil) diff --git a/spec/controllers/results_controller_spec.rb b/spec/controllers/results_controller_spec.rb index 1fad51f8e2..7d9aa286fb 100644 --- a/spec/controllers/results_controller_spec.rb +++ b/spec/controllers/results_controller_spec.rb @@ -128,14 +128,14 @@ def self.test_unauthorized(route_name) it 'should return the next group with a larger group name that satisfies the constraints' do get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id, id: grouping1.current_result.id, - direction: 1, filterData: { sectionValue: 'Section 1' } } + direction: 1, filterData: { section: 'Section 1' } } expect(response.parsed_body['next_grouping']['id']).to eq(grouping3.id) end it 'should not return the next group that doesn\'t satisfy the constraint' do get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id, id: grouping1.current_result.id, - direction: 1, filterData: { sectionValue: 'Section 1' } } + direction: 1, filterData: { section: 'Section 1' } } expect(response.parsed_body['next_grouping']['id']).not_to eq(grouping2.id) end end @@ -144,7 +144,7 @@ def self.test_unauthorized(route_name) it 'should return the next grouping without constraints' do get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id, id: grouping1.current_result.id, - direction: 1, filterData: { sectionValue: '' } } + direction: 1, filterData: { section: '' } } expect(response.parsed_body['next_grouping']['id']).to eq(grouping2.id) end end