Skip to content
Snippets Groups Projects
Commit 01398bc6 authored by Bereczki Sandor's avatar Bereczki Sandor
Browse files

Now you can modify the correction of solutions

parent 110768c3
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ import { GET_TASKS,
ADD_DOCUMENT,
GET_DOCUMENTS,
CORRECT_SOLUTION,
SELECT_SOLUTION,
CHECK } from './types';
export const getTasks = () => (
......@@ -262,8 +263,17 @@ export const correctSolution = (id, corrected, accepted, note) => (
}
);
export const check = () => (
export const check = name => (
(dispatch) => {
dispatch({ type: CHECK });
dispatch({ type: CHECK, target: name });
}
);
export const selectSolution = solution => (
(dispatch) => {
dispatch({
type: SELECT_SOLUTION,
payload: solution,
});
}
);
......@@ -25,6 +25,7 @@ export const ADD_SOLUTION = 'add_solution';
export const ADD_DOCUMENT = 'add_document';
export const GET_DOCUMENTS = 'get_documents';
export const CORRECT_SOLUTION = 'correct_solution';
export const SELECT_SOLUTION = 'select_solution';
export const CHECK = 'check';
export const GET_EVENTS = 'get_events';
......
......@@ -6,7 +6,8 @@ import { correctSolution,
check,
clearWrite,
getSolutions,
getDocuments } from '../../actions/homework';
getDocuments,
selectSolution } from '../../actions/homework';
class CorrectSolutionForm extends Component {
constructor(props) {
......@@ -34,18 +35,23 @@ class CorrectSolutionForm extends Component {
} else {
fileLink = null;
}
const { note } = this.props.correction;
const {
corrected,
accepted,
note,
} = this.props.correction;
return (
<Modal
open={this.state.showModal}
trigger={
<Button
inverted
color='orange'
color={this.props.color}
style={{ marginRight: '1.5em', marginTop: '1.5em' }}
onClick={() => { this.setState({ showModal: true }); }}
onClick={() => {
this.setState({ showModal: true });
this.props.selectSolution(relevantSolution);
}}
>
{studentFullName}
</Button>
......@@ -65,13 +71,36 @@ class CorrectSolutionForm extends Component {
{fileLink === null ?
<p>Nincs fájl.</p> :
<a href={fileLink}>Fájl letöltése</a>}
<Header as='h5'>Elfogadás/Elutasítás:</Header>
<Button color={this.props.correction.accepted ? 'green' : 'red'} onClick={() => this.props.check()}>
<Header as='h5'>Kijavítás állapotának változtatása:</Header>
<Button
color='orange'
inverted={corrected}
onClick={() => this.props.check('corrected')}
>
<Checkbox
label='Nincs kijavítva'
checked={!corrected}
/>
</Button>
<Header as='h5'>Elfogadás/elutasítás:</Header>
<Button
color='green'
inverted={!accepted}
onClick={() => this.props.check('accepted')}
>
<Checkbox
label='Elfogadható'
checked={accepted}
/>
</Button>
<Button
color='red'
inverted={accepted}
onClick={() => this.props.check('accepted')}
>
<Checkbox
label={this.props.correction.accepted
? 'Elfogadható'
: 'Nem elfogadható'}
checked={this.props.correction.accepted}
label='Nem elfogadható'
checked={!accepted}
/>
</Button>
<Header as='h5'>A feladat megoldásának szöveges értékelése:</Header>
......@@ -102,9 +131,9 @@ class CorrectSolutionForm extends Component {
onClick={() => {
this.props.correctSolution(
relevantSolution.id,
true,
this.props.correction.accepted,
this.props.correction.note,
corrected,
accepted,
note,
);
this.setState({ showModal: false });
this.props.clearWrite();
......@@ -127,4 +156,5 @@ export default connect(mapStateToProps, {
clearWrite,
getSolutions,
getDocuments,
selectSolution,
})(CorrectSolutionForm);
......@@ -83,6 +83,7 @@ class SolutionDetailsForm extends Component {
waitForCorrectionStudents.map(student => (
<CorrectSolutionForm
key={Math.random()}
color='orange'
studentName={student.nick}
studentFullName={student.full_name}
studentId={student.id}
......@@ -92,19 +93,35 @@ class SolutionDetailsForm extends Component {
))
}
<Divider />
<Header as='h3'>A megoldás nem elfogadható:</Header>
<Header as='h3'>A megoldás nem elfogadható (A névre kattintva módosítható a javítás):</Header>
{noAcceptStudents.length === 0 ?
emptyMessage(emptyStudentText) :
noAcceptStudents.map(student => (
<Button key={Math.random()} color='red' style={{ marginRight: '1.5em', marginTop: '1.5em' }}>{student.full_name}</Button>
<CorrectSolutionForm
key={Math.random()}
color='red'
studentName={student.nick}
studentFullName={student.full_name}
studentId={student.id}
taskTitle={this.props.tasktitle}
taskSolutions={taskSolutions}
/>
))
}
<Divider />
<Header as='h3'>Elfogadva:</Header>
<Header as='h3'>Elfogadva (A névre kattintva módosítható a javítás):</Header>
{acceptedStudents.length === 0 ?
emptyMessage(emptyStudentText) :
acceptedStudents.map(student => (
<Button key={Math.random()} color='green' style={{ marginRight: '1.5em', marginTop: '1.5em' }}>{student.full_name}</Button>
<CorrectSolutionForm
key={Math.random()}
color='green'
studentName={student.nick}
studentFullName={student.full_name}
studentId={student.id}
taskTitle={this.props.tasktitle}
taskSolutions={taskSolutions}
/>
))
}
</Modal.Content>
......
import { WRITE_SOLUTION, CHECK, CLEAR_WRITE } from '../actions/types';
import { WRITE_SOLUTION, CHECK, CLEAR_WRITE, SELECT_SOLUTION } from '../actions/types';
const INITIAL_STATE = {
accepted: false,
corrected: false,
note: '',
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case SELECT_SOLUTION:
return {
corrected: action.payload.corrected,
accepted: action.payload.accepted,
note: action.payload.note,
};
case WRITE_SOLUTION:
return { ...state, [action.target]: action.payload };
case CHECK:
return { ...state, accepted: !state.accepted };
return {
...state,
[action.target]: !state[action.target],
};
case CLEAR_WRITE:
return INITIAL_STATE;
default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment