Skip to content

Show programming solution #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 29, 2018
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
6 changes: 6 additions & 0 deletions src/components/academy/grading/GradingEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type DispatchProps = {

export type OwnProps = {
comment: string
solution: number | string | null
questionId: number
submissionId: number
initialGrade: number
Expand Down Expand Up @@ -91,6 +92,11 @@ class GradingEditor extends React.Component<GradingEditorProps, State> {
message={'You have changes that may not be saved. Are you sure you want to leave?'}
/>
) : null}
{this.props.solution !== null ? (
<div className="grading-editor-solution">
<pre> {this.props.solution.toString()} </pre>
</div>
) : null}
<div className="grading-editor-input-parent">
<table>
<tbody>
Expand Down
1 change: 1 addition & 0 deletions src/components/academy/grading/GradingWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class GradingWorkspace extends React.Component<GradingWorkspaceProps> {
body: (
<GradingEditor
comment={props.grading![questionId].grade.comment}
solution={props.grading![questionId].question.solution}
questionId={props.grading![questionId].question.id}
submissionId={props.submissionId}
initialGrade={props.grading![questionId].grade.grade}
Expand Down
4 changes: 3 additions & 1 deletion src/components/academy/grading/gradingShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ export type GradingQuestion = {
*
* @property comment This property is already present in GradingQuestion,
* and thus does not need to be used here, and is set to null
* @property solution this can be either the answer to the MCQ, the solution to
* a programming question, or null.
*/
interface IAnsweredQuestion extends IQuestion {
comment: null
solution?: number
solution: number | string | null
answer: string | number | null
solutionTemplate?: string
choices?: MCQChoice[]
Expand Down
2 changes: 2 additions & 0 deletions src/mocks/gradingAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Hello and welcome to this assessment! This is the *0th question*.
id: 0,
library: mockLibrary,
solutionTemplate: '0th question mock solution template',
solution: 'This is how the 0th question is `solved`',
type: 'programming'
},
maxGrade: 1000,
Expand All @@ -105,6 +106,7 @@ Hello and welcome to this assessment! This is the *0th question*.
id: 1,
library: mockLibrary,
solutionTemplate: '1st question mock solution template',
solution: null,
type: 'programming'
},
maxGrade: 200,
Expand Down
6 changes: 5 additions & 1 deletion src/sagas/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ async function getGrading(submissionId: number, tokens: Tokens): Promise<Grading
comment: null,
id: question.id,
library: castLibrary(question.library),
solution: question.answer,
solution: gradingQuestion.solution
? gradingQuestion.solution
: question.solution !== undefined
? question.solution
: null,
solutionTemplate: question.solutionTemplate,
type: question.type as QuestionType
},
Expand Down
7 changes: 7 additions & 0 deletions src/styles/_academy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@
}

.GradingEditor {
.grading-editor-solution {
pre {
white-space: pre-wrap;
word-wrap: break-word;
word-break: break-word;
}
}
.grading-editor-input-parent {
/** Center the text for numeric input and showing grades. */
table {
Expand Down