Skip to content

Commit ea05594

Browse files
remo5000ning-y
authored andcommitted
Change Submission Semantics (#178)
* Change ControlBar to show 'Done' * Change controlBarProps for playground * Fix prop typo in ControlBar * Change controlBarProps for GradingWorkspace * Change controlBarProps for AssessmentWorkspace * Make control bar's has* properties mandatory * Add mandatory properties to Playground * Alphabetisize AssessmentWorkspace props * Alphabetisize GradingWorkspace controlbar props and one additional prop for AssessmentWorkspace as well. * Move library definition to question Even MCQ questions need library to use the REPL * Pass sourceChapter as a prop for AssessmentWorkspace * Add make GradingWorkspace pass in chapter prop * Fix questionId overflow for GradingWorkspace * Format GradingWorkspace
1 parent 62f2d69 commit ea05594

File tree

8 files changed

+45
-37
lines changed

8 files changed

+45
-37
lines changed

src/components/Playground.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ class Playground extends React.Component<IPlaygroundProps, PlaygroundState> {
6161
handleReplEval: this.props.handleReplEval,
6262
handleReplOutputClear: this.props.handleReplOutputClear,
6363
hasChapterSelect: true,
64+
hasDoneButton: false,
6465
hasNextButton: false,
6566
hasPreviousButton: false,
66-
hasSubmitButton: false,
67+
hasSaveButton: false,
68+
hasShareButton: true,
6769
isRunning: this.props.isRunning,
6870
queryString: this.props.queryString,
6971
sourceChapter: this.props.sourceChapter

src/components/academy/grading/GradingWorkspace.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,15 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
6464
)
6565
}
6666

67+
/* If questionId is out of bounds, set it to the max. */
68+
const questionId =
69+
this.props.questionId >= this.props.grading.length
70+
? this.props.grading.length - 1
71+
: this.props.questionId
6772
/* Get the question to be graded */
68-
const question = this.props.grading[this.props.questionId].question as IQuestion
73+
const question = this.props.grading[questionId].question as IQuestion
6974
const workspaceProps: WorkspaceProps = {
70-
controlBarProps: this.controlBarProps(this.props),
75+
controlBarProps: this.controlBarProps(this.props, questionId),
7176
editorProps:
7277
question.type === QuestionTypes.programming
7378
? {
@@ -84,7 +89,7 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
8489
handleSideContentHeightChange: this.props.handleSideContentHeightChange,
8590
mcq: question as IMCQQuestion,
8691
sideContentHeight: this.props.sideContentHeight,
87-
sideContentProps: this.sideContentProps(this.props),
92+
sideContentProps: this.sideContentProps(this.props, questionId),
8893
replProps: {
8994
output: this.props.output,
9095
replValue: this.props.replValue,
@@ -100,29 +105,31 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
100105
}
101106

102107
/** Pre-condition: Grading has been loaded */
103-
private sideContentProps: (p: GradingWorkspaceProps) => SideContentProps = (
104-
props: GradingWorkspaceProps
108+
private sideContentProps: (p: GradingWorkspaceProps, q: number) => SideContentProps = (
109+
props: GradingWorkspaceProps,
110+
questionId: number
105111
) => ({
106112
activeTab: props.activeTab,
107113
handleChangeActiveTab: props.handleChangeActiveTab,
108114
tabs: [
109115
{
110-
label: `Grading: Question ${props.questionId}`,
116+
label: `Grading: Question ${questionId}`,
111117
icon: IconNames.TICK,
112118
/* Render an editor with the xp given to the current question. */
113-
body: <GradingEditor maximumXP={props.grading![props.questionId].maximumXP} />
119+
body: <GradingEditor maximumXP={props.grading![questionId].maximumXP} />
114120
},
115121
{
116-
label: `Task ${props.questionId}`,
122+
label: `Task ${questionId}`,
117123
icon: IconNames.NINJA,
118-
body: <Text> {props.grading![props.questionId].question.content} </Text>
124+
body: <Text> {props.grading![questionId].question.content} </Text>
119125
}
120126
]
121127
})
122128

123129
/** Pre-condition: Grading has been loaded */
124-
private controlBarProps: (p: GradingWorkspaceProps) => ControlBarProps = (
125-
props: GradingWorkspaceProps
130+
private controlBarProps: (p: GradingWorkspaceProps, q: number) => ControlBarProps = (
131+
props: GradingWorkspaceProps,
132+
questionId: number
126133
) => {
127134
const listingPath = `/academy/grading`
128135
const gradingWorkspacePath = listingPath + `/${this.props.submissionId}`
@@ -133,18 +140,16 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
133140
handleReplEval: this.props.handleReplEval,
134141
handleReplOutputClear: this.props.handleReplOutputClear,
135142
hasChapterSelect: false,
136-
hasNextButton: this.props.questionId < this.props.grading!.length - 1,
137-
hasPreviousButton: this.props.questionId > 0,
143+
hasDoneButton: questionId === this.props.grading!.length - 1,
144+
hasNextButton: questionId < this.props.grading!.length - 1,
145+
hasPreviousButton: questionId > 0,
138146
hasSaveButton: false,
139147
hasShareButton: false,
140-
hasSubmitButton: this.props.questionId === this.props.grading!.length - 1,
141148
isRunning: this.props.isRunning,
142-
onClickNext: () =>
143-
history.push(gradingWorkspacePath + `/${(this.props.questionId + 1).toString()}`),
144-
onClickPrevious: () =>
145-
history.push(gradingWorkspacePath + `/${(this.props.questionId - 1).toString()}`),
146-
onClickSubmit: () => history.push(listingPath),
147-
sourceChapter: 2 // TODO dynamic library changing
149+
onClickDone: () => history.push(listingPath),
150+
onClickNext: () => history.push(gradingWorkspacePath + `/${(questionId + 1).toString()}`),
151+
onClickPrevious: () => history.push(gradingWorkspacePath + `/${(questionId - 1).toString()}`),
152+
sourceChapter: this.props.grading![questionId].question.library.chapter
148153
}
149154
}
150155
}

src/components/academy/grading/gradingShape.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AssessmentCategory, IQuestion, Library, MCQChoice } from '../../assessment/assessmentShape'
1+
import { AssessmentCategory, IQuestion, MCQChoice } from '../../assessment/assessmentShape'
22

33
/**
44
* Information on a Grading, for a particular student submission
@@ -44,7 +44,6 @@ export type GradingQuestion = {
4444
interface IAnsweredQuestion extends IQuestion {
4545
solution?: number
4646
answer?: string | number
47-
library?: Library
4847
solutionTemplate?: string
4948
choices?: MCQChoice[]
5049
}

src/components/assessment/AssessmentWorkspace.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,17 @@ class AssessmentWorkspace extends React.Component<
159159
handleReplEval: this.props.handleReplEval,
160160
handleReplOutputClear: this.props.handleReplOutputClear,
161161
hasChapterSelect: false,
162+
hasDoneButton: questionId === this.props.assessment!.questions.length - 1,
162163
hasNextButton: questionId < this.props.assessment!.questions.length - 1,
163164
hasPreviousButton: questionId > 0,
164165
hasSaveButton: true,
165166
hasShareButton: false,
166-
hasSubmitButton: questionId === this.props.assessment!.questions.length - 1,
167167
isRunning: this.props.isRunning,
168+
onClickDone: () => history.push(listingPath),
168169
onClickNext: () => history.push(assessmentWorkspacePath + `/${(questionId + 1).toString()}`),
169170
onClickPrevious: () =>
170171
history.push(assessmentWorkspacePath + `/${(questionId - 1).toString()}`),
171-
onClickSubmit: () => history.push(listingPath),
172-
sourceChapter: 2 // TODO dynamic library changing
172+
sourceChapter: this.props.assessment!.questions[questionId].library.chapter
173173
}
174174
}
175175
}

src/components/assessment/assessmentShape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export enum AssessmentCategories {
3434
export type AssessmentCategory = keyof typeof AssessmentCategories
3535

3636
export interface IProgrammingQuestion extends IQuestion {
37-
library: Library
3837
solutionTemplate: string
3938
type: 'programming'
4039
}
@@ -47,6 +46,7 @@ export interface IMCQQuestion extends IQuestion {
4746
export interface IQuestion {
4847
content: string
4948
id: number
49+
library: Library
5050
type: QuestionType
5151
}
5252

src/components/workspace/ControlBar.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { sourceChapters } from '../../reducers/states'
88
import { controlButton } from '../commons'
99

1010
export type ControlBarProps = {
11-
hasChapterSelect?: boolean
12-
hasNextButton?: boolean
13-
hasPreviousButton?: boolean
14-
hasSaveButton?: boolean
15-
hasShareButton?: boolean
16-
hasSubmitButton?: boolean
11+
hasChapterSelect: boolean
12+
hasNextButton: boolean
13+
hasPreviousButton: boolean
14+
hasSaveButton: boolean
15+
hasShareButton: boolean
16+
hasDoneButton: boolean
1717
isRunning: boolean
1818
queryString?: string
1919
sourceChapter: number
@@ -26,7 +26,7 @@ export type ControlBarProps = {
2626
onClickNext?(): any
2727
onClickPrevious?(): any
2828
onClickSave?(): any
29-
onClickSubmit?(): any
29+
onClickDone?(): any
3030
}
3131

3232
interface IChapter {
@@ -41,7 +41,7 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
4141
hasPreviousButton: false,
4242
hasSaveButton: false,
4343
hasShareButton: true,
44-
hasSubmitButton: false,
44+
hasDoneButton: false,
4545
onClickNext: () => {},
4646
onClickPrevious: () => {},
4747
onClickSave: () => {}
@@ -120,8 +120,8 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
120120
const nextButton = this.props.hasNextButton
121121
? controlButton('Next', IconNames.ARROW_RIGHT, this.props.onClickNext, { iconOnRight: true })
122122
: undefined
123-
const submitButton = this.props.hasSubmitButton
124-
? controlButton('Submit', IconNames.TICK_CIRCLE, this.props.onClickSubmit, {
123+
const submitButton = this.props.hasDoneButton
124+
? controlButton('Done', IconNames.TICK_CIRCLE, this.props.onClickDone, {
125125
iconOnRight: true
126126
})
127127
: undefined

src/mocks/assessmentAPI.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const mockAssessmentQuestions: Array<IProgrammingQuestion | IMCQQuestion>
117117
}
118118
],
119119
id: 2,
120+
library: mockLibrary,
120121
type: 'mcq'
121122
}
122123
]

src/mocks/gradingAPI.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const mockGrading: Grading = [
111111
}
112112
],
113113
id: 2,
114+
library: mockLibrary,
114115
type: 'mcq'
115116
},
116117
maximumXP: 100,

0 commit comments

Comments
 (0)