Permalink
Browse files

Fixed answer import error

  • Loading branch information...
mennodekker committed Dec 5, 2017
1 parent 5f58b4b commit e7bc7e1a544e19c264640e6564c67f553765fbbb
Showing with 3 additions and 19 deletions.
  1. +3 −19 classes/Gems/Task/Import/SaveAnswerTask.php
@@ -71,7 +71,7 @@ public function execute($row = null,
// \MUtil_Echo::track($row);
if ($row) {
$answers = $row;
$double = false;
$prevAnswers = false;
$token = null;
$tracker = $this->loader->getTracker();
$userId = $this->loader->getCurrentUser()->getUserId();
@@ -98,23 +98,7 @@ public function execute($row = null,
$token = $tracker->getToken($row['token']);
if ($token->exists && $token->isCompleted() && $token->getReceptionCode()->isSuccess()) {
$currentAnswers = $token->getRawAnswers();
$usedAnswers = array_intersect_key($answers, $currentAnswers);
// \MUtil_Echo::track($currentAnswers, $answers, $usedAnswers);
if ($usedAnswers) {
foreach ($usedAnswers as $name => $value) {
if ((null === $answers[$name]) || ($answers[$name] == $this->targetModel->get($name, 'default'))) {
// There is no value to set, so do not set the value
unset($answers[$name]);
} elseif (! ((null === $value) || ($value == $this->targetModel->get($name, 'default')))) {
// The value was already set
$double = true;
// But no break because of previous unsets
// break;
}
}
}
$prevAnswers = true;
}
}
if (! ($token && $token->exists)) {
@@ -125,7 +109,7 @@ public function execute($row = null,
}
if ($answers) {
if ($double) {
if ($prevAnswers) {
if (\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_OVERWRITE == $tokenCompletion) {
$code = $this->util->getReceptionCode('redo');

0 comments on commit e7bc7e1

Please sign in to comment.