Skip to content

Commit 0021d31

Browse files
remo5000ning-y
authored andcommitted
Hide long summary unless unattempted (#264)
* Add attempted prop for AssessmentWorkspace * Pass attempted field to AssessmentWorkspace * Change to notAttempted property There are fields such as attemping and attempted that will cause confusion * Remove attmpted field from IAssessmentOverview It is redundant * Pass in proper field to AssessmentWorkspace There was a bug there, whoops
1 parent 8aca70d commit 0021d31

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

src/components/assessment/AssessmentWorkspace.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type StateProps = {
3737
export type OwnProps = {
3838
assessmentId: number
3939
questionId: number
40+
notAttempted: boolean
4041
closeDate: string
4142
}
4243

@@ -65,7 +66,12 @@ class AssessmentWorkspace extends React.Component<
6566
AssessmentWorkspaceProps,
6667
{ showOverlay: boolean }
6768
> {
68-
public state = { showOverlay: false }
69+
public constructor(props: AssessmentWorkspaceProps) {
70+
super(props)
71+
this.state = {
72+
showOverlay: false
73+
}
74+
}
6975

7076
/**
7177
* After mounting (either an older copy of the assessment
@@ -74,7 +80,7 @@ class AssessmentWorkspace extends React.Component<
7480
*/
7581
public componentDidMount() {
7682
this.props.handleAssessmentFetch(this.props.assessmentId)
77-
if (this.props.questionId === 0) {
83+
if (this.props.questionId === 0 && this.props.notAttempted) {
7884
this.setState({ showOverlay: true })
7985
}
8086
}

src/components/assessment/__tests__/AssessmentWorkspace.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import AssessmentWorkspace, { AssessmentWorkspaceProps } from '../AssessmentWork
88
const defaultProps: AssessmentWorkspaceProps = {
99
activeTab: 0,
1010
assessmentId: 0,
11+
notAttempted: true,
1112
closeDate: '2048-06-18T05:24:26.026Z',
1213
editorValue: null,
1314
editorWidth: '50%',

src/components/assessment/assessmentShape.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Used to display information regarding an assessment in the UI.
33
*/
44
export interface IAssessmentOverview {
5-
attempted: boolean
65
category: AssessmentCategory
76
closeAt: string
87
coverImage: string

src/components/assessment/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ class Assessment extends React.Component<IAssessmentProps, State> {
8787
// If there is an assessment to render, create a workspace. The assessment
8888
// overviews must still be loaded for this, to send the due date.
8989
if (assessmentId !== null && this.props.assessmentOverviews !== undefined) {
90+
const overview = this.props.assessmentOverviews.filter(a => a.id === assessmentId)[0]
9091
const assessmentProps: AssessmentProps = {
9192
assessmentId,
9293
questionId,
93-
// get the closeDate of the assessment
94-
closeDate: this.props.assessmentOverviews.filter(a => a.id === assessmentId)[0].closeAt
94+
notAttempted: overview.status === AssessmentStatuses.not_attempted,
95+
closeDate: overview.closeAt
9596
}
9697
return <AssessmentWorkspaceContainer {...assessmentProps} />
9798
}

src/mocks/assessmentAPI.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { externalLibraries } from '../reducers/externalLibraries'
1212

1313
const mockOpenAssessmentsOverviews: IAssessmentOverview[] = [
1414
{
15-
attempted: true,
1615
category: AssessmentCategories.Mission,
1716
closeAt: '2048-06-18T05:24:26.026Z',
1817
coverImage: 'https://fakeimg.pl/300/',
@@ -26,7 +25,6 @@ const mockOpenAssessmentsOverviews: IAssessmentOverview[] = [
2625
story: 'mission-1'
2726
},
2827
{
29-
attempted: false,
3028
category: AssessmentCategories.Mission,
3129
closeAt: '2048-06-18T05:24:26.026Z',
3230
coverImage: 'https://fakeimg.pl/350x200/?text=World&font=lobster',
@@ -40,7 +38,6 @@ const mockOpenAssessmentsOverviews: IAssessmentOverview[] = [
4038
story: 'mission-2'
4139
},
4240
{
43-
attempted: true,
4441
category: AssessmentCategories.Sidequest,
4542
closeAt: '2048-06-18T05:24:26.026Z',
4643
coverImage: 'https://fakeimg.pl/350x200/?text=Hello',
@@ -57,7 +54,6 @@ const mockOpenAssessmentsOverviews: IAssessmentOverview[] = [
5754

5855
const mockClosedAssessmentOverviews: IAssessmentOverview[] = [
5956
{
60-
attempted: true,
6157
category: AssessmentCategories.Mission,
6258
closeAt: '2008-06-18T05:24:26.026Z',
6359
coverImage: 'https://fakeimg.pl/350x200/ff0000/000',
@@ -71,7 +67,6 @@ const mockClosedAssessmentOverviews: IAssessmentOverview[] = [
7167
story: 'mission-3'
7268
},
7369
{
74-
attempted: false,
7570
category: AssessmentCategories.Sidequest,
7671
closeAt: '2008-06-18T05:24:26.026Z',
7772
coverImage: 'https://fakeimg.pl/350x200/ff0000,128/000,255',

0 commit comments

Comments
 (0)