'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _immutable = require('immutable');

var _presenter = require('./presenter');

var _presenter2 = _interopRequireDefault(_presenter);

var _makeEditable = require('../../../../../common/components/shared/functionality/makeEditable');

var _makeEditable2 = _interopRequireDefault(_makeEditable);

var _reactRedux = require('../../../../../common/react-redux');

var _regrading = require('../../../../../common/actions/regrading');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// for Redux caching
var emptyMap = (0, _immutable.Map)();

function mapStateToProps(state, props) {
  var workingSessionItemResult = props.sessionItemResult.getWorkingInstance();
  var modifications = state.getIn(['modifications', 'sessionItemResults', props.sessionItem.id], emptyMap);

  return {
    activeQuizSessionId: state.getIn(['quizSessions', 'activeQuizSessionId']),
    appContainer: state.getIn(['ui', 'appContainer']),
    itemResultsModifications: modifications,
    graderFeedback: workingSessionItemResult.getIn(['feedback', 'graderFeedback'], emptyMap)
  };
}

var dispatchableActions = {
  toggleRegradingEditMode: _regrading.toggleRegradingEditMode
};

exports.default = (0, _makeEditable2.default)((0, _reactRedux.connect)(mapStateToProps, dispatchableActions)(_presenter2.default));