<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import ProgressPanel from '../../components/ProgressPanel';
import SubmissionEditForm from './SubmissionEditForm';
import SubmissionEditStepForm from './SubmissionEditStepForm';
import SubmissionEditTabForm from './SubmissionEditTabForm';
import {
  fetchSubmission, saveDraft, submit,
  unsubmit, autograde, reset, saveGrade, mark, publish,
} from '../../actions';
import {
  AnswerProp, AssessmentProp, ExplanationProp, GradingProp, PostProp, QuestionProp,
  ReduxFormProp, SubmissionProp, TopicProp,
} from '../../propTypes';
import { DATA_STATES } from '../../constants';

class VisibleSubmissionEditIndex extends Component {
  componentDidMount() {
    const { fetchData, match: { params } } = this.props;
    fetchData(params.submissionId);
  }

  allCorrect() {
    const { explanations, questions } = this.props;
    if (Object.keys(explanations).length !== Object.keys(questions).length) {
      return false;
    }

    const numIncorrect = Object.keys(explanations).filter(qid => explanations[qid] && !explanations[qid].correct).length;
    return numIncorrect === 0;
  }

  handleSubmit() {
    const { form, match: { params }, submitAnswer } = this.props;
    const answers = Object.values(form.values);
    submitAnswer(params.submissionId, answers);
  }

  handleUnsubmit() {
    const { match: { params }, unsubmitAnswer } = this.props;
    unsubmitAnswer(params.submissionId);
  }

  handleSaveDraft() {
    const { form, match: { params }, saveDraftAnswer } = this.props;
    const answers = Object.values(form.values);
    saveDraftAnswer(params.submissionId, answers);
  }

  handleAutograde(answerId) {
    const { form, match: { params }, autogradeAnswer } = this.props;
    const answers = [form.values[answerId]];
    autogradeAnswer(params.submissionId, answers);
  }

  handleSaveGrade() {
    const { match: { params }, grading, saveAnswerGrade } = this.props;
    saveAnswerGrade(params.submissionId, Object.values(grading));

  handleReset(answerId) {
    const { match: { params }, resetAnswer } = this.props;
    resetAnswer(params.submissionId, answerId);
  }

  handleMark() {
    const { match: { params }, grading, markAnswer } = this.props;
    markAnswer(params.submissionId, Object.values(grading));
  }

  handlePublish() {
    const { match: { params }, grading, publishAnswer } = this.props;
    publishAnswer(params.submissionId, Object.values(grading));
  }

  renderProgress() {
    const { submission } = this.props;
    if (submission.canGrade) {
      return <ProgressPanel submission={submission} />;<commit_msg>Fix missing bracket<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import ProgressPanel from '../../components/ProgressPanel';
import SubmissionEditForm from './SubmissionEditForm';
import SubmissionEditStepForm from './SubmissionEditStepForm';
import SubmissionEditTabForm from './SubmissionEditTabForm';
import {
  fetchSubmission, saveDraft, submit,
  unsubmit, autograde, reset, saveGrade, mark, publish,
} from '../../actions';
import {
  AnswerProp, AssessmentProp, ExplanationProp, GradingProp, PostProp, QuestionProp,
  ReduxFormProp, SubmissionProp, TopicProp,
} from '../../propTypes';
import { DATA_STATES } from '../../constants';

class VisibleSubmissionEditIndex extends Component {
  componentDidMount() {
    const { fetchData, match: { params } } = this.props;
    fetchData(params.submissionId);
  }

  allCorrect() {
    const { explanations, questions } = this.props;
    if (Object.keys(explanations).length !== Object.keys(questions).length) {
      return false;
    }

    const numIncorrect = Object.keys(explanations).filter(qid => explanations[qid] && !explanations[qid].correct).length;
    return numIncorrect === 0;
  }

  handleSubmit() {
    const { form, match: { params }, submitAnswer } = this.props;
    const answers = Object.values(form.values);
    submitAnswer(params.submissionId, answers);
  }

  handleUnsubmit() {
    const { match: { params }, unsubmitAnswer } = this.props;
    unsubmitAnswer(params.submissionId);
  }

  handleSaveDraft() {
    const { form, match: { params }, saveDraftAnswer } = this.props;
    const answers = Object.values(form.values);
    saveDraftAnswer(params.submissionId, answers);
  }

  handleAutograde(answerId) {
    const { form, match: { params }, autogradeAnswer } = this.props;
    const answers = [form.values[answerId]];
    autogradeAnswer(params.submissionId, answers);
  }

  handleSaveGrade() {
    const { match: { params }, grading, saveAnswerGrade } = this.props;
    saveAnswerGrade(params.submissionId, Object.values(grading));
  }

  handleReset(answerId) {
    const { match: { params }, resetAnswer } = this.props;
    resetAnswer(params.submissionId, answerId);
  }

  handleMark() {
    const { match: { params }, grading, markAnswer } = this.props;
    markAnswer(params.submissionId, Object.values(grading));
  }

  handlePublish() {
    const { match: { params }, grading, publishAnswer } = this.props;
    publishAnswer(params.submissionId, Object.values(grading));
  }

  renderProgress() {
    const { submission } = this.props;
    if (submission.canGrade) {
      return <ProgressPanel submission={submission} />;
{'fraction_non_alphanumeric': 0.13250555967383246, 'fraction_numerical': 0.00037064492216456633, 'mean_word_length': 4.14, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1569439', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1584, 'n_words': 348}