"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _immutable = require("immutable");

var _reduxRecord = _interopRequireDefault(require("./reduxRecord"));

var _constants = require("@instructure/quiz-common/lib/constants");

var QuizSessionResult =
/*#__PURE__*/
function (_ReduxRecord) {
  (0, _inherits2.default)(QuizSessionResult, _ReduxRecord);

  function QuizSessionResult() {
    (0, _classCallCheck2.default)(this, QuizSessionResult);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(QuizSessionResult).apply(this, arguments));
  }

  (0, _createClass2.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 "".concat(_constants.QUIZ_SESSION_RESULT_FETCH_CALL, "_").concat(id);
    }
  }]);
  return QuizSessionResult;
}((0, _reduxRecord.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;