Beispiel #1
0
    turk_easyExpireHit($hitId);
    sleep(0.25);
    //Give the HIT a moment to expire
    $mt = turk_easyDispose($hitId);
    sleep(0.25);
    //Give the HIT a moment to dispose
}
$sql = "SELECT * from hits WHERE task = :task";
$sth = $dbh->prepare($sql);
$sth->execute(array(':task' => $_REQUEST['task']));
$hits = $sth->fetchAll();
foreach ($hits as $hit) {
    $hitId = $hit['hit_Id'];
    $hitInfo = turk50_getHit($hitId);
    if (property_exists($hitInfo->HIT, "HITStatus")) {
        expireHit($hitId);
        // sleep(.25);
        if ($hitInfo->HIT->HITStatus == "Disposed") {
            // expireHit($hitId);
            $sql = "DELETE FROM hits WHERE hit_Id = :hit_Id";
            $sth = $dbh->prepare($sql);
            $sth->execute(array(':hit_Id' => $hitId));
        } else {
            if ($hitInfo->HIT->HITStatus == "Reviewable") {
                $sql = "UPDATE hits SET assignable = 0 WHERE hit_Id = :hit_Id";
                $sth = $dbh->prepare($sql);
                $sth->execute(array(':hit_Id' => $hitId));
            }
        }
    }
    // else{
Beispiel #2
0
function removeOldHITs()
{
    global $dbh, $debug, $SANDBOX;
    // Get target number of workers
    // Delete old HITs and get num assignable
    // delete hits with no HITId
    $sql = "DELETE FROM hits WHERE task = :task AND hit_Id is null";
    $sth = $dbh->prepare($sql);
    $sth->execute(array(':task' => $_REQUEST['task']));
    $sql = "SELECT * from hits WHERE task = :task AND sandbox = :sandbox";
    $sth = $dbh->prepare($sql);
    $sth->execute(array(':task' => $_REQUEST['task'], ':sandbox' => $SANDBOX));
    $hits = $sth->fetchAll();
    foreach ($hits as $hit) {
        $hitId = $hit['hit_Id'];
        $hitInfo = turk50_getHit($hitId);
        // fwrite($debug,  $hitId . " " . $hitInfo->HIT->Request->IsValid . " IsValid?\n");
        // fwrite($debug,  $hitId . " " . $hitInfo->HIT->HITStatus . " HITStatus?\n");
        if ($hitInfo->HIT->Request->IsValid == "False") {
            $sql = "DELETE FROM hits WHERE hit_Id = :hit_Id";
            $sth = $dbh->prepare($sql);
            $sth->execute(array(':hit_Id' => $hitId));
        } else {
            if (property_exists($hitInfo->HIT, "HITStatus")) {
                if ($hitInfo->HIT->HITStatus == "Disposed") {
                    $sql = "DELETE FROM hits WHERE hit_Id = :hit_Id";
                    $sth = $dbh->prepare($sql);
                    $sth->execute(array(':hit_Id' => $hitId));
                } else {
                    if ($hitInfo->HIT->HITStatus == "Reviewable") {
                        $sql = "UPDATE hits SET assignable = 0 WHERE hit_Id = :hit_Id";
                        $sth = $dbh->prepare($sql);
                        $sth->execute(array(':hit_Id' => $hitId));
                    } else {
                        $expired = expireHit($hitId);
                        if ($expired != "error with disposal") {
                            $sql = "DELETE FROM hits WHERE hit_Id = :hit_Id";
                            $sth = $dbh->prepare($sql);
                            $sth->execute(array(':hit_Id' => $hitId));
                        }
                    }
                }
            }
        }
        sleep(1);
        //Don't overload mturk with getHit
    }
}