/**
  * Assigns a test taker to a delivery
  *
  * @throws \common_Exception
  * @throws \oat\oatbox\service\ServiceNotFoundException
  */
 public function assignTestTakers()
 {
     $deliveryId = $this->getRequestParameter('delivery');
     $testTakers = $this->getRequestParameter('testtaker');
     $testCenterId = $this->getRequestParameter('testCenter');
     if (!is_array($testTakers)) {
         $testTakers = array($testTakers);
     }
     try {
         $added = DeliveryHelper::assignTestTakers($testTakers, $deliveryId, $testCenterId);
         $notAdded = array_diff($testTakers, $added);
         $this->returnJson(array('success' => !count($notAdded), 'processed' => $added, 'unprocessed' => $notAdded));
     } catch (ServiceNotFoundException $e) {
         \common_Logger::w('No delivery service defined for proctoring');
         $this->returnError('Proctoring interface not available');
     }
 }
$i = 0;
$proctorNum = 1;
$ttNum = 1;
$subClass = $testTakerService->createSubClass($testTakerService->getRootClass(), 'jmeter_test_taker_' . $totalTtNum);
while ($i < $totalProctorNum) {
    if ($userService->loginAvailable('Jmeter_proctor_' . $proctorNum)) {
        $tts = array();
        //create sample group
        $testCenter = $testCenterService->createInstance(new \core_kernel_classes_Class($testCenterService::CLASS_URI), 'jmeter_test_center_' . $proctorNum);
        $proctor = $userService->addUser('Jmeter_proctor_' . $proctorNum, 'Jmeter_proctor_' . $proctorNum, new \core_kernel_classes_Resource("http://www.tao.lu/Ontologies/TAOProctor.rdf#ProctorRole"), $userClass);
        $proctor->setPropertyValue(new core_kernel_classes_Property($proctorManagementService::PROPERTY_ASSIGNED_PROCTOR_URI), $testCenter);
        $proctor->setPropertyValue(new core_kernel_classes_Property($proctorManagementService::PROPERTY_ADMINISTRATOR_URI), $testCenter);
        $i++;
        $j = 0;
        while ($j < $ttByProctor) {
            if ($userService->loginAvailable('jmeter_TT_' . $ttNum)) {
                $tt = $testTakerCrudService->createFromArray(array(PROPERTY_USER_LOGIN => 'jmeter_TT_' . $ttNum, PROPERTY_USER_PASSWORD => 'jmeter_TT_' . $ttNum, RDFS_LABEL => 'jmeter_tt' . $ttNum, PROPERTY_USER_FIRSTNAME => 'jmeter_tt_' . $ttNum, PROPERTY_USER_LASTNAME => 'jmeter_tt_' . $ttNum, RDF_TYPE => $subClass));
                $tts[] = $tt->getUri();
                $j++;
            }
            $ttNum++;
        }
        $testCenterService->addTestTaker($tt->getUri(), $testCenter);
        //add delivery to eligible list
        \oat\taoProctoring\model\EligibilityService::singleton()->createEligibility($testCenter, $delivery);
        \oat\taoProctoring\model\EligibilityService::singleton()->setEligibleTestTakers($testCenter, $delivery, $tts);
        //assign tt to delivery
        \oat\taoProctoring\helpers\DeliveryHelper::assignTestTakers($tts, $delivery->getUri(), $testCenter->getUri());
    }
    $proctorNum++;
}