public static function fromSimpleXML($xml) { $returnval = new MechanicalTurkAssignment(); $returnval->setAssignmentId("" . $xml->AssignmentId); $returnval->setWorkerId("" . $xml->WorkerId); $returnval->setHITId("" . $xml->HITId); $returnval->setAssignmentStatus("" . $xml->AssignmentStatus); $returnval->setAutoApprovalTime("" . $xml->AutoApprovalTime); // TODO: use an actual Date object $returnval->setAcceptTime("" . $xml->AcceptTime); $returnval->setSubmitTime("" . $xml->SubmitTime); $returnval->setApprovalTime("" . $xml->ApprovalTime); $returnval->answer = MechanicalTurkQuestionFormAnswers::fromSimpleXML(simplexml_load_string($xml->Answer)); return $returnval; }
public function GetAssignmentsForHIT($hit_id) { $params = array('HITId' => urlencode($hit_id)); // For full functionality, implement setOption for options $request = new MechanicalTurkRequest("GetAssignmentsForHIT", $params, $this->options['sandbox']); $res = $request->go(); // TODO: implement paging for multiple answers. This method should return an array of assignments. if ($res->OperationRequest->Errors) { $this->print_errors($res->OperationRequest->Errors->Error); return false; } else { if (intval($res->GetAssignmentsForHITResult->NumResults) == 1) { return MechanicalTurkAssignment::fromSimpleXML($res->GetAssignmentsForHITResult->Assignment); } else { return NULL; } } }