'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _immutable = require('immutable');

var _reduxRecord = require('./reduxRecord');

var _reduxRecord2 = _interopRequireDefault(_reduxRecord);

var _constants = require('../../constants');

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

var QuizSessionResult = function (_ReduxRecord) {
  (0, _inherits3.default)(QuizSessionResult, _ReduxRecord);

  function QuizSessionResult() {
    (0, _classCallCheck3.default)(this, QuizSessionResult);
    return (0, _possibleConstructorReturn3.default)(this, (QuizSessionResult.__proto__ || Object.getPrototypeOf(QuizSessionResult)).apply(this, arguments));
  }

  (0, _createClass3.default)(QuizSessionResult, [{
    key: 'isGraded',
    value: function isGraded() {
      return this.status === 'graded';
    }
  }, {
    key: 'isLoaded',
    value: function isLoaded() {
      return this.id !== '0';
    }
  }, {
    key: 'getSessionItemResults',
    value: function getSessionItemResults() {
      return this.getRelationList('sessionItemResults', 'findSessionItemResult');
    }
  }, {
    key: 'getWorkingInstance',
    value: function getWorkingInstance() {
      var mods = this.getState().getIn(['modifications', 'quizSessionResults', this.id]);
      return QuizSessionResult.create(this.merge(mods));
    }
  }, {
    key: 'hasModifications',
    value: function hasModifications() {
      return !(0, _immutable.is)(this.getWorkingInstance(), this);
    }
  }], [{
    key: 'fetcherTag',
    value: function fetcherTag(id) {
      return _constants.QUIZ_SESSION_RESULT_FETCH_CALL + '_' + id;
    }
  }]);
  return QuizSessionResult;
}((0, _reduxRecord2.default)({
  createdAt: null,
  fudgePoints: null,
  gradingMethod: null,
  id: '0',
  percentage: null,
  pointsPossible: null,
  quizSession: null,
  score: null,
  sessionItemResults: (0, _immutable.List)(),
  status: null,
  updatedAt: null
}));

exports.default = QuizSessionResult;