Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ class Playground extends React.Component<IPlaygroundProps, PlaygroundState> {
handleReplEval: this.props.handleReplEval,
handleReplOutputClear: this.props.handleReplOutputClear,
hasChapterSelect: true,
hasDoneButton: false,
hasNextButton: false,
hasPreviousButton: false,
hasSubmitButton: false,
hasSaveButton: false,
hasShareButton: true,
isRunning: this.props.isRunning,
queryString: this.props.queryString,
sourceChapter: this.props.sourceChapter
Expand Down
45 changes: 25 additions & 20 deletions src/components/academy/grading/GradingWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
)
}

/* If questionId is out of bounds, set it to the max. */
const questionId =
this.props.questionId >= this.props.grading.length
? this.props.grading.length - 1
: this.props.questionId
/* Get the question to be graded */
const question = this.props.grading[this.props.questionId].question as IQuestion
const question = this.props.grading[questionId].question as IQuestion
const workspaceProps: WorkspaceProps = {
controlBarProps: this.controlBarProps(this.props),
controlBarProps: this.controlBarProps(this.props, questionId),
editorProps:
question.type === QuestionTypes.programming
? {
Expand All @@ -84,7 +89,7 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
handleSideContentHeightChange: this.props.handleSideContentHeightChange,
mcq: question as IMCQQuestion,
sideContentHeight: this.props.sideContentHeight,
sideContentProps: this.sideContentProps(this.props),
sideContentProps: this.sideContentProps(this.props, questionId),
replProps: {
output: this.props.output,
replValue: this.props.replValue,
Expand All @@ -100,29 +105,31 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
}

/** Pre-condition: Grading has been loaded */
private sideContentProps: (p: GradingWorkspaceProps) => SideContentProps = (
props: GradingWorkspaceProps
private sideContentProps: (p: GradingWorkspaceProps, q: number) => SideContentProps = (
props: GradingWorkspaceProps,
questionId: number
) => ({
activeTab: props.activeTab,
handleChangeActiveTab: props.handleChangeActiveTab,
tabs: [
{
label: `Grading: Question ${props.questionId}`,
label: `Grading: Question ${questionId}`,
icon: IconNames.TICK,
/* Render an editor with the xp given to the current question. */
body: <GradingEditor maximumXP={props.grading![props.questionId].maximumXP} />
body: <GradingEditor maximumXP={props.grading![questionId].maximumXP} />
},
{
label: `Task ${props.questionId}`,
label: `Task ${questionId}`,
icon: IconNames.NINJA,
body: <Text> {props.grading![props.questionId].question.content} </Text>
body: <Text> {props.grading![questionId].question.content} </Text>
}
]
})

/** Pre-condition: Grading has been loaded */
private controlBarProps: (p: GradingWorkspaceProps) => ControlBarProps = (
props: GradingWorkspaceProps
private controlBarProps: (p: GradingWorkspaceProps, q: number) => ControlBarProps = (
props: GradingWorkspaceProps,
questionId: number
) => {
const listingPath = `/academy/grading`
const gradingWorkspacePath = listingPath + `/${this.props.submissionId}`
Expand All @@ -133,18 +140,16 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
handleReplEval: this.props.handleReplEval,
handleReplOutputClear: this.props.handleReplOutputClear,
hasChapterSelect: false,
hasNextButton: this.props.questionId < this.props.grading!.length - 1,
hasPreviousButton: this.props.questionId > 0,
hasDoneButton: questionId === this.props.grading!.length - 1,
hasNextButton: questionId < this.props.grading!.length - 1,
hasPreviousButton: questionId > 0,
hasSaveButton: false,
hasShareButton: false,
hasSubmitButton: this.props.questionId === this.props.grading!.length - 1,
isRunning: this.props.isRunning,
onClickNext: () =>
history.push(gradingWorkspacePath + `/${(this.props.questionId + 1).toString()}`),
onClickPrevious: () =>
history.push(gradingWorkspacePath + `/${(this.props.questionId - 1).toString()}`),
onClickSubmit: () => history.push(listingPath),
sourceChapter: 2 // TODO dynamic library changing
onClickDone: () => history.push(listingPath),
onClickNext: () => history.push(gradingWorkspacePath + `/${(questionId + 1).toString()}`),
onClickPrevious: () => history.push(gradingWorkspacePath + `/${(questionId - 1).toString()}`),
sourceChapter: this.props.grading![questionId].question.library.chapter
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/academy/grading/gradingShape.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AssessmentCategory, IQuestion, Library, MCQChoice } from '../../assessment/assessmentShape'
import { AssessmentCategory, IQuestion, MCQChoice } from '../../assessment/assessmentShape'

/**
* Information on a Grading, for a particular student submission
Expand Down Expand Up @@ -44,7 +44,6 @@ export type GradingQuestion = {
interface IAnsweredQuestion extends IQuestion {
solution?: number
answer?: string | number
library?: Library
solutionTemplate?: string
choices?: MCQChoice[]
}
6 changes: 3 additions & 3 deletions src/components/assessment/AssessmentWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,17 @@ class AssessmentWorkspace extends React.Component<
handleReplEval: this.props.handleReplEval,
handleReplOutputClear: this.props.handleReplOutputClear,
hasChapterSelect: false,
hasDoneButton: questionId === this.props.assessment!.questions.length - 1,
hasNextButton: questionId < this.props.assessment!.questions.length - 1,
hasPreviousButton: questionId > 0,
hasSaveButton: true,
hasShareButton: false,
hasSubmitButton: questionId === this.props.assessment!.questions.length - 1,
isRunning: this.props.isRunning,
onClickDone: () => history.push(listingPath),
onClickNext: () => history.push(assessmentWorkspacePath + `/${(questionId + 1).toString()}`),
onClickPrevious: () =>
history.push(assessmentWorkspacePath + `/${(questionId - 1).toString()}`),
onClickSubmit: () => history.push(listingPath),
sourceChapter: 2 // TODO dynamic library changing
sourceChapter: this.props.assessment!.questions[questionId].library.chapter
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/assessment/assessmentShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export enum AssessmentCategories {
export type AssessmentCategory = keyof typeof AssessmentCategories

export interface IProgrammingQuestion extends IQuestion {
library: Library
solutionTemplate: string
type: 'programming'
}
Expand All @@ -47,6 +46,7 @@ export interface IMCQQuestion extends IQuestion {
export interface IQuestion {
content: string
id: number
library: Library
type: QuestionType
}

Expand Down
20 changes: 10 additions & 10 deletions src/components/workspace/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { sourceChapters } from '../../reducers/states'
import { controlButton } from '../commons'

export type ControlBarProps = {
hasChapterSelect?: boolean
hasNextButton?: boolean
hasPreviousButton?: boolean
hasSaveButton?: boolean
hasShareButton?: boolean
hasSubmitButton?: boolean
hasChapterSelect: boolean
hasNextButton: boolean
hasPreviousButton: boolean
hasSaveButton: boolean
hasShareButton: boolean
hasDoneButton: boolean
isRunning: boolean
queryString?: string
sourceChapter: number
Expand All @@ -26,7 +26,7 @@ export type ControlBarProps = {
onClickNext?(): any
onClickPrevious?(): any
onClickSave?(): any
onClickSubmit?(): any
onClickDone?(): any
}

interface IChapter {
Expand All @@ -41,7 +41,7 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
hasPreviousButton: false,
hasSaveButton: false,
hasShareButton: true,
hasSubmitButton: false,
hasDoneButton: false,
onClickNext: () => {},
onClickPrevious: () => {},
onClickSave: () => {}
Expand Down Expand Up @@ -120,8 +120,8 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
const nextButton = this.props.hasNextButton
? controlButton('Next', IconNames.ARROW_RIGHT, this.props.onClickNext, { iconOnRight: true })
: undefined
const submitButton = this.props.hasSubmitButton
? controlButton('Submit', IconNames.TICK_CIRCLE, this.props.onClickSubmit, {
const submitButton = this.props.hasDoneButton
? controlButton('Done', IconNames.TICK_CIRCLE, this.props.onClickDone, {
iconOnRight: true
})
: undefined
Expand Down
1 change: 1 addition & 0 deletions src/mocks/assessmentAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const mockAssessmentQuestions: Array<IProgrammingQuestion | IMCQQuestion>
}
],
id: 2,
library: mockLibrary,
type: 'mcq'
}
]
Expand Down
1 change: 1 addition & 0 deletions src/mocks/gradingAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const mockGrading: Grading = [
}
],
id: 2,
library: mockLibrary,
type: 'mcq'
},
maximumXP: 100,
Expand Down