/** * Get test centers a test-taker is assigned to * * @access public * @param User $user * @return array resources of testcenter */ public function getTestCentersByTestTaker(User $user) { $testcenters = $user->getPropertyValues(self::PROPERTY_MEMBERS_URI); array_walk($testcenters, function (&$testcenter) { $testcenter = new core_kernel_classes_Resource($testcenter); }); return $testcenters; }
/** * Get user email address. * @param User $user * @return string * @throws Exception if email address is not valid */ public function getUserMail(User $user) { $userMail = current($user->getPropertyValues(PROPERTY_USER_MAIL)); if (!$userMail || !filter_var($userMail, FILTER_VALIDATE_EMAIL)) { throw new Exception('User email is not valid.'); } return $userMail; }
/** * get the groups of a user * * @access public * @author Joel Bout, <*****@*****.**> * @param string userUri * @return array resources of group */ public function getGroups(User $user) { $groups = $user->getPropertyValues(self::PROPERTY_MEMBERS_URI); array_walk($groups, function (&$group) { $group = new core_kernel_classes_Resource($group); }); return $groups; }
/** * Get test centers a test-taker is assigned to * * @access public * @param User $user * @return array resources of testcenter */ public function getTestCentersByTestTaker(User $user) { return $this->mergeActualResources($user->getPropertyValues(self::PROPERTY_MEMBERS_URI)); }
/** * Gets the value of a string property from a user * @param User $user * @param string $property * @return string */ public static function getUserStringProp(User $user, $property) { $value = $user->getPropertyValues($property); return empty($value) ? '' : current($value); }
/** * Gets the value of a string property from a user * @param User $user * @param string $property * @return mixed|string */ private function getUserStringProp($user, $property) { $value = $user->getPropertyValues($property); return empty($value) ? '' : current($value); }
/** * Set the initial outcomes defined in the rdf outcome map configuration file * * @param AssessmentTestSession $session * @param \oat\oatbox\user\User $testTaker * @throws common_exception_Error * @throws common_ext_ExtensionException */ public static function setInitialOutcomes(AssessmentTestSession $session, \oat\oatbox\user\User $testTaker) { $rdfOutcomeMap = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('rdfOutcomeMap'); if (is_array($rdfOutcomeMap)) { foreach ($rdfOutcomeMap as $outcomeId => $rdfPropUri) { //set outcome value $values = $testTaker->getPropertyValues($rdfPropUri); $outcome = $session->getVariable($outcomeId); if (!is_null($outcome) && count($values)) { $outcome->setValue(new QtiString($values[0])); } } } }