"use strict";

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

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

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

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

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

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

function getItemAnalyses(quizId) {
  var url = "/api/quizzes/".concat(quizId, "/stats/item_analyses/");
  return function (dispatch, getState) {
    var DynamoFetcher = (0, _withDynamoPagination.default)(_Fetcher.default);
    var dynamoFetcherGet = new DynamoFetcher();
    return dynamoFetcherGet.paginatedGet(url).then(function (response) {
      dispatch([(0, _callHandlers.handleItemAnalysesResponse)(response), (0, _quizzes.associateItemAnalyses)(quizId, response)]);
    });
  };
}