Skip to content

Commit

Permalink
Addressed #6642 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDervishi committed Jul 21, 2023
1 parent 44c057a commit d0c5f57
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 29 deletions.
22 changes: 2 additions & 20 deletions app/assets/javascripts/Components/Modals/filter_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -271,11 +253,11 @@ export class FilterModal extends React.Component {
<p>{I18n.t("activerecord.models.section.one")}</p>
<SingleSelectDropDown
options={this.props.sections}
selected={this.props.filterData.sectionValue}
selected={this.props.filterData.section}
select={selection => {
this.props.mutateFilterData({
...this.props.filterData,
sectionValue: selection,
section: selection,
});
}}
defaultValue={""}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/Components/Result/result.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const INITIAL_FILTER_MODAL_STATE = {
annotationValue: "",
tas: [],
tags: [],
sectionValue: "",
section: "",
markingStateValue: "",
totalMarkRange: {
min: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("FilterModal", () => {
annotationValue: "",
tas: ["a", "b"],
tags: ["a", "b"],
sectionValue: "",
section: "",
markingStateValue: "",
totalMarkRange: {
min: "",
Expand Down
8 changes: 4 additions & 4 deletions app/models/grouping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/'').
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/results_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d0c5f57

Please sign in to comment.