Commit 5be891b0 authored by Hidde Leistra's avatar Hidde Leistra

Tidy up premade-feedback branch for merge request

parent b27a6297
......@@ -38,7 +38,12 @@ class Exams extends React.Component {
// keep page and name of problem as widget.problem object
widgets[problem.widget.id] = {
...problem.widget,
problem : problem
problem: {
id: problem.id,
page: problem.page,
name: problem.name,
graded: problem.graded
}
}
})
......@@ -56,7 +61,7 @@ class Exams extends React.Component {
previewing: false
}
}
// This is a rough update for when feedback is edited.
// This is a rough update for when feedback is edited.
newProps.exam.problems.forEach(problem => {
prevState.widgets[problem.widget.id].problem.feedback = problem.feedback
})
......@@ -291,8 +296,6 @@ class Exams extends React.Component {
PanelEdit = (props) => {
const selectedWidgetId = this.state.selectedWidgetId
let selectedWidget = selectedWidgetId && this.state.widgets[selectedWidgetId]
let problem = selectedWidget && selectedWidget.problem
return (
<nav className='panel'>
......@@ -322,9 +325,9 @@ class Exams extends React.Component {
}} />
{this.state.editActive
? <EditPanel problemID={problem.id} feedback={this.state.feedbackToEdit}
? <EditPanel problemID={props.problem.id} feedback={this.state.feedbackToEdit}
goBack={this.backToFeedback} />
: <FeedbackPanel examID={this.props.examID} problem={problem}
: <FeedbackPanel examID={this.props.examID} problem={props.problem}
editFeedback={this.editFeedback} showTooltips={this.state.showTooltips}
grading={false}
/>}
......
......@@ -216,7 +216,7 @@ class Grade extends React.Component {
: <FeedbackPanel examID={exam.id} submissionID={submission.id}
problem={problem} solution={solution} graderID={this.props.graderID}
editFeedback={this.editFeedback} showTooltips={this.state.showTooltips}
grading={true} updateSubmission={() => {
grading updateSubmission={() => {
this.props.updateSubmission(this.state.sIndex)
}
} />
......
......@@ -90,7 +90,7 @@ class FeedbackPanel extends React.Component {
const blockURI = this.props.examID + '/' + this.props.submissionID + '/' + this.props.problem.id
let totalScore = 0
if(this.props.grading) {
if (this.props.grading) {
for (let i = 0; i < this.props.solution.feedback.length; i++) {
const probIndex = this.props.problem.feedback.findIndex(fb => fb.id === this.props.solution.feedback[i])
if (probIndex >= 0) totalScore += this.props.problem.feedback[probIndex].score
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment