'use strict';

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

var _Fetcher = require('../../common/util/Fetcher');

var _Fetcher2 = _interopRequireDefault(_Fetcher);

var _callHandlers = require('../../common/api/callHandlers');

var _quizzes = require('../../common/actions/quizzes');

var _withDynamoPagination = require('../../common/util/withDynamoPagination');

var _withDynamoPagination2 = _interopRequireDefault(_withDynamoPagination);

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

function getItemAnalyses(quizId) {
  var url = '/api/quizzes/' + quizId + '/stats/item_analyses/';

  return function (dispatch, getState) {
    var DynamoFetcher = (0, _withDynamoPagination2.default)(_Fetcher2.default);
    var dynamoFetcherGet = new DynamoFetcher();

    return dynamoFetcherGet.paginatedGet(url).then(function (response) {
      dispatch([(0, _callHandlers.handleItemAnalysesResponse)(response), (0, _quizzes.associateItemAnalyses)(quizId, response)]);
    });
  };
}