add rubric tab open state to student view

closes EVAL-4016
flag=assignments_2_student

Test Plan:
- Create an assignment with text entry submission type.
- Attach a rubric to the assignment.
- As a student, go to the assignment
- Ensure the rubric is initially expanded
- Close the rubric with the little arrow in the corner
- Start typing a reply in the RCE.
- Once you stop typing, and the RCE saves the draft, after a few seconds
- ensure the rubric panel does NOT open up again.

Change-Id: I176d1dd94fc60298dfb032f4c0f1db6493b068c2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/345641
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Chris Soto <christopher.soto@instructure.com>
Product-Review: Ravi Koll <ravi.koll@instructure.com>
This commit is contained in:
Kai Bjorkman 2024-04-18 16:29:30 -06:00
parent 7bac8db0db
commit b24bb5bc1e
4 changed files with 27 additions and 4 deletions

View File

@ -16,7 +16,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, {useState} from 'react'
import {arrayOf, bool} from 'prop-types'
import {arrayOf, bool, func} from 'prop-types'
import CanvasSelect from '@canvas/instui-bindings/react/Select'
import {fillAssessment} from '@canvas/rubrics/react/helpers'
import {useScope as useI18nScope} from '@canvas/i18n'
@ -216,6 +216,8 @@ RubricTab.propTypes = {
rubric: Rubric.shape,
rubricAssociation: RubricAssociation.shape,
peerReviewModeEnabled: bool,
rubricExpanded: bool,
toggleRubricExpanded: func,
}
RubricTab.defaultProps = {

View File

@ -28,6 +28,7 @@ import {useQuery} from 'react-apollo'
import {transformRubricData, transformRubricAssessmentData} from '../helpers/RubricHelpers'
import useStore from './stores/index'
import {fillAssessment} from '@canvas/rubrics/react/helpers'
import {bool, func} from 'prop-types'
const I18n = useI18nScope('assignments_2')
@ -84,6 +85,8 @@ export default function RubricsQuery(props) {
rubric={transformRubricData(data.assignment.rubric)}
rubricAssociation={data.assignment.rubricAssociation}
peerReviewModeEnabled={props.assignment.env.peerReviewModeEnabled}
rubricExpanded={props.rubricExpanded}
toggleRubricExpanded={props.toggleRubricExpanded}
/>
)
}
@ -91,4 +94,6 @@ export default function RubricsQuery(props) {
RubricsQuery.propTypes = {
assignment: Assignment.shape,
submission: Submission.shape,
rubricExpanded: bool,
toggleRubricExpanded: func,
}

View File

@ -43,7 +43,7 @@ import VisualOnFocusMessage from './VisualOnFocusMessage'
import ToolLaunchIframe from '@canvas/external-tools/react/components/ToolLaunchIframe'
import iframeAllowances from '@canvas/external-apps/iframeAllowances'
import {Flex} from '@instructure/ui-flex'
import {arrayOf, func} from 'prop-types'
import {arrayOf, func, bool} from 'prop-types'
const I18n = useI18nScope('assignments_2_student_content')
@ -128,7 +128,7 @@ function renderAttemptsAndAvailability(assignment) {
}
function renderContentBaseOnAvailability(
{assignment, submission, reviewerSubmission},
{assignment, submission, reviewerSubmission, rubricExpanded, toggleRubricExpanded},
alertContext,
onSuccessfulPeerReview
) {
@ -182,7 +182,12 @@ function renderContentBaseOnAvailability(
{assignment.rubric && (
<Suspense fallback={<LoadingIndicator />}>
<RubricsQuery assignment={assignment} submission={submission} />
<RubricsQuery
assignment={assignment}
submission={submission}
rubricExpanded={rubricExpanded}
toggleRubricExpanded={toggleRubricExpanded}
/>
</Suspense>
)}
</div>
@ -314,6 +319,8 @@ StudentContent.propTypes = {
reviewerSubmission: Submission.shape,
onChangeSubmission: func,
allSubmissions: arrayOf(Submission.shape),
rubricExpanded: bool,
toggleRubricExpanded: func,
}
StudentContent.defaultProps = {

View File

@ -92,6 +92,7 @@ class ViewManager extends React.Component {
dummyNextSubmission: null,
submissions: [],
reviewerSubmission: [],
rubricExpanded: true,
}
static getDerivedStateFromProps(props, state) {
@ -238,6 +239,12 @@ class ViewManager extends React.Component {
})
}
toggleRubricExpanded = () => {
this.setState(prevState => ({
rubricExpanded: !prevState.rubricExpanded,
}))
}
render() {
const assignment = this.getAssignment()
const submission = this.getDisplayedSubmission()
@ -267,6 +274,8 @@ class ViewManager extends React.Component {
reviewerSubmission={reviewerSubmission}
allSubmissions={this.state.submissions}
onChangeSubmission={this.onChangeSubmission}
rubricExpanded={this.state.rubricExpanded}
toggleRubricExpanded={this.toggleRubricExpanded}
/>
</StudentViewContext.Provider>
)