Пример #1
0
function createQualificationRequirement($row)
{
    global $dbh, $SANDBOX;
    $qualsArray = array();
    $percentApproved = (string) $row[0]["percentApproved"];
    // require Worker_PercentAssignmentsApproved >= IntegerValue
    if ($percentApproved != "") {
        $Worker_PercentAssignmentsApproved = array("QualificationTypeId" => "000000000000000000L0", "Comparator" => "GreaterThanOrEqualTo", "IntegerValue" => $percentApproved);
        array_push($qualsArray, $Worker_PercentAssignmentsApproved);
    }
    // require Worker_Locale == Country
    $country = $row[0]["country"];
    if ($country != "" && $country != "All") {
        $Worker_Locale = array("QualificationTypeId" => "00000000000000000071", "Comparator" => "EqualTo", "LocaleValue" => array("Country" => $country));
        array_push($qualsArray, $Worker_Locale);
    }
    if ($_REQUEST['requireUniqueWorkers'] == "true") {
        if ($SANDBOX) {
            $dbCol = "noRepeatQualIdSandbox";
        } else {
            $dbCol = "noRepeatQualIdLive";
        }
        $noRepeatQualId = $row[0][$dbCol];
        if ($noRepeatQualId == null || $noRepeatQualId == "") {
            $qual = turk50_createQualificationType(generateRandomString(), "This qualification is for people who have worked for me on this task before.", "Worked for me before", $SANDBOX);
            // print_r($qual);
            $noRepeatQualId = $qual->QualificationType->QualificationTypeId;
            if ($SANDBOX) {
                $sql = "UPDATE retainer set noRepeatQualIdSandbox = :noRepeatQualId WHERE task = :task";
            } else {
                $sql = "UPDATE retainer set noRepeatQualIdLive = :noRepeatQualId WHERE task = :task";
            }
            $sth = $dbh->prepare($sql);
            $sth->execute(array(":task" => $_REQUEST['task'], ":noRepeatQualId" => $noRepeatQualId));
        }
        $Unique_Workers_Qual = array("QualificationTypeId" => (string) $noRepeatQualId, "Comparator" => "DoesNotExist");
        array_push($qualsArray, $Unique_Workers_Qual);
    }
    return $qualsArray;
}
Пример #2
0
         if (strpos($turkSubmitTo, 'workersandbox') !== FALSE) {
             $dbCol = "noRepeatQualIdSandbox";
             $SANDBOX = true;
         } else {
             $dbCol = "noRepeatQualIdLive";
             $SANDBOX = false;
         }
     }
 }
 $sql = "SELECT * FROM retainer WHERE task = :task";
 $sth = $dbh->prepare($sql);
 $sth->execute(array(":task" => $task));
 $result = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT);
 $noRepeatQualId = $result[$dbCol];
 if ($noRepeatQualId == null || $noRepeatQualId == "" || isset($_REQUEST['reset'])) {
     $qual = turk50_createQualificationType(generateRandomString(), "This qualification is for people who have worked for me on this task before.", "Worked for me before", $SANDBOX);
     // print_r($qual);
     $noRepeatQualId = $qual->QualificationType->QualificationTypeId;
     if ($SANDBOX) {
         $sql = "UPDATE retainer set noRepeatQualIdSandbox = :noRepeatQualId WHERE task = :task";
     } else {
         $sql = "UPDATE retainer set noRepeatQualIdLive = :noRepeatQualId WHERE task = :task";
     }
     $sth = $dbh->prepare($sql);
     $sth->execute(array(":task" => $task, ":noRepeatQualId" => $noRepeatQualId));
 }
 if (isset($_REQUEST['assignQualification']) && ($_REQUEST['assignQualification'] = "true")) {
     $mt = turk50_assignQualification($_REQUEST['workerId'], $noRepeatQualId, $SANDBOX);
     echo $mt;
 }
 // echo "here";