Skip to content
Snippets Groups Projects

Toggling pregrading and Identifying blank solutions

Open Ghost User requested to merge feature/toggle-pregrading into develop
Compare and Show latest version
8 files
+ 121
151
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 43
1
@@ -47,6 +47,7 @@ class Exams extends React.Component {
page: problem.page,
name: problem.name,
graded: problem.graded,
grading_policy: problem.grading_policy,
feedback: problem.feedback || [],
mc_options: problem.mc_options.map((option) => {
// the database stores the positions of the checkboxes but the front end uses the top-left position
@@ -195,13 +196,40 @@ class Exams extends React.Component {
const problem = changedWidget.problem
if (!problem) return
api.put('problems/' + problem.id + '/name', { name: problem.name })
api.put('problems/' + problem.id, { name: problem.name })
.catch(e => Notification.error('Could not save new problem name: ' + e))
.then(this.setState({
changedWidgetId: null
}))
}
onChangeAutoApproveType (e) {
const selectedWidgetId = this.state.selectedWidgetId
if (!selectedWidgetId) return
const selectedWidget = this.state.widgets[selectedWidgetId]
if (!selectedWidget) return
const problem = selectedWidget.problem
if (!problem) return
const newPolicy = e.target.value
api.put('problems/' + problem.id, { grading_policy: newPolicy })
.catch(e => Notification.error('Could not change grading policy: ' + e))
.then(this.setState(prevState => ({
widgets: update(prevState.widgets, {
[selectedWidgetId]: {
problem: {
grading_policy: {
$set: newPolicy
}
}
}
})
})))
}
    • If you first do catch and then then what you get is that the then callback is also executed if the api call results in an error. If you switch the order and an error occurs in api.put, the then callback does not get executed but the catch does. See for yourself if you want to update the state in case of an error.

Please register or sign in to reply
createNewWidget = (widgetData) => {
this.setState((prevState) => {
return {
@@ -738,6 +766,20 @@ class Exams extends React.Component {
}
</React.Fragment>
)}
{props.problem &&
<React.Fragment>
<div className='panel-block mcq-block'>
<b>Auto-approve</b>
<div className='select is-hovered is-fullwidth'>
<select value={props.problem.grading_policy} onChange={this.onChangeAutoApproveType.bind(this)}>
<option value='0'>Nothing</option>
<option value='1'>Blanks</option>
{props.problem.mc_options.length !== 0 && <option value='2'>One answer/blanks</option>}
</select>
</div>
</div>
</React.Fragment>
}
<div className='panel-block'>
<button
disabled={props.disabledDelete}
Loading