-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: hide file upload if it was disabled * chore: prevent status alert from crashing for now * chore: change step states from complete to done * chore: change assessment data shape to match backend * chore: remove unnecessary onclick on info popover * chore: update some logic on progress bar * chore: update url to use the real backend * chore: update step state complete to done * chore: update requested change * chore: update requested change
- Loading branch information
1 parent
b0a1912
commit 7ff5c5d
Showing
19 changed files
with
217 additions
and
64 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/components/Assessment/ReadonlyAssessment/AssessmentCriterion.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import Feedback from './Feedback'; | ||
import messages from './messages'; | ||
import { useORAConfigData } from 'data/services/lms/hooks/selectors'; | ||
|
||
const AssessmentCriterion = ({ | ||
criteria, | ||
overallFeedback, | ||
stepLabel, | ||
}) => { | ||
const { formatMessage } = useIntl(); | ||
const { rubricConfig } = useORAConfigData(); | ||
return ( | ||
<> | ||
{rubricConfig.criteria.map((criterion, i) => { | ||
const assessmentCriterion = criteria[i]; | ||
const option = criterion.options[assessmentCriterion.selectedOption]; | ||
return ( | ||
<Feedback | ||
key={criterion.name} | ||
criterionName={criterion.name} | ||
criterionDescription={criterion.description} | ||
selectedOption={option.name} | ||
selectedPoints={option.points} | ||
commentHeader={stepLabel} | ||
commentBody={assessmentCriterion.feedback} | ||
/> | ||
); | ||
})} | ||
<Feedback | ||
criterionName={formatMessage(messages.overallFeedback)} | ||
commentHeader={stepLabel} | ||
commentBody={overallFeedback} | ||
/> | ||
</> | ||
); | ||
}; | ||
AssessmentCriterion.defaultProps = {}; | ||
AssessmentCriterion.propTypes = { | ||
criteria: PropTypes.arrayOf(PropTypes.shape({ | ||
selectedOption: PropTypes.number, | ||
// selectedPoints: PropTypes.number, | ||
feedback: PropTypes.string, | ||
})), | ||
overallFeedback: PropTypes.string, | ||
stepLabel: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default AssessmentCriterion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { useIntl } from '@edx/frontend-platform/i18n'; | ||
import { CheckCircle, Info, WarningFilled } from '@edx/paragon/icons'; | ||
import { StrictDict } from '@edx/react-unit-test-utils'; | ||
|
||
import { | ||
stepNames, | ||
stepStates, | ||
} from 'data/services/lms/constants'; | ||
import { useGlobalState } from 'data/services/lms/hooks/selectors'; | ||
import messages from './messages'; | ||
import alertMessages from './alertMessages'; | ||
import headingMessages from './alertHeadingMessages'; | ||
|
||
export const alertMap = { | ||
[stepStates.done]: { | ||
variant: 'success', | ||
icon: CheckCircle, | ||
}, | ||
[stepStates.closed]: { | ||
variant: 'danger', | ||
icon: Info, | ||
}, | ||
[stepStates.teamAlreadySubmitted]: { | ||
variant: 'warning', | ||
icon: WarningFilled, | ||
}, | ||
[stepStates.cancelled]: { | ||
variant: 'warning', | ||
icon: WarningFilled, | ||
}, | ||
[stepStates.inProgress]: { | ||
variant: 'dark', | ||
icon: null, | ||
}, | ||
}; | ||
|
||
const useStatusAlertMessages = (step = null) => { | ||
const { formatMessage } = useIntl(); | ||
const { | ||
activeStepName, | ||
stepState, | ||
cancellationInfo, | ||
} = useGlobalState({ step }); | ||
const stepName = step || activeStepName; | ||
const isRevisit = stepName !== activeStepName; | ||
if (cancellationInfo.hasCancelled) { | ||
const { cancelledBy, cancelledAt } = cancellationInfo; | ||
if (cancelledBy) { | ||
return { | ||
message: formatMessage( | ||
alertMessages.submission.cancelledBy, | ||
{ cancelledBy, cancelledAt }, | ||
), | ||
heading: formatMessage(headingMessages.submission.cancelledBy), | ||
}; | ||
} | ||
return { | ||
message: formatMessage(alertMessages.submission.cancelledAt, { cancelledAt }), | ||
heading: formatMessage(headingMessages.submission.cancelledAt), | ||
}; | ||
} | ||
if (stepName === stepNames.submission && isRevisit) { | ||
return { | ||
message: formatMessage(alertMessages.submission.finished), | ||
heading: formatMessage(headingMessages.submission.finished), | ||
}; | ||
} | ||
if (stepName === stepNames.peer && isRevisit && stepState !== stepStates.waiting) { | ||
return { | ||
message: formatMessage(alertMessages.peer.finished), | ||
heading: formatMessage(headingMessages.peer.finished), | ||
}; | ||
} | ||
return { | ||
message: formatMessage(alertMessages[stepName][stepState]), | ||
heading: formatMessage(headingMessages[stepName][stepState]), | ||
}; | ||
}; | ||
|
||
const useStatusAlert = (step = null) => { | ||
const { stepState } = useGlobalState({ step }); | ||
const { variant, icon } = alertMap[stepState]; | ||
const { message, heading } = useStatusAlertMessages(step); | ||
return { | ||
variant, | ||
icon, | ||
message, | ||
heading, | ||
}; | ||
}; | ||
|
||
export default useStatusAlert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.