/** * Reset HIT * * @param $contract_id * @param $id * @return bool */ public function resetHIT($contract_id, $task_id) { $contract = $this->contract->find($contract_id); try { $task = $this->task->getTask($contract_id, $task_id); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['Contract id' => $contract_id, 'Task' => $task_id]); return false; } try { $this->turk->deleteHIT($task->hit_id); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['Contract id' => $contract_id, 'hit id' => $task->hit_id, 'Task' => $task_id]); return false; } $title = sprintf('%s page-%s', $contract->title, $task->page_no); $url = $this->task_url . $task->pdf_url; $description = 'Some description goes here'; try { $ret = $this->turk->createHIT($title, $description, $url); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['Contract id' => $contract_id, 'Task' => $task_id]); return false; } $update = ['hit_id' => $ret->hit_id, 'assignments' => null, 'status' => 0, 'approved' => 0, 'hit_type_id' => $ret->hit_type_id]; if ($ret) { $this->task->update($task->contract_id, $task->page_no, $update); $this->logger->info('HIT successfully reset', ['Contract id' => $contract_id, 'Task' => $task_id]); $this->logger->mTurkActivity('mturk.log.reset', null, $task->contract_id, $task_id); return true; } $this->logger->error('Error in MTurk', ['Contract id' => $contract_id, 'Task' => $task_id]); return false; }