From c40fddae031508a94727535431a54077e9c265c7 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 17:29:55 +0800 Subject: [PATCH 01/14] Change ControlBar to show 'Done' --- src/components/workspace/ControlBar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index 2b5fc76b7a..d7466cc7a2 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -13,7 +13,7 @@ export type ControlBarProps = { hasPreviousButton?: boolean hasSaveButton?: boolean hasShareButton?: boolean - hasSubmitButton?: boolean + hasDoneButton?: boolean isRunning: boolean queryString?: string sourceChapter: number @@ -26,7 +26,7 @@ export type ControlBarProps = { onClickNext?(): any onClickPrevious?(): any onClickSave?(): any - onClickSubmit?(): any + onClickDone?(): any } interface IChapter { @@ -120,8 +120,8 @@ class ControlBar extends React.PureComponent { 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 From fb96de16d93644c486cae40aa51f1d299d41490d Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 17:53:19 +0800 Subject: [PATCH 02/14] Change controlBarProps for playground --- src/components/Playground.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index f82ed42f5d..134fe79ab8 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -63,7 +63,7 @@ class Playground extends React.Component { hasChapterSelect: true, hasNextButton: false, hasPreviousButton: false, - hasSubmitButton: false, + hasDoneButton: false, isRunning: this.props.isRunning, queryString: this.props.queryString, sourceChapter: this.props.sourceChapter From d500586066212f6e8e609d4f3409f36758217131 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 17:53:50 +0800 Subject: [PATCH 03/14] Fix prop typo in ControlBar --- src/components/workspace/ControlBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index d7466cc7a2..9e4400d091 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -41,7 +41,7 @@ class ControlBar extends React.PureComponent { hasPreviousButton: false, hasSaveButton: false, hasShareButton: true, - hasSubmitButton: false, + hasDoneButton: false, onClickNext: () => {}, onClickPrevious: () => {}, onClickSave: () => {} From d2d6b8a7720166b251e0e2018221bcd5e86c8066 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 17:54:14 +0800 Subject: [PATCH 04/14] Change controlBarProps for GradingWorkspace --- src/components/academy/grading/GradingWorkspace.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/academy/grading/GradingWorkspace.tsx b/src/components/academy/grading/GradingWorkspace.tsx index 5607897f45..b04f344817 100644 --- a/src/components/academy/grading/GradingWorkspace.tsx +++ b/src/components/academy/grading/GradingWorkspace.tsx @@ -137,13 +137,13 @@ class GradingWorkspace extends React.Component { hasPreviousButton: this.props.questionId > 0, hasSaveButton: false, hasShareButton: false, - hasSubmitButton: this.props.questionId === this.props.grading!.length - 1, + hasDoneButton: 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), + onClickDone: () => history.push(listingPath), sourceChapter: 2 // TODO dynamic library changing } } From 4c305a9a7400272e73fc315d416418ce2695e7c6 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:06:23 +0800 Subject: [PATCH 05/14] Change controlBarProps for AssessmentWorkspace --- src/components/assessment/AssessmentWorkspace.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index d0ecc4adcf..e01cbedc82 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -163,12 +163,12 @@ class AssessmentWorkspace extends React.Component< hasPreviousButton: questionId > 0, hasSaveButton: true, hasShareButton: false, - hasSubmitButton: questionId === this.props.assessment!.questions.length - 1, + hasDoneButton: questionId === this.props.assessment!.questions.length - 1, isRunning: this.props.isRunning, onClickNext: () => history.push(assessmentWorkspacePath + `/${(questionId + 1).toString()}`), onClickPrevious: () => history.push(assessmentWorkspacePath + `/${(questionId - 1).toString()}`), - onClickSubmit: () => history.push(listingPath), + onClickDone: () => history.push(listingPath), sourceChapter: 2 // TODO dynamic library changing } } From a80f9da894e61a52c77c2cd9f34ae19e2c8b1cfa Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 17:58:54 +0800 Subject: [PATCH 06/14] Make control bar's has* properties mandatory --- src/components/workspace/ControlBar.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index 9e4400d091..3956747c5d 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -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 - hasDoneButton?: boolean + hasChapterSelect: boolean + hasNextButton: boolean + hasPreviousButton: boolean + hasSaveButton: boolean + hasShareButton: boolean + hasDoneButton: boolean isRunning: boolean queryString?: string sourceChapter: number From 0317d218a5bec8184b832f5c8270fe9566e412f8 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:00:08 +0800 Subject: [PATCH 07/14] Add mandatory properties to Playground --- src/components/Playground.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index 134fe79ab8..1f75774b9f 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -61,9 +61,11 @@ class Playground extends React.Component { handleReplEval: this.props.handleReplEval, handleReplOutputClear: this.props.handleReplOutputClear, hasChapterSelect: true, + hasDoneButton: false, hasNextButton: false, hasPreviousButton: false, - hasDoneButton: false, + hasSaveButton: false, + hasShareButton: true, isRunning: this.props.isRunning, queryString: this.props.queryString, sourceChapter: this.props.sourceChapter From 2882ad94595237febac856c90db28ecc8755b988 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:01:11 +0800 Subject: [PATCH 08/14] Alphabetisize AssessmentWorkspace props --- src/components/assessment/AssessmentWorkspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index e01cbedc82..8bf13f9b95 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -159,11 +159,11 @@ 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, - hasDoneButton: questionId === this.props.assessment!.questions.length - 1, isRunning: this.props.isRunning, onClickNext: () => history.push(assessmentWorkspacePath + `/${(questionId + 1).toString()}`), onClickPrevious: () => From c88849af0d0b25960e6122b6343eb615b797ed6a Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:02:18 +0800 Subject: [PATCH 09/14] Alphabetisize GradingWorkspace controlbar props and one additional prop for AssessmentWorkspace as well. --- src/components/academy/grading/GradingWorkspace.tsx | 4 ++-- src/components/assessment/AssessmentWorkspace.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/academy/grading/GradingWorkspace.tsx b/src/components/academy/grading/GradingWorkspace.tsx index b04f344817..28d925882a 100644 --- a/src/components/academy/grading/GradingWorkspace.tsx +++ b/src/components/academy/grading/GradingWorkspace.tsx @@ -133,17 +133,17 @@ class GradingWorkspace extends React.Component { handleReplEval: this.props.handleReplEval, handleReplOutputClear: this.props.handleReplOutputClear, hasChapterSelect: false, + hasDoneButton: this.props.questionId === this.props.grading!.length - 1, hasNextButton: this.props.questionId < this.props.grading!.length - 1, hasPreviousButton: this.props.questionId > 0, hasSaveButton: false, hasShareButton: false, - hasDoneButton: this.props.questionId === this.props.grading!.length - 1, isRunning: this.props.isRunning, + onClickDone: () => history.push(listingPath), onClickNext: () => history.push(gradingWorkspacePath + `/${(this.props.questionId + 1).toString()}`), onClickPrevious: () => history.push(gradingWorkspacePath + `/${(this.props.questionId - 1).toString()}`), - onClickDone: () => history.push(listingPath), sourceChapter: 2 // TODO dynamic library changing } } diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index 8bf13f9b95..de9c64f5a5 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -165,10 +165,10 @@ class AssessmentWorkspace extends React.Component< hasSaveButton: true, hasShareButton: false, isRunning: this.props.isRunning, + onClickDone: () => history.push(listingPath), onClickNext: () => history.push(assessmentWorkspacePath + `/${(questionId + 1).toString()}`), onClickPrevious: () => history.push(assessmentWorkspacePath + `/${(questionId - 1).toString()}`), - onClickDone: () => history.push(listingPath), sourceChapter: 2 // TODO dynamic library changing } } From 727e0f9a2be2c40d0e9f773f4a0c62b61d27a488 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:28:21 +0800 Subject: [PATCH 10/14] Move library definition to question Even MCQ questions need library to use the REPL --- src/components/academy/grading/gradingShape.ts | 3 +-- src/components/assessment/assessmentShape.ts | 2 +- src/mocks/assessmentAPI.ts | 1 + src/mocks/gradingAPI.ts | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/academy/grading/gradingShape.ts b/src/components/academy/grading/gradingShape.ts index 5d127abd94..97c64917e8 100644 --- a/src/components/academy/grading/gradingShape.ts +++ b/src/components/academy/grading/gradingShape.ts @@ -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 @@ -44,7 +44,6 @@ export type GradingQuestion = { interface IAnsweredQuestion extends IQuestion { solution?: number answer?: string | number - library?: Library solutionTemplate?: string choices?: MCQChoice[] } diff --git a/src/components/assessment/assessmentShape.ts b/src/components/assessment/assessmentShape.ts index 3ff33c1c3f..301d5a703f 100644 --- a/src/components/assessment/assessmentShape.ts +++ b/src/components/assessment/assessmentShape.ts @@ -34,7 +34,6 @@ export enum AssessmentCategories { export type AssessmentCategory = keyof typeof AssessmentCategories export interface IProgrammingQuestion extends IQuestion { - library: Library solutionTemplate: string type: 'programming' } @@ -47,6 +46,7 @@ export interface IMCQQuestion extends IQuestion { export interface IQuestion { content: string id: number + library: Library type: QuestionType } diff --git a/src/mocks/assessmentAPI.ts b/src/mocks/assessmentAPI.ts index 26570f0a14..b67b2a6ce1 100644 --- a/src/mocks/assessmentAPI.ts +++ b/src/mocks/assessmentAPI.ts @@ -117,6 +117,7 @@ export const mockAssessmentQuestions: Array } ], id: 2, + library: mockLibrary, type: 'mcq' } ] diff --git a/src/mocks/gradingAPI.ts b/src/mocks/gradingAPI.ts index 7b60e31895..4038899587 100644 --- a/src/mocks/gradingAPI.ts +++ b/src/mocks/gradingAPI.ts @@ -111,6 +111,7 @@ const mockGrading: Grading = [ } ], id: 2, + library: mockLibrary, type: 'mcq' }, maximumXP: 100, From 0152dd7739d930deca0fe1ae92c93d07e6a95888 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:32:00 +0800 Subject: [PATCH 11/14] Pass sourceChapter as a prop for AssessmentWorkspace --- src/components/assessment/AssessmentWorkspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index de9c64f5a5..4369779314 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -169,7 +169,7 @@ class AssessmentWorkspace extends React.Component< onClickNext: () => history.push(assessmentWorkspacePath + `/${(questionId + 1).toString()}`), onClickPrevious: () => history.push(assessmentWorkspacePath + `/${(questionId - 1).toString()}`), - sourceChapter: 2 // TODO dynamic library changing + sourceChapter: this.props.assessment!.questions[questionId].library.chapter } } } From 23e10cf11444d04cc68089f8875dc2a8a21b7b8a Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:38:22 +0800 Subject: [PATCH 12/14] Add make GradingWorkspace pass in chapter prop --- src/components/academy/grading/GradingWorkspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/academy/grading/GradingWorkspace.tsx b/src/components/academy/grading/GradingWorkspace.tsx index 28d925882a..7abfa1c83d 100644 --- a/src/components/academy/grading/GradingWorkspace.tsx +++ b/src/components/academy/grading/GradingWorkspace.tsx @@ -144,7 +144,7 @@ class GradingWorkspace extends React.Component { history.push(gradingWorkspacePath + `/${(this.props.questionId + 1).toString()}`), onClickPrevious: () => history.push(gradingWorkspacePath + `/${(this.props.questionId - 1).toString()}`), - sourceChapter: 2 // TODO dynamic library changing + sourceChapter: this.props.grading![this.props.questionId].question.library.chapter } } } From 47b8b94be9aa3996d1c44db02c74b3a98a0d2713 Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:45:26 +0800 Subject: [PATCH 13/14] Fix questionId overflow for GradingWorkspace --- .../academy/grading/GradingWorkspace.tsx | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/components/academy/grading/GradingWorkspace.tsx b/src/components/academy/grading/GradingWorkspace.tsx index 7abfa1c83d..88a06482e5 100644 --- a/src/components/academy/grading/GradingWorkspace.tsx +++ b/src/components/academy/grading/GradingWorkspace.tsx @@ -64,10 +64,15 @@ class GradingWorkspace extends React.Component { ) } + /* 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 ? { @@ -84,7 +89,7 @@ class GradingWorkspace extends React.Component { 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, @@ -100,29 +105,29 @@ class GradingWorkspace extends React.Component { } /** 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: + body: }, { - label: `Task ${props.questionId}`, + label: `Task ${questionId}`, icon: IconNames.NINJA, - body: {props.grading![props.questionId].question.content} + body: {props.grading![questionId].question.content} } ] }) /** 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}` @@ -133,18 +138,18 @@ class GradingWorkspace extends React.Component { handleReplEval: this.props.handleReplEval, handleReplOutputClear: this.props.handleReplOutputClear, hasChapterSelect: false, - hasDoneButton: this.props.questionId === this.props.grading!.length - 1, - 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, isRunning: this.props.isRunning, onClickDone: () => history.push(listingPath), onClickNext: () => - history.push(gradingWorkspacePath + `/${(this.props.questionId + 1).toString()}`), + history.push(gradingWorkspacePath + `/${(questionId + 1).toString()}`), onClickPrevious: () => - history.push(gradingWorkspacePath + `/${(this.props.questionId - 1).toString()}`), - sourceChapter: this.props.grading![this.props.questionId].question.library.chapter + history.push(gradingWorkspacePath + `/${(questionId - 1).toString()}`), + sourceChapter: this.props.grading![questionId].question.library.chapter } } } From 191f321a6e9180774fff70ac2d9a35ba24bca23b Mon Sep 17 00:00:00 2001 From: remo5000 Date: Fri, 6 Jul 2018 18:46:23 +0800 Subject: [PATCH 14/14] Format GradingWorkspace --- src/components/academy/grading/GradingWorkspace.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/academy/grading/GradingWorkspace.tsx b/src/components/academy/grading/GradingWorkspace.tsx index 88a06482e5..99edcd0b08 100644 --- a/src/components/academy/grading/GradingWorkspace.tsx +++ b/src/components/academy/grading/GradingWorkspace.tsx @@ -106,7 +106,8 @@ class GradingWorkspace extends React.Component { /** Pre-condition: Grading has been loaded */ private sideContentProps: (p: GradingWorkspaceProps, q: number) => SideContentProps = ( - props: GradingWorkspaceProps, questionId: number + props: GradingWorkspaceProps, + questionId: number ) => ({ activeTab: props.activeTab, handleChangeActiveTab: props.handleChangeActiveTab, @@ -127,7 +128,8 @@ class GradingWorkspace extends React.Component { /** Pre-condition: Grading has been loaded */ private controlBarProps: (p: GradingWorkspaceProps, q: number) => ControlBarProps = ( - props: GradingWorkspaceProps, questionId: number + props: GradingWorkspaceProps, + questionId: number ) => { const listingPath = `/academy/grading` const gradingWorkspacePath = listingPath + `/${this.props.submissionId}` @@ -145,10 +147,8 @@ class GradingWorkspace extends React.Component { hasShareButton: false, isRunning: this.props.isRunning, onClickDone: () => history.push(listingPath), - onClickNext: () => - history.push(gradingWorkspacePath + `/${(questionId + 1).toString()}`), - onClickPrevious: () => - history.push(gradingWorkspacePath + `/${(questionId - 1).toString()}`), + onClickNext: () => history.push(gradingWorkspacePath + `/${(questionId + 1).toString()}`), + onClickPrevious: () => history.push(gradingWorkspacePath + `/${(questionId - 1).toString()}`), sourceChapter: this.props.grading![questionId].question.library.chapter } }