From 81601ca6eafed0f2bb24f01510b00870652205d5 Mon Sep 17 00:00:00 2001 From: atesker Date: Tue, 1 Oct 2019 12:07:26 -0400 Subject: [PATCH 1/4] EDUCATOR-4365 - display max grade for not started assignments --- src/components/Gradebook/index.jsx | 10 +++++++--- src/containers/GradebookPage/index.jsx | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/Gradebook/index.jsx b/src/components/Gradebook/index.jsx index 93aedf5..6cd138f 100644 --- a/src/components/Gradebook/index.jsx +++ b/src/components/Gradebook/index.jsx @@ -78,10 +78,12 @@ export default class Gradebook extends React.Component { ); let adjustedGradePossible = ''; - - if (subsection.attempted) { - adjustedGradePossible = ` / ${subsection.score_possible}`; + // this check is necessary because there can be a delay between the very first time the grade + // is calculcated by the backend. + if (this.props.gradeOriginalPossibleGraded != null) { + adjustedGradePossible = ` / ${this.props.gradeOriginalPossibleGraded}`; } + this.setState({ modalAssignmentName: `${subsection.subsection_name}`, modalOpen: true, @@ -948,6 +950,7 @@ Gradebook.defaultProps = { gradeOverrides: [], gradeOverrideCurrentEarnedGradedOverride: null, gradeOriginalEarnedGraded: null, + gradeOriginalPossibleGraded: null, location: { search: '', }, @@ -1009,6 +1012,7 @@ Gradebook.propTypes = { })), gradeOverrideCurrentEarnedGradedOverride: PropTypes.number, gradeOriginalEarnedGraded: PropTypes.number, + gradeOriginalPossibleGraded: PropTypes.number, headings: PropTypes.arrayOf(PropTypes.string).isRequired, history: PropTypes.shape({ push: PropTypes.func, diff --git a/src/containers/GradebookPage/index.jsx b/src/containers/GradebookPage/index.jsx index e68520c..efaf551 100644 --- a/src/containers/GradebookPage/index.jsx +++ b/src/containers/GradebookPage/index.jsx @@ -51,6 +51,7 @@ const mapStateToProps = (state, ownProps) => ( gradeOverrideCurrentPossibleGradedOverride: state.grades.gradeOverrideCurrentPossibleGradedOverride, gradeOriginalEarnedGraded: state.grades.gradeOriginalEarnedGraded, + gradeOriginalPossibleGraded: state.grades.gradeOriginalPossibleGraded, headings: getHeadings(state), tracks: state.tracks.results, cohorts: state.cohorts.results, From 15cdd7a256c6cd07821569304c9936d0b5510ef8 Mon Sep 17 00:00:00 2001 From: Matt Hughes Date: Wed, 2 Oct 2019 12:19:12 -0400 Subject: [PATCH 2/4] handle the two distinct data sources for this information properly JIRA:EDUCATOR-4711 --- src/components/Gradebook/index.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Gradebook/index.jsx b/src/components/Gradebook/index.jsx index 6cd138f..3358bb9 100644 --- a/src/components/Gradebook/index.jsx +++ b/src/components/Gradebook/index.jsx @@ -78,10 +78,8 @@ export default class Gradebook extends React.Component { ); let adjustedGradePossible = ''; - // this check is necessary because there can be a delay between the very first time the grade - // is calculcated by the backend. - if (this.props.gradeOriginalPossibleGraded != null) { - adjustedGradePossible = ` / ${this.props.gradeOriginalPossibleGraded}`; + if (subsection.attempted) { + adjustedGradePossible = subsection.score_possible; } this.setState({ @@ -715,7 +713,12 @@ export default class Gradebook extends React.Component { name="adjustedGradeValue" value={this.state.adjustedGradeValue} onChange={value => this.onChange(value)} - /> {this.state.adjustedGradePossible} + /> + {(this.state.adjustedGradePossible + || this.props.gradeOriginalPossibleGraded) + && ' / '} + {this.state.adjustedGradePossible + || this.props.gradeOriginalPossibleGraded} ), }]} />)} From bc39443d9465424d6862b750c9c7e200cf5284a2 Mon Sep 17 00:00:00 2001 From: Matt Hughes Date: Wed, 2 Oct 2019 13:17:23 -0400 Subject: [PATCH 3/4] improving state management of these modal fields --- src/components/Gradebook/index.jsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/components/Gradebook/index.jsx b/src/components/Gradebook/index.jsx index 3358bb9..95934ca 100644 --- a/src/components/Gradebook/index.jsx +++ b/src/components/Gradebook/index.jsx @@ -149,15 +149,18 @@ export default class Gradebook extends React.Component { this.props.selectedTrack, ); - this.setState({ - modalOpen: false, - updateModuleId: null, - updateUserId: null, - reasonForChange: '', - adjustedGradeValue: '', - }); + this.closeAssignmentModal(); } + closeAssignmentModal = () => this.setState({ + adjustedGradePossible: '', + adjustedGradeValue: '', + modalOpen: false, + reasonForChange: '', + updateModuleId: null, + updateUserId: null, + }); + handleAssignmentFilterChange = (assignment) => { const selectedFilterOption = this.props.assignmentFilterOptions.find(assig => assig.label === assignment); @@ -737,13 +740,7 @@ export default class Gradebook extends React.Component { Save Grade , ]} - onClose={() => this.setState({ - modalOpen: false, - adjustedGradeValue: 0, - updateModuleId: null, - updateUserId: null, - reasonForChange: '', - })} + onClose={this.closeAssignmentModal} /> {this.props.showBulkManagement && ( From e8cbc66e6fc7da8814acc56d2f605531932693d4 Mon Sep 17 00:00:00 2001 From: Matt Hughes Date: Wed, 2 Oct 2019 13:51:43 -0400 Subject: [PATCH 4/4] clear out redux state related to the modal consistently ... as we already do with component state for these sorts of fields --- src/components/Gradebook/index.jsx | 20 ++++++++++++-------- src/containers/GradebookPage/index.jsx | 2 ++ src/data/actions/grades.js | 5 +++++ src/data/constants/actionTypes/grades.js | 2 ++ src/data/reducers/grades.js | 16 ++++++++++++++++ 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/components/Gradebook/index.jsx b/src/components/Gradebook/index.jsx index 95934ca..ca972a4 100644 --- a/src/components/Gradebook/index.jsx +++ b/src/components/Gradebook/index.jsx @@ -152,14 +152,17 @@ export default class Gradebook extends React.Component { this.closeAssignmentModal(); } - closeAssignmentModal = () => this.setState({ - adjustedGradePossible: '', - adjustedGradeValue: '', - modalOpen: false, - reasonForChange: '', - updateModuleId: null, - updateUserId: null, - }); + closeAssignmentModal = () => { + this.props.doneViewingAssignment(); + this.setState({ + adjustedGradePossible: '', + adjustedGradeValue: '', + modalOpen: false, + reasonForChange: '', + updateModuleId: null, + updateUserId: null, + }); + }; handleAssignmentFilterChange = (assignment) => { const selectedFilterOption = this.props.assignmentFilterOptions.find(assig => @@ -1013,6 +1016,7 @@ Gradebook.propTypes = { gradeOverrideCurrentEarnedGradedOverride: PropTypes.number, gradeOriginalEarnedGraded: PropTypes.number, gradeOriginalPossibleGraded: PropTypes.number, + doneViewingAssignment: PropTypes.func.isRequired, headings: PropTypes.arrayOf(PropTypes.string).isRequired, history: PropTypes.shape({ push: PropTypes.func, diff --git a/src/containers/GradebookPage/index.jsx b/src/containers/GradebookPage/index.jsx index efaf551..b746fce 100644 --- a/src/containers/GradebookPage/index.jsx +++ b/src/containers/GradebookPage/index.jsx @@ -3,6 +3,7 @@ import { connect } from 'react-redux'; import Gradebook from '../../components/Gradebook'; import { closeBanner, + doneViewingAssignment, fetchGradeOverrideHistory, fetchGrades, fetchMatchingUserGrades, @@ -115,6 +116,7 @@ const mapStateToProps = (state, ownProps) => ( ); const mapDispatchToProps = { + doneViewingAssignment, getUserGrades: fetchGrades, fetchGradeOverrideHistory, searchForUser: fetchMatchingUserGrades, diff --git a/src/data/actions/grades.js b/src/data/actions/grades.js index 0e5523a..d404329 100644 --- a/src/data/actions/grades.js +++ b/src/data/actions/grades.js @@ -16,6 +16,7 @@ import { GOT_BULK_HISTORY, BULK_HISTORY_ERR, GOT_GRADE_OVERRIDE_HISTORY, + DONE_VIEWING_ASSIGNMENT, ERROR_FETCHING_GRADE_OVERRIDE_HISTORY, UPLOAD_OVERRIDE, UPLOAD_OVERRIDE_ERROR, @@ -174,6 +175,9 @@ const formatGradeOverrideForDisplay = historyArray => historyArray.map(item => ( adjustedGrade: item.earned_graded_override, })); +const doneViewingAssignment = () => dispatch => dispatch({ + type: DONE_VIEWING_ASSIGNMENT, +}); const fetchGradeOverrideHistory = (subsectionId, userId) => ( dispatch => LmsApiService.fetchGradeOverrideHistory(subsectionId, userId) @@ -319,6 +323,7 @@ export { closeBanner, submitFileUploadFormData, fetchBulkUpgradeHistory, + doneViewingAssignment, fetchGradeOverrideHistory, updateGradesIfAssignmentGradeFiltersSet, }; diff --git a/src/data/constants/actionTypes/grades.js b/src/data/constants/actionTypes/grades.js index 345ac89..b8c91c3 100644 --- a/src/data/constants/actionTypes/grades.js +++ b/src/data/constants/actionTypes/grades.js @@ -2,6 +2,7 @@ const STARTED_FETCHING_GRADES = 'STARTED_FETCHING_GRADES'; const FINISHED_FETCHING_GRADES = 'FINISHED_FETCHING_GRADES'; const ERROR_FETCHING_GRADES = 'ERROR_FETCHING_GRADES'; const GOT_GRADES = 'GOT_GRADES'; +const DONE_VIEWING_ASSIGNMENT = 'DONE_VIEWING_ASSIGNMENT'; const GOT_GRADE_OVERRIDE_HISTORY = 'GOT_GRADE_OVERRIDE_HISTORY'; const ERROR_FETCHING_GRADE_OVERRIDE_HISTORY = 'ERROR_FETCHING_GRADE_OVERRIDE_HISTORY'; @@ -43,6 +44,7 @@ export { UPLOAD_ERR, GOT_BULK_HISTORY, BULK_HISTORY_ERR, + DONE_VIEWING_ASSIGNMENT, GOT_GRADE_OVERRIDE_HISTORY, ERROR_FETCHING_GRADE_OVERRIDE_HISTORY, FILTER_SELECTED, diff --git a/src/data/reducers/grades.js b/src/data/reducers/grades.js index 5668680..4fdcf0e 100644 --- a/src/data/reducers/grades.js +++ b/src/data/reducers/grades.js @@ -10,6 +10,7 @@ import { UPLOAD_COMPLETE, UPLOAD_ERR, GOT_BULK_HISTORY, + DONE_VIEWING_ASSIGNMENT, GOT_GRADE_OVERRIDE_HISTORY, ERROR_FETCHING_GRADE_OVERRIDE_HISTORY, } from '../constants/actionTypes/grades'; @@ -55,6 +56,21 @@ const grades = (state = initialState, action) => { totalUsersCount: action.totalUsersCount, filteredUsersCount: action.filteredUsersCount, }; + case DONE_VIEWING_ASSIGNMENT: { + const { + gradeOverrideHistoryResults, + gradeOverrideCurrentEarnedAllOverride, + gradeOverrideCurrentPossibleAllOverride, + gradeOverrideCurrentEarnedGradedOverride, + gradeOverrideCurrentPossibleGradedOverride, + gradeOriginalEarnedAll, + gradeOriginalPossibleAll, + gradeOriginalEarnedGraded, + gradeOriginalPossibleGraded, + ...rest + } = state; + return rest; + } case GOT_GRADE_OVERRIDE_HISTORY: return { ...state,