query
stringlengths
9
43.3k
document
stringlengths
17
1.17M
metadata
dict
negatives
sequencelengths
0
30
negative_scores
sequencelengths
0
30
document_score
stringlengths
5
10
document_rank
stringclasses
2 values
Get the send response event
public function getEvent() { if (!$this->event instanceof SendResponseEvent) { $this->setEvent(new SendResponseEvent()); } return $this->event; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function send()\n {\n return $this->_response;\n }", "public function responseReceived(Swift_Events_ResponseEvent $e);", "public function respond()\n\t{\n\t\tif (!PhandaStr::startsIn('client-', $this->payload->event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t$channel = $this->channelManager->find($this->connection->getApplication()->getAppId(), $this->payload->channel);\n\t\t$channel->broadcastToOthers($this->connection, $this->payload);\n\t}", "public function responseMsg()\n {\n $file = 'log.txt';\n file_put_contents($file, \"read:\\n\", FILE_APPEND);\n $postStr = $GLOBALS[\"HTTP_RAW_POST_DATA\"];\n \n file_put_contents($file, $postStr, FILE_APPEND);\n // extract post data\n if (! empty($postStr)) {\n /*\n * libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,\n * the best way is to check the validity of xml by yourself\n */\n libxml_disable_entity_loader(true);\n $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);\n \n $RX_TYPE = trim($postObj->MsgType);\n \n switch ($RX_TYPE) {\n case \"event\":\n $resultStr = $this->transmitText($postObj, \"\");\n ;\n echo $resultStr;\n return;\n break;\n }\n \n \n } else {\n echo \"\";\n exit();\n }\n \n \n }", "public function sendResponse()\n {\n }", "public function sendResponse()\n {\n echo $this->getResponseMessage();\n }", "public function responseMsg() {\n $postStr = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents(\"php://input\"); \n //extract post data\n if (!empty($postStr)) {\n $this->logger(\"R \" . $postStr);\n /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,\n the best way is to check the validity of xml by yourself */\n libxml_disable_entity_loader(true);\n $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);\n $RX_TYPE = trim($postObj->MsgType);\n switch ($RX_TYPE) {\n case \"event\":\n $result = $this->receiveEvent($postObj);\n break;\n case \"text\":\n $result = $this->receiveText($postObj);\n break;\n case \"image\":\n $result = $this->receiveImage($postObj);\n break;\n case \"location\":\n $result = $this->receiveLocation($postObj);\n break;\n case \"voice\":\n $result = $this->receiveVoice($postObj);\n break;\n case \"video\":\n $result = $this->receiveVideo($postObj);\n break;\n case \"link\":\n $result = $this->receiveLink($postObj);\n break;\n default:\n $result = \"unknow msg type: \" . $RX_TYPE;\n break;\n }\n $this->logger(\"T \" . $result);\n echo $result;\n } else {\n echo \"\";\n exit;\n }\n }", "public function replyResponse();", "abstract function handleResponseEvent(HttpClientResponseEvent $event);", "public function getEvent()\n {\n return $this->messageEvent;\n }", "public function sendResponseUpdate()\n {\n //\n }", "public function autoEmitResponse()\n {\n return $this->_autoEmitResponse;\n }", "public function responseMsg()\n {\n $postStr = $GLOBALS[\"HTTP_RAW_POST_DATA\"];\n file_get_contents('data.xml',$postStr);\n //extract post data\n if (!empty($postStr)) {\n /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,\n the best way is to check the validity of xml by yourself */\n libxml_disable_entity_loader(true);\n $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);\n switch ($postObj->MsgType) {\n \tcase 'text':\n \t\t$this->doText($postObj);\n \t\tbreak;\n \tcase 'image':\n \t\t$this->doImage($postObj);\n \t\tbreak;\n \tcase 'voice':\n \t\t$this->doVoice($postObj);\n \t\tbreak;\n \tcase 'location':\n \t\t$this->doLocation($postObj);\n \t\tbreak;\n case 'event';\n $this->doEvent($postObj);\n break;\n \tdefault:\n \t\t# code...\n \t\tbreak;\n }\n \n } else {\n echo \"\";\n exit;\n }\n }", "public function onKernelResponse(ResponseEvent $event) {\n $response = $event->getResponse();\n $response->headers->set('X-Form-Test-Response-Event', 'invoked');\n }", "protected function send_response() {\n $this->prepare_response();\n $this->send_headers();\n echo $this->response;\n }", "public function responseMsg()\n {\n $postStr = $GLOBALS[\"HTTP_RAW_POST_DATA\"];\n\n //extract post data\n if (!empty($postStr)){\n\n $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);\n define('FROM_USER_NAME', $postObj->FromUserName);\n define('TO_USER_NAME', $postObj->ToUserName);\n $msg_type = $postObj->MsgType;\n\n switch($msg_type)\n {\n case 'text':\n TextMessage::handle($postObj);\n break;\n case 'image':\n ImageMessage::handle($postObj);\n break;\n case 'voice':\n VoiceMessage::handle($postObj);\n break;\n case 'video':\n VideoMessage::handle($postObj);\n break;\n case 'location':\n LocationMessage::handle($postObj);\n break;\n case 'link':\n LinkMessage::handle($postObj);\n break;\n case 'event':\n EventMessage::handle($postObj);\n break;\n default:\n echo '';\n exit;\n }\n\n }else {\n echo '';\n exit;\n }\n }", "function get_response() {\n\t\treturn $this->response;\n\t}", "public function sendResponse()\n {\n $this->_body[] = \"\\n\";\n $this->outputBody();\n }", "public function sendResponse(Response $response);", "public function events()\n {\n return [\n Response::EVENT_BEFORE_SEND => 'beforeSend',\n ];\n }", "public function setEvent(SendResponseEvent $e)\n {\n $this->event = $e;\n return $this;\n }", "public function send()\n {\n /**\n * @var CaptureResponse\n */\n return parent::send();\n }", "abstract function getResponseMessage();", "function _send_response($serv,$fd,$name,$response) {\n $xml_string = _format_as_xml($name,$response);\n _log(\"response to client {$fd},{$xml_string}\");\n $serv->send($fd,$xml_string);\n return true;\n}", "public function responseMsg()\n {\n $postStr = $GLOBALS[\"HTTP_RAW_POST_DATA\"];\n // file_put_contents(dirname(__FILE__).\"test.xml\", $postStr);\n // $path = dirname(__FILE__).\"\\Controller20160812145838.xml\";\n // $path = str_replace(\"\\\\Controller\\\\\", \"\\\\\", $path);\n // $postStr = file_get_contents($path, true);\n // echo \"$path\";\n //extract post data\n if (!empty($postStr)){\n /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,\n the best way is to check the validity of xml by yourself */\n libxml_disable_entity_loader(true);\n $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);\n $RX_TYPE = trim($postObj->MsgType);\n switch ($RX_TYPE) {\n case 'event':\n $result = $this->receiveEvent($postObj);\n break;\n\n default:\n # code...\n break;\n }\n echo $result;\n\n // $this->updateuser($postObj);\n exit;\n\n\n }else {\n echo \"\";\n exit;\n }\n }", "public function getResponse()\n {\n return $this->di['response'];\n }", "function getResponseMessage ()\n\t{\n\t\treturn $this->responseMessage;\n\t}", "protected function sendResponse() {\n $this->Resp['ET'] = time() - $this->Resp['ET'];\n $DateFormat = 'D d M g:i:s A';\n $this->Resp['ST'] = date($DateFormat, time());\n\n $JsonResp = json_encode($this->Resp);\n\n header('Content-Type: application/json');\n header('Content-Length: ' . strlen($JsonResp));\n /**\n * Important: Tells volley not to cache the response\n */\n if($this->Expiry==null){\n $Expires=time() - 3600;\n } else {\n $Expires=time() + $this->Expiry;\n }\n header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', $Expires));\n echo $JsonResp;\n }", "public function sendResponse() {\n\t\t$this -> sendStatus();\n\t\t$this -> sendHeaders();\n\t\t$this -> sendBody();\n\t}", "public function response() {\n return $this->response;\n }" ]
[ "0.6735958", "0.6588701", "0.65588176", "0.6544782", "0.6518023", "0.64948297", "0.6132916", "0.6075823", "0.60234433", "0.5993843", "0.5896785", "0.5881215", "0.5855359", "0.58174086", "0.5802597", "0.5736978", "0.5711655", "0.56970423", "0.5690485", "0.5689411", "0.5688007", "0.56827253", "0.5675727", "0.56531477", "0.56336784", "0.5625875", "0.5593198", "0.55906266", "0.55804205", "0.55716" ]
0.7057273
0
Register the default event listeners The order in which the response sender are listed here, is by their usage: PhpEnvironmentResponseSender has highest priority, because it's used most often. ConsoleResponseSender and SimpleStreamResponseSender are not used that often, yo they have a lower priority. You can attach your response sender before or after every default response sender implementation. All default response sender implementation have negative priority. You are able to attach listeners without giving a priority and your response sender would be first to try.
protected function attachDefaultListeners() { $events = $this->getEventManager(); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new PhpEnvironmentResponseSender(), -1000); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new ConsoleResponseSender(), -2000); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new SimpleStreamResponseSender(), -3000); $events->attach(SendResponseEvent::EVENT_SEND_RESPONSE, new HttpResponseSender(), -4000); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "protected function attachDefaultListeners()\r\n {\r\n // No event listeners by default\r\n }", "static public function getSubscribedEvents()\n {\n return array(\n KernelEvents::RESPONSE => array('onResponse'),\n );\n }", "private function getDefaultHandlers()\n {\n return array(\n TextProtocol::PREFIX_STATUS => new ResponseStatusHandler(),\n TextProtocol::PREFIX_ERROR => new ResponseErrorHandler(),\n TextProtocol::PREFIX_INTEGER => new ResponseIntegerHandler(),\n TextProtocol::PREFIX_BULK => new ResponseBulkHandler(),\n TextProtocol::PREFIX_MULTI_BULK => new ResponseMultiBulkHandler(),\n );\n }", "public static function registerListeners();", "public static function getSubscribedEvents()\n {\n return array(\n KernelEvents::RESPONSE => array('onPostProcessing', 10)\n );\n }", "public function events()\n {\n return [\n Response::EVENT_BEFORE_SEND => 'beforeSend',\n ];\n }", "final public function listensEverything()\n {\n $this->eventTypes = '*';\n }", "public function registerEventListeners(): void\n {\n foreach ($this->listens() as $event => $listeners) {\n foreach ($listeners as $listener) {\n Event::listen($event, $listener);\n }\n }\n }", "protected function registerEvents()\n {\n $events = $this->app->make(Dispatcher::class);\n\n foreach ($this->events as $event => $listeners) {\n foreach ($listeners as $listener) {\n $events->listen($event, $listener);\n }\n }\n }", "public static function getSubscribedEvents()\n {\n return array(\n 'request.before_send' => array('onBeforeSend', 250),\n );\n }", "protected function setDefaultListeners()\n {\n if (!method_exists($this, 'getUseAcl') || !$this->getUseAcl()) {\n return;\n }\n\n $this->getEventManager()->getSharedManager()->attach(\n 'Zend\\View\\Helper\\Navigation\\AbstractHelper',\n 'isAllowed',\n ['Zend\\View\\Helper\\Navigation\\Listener\\AclListener', 'accept']\n );\n }", "function defineHandlers() {\n\t\tEventsManager::listen ( 'on_daily', 'on_daily' );\n\t\tEventsManager::listen ( 'on_reports_panel', 'on_reports_panel' );\n\t\tEventsManager::listen ( 'on_am_reports_panel', 'on_am_reports_panel' );\n\t\tEventsManager::listen ( 'on_system_permissions', 'on_system_permissions' );\n\t\tEventsManager::listen ( 'on_admin_panel', 'on_admin_panel' );\n\t\tEventsManager::listen ( 'on_main_menu', 'on_main_menu' );\n\t\tEventsManager::listen ( 'on_inline_tabs', 'on_inline_tabs' );\n\t\tEventsManager::listen ( 'on_phone_homescreen', 'on_phone_homescreen' );\n\t\tEventsManager::listen ( 'on_custom_user_permissions', 'on_custom_user_permissions' );\n\t\tEventsManager::listen ( 'on_initial_javascript_assign', 'on_initial_javascript_assign' );\n\t\t// EventsManager::listen ( 'on_wireframe_updates', 'on_wireframe_updates' );\n\t\t// EventsManager::listen ( 'on_shutdown', 'on_shutdown' );\n\t\t\n\t\t//Time Reports Plus\n\t\tEventsManager::listen ( 'on_homescreen_tab_types', 'on_homescreen_tab_types' );\n\t\tEventsManager::listen ( 'on_project_overview_sidebars', 'on_project_overview_sidebars' );\n\t}", "public function attach(EventManagerInterface $events, $priority = 1)\n {\n $this->listeners[] = $events->attach(MvcEvent::EVENT_FINISH, [$this, 'sendResponse'], -10000);\n }", "private function registerSubscribers(): void\n {\n $events = $this->app->make(Dispatcher::class);\n\n $events->subscribe(CallSubscriber::class);\n $events->subscribe(SystemMessageSubscriber::class);\n $events->subscribe(BotSubscriber::class);\n }", "private function listeners()\r\n {\r\n $this->app['director']->addListener('on_page_view', function($event) {\r\n /** @var PageView $listener */\r\n $listener = $this->app->make(PageView::class);\r\n $listener->handle($event);\r\n });\r\n }", "public function register()\n {\n set_error_handler([$this, 'onError'], error_reporting());\n set_exception_handler([$this, 'onException']);\n register_shutdown_function([$this, 'onShutdown']);\n }", "public function getSubscribedEvents()\n\t{\n\t\treturn array(\n\t\t\t'Nette\\Application\\Application::onStartup' => 'setDefaultTarget',\n\t\t);\n\t}", "private function bindEventListenersEvents()\n\t{\n\t\tif ($this->_eventListeners && !$this->_listenerInstances) {\n\t\t\tforeach ($this->_eventListeners as $listener) {\n \n\t\t\t\t$listener = static::getListener($listener);\n\t\t\t\t\n\t\t\t\t$events = $listener->events();\n\t\t\t\t\n\t\t\t\tif ($events) foreach ($events as $name => $handler) {\n\t\t\t\t\tstatic::on($name, is_string($handler) ? [$listener, $handler] : $handler);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public function registerListeners(array $eventListeners = []);", "public static function getSubscribedEvents() {\n $events[KernelEvents::RESPONSE][] = ['addCheckToUrl', -1000];\n return $events;\n }", "protected function registerPersistentEventHandlers()\n {\n // core -> \n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'api.method_not_found', array('Pdfviewer_Listener_Core', 'apiMethodNotFound'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'core.preinit', array('Pdfviewer_Listener_Core', 'preInit'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'core.init', array('Pdfviewer_Listener_Core', 'init'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'core.postinit', array('Pdfviewer_Listener_Core', 'postInit'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'controller.method_not_found', array('Pdfviewer_Listener_Core', 'controllerMethodNotFound'));\n \n // front controller -> Pdfviewer_Listener_FrontController\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'frontcontroller.predispatch', array('Pdfviewer_Listener_FrontController', 'preDispatch'));\n \n // installer -> Pdfviewer_Listener_Installer\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'installer.module.installed', array('Pdfviewer_Listener_Installer', 'moduleInstalled'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'installer.module.upgraded', array('Pdfviewer_Listener_Installer', 'moduleUpgraded'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'installer.module.uninstalled', array('Pdfviewer_Listener_Installer', 'moduleUninstalled'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'installer.subscriberarea.uninstalled', array('Pdfviewer_Listener_Installer', 'subscriberAreaUninstalled'));\n \n // modules -> Pdfviewer_Listener_ModuleDispatch\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module_dispatch.postloadgeneric', array('Pdfviewer_Listener_ModuleDispatch', 'postLoadGeneric'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module_dispatch.preexecute', array('Pdfviewer_Listener_ModuleDispatch', 'preExecute'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module_dispatch.postexecute', array('Pdfviewer_Listener_ModuleDispatch', 'postExecute'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module_dispatch.custom_classname', array('Pdfviewer_Listener_ModuleDispatch', 'customClassname'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module_dispatch.service_links', array('Pdfviewer_Listener_ModuleDispatch', 'serviceLinks'));\n \n // mailer -> Pdfviewer_Listener_Mailer\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.mailer.api.sendmessage', array('Pdfviewer_Listener_Mailer', 'sendMessage'));\n \n // page -> Pdfviewer_Listener_Page\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'pageutil.addvar_filter', array('Pdfviewer_Listener_Page', 'pageutilAddvarFilter'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'system.outputfilter', array('Pdfviewer_Listener_Page', 'systemOutputfilter'));\n \n // errors -> Pdfviewer_Listener_Errors\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'setup.errorreporting', array('Pdfviewer_Listener_Errors', 'setupErrorReporting'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'systemerror', array('Pdfviewer_Listener_Errors', 'systemError'));\n \n // theme -> Pdfviewer_Listener_Theme\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'theme.preinit', array('Pdfviewer_Listener_Theme', 'preInit'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'theme.init', array('Pdfviewer_Listener_Theme', 'init'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'theme.load_config', array('Pdfviewer_Listener_Theme', 'loadConfig'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'theme.prefetch', array('Pdfviewer_Listener_Theme', 'preFetch'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'theme.postfetch', array('Pdfviewer_Listener_Theme', 'postFetch'));\n \n // view -> Pdfviewer_Listener_View\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'view.init', array('Pdfviewer_Listener_View', 'init'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'view.postfetch', array('Pdfviewer_Listener_View', 'postFetch'));\n \n // user login -> Pdfviewer_Listener_UserLogin\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.login.started', array('Pdfviewer_Listener_UserLogin', 'started'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.login.veto', array('Pdfviewer_Listener_UserLogin', 'veto'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.login.succeeded', array('Pdfviewer_Listener_UserLogin', 'succeeded'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.login.failed', array('Pdfviewer_Listener_UserLogin', 'failed'));\n \n // user logout -> Pdfviewer_Listener_UserLogout\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.logout.succeeded', array('Pdfviewer_Listener_UserLogout', 'succeeded'));\n \n // user -> Pdfviewer_Listener_User\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.gettheme', array('Pdfviewer_Listener_User', 'getTheme'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.account.create', array('Pdfviewer_Listener_User', 'create'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.account.update', array('Pdfviewer_Listener_User', 'update'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.account.delete', array('Pdfviewer_Listener_User', 'delete'));\n \n // registration -> Pdfviewer_Listener_UserRegistration\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.registration.started', array('Pdfviewer_Listener_UserRegistration', 'started'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.registration.succeeded', array('Pdfviewer_Listener_UserRegistration', 'succeeded'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.ui.registration.failed', array('Pdfviewer_Listener_UserRegistration', 'failed'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.registration.create', array('Pdfviewer_Listener_UserRegistration', 'create'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.registration.update', array('Pdfviewer_Listener_UserRegistration', 'update'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'user.registration.delete', array('Pdfviewer_Listener_UserRegistration', 'delete'));\n \n // users module -> Pdfviewer_Listener_Users\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.users.config.updated', array('Pdfviewer_Listener_Users', 'configUpdated'));\n \n // group -> Pdfviewer_Listener_Group\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'group.create', array('Pdfviewer_Listener_Group', 'create'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'group.update', array('Pdfviewer_Listener_Group', 'update'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'group.delete', array('Pdfviewer_Listener_Group', 'delete'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'group.adduser', array('Pdfviewer_Listener_Group', 'addUser'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'group.removeuser', array('Pdfviewer_Listener_Group', 'removeUser'));\n \n // special purposes and 3rd party api support -> Pdfviewer_Listener_ThirdParty\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'get.pending_content', array('Pdfviewer_Listener_ThirdParty', 'pendingContentListener'));\n EventUtil::registerPersistentModuleHandler('Pdfviewer', 'module.content.gettypes', array('Pdfviewer_Listener_ThirdParty', 'contentGetTypes'));\n }", "function defineHandlers()\n {\n EventsManager::listen('on_admin_panel', 'on_admin_panel');\n EventsManager::listen('on_object_deleted', 'on_object_deleted');\n EventsManager::listen('on_object_options', 'on_object_options');\n // EventsManager::listen('on_post_install', 'on_post_install');\n }", "protected function installEventListeners()\n {\n $request = Craft::$app->getRequest();\n // Do nothing at all on AJAX requests\n if (!$request->getIsConsoleRequest() && $request->getIsAjax()) {\n return;\n }\n // Install only for non-console site requests\n if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest()) {\n $this->installSiteEventListeners();\n }\n // Install only for non-console Control Panel requests\n if ($request->getIsCpRequest() && !$request->getIsConsoleRequest()) {\n $this->installCpEventListeners();\n }\n }", "private function assignDefaultResponses(): void\n {\n if ($this->operation->hasSuccessResponseCode()) {\n return;\n }\n\n if (strtolower($this->route->getAction()) == 'delete') {\n $this->operation->pushResponse(\n (new Response())\n ->setCode('204')\n ->setDescription('Resource deleted')\n );\n\n return;\n }\n\n $response = (new Response())->setCode('200');\n\n if (in_array($this->operation->getHttpMethod(), ['OPTIONS','HEAD'])) {\n $this->operation->pushResponse($response);\n\n return;\n }\n\n foreach ($this->config->getResponseContentTypes() as $mimeType) {\n $schema = (new Schema())->setDescription('');\n\n if ($mimeType == 'application/xml') {\n $schema->setXml((new Xml())->setName('response'));\n }\n\n $response->pushContent(\n (new Content())->setMimeType($mimeType)->setSchema($schema)\n );\n }\n\n $this->operation->pushResponse($response);\n }", "protected function bindBaseEvent() {\n $this->server->on('start', [$this, 'onStart']);\n $this->server->on('shutdown', [$this, 'onShutdown']);\n $this->server->on('managerStart', [$this, 'onManagerStart']);\n $this->server->on('managerStop', [$this, 'onManagerStop']);\n $this->server->on('workerStart', [$this, 'onWorkerStart']);\n $this->server->on('workerStop', [$this, 'onWorkerStop']);\n }", "public function implementedEvents()\n {\n $this->setupDetectors();\n\n // make sure the listener does absolutely nothing unless\n // the application/vnd.api+json Accept header is used.\n if (!$this->_checkRequestType('jsonapi')) {\n return null;\n }\n\n // accept body data posted with Content-Type `application/vnd.api+json`\n $this->_controller()->RequestHandler->config([\n 'inputTypeMap' => [\n 'jsonapi' => ['json_decode', true]\n ]\n ]);\n\n return [\n 'Crud.beforeHandle' => ['callable' => [$this, 'beforeHandle'], 'priority' => 10],\n 'Crud.setFlash' => ['callable' => [$this, 'setFlash'], 'priority' => 5],\n 'Crud.afterSave' => ['callable' => [$this, 'afterSave'], 'priority' => 90],\n 'Crud.afterDelete' => ['callable' => [$this, 'afterDelete'], 'priority' => 90],\n 'Crud.beforeRender' => ['callable' => [$this, 'respond'], 'priority' => 100],\n 'Crud.beforeRedirect' => ['callable' => [$this, 'beforeRedirect'], 'priority' => 100],\n ];\n }", "function defineHandlers()\n {\n EventsManager::listen('on_main_menu', 'on_main_menu');\n EventsManager::listen('on_project_tabs', 'on_project_tabs');\n EventsManager::listen('on_available_project_tabs', 'on_available_project_tabs');\n EventsManager::listen('on_object_options', 'on_object_options');\n EventsManager::listen('on_quick_add', 'on_quick_add');\n }", "public function onKernelResponse(ResponseEvent $event)\n {\n $this->manager->registerResponseEvent($event->getResponse());\n }", "public function getEventMappings()\n {\n return [\n 'test.listener' => [\n 'method' => 'onListenerTriggered',\n 'priority' => Priority::MEDIUM\n ]\n ];\n }", "protected function bindExtraEvent() {\n $events = $this->conf['swoole']['events'];\n foreach ($events as $event) {\n $this->server->on($event, [$this, 'on' . ucfirst($event)]);\n }\n }" ]
[ "0.64369243", "0.6023557", "0.58893555", "0.57363605", "0.5688798", "0.56529254", "0.5623892", "0.5619542", "0.56027645", "0.5581952", "0.5520178", "0.5484865", "0.54778", "0.5469668", "0.5458157", "0.5427542", "0.54055375", "0.5390669", "0.5368967", "0.53354925", "0.53207177", "0.5314083", "0.5301664", "0.5292596", "0.5266082", "0.5250123", "0.5245749", "0.5225645", "0.5208165", "0.5197344" ]
0.850558
0
Get the boards owned by the user
public function boards() { return $this->morphMany(Board::class, 'owner'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getUsersBoardAction()\n {\n $organization = $this->getUser()->getOrganization();\n\n $users = $this->getUserRepository()->getBoard($organization);\n\n return View::create($users);\n }", "public function getGamesOwned($userId): GameList;", "public final function grabBoards()\n {\n global $db;\n \n $result = $db->query('\n SELECT cat_id, name\n FROM {db_prefix}categories\n ORDER BY cat_order ASC');\n \n $categories = array();\n while ($row = $db->fetch_assoc($result))\n {\n $categories[$row['cat_id']] = array(\n \t'id' => $row['cat_id'],\n 'name' => $row['name'],\n 'boards' => array()\n );\n }\n \n $db->free_result($result);\n \n // And for the boards.\n $result = $db->query('\n SELECT board_id, name, description, num_posts, num_topics, category_id, board_order, permissions, last_post\n FROM {db_prefix}boards\n ORDER BY board_order ASC');\n \n $boards = array();\n while ($row = $db->fetch_assoc($result))\n {\n if (!isset($categories[$row['category_id']]))\n continue;\n \n $this->boards[$row['board_id']] = $row;\n \n // If we don't have permissions to view this board, skip it.\n if (!$this->checkBoardPermissions($row['board_id']))\n {\n \tunset($this->boards[$row['board_id']]);\n \tcontinue;\n }\n\t\t\t\n\t\t\t// If there is a last post, grab it.\n\t\t\t$data = $this->grabBoardLastPost($row['last_post'], $row['board_id']);\n \n $categories[$row['category_id']]['boards'][$row['board_order']] = $row;\n\t\t\t$categories[$row['category_id']]['boards'][$row['board_order']]['last_post'] = $data;\n }\n \n $db->free_result($result);\n \n $this->categories = array_filter($categories);\n \n return true;\n }", "public function getBoards()\n {\n return $this->createQueryBuilder('f')\n ->orderBy('f.id + COALESCE(f.orderOffset, 0)', 'asc')\n ->addOrderBy('f.id', 'asc')\n ->getQuery()\n ->getResult();\n }", "protected function readBoards() {\n\t\t$this->boards = WCF::getCache()->get('board', 'boards');\n\t}", "public function index()\n {\n $boards = Auth::user()->boards;\n\n return view('board.index', compact('boards'));\n }", "public function show($board_id)\n {\n\n // All users except Me\n $sharing = User::where('id' , '!=' , Auth::User()->id)->get();\n // dd($sharing);\n\n // RECUP TABLES DE l'USER\n // $sharingBoard = $sharing->boards();\n // dd($sharingBoard);\n\n $identity = User::where('id' , '==', BoardUser::where('user_id')->get());\n // dd($identity);\n\n // foreach ($sharing as $share ) {\n // // dd($share->boards);\n // }\n\n $bb = Board::with('users.boards')->where('user_id' , '!=' , Auth::User()->id)->get();\n\n\n\n // $myPivot = BoardUser::where('board_id', '==', $board_id)->select('user_id');\n $myPivot = BoardUser::all()->where('board_id', '==', $board_id);\n\n\n\n $myUser = User::all();\n $myBoard = Board::all();\n $myTodo = Todo::where('board_id', $board_id)->get(); // apres le Get >> Collection\n $myTask = Task::all();\n $myComment = Comment::all();\n $myBackground = Background::all();\n\n return view ('todo', [\n \"board_id\" => $board_id,\n \"myBoard\" => $myBoard,\n \"myTodo\" => $myTodo,\n \"myTask\" => $myTask,\n \"myComment\" => $myComment,\n \"myBackground\" => $myBackground,\n \"myUser\"=>$myUser,\n \"sharing\" => $sharing,\n \"myPivot\" => $myPivot,\n ]);\n\n }", "public function index()\n {\n $boards = Board::with(['user'])->get();\n return view('admin.board.index', compact('boards'));\n }", "function GetMessageBoardBy_User($user_login_id)\n\t{\n\t\tglobal $db;\n\t\t$sql= \" SELECT * FROM \".MESSAGE_BOARD_MASTER .\" AS MBM \"\n\t\t\t .\" LEFT JOIN \".project_MASTER.\" AS PM ON MBM.project_id = PM.project_id\"\n\t\t\t .\" WHERE MBM.sender_login_id = '\".$user_login_id.\"' \";\n\t\t$db->query($sql);\n\t}", "public function getUserChannels()\n {\n return $this->hasOne(UserChannelResource::class, ['channel_id' => 'id'])\n ->andWhere(['user_id' => Yii::$app->user->id]);\n }", "public function getUserBoard($username, $boardname) {\n $this->checkBoard($username, $boardname);\n $this->client->auth->setOAuthToken($this->accessToken);\n\n try {\n $parameters[\"fields\"] = \"id,name,url,description,creator,created_at,counts,image\";\n $boardname = strtolower(str_replace(\" \",\"-\",urldecode($boardname)));\n $board = $this->client->boards->get($username.\"/\".$boardname, $parameters);\n } catch(\\Exception $e) {\n throw new ConnectorServiceException('Error getting board settings: ' . $e->getMessage(), $e->getCode());\n }\n\n return $board->toArray();\n }", "public function get_all_board()\n\t{\n\t\treturn $this->db->get($this->table)->result();\n\t}", "function onboard_get()\n {\n $load = 'onboard_id';\n if ($this->get('id') != '') {\n $id = $this->get('id'); \n } elseif ($this->get('cid') != '') {\n $id = $this->get('cid');\n $load = 'crew_id';\n } else {\n $id = $this->get_user()->id;\n }\n \n $cache = Cache::get_instance();\n $onboard = $cache::get('onboard' . $id);\n\n if (!$onboard) { \n $onboard = new Onboard($id); \n $onboard->load($id, $load); \n $cache::save('onboard' . $onboard->onboard_id, $onboard, 1800);\n }\n \n $response = $onboard->getData(); \n \n $this->response($response);\n }", "public function getBoard( $uid ){\n\n $gameBoard = $this->find(\n 'first',\n [\n 'conditions' => [\n 'Game.uid' => $uid\n ],\n 'contain' => [\n 'Board' => [\n 'fields' => [\n 'Board.width',\n 'Board.height'\n ]\n ]\n ]\n ]\n );\n\n return $gameBoard['Board'];\n\n }", "function getRoomUsers($placename, $is_owner = -1) {\n\tglobal $con;\n\t$sql = \"SELECT username, is_owner FROM (\n\t\t\t\tSELECT *\n\t\t\t\tFROM users_rooms\n\t\t\t\tWHERE placename='{$placename}'\";\n\tif($is_owner != -1) {\n\t\t$sql .= \" AND is_owner={$is_owner}\";\n\t}\n\t$sql .=\t\t\" UNION\n\t\t\t\tSELECT username, NULL as placename, NULL as is_owner\n\t\t\t\tFROM users) AS combined\n\t\t\t\tGROUP BY username\"; //TODO: Make this not include kiosk users\n\t$result = mysqli_query($con, $sql);\n\t$rows = array();\n\twhile ($row = mysqli_fetch_assoc($result)) {\n\t\t$rows[] = $row;\n\t}\n\treturn $rows;\n}", "public function getMediaRoomsByUserId()\n {\n /*if ( !OW::getUser()->isAuthenticated() )\n {\n throw new AuthenticateException();\n }*/\n\n $clean = ODE_CLASS_InputFilter::getInstance()->sanitizeInputs($_REQUEST);\n if ($clean == null){\n echo json_encode(array(\"status\" => \"error\", \"massage\" => 'Insane inputs detected'));\n exit;\n }\n\n $user_rooms = array();\n $rooms = COCREATION_BOL_Service::getInstance()->getAllRooms();\n foreach ($rooms as $room) {\n if ((COCREATION_BOL_Service::getInstance()->isMemberJoinedToRoom($clean['userId'], $room->id) ||\n $clean['userId'] == intval($room->ownerId)) && $room->type == \"media\")\n {\n $avatar = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($room->ownerId))[$room->ownerId];\n $room->ownerImage = $avatar['src'];\n $room->ownerName = $avatar['title'];\n $room->sheetId = COCREATION_BOL_Service::getInstance()->getSheetByRoomId($room->id)[0]->url;\n array_push($user_rooms, $room);\n }\n }\n\n header(\"Access-Control-Allow-Origin: *\");\n //echo json_encode(array(\"status\" => \"ok\", \"data\" => $user_rooms));\n echo json_encode($user_rooms);\n exit;\n }", "public function getPlayerBoard(){\n return $this->player_array;\n }", "public function conversationsList()\n {\n /* TODO: Dynamic list in meta */\n $users = static::where('id', '!=', $this->id)->take(8)->get();\n\n return $users->map(function ($user) {\n return [\n 'id' => $user->id,\n 'avatar' => $user->avatarUrl,\n 'name' => $user->name,\n 'description' => $user->description,\n 'unread' => $this->unreadMessagesCount($user),\n 'open' => false,\n 'messages' => [],\n 'loading' => false,\n 'sending' => false\n ];\n });\n }", "function onboards_get()\n\t{\n $search = array();\n $response = FALSE; \n \n $cache = Cache::get_instance();\n $response = $cache::get('onboards' . serialize($this->_args));\n\n if (!$response) {\n $response['_count'] = $this->model->count_results($this->_args);\n\n if ($response['_count'] > 0)\n {\n $response['data'] = $this->model->fetch($this->_args, true)->result();\n } \n $response['l'] = $this->db->last_query(); \n //$cache::save('onboard' . serialize($this->_args), $response);\n }\n\n $this->response($response);\n\t}", "public function getChesssBoard();", "public function getRooms() {\n $query = $this->query('SELECT rooms.*, users.username AS \"host_username\"\n FROM rooms\n LEFT JOIN users\n ON (users.id = rooms.id)');\n $query->execute();\n return $query->fetchAll(PDO::FETCH_ASSOC);\n }", "public function getUsersWeeklyBoardAction()\n {\n $organization = $this->getUser()->getOrganization();\n\n $users = $this->getUserRepository()->getWeeklyBoard($organization);\n\n return View::create($users);\n }", "public function index()\n {\n // JWT-Authのme()メソッドと同じ仕組み\n // BearerTokenを基にログインユーザーを特定し、ユーザー名を取得する\n $name = response()->json(auth()->user())->original->name;\n\n $boards = User::where('name', $name)\n ->first()\n ->boards;\n return response()->json([\n 'boards' => $boards,\n ], 200, [], JSON_UNESCAPED_UNICODE);\n }", "public function getWidgetsList()\n\t{\n\t\tif( $this->auth->user()->role == \"user\" ){\n\t\t\t$result = $this->auth->user()->campaigns()->lists('id');\n\t\t\treturn $this->widget->whereIn('campaign_id', $result )->where('user_id', $this->auth->id())->orderBy( 'created_at' , 'DESC' )->get();\n\t\t}else{\n\t\t\t$assigned = $this->auth->user()->assigned_campaigns;\n\t\t\t$assigned = json_decode($assigned);\n\t\t\treturn $this->widget->whereIn( 'campaign_id' , $assigned )->orderBy( 'created_at' , 'DESC' )->get() ;\n\t\t}\n\t}", "public function getUsers();", "public function getUsers();", "public function getUsers();", "public function list_owner()\n {\n $query = User::select(DB::raw(\"CONCAT(name,' ',lastname) AS owner\"), 'id')->whereHas(\n 'roles', function($q){\n $q->where('name','=', 'owner');\n }\n )->pluck('owner', 'id')->all();\n\n return ['' => trans('app.select_owner')] + $query;\n }", "public function getAccountsWithUsers();", "function get_workouts_by_user($username)\r\n{\r\n\t$query =\"SELECT * FROM users WHERE username ='$username'\";\r\n\t$result = queryMysql($query);\r\n\t$user_data = mysql_fetch_array($result);\r\n\t$user_id = $user_data['id'];\r\n\t\r\n\t\r\n\t$query = \"SELECT id FROM workouts WHERE user_id ='$user_id' ORDER BY date\";\r\n\t$result = queryMysql($query);\r\n\t\r\n\t$workout_object_list = array();\r\n\twhile($workout_data = mysql_fetch_array($result))\r\n\t{\r\n\t\t$workout_id = $workout_data['id'];\r\n\t\t$workout_object = get_workout_by_workout_id($workout_id);\r\n\t\t$workout_object_list[] = $workout_object;\r\n\t}\r\n\treturn $workout_object_list;\r\n}" ]
[ "0.6787358", "0.63407284", "0.63406295", "0.60959804", "0.6088827", "0.60060215", "0.5974755", "0.5898733", "0.586418", "0.58276206", "0.57939565", "0.5789701", "0.57071304", "0.56992894", "0.5627733", "0.5625437", "0.5624131", "0.5614554", "0.56130695", "0.560227", "0.5571793", "0.55705166", "0.55569696", "0.5538709", "0.5538473", "0.5538473", "0.5538473", "0.55384064", "0.5508179", "0.54933107" ]
0.706947
0
Attaches a stage and assigns a fallback to the attached stage.
public function attach(callable $stage, callable $fallback = null);
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function addStage(Stage $stage);", "public function addStage(Stage $stage): void {\n if ($this->fixedStages) {\n throw new InvalidStateException('Cannot modify pipeline after loading data.');\n }\n $this->stages[] = $stage;\n $stage->setPipeline($this);\n }", "function setStage($data) {\n $this->logHelper->log ( INFO, \"stage:\".$data [static::STAGE] );\n if (is_array ( $data ) && isset ( $data [static::STAGE] ) && ! empty ( $data [static::STAGE] ) && ! is_null ( $data [static::STAGE] )) {\n // return the same if stage is already set with required format\n if (is_array ( $data [static::STAGE] ) || is_object ( $data [static::STAGE] )) {\n return $data [static::STAGE];\n } else {\n $stage = $this->getStage ( \"id\", $data [static::STAGE] );\n \n // if name is set as value\n if (is_null ( $stage )) {\n $stage = $this->getStage ( \"name\", $data [static::STAGE] );\n }\n // set to default stage\n if (is_null ( $stage )) {\n $stage = $this->getStage ( \"name\", $this->defaultStage );\n }\n return $stage;\n }\n } else {\n // set to default stage\n return $this->getStage ( \"name\", $this->defaultStage );\n }\n }", "public function setStage($stage)\n {\n $this->stage = $stage;\n\n return $this;\n }", "Public function set_lib_stage ($lib_sta)\r\n\t\t\t{\r\n\t\t\t\t $this-> lib_stage = $lib_sta;\r\n\t\t\t}", "public function setFallbackText($fallback)\n {\n $this->attachment[\"fallback\"] = $fallback;\n }", "protected static function bootIfNotBooted(): void\n {\n if (static::$booted) {\n return;\n }\n\n // Collect office document extensions\n static::$presetsExtensions[static::PRESET_DOCUMENTS_ALL] = array_unique(array_merge(\n static::$presetsExtensions[static::PRESET_DOCUMENTS_ALL],\n static::$presetsExtensions[static::PRESET_DOCUMENTS_TEXT],\n static::$presetsExtensions[static::PRESET_DOCUMENTS_TABLES],\n static::$presetsExtensions[static::PRESET_DOCUMENTS_PRESENTATIONS],\n ));\n\n // Collect all permitted extensions\n $all = array_values(static::$presetsExtensions);\n static::$presetsExtensions[static::PRESET_ALL_PERMITTED] = array_unique(array_merge(...$all));\n\n static::$booted = true;\n }", "function onCreateApprovalStage(Stage $stage, $objApproval_)\n\t{\n\t\t$objApproval = new TrOfflineTrainingApproval;\n\t\t$objApproval->tr_offline_training_id = is_object($objApproval_)? $objApproval_->tr_offline_training_id : $objApproval_;\n\t\t$objApproval->status = 0;\n\t\t$objApproval->stage_id = $stage->id;\n//\t\t$objApproval->comment = request('comment');\n//\t\t$objApproval->approver_id = Auth::user()->id;\n\t\t$objApproval->save();\n\n\t}", "function onEnableFinalApprovalStage(Stage $stage, $objApproval)\n\t{\n\t\t$objApproval->status = 1;\n\t\t$objApproval->comment = request('comment');\n\t\t$objApproval->approver_id = Auth::user()->id;\n\t\t$objApproval->save();\n\n\t\t$objApproval->training->status = 1; //approve main training.\n\t\t$objApproval->training->save();\n\n\t\t//tr_user_offline_training_id\n\n\t}", "public function testUpdateStage()\n {\n $pipeline_id = '521f26eccce8b4310e00006b';\n $stage_id = '52219a33cce8b46dd400006a';\n $name = 'Test Stage Update';\n\n $client = new ClinchPadClient('api-key');\n $resource = new ClinchPadStages($client);\n $resource->updateStage($pipeline_id, $stage_id, $name);\n\n $this->assertEquals('PUT', $client->getClient()->method);\n $this->assertEquals($client->getEndpoint() . '/pipelines/'.$pipeline_id.'/stages/' . $stage_id, $client->getClient()->uri);\n }", "public function setFallback($fallback)\n {\n $this->fallback = $fallback;\n }", "public function testSettingFallback()\n {\n $attachmentObject = new Attachment();\n $returnedObject = $attachmentObject->setFallback($this->dummyString);\n $refAttachmentObject = new \\ReflectionObject($attachmentObject);\n $fallbackProperty = $refAttachmentObject->getProperty('fallback');\n $fallbackProperty->setAccessible(true);\n \n $this->assertInstanceOf(Attachment::class, $returnedObject);\n $this->assertEquals($this->dummyString, $fallbackProperty->getValue($attachmentObject));\n }", "public function setStage(string $nextStage): bool\n\t{\n\t\tif ($this->isStageValid($nextStage) && $this->canSwitchToStage($nextStage))\n\t\t{\n\t\t\treturn $this->persist($nextStage);\n\t\t}\n\t\treturn false;\n\t}", "protected function bootIfNotBooted()\n {\n if ( ! isset(static::$booted[static::ENTITY_TYPE][static::class]) ) {\n static::$booted[static::ENTITY_TYPE][static::class] = true;\n\n /** @todo Document action */\n do_action_ref_array('thelonius/' . static::ENTITY_TYPE . '/booting', [ &$this ]);\n\n $this->boot();\n\n /** @todo Document action */\n do_action_ref_array('thelonius/' . static::ENTITY_TYPE . '/booted', [ &$this ]);\n }\n }", "public function update(Stage $stage, Request $request)\n {\n $stage = Stage::where('id', $stage->id)->first();\n $stage->user_id = $request->user_id;\n $stage->background = $request->background;\n $stage->stage_type = $request->stage_type;\n $stage->displayable = $request->displayable;\n $stage->save();\n\n event(new StageMessage($stage));\n\n return $stage;\n }", "abstract public function attach();", "protected function bootIfNotBooted(): void\n {\n if (! $this->booted) {\n $this->boot();\n }\n\n $this->booted = true;\n }", "protected function bootIfNotBooted()\n {\n if (! isset(static::$booted[static::class])) {\n static::$booted[static::class] = true;\n static::boot( $this );\n }\n }", "protected function bootIfNotBooted()\n {\n if (!isset(static::$booted[static::class])) {\n static::$booted[static::class] = true;\n $this->fireEvent('booting', false);\n\n static::boot();\n\n $this->fireEvent('booted', false);\n }\n }", "public function earlyReturningOfAsset ()\n {\n $this->getNextAvailability();\n\n if ( !$this->nextAvailability ) {\n return $this->createAvailability(DateUtil::getDateTime(), $this->endTime, $this->dropAddress->id);\n }\n\n return ( new AssetAvailabilityManagement([\n 'start_time' => DateUtil::getDateTime(),\n ], $this->nextAvailability) )->update();\n }", "public function earlyHandoverOfAsset ()\n {\n $this->getPreviousAvailability();\n\n if ( !$this->previousAvailability ) return true;\n\n ( new AssetAvailabilityManagement([\n 'start_time' => DateUtil::getDateTime(),\n ], $this->previousAvailability) )->update();\n }", "public function edit(Stage $stage)\n {\n //\n }", "public function setFallback(string $fallback = null)\n\t{\n\t\t$this->fallback = $fallback;\n\t}", "function onRejectApprovalStage(Stage $stage, $objApproval)\n\t{\n\t\t$objApproval->status = 0;\n\t\t$objApproval->comment = request('comment');\n\t\t$objApproval->approver_id = Auth::user()->id;\n\t\t$objApproval->save();\n\n\t}", "public\n function createStage($model, $stage)\n {\n $stageFormat = $model->fs_format;\n if ($stage == Tournament::STAGE_GS) {\n $stageFormat = $model->gs_format;\n }\n if ($stageFormat === Tournament::FORMAT_SINGLE_ELIMINATION) {\n $this->createSingleEliminationStage($model, $stage);\n } else if ($stageFormat === Tournament::FORMAT_DOUBLE_ELIMINATION) {\n $this->createDoubleEliminationStage($model, $stage);\n } else if ($stageFormat === Tournament::FORMAT_ROUND_ROBIN) {\n $this->createRoundRobinStage($model, $stage);\n } else {\n $this->createSwissStage($model, $stage);\n }\n\n }", "protected function bootIfNotBooted()\n {\n if (! isset(static::$booted[static::class])) {\n static::$booted[static::class] = true;\n\n // $this->fireModelEvent('booting', false);\n\n static::booting();\n static::boot();\n static::booted();\n\n // $this->fireModelEvent('booted', false);\n }\n }", "public function onValidateStage($from_host, $path) {\nglobal $_LW;\nreturn true; // return true/false depending on whether the file at $path should be staged\n}", "public abstract function getInitialStage(): string;", "public function filter_import_stage( $stageoutput, $import_name, $stage, $step )\r\n\t{\r\n\t\t// Only act on this filter if the import_name is one we handle...\r\n\t\tif( !in_array( $import_name, $this->supported_importers ) ) {\r\n\t\t\t// Must return $stageoutput as it may contain the stage HTML of another importer\r\n\t\t\treturn $stageoutput;\r\n\t\t}\r\n\r\n\t\t$inputs = array();\r\n\r\n\t\t// Validate input from various stages...\r\n\t\tswitch( $stage ) {\r\n\t\tcase 1:\r\n\t\t\tif( count( $_POST ) ) {\r\n\t\t\t\t$inputs = $_POST->filter_keys( 'db_type', 'db_name','db_host','db_user','db_pass','db_prefix', 'tag_import' );\r\n\t\t\t\tforeach ( $inputs as $key => $value ) {\r\n\t\t\t\t\t$$key = $value;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$connect_string = $this->get_connect_string( $db_type, $db_host, $db_name );\r\n\t\t\t\tif( $this->hab_connect( $connect_string, $db_user, $db_pass, $db_prefix ) ) {\r\n\t\t\t\t\t$stage = 2;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\t$inputs['warning']= _t( 'Could not connect to the Habari database using the values supplied. Please correct them and try again.' );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t// Based on the stage of the import we're on, do different things...\r\n\t\tswitch( $stage ) {\r\n\t\tcase 1:\r\n\t\tdefault:\r\n\t\t\t$output = $this->stage1( $inputs );\r\n\t\t\tbreak;\r\n\t\tcase 2:\r\n\t\t\t$output = $this->stage2( $inputs );\r\n\t\t}\r\n\r\n\t\treturn $output;\r\n\t}", "function onEnableApprovalStage(Stage $stage, $objApproval)\n\t{\n\t\t$objApproval->status = 1;\n\t\t$objApproval->comment = request('comment');\n\t\t$objApproval->approver_id = Auth::user()->id;\n\t\t$objApproval->save();\n\t\t//tr_user_offline_training_id\n\t}" ]
[ "0.5955727", "0.5633084", "0.4950355", "0.46834555", "0.4645234", "0.4534022", "0.43755195", "0.42861995", "0.42790926", "0.4220418", "0.4212429", "0.4186967", "0.41819283", "0.41526884", "0.41468272", "0.4128754", "0.4099988", "0.4069249", "0.4063158", "0.40604678", "0.40468818", "0.40463853", "0.40331542", "0.40046012", "0.40037626", "0.39881462", "0.3984688", "0.39655274", "0.39596006", "0.3958663" ]
0.7390845
0
Get the snacks owned by the user
public function userSnacks(User $user){ return Snack::where('owner_id', $user->id)->get(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function snackDetails(User $user, $snack){\n return Snack::where('owner_id', $user->id)\n ->where('id', $snack)\n ->get()\n ->first(); //use this to ensure 1 row returned\n }", "public function getGamesOwned($userId): GameList;", "public function getWishlistsByUser();", "public function getOwnersList(){\n return $this->_get(6);\n }", "public function ownedBy() {\n\t\tif ($this->getUserobjecttype() != \"\") {\n\t\t\t$objectQueryName = $this->getUserobjecttype() . 'Query';\n\t\t\tif (class_exists($objectQueryName)) {\n\t\t\t\t$query = BaseQuery::create($this->getUserobjecttype());\n\t\t\t\treturn $query->findPK($this->getUserobjectid());\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "abstract function getOwned();", "public static function get_user_hidden_opps($username)\n {\n global $wpdb;\n global $tt_opp_dates_table_hidden;\n\n $sql = \"SELECT * FROM $tt_opp_dates_table_hidden WHERE username= '$username'\";\n\n $opp_items = $wpdb->get_results( $sql );\n\n $opp_items_array = array();\n foreach ($opp_items as $opp_info)\n {\n $opp_items_array[] = $opp_info->opp_id;\n\n\n }\n return $opp_items_array;\n\n }", "public function ownedBy($owner, string $name);", "public function show($userId)\n {\n $userMongoId = new MongoId($userId);\n $ids = is_array($userId) ? $userId : [$userMongoId];\n $requests = $this->db->users->findOne(['_id'=>['$in'=>$ids]], ['friendship'=>true]);\n\n return $this->showAll($this->db->users->find([\n 'friendship' => $userMongoId,\n '_id' => ['$in'=>$requests['friendship']]\n ]));\n }", "public function getUsers()\n {\n return $this->hasOne(Users::class, ['id' => 'users_id'])->inverseOf('dislikes');\n }", "public function getStoriesAssignedTo(User $user)\n {\n return $this->getStories()->filter(function ($story) use ($user) {\n return $user == $story->getAssignee();\n });\n }", "function loan_Statistic_Owner($item) {\n\t\t$query = 'SELECT u.name\n\t\t\t\t FROM item i, users u\n\t\t\t\t WHERE i.owner = u.email\n\t\t\t\t AND i.item_name = \\''.$item.'\\';\n\t\t\t\t ';\n\t\t$result = pg_query($query);\n\t\n\t\treturn $result;\n\t}", "public function following() {\n return $this->redis->sMembers($this->user_follow_db.$this->id);\n }", "public function user()\n {\n return $this->morphedByMany(User::class, 'favoritable');\n }", "public function getByIdOwner($id, $user)\n {\n return $this->db->get_where($this->_table, [\"id\" => $id, \"user_id\" => $user])->row();\n }", "static function getUserItems() {\n\t\t$id = Users::getUser();\n\t\t\n\t\t$id = parent::escape($id, \"sql\");\n\t\t\n\t\t$data = parent::query(\"SELECT *\n\t\t\t\t\t\t\t\tFROM `user_objects`\n\t\t\t\t\t\t\t\tWHERE `user_id` = '$id'\n\t\t\t\t\t\t\t\tAND `approve` = '1'\n\t\t\t\t\t\t\t\");\n\t\t\t\t\t\t\t\n\t\treturn $data;\n\t}", "public function followed_by($user_id=0) {\n \tif ($user_id == 0) $user_id = $this->id;\n return $this->redis->sMembers($this->user_followed_by_db.$user_id);\n }", "public function getUserPinnedItems(string $user): mixed\n {\n $query = \"query {\n repositoryOwner(login: \\\"${user}\\\") {\n ... on ProfileOwner {\n pinnedItemsRemaining\n itemShowcase {\n items(first: 6) {\n totalCount\n edges {\n node {\n ... on Repository {\n name\n description\n primaryLanguage {\n name\n }\n stargazers {\n totalCount\n }\n forkCount\n resourcePath\n isTemplate\n }\n }\n }\n }\n hasPinnedItems\n }\n }\n }\n }\";\n\n return $this->graphQlRequest($query);\n }", "public function getUsers(){\n $userIds = array();\n foreach( $this->members as $member ){\n if( !empty( $member->id) ){\n $userIds[] = $member->id;\n }\n }\n foreach( $this->pending as $member ){\n if( !empty( $member->id) ){\n $userIds[] = $member->id;\n }\n }\n foreach( $this->blocked as $member ){\n if( !empty( $member->id) ){\n $userIds[] = $member->id;\n }\n }\n $userIds[] = $this->owner->id;\n return array_unique($userIds);\n }", "public function getDislikeShop($user_id){\r\n\t\t$req = self::$db->prepare('SELECT s.* FROM `dislikedshops` d left join shops s on d.shop_id=s.id WHERE TIMEDIFF(now(), created_at )<=\"02:00\" and user_id=:user_id');\r\n\t\t$req->execute(array('user_id'=>$user_id));\r\n\t\t$shopsDislike=[];\r\n\t\twhile ($donnees = $req->fetch())\r\n {\r\n\t $shop=new Shop($donnees[\"name\"],$donnees[\"image\"],$donnees[\"distance\"]);\r\n\t $shop->setId($donnees[\"id\"]);\r\n\t $shopsDislike[]=$shop;\r\n }\r\n return $shopsDislike;\r\n\t}", "public function getOwner($user)\n {\n return $this->db->get_where($this->_table_user, [\"id\" => $user])->row()->nama;\n }", "public function getOwners()\n {\n return $this->makeRequest('leads/list/owners');\n }", "public function getShouts($user, $page = null, $limit = null)\n {\n return $this->getClient()->call('user.getshouts', array(\n 'user' => $user,\n 'page' => $page,\n 'limit' => $limit,\n ));\n }", "public function getUserSessions(int $user): Collection;", "public function list_owner()\n {\n $query = User::select(DB::raw(\"CONCAT(name,' ',lastname) AS owner\"), 'id')->whereHas(\n 'roles', function($q){\n $q->where('name','=', 'owner');\n }\n )->pluck('owner', 'id')->all();\n\n return ['' => trans('app.select_owner')] + $query;\n }", "public function getOwnerNsid();", "public function kegiatanByOwner($user)\n {\n return $this->db->get_where($this->_table, [\"user_id\" => $user])->result();\n }", "public function userKnow(\\App\\User $user)\n {\n return \\App\\Repositories\\UserFriendshipRepository::getFriendsOf($user);\n // return $user->select('users.id','email', 'firstname', 'lastname')\n // ->leftJoin('orders',function($join){\n // $join->on('orders.buyer_id','=','users.id')\n // ->orOn('orders.owner_id','=','users.id');\n // })\n // ->leftJoin('houses',function($join){\n // $join->on('houses.buyer_id','=','users.id')\n // ->orOn('houses.owner_id','=','users.id');\n // })\n // ->where('users.id','<>',$user->id)\n // ->where(function ($query) use ($user) {\n // $query->where('parent_id',$user->id)\n // ->orWhere('users.id',$user->parent_id)\n // ->orwhere('orders.owner_id',$user->id)\n // ->orWhere('orders.buyer_id',$user->id)\n // ->orwhere('houses.owner_id',$user->id)\n // ->orWhere('houses.buyer_id',$user->id);\n // })\n // ->get()\n // ->unique();\n }", "function _horde_listSharesOfOwner($shareRoot, $userName)\n{\n if (!Auth::isAdmin()) {\n return PEAR::raiseError(_(\"You are not allowed to list shares.\"));\n }\n\n require_once 'Horde/Share.php';\n $shares = &Horde_Share::singleton($shareRoot);\n\n $share_list = &$shares->listShares($userName, PERMS_SHOW, $userName);\n $myshares = array();\n foreach ($share_list as $share) {\n $myshares[] = $share->getName();\n }\n\n return $myshares;\n}", "public static function getAllOfUser()\n {\n $list = Nestling::with(['specie','customSpecie'])\n ->where('userId','=',Auth::id())\n ->where('state',1)\n ->get();\n return $list;\n }" ]
[ "0.6420252", "0.6047609", "0.59416115", "0.5871182", "0.5864362", "0.5521833", "0.54607177", "0.54527795", "0.54238766", "0.5397309", "0.53931314", "0.5352578", "0.5342507", "0.5332246", "0.53293145", "0.53174776", "0.53055376", "0.5304143", "0.5296713", "0.52933794", "0.52919817", "0.52642083", "0.5244889", "0.5206713", "0.52067024", "0.520551", "0.51931363", "0.51744336", "0.514309", "0.51374716" ]
0.7947099
0
Get the details for a user owned snack
public function snackDetails(User $user, $snack){ return Snack::where('owner_id', $user->id) ->where('id', $snack) ->get() ->first(); //use this to ensure 1 row returned }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function userSnacks(User $user){\n return Snack::where('owner_id', $user->id)->get();\n }", "public function getUser()\n {\n $user = DB::connection('mysql_whmcs')\n ->table('tblclients')\n ->where('id', Auth::user()->wid)\n ->first();\n\n $btw = DB::connection('mysql_whmcs')\n ->table('tblcustomfieldsvalues')\n ->where('relid', Auth::user()->wid)\n ->first();\n\n $user->btw = $btw->value;\n\n unset( $user->{'password'} );\n unset( $user->{'securityqans'} );\n unset( $user->{'uuid'} );\n\n Cache::put('UserInfo_' . Auth::user()->wid, $user, 30);\n\n\n if (Gate::denies('owns-data', $user->id)){\n abort(401);\n }\n\n return Api::respondSuccess($user);\n }", "public function getDetailInfo()\r\n {\r\n try {\r\n $response = $this->userApi_instance->usersUserIdGet($this->user_id);\r\n\r\n } catch (Exception $e) {\r\n echo 'Exception: ', $e->getMessage(), PHP_EOL;\r\n }\r\n echo $response;\r\n }", "public function getUserInfo() {\n $this->user = $this->client->getResourceOwner($this->token);\n\n var_dump($this->user->getName());\n return $this->user;\n }", "public function ownedBy() {\n\t\tif ($this->getUserobjecttype() != \"\") {\n\t\t\t$objectQueryName = $this->getUserobjecttype() . 'Query';\n\t\t\tif (class_exists($objectQueryName)) {\n\t\t\t\t$query = BaseQuery::create($this->getUserobjecttype());\n\t\t\t\treturn $query->findPK($this->getUserobjectid());\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}", "public function getUserDetails()\n {\n $results = $this->make('users/__SELF__', 'get');\n\n return $results['count'] ? $results['results'][0] : [];\n }", "function user_get()\r\n {\r\n //Respond with information about a user\r\n }", "public function userShow ($id='')\n\t{\n\t\tif(!empty($id))\n\t\t{\n\t\t\t$url = 'http://twitter.com/users/show/'. $id .'.xml';\n\t\t\n\t\t\tif(function_exists('curl_init'))\n\t\t\t{\n\t\t\t\t$ch = curl_init();\n\t\t\t\t\t\n\t\t\t\tcurl_setopt($ch, CURLOPT_URL, $url);\n\t\t\t\tcurl_setopt($ch, CURLOPT_VERBOSE, 1);\n\t\t\t\tcurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\t\t\t\tcurl_setopt($ch, CURLOPT_USERPWD, \"$this->Username:$this->Password\");\n\t\t\t\tcurl_setopt($ch, CURLOPT_GET, 1);\t\t\n\t\t\n\t\t\t\t$xml = curl_exec($ch);\n\t\t\t\t$Headers = curl_getinfo($ch);\n\t\t\n\t\t\t\tcurl_close($ch);\n\t\t\t\n\t\t\t\tif($Headers['http_code'] == 200)\n\t\t\t\t{\n\t\t\n\t\t\t\t\t$data = simplexml_load_string($xml);\n\t\t\t\t\t$protc = \"protected\";\t\n\t\t\t\t\t$usershow = array ();\n\t\t\t\t\t$usershow['userid'] = (string) $data->id;\n\t\t\t\t\t$usershow['name'] = (string) $data->name;\n\t\t\t\t\t$usershow['screen_name'] = (string) $data->screen_name ;\n\t\t\t\t\t$usershow['location'] = (string) $data->location ;\n\t\t\t\t\t$usershow['description'] = (string) $data->description;\n\t\t\t\t\t$usershow['profile_image_url'] = (string) $data->profile_image_url;\n\t\t\t\t\t$usershow['url'] = (string) $data->url;\n\t\t\t\t\t$usershow['protected'] = (string) $data->$protc;\n\t\t\t\t\t$usershow['bg_color'] = (string) $data->profile_background_color;\n\t\t\t\t\t$usershow['text_color'] = (string) $data->profile_text_color;\n\t\t\t\t\t$usershow['link_color'] = (string) $data->profile_link_color;\n\t\t\t\t\t$usershow['sidebar_bg_color'] = (string) $data->profile_sidebar_fill_color;\n\t\t\t\t\t$usershow['sidebar_border_color'] = (string) $data->profile_sidebar_border_color;\n\t\t\t\t\t$usershow['following_count'] = (string) $data->friends_count;\n\t\t\t\t\t$usershow['followers_count'] = (string) $data->followers_count;\n\t\t\t\t\t$usershow['favourites_count'] = (string) $data->favourites_count;\n\t\t\t\t\t$usershow['utc_offset'] = (string) $data->utc_offset;\n\t\t\t\t\t$usershow['bg_image'] = (string) $data->profile_background_image;\n\t\t\t\t\t$usershow['bg_tile'] = (string) $data->profile_background_tile;\n\t\t\t\t\t$usershow['statuses_count'] = (string) $data->statuses_count;\n\t\t\t\t\t\n\t\t\t\t\t$usershow['status']['created_at'] = (string) $data->status->created_at;\n\t\t\t\t\t$usershow['status']['id'] = (string) $data->status->id;\n\t\t\t\t\t$usershow['status']['text'] = (string) $data->status->text;\n\t\t\t\t\t$usershow['status']['source'] = (string) $data->status->source;\n\t\t\t\t\n\t\t\t\t\treturn $usershow;\n\t\t\t\t\n\t\t\t\t}else\n\t\t\t\t{\n\t\t\t\t\tif($Headers['http_code'] == 401)\n\t\t\t\t\t{\n\t\t\t\t\t\t$this->Error(4);\n\t\t\t\t\t\n\t\t\t\t\t} elseif($Headers['http_code'] == 404)\n\t\t\t\t\t{\n\t\t\t\t\t\t$this->Error(5);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\n\t\t\t}else\n\t\t\t{\n\t\t\t\t$this->Error(2);\n\t\t\t}\n\t\t}else\n\t\t{\n\t\t\t$this->Error(6);\n\t\t}\t\n\t}", "function get_profile_user_get()\n {\n $account_id = $this->checkSessionAndTokenAuth();\n $res = $this->responseUserAccountDatas($account_id);\n\n $res = removeNullOfObject($res);\n $this->response(RestSuccess($res), SUCCESS_CODE);\n }", "public function getOwnerNsid();", "public function getUserSummary()\r\n {\r\n return $this->get(self::_USER_SUMMARY);\r\n }", "public function getUserDetailAction()\n {\n //get input\n $inputs = $this->getAllUrlParam();\n\n //define default\n $default = [];\n \n // Validate input\n $params = $this->validateApi($this->getUserDetail, $default, $inputs);\n \n if (isset($params['msgError']))\n {\n //Validate error\n return $this->validateError($params['fieldError'], $params['msgError']);\n }\n \n //get user repository\n $userRepo = $this->getUserRepository();\n \n //get user data by id\n $result = $userRepo->getUserDetail($params);\n\n //Check response error\n if (!$result['success'])\n {\n return $this->validateBussinessError($result['message']);\n }\n\n return $this->output($result['data']);\n }", "function getFamilyOwner()\n {\n if(isset($_POST[\"familyOwnerId\"]))\n {\n echo json_encode(Users::getUser($_POST[\"familyOwnerId\"]));\n }\n }", "private function _getUserInfo()\n {\n return \\User::find($this->_me['id'])->userInfo()->first();\n }", "public function getUserDetail(){\n $this->openFunction('BAPI_USER_GETLIST');\n //$this->fce->USERNAME = $id;\n //$this->fce->CACHE_RESULT = 'X';\n $this->fce->call();\n\n $itTampung = array();\n if ($this->fce->GetStatus() == SAPRFC_OK) {\n\n $this->fce->USERLIST->Reset();\n while ($this->fce->USERLIST->Next()) {\n $itTampung[] = $this->fce->USERLIST->row;\n }\n\n }\n return $itTampung;\n }", "public function show()\n {\n //\n $personal_details = PersonalDetails::all();\n\n foreach ($personal_details as $interest){\n var_dump($interest->users['name']);\n }\n }", "public function fetchRecord()\n {\n // Fetch the user record from the database.\n //\n return $this->userRepository->simplyFindByUsername( $this->segment(2) );\n }", "public function readUser() {\n $meta = json_decode($this->ctrlr->__openid['Openid']['meta'], true);\n if(!empty($meta) && !empty($meta['slideshare_user'])):\n if(!empty($meta['slideshare_user']['password'])):\n $meta['slideshare_user']['password'] = $this->Gatekeeper->decode($meta['slideshare_user']['password']);\n endif;\n $this->ctrlr->set(\"slideUser\", $meta['slideshare_user']);\n return $meta['slideshare_user'];\n endif;\n }", "public function getSponsor($username)\n\t{\n\n\t}", "function getUserDetails($username)\n\t{\n\t\t$this->userName = $username;\n\t\t\n\t\t// Removed the RDN Setup as this should be done by the auth function... ie we check auth before we get user details!\n\t\t//$this->ldaprdn = \"cn=users,\" . $this->ldapconfig['basedn'];\n\t\t//$this->ldaprdn = \"uid=\" . $this->userName . \",cn=users,\" . $this->ldapconfig['basedn'];\n\t\t//$filter = \"(cn=\".$this->userName.\")\";\n\t\t$filter=\"(objectclass=*)\";\n\t\t$retArr = array(\"sn\", \"givenname\", \"mail\",\"cn\");\n\t\t//echo $this->ldaprdn;\n\t\t$res = ldap_search($this->ldapconn,$this->ldaprdn,$filter,$retArr);\n\t\t$info = ldap_get_entries($this->ldapconn, $res);\n\t\t//print_r( $info );\n\t\t$retVar = array();\n\t\t\n\t\t// build the return values\n\t\tif (isset($info[0]['mail'][0])) { $retVar['mail'] = $info[0]['mail'][0]; }\n\t\tif (isset($info[0]['sn'][0])) { $retVar['sn'] = $info[0]['sn'][0]; }\n\t\tif (isset($info[0]['cn'][0])) { $retVar['cn'] = $info[0]['cn'][0]; }\n\t\tif (isset($info[0]['givenname'][0])) { $retVar['givenname'] = $info[0]['givenname'][0]; }\n\t\tif (isset($info[0]['dn'])) { $retVar['dn'] = $info[0]['dn']; }\n\t\t\n\t\treturn $retVar;\n\t}", "public function getOwner($user)\n {\n return $this->db->get_where($this->_table_user, [\"id\" => $user])->row()->nama;\n }", "function User($username) {\n $params = array(\n 'method' => 'flickr.people.findByUsername',\n 'username' => $username,\n 'api_key' => $this->getAPIKey()\n );\n $this->setQueryString($params);\n $response = $this->request('');\n $result = $this->getAttribute($response->getBody(), 'user', NULL, 'nsid');\n return $result;\n }", "public function usersFromStackAction() {\n\t\t\t$config = array(\n\t\t\t 'host' => 'localhost',\n\t\t\t 'username' => 'root',\n\t\t\t 'password' => '',\n\t\t\t 'dbname' => 'epicadvice',\n\t\t\t);\n\t\t\t$db = Zend_Db::factory('PDO_MYSQL', $config);\n\t\t\t$table = new Zend_Db_Table(array(\"db\" => $db, \"name\" => \"epic_db_profile\"));\n\t\t\t\n\t\t\t// Things to Ignore\n\t\t\t$ignoreKeys = array('badgeSummary','hasReplies','hasMessage','location','birthday','preferencesRaw');\n\n\t\t\t// Things to Map\n\t\t\t$keyMapping = array(\n\t\t\t\t'websiteUrl' => 'url',\n\t\t\t\t'displayName' => 'name',\n\t\t\t\t'displayNameCleaned' => 'slug',\n\t\t\t\t'aboutMe' => 'bio',\n\t\t\t);\n\n\t\t\t// Target XMl\n\t\t\t$xpath = $this->getXPath(\"Users\");\n\t\t\t$users = $xpath->evaluate('//Users/row');\n\n\t\t\t$highestId = 0;\n\t\t\tforeach ($users as $user) {\n\t\t\t\t\t$parsed = $this->parseNode($user, $keyMapping, $ignoreKeys);\n\t\t\t\t\tif($parsed['id'] == -1) continue;\n\t\t\t\t\tif($parsed['id'] > $this->_parseLimit) continue;\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t$profile = EpicDb_Mongo::db('user')->fetchOne(array('id' => (int)$parsed['id']));\n\t\t\t\t\tif (!$profile) {\n\t\t\t\t\t\t$userClass = EpicDb_Mongo::dbClass('user');\n\t\t\t\t\t\t$profile = new $userClass;\n\t\t\t\t\t\t$profile->_type = 'user';\n\t\t\t\t\t\t$user = new MW_Auth_Mongo_Role();\n\n\t\t\t\t\t\tforeach(array(\"openId\", \"openIdAlt\") as $key) {\n\t\t\t\t\t\t\tif ( !empty($parsed[$key]) ) {\n\t\t\t\t\t\t\t\t$auth = $user->auth->new();\n\t\t\t\t\t\t\t\t$auth->openid = $parsed[$key];\n\t\t\t\t\t\t\t\t$user->auth->addDocument($auth);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$user->save();\n\t\t\t\t\t\t$profile->user = $user;\n\t\t\t\t\t\t$profile->save();\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// Data from the Profiles DB\n\t\t\t\t\t$select = $table->select()->where(\"user_id = ?\", $parsed['id']);\n\t\t\t\t\t$row = $table->fetchAll($select)->current(); \n\t\t\t\t\t// var_dump($row); exit;\n\t\t\t\t\t// var_dump($profile); exit;\n\t\t\t\t\tif($row) {\n\t\t\t\t\t\t$query = array(\n\t\t\t\t\t\t\t'name' => $row->character,\n\t\t\t\t\t\t\t'realm' => $row->realm,\n\t\t\t\t\t\t\t'region' => $row->region,\n\t\t\t\t\t\t\t'faction' => (int) $row->faction,\n\t\t\t\t\t\t);\n\t\t\t\t\t\t$char = EpicDb_Mongo::db('character')->fetchOne($query);\n\t\t\t\t\t\tif(!$char) {\n\t\t\t\t\t\t\t$char = EpicDb_Mongo::newDoc('character');\n\t\t\t\t\t\t\t$this->copyToMongo($query, $char);\n\t\t\t\t\t\t\t$char->tags->tag($profile, 'owner');\n\t\t\t\t\t\t\t$char->save();\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\t$profile->characters->addDocument($char);\n\t\t\t\t\t}\n\t\t\t\t\t$this->copyToMongo($parsed, $profile);\n\t\t\t\t\t// Save it onto the profile\n\t\t\t\t\t$profile->save();\n\n\t\t\t\t\t$highestId = max($highestId, (int)$parsed['id']);\n\t\t\t}\n\t\t\t$lastId = MW_Mongo_Sequence::setNextSequence('user', $highestId);\n\t\t\techo \"Imported up to ID #\".$lastId;\n\t\t\texit;\n\t\t}", "public function _return_current_user_details()\n\t{\n\t\t//get Current user email address\n\n\t\tif ($this->user) {\n\t\t\t$user_emailAddress = $this->user->user_email;\n\t\t}\n\n\t\t//Search for the above user in helpdesk\n\n\t\t$_getUserSearchResults = $this->kayakoAPI->_getUserSearchEmailAddress($user_emailAddress);\n\n\t\treturn $_getUserSearchResults;\n\t}", "public function fetch_user()\n {\n $this->seeInDatabase('users', ['first_name' => 'David',\n 'last_name' => 'Bishop']);\n }", "public function honoursNAwardsAction()\n {\n $field_arr=array(\"usr.id,usr.honors_n_awards\");\n $user_id = \\Auth_UserAdapter::getIdentity()->getId();\n $result=\\Extended\\ilook_user::getUserInfo($field_arr,$user_id);\n $this->view->honours_awards=$result;\n }", "private function getUserDetails()\n {\n require_once $this->root.'api/classes/Database.php';\n $db = new Database();\n $db->connect();\n $statement = 'SELECT * FROM users WHERE username = :username LIMIT 1';\n $params = array('username' => $this->username);\n $result = $db->run($statement, $params);\n $user = $result[0];\n $db->close();\n\n $this->user_password_in_database = $user['password'];\n $this->user_id = $user['id'];\n\n // Check if user has an existing Avatar\n $db->connect();\n $statement = 'SELECT thumbnail FROM photos WHERE user_id = :user_id LIMIT 1';\n $params = array('user_id' => $this->user_id);\n $photo_result = $db->run($statement, $params);\n $avatar = $photo_result[0];\n $db->close();\n if (empty($avatar['thumbnail'])) {\n $this->user_has_avatar = false;\n } else {\n $this->user_has_avatar = true;\n }\n }", "public function get_user()\n {\n\n $query = \"SELECT id, name\n FROM ac_payroll_item\n WHERE is_active = 1\n AND barcode IS NOT null\n ORDER BY name ASC\";\n $result = $this->database->getData($query, 'we')->result();\n\n echo json_encode($result);\n\n }", "function details($params = array()) {\n \n if(!isset($params['user_id'])){\n echo \"User ID required\";\n die();\n }\n \n \n \n $request = 'users/' . $params['user_id'];\n $request .= parent::createURL($params, array('user_id'));\n \n $result = parent::makeRequest($request);\n \n return $result;\n \n }", "public function get_user($username = NULL)\n {\n \t$client = new Client();\n \t$url_string = $this->base_api.\"item/\".$username.$this->after_item;\n \t$response = $client->get($url_string);\n \t$response = $response->json();\n \treturn $response;\n }" ]
[ "0.6903883", "0.6017427", "0.59585935", "0.5731012", "0.5666567", "0.5623915", "0.55903435", "0.55514044", "0.55439353", "0.5531368", "0.55220103", "0.5520278", "0.55089784", "0.5492315", "0.54772496", "0.5476747", "0.5470431", "0.5467044", "0.54612255", "0.5445942", "0.5437446", "0.5430541", "0.541352", "0.5365241", "0.5362399", "0.5361805", "0.53592366", "0.53586197", "0.5354333", "0.53499115" ]
0.7511082
0
Method adds a snack tied to the user Placing in Repo to separate from enpoints
public function addSnack($request){ $snack = new Snack; $snack->snack_name = $request->name; $snack->pieces = $request->quantity; $snack->owner_id = $request->user()->id; try{ $snack->save(); } catch (Exception $ex) { return false; } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function userSnacks(User $user){\n return Snack::where('owner_id', $user->id)->get();\n }", "public function updateSnack($request){\n $snack = $this->snackDetails($request->user(), $request->id);\n \n $snack->snack_name = $request->name;\n $snack->pieces = $request->quantity;\n $snack->description = $request->description;\n $snack->save();\n }", "public function add( Entity $user ) {\n\t}", "public function snackDetails(User $user, $snack){\n return Snack::where('owner_id', $user->id)\n ->where('id', $snack)\n ->get()\n ->first(); //use this to ensure 1 row returned\n }", "private function addQuestionToUser()\n {\n $this->di->dispatcher->forward([\n 'controller' => 'user-question',\n 'action' => 'add',\n 'params' => [$this->userId, $this->lastInsertedId]\n ]);\n }", "public function sponsoredAction(){\r\n\t\t$this->view->params = $params = $this->_getParam('type');\r\n\t\tif($params == 'photos'){\r\n\t\t\t$this->view->id = $id = $this->_getParam('photo_id');\r\n\t\t\t$item = Engine_Api::_()->getItem('photo', $id);\r\n\t\t}else{\r\n\t\t\t$this->view->id = $id = $this->_getParam('album_id');\r\n\t\t\t$item = Engine_Api::_()->getItem('album', $id);\r\n\t\t}\r\n\t\tif($item->is_sponsored == 1)\r\n\t\t\t$status = 0;\r\n\t\telse\r\n\t\t\t$status = 1;\r\n\t\t // Check post\r\n if( $this->getRequest()->isPost())\r\n {\r\n\t\t\t$item->is_sponsored = $status;\r\n\t\t\t$item->save();\r\n\t\t\techo $status;die;\r\n\t\t}\r\n\t\techo \"error\";die;\r\n\t}", "public function sauceyShove($msg)\n {\n $this->taskExec('cp -r ./behat.yml vendor/saucey/framework/ymls/behat.yml.master.dist')\n ->run();\n\n //Push to remote for framework\n $this->taskGitStack()\n ->dir('./vendor/saucey/framework')\n ->add('-A')\n ->commit('robo saucey:work is shoving to all remote:master:framework')\n ->push('origin', 'master')\n ->run();\n\n //Pull from remotes for saucey\n $this->taskGitStack()\n ->dir('.')\n ->pull('origin', 'master')\n ->pull('origin', 'develop')\n ->run();\n\n //Push to remotes for saucey\n $this->taskGitStack()\n ->dir('.')\n ->add('-A')\n ->commit($msg)\n ->push('origin', 'develop')\n ->run();\n\n //Pull from remotes for wiki\n $this->taskGitStack()\n ->dir('./saucey.wiki')\n ->pull('origin', 'master')\n ->run();\n\n //Push to remotes for wiki\n $this->taskGitStack()\n ->dir('./saucey.wiki')\n ->add('-A')\n ->commit('robo saucey:wiki is shoving to all remote:master:wiki')\n ->push('origin', 'master')\n ->run();\n }", "public function store(CreateSnipRequest $request)\n {\n $snip = new Snip;\n $snip->name = $request->name;\n $snip->content = $request->comment;\n $snip->language_id = $request->language_id;\n $snip->user_id = user()->id;\n $snip->save();\n\n return redirect(action('SnipController@show', $snip->id));\n }", "function add_to_poked_by($user_data)\n\t{\n\t\t$q = \"REPLACE INTO poked_bys (name, times, users_id) VALUES (?, 1, ?)\";\n\t\t$values = array($user_data[0]['name'], $user_data[0]['id']);\n\t\t$this->db->query($q, $values);\n\t}", "function xstats_setShipOwner( $gameId, $turn, $shipId, $ownerId, $ownerIndex ) {\n $query = \"INSERT INTO skrupel_xstats_shipowner(gameid,shipid,ownerid,ownerindex,turn\".\n \")VALUES(\".\n $gameId.\",\".\n $shipId.\",\".\n $ownerId.\",\".\n $ownerIndex.\",\".\n $turn.\n \")\";\n @mysql_query( $query );\n}", "function addUserLine($login, $shortname, $like, $unlike) {\n\t$ch = curl_init ();\n\t$userLine = array (\n\t\t\t'like' => $like,\n\t\t\t'unlike' => $unlike \n\t);\n\t\n\t$payload = json_encode ( $userLine );\n\t\n\tcurl_setopt ( $ch, CURLOPT_URL, 'http://localhost:5984/looppastonbus/' . $login . \"_\" . $shortname );\n\tcurl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, 'PUT' ); /* or PUT */\n\tcurl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload );\n\tcurl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );\n\tcurl_setopt ( $ch, CURLOPT_HTTPHEADER, array (\n\t\t\t'Content-type: application/json',\n\t\t\t'Accept: */*' \n\t) );\n\t$response = curl_exec ( $ch );\n\tcurl_close ( $ch );\n}", "public function noteAdd(){\n $user = $this->_ap_right_check();\n if(!$user){\n return;\n } \n $this->Notes->add($user);\n }", "function addUserWithInvalidBranch(){\n $utility = new utility();\n $utility->addNewUser(\"auto_inc\", \"testUsername\", 5, 1, \"password\", \"test user\", \"171\");\n}", "function mobiconnector_add_user_by_user_social($user){\r\n\treturn bamobile_mobiconnector_add_user_by_user_social($user);\r\n}", "public function executeStoneMasonProfile(sfWebRequest $oRequest){\n $snIdUser = $oRequest->getParameter('id','');\n //$snIdUser = $this->getUser()->getAttribute('user_id', null, 'sfGuardSecurityUser');\n $this->snTabKey = $oRequest->getParameter('tab','info');\n $ssSuccessKey = 4; // Success message key for add\n\t\t$this->snCementeryId = $oRequest->getParameter('user_cem_cemetery_id', '');\n\t\t$this->asCementery = array();\n // Add edit part\n $edit_form = false;\n if($snIdUser){\n\t\t\t$edit_form = true;\t\t\n $this->forward404Unless($oGuardUser = Doctrine::getTable('sfGuardUser')->find($snIdUser));\n $this->oSfGuardUsersForm = new sfGuardUserForm($oGuardUser);\n $ssSuccessKey = 2; // Success message key for add\n\t\t\t\n\t\t\t// For get Cemetery List\n\t\t\t$oUserCemetery = Doctrine::getTable('UserCemetery')->findByUserId($snIdUser);\n\t\t\tif(count($oUserCemetery) > 0)\n\t\t\t\t$oCemeteryCountry = Doctrine::getTable('CemCemetery')->find($oUserCemetery[0]->getCemCemeteryId());\n\n\t\t\t$snCountryId = (isset($oCemeteryCountry)) ? $oCemeteryCountry->getCountryId() : '';\n\t\t\t\n\t\t\t\n\t\t\t$this->asCementery = Doctrine::getTable('CemCemetery')->getAllCemeteries($snCountryId);\n\t\t\t$this->snCementeryId = ($this->snCementeryId == '') ? $oUserCemetery[0]->getCemCemeteryId() : $this->snCementeryId;\n }\n else\n $this->oSfGuardUsersForm = new sfGuardUserForm();\n \n $this->getConfigurationFields($this->oSfGuardUsersForm); \n \n $amUserRequestParameter = $oRequest->getParameter($this->oSfGuardUsersForm->getName());\n\t\tif($amUserRequestParameter['cem_country_id'] != '')\n\t\t\t$this->asCementery = Doctrine::getTable('CemCemetery')->getAllCemeteries($amUserRequestParameter['cem_country_id']);\n \n if($oRequest->isMethod('post')) {\n\t\t\t$this->oSfGuardUsersForm->bind($amUserRequestParameter);\n\t\t\t$arr_param = $oRequest->getParameter($this->oSfGuardUsersForm->getName());\n\n\t\t\t\n\t\t\t$grp_list = isset($arr_param['service_list']) ? $arr_param['service_list'] : '';\t\t\t\t\t\t\n\t\t\t$bSelectCemetery = false;\n\t\t\tif($this->getUser()->isSuperAdmin()){\n\t\t\t\tif($oRequest->getParameter('user_cem_cemetery_id') != '')\n\t\t\t\t\t$bSelectCemetery = true;\n\t\t\t}\n\t\t\telse\n\t\t\t\t$bSelectCemetery = true;\n\t\t\t\n\t\t\t\n\t\t\tif($this->oSfGuardUsersForm->isValid() && $bSelectCemetery){\n\t\t\t\t\n\t\t\t\t$snIdUser = $this->oSfGuardUsersForm->save()->getId();\n\t\t\t\t\n\t\t\t\tif($snIdUser) {\n\t\t\t\t\t$q = Doctrine::getTable('CemStonemason')->findByUserId($snIdUser);\n\t\t\t\t\t\t\n\t\t\t\t\tif(count($q) > 0):\t\n\t\t\t\t\t\t// update stone mason table\n\t\t\t\t\t\tDoctrine_Query::create()\n\t\t\t\t\t\t ->update('CemStonemason csm')\n\t\t\t\t\t\t ->set('csm.bond', '?', $arr_param['bond'])\n\t\t\t\t\t\t ->set('csm.annual_license_fee', '?', $arr_param['annual_license_fee'])\n\t\t\t\t\t\t ->set('csm.abn_acn_number', '?', $arr_param['abn_acn_number'])\n\t\t\t\t\t\t ->set('csm.contractors_license_number', '?', $arr_param['contractors_license_number'])\n\t\t\t\t\t\t ->set('csm.general_induction_cards', '?', $arr_param['general_induction_cards'])\n\t\t\t\t\t\t ->set('csm.operator_licenses', '?', $arr_param['operator_licenses'])\n\t\t\t\t\t\t ->set('csm.list_current_employees', '?', $arr_param['list_current_employees'])\n\t\t\t\t\t\t ->set('csm.list_contractors', '?', $arr_param['list_contractors'])\n\t\t\t\t\t\t ->where('csm.user_id = ?', $snIdUser)\n\t\t\t\t\t\t ->execute();\n\t\t\t\t\telse:\n\t\t\t\t\t\t//add record in stone mason table\n\t\t\t\t\t\t$ug = new CemStonemason();\n\t\t\t\t\t\t$ug->setUserId($snIdUser);\n\t\t\t\t\t\t$ug->setBond($arr_param['bond']);\n\t\t\t\t\t\t$ug->setAnnualLicenseFee($arr_param['annual_license_fee']);\n\t\t\t\t\t\t$ug->setAbnAcnNumber($arr_param['abn_acn_number']);\n\t\t\t\t\t\t$ug->setContractorsLicenseNumber($arr_param['contractors_license_number']);\n\t\t\t\t\t\t$ug->setGeneralInductionCards($arr_param['general_induction_cards']);\n\t\t\t\t\t\t$ug->setOperatorLicenses($arr_param['operator_licenses']);\n\t\t\t\t\t\t$ug->setListCurrentEmployees($arr_param['list_current_employees']);\n\t\t\t\t\t\t$ug->setListContractors($arr_param['list_contractors']);\n\t\t\t\t\t\t$ug->save();\n\t\t\t\t\tendif;\t\n\t\t\t\t\t\n\t\t\t\t\t\t// update user cemetery table\n\t\t\t\t\t\tDoctrine_Query::create()\n\t\t\t\t\t\t ->update('UserCemetery uc')\n\t\t\t\t\t\t ->set('uc.organisation', '?', $arr_param['organisation'])\n\t\t\t\t\t\t ->set('uc.code', '?', $arr_param['code'])\n\t\t\t\t\t\t ->set('uc.address', '?', $arr_param['address'])\n\t\t\t\t\t\t ->set('uc.state', '?', $arr_param['state'])\n\t\t\t\t\t\t ->set('uc.phone', '?', $arr_param['phone'])\n\t\t\t\t\t\t ->set('uc.suburb', '?', $arr_param['suburb'])\n\t\t\t\t\t\t ->set('uc.title', '?', $arr_param['title'])\n\t\t\t\t\t\t ->set('uc.middle_name', '?', $arr_param['middle_name'])\n\t\t\t\t\t\t ->set('uc.postal_code', '?', $arr_param['postal_code'])\n\t\t\t\t\t\t ->set('uc.fax', '?', $arr_param['fax'])\n\t\t\t\t\t\t ->set('uc.area_code', '?', $arr_param['area_code'])\n ->set('uc.user_code', '?', $arr_param['user_code'])\n\t\t\t\t\t\t ->set('uc.fax_area_code', '?', $arr_param['fax_area_code'])\n\t\t\t\t\t\t ->where('uc.user_id = ?', $snIdUser)\n\t\t\t\t\t\t ->execute();\t\n\t\t\t\t}\t\t\n\t\t\t\t\n\n\t\t\t\t$this->getUser()->setFlash('snSuccessMsgKey', $ssSuccessKey); //Set messages for add and update records\n\t\t\t\tunset($this->oSfGuardUsersForm);\n\t\t\t\t\n\t\t\t\t$this->redirect('user/stoneMasonProfile?id='.$snIdUser);\n\n\t\t\t}else{\n\t\t\t\tif(!$bSelectCemetery) {\n\t\t\t\t\t$this->getUser()->setFlash('ssErrorCemeter',__('Cemetery required'));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n }", "public function refurbishUser($user);", "private function postSpouse()\n {\n\n $spouseId = null;\n if (isset($_POST['spouse'])) {\n $spouseId = $_POST['spouse'];\n }\n\n if (!$spouseId) {\n FlashMessage::add(FlashMessage::TYPE_ERROR, 'Bitte einen Ehepartner/in auswählen!');\n } else {\n $user = $this->data['user'];\n $spouse = User::find($spouseId);\n\n $user->spouse = $spouse;\n $user->main_address = true;\n\n $this->data['user'] = $user;\n $user->save();\n\n $spouse->spouse = $user;\n $user->main_address = false;\n $spouse->save();\n\n FlashMessage::add(Flashmessage::TYPE_SUCCESS, 'Ehepartner/in erfolgreich gespeichert.');\n Helpers::redirect('?page=' . $_GET['page'] . '&view=detail&tab=data&id=' . $_GET['id'] . '&edit=1');\n }\n\n }", "function _horde_addShare($shareRoot, $shareName, $shareTitle, $userName)\n{\n if (!Auth::isAdmin()) {\n return PEAR::raiseError(_(\"You are not allowed to add shares.\"));\n }\n\n require_once 'Horde/Share.php';\n $shares = &Horde_Share::singleton($shareRoot);\n\n if (is_a($share = &$shares->newShare($shareName), 'PEAR_Error')) {\n return $share;\n }\n $share->set('owner', $userName);\n $share->set('name', $shareTitle);\n\n if (is_a($result = $shares->addShare($share), 'PEAR_Error')) {\n return $result;\n }\n\n return true;\n}", "public function makeOwner ($user) {\n\n\t}", "public function _add_forward_to()\n\t{\n\t\t\n\t\t//if the person is a group user don't show them this:\n\t\t$user = new User_Model($_SESSION['auth_user']->id);\n\t\t//figure out what group this user is\n\t\t//if they're not a groupie, then quit\n\t\t$group_id = groups::get_user_group($user);\n\t\tif($group_id)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t//get a list of groups that this item could be sent to:\n\t\t\n\t\t$groups = ORM::factory(\"simplegroups_groups\")->find_all();\n\t\t\t$groups_array = array();\n\t\t\tforeach($groups as $group)\n\t\t\t{\n\t\t\t\t$groups_array[$group->id] = $group->name;\n\t\t\t}\n\t\t\n\t\t//get the id of the item in question\n\t\t$id = Event::$data;\n\t\t\n\t\t//if we're looking at a message...\n\t\tif (Router::$controller == 'messages')\n\t\t{\n\t\t\t$item_type = \"message\";\n\t\t}\n\t\telseif (Router::$controller == 'reports')\n\t\t{\n\t\t\t$item_type = \"incident\";\n\t\t}\n\t\telse //something when wrong so get out of here\n\t\t{\n\t\t\treturn; \n\t\t}\n\t\t\n\t\t\n\t\t//it seems that newer versions of Ushahidi now pass around the entier report DB object\n\t\t//and not just a string of the id\n\t\tif(!is_string($id) AND $item_type == 'incident')\n\t\t{\n\t\t\t$id = $id->incident_id;\n\t\t}\n\t\t\n\t\t\t\n\t\t//figure out if the current message/incident has already been assigned to a group\n\t\t\n\t\t$assigned_groups = ORM::factory(\"simplegroups_groups\")\n\t\t\t->join(\"simplegroups_groups_$item_type\", \"simplegroups_groups_$item_type.simplegroups_groups_id\", \"simplegroups_groups.id\")\n\t\t\t->where(\"simplegroups_groups_$item_type.\".$item_type.\"_id\", $id)\n\t\t\t->find_all();\n\t\t\n\t\n\t\t$view = new View('simplegroups/forwardto');\n\t\t$view->message_id = $id;\n\t\t$view->assigned_groups = $assigned_groups;\n\t\t$view->groups_array = $groups_array;\n\t\t$view->item_type = $item_type;\n\t\t$view->render(TRUE);\n\t\t\n\t}", "public function SlikesToFeed(){\n$send = 0;\t\n\nif($this->itemid && $this->parentid)\n$send = $this->query_insert(\"insert into \".tbl_feed.\" set `byuser`='{$this->i}',\n`community`='{$this->in_community}',\n `itemid`='{$this->itemid}',\n `added`='{$this->now}',\n `categ`='{$this->type}', `parent_id`='{$this->parentid}'\");\n\t\nreturn $send;\t\n}", "public function scavengerAction(){\n\n if(!(isset($_SESSION['user_id']) && isset($this->route_params['token']))){\n $url = '/museum/gamify/';\n $this->redirect($url);\n }\n\n $gameid = $this->route_params['token'];\n $game_name = \"Scavenger Hunt\";\n $questions = Question::getAllQuestionsByGameId($gameid);\n $resource = Game::getResourceForId($gameid);\n if($resource)\n $game_name =$resource[0]['text'];\n\n for ($counter=0; $counter<sizeof($questions);$counter++) {\n\n $scoreForQuestion = Question::getUserScoreForScavengerHuntQuestion($questions[$counter]['id']);\n //var_dump($scoreForQuestion);\n $questions[$counter]['answered'] = $scoreForQuestion['answered'];\n $questions[$counter]['userpoints'] = $scoreForQuestion['userpoints'];\n\n for ($opt=0; $opt<sizeof($questions[$counter]['options']);$opt++){\n $optionScore = Question::getUserScoreForScavengerHuntOption($questions[$counter]['id']\n ,$questions[$counter]['options'][$opt]['id']);\n\n $questions[$counter]['options'][$opt]['answered'] = $optionScore['answered'];\n $questions[$counter]['options'][$opt]['userpoints'] = $optionScore['userpoints'];\n $questions[$counter]['options'][$opt]['userbadge'] = $optionScore['userbadge'];\n $questions[$counter]['options'][$opt]['status'] = $optionScore['status'];\n $questions[$counter]['options'][$opt]['image'] = $optionScore['image'];\n $questions[$counter]['options'][$opt]['badge_img'] = $optionScore['badge_img'];\n }\n }\n View::renderTemplate('User/scavenger.html',array('questions' => $questions,'gameid' => $gameid,'game_name' => $game_name));\n }", "function hook_rbkc_api_user_post_create($user, $queue_item) {\n\t\n}", "public function api_add()\n\t{ \n\n\t\t$this->_checkVars(array('type', 'id_object','reason'));\n \n\n\t\t//$this->logged = $this->Member->findByBig( $this->Auth->user('big') );//don't understand why it's not already filled\n\t\t$memBig = $this->logged['Member']['big'];\n $type = $this->api['type'];\n\t\t$reason = $this->api['reason'];\n $idObj= $this->api['id_object'];\n\t\t \n \t\n // Check if reason matches predefined ones\n\t\tif (array_key_exists($reason, Defines::$flag_types))\n\t\t{\n\t\t\t$text = Defines::$flag_types[$reason];\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$this->_apiEr(__('Reason errato'));\n\t\t}\n\n\t\t// Check if type of signalation is valid\n\t\tif (!array_key_exists($type, Defines::$signalations))\n\t\t{//TODO in bootstrap aggiungere anche Comment in signalations\n\t\t\t\n $this->_apiEr(__('Tipo di segnalazione errata'));\n\t\t}\n \n //Search member_big of bad member\n $BadMemBig=$this->Signalation->findBadMemBig($type,$idObj);\n if ($BadMemBig==null OR $BadMemBig=='')\n {\n $this->_apiEr(__('Identificatore autore mancante'));\n }\n \n \n\t\t// Can be this signalation added?\n\t\t$canSignal = $this->Signalation->canSignal($memBig, $BadMemBig, $type, $idObj);\n\t\tif (!$canSignal)\n\t\t{\n\t\t$this->_apiEr(__('Segnalazione non possibile. Una segnalazione con questi parametri Ŕ giÓ attiva o effettuata recentemente.'));\n\t\t}\n \n \n\t\t// If signalation is made of type CHAT , add member to ignore list.\n\t\tif ($type == 1)\n\t\t{\n\t\t\t// Check if member exists? Not needed, the method has a try catch block so there won't be any dirty messages errored out\n\t\t\t$isOnList = $this->MemberSetting->isOnIgnoreListDual($memBig, $BadMemBig);\n\t\t\tif (!$isOnList)\n\t\t\t{\n\t\t\t\t$res = $this->MemberSetting->addToIgnoreList($memBig, $BadMemBig);\n\t\t\t\tif ($res === FALSE)\n\t\t\t\t{\n\t\t\t\t\t$this->_apiEr(__('Errore. Utente non aggiunto alla black list.'));\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If this is a chat, send last M chat messages with up to N characters\n // TODO migliorare prendendo N messaggi precedenti e N successivi a quello incriminato\n\t\t\t$ress = $this->ChatMessage->getMessagesForSignalation($memBig, $BadMemBig);\n\t\t}\n\t\telseif ($type == 2)\n\t\t{\n\t\t\t// Signalation of type photo - add link to the photo and link to delete the photo\n\t\t\tif (empty($idObj))\n\t\t\t{\n\t\t\t\techo json_encode('We are sorry. The report cannot be processed. The reason is: Missing photo identificator.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t$photo = $this->Photo->getSignaledPhoto($idObj);\n\t\t\tif (empty($photo['Gallery']['event_big']))\n\t\t\t{\n\t\t\t\t$img = $this->FileUrl->place_photo($photo['Gallery']['place_big'], $photo['Photo']['gallery_big'], $photo['Photo']['big'], $photo['Photo']['original_ext']);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$img = $this->FileUrl->event_photo($photo['Gallery']['event_big'], $photo['Photo']['gallery_big'], $photo['Photo']['big'], $photo['Photo']['original_ext']);\n\t\t\t}\n\n\t\t}\n elseif ($type == 3)\n { // Signalation of type comment\n \n if (empty($idObj))\n {\n echo json_encode('We are sorry. The report cannot be processed. The reason is: Missing comment identificator.');\n return;\n }\n \n //TODO quali dati riportiamo e cosa facciamo nel caso di commenti impropri ?\n \n }\n \n /*$this->log(\"membig \".$memBig);\n $this->log(\"badmembig \".$BadMemBig);\n $this->log(\"type \".$type);\n $this->log(\"text \".$text);//$this->log(\"type \".$type);\n $this->log(\"idObj \".$idObj);*/\n \n\t\t$result = $this->Signalation->addSignalation($memBig, $BadMemBig, $type, $text, $idObj);\n\n\t\t// Send email report to admins\n\t\t$member = $this->Signalation->Member->getMemberByBig($memBig);\n\t\t$flagged = $this->Signalation->Member->getMemberByBig($BadMemBig);\n\t\t$memberName = !empty($member) ? $member['Member']['name'] .\n\t\t\t(!empty($member['Member']['middle_name']) ? ' ' . $member['Member']['middle_name'] . ' ' : ' ') . $member['Member']['surname'] : 'Deleted member';\n\t\t$flaggedName = !empty($flagged) ? $flagged['Member']['name'] .\n\t\t\t(!empty($flagged['Member']['middle_name']) ? ' ' . $flagged['Member']['middle_name'] . ' ' : ' ') . $flagged['Member']['surname'] : 'Deleted member';\n\t\t$params = array(\n\t\t\t'reason' => $text,\n\t\t\t'type' => $type,\n\t\t\t'member_name' => $memberName,\n\t\t\t'member_big' => $memBig,\n\t\t\t'flagged_name' => $flaggedName,\n\t\t\t'flagged_big' => $BadMemBig,\n\t\t);\n\t\tif ($type == 1)\n\t\t{//SIGNAL_CHAT\n\t\t\t$params['messages'] = $ress;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$params['img'] = $img;\n\t\t\t$params['photoBig'] = $idObj;\n\t\t}\n\t\tApp::uses('Emailer', 'Lib');\n\t\tEmailer::sendEmail('chat_signalation', null, $params, __('New signalation'), FLAG_MAIL_TO);\n\n\n\t\tif ($result !== false)\n\t\t{\n\t\t\t$this->_apiOk();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$this->_apiEr(__('Errore. Segnalazione non inserita.'));\n\t\t}\n\n\t}", "public function add(string $itemName, string $userId): void;", "public static function registerUserOwnerBlock(\\Elgg\\Hook $hook) {\n\t\t\n\t\t$user = elgg_get_logged_in_user_entity();\n\t\tif (empty($user)) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\t$entity = $hook->getEntityParam();\n\t\tif (!$entity instanceof \\ElggUser) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif ($entity->guid !== $user->guid) {\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tif (elgg_get_plugin_setting('enable_personal', 'todos') !== 'yes') {\n\t\t\treturn;\n\t\t}\n\t\t$return = $hook->getValue();\n\t\t\n\t\t$return[] = \\ElggMenuItem::factory([\n\t\t\t'name' => 'todos',\n\t\t\t'text' => elgg_echo('todos:owner_block:user'),\n\t\t\t'href' => elgg_generate_url('collection:object:todolist:all'),\n\t\t]);\n\t\t\n\t\treturn $return;\n\t}", "function completePenName () {\n\terror_log(\"completePenName\");\n\terror_log(\"in \" . __CLASS__. \" Method \" . __METHOD__ . \" Line=\" . __LINE__ );\n\n\t\tglobal $consumer_key;\n\t\tglobal $consumer_secret;\n\t\tinclude_once('auth/twitterOAuth.php');\n\t\t$request_token = $this->request_token;\n\t\t$request_token_secret = Session::get('request_token_secret');\n\t\t$askForAuth = new TwitterOAuth($consumer_key, $consumer_secret,$request_token,$request_token_secret);\n\t\t$accessToken = $askForAuth->getAccessToken();\n\t\t$gotAuth = new TwitterOAuth($consumer_key, $consumer_secret,$accessToken['oauth_token'],$accessToken['oauth_token_secret']);\n\t\t$validator = $gotAuth->OAuthRequest('https://twitter.com/account/verify_credentials.json', array(),'GET');\n\t\tif (!$validator) {\n\t\t\techo(\"Validator problems\");\n\t\t\tdie();\n\t\t}\n\t\t$new_data = json_decode($validator);\n\t\t//print_r($new_data);\n\t\t$new_pen =& TweetUser::getTweetUser( $new_data -> screen_name );\n\t\tif($new_pen -> ClassName == 'TweetUser'){ // Twitter Usernames need to be promoted\n\t\t $new_pen = $new_pen -> newClassInstance(\"PenName\");\n\t\t $new_pen->write();\n\t\t}\n\t\t$new_pen->request_token = $accessToken['oauth_token'];\n\t\t$new_pen->request_token_secret = $accessToken['oauth_token_secret'];\n\t\t$new_data -> twitter_id = $new_data -> id;\n\t\tunset($new_data -> id);\n\t\tPleaseMap::object2object($new_pen,TweetUser::$friendships_create,$new_data);\n\t\t$new_pen->write();\n\n\t\t$wayBack = Session::get('pre_auth');\n\t\terror_log(\"Way Back = $wayBack\");\n\t\tglobal $userState;\n\t\tswitch ($userState) {\n\t\t case 'anonymous':\n\t\t Page_Controller::sessionInfo('UserState',true,'AttendingClub');\n\t\t // create a socialite reference a dummy profile, that has links to the Standard Queries\n\t\t $pro = DataObject::get_one('Profile','`Name`=\"'. $new_pen->screen_name .'\"' );\n\t\t if (!$pro) {\n\t\t\t$pro = new Profile();\n\t\t\t$pro -> Name = $new_pen->screen_name;\n\t\t\t$pro -> write();\n\t\t }\n\t\t $this->profile = $this->mentee = $pro;\n\t\t // $this->standardPanes($new_pen); \n\t\t // This socialite has NO panes, panes will be generated from \n\t\t // Organizer's panes on the fly\n\t\t //\n\t\t $new_pen -> ProfileID = $this->profile->ID;\n\t\t $new_pen -> write();\n\t\t Session::set('socialiteProfileID', $this->profile->ID );\n\t\t PenName::getSessionPenName($new_pen->ID,true);\n\t\t break;\n\t\t case 'loggedIn':\n\t\t // we just need to attach this new pen name to the existing logged in\n\t\t // user's profile\n\t\t if($new_pen -> ClassName == 'PenName'){ // Twitter Usernames need to be promoted\n\t\t\t $new_pen = $new_pen -> newClassInstance(\"UsersPenName\");\n\t\t\t $new_pen->write();\n\t\t\tToDo::insureToDoItem('InternalToDo', $new_pen, 'maintainMe');\n\t\t }\n\t\t $new_pen -> ProfileID = $this->profile->ID;\n\t\t $new_pen -> write();\n\n\t\t if ($this->PenNames->count() == 0) {\n\t\t\t// that is, this is the very, very first pen name for this account\n\t\t\t // generate the standard Panes for this user from the Organizer\n\t\t\t $pd = new PaneDef();\n\t\t\t $pd -> setOrganizer($this->Organizer);\n\t\t\t $pd -> setMentee($new_pen);\n\t\t\t $pd -> deepCopy();\n\t\t }\n\n\t\t $wayBack = $this->Link();\t\n\t\t break;\n\t default: \n\t\t error_log(\"Bad state when validating from Twitter authorization: $userState\");\n\t\t die();\n\t\t}\n\n\t\terror_log(\"Way Back = $wayBack\");\n\t\tDirector::Redirect($wayBack );\t\n\t}", "public function suggest_user()\n {\n }", "public function index( $deck_id=null ){\n\t\t$deck_id = $this->params['url']['deck_id'];\n\t\t$this->set('deck_id', $deck_id);\n=======\n\t/* var $uses = [ 'User' ]; */\n \n public function index( $deck_id=null ){\n\t\t\n>>>>>>> origin/master\n\t\t$this->paginate = array(\n\t\t\t\t\t\t\t\t'order' => array('Card.id'=>'asc'),\n\t\t\t\t\t\t\t\t'conditions' => [\n\t\t\t\t\t\t\t\t\t'Card.deck_id' => $deck_id\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t'limit' => 1\n\t\t\t\t\t\t\t);\n\t\t$cards = $this->paginate('Card');\n $this->set(compact('cards'));\n<<<<<<< HEAD\n\t\t\n\n\n\t\t\n=======\n>>>>>>> origin/master\n\t}\n\t\n\tpublic function add(){\n\t\t$deck_id = $this->params['url']['deck_id'];\n\t\t$this->set('deck_id', $deck_id);\n\t\t\n\t\t\n\t\t\n\t\t\t$d_id = isset($this->request->query['$d_id']) ? $this->request->query['$d_id'] : null;\n\t if ($this->request->is('post')) {\n $this->Card->create();\n if ($this->Card->save($this->request->data)) {\n $this->redirect(array('action' => 'index','?' => array('deck_id' => $deck_id )));\n\t\t\t\t$this->Session->setFlash(__('The card has been created'));\n $this->redirect(array('action' => 'index','?' => array('deck_id' => $deck_id )));\n } \n }\n }\n \n}", "function add_knop($id) {\n array_push($this->knoppen, $id);\n }" ]
[ "0.55016166", "0.5363121", "0.51900893", "0.51447725", "0.5129983", "0.5080833", "0.49913675", "0.49818778", "0.4944377", "0.4924034", "0.4897922", "0.47399318", "0.47293985", "0.46907994", "0.46374157", "0.46301258", "0.46125937", "0.46069613", "0.46053675", "0.46038055", "0.46007684", "0.45963883", "0.4593655", "0.45932993", "0.4589095", "0.4587171", "0.45839608", "0.45812735", "0.4581258", "0.45558476" ]
0.6049594
0
Update an snack object
public function updateSnack($request){ $snack = $this->snackDetails($request->user(), $request->id); $snack->snack_name = $request->name; $snack->pieces = $request->quantity; $snack->description = $request->description; $snack->save(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function update() {\r\n\t\t$this->_update();\r\n\t}", "public function update() {}", "public function update()\n {\n }", "public function update() { }", "public function update() { }", "protected function _update()\n\t{\n\t}", "protected function update () {\n\n }", "protected function _update ()\n {\n $storage = $this->_make_storage ();\n $storage->update_object ($this);\n }", "public function update() {\t}", "public function update() {\r\n\t }", "protected function update()\n {\n }", "public function update()\n {\n //\n }", "public function update()\n {\n //\n }", "public function update()\n {\n //\n }", "public function update()\n {\n //\n }", "public function update()\n {\n //\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "public function update()\n {\n }", "protected function update(){\n\t}", "public function update () {\n }", "public function update()\n {\n\n }", "public function update()\n {\n\n }", "public function update()\n {\n\n }" ]
[ "0.61913824", "0.60100013", "0.59863967", "0.5940381", "0.5940381", "0.58984816", "0.58953786", "0.58876383", "0.5887018", "0.5871767", "0.58697414", "0.5834883", "0.5834883", "0.5834883", "0.5834883", "0.5834883", "0.5811063", "0.5811063", "0.5811063", "0.5811063", "0.5811063", "0.5811063", "0.5811063", "0.5811063", "0.5811063", "0.5803282", "0.5789388", "0.5776078", "0.5776078", "0.5776078" ]
0.7505615
0
/ recalculate the price using type and discount ptype => type of discount type=> use for food selection to let it become 0 in ptype 3
public static function calPrice($ptype,$discount,$price,$type) { $message =""; switch ($ptype) { case '1': $dis = $discount/100; $price *= $dis; $message = "Discount ".(100-$discount)." %"; break; case '2': $price -= $discount; if($price <= 0) { $price = 0; } $message = "Discount RM".$discount; break; case '3': $price = $type == 1 ? $discount : 0; $message = "Only RM".$discount; break; default: # code... break; } $data['price'] = $price; $data['message'] = $message; return $data; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function getPrice($pid=0 , $discount=false){\n if($discount){\n\n }\n else{\n\n }\n\n }", "function lds_travel_discounted_price($original_price,$discount){\n\n $discounted_cost = (int)$original_price-(((int)$original_price * (int)$discount)/100);\n \n return round($discounted_cost);\n\n}", "function apply_discount($price, $discount, $precision=6) {\n if(!$discount) return $price;\n list($abs_discount, $perc_discount) = split_discount($discount);\n if($perc_discount) { \n if(!is_numeric($perc_discount)) return $price;\n $discount_factor = (100-$perc_discount) / 100;\n return round($price * $discount_factor, $precision);\n }\n if(!is_numeric($abs_discount)) return $price;\n return $price - $abs_discount;\n}", "function getProductRate($sell_type,$pid)\n\t {\t\n\t \n\t \tob_start();\n\t\t $sql=\"select * from \".INFINITE_PRODUCT_DETAIL.\" where product_id='\".$pid.\"'\";\n\t\t$result= $this->db->query($sql,__FILE__,__LINE__);\n\t\t$row= $this->db->fetch_array($result);\n\t\t ?>\n <input name=\"unit_price[]\" readonly=\"readonly\" style=\"width:100px\" class=\"cost\" value=\"<?php if($sell_type=='bundel' or $sell_type=='kg') echo $row['bundel_price']; else echo $row['pices_price']; ?>\" type=\"text\">\n <?php \n\t\t $html = ob_get_contents();\n\t\tob_end_clean();\n\t\treturn $html;\n\t }", "public static function getPromotioinPrice($price,$id,$type)\n\t{\n\t\t$promotion = self::getPromotion();\n\t\t\n\t\tif(empty($promotion))\n\t\t{\n\t\t\treturn $price;\n\t\t}\n\t\t\n\t\tif($type == 2 && $promotion->enable_selection == 0)\n\t\t{\n\t\t\treturn $price;\n\t\t}\n\n\t\t//$food->Price = self::calPrice($promotion->type_discount,$promotion->discount,$food->Price);\n\t\t\n\t\treturn self::findPromotionPrice($promotion,$price,$id,$type);\n\t}", "function price_calculator($data, $accessedBy = NULL){\n\n $free_artworks = 1;\n $pressproofprice = 0.00;\n $labels_per_rolls = '';\n $promotiondiscount = 0.00;\n $plainlabelsprice = 0.00;\n $label_finish = 0.00;\n\n $producttype = $data['producttype'];\n $labels = $data['labels'];\n $persheets = $data['persheets'];\n $menu = $data['menu'];\n $design = $data['design'];\n //$labeltype = $data['labeltype'];\n\n $labeltype = $this->home_model->get_db_column('digital_printing_process', 'Print_Type', 'name', $data['labeltype']);\n $ProductBrand = $this->ProductBrand($menu);\n\n if($producttype == 'sheet'){\n\n $sheets = ceil($labels/$persheets);\n //$sheets = $labels;\n // $labels = $persheets*$labels;\n\n $data=$this->product_model->ajax_price($sheets, $menu, $ProductBrand);\n $price = $data['custom_price'];\n $printprice = 0.00;\n $designprice = 0.00;\n $free_artworks = 1;\n\n if($labeltype=='Mono' || $labeltype=='Fullcolour'){\n $printprice = $this->home_model->calculate_printed_sheets($sheets, $labeltype, $design, $ProductBrand, $menu);\n $free_artworks = $printprice['artworks'];\n $designprice = $printprice['desginprice'];\n $printprice = $printprice['price'];\n }\n }else{\n\n\n $pressproof = $data['pressproof'];\n $rollfinish = $data['finish'];\n\n //$rolls = (isset($data['rolls']) and $data['rolls']!='')?$data['rolls']:'';\n\n $min_qty = $this->home_model->min_qty_roll($menu);\n\n if ($accessedBy != '' && $accessedBy == 'material_page') {\n $response = $this->home_model->rolls_calculation($min_qty, $persheets, $labels, \"\", $accessedBy);\n } else {\n $response = $this->home_model->rolls_calculation($min_qty, $persheets, $labels);\n }\n\n\n $labels = $response['total_labels'];\n $labels_per_rolls = $response['per_roll'];\n $sheets = $response['rolls'];\n\n\n $collection['labels'] = $labels;\n $collection['manufature'] = $menu;\n $collection['finish'] = $data['finish'];\n $collection['rolls'] = $sheets;\n $collection['labeltype'] = $labeltype;\n\n $price_res = $this->home_model->calculate_printing_price($collection);\n $promotiondiscount = $price_res['promotiondiscount'];\n $plainlabelsprice = $price_res['plainprice'];\n $label_finish = $price_res['label_finish'];\n\n\n //137.51*1.1 = 151.261\n $price = $plainprice = $price_res['final_price'];\n\n /*************** Roll Labels Price *************/\n $printprice = 0.00;\n $designprice = 0.00;\n $free_artworks = 10;\n if ($pressproof == 1) {\n $pressproofprice = 50.00;\n }\n /*************** Roll Labels Price *************/\n }\n\n\n\n\n //$('.nlabelfilter').trigger('mouseover');\n\n $delivery_txt = $this->shopping_model->delevery_txt();\n\n $ProductBrand = $this->ProductBrand($menu);\n\n\n if (preg_match(\"/A4 Labels/is\", $ProductBrand) || preg_match(\"/A5 Labels/is\", $ProductBrand)) { //For A5 Sheet Discount\n $mat_code = $this->home_model->getmaterialcode($menu);\n //For A5 Sheet Discount\n if (preg_match(\"/A5 Labels/is\", $ProductBrand)) {\n $material_discount = $this->home_model->check_material_discount($mat_code, 'A5');\n } else {\n $material_discount = $this->home_model->check_material_discount($mat_code, 'A4');\n }\n\n if ($material_discount) {\n $wpep_discount = (($price) * ($material_discount / 100));\n $wpep_discount = number_format($wpep_discount, 2, '.', '');\n $wpep_discount_txt = '<small class=\"discount_price\">' . symbol . $price . ' </small>';\n $price = number_format(($price - $wpep_discount), 2, '.', '');\n }\n }\n\n\n $plainprice = number_format($price,2,'.','');\n $price = $designprice+$printprice+$price+$pressproofprice;\n $price = number_format($price,2,'.','');\n\n $pressproofprice = number_format($pressproofprice,2,'.','');\n\n\n if (preg_match(\"/WPEP/i\", $menu) and $producttype == 'sheet') {\n $wpep_discount = (($plain) * (20 / 100));\n $price = number_format(($price - $wpep_discount),2,'.','');\n\n }\n\n $delivery_txt = '';\n if($price > 25){\n $delivery_txt = '<b> Free Delivery </b>';\n }\n\n $priceperlabels = number_format(($price/$labels),3,'.','');\n\n $price_array = array('price'=>$price,\n 'plainprint'=>($plainprice+$printprice),\n 'plainprice'=>$plainprice,\n 'printprice'=>$printprice,\n 'designprice'=>$designprice,\n 'pressproof'=>$pressproofprice,\n 'priceperlabels'=>$priceperlabels,\n 'artworks'=>$free_artworks,\n 'nodesing'=>$design,\n 'sheets'=>$sheets,\n 'rolls'=>$sheets,\n 'labels'=>$labels,\n 'labels_per_rolls'=>$labels_per_rolls,\n 'delivery_txt'=>$delivery_txt,\n 'promotiondiscount'=>$promotiondiscount,\n 'plainlabelsprice'=>$plainlabelsprice,\n 'label_finish'=>$label_finish);\n return $price_array;\n\n\n }", "function get_price_adjustments_summary( $type, $pre_or_post = 'both', $price = false ){\n\t\tif( $pre_or_post == 'both' ){\n\t\t\t$adjustment_summary_pre = $this->get_price_adjustments_summary($type, 'pre');\n\t\t\t$adjustment_summary_post = $this->get_price_adjustments_summary($type, 'post'); \n\t\t\treturn $adjustment_summary = array_merge($adjustment_summary_pre, $adjustment_summary_post);\n\t\t}\n\t\t$adjustments = $this->get_price_adjustments($type);\n\t\t$adjustment_summary = array();\n\t\tif( $price === false ){\n\t\t\tif( $pre_or_post == 'post' ){\n\t\t\t\t$price = $this->get_price_pre_taxes() + $this->get_price_taxes();\n\t\t\t}else{\n\t\t\t\t$price = $this->get_price_base();\n\t\t\t}\n\t\t}\n\t\tforeach($adjustments as $adjustment){\n\t\t\t$adjustment_amount = 0;\n\t\t\tif( !empty($adjustment['amount']) ){\n\t\t\t\tif( !empty($adjustment['tax']) && $adjustment['tax'] == $pre_or_post ){\n\t\t\t\t\tif( !empty($adjustment['type']) ){\n\t\t\t\t\t\t$adjustment_summary_item = array('name' => $adjustment['name'], 'desc' => $adjustment['desc'], 'adjustment'=>'0', 'amount_adjusted'=>0, 'tax'=>$pre_or_post);\n\t\t\t\t\t\tif( $adjustment['type'] == '%' ){ //adjustment by percentage\n\t\t\t\t\t\t\t$adjustment_summary_item['amount_adjusted'] = round($price * ($adjustment['amount']/100),2);\n\t\t\t\t\t\t\t$adjustment_summary_item['amount'] = $this->format_price($adjustment_summary_item['amount_adjusted']);\n\t\t\t\t\t\t\t$adjustment_summary_item['adjustment'] = number_format($adjustment['amount'],2).'%';\n\t\t\t\t\t\t\t$adjustment_summary[] = $adjustment_summary_item;\n\t\t\t\t\t\t}elseif( $adjustment['type'] == '#' ){ //adjustment by amount\n\t\t\t\t\t\t\t$adjustment_summary_item['amount_adjusted'] = round($adjustment['amount'],2);\n\t\t\t\t\t\t\t$adjustment_summary_item['amount'] = $this->format_price($adjustment_summary_item['amount_adjusted']);\n\t\t\t\t\t\t\t$adjustment_summary_item['adjustment'] = $this->format_price($adjustment['amount']);\n\t\t\t\t\t\t\t$adjustment_summary[] = $adjustment_summary_item;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn $adjustment_summary;\n\t}", "public function calculateDiscount(): float\n {\n $discount = $this->checkCustomerDiscount(); //get the chosen discount\n //set the variable to group or customer to know where the percentage comes from\n $groupOrCustumor = \"\";\n if (!empty($this->calculation)){\n if ($this->calculation[0] === 'customer'){\n $groupOrCustumor = 'Customer';\n } else {\n $groupOrCustumor = 'Group';\n }\n $this->calculation = []; //empty calculation again so we don't get errors\n }\n $price = $this->product->getProductprice(); //get the price\n $quantityDisc = ($price/100) * $this->quantity; //the value of the quantity discount to substract\n $price = $price - $quantityDisc; //result of price minus quantity discount\n //if the customer and the group have a variable discount\n if ($discount[2]) {\n $percentage = ($price / 100) * $this->discount;\n $total = $price - $percentage;\n array_push($this->calculation, 'Quantity discount: ' . $this->quantity . '%', $groupOrCustumor . ': ' . $this->discount . '%'); //push the price calculation\n //if the group has a variable discount and the customer has a fixed discount\n } elseif ($discount[1] == true && $this->customer->getFixedDiscounts() != null) {\n $total = $price - ($this->customer->getFixedDiscounts()) * 100;\n $percentage = ($total / 100) * $this->discount;\n $total = $total - $percentage;\n array_push($this->calculation, 'Quantity discount: ' . $this->quantity . '%', 'Customer: €' . $this->customer->getFixedDiscounts(), 'Group: ' . $this->discount . '%'); //push the price calculation\n //if the group has a fixed discount and the customer a variable discount\n } elseif ($discount[1] == false && $this->customer->getVarDiscount() != null) {\n $total = $price - $discount[0];\n $percentage = ($total / 100) * $this->customer->getVarDiscount();\n $total -= $percentage;\n array_push($this->calculation, 'Quantity discount: ' . $this->quantity . '%', 'Group: €' . $discount[0]/100, 'Customer: ' . $this->customer->getVarDiscount() . '%'); //push the price calculation\n //else the group and the customer have a fixed discount\n } else {\n $total = $price - $discount[0];\n $total -= $this->customer->getFixedDiscounts();\n array_push($this->calculation, 'Quantity discount: ' . $this->quantity . '%', 'Group: €' . $discount[0]/100, 'Customer: €' . $this->customer->getFixedDiscounts()); //push the price calculation\n }\n //if the total price is negative change total price to zero\n if ($total < 0) {\n $total = 0;\n }\n //change the total price from cents to euro's\n $total = $total / 100;\n return $total;\n }", "function get_price_adjustments( $type ){\n\t\t$adjustments = array();\n\t\tif( !empty($this->booking_meta[$type]) && is_array($this->booking_meta[$type]) ){\n\t\t\t$adjustments = $this->booking_meta[$type];\n\t\t}\n\t\t//run this filter to be backwards compatible, e.g. em_booking_get_price_discount\n\t\tif( $type == 'discounts' ){\n\t\t\t$adjustments = apply_filters('em_booking_get_price_discounts', $adjustments, $this);\n\t\t}\n\t\treturn apply_filters('em_booking_get_price_adjustments', $adjustments, $type, $this);\n\t}", "protected static function findPromotionPrice($promotion,$price,$id,$type)\n\t{\n\n\t\t$arrayLimit = DetectPromotionController::getDailyList($id,$promotion->id,$promotion->type_promotion);\n\t\t$food = Food::findOne($id);\n\t\tif(empty($arrayLimit))\n\t\t{\n\t\t\t\n\t\t\treturn $price;\n\t\t}\n\n\t\t$data = $price;\n\t\t$dailyLimit = $arrayLimit['daily'];\n\t\t$limit =$arrayLimit['limit'];\n\t\t\n\t\tif($dailyLimit->food_limit < $limit->food_limit)\n\t\t{\n\t\t\t$data = self::calPrice($promotion->type_discount,$promotion->discount,$price,$type);\n\t\t\t$data['left'] = $limit->food_limit - $dailyLimit->food_limit;\n\t\t}\n\t\t\n\t\treturn $data;\n\t}", "function discountManage($copon, $user_id, $total_price) {\n //$query = \"SELECT value,value_type,coupon_code,id FROM `nfw_coupon` WHERE CURDATE() between start_date and end_date and coupon_code = '$copon' \";\n $query = \"SELECT value,value_type,coupon_code,id FROM `nfw_coupon` \n WHERE id not in(select coupon_id from nfw_product_order) \n and coupon_code not in(SELECT reference_id FROM `nfw_wallet`)\n and CURDATE() between start_date and end_date and coupon_code = '$copon' \";\n $result = resultAssociate($query);\n //print_r($result);\n $dte1 = date('Y-m-d H:i:s');\n if ($result) {\n\n $val1 = $result[0]['value'];\n $val_type = $result[0]['value_type'];\n //echo $total_price;\n $temp = array();\n\n if ($val_type == '%') {\n $data = ($total_price * $val1) / 100;\n }\n if ($val_type == 'Fixed') {\n $data = $val1;\n }\n\n $temp['coupon_id'] = $result[0]['id'];\n $temp['coupon_code'] = $result[0]['coupon_code'];\n $temp['value_code'] = $data;\n } else {\n $temp = array();\n }\n\n return $temp;\n }", "public function price(){\n\t\t\n\t\tif( is_null($this->priceArray) ){\n\t\t\t$this->priceArray = $this->prices();\n\t\t}\n\t\t\n\t\t//echo json_encode($this->priceArray) . \"\\n\";\n\t \n\t\t$amount = 0;\n\t\t\n\t\tif($this->type_id == 1){\n\t\t\t$amount += $this->priceNationalTriEye();\n\t\t}elseif($this->type_id == 2){\n\t\t\t$amount += $this->priceNationalSingleEye();\n\t\t}elseif($this->type_id == 3){\n\t\t\t$amount += $this->priceStateTriEye();\n\t\t}elseif($this->type_id == 4){\n\t\t\t$amount += $this->priceCountyTriEye();\n\t\t}elseif($this->type_id == 5){\n\t\t\t$amount += $this->priceFederalTriEye();\n\t\t}elseif($this->type_id == 6){\n\t\t\t$amount += $this->priceFederalState();\n\t\t}elseif($this->type_id == 7){\n\t\t\t$amount += $this->priceFederalDistrict();\n\t\t}elseif($this->type_id == 8){\n\t\t\t$amount += $this->priceEmployment();\n\t\t}elseif($this->type_id == 9){\n\t\t\t$amount += $this->priceEducation();\n\t\t}elseif($this->type_id == 10){\n\t\t\t$amount += $this->priceMvr();\n\t\t}elseif($this->type_id == 11){\n\t\t\t$amount += $this->priceHomeAuto();\n\t\t}elseif($this->type_id == 12){\n\t\t\t$amount += $this->pricePersonal();\n\t\t}elseif($this->type_id == 13){\n\t\t\t$amount += $this->priceHomeAuto();\n\t\t}\n\t\t\n\t\t\n\t\treturn $amount;\n\t\t\n }", "private function evaluate(string $discount, float $price) :float\n {\n $discountAmt = 0.00;\n if (preg_match(\"/^\\d+$/\", $discount)) {\n return (float) $discount;\n } elseif (preg_match(\"/^(\\d+)\\/(\\d+)$/\", $discount, $matches)) {\n $numer = $matches[1];\n $denom = $matches[2];\n \n $rate = (float) $numer/$denom;\n $discountAmt = $rate * $price;\n } \n \n return $discountAmt;\n }", "public function calculatePricePT()\n {\n//\t\tvar_dump($this->Price_pT_Base_override).\"<br>\";\n\t\tif(isset($this->Price_pT_Base_override) && $this->Price_pT_Base_override != \"\")\n\t\t\t{\n//\t\t\techo \"Price over ride<br>\";\n\t\t\t$this->Price_Sub_Total = $this->Price_pT_Base_override + $this->Price_production_pT + $this->Price_transport_pT;\t\n\t\t\t}\n\t\telse{\n\t\t\t//First calculate the price per ton, which is the sum of the ingedients->product price per tom\n\t \t\t$sum = 0;\n\t\t\tforeach($this->ingredients as $ingredientItem)\n\t\t\t\t{\n\t\t\t\t$sum += $ingredientItem->weightedCost;\n\t\t\t\t}\n\t\t\t$this->Price_pT_Base = $sum;\n\t\t\t$this->Price_Sub_Total = $this->Price_pT_Base + $this->Price_production_pT + $this->Price_transport_pT;\n\t\t}\n\t\t\n\n\t\t\n }", "private function ProductDiscount() {\n\t\t$this->ProductDiscountPercentage();\n\t\tif ($this->_datafield) {\n\t\t\tif ($this->is_percent) {\n\t\t\t\t$this->amount = substr(str_replace(\",\",\".\",$this->_datafield), 0, -1);\n\t\t\t}\n\t\t\telse $this->amount = str_replace(\",\",\".\",$this->_datafield);\n\t\t}\n\t}", "function calculate_price(){\n\t\t//any programatic price adjustments should be added here, otherwise you need to run this function again\n\t\tdo_action('em_booking_pre_calculate_price', $this);\n\t //reset price and taxes calculations\n\t $this->booking_price = $this->booking_taxes = null;\n\t //get post-tax price and save it to booking_price\n\t $this->booking_price = apply_filters('em_booking_calculate_price', $this->get_price_post_taxes(), $this);\n\t return $this->booking_price; \n\t}", "function xtcGetOptionPrice($pID, $option, $value, $qty = 1) {\n $price = $discount = $attributes_weight = 0;\n \n $dataArr = array(\n 'weight' => 0,\n 'price' => 0,\n 'discount' => 0,\n 'qty' => $qty,\n 'weight_prefix' => '',\n 'price_prefix' => ''\n );\n \n $attribute_query = xtDBquery(\n \"SELECT p.products_discount_allowed,\n p.products_tax_class_id,\n p.products_price,\n p.products_weight,\n pa.*\n FROM \" . TABLE_PRODUCTS_ATTRIBUTES . \" pa\n JOIN \" . TABLE_PRODUCTS . \" p\n ON p.products_id = pa.products_id\n WHERE pa.products_id = '\" . (int)$pID . \"'\n AND pa.options_id = '\" . (int)$option . \"'\n AND pa.options_values_id = '\" . (int)$value . \"'\n \");\n \n if (xtc_db_num_rows($attribute_query, true) > 0) {\n $attribute_data = xtc_db_fetch_array($attribute_query, true);\n \n // calculate weight\n $attributes_weight = $attribute_data['options_values_weight'];\n if ($attribute_data['weight_prefix'] != '+') {\n $attributes_weight *= -1;\n }\n \n // calculate discount\n if ($this->cStatus['customers_status_discount_attributes'] == '1' && $this->cStatus['customers_status_discount'] != 0.00) {\n $discount = $this->cStatus['customers_status_discount'];\n if ($attribute_data['products_discount_allowed'] < $this->cStatus['customers_status_discount']) {\n $discount = $attribute_data['products_discount_allowed'];\n }\n }\n \n // calculate price and several currencies on product attributes\n $CalculateCurr = (($attribute_data['products_tax_class_id'] == 0) ? true : false);\n $price = $this->xtcFormat($attribute_data['options_values_price'], false, $attribute_data['products_tax_class_id'], $CalculateCurr);\n if ($attribute_data['price_prefix'] == '+') {\n $price = $price - ($price / 100 * $discount);\n } else {\n $price *= -1;\n }\n \n $dataArr = array(\n 'weight' => $attributes_weight,\n 'price' => $price,\n 'discount' => $discount,\n 'qty' => $qty,\n 'weight_prefix' => $attribute_data['weight_prefix'],\n 'price_prefix' => $attribute_data['price_prefix']\n );\n \n //new module support\n $dataArr = $this->priceModules->GetOptionPrice($dataArr,$attribute_data,$pID, $option, $value, $qty);\n }\n return $dataArr;\n }", "function get_price($type, $regular, $sales) {\n\t\n\t// Prices are handled different based upon the product type:\n\tif ($type == 'coffee') {\n\t\t\n\t\t// Only add the sale price if it's greater than 0 \n\t\t// and less than the regular price:\n\t\tif ((0 < $sales) && ($sales < $regular)) {\n\t\t\treturn ' Sale: $' . $sales . '!';\n\t\t}\n\t\t\n\t} elseif ($type == 'goodies') {\n\t\t\n\t\t// Display the sale price if it's greater than 0\n\t\t// and less than the regular price:\n\t\tif ((0 < $sales) && ($sales < $regular)) {\n\t\t\treturn \"<strong>Sale Price:</strong> \\$$sales! (normally \\$$regular)<br />\";\n\t\t} else {\n\t\t\t// Otherwise, display the regular price:\n\t\t\treturn '<strong>Price:</strong> $' . $regular . '<br />';\t\t\t\n\t\t}\t\t\n\t\t\n\t}\n\t\n}", "public function ajaxUpdatePrice()\n {\n $templateId = Input::get('product_id'); \n $template = CardTemplate::find($templateId);\n \n $price = 0;\n $sets = 1;\n $discountPercent = 0;\n \n if(Input::get('custom_set') != '1') \n {\n //normal quantity\n \n $discountId = Input::get('discount'); \n $quantityId = Input::get('quantity'); \n \n $discount = CardDiscount::find($discountId);\n $quantity = CardQuantity::find($quantityId);\n if(isset($template->id) && isset($quantity->id))\n {\n $sets = 1;\n $basePrice = $template->basePrice($quantityId);\n \n if(isset($discount->id))\n {\n $discountPercent = min($discount->percent, 100);\n $sets = $discount->sets;\n }\n\n $price = $basePrice * $sets; \n }\n }\n else\n {\n //get custom set's quantities\n $quantities = Input::get('custom-quantity');\n if(is_array($quantities))\n {\n foreach($quantities as $quantityId)\n {\n //calculate option prices\n $price += $template->basePrice($quantityId); \n } \n \n $discountPercent = CardDiscount::getSetDiscount($template->card_id, count($quantities)); \n } \n }\n \n $discountPercent = max($discountPercent, $template->getPromotionDiscount());\n $price = $price * (100 - $discountPercent) / 100; \n \n echo format_currency($price);\n }", "private function calculateDiscountPrice(&$order, &$discount)\n {\n /* Calculate the new discounted total price */\n $total = 0;\n foreach ($order['items'] as &$item) {\n if (!array_key_exists('discounted_price', $item)) {\n $item['discounted_price'] = $item['total'];\n }\n $total = $total + $item['discounted_price'];\n }\n /* Apply discounts that require the new total price */\n if($this->arraySearch($discount['applied_discounts'], 'id', 1)){\n $total = $total - (10 * $total) / 100;\n }\n $discount['discounted_price'] = $total;\n return;\n }", "function get_price_adjustments_amount( $type, $pre_or_post = 'both', $price = false ){\n\t\t$adjustments = $this->get_price_adjustments_summary($type, $pre_or_post, $price);\n\t\t$adjustment_amount = 0;\n\t\tforeach($adjustments as $adjustment){\n\t\t\t$adjustment_amount += $adjustment['amount_adjusted'];\n\t\t}\n\t\treturn $adjustment_amount;\n\t}", "public function price(): float;", "function price_update($id,$type)\n{\nglobal $ds;\nglobal $dr;\nglobal $db;\nglobal $dd;\nglobal $site_servers;\nglobal $site_server_activ;\n\nif($type==\"photo\"){$table_name=\"sizes\";}\nif($type==\"video\"){$table_name=\"video_types\";}\nif($type==\"audio\"){$table_name=\"audio_types\";}\nif($type==\"vector\"){$table_name=\"vector_types\";}\n\n\t$sql=\"select id_parent,name from licenses order by priority\";\n\t$dr->open($sql);\n\twhile(!$dr->eof)\n\t{\n\t\t$sql=\"select * from \".$table_name.\" where license=\".$dr->row[\"id_parent\"].\" order by priority\";\n\t\t$ds->open($sql);\n\t\twhile(!$ds->eof)\n\t\t{\n\t\t\t$sql=\"select price,url,shipped from items where id_parent=\".(int)$id.\" and price_id=\".$ds->row[\"id_parent\"];\n\t\t\t$dd->open($sql);\n\t\t\tif(!$dd->eof)\n\t\t\t{\n\t\t\t\tif(isset($_POST[$type.\"_chk\".$ds->row[\"id_parent\"]]))\n\t\t\t\t{\n\t\t\t\t\t$sql=\"update items set price=\".(float)$_POST[$type.\"_price\".$ds->row[\"id_parent\"]].\" where id_parent=\".(int)$id.\" and price_id=\".$ds->row[\"id_parent\"];\n\t\t\t\t\t$db->execute($sql);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t$sql=\"delete from items where id_parent=\".(int)$id.\" and price_id=\".$ds->row[\"id_parent\"];\n\t\t\t\t\t$db->execute($sql);\n\t\t\t\t\n\t\t\t\t\tif($dd->row[\"shipped\"]!=1)\n\t\t\t\t\t{\n\t\t\t\t\t\tif($type!=\"photo\")\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$url=site_root.$site_servers[$site_server_activ].\"/\".(int)$id.\"/\".$dd->row[\"url\"];\n\t\t\t\t\t\t\tif(file_exists($_SERVER[\"DOCUMENT_ROOT\"].$url))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t@unlink($_SERVER[\"DOCUMENT_ROOT\"].$url);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\t\n\t\t\t\tif(isset($_SESSION['entry_admin']))\n\t\t\t\t{\n\t\t\t\t\tif($type==\"photo\")\n\t\t\t\t\t{\n\t\t\t\t\t\t$photo_file=get_photo_file($id);\n\t\t\t\t\t\tif($photo_file!=\"\" and isset($_POST[$type.\"_chk\".$ds->row[\"id_parent\"]]))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sql=\"insert into items (id_parent,name,url,price,priority,shipped,price_id) values (\".$id.\",'\".$ds->row[\"title\"].\"','\".$photo_file.\"',\".(float)$_POST[$type.\"_price\".$ds->row[\"id_parent\"]].\",\".$ds->row[\"priority\"].\",0,\".$ds->row[\"id_parent\"].\")\";\n\t\t\t\t\t\t\t$db->execute($sql);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t$ds->movenext();\n\t\t}\n\t$dr->movenext();\n\t}\n}", "abstract function getPrice();", "function fn_rma_recalculate_order_routine(&$order, &$item, $mirror_item, $type = '', $ex_data = array())\n{\n $amount = 0;\n if (!isset($item['extra']['exclude_from_calculate'])) {\n if (in_array($type, array('M+', 'M-O+'))) {\n $sign = ($type == 'M+') ? 1 : -1;\n\n $delta = ($mirror_item['price'] * $mirror_item['extra']['returns'][$ex_data['return_id']]['amount']);\n $order['subtotal'] = $order['subtotal'] + $sign * $delta;\n $order['total'] = $order['total'] + $sign * $delta;\n\n $_discount = isset($mirror_item['extra']['discount']) ? $mirror_item['extra']['discount'] : (isset($item['extra']['discount']) ? $item['extra']['discount'] : 0);\n $order['discount'] = $order['discount'] + $sign * $_discount * $item['amount'];\n unset($mirror_item['extra']['discount'], $item['extra']['discount']);\n }\n if (in_array($type, array('O-', 'M-O+'))) {\n $amount = fn_rma_recalculate_product_amount($item['item_id'], $item['product_id'], @$item['extra']['product_options'], $type, $ex_data);\n }\n } else {\n if (in_array($type, array('O-', 'M-O+'))) {\n fn_rma_recalculate_product_amount($item['item_id'], $item['product_id'], @$item['extra']['product_options'], $type, $ex_data);\n }\n }\n\n fn_set_hook('rma_recalculate_order', $item, $mirror_item, $type, $ex_data, $amount);\n}", "public function getPrice(string $type = 'default', ?string $currency = null): ?float;", "function discount_admin_content_type_submit($form, &$form_state) {\n // Remove internal Form API values.\n unset($form_state['values']['form_id'], $form_state['values']['form_token'], $form_state['values']['form_build_id'], $form_state['values']['op']);\n\n $product_types = array();\n \n // Setting up the price field for the selected content types.\n $content_types = $form_state['values']['discount_content_types'];\n \n // Unset to prevent 'double' save\n unset($form_state['values']['discount_content_types']);\n \n if (!empty($content_types) && is_array($content_types)) {\n foreach (discount_get_fields() as $field_name => $field_) {\n // Check to see if the field already exists.\n $field = field_info_field($field_name);\n // If the field does not exist then create it.\n if (empty($field)) {\n $field = array(\n 'field_name' => $field_name,\n 'type' => $field_['type'],\n 'entity_types' => array('node'),\n );\n field_create_field($field);\n }\n }\n \n foreach ($content_types as $type => $checked) {\n \n // If a node type is checked, then create the price field.\n if ($checked) {\n // Save content_type as a product.\n $product_types[$type] = $type;\n \n foreach (discount_get_fields() as $field_name => $field_) {\n // Foreach checked content type, we must assign the price field to the content type.\n $instance = field_info_instance('node', $field_name, $type);\n\n if (empty($instance)) {\n $instance = array(\n 'field_name' => $field_name,\n 'label' => $field_['title'],\n 'description' => $field_['description'],\n 'entity_type' => 'node',\n 'bundle' => $type,\n );\n // It doesn't exist. Create it.\n field_create_instance($instance);\n }\n }\n }\n // If not, then delete the instance.\n else {\n foreach (discount_get_fields() as $field_name => $field_) {\n $instance = field_info_instance('node', $field_name, $type);\n if (!empty($instance)) {\n field_delete_instance($instance);\n }\n }\n }\n }\n }\n\n variable_set('discount_content_types', $product_types);\n \n // Set VAT to nothing if the checkbox is unchecked.\n if (empty($form_state['values']['discount_vat_state'])) {\n $form_state['values']['discount_vat_value'] = '';\n // Check to see if the VAT instance exists and if so, delete it.\n if (module_exists('discount_order')) {\n $instance = field_info_instance('node', 'vat', 'order');\n if (!empty($instance)) {\n field_delete_instance($instance);\n }\n }\n }\n else {\n // If the enable VAT checkbox is checked and if discount_order is enabled,\n // then create the vat field for the Order content type.\n if (module_exists('discount_order')) {\n // Check to see if the vat field already exists.\n $vat = field_info_field('vat');\n // If the vat field does not exist then create it.\n if (empty($vat)) {\n $vat = array(\n 'field_name' => 'vat',\n 'type' => 'number_decimal',\n 'entity_types' => array('node'),\n );\n field_create_field($vat);\n\n // Assign the vat field to the Order content type.\n $instance = field_info_instance('node', 'vat', 'order');\n if (empty($instance)) {\n $instance = array(\n 'field_name' => 'vat',\n 'label' => t('VAT'),\n 'description' => t('The VAT tax.'),\n 'entity_type' => 'node',\n 'bundle' => 'order',\n );\n // It doesn't exist. Create it.\n field_create_instance($instance);\n }\n }\n }\n }\n \n // Save other variables.\n foreach ($form_state['values'] as $key => $value) {\n if (is_array($value) && isset($form_state['values']['array_filter'])) {\n $value = array_keys(array_filter($value));\n }\n variable_set($key, $value);\n }\n \n drupal_set_message(t('The configuration options have been saved.'));\n}", "function getPrice();", "function checkout() :int {\n $price = 200.1;\n $taxRate = 1.03;\n $FullPrice = $price * $taxRate;\n return $FullPrice;\n}", "public function calculateTotalPrice()\n {\n }" ]
[ "0.6805903", "0.6627509", "0.6547144", "0.63474244", "0.6307581", "0.6249852", "0.624451", "0.6231819", "0.62076795", "0.6137269", "0.6063061", "0.60604864", "0.60526544", "0.6046439", "0.6040904", "0.6026942", "0.5998348", "0.5997505", "0.5926959", "0.5893059", "0.5884117", "0.5881619", "0.58616215", "0.58526963", "0.584127", "0.5780658", "0.57801247", "0.5774256", "0.5771454", "0.57568526" ]
0.7570489
0
Returns a list of paginated coins
function index() { $coins = Coin::latest() ->paginate(10); return CoinResource::collection($coins); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getAllPaginated()\n {\n }", "public function index()\n {\n $this->authorize('list', Currency::class);\n\n return $this->ok($this->repo->paginate($this->request->all()));\n }", "function getInvoiceCoins($onlyActive = false){\n return getJSON(URL_INVOICECOINS, FILE_INVOICECOINS, $onlyActive);\n}", "function getAllAccounts(int $pageSize = 50, int $offset = 0){\nreturn $this->get(\"/ledger/account?pageSize={$pageSize}&offset={$offset}\");\n}", "public function paginate();", "public function balance_get_list($data)\n {\n $service = $this->di['mod_service']('Client', 'Balance');\n list($q, $params) = $service->getSearchQuery($data);\n $per_page = $this->di['array_get']($data, 'per_page', $this->di['pager']->getPer_page());\n $pager = $this->di['pager']->getSimpleResultSet($q, $params, $per_page);\n\n foreach($pager['list'] as $key => $item){\n $pager['list'][$key] = array(\n 'id' => $item['id'],\n 'description' => $item['description'],\n 'amount' => $item['amount'],\n 'currency' => $item['currency'],\n 'created_at' => $item['created_at'],\n );\n }\n\n return $pager;\n }", "public function index()\n {\n $billPays = $this->repository->paginate(8);\n\n return $billPays;\n }", "function findAllPaginated($perPage = 20);", "public function BorrowList(){\n\t\t\tglobal $DB, $GLOB, $BOOK;\n\t\t\t//lay thong tin so trang\n\t\t\tif(isset($_REQUEST['page_number'])){\n\t\t\t\t$page_num = intval($_REQUEST['page_number']);\n\t\t\t}else{\n\t\t\t\t$page_num = 1;\n\t\t\t}\n\t\t\t$bookperPage = 10;\n\t\t\t//glb\n\t\t\t$GLOB->obj_page_num = $page_num;\n\t\t\t//get max record\n\t\t\tif($data = $DB->query(\"SELECT sum(status) FROM borrow WHERE acpt='0' \")){\n\t\t\t\t$total = $data[0]['sum(status)'];\n\t\t\t}else{\n\t\t\t\t$total = 1;\n\t\t\t}\n\t\t\t$totalPage = ceil($total/$bookperPage);\n\t\t\t$GLOB->obj_page_total = $totalPage;\n\t\t\t$res = array();\n\t\t\t//Gioi han phan trang\n\t\t\t$start = ($page_num-1)*$bookperPage;\n\t\t\t$GLOB->TableStart = $start+1;\n\t\t\t$sql_add = \" ORDER BY id DESC LIMIT {$start}, {$bookperPage} \";\n\t\t\t//get data\n\t\t\tif($data = $DB->query(\"SELECT * FROM borrow WHERE acpt='0' {$sql_add} \")){\n\t\t\t\t$res = $data;\n\t\t\t}else{\n\t\t\t\t$res = false;\n\t\t\t}\n\t\t\treturn $res;\n\t\t}", "public function paginate()\n {\n return $this->customerService->paginate(request()->get('perPage', 10));\n }", "public function getCoins ()\n {\n\n $coins = file_get_contents('https://api.gdax.com/products');\n\n // Convert JSOn resource to object\n $coins = json_decode($coins);\n\n // Convert object to array\n $coins = json_decode(json_encode($coins) , TRUE);\n\n return $coins;\n\n }", "private function fetchPaginatedResults()\n {\n $select = new Select($this->tableGateway->getTable());\n\n // Create a new result set based on the Cours entity:\n $resultSetPrototype = new ResultSet();\n $resultSetPrototype->setArrayObjectPrototype(new Cours());\n\n // Create a new pagination adapter object:\n $paginatorAdapter = new DbSelect(\n // our configured select object:\n $select,\n // the adapter to run it against:\n $this->tableGateway->getAdapter(),\n // the result set to hydrate:\n $resultSetPrototype\n );\n\n $paginator = new Paginator($paginatorAdapter);\n\n return $paginator;\n }", "function getFullTransactionPaginated($dbh, $page, $rpp) {\n\t$q = $dbh->query($b = \"select address, txid, amount, block, 1000*blocktime from agsinfo where amount > 0 limit \" . ($page*$rpp) .\", \" . (($page*$rpp) + $rpp));\n\t$r = $q->fetchAll(PDO::FETCH_NUM);\n\treturn $r;\n}", "function extract_coins(){\r\n //Store the URL\r\n $url = \"https://api.coingecko.com/api/v3/coins/list\";\r\n //Initiate cURL to operate on API\r\n $curl = curl_init($url);\r\n //Set the Option to RETURNTRANSFER to fetch data from the API\r\n curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);\r\n //Execute the URl thorugh cURL\r\n $res = curl_exec($curl);\r\n //If any Error occurs from the API send the error DATA\r\n if(curl_errno($curl)){\r\n return array(\"id\"=> \"NULL\",\"name\" => \"Error : Could not find any coin\",\"symbol\"=>\"NULL\");\r\n }\r\n //Decode the JSON data sent from the API to an Associative Array\r\n $arr = json_decode($res,true);\r\n //Return the array\r\n return $arr;\r\n }", "public function index(Account $account)\n {\n return $account->transactions()->orderBy('id', 'desc')->paginate(15);\n }", "public function index()\n {\n $models = $this->model->paginate(25);\n $transformer = $this->transformer;\n return $this->response->paginator($models, $transformer);\n }", "public function getPaginate(){ }", "public function transaction_get_list($data)\n {\n $transactionService = $this->di['mod_service']('Invoice', 'Transaction');\n list ($sql, $params) = $transactionService->getSearchQuery($data);\n $per_page = $this->di['array_get']($data, 'per_page', $this->di['pager']->getPer_page());\n $pager = $this->di['pager']->getSimpleResultSet($sql, $params, $per_page);\n foreach ($pager['list'] as $key => $item) {\n $transaction = $this->di['db']->getExistingModelById('Transaction', $item['id'], 'Transaction not found');\n $pager['list'][$key] = $transactionService->toApiArray($transaction);\n }\n\n return $pager;\n }", "function getOrderCoins($onlyActive = false){\n return getJSON(URL_ORDERCOINS, FILE_ORDERCOINS,$onlyActive);\n}", "public function index()\n {\n $data = Master_balai::paginate(5);\n return $data;\n }", "private function get_from_db() {\n\t\t\t$start_from = ( $this->page-1 ) * KG_Config::getPublic('transactions_per_page_cocpit');\n\t\t\tglobal $wpdb;\n\t\t\t$data = $wpdb->get_results( \n\t\t\t\t$wpdb->prepare(\"\n\t\t\t\t\tSELECT * FROM \" . KG_Config::getPublic('table_transactions') . \"\n\t\t\t\t\tORDER BY {$this->sort_column} DESC\n\t\t\t\t\tLIMIT %d, %d\n\t\t\t\t\t\", \n\t\t\t\t\t $start_from, \n\t\t\t\t\t KG_Config::getPublic('transactions_per_page_cocpit')\n\t\t\t\t\t ),\n\t\t\t\tARRAY_A \n\t\t\t); \n\t\t\treturn $data;\n\t\t}", "public function index()\n {\n return TransactionResource::collection($this->service->paginate());\n }", "public static function currencyCoins() {\n\n $currencies = Coin::select(\n 'coins.coin_id AS coin_id',\n 'coins.coin_coin AS coin_coin',\n DB::raw('(amount - amount_inorder) AS current_balance')\n )\n ->join('wallet', 'coins.coin_id', '=', 'wallet.coin_id')\n ->where('wallet.user_id', Auth::id())\n ->where('coins.coin_enabled', 1)\n ->where(DB::raw('(amount - amount_inorder)'), '>', 0)\n ->get();\n\n return $currencies;\n }", "public function findAllWithPaginate($number)\n {\n $savoirs = Savoir::paginate($number);\n\n return $savoirs;\n }", "public function coinbaseAccounts()\n {\n return $this->httpGet('/coinbase-accounts', [], 'SIGN');\n }", "public function getPageList($limit, $offset);", "public function index()\n {\n $currencies = Currency::orderBy('id', 'DESC')->paginate(50);\n\n return response([\n 'currencies' => $currencies,\n ], 200);\n }", "public function getAllCurrencies()\n {\n $offset = @$this->input->post_get('offset');\n $limit = @$this->input->post_get('limit');\n $data = $this->posts->get_all_data('currency', $offset, $limit);\n $count = count($this->posts->get_all_data('currency'));\n $this->output->set_content_type('application/json')->set_output(json_encode(array('success' => true, 'data' => $data, 'count' => $count)));\n }", "public function getAll($paginate, $orderBy);", "public function getPaginator();" ]
[ "0.6496192", "0.63660485", "0.62806773", "0.6179738", "0.61161864", "0.611535", "0.6091838", "0.6050275", "0.6022879", "0.60074383", "0.60002285", "0.59722936", "0.59490615", "0.59325904", "0.58867997", "0.5852137", "0.5850961", "0.5849253", "0.58317614", "0.5826127", "0.5822924", "0.5794618", "0.5780261", "0.5768666", "0.5756234", "0.5748152", "0.5732195", "0.5701823", "0.56874937", "0.5684754" ]
0.6880276
0
Deletes a coin from the database
function destroy(Request $request, $id) { // Find the coin to be deleted. $coin = Coin::findOrFail($id); $coin->delete(); return json_encode("Coin Deleted"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function deleteFromDatabase();", "public function delete()\n {\n // deletes row from database\n $this->db->query('DELETE FROM ' . $this->db->tableName('house_auctions') . ' WHERE ' . $this->db->fieldName('house_id') . ' = ' . $this->data['house_id']);\n\n // resets object handle\n $this->data = array();\n }", "public function delete()\n {\n $this->db->delete(\"recyclebin\", $this->db->quoteInto(\"id = ?\", $this->model->getId()));\n }", "function delete() {\n\t\t$sql = \"DELETE FROM pa_payment\n\t\t\t\tWHERE pay_id=?\";\n\t\t$this->pa_db->query($sql, array($this->pay_id));\n\t}", "public function delete() {\n $mysqli = Database::getMYSQLI();\n \n $stmt = $mysqli->prepare(\"DELETE responses FROM responses WHERE id = ?\");\n \n $stmt->bind_param('i', $this->id);\n \n $stmt->execute();\n $stmt->close();\n $mysqli->close();\n }", "function deleteInDatabase(){\n }", "public function delete() {\n\t\t// Construct delete query\n $delete_query = \"DELETE FROM \" . static::$tableName . \" \"\n . $this->genPrimaryKeyWhereClause();\n\t\t// Execute delete query\n self::$database->query($delete_query);\n\t}", "function supprimePays($pays){\r\n $db = dbConnect();\r\n\r\n $statement = $db->prepare('DELETE FROM pays WHERE code_pays = :code_pays');\r\n $statement->bindParam(':code_pays',$pays);\r\n $statement->execute();\r\n}", "public function delete(){\n\n //fazer a conexao com o BD\n $sql = new Sql();\n \n //realiza a operacao de deletar\n $sql->query(\"DELETE FROM tb_orders WHERE idorder = :idorder\", [\n //faz o bind dos parametros\n ':idorder'=>$this->getidorder()//pega o objeto dentro da propria classe\n ]);\n\n }", "public function delete()\n\t{\n\t\t$statement = $this->dbObject->prepare(\n\t\t\t\"DELETE FROM `\"\n\t\t\t. strtolower(get_called_class())\n\t\t\t. \"` WHERE id = :id LIMIT 1;\");\n\n\t\t$statement->bindValue(\":id\", $this->id);\n\t\t$statement->execute();\n\n\t\t$this->id = 0;\n\t\t$this->isNew = true;\n\t}", "function deleteContatos($request, $response, $args)\r\n{ \r\n $id = $args['id'];\r\n $sql = \"delete from contato where id = \".$id;\r\n try {\r\n $db = getConnection();\r\n $db->exec($sql);\r\n $db = null;\r\n echo 'Deletado'; \r\n } catch(PDOException $e) {\r\n echo '{\"error\":{\"text\":'. $e->getMessage() .'}}'; \r\n }\r\n}", "public function delete() {\r\n $connection = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);\r\n \r\n if ($connection->connect_error) {\r\n echo $connection->connect_error;\r\n }\r\n // Prepare and bind\r\n $stmt = $connection->prepare(\"DELETE FROM posts WHERE id = ? LIMIT 1\");\r\n $stmt->bind_param(\"i\", $postId);\r\n \r\n // Set parameters and execute\r\n $postId = $this->id;\r\n $stmt->execute();\r\n \r\n $stmt->close();\r\n $connection->close();\r\n }", "public function delete_round() {\n $delete = 1;\n $query = \"UPDATE `rounds` SET `soft_delete`= :soft_delete \" \n . \" WHERE `id` = :id\";\n $values = array(\n ':id' => $_POST['id'],\n ':soft_delete' => $delete\n );\n $this->query_execute($query, $values); \n }", "private function delete() {\r\n\t\t$this->verifyAction('delete');\r\n\t\t$this->saveHistory('delete');\r\n\t\t$id=$this->getId();\r\n\t\tglobal $db;\r\n\t\t$deleteSql=\"delete from \".$this->tableName.\" where \".$this->idField.\"=?\";\r\n//\t\tdebug($deleteSql);\r\n\t\terror($db->query($deleteSql, array($id)));\r\n\t\techo \"<script>alert('删除成功。');window.location='?do=show';</script>\";\r\n\t}", "public function delete()\r\n\t{\r\n\t\t$sql = 'DELETE FROM '.static::$_table.' WHERE id=\"'.$this->_obj_id.'\"';\r\n\t\tself::db()->delete($sql);\r\n\t}", "public function delete() \n {\n \n $sql = 'DELETE FROM remembered_logins WHERE token_hash = :token_hash';\n\n $db = static::getDB();\n $stmt = $db->prepare($sql);\n\n $stmt->bindValue(':token_hash', $this->token_hash, PDO::PARAM_STR);\n\n $stmt->execute();\n\n }", "public function delete()\n {\n if ($this->isLoaded) {\n $sqlQuery = \"DELETE FROM `\" . $this->table\n . \"` WHERE $this->primaryKey = ?\";\n\n $statement = self::$dbh->prepare($sqlQuery);\n $statement->execute([$this->data[$this->primaryKey]]);\n $this->isLoaded = false;\n $this->data[$this->primaryKey] = null;\n } else {\n self::$logger->notice(\"You must load an entry before deleting\");\n }\n }", "public function delete() {\n\n // Does the Article object have an ID?\n if ( is_null( $this->id ) ) trigger_error ( \"Article::delete(): Attempt to delete an Article object that does not have its ID property set.\", E_USER_ERROR );\n\n // Delete the Article\n $conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );\n $stmt = $conn->prepare ( \"DELETE FROM articles WHERE id = :id LIMIT 1\" );\n $stmt->bindValue( \":id\", $this->id, PDO::PARAM_INT );\n $stmt->execute();\n $conn = null;\n }", "public static function delete($walletId)\n {\n\n try {\n $conn = &PDOData::connect();\n $stmt = $conn->prepare(\"DELETE FROM wallets WHERE id = :id\"); \n $stmt->bindParam(':id', $walletId);\n if ($stmt->execute()) {\n echo \"SUCCESS\";\n }else {\n echo \"FAILED\";\n } \n } catch(PDOException $e) {\n echo \"Connection failed: \" . $e->getMessage();\n }\n PDOData::disconnect();\n }", "public function delete(){\n $query = \"DELETE FROM manga WHERE id_manga = :id\";\n\t $result = $this->pdo->prepare($query);\n\t $result->bindValue(\"id\", $this->id_manga, PDO::PARAM_INT);\n\t $result->execute();\n }", "public function delete();", "public function delete();", "public function delete();", "public function delete();", "public function delete();", "public function delete();", "public function delete();", "public function delete();", "public function delete();", "public function delete();" ]
[ "0.70617384", "0.679481", "0.6749741", "0.65025675", "0.64572173", "0.6419238", "0.63800246", "0.63458407", "0.6326092", "0.6304102", "0.62709826", "0.6242775", "0.62184", "0.62072456", "0.6201183", "0.618151", "0.61646646", "0.61592156", "0.6143238", "0.61363804", "0.6136032", "0.6136032", "0.6136032", "0.6136032", "0.6136032", "0.6136032", "0.6136032", "0.6136032", "0.6136032", "0.6136032" ]
0.68469524
1
for to get to the word
public function ActionGetWord(){ return $this->blM->get(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function ActionGetWord(){\n return $this->blW->get();\n }", "function getTheWord($text, $firstPosition, $lastPosition)\n{\n return substr($text, $firstPosition,($lastPosition-$firstPosition));\n}", "function process_word($word)\n{\n $word=strtolower($word);\n switch($word)\n {\n case \"a\":\n case \"an\":\n case \"the\":\n case \"it\":\n case \"rt\":\n case \"to\":\n return \"\";\n }\n if(str_split($word)[0]==\"@\") return \"\";\n return $word;\n}", "function pspell_suggest($i, $word) {\n \n // exec\n $cmd = pspell_cmd($i, \"--suggest\");\n $word = escapeshellarg($word);\n $r = `echo $word | $cmd`;\n \n // \"&\" multiple matches\n if (preg_match(\"/^[\\&] (.+?) (\\d+) (\\d+): (.+)$/m\", $r, $uu)) {\n return preg_split(\"/,\\s*/\", $uu[4]);\n }\n else {\n //return($word); //@todo: native behaviour?\n }\n }", "public function word() {\n // get a word\n return $this->words[rand(0, count($this->words) - 1)]; \n }", "public function getWord()\n {\n return $this->word;\n }", "public function getWord()\n {\n return $this->word;\n }", "public function word()\n {\n return $this->word;\n }", "abstract public function getWord($vname,$default = null, $method = 'any');", "public function overview($word);", "function getWord( $wordFile, $chooseWord){\n\treturn strtolower(trim( $wordFile[$chooseWord]));\n}", "function analyseword($tok)\r\n\t{\r\n\t\t// Si c'est un nombre\r\n\t\tif (($tok[0] == '$') || ($tok[0] == '#') || ($tok == (string)intval($tok)))\r\n\t\treturn $this->formatspecialtok($tok, $this->colornumber, $this->stylenumber);\r\n\t\t// Si c'est vide, on renvoie une chaine vide\r\n\t\tif (empty($tok)) return $tok;\r\n\t\t// Si c'est un mot cle\r\n\t\tif ((($this->case_sensitive) && (is_integer(array_search($tok, $this->keywords, FALSE)))) ||\r\n\t\t((!$this->case_sensitive) && (is_integer($this->array_search_case($tok, $this->keywords)))))\r\n\t\treturn $this->formatspecialtok($tok, $this->colorkeyword, $this->stylekeyword);\r\n\t\t// Sinon, on renvoie le mot sans formattage\r\n\t\treturn $this->formatspecialtok($tok, $this->colortext, $this->styletext);\r\n\t}", "public function getWord()\r\n {\r\n return $this->gamePlay->getGuessedWord();\r\n }", "function fulltext($arg) {\r\n\t\t$x = $arg;\r\n\t\tswitch ($arg) {\r\n\t\t\tcase 'HEA':\r\n\t\t\t\t $x = \" HEALTH\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'SOC':\r\n\t\t\t\t $x = \" SOCIAL\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'POL':\r\n\t\t\t\t $x = \" POLITICAL\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'BUS':\r\n\t\t\t\t $x = \" BUSINESS\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'YOU':\r\n\t\t\t\t $x = \" YOUTH\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'LEG':\r\n\t\t\t\t $x = \" LEGAL\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'EDU':\r\n\t\t\t\t $x = \" EDUCATIONAL\";\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'PAS':\r\n\t\t\t\t $x = \" PASTORAL\";\r\n\t\t\t\tbreak;\t\t\t\r\n\t\t\tcase 'EVE':\r\n\t\t\t\t $x = \" SOCIAL & COMMUNITY EVENTS\";\r\n\t\t\t\tbreak;\t\t\t\r\n\t\t\tdefault:\r\n\t\t\t\techo \"No specific segment was chosen\";\r\n\t\t}\r\n\r\n\t\treturn ($x);\r\n\t\t}", "public function catchPhraseNoun()\n\t{\n\t\treturn static::randomElement(static::$noun);\n\t}", "function hello_karli() {\n\t$chosen = hello_karli_get_words();\n\techo \"<p id='karli'>$chosen</p>\";\n}", "public function catch_phrase()\n\t{\n\t\t$buzzwords = static::translate('faker.company.buzzwords');\n\t\t$words = array();\n\n\t\tforeach ($buzzwords as $group)\n\t\t{\n\t\t\t$words[] = $group[array_rand($group)];\n\t\t}\n\n\t\treturn implode(' ', $words);\n\t}", "private function words($text) {\r\n\t\t$matches = array();\r\n\t\tpreg_match_all(\"/[a-z]+/\",strtolower($text),$matches);\r\n\t\treturn $matches[0];\r\n\t}", "public function catchPhraseNoun()\n {\n return static::randomElement(static::$noun);\n }", "function translator($word,$dictionary){\n if(array_key_exists($word,$dictionary)){\n return $dictionary[$word];\n }else { return $word;}\n}", "function hl($text, $word) {\n if(!empty($_GET['hl']) && $_SESSION['search_type'] == 'text') {\n if($_SESSION['search_con'] == 'or') {\n $words = explode(\" \",$word);\n for($x=0;$x<count($words);$x++)\n $ret['text'] = preg_replace(\"#\".$words[$x].\"#i\",'<span class=\"fontRed\" title=\"'.$words[$x].'\">'.$words[$x].'</span>',$text);\n }\n else\n $ret['text'] = preg_replace(\"#\".$word.\"#i\",'<span class=\"fontRed\" title=\"'.$word.'\">'.$word.'</span>',$text);\n\n if(!preg_match(\"#<span class=\\\"fontRed\\\" title=\\\"(.*?)\\\">#\", $ret['text']))\n $ret['class'] = 'class=\"commentsRight\"';\n else\n $ret['class'] = 'class=\"highlightSearchTarget\"';\n } else {\n $ret['text'] = $text;\n $ret['class'] = 'class=\"commentsRight\"';\n }\n\n return $ret;\n}", "abstract function modifyWord($word);", "public function word($word)\n {\n $word = mb_strtolower($word);\n\n\n if (mb_strlen($word) <= 2)\n return $word;\n\n if ($this->_locale == 'ru')\n $word = str_replace('ё', 'е', $word);\n\n if ($this->_locale == 'uk')\n $word = str_replace('ґ', 'г', $word);\n\n # Check against cache of stemmed words\n if ($this->caching && isset($this->_cache[$word])) {\n return $this->_cache[$word];\n }\n\n $stem = $word;\n do {\n $start = null;\n $end = null;\n if (isset($this->_patterns['rvre'])) {\n\n if (!preg_match($this->_patterns['rvre'], $word, $p))\n break;\n\n $start = $p[1];\n $end = $p[2];\n }\n\n if (!$start || !$end)\n break;\n\n // Step 1\n if ($this->_locale == 'en') {\n\n // Part a\n if (mb_substr($end, -1) == 's') {\n $this->stringReplace($end, '/sses/', 'ss')\n OR $this->stringReplace($end, '/ies/', 'i')\n OR $this->stringReplace($end, '/ss/', 'ss')\n OR $this->stringReplace($end, '/s/', '');\n }\n\n // Part b\n if (\n mb_substr($end, -2, 1) != 'e'\n OR !$this->stringReplace($end, '/eed/', 'ee')\n ) { // First rule\n if (isset($this->_patterns['vowel'])) {\n\n // ing and ed\n if (\n $this->pregMatch(mb_substr($end, 0, -3), $this->_patterns['vowel']) &&\n $this->stringReplace($end, '/ing/', '')\n OR $this->pregMatch(mb_substr($end, 0, -2), $this->_patterns['vowel']) &&\n $this->stringReplace($end, '/ed/', '')\n ) { // Note use of && and OR, for precedence reasons\n\n // If one of above two test successful\n if (\n !$this->stringReplace($end, '/at/', 'ate')\n AND !$this->stringReplace($end, '/bl/', 'ble')\n AND !$this->stringReplace($end, '/iz/', 'ize')\n ) {\n\n // Double consonant ending\n if (isset($this->_patterns['consonant'])) {\n if (\n $this->doubleConsonant($end, $this->_patterns['consonant'])\n AND mb_substr($end, -2) != 'll'\n AND mb_substr($end, -2) != 'ss'\n AND mb_substr($end, -2) != 'zz'\n ) {\n $end = mb_substr($end, 0, -1);\n } else if (\n $this->mCount($end, $this->_patterns['vowel'], $this->_patterns['consonant']) == 1\n AND $this->cvcSequence($end, $this->_patterns['vowel'], $this->_patterns['consonant'])\n ) {\n $end .= 'e';\n }\n }\n }\n }\n\n // Step 1c\n if (\n mb_substr($end, -1) == 'y' &&\n $this->pregMatch(mb_substr($end, 0, -1), $this->_patterns['vowel'])\n ) {\n $this->stringReplace($end, '/y/', 'i');\n }\n }\n }\n\n } else if ($this->_locale == 'ru' || $this->_locale == 'uk') {\n\n if (isset($this->_patterns['perfectiveground']) && isset($this->_patterns['reflexive'])) {\n\n if (!$this->stringReplace($end, $this->_patterns['perfectiveground'], '')) {\n\n $this->stringReplace($end, $this->_patterns['reflexive'], '');\n\n if (isset($this->_patterns['adjective']) && isset($this->_patterns['participle'])) {\n\n if ($this->stringReplace($end, $this->_patterns['adjective'], '')) {\n\n $this->stringReplace($end, $this->_patterns['participle'], '');\n\n } else {\n\n if (isset($this->_patterns['verb']) && isset($this->_patterns['noun'])) {\n\n if (!$this->stringReplace($end, $this->_patterns['verb'], ''))\n $this->stringReplace($end, $this->_patterns['noun'], '');\n\n }\n\n }\n }\n }\n }\n }\n\n // Step 2\n if ($this->_locale == 'en') {\n switch (mb_substr($end, -2, 1)) {\n\n case 'a':\n $this->stringReplace($end, '/ational/', 'ate')\n OR $this->stringReplace($end, '/tional/', 'tion');\n break;\n\n case 'c':\n $this->stringReplace($end, '/enci/', 'ence')\n OR $this->stringReplace($end, '/anci/', 'ance');\n break;\n\n case 'e':\n $this->stringReplace($end, '/izer/', 'ize');\n break;\n\n case 'g':\n $this->stringReplace($end, '/logi/', 'log');\n break;\n\n case 'l':\n $this->stringReplace($end, '/entli/', 'ent')\n OR $this->stringReplace($end, '/ousli/', 'ous')\n OR $this->stringReplace($end, '/alli/', 'al')\n OR $this->stringReplace($end, '/bli/', 'ble')\n OR $this->stringReplace($end, '/eli/', 'e');\n break;\n\n case 'o':\n $this->stringReplace($end, '/ization/', 'ize')\n OR $this->stringReplace($end, '/ation/', 'ate')\n OR $this->stringReplace($end, '/ator/', 'ate');\n break;\n\n case 's':\n $this->stringReplace($end, '/iveness/', 'ive')\n OR $this->stringReplace($end, '/fulness/', 'ful')\n OR $this->stringReplace($end, '/ousness/', 'ous')\n OR $this->stringReplace($end, '/alism/', 'al');\n break;\n\n case 't':\n $this->stringReplace($end, '/biliti/', 'ble')\n OR $this->stringReplace($end, '/aliti/', 'al')\n OR $this->stringReplace($end, '/iviti/', 'ive');\n break;\n }\n } else if ($this->_locale == 'ru') {\n $this->stringReplace($end, '/и$/', '');\n } else if ($this->_locale == 'uk') {\n $this->stringReplace($end, '/ії$/', '');\n }\n\n // Step 3\n if ($this->_locale == 'en') {\n switch (mb_substr($end, -2, 1)) {\n case 'a':\n $this->stringReplace($end, '/ical/', 'ic');\n break;\n\n case 's':\n $this->stringReplace($end, '/ness/', '');\n break;\n\n case 't':\n $this->stringReplace($end, '/icate/', 'ic')\n OR $this->stringReplace($end, '/iciti/', 'ic');\n break;\n\n case 'u':\n $this->stringReplace($end, '/ful/', '');\n break;\n\n case 'v':\n $this->stringReplace($end, '/ative/', '');\n break;\n\n case 'z':\n $this->stringReplace($end, '/alize/', 'al');\n break;\n }\n } else if ($this->_locale == 'ru' || $this->_locale == 'uk') {\n if (isset($this->_patterns['derivational'])) {\n if ($this->pregMatch($end, $this->_patterns['derivational'])) {\n if ($this->_locale == 'ru')\n $this->stringReplace($end, '/ость?$/', '');\n if ($this->_locale == 'uk')\n $this->stringReplace($end, '/ость?$/', '');\n }\n }\n }\n\n // Step 4\n if ($this->_locale == 'en') {\n switch (mb_substr($end, -2, 1)) {\n case 'a':\n $this->stringReplace($end, '/al/', '', 1);\n break;\n\n case 'c':\n $this->stringReplace($end, '/ance/', '', 1)\n OR $this->stringReplace($end, '/ence/', '', 1);\n break;\n\n case 'e':\n $this->stringReplace($end, '/er/', '', 1);\n break;\n\n case 'i':\n $this->stringReplace($end, '/ic/', '', 1);\n break;\n\n case 'l':\n $this->stringReplace($end, '/able/', '', 1)\n OR $this->stringReplace($end, '/ible/', '', 1);\n break;\n\n case 'n':\n $this->stringReplace($end, '/ant/', '', 1)\n OR $this->stringReplace($end, '/ement/', '', 1)\n OR $this->stringReplace($end, '/ment/', '', 1)\n OR $this->stringReplace($end, '/ent/', '', 1);\n break;\n\n case 'o':\n if (substr($end, -4) == 'tion' OR substr($end, -4) == 'sion') {\n $this->stringReplace($end, '/ion/', '', 1);\n } else {\n $this->stringReplace($end, '/ou/', '', 1);\n }\n break;\n\n case 's':\n $this->stringReplace($end, '/ism/', '', 1);\n break;\n\n case 't':\n $this->stringReplace($end, '/ate/', '', 1)\n OR $this->stringReplace($end, '/iti/', '', 1);\n break;\n\n case 'u':\n $this->stringReplace($end, '/ous/', '', 1);\n break;\n\n case 'v':\n $this->stringReplace($end, '/ive/', '', 1);\n break;\n\n case 'z':\n $this->stringReplace($end, '/ize/', '', 1);\n break;\n }\n } else if ($this->_locale == 'ru' || $this->_locale == 'uk') {\n if (!$this->stringReplace($end, '/ь$/', '')) {\n $this->stringReplace($end, '/ейше?/', '');\n $this->stringReplace($end, '/нн$/', 'н');\n }\n }\n\n // Step 5\n if ($this->_locale == 'en') {\n if (isset($this->_patterns['vowel']) && isset($this->_patterns['consonant'])) {\n\n // Part a\n if (mb_substr($end, -1) == 'e') {\n if ($this->mCount(mb_substr($end, 0, -1), $this->_patterns['vowel'], $this->_patterns['consonant']) > 1) {\n $this->stringReplace($end, '/e/', '');\n } else if ($this->mCount(mb_substr($end, 0, -1)) == 1) {\n if (!$this->cvcSequence(mb_substr($end, 0, -1), $this->_patterns['vowel'], $this->_patterns['consonant'])) {\n $this->stringReplace($end, '/e/', '');\n }\n }\n }\n\n // Part b\n if (\n $this->mCount($end, $this->_patterns['vowel'], $this->_patterns['consonant']) > 1\n AND $this->doubleConsonant($end, $this->_patterns['consonant'])\n AND mb_substr($end, -1) == 'l'\n ) {\n $end = mb_substr($end, 0, -1);\n }\n\n }\n }\n\n $stem = $start . $end;\n\n } while (false);\n\n if ($this->caching)\n $this->_cache[$word] = $stem;\n\n return $stem;\n }", "function pimpup4solr($txt)\n{\n\t$words=explode(' ',$txt);\n\tforeach($words as $word)\n\t{\n\t\tif(trim($word))\n\t\t{\n\t\t\t//if ($word=='information') // double it\n\t\t\t\tif (rand(0,1)) $pimped.=' '.$word;\n\t\t\t$pimped.=' '.$word;\n\t\t}\n\t}\n\treturn $pimped;\n}", "public function word()\n {\n return $this->getRandomKey('word');\n }", "function print_words_elem( $word, $index, $text_input_idx) {\n\t$s = \"words[$text_input_idx][$index] = '\" . escape_quote( $word ) . \"';\\n\";\n\techo $s;\n}", "public function getWord($vname,$default = null, $method = 'any') \n {\n $val = self::getVar($vname,$default,$method);\n if (is_array($val)) {\n $val = array_shift($val);\n } \n if (!is_string($val)) {\n return $default;\n } \n $words = explode(\" \",$val);\n return $words[0];\n }", "public function fulltext($searchWord);", "public function saySomething($word){\n\t\techo $word;\n\t}", "function get_phrase($term, $case=0) {\n return phrase($term, $case);\n}" ]
[ "0.687465", "0.65975416", "0.64908755", "0.63687617", "0.6259453", "0.6247661", "0.6247661", "0.62002605", "0.61802953", "0.61788243", "0.6152926", "0.6133708", "0.61319035", "0.6053431", "0.6028146", "0.6021242", "0.60202086", "0.59813434", "0.59367406", "0.590992", "0.5883683", "0.58759946", "0.5874245", "0.58583534", "0.5853142", "0.58378255", "0.5823538", "0.5803985", "0.57544804", "0.5751635" ]
0.6876449
0
try to connect to maxscale and login
function __construct() { try { $this->con = new TelnetClient(HOST, PORT, 10.0, 10.0); $this->con->connect(); } catch(Exception $e) { die('unable to connect: '.$e); } try { $this->con->setPrompt('MaxScale>'); $this->con->login(USERNAME, PASSWORD, 'MaxScale login:'); } catch(Exception $e) { die('unable to login: '.$e); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function connect() {\n session_set_cookie_params(0, '/', '', false);\n /* Create signon session */\n $session_name = 'PMASignonSession';\n session_name($session_name);\n\n session_start();\n $_SESSION['PMA_single_signon_user'] = $this->db_username;\n $_SESSION['PMA_single_signon_password'] = $this->db_password;\n\n include(APPPATH . '/config/database.php');\n $_SESSION['PMA_single_signon_host'] = $db['default']['hostname'];\n $_SESSION['PMA_single_signon_port'] = 3306;\n\n /* Close that session */\n session_write_close();\n header('Location: ' . $this->config->base_url() . 'phpmyadmin/index.php?' . time());\n }", "private function _login() \n {\n\n }", "private function tryLogin(){\n if (!Auth::isOnline()) {\n $this->checkCockie();\n }\n }", "public function connect() {\n // initialisation\n $cookieJar = new FileCookieJar($this->cookieFilePath, TRUE);\n $client = new \\GuzzleHttp\\Client(['cookies' => $cookieJar]);\n\n // connection\n try {\n $response = $client->post('https://recruteurs.apec.fr/cms/login',\n [\n 'form_params' => [\n 'source' => 'loginApecInterlocuteur',\n 'username' => $this->username,\n 'password' => $this->password,\n ],\n 'timeout' => 5\n ]\n );\n } catch (\\Exception $e) {\n throw new \\Exception ('Erreur de connection avec APEC', 502);\n }\n\n // retour\n unset ($cookieJar, $client);\n return true;\n }", "private function connect() {\n\t\t$link = mysql_connect($this->host, $this->user, $this->password);\n\t\tif( $link !== false )\n\t\t\t$this->link = $link;\n\t\telse\n\t\t\t$this->reportError(\"Could not connect\");\n\t\t\n\t\tif( $this->db ) {\n\t\t\tif( @mysql_select_db($this->db, $this->link) === false ) {\n\t\t\t\t$this->reportError(\"Could not select database '{$this->db}'\");\n\t\t\t}\n\t\t}\n\t}", "public static function login()\n\t{\n\t\t$creds = jda_credentials();\n\t\techo \"core/jdahelper5250: \".$creds['jda_lib']. \"\\n\";\n\n\t\tself::$start_time = microtime(true);\n\t\tself::$lastTime = microtime(true);\n\n\t\techo \"Connecting to JDA \\n\";\n\t\tself::$jda = new jdatelnet(\"jdaprod2.rgoc.com.ph\",3);\n\t\tself::$jda->screenWait(\"Password\");\n\t\tself::$jda->login($creds['user'],$creds['password'],$creds['jda_lib']);\n\t}", "private function _logon()\r\n\t{\r\n\t\t$this->_CI->xmlrpc->server($this->_host.$this->_api, $this->_port);\r\n\t\t$this->_session_id = $this->_oxFunction('logon', array($this->_setDataType($this->_username), $this->_setDataType($this->_password)));\r\n\t}", "public function login()\n\t{\n\n\t\t$this->paramater = $this->objectToArray($this->config->opauth);\n\n\t\tif (is_array($this->paramater)) {\n\t\t\t$paramater = $this->paramater;\n\t\t}\n\t\t\n\t\t$opauth = new Opauth($paramater);\n\n\t\t$opauth->run();\n\t}", "public function connect()\n \t{\n \t\tif( $this->gesica_sess_utils->is_admin_mode_enabled()){\n \t\t\n \t\t\theader('Location:'.base_url().'home/main_panel'); /* si oui on le redirige vers le main_panel*/\n \t\t\n \t\t}elseif( $this->gesica_sess_utils->is_checkout_mode_enabled() ){ /* mode caisse activé ?*/\n\n \t\t\t/* si oui alors cela doit venir d'un formulaire minimal avec uniquement que le mot de passe \n \t\t\tpour passer en admin */\n\n \t\t\t$this->go_to_admin_mode() ;\n\n \t\t}else{\t/* Il s'agit d'une nouvelle connexion */\n\n \t\t\t$this->connect_enterprise(); \t\n \t\t}\n \t}", "public function connectAction():void{\n Rest::init();\n Rest::checkParams(['us_email', 'us_password']);\n $user = User::findFirstByUsEmail(Rest::$params['us_email']);\n if($user === null){\n Rest::renderError();\n }\n if($user->us_password !== md5(Rest::$params['us_password'])){\n Rest::renderError();\n }\n UserManager::connect($user->toArray());\n Rest::renderSuccess();\n }", "public function login(){\n\t\techo 1111;exit;\n\t\t$data = $this->getApiParams();\n\t\tprint_r($data);exit;\n\t}", "private function connect()\n {\n\t\tif(isset($_SESSION['AAT']['debug']) && $_SESSION['AAT']['debug'] === 1) \n\t\t{ \n\t\t\t$this->oDebugLog->addLog('message','MusaDB','connect','in'); \n\t\t}\n\t\t\t\n\t\t$host = $_SESSION['AAT']['dbhost'];\n\t\t$port = $_SESSION['AAT']['dbport'];\n\t\t$db = $_SESSION['AAT']['dbname'];\n\t\t$user = $_SESSION['AAT']['dbuser'];\n\t\t$pass = $_SESSION['AAT']['dbpassword'];\n\t\t \n\t\ttry\n\t\t{\n\t\t // test database connection\n\t $this->oConn = new Database($host, $port, $db, $user, $pass);\n\t $this->oConn->connect();\n\t\t}\n\t\tcatch (Exception $e)\n\t\t{\n\t\t\tif(isset($_SESSION['AAT']['debug']) && $_SESSION['AAT']['debug'] === 1) \n\t\t\t{ \n\t\t\t\t$this->oDebugLog->addLog('message','MusaDB','connect','failed: ' . $e->getMessage() ); \n\t\t\t}\n\t\t\t//todo: redirect to error page or something\n\t\t\t exit(\"Caught exception: \" . $e->getMessage() . \"\\n\");\n\t\t\t \n\t\t}\n }", "public static function login()\n {\n session_regenerate_id(true);\n $_SESSION['est_connecte'] = true;\n }", "public function login();", "protected function _phonyLogin() {\n }", "protected function _phonyLogin() {\n }", "function connect() { if ( 0 == $this->Link_ID ) {\r\n // Check for local connect\r\n if(!$this->PConnect) {\r\n $this->Link_ID = empty($this->Host) ? \r\n $this->Link_ID = msql_connect() :\r\n $this->Link_ID = msql_connect($this->Host);\r\n } else {\r\n $this->Link_ID = empty($this->Host) ? \r\n $this->Link_ID = msql_pconnect() :\r\n $this->Link_ID = msql_pconnect($this->Host);\r\n }\r\n }\r\n \r\n // Still not connected? Raise error.\r\n if ( 0 == $this->Link_ID ) {\r\n $this->halt(\"connect($this->Host) failed.\");\r\n }\r\n\r\n // Select current database\r\n\t if (!msql_select_db($this->Database, $this->Link_ID)) {\r\n $this->halt(\"cannot use database \".$this->Database);\r\n }\r\n }", "public static function login() {\n }", "public function login()\n {\n $data['TITLE'] = \"Connectez-vous\";\n\n if (!empty($this->input->post())) {\n\n $id = $this->Users_manager->checkLogin($this->input->post('email'), $this->input->post('pwd'));\n\n if (!empty($id)) {\n if ($this->reCapchaV3($this->input->post('token'))) $this->connect($id);\n } else {\n $data['ERRORS'] = 'Identifiants de connexion incorrectes';\n }\n\n }\n\n $data['CONTENT'] = $this->smarty->fetch('front/login.tpl', $data);\n $this->smarty->display('front/templates/min-content.tpl', $data);\n\n }", "private function login_action ( $login, $password, $host ) { \n $params = array( );\n\t\tif( !is_null( $login ) &&\n\t\t\t!is_null( $password ) &&\n\t\t\t!is_null( $host )\n\t\t) {\n onapp_debug('Trying to login : host => ' . $host . 'login => ' . $login . 'password => *******');\n\t\t\t$onapp = new ONAPP_Factory(\n\t\t\t\t$host,\n\t\t\t\t$login,\n\t\t\t\t$password\n\t\t\t);\n\n onapp_debug( 'VersioinApi => ' . $onapp->getAPIVersion( ));\n if ( ! is_null( $onapp->getAPIVersion( ) ) ) {\n $this->_start_session( );\n $this->_load_profile( $onapp );\n return true;\n }\n\t\t}\n return false;\n }", "private function initConnector() {\n $this->sid = \"ACf9c6f06c02da4a709f156ec489c445ce\";\n $this->token = \"fda028e2dd1b388300feb621eecceb72\";\n $this->client = (new Client($this->sid,$this->token));\n }", "public function login()\n {\n }", "public function connectionJira(){\n\t//login\n\t\tglobal $jirauser,$jirapwd,$url,$username,$password; \n\t\t$username = ' ';// base64_decode($jirauser) ;\n\t\t$password = ' ';//base64_decode($jirapwd) ;\n\t\t$url = \"http://148.100.5.224:3000/api\";\n}", "private function login() {\n if ((int) $_SESSION[$this->sessionName] < time()) {\n $_SESSION[$this->sessionName] = time() + (1000 * 3); // pra evitar auto loopíng ao usar call\n $ret = $this->call('login/enter', [], 'GET', ['App-Key' => $this->appkey]);\n $_SESSION[$this->sessionName] = 0;\n $this->printLogsOnScreen('Ret-Login: ' . var_export($ret, true));\n if ($ret->status === 200 && $ret->error === false && $ret->content->token) {\n $this->token = $ret->content->token;\n } else {\n throw new \\Exception('IntegracaoAdapterLogin: Não foi possível efetuar login em \"' . $this->endpoint . '\" com as credenciais informadas');\n }\n $_SESSION[$this->sessionName] = time() + (58 * $ret->content->expire); // duração do token, para não ficar fazendo login toda hora\n }\n }", "function db_login() {\n\t\n\treturn array( \n\t\t'dsn'\t => 'mysql:dbname=cutups;host=localhost;port=8888',\n\t\t'user' => 'editor',\n\t\t'pass' => 'TvXhRzNztLhmbhqF'\n\t);\n}", "public function login() {\n\t\t\n\t}", "function member_login() {\r\n\t\t$this->login();\r\n\t}", "function ml_connectToDatabase() {\n global $databaseServer,\n $databaseUsername, $databasePassword, $databaseName,\n $ml_mysqlLink;\n \n \n $ml_mysqlLink =\n mysql_connect( $databaseServer, $databaseUsername, $databasePassword )\n or ml_operationError( \"Could not connect to database server: \" .\n mysql_error() );\n \n\tmysql_select_db( $databaseName )\n or ml_operationError( \"Could not select $databaseName database: \" .\n mysql_error() );\n }", "private function _connect_bosh() {\n\t\t$this->CI->load->helper('jax');\n\t\t\n\t\t// Get RID, SID, JID after successful auth \n\t\t$this->JAXL->addPlugin('jaxl_post_auth', 'postAuth');\n\t\t// Detect auth failure\n\t\t$this->JAXL->addPlugin('jaxl_post_auth_failure','postAuthFailure');\n\n\t\t$this->JAXL->addPlugin('jaxl_post_disconnect', 'postDisconnect');\n\n\t\t// Start up the core...\n\t\t$this->JAXL->startCore('bosh');\n\t}", "function loginToSystem() {\n $this->model->loginToSystem();\n }" ]
[ "0.58284414", "0.5790222", "0.5722025", "0.569989", "0.5683981", "0.56823564", "0.5680313", "0.56506854", "0.56458664", "0.561264", "0.5612159", "0.5597961", "0.5594069", "0.55617654", "0.55455035", "0.55455035", "0.55427194", "0.55406976", "0.55225", "0.55067784", "0.5501977", "0.55014074", "0.5495401", "0.54851", "0.5480687", "0.5475518", "0.5475385", "0.544442", "0.54310423", "0.5430062" ]
0.58438116
0
generate random consonants separated by vowels
function generate_faux_word($letters = 5){ //define arrays of consonants and vowels //no q, it's tough to remember $consonants = array('a', 'a', 'a', 'a', 'a', 'a', 'a'); $vowels = array('a', 'e', 'i', 'o', 'u'); $ret_word = ""; $consonant_toggle = true; //randomly choose a consonant then a vowel until the word is as long as the parameter while(strlen($ret_word) < $letters){ if ($consonant_toggle){ $ret_word .= $consonants[array_rand($consonants)]; $consonant_toggle = false; }else{ $ret_word .= $vowels[array_rand($vowels)]; $consonant_toggle = true; } } return $ret_word; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function readable_random_string($length = 6)\n{\n $string = '';\n $vowels = array(\"a\",\"e\",\"i\",\"o\",\"u\");\n $consonants = array(\n 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm',\n 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'\n );\n\n $max = $length / 2;\n for ($i = 1; $i <= $max; $i++)\n {\n $string .= $consonants[rand(0,19)];\n $string .= $vowels[rand(0,4)];\n }\n\n return $string;\n}", "function ae_gen_password($syllables = 3, $use_prefix = false)\n{\n if (!function_exists('ae_arr'))\n {\n // This function returns random array element\n function ae_arr(&$arr)\n {\n return $arr[rand(0, sizeof($arr)-1)];\n }\n }\n\n // 20 prefixes\n $prefix = array('aero', 'anti', 'auto', 'bi', 'bio',\n 'cine', 'deca', 'demo', 'dyna', 'eco',\n 'ergo', 'geo', 'gyno', 'hypo', 'kilo',\n 'mega', 'tera', 'mini', 'nano', 'duo');\n\n // 10 random suffixes\n $suffix = array('dom', 'ity', 'ment', 'sion', 'ness',\n 'ence', 'er', 'ist', 'tion', 'or'); \n\n // 8 vowel sounds \n $vowels = array('a', 'o', 'e', 'i', 'y', 'u', 'ou', 'oo'); \n\n // 20 random consonants \n $consonants = array('w', 'r', 't', 'p', 's', 'd', 'f', 'g', 'h', 'j', \n 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'qu');\n\n $password = $use_prefix?ae_arr($prefix):'';\n $password_suffix = ae_arr($suffix);\n\n for($i=0; $i<$syllables; $i++)\n {\n // selecting random consonant\n $doubles = array('n', 'm', 't', 's');\n $c = ae_arr($consonants);\n if (in_array($c, $doubles)&&($i!=0)) { // maybe double it\n if (rand(0, 2) == 1) // 33% probability\n $c .= $c;\n }\n $password .= $c;\n //\n\n // selecting random vowel\n $password .= ae_arr($vowels);\n\n if ($i == $syllables - 1) // if suffix begin with vovel\n if (in_array($password_suffix[0], $vowels)) // add one more consonant \n $password .= ae_arr($consonants);\n\n }\n\n // selecting random suffix\n $password .= $password_suffix;\n\n return $password;\n}", "function GeneratePW() {\n\t$length = 9;\n\t$vowels = 'aeiouy';\n\t$consonants = 'bdghjmnpqrstvz';\n\t$consonants .= '23456789';\n\n \n\t$password = '';\n\t$alt = time() % 2;\n\tfor ($i = 0; $i < $length; $i++) {\n\t\tif ($alt == 1) {\n\t\t\t$password .= $consonants[(rand() % strlen($consonants))];\n\t\t\t$alt = 0;\n\t\t} else {\n\t\t\t$password .= $vowels[(rand() % strlen($vowels))];\n\t\t\t$alt = 1;\n\t\t}\n\t}\n\treturn $password;\n\n}", "protected function _generateWord()\r\n {\r\n $word = '';\r\n $wordLen = $this->getWordLen();\r\n $vowels = $this->_useNumbers ? self::$VN : self::$V;\r\n $consonants = $this->_useNumbers ? self::$CN : self::$C;\r\n\r\n for ($i=0; $i < $wordLen; $i = $i + 2) {\r\n // generate word with mix of vowels and consonants\r\n $consonant = $consonants[array_rand($consonants)];\r\n $vowel = $vowels[array_rand($vowels)];\r\n $word .= $consonant . $vowel;\r\n }\r\n\r\n if (strlen($word) > $wordLen) {\r\n $word = substr($word, 0, $wordLen);\r\n }\r\n\t\t//$word = strtoupper($word);\r\n return $word;\r\n }", "static function getNew() { // from http://www.blueroo.net/max/pwdgen.php\n\t\t$consts = 'bcdgjlmnprst';\n\t\t$vowels = 'aeiou';\n\t\tfor ($x= 0;$x<6;$x++) {\n\t\t\tmt_srand((double)microtime() *1000000);\n\t\t\t$const[$x] = substr($consts, mt_rand(0, strlen($consts) -1), 1);\n\t\t\t$vow[$x] = substr($vowels, mt_rand(0, strlen($vowels) -1), 1);\n\t\t}\n\t\treturn $const[0].$vow[0].$const[2].$const[1].$vow[1].$const[3].$vow[3]\n\t\t\t.$const[4];\n\t}", "function GenerateWord()\r\n{\r\n $nb=rand(3,10);\r\n $w='';\r\n for($i=1;$i<=$nb;$i++)\r\n $w.=chr(rand(ord('a'),ord('z')));\r\n return $w;\r\n}", "function GenerateWord()\n{\n $nb=rand(3,10);\n $w='';\n for($i=1;$i<=$nb;$i++)\n $w.=chr(rand(ord('a'),ord('z')));\n return $w;\n}", "function GenerateWord()\n{\n\t$nb=rand(3,10);\n\t$w='';\n\tfor($i=1;$i<=$nb;$i++)\n\t\t$w.=chr(rand(ord('a'),ord('z')));\n\treturn $w;\n}", "function randon_DNA($a,$c,$g,$t){\r\n return str_shuffle(str_repeat(\"A\",$a).str_repeat(\"C\",$c).str_repeat(\"G\",$g).str_repeat(\"T\",$t));\r\n}", "protected function generateVerifyCode()\n {\n if ($this->minLength > $this->maxLength) {\n $this->maxLength = $this->minLength;\n }\n if ($this->minLength < 3) {\n $this->minLength = 3;\n }\n if ($this->maxLength > 20) {\n $this->maxLength = 20;\n }\n $length = mt_rand($this->minLength, $this->maxLength);\n \n $letters = 'bcdfghjklmnpqrstvwxyz';\n $vowels = 'aeiou';\n $code = '';\n for ($i = 0; $i < $length; ++$i) {\n if ($i % 2 && mt_rand(0, 10) > 2 || !($i % 2) && mt_rand(0, 10) > 9) {\n $code .= $vowels[mt_rand(0, 4)];\n } else { \n $code .= $letters[mt_rand(0, 20)];\n } \n } \n \n return $code;\n }", "function generateCode($characters)\n\t{\n\t\t$possible = '23456789bcdfghjkmnpqrstvwxyz';\n\t\t$code = '';\n\t\t$i = 0;\n\n\t\twhile ($i < $characters)\n\t\t{\n\t\t\t$code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);\n\t\t\t$i++;\n\t\t}\n\n\t\treturn $code;\n\t}", "function getCodigoVenta($n) {\n $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n $randomString = '';\n\n for ($i = 0; $i < $n; $i++) {\n $index = rand(0, strlen($characters) - 1);\n $randomString .= $characters[$index];\n }\n\n return $randomString;\n}", "public function generateVerifyCode()\n\t{\n\t\tif($this->minLength < 3)\n\t\t\t$this->minLength = 3;\n\t\tif($this->maxLength > 20)\n\t\t\t$this->maxLength = 20;\n\t\tif($this->minLength > $this->maxLength)\n\t\t\t$this->maxLength = $this->minLength;\n\t\t$length = mt_rand($this->minLength,$this->maxLength);\n\n\t\t$letters = 'bcdfghjklmnpqrstvwxyz';\n\t\t$vowels = 'aeiou';\n\t\t$numbers = '1234567890';\n\t\t$code = '';\n\t\tfor($i = 0; $i < $length; ++$i)\n\t\t{\n\t\t\tif($i % 2 && mt_rand(0,10) > 2 || !($i % 2) && mt_rand(0,10) > 9)\n\t\t\t\t$code.=$vowels[mt_rand(0,4)];\n\t\t\telse\n\t\t\t\t$code.=$letters[mt_rand(0,20)];\n if($i == $length / 2 || mt_rand(0,7) > $length / 2)\n $code.=$numbers[mt_rand(0,9)];\n\t\t}\n\n\t\treturn $code;\n\t}", "function generate_pass($length)\n\t{\n\t\t$vowels = array('a', 'e', 'i', 'o', 'u');\n\t\t$cons = array('b', 'c', 'd', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', 'tr',\n\t\t'cr', 'br', 'fr', 'th', 'dr', 'ch', 'ph', 'wr', 'st', 'sp', 'sw', 'pr', 'sl', 'cl');\n\n\t\t$num_vowels = count($vowels);\n\t\t$num_cons = count($cons);\n\n\t\t$password = '';\n\n\t\tfor ($i = 0; $i < $length; $i++)\n\t\t{\n\t\t\t$password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];\n\t\t}\n\n\t\treturn substr($password, 0, $length);\n\t}", "public function generarCodigoCita()\n {\n $flag = true;\n $codigo = '';\n do {\n $codigo = substr(str_shuffle(str_repeat(\"0123456789abcdefghijklmnopqrstuvwxyz\", 5)), 0, 5);\n $flag = cita::where('codigo', $codigo)->count() > 0;\n } while ($flag);\n\n return $codigo;\n }", "function random_password($car) {\n $string = \"\";\n $chaine = \"abcdefghijklmnpqrstuvwxy123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&([-_)]=+%#{}+\";\n srand((double)microtime()*1000000);\n for ($i=0; $i<$car; $i++) {\n $string .= $chaine[rand()%strlen($chaine)];\n }\n echo $string;\n}", "function generateSalt(){\n $amostra = array_merge( range( 'a', 'z' ), range( 'A', 'Z' ), range( 0, 9 ) );\n \n // Embaralha o array\n shuffle( $amostra );\n \n $index = array_rand( $amostra, SALT_SIZE );\n \n $salt = '';\n \n for ( $i = 0; $i < SALT_SIZE; $i++ ){\n $salt .= $amostra[ $i ];\n }\n \n return $salt;\n }", "function generate(){\n\t$char = 'abcdefghijklmnopqrstuvwxyz1234567890';\n\n\treturn substr(str_shuffle($char), 0,5);\n}", "function cadenaAleatorea ($longitud = 10){\n\n $caracteres = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n // Iniciamos la semilla de numeros aleatorios y la key\n srand((double)microtime()*1000000);\n $cadena = \"\";\n\n // Creamos la cadena de N caracteres;\n for($x=0;$x<$longitud;$x++){\n\n $aleatorio = rand(0,35);\n $cadena .= substr($caracteres, $aleatorio, 1);\n\n } // for($x=0;$x<$longitud;$x++)\n\n return $cadena; \n \n}", "function generateRandomString($length=9, $strength=0)\n{\n\t$vowels = 'aeuyi';\n\t$consonants = 'bdghjmnpqrstvz';\n\tif ($strength & 1)\n\t\t$consonants .= 'BDGHJLMNPQRSTVWXZ';\n\tif ($strength & 2)\n\t\t$vowels .= \"AEUYI\";\n\tif ($strength & 4)\n\t\t$consonants .= '23456789';\n\tif ($strength & 8)\n\t\t$consonants .= '@#$%?';\n\n\t$string = '';\n\t$alt = time() % 2; // will give a random alternation start\n\tfor ($i = $alt; $i < $length+$alt; $i++)\n\t{\n\t\tif ($i%2)\n\t\t\t$string .= $consonants[(rand() % strlen($consonants))];\n\t\telse\n\t\t\t$string .= $vowels[(rand() % strlen($vowels))];\n\t}\n\treturn $string;\n}", "public static function color(){\n \n $chars = \"0123456789abcdef\";\n $str = \"\";\n for ($i = 0; $i < 6; $i++) {\n $str .= $chars{mt_rand(0, strlen($chars) - 1)};\n }\n return $str;\n \n }", "protected function _createCode()\n {\n $chars = array ('A', 'B', 'C', 'D', 'E', 'F', 'G',\n 'H', 'I', 'J', 'K', 'L', 'M', 'N', '0', 'P',\n 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');\n $code = '';\n for ($i = 0; $i < self::CODE_LENGTH; $i++) {\n $code .= $chars[rand(0, count($chars) - 1)];\n }\n return $code;\n }", "function generateCode($characters) \n{\n\t$possible = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; \n\t$code = '';\n\t$i = 0;\n\twhile ($i < $characters) \n\t{ \n\t\t$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);\n\t\t$i++;\n\t}\n\treturn $code;\n}", "public function Exec()\n\t{\n\t\t$c = range( 'A', 'Z' );\n\t\t$n = range( '0', '9' );\n\t\t$l = count( $c )-1;\n\t\t$i = count( $n )-1;\n\t\t$p = $c[rand( 1, $l )] . $n[rand( 1, $i )] . $c[rand( 1, $l )];\n\t\t$p .= $c[rand( 1, $l )] . $n[rand( 1, $i )] . $c[rand( 1, $l )];\n\t\t$p .= $n[rand( 1, $i )];\n\t\treturn $p;\n }", "public function generateCode()\n {\n $v = array(\"a\", \"e\", \"i\", \"o\", \"u\", \"ou\", \"ie\", \"ee\", \"ei\", \"ao\");\n $c = array(\"b\", \"bl\", \"br\", \"c\", \"ch\", \"cl\", \"d\", \"dh\", \"f\", \"fh\", \"g\", \"gh\", \"h\", \"j\", \"k\", \"kr\", \"kl\", \"l\", \"m\", \"mn\", \"mp\", \"n\", \"np\", \"p\", \"pp\", \"qu\", \"r\", \"s\", \"sh\", \"sch\", \"st\", \"t\", \"th\", \"thr\", \"tt\", \"v\", \"w\", \"xy\", \"y\", \"z\");\n $this->code = \"\";\n for ($i = 0; $i < $this->stringLength; $i++) {\n //$this->code .= chr(rand(97,122));\n $this->code .= $c[rand(0, count($c)-1)] . $v[rand(0, count($v)-1)];\n }\n $this->code = strtoupper(substr($this->code, 0, 1)) . substr($this->code, 1, $this->stringLength-1);\n $this->saveToSession();\n }", "public static function generatePassword($length = 6, $uppercaseAllowed = true, $lowercaseAllowed = true)\n\t{\n\t\t// list of allowed vowels and vowelsounds\n\t\t$vowels = array('a', 'e', 'i', 'u', 'ae', 'ea');\n\n\t\t// list of allowed consonants and consonant sounds\n\t\t$consonants = array('b', 'c', 'd', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'r', 's', 't', 'u', 'v', 'w', 'tr', 'cr', 'fr', 'dr', 'wr', 'pr', 'th', 'ch', 'ph', 'st');\n\n\t\t// init vars\n\t\t$consonantsCount = count($consonants);\n\t\t$vowelsCount = count($vowels);\n\t\t$pass = '';\n\t\t$tmp = '';\n\n\t\t// create temporary pass\n\t\tfor($i = 0; $i < $length; $i++) $tmp .= ($consonants[rand(0, $consonantsCount - 1)] . $vowels[rand(0, $vowelsCount - 1)]);\n\n\t\t// reformat the pass\n\t\tfor($i = 0; $i < $length; $i++)\n\t\t{\n\t\t\tif(rand(0, 1) == 1) $pass .= strtoupper(substr($tmp, $i, 1));\n\t\t\telse $pass .= substr($tmp, $i, 1);\n\t\t}\n\n\t\t// reformat it again, if uppercase isn't allowed\n\t\tif(!$uppercaseAllowed) $pass = strtolower($pass);\n\n\t\t// reformat it again, if uppercase isn't allowed\n\t\tif(!$lowercaseAllowed) $pass = strtoupper($pass);\n\n\t\t// return pass\n\t\treturn $pass;\n\t}", "private function rand_chars($c, $l, $u = FALSE) \n\t{\n\t\t//integer $l is how long you want the string to be.\n\t\t//boolean $u is whether or not a character can appear beside itself.\n\t\t if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++);\n\t\t else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s));\n\t\t return $s;\n\t}", "function generate_char($sType,$iLength)\n{\n $str = \"\";\n\t$iLength = (int) $iLength;\n\tsrand ((double) microtime() * 1000000);\n\t\n\tswitch($sType){\n\t\tcase \"i\":\n\t\t\tfor($i=0;$i < $iLength;$i++){\n\t\t\t //Generate the random number\n\n \t\t\t $rand_number = rand(1, 9);\n\t\t\t $str .= $rand_number;\t\t\n\t\t\t}//for\n\t\t\tbreak;\n\t\tcase \"s\":\n\t\t\tfor($i=0;$i < $iLength;$i++){\n\t\t\t //Generate the random character\n\t\t\t // $rand_char = chr(rand(0,25) + 65);\n\t\t\t $rand_logic = rand(0,1) ;\n\t\t\t \n\t\t\t if ( $rand_logic )\n\t\t\t {\n\t\t\t \t$rand_char = chr(rand(0,25) + 65);\n\t\t\t }\n\t\t\t else\n\t\t\t {\n\t\t\t \t$rand_char = chr(rand(0,25) + 97);\n\t\t\t }\n\t\t\t $str .= $rand_char;\n\t\t\t}\n\t\t\tbreak;\t\n\t}//switch\n\t\n\treturn $str;\n}", "public function __construct() {\n\t\tstatic::$chars['consonant'] = [\n\t\t\t'b' => 2,\n\t\t\t'c'\t=> 3,\n\t\t\t'd'\t=> 4,\n\t\t\t'f' => 2,\n\t\t\t'g' => 2,\n\t\t\t'h'\t=> 6,\n\t\t\t'j'\t=> 1,\n\t\t\t'k' => 1,\n\t\t\t'l' => 4,\n\t\t\t'm' => 3,\n\t\t\t'n' => 7,\n\t\t\t'p' => 2,\n\t\t\t'q' => [\n\t\t\t\t'freq' => 1,\n\t\t\t\t'rules' => [\n\t\t\t\t\t0 => function ($iChar, $currChar, $wordChars) {\n\t\t\t\t\t\t// ensure a Q is trailed by a U\n\t\t\t\t\t\tif ($wordChars[$iChar+1] == 'u') {\n\t\t\t\t\t\t\tthrow new CharValidationException(\"Consonant rule failed: 'Q is trailed by a U'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t],\n\t\t\t'r' => 6,\n\t\t\t's' => 6,\n\t\t\t't' => 9,\n\t\t\t'v' => 1,\n\t\t\t'w' => 2,\n\t\t\t'x' => 1,\n\t\t\t'z' => 1\n\t\t];\n\t\tstatic::$charFreqArr['consonant'] = static::generateCharFreqArr(static::$chars, 'consonant');\n\n\t\tstatic::$chars['vowel'] = [\n\t\t\t'a' => 8,\n\t\t\t'e' => [\n\t\t\t\t'freq' => 10,\n\t\t\t\t'rules' => [\n\t\t\t\t\t0 => function ($iChar, $currChar, $wordChars) {\n\t\t\t\t\t\t// ensure I before E except after C\n\t\t\t\t\t\tif ($wordChars[$iChar-1] != 'c' && $wordChars[$iChar+1] == 'i') {\n\t\t\t\t\t\t\tthrow new CharValidationException(\"Vowel rule failed: 'I before E'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t],\n\t\t\t'i'\t=> 7,\n\t\t\t'o'\t=> 8,\n\t\t\t'u' => 3,\n\t\t\t'y' => 2\n\t\t];\n\t\tstatic::$charFreqArr['vowel'] = static::generateCharFreqArr(static::$chars, 'vowel');\n\n\t\tstatic::$realElements = [\n\t\t\t'Aluminum',\n\t\t\t'Copper',\n\t\t\t'Gold',\n\t\t\t'Iron',\n\t\t\t'Nickel',\n\t\t\t'Platinum',\n\t\t\t'Silver',\n\t\t\t'Tin',\n\t\t\t'Zinc'\n\t\t];\n\n\t\tstatic::$suffixes = [\n\t\t\t'ium',\n\t\t\t'um',\n\t\t\t'er',\n\t\t\t'on',\n\t\t\t'el',\n\t\t\t'in',\n\t\t\t'ine',\n\t\t\t'ese'\n\t\t];\n\t}", "function gen_chars_no_dup($long){\n $chars = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"; \n mt_srand((double)microtime()*1000000); \n $i=0; \n while ($i != $long){ \n $rand = mt_rand() % strlen($chars); \n $tmp = $chars[$rand]; \n $pass = $pass . $tmp; \n $chars=str_replace($tmp, \"\", $chars); \n $i++; \n } \n return strrev($pass); \n}" ]
[ "0.69348645", "0.68525195", "0.6694745", "0.6638442", "0.61237717", "0.60762465", "0.60755646", "0.592206", "0.59162796", "0.59062254", "0.5902506", "0.59019727", "0.5897147", "0.5888603", "0.5860903", "0.5859026", "0.5856709", "0.5855698", "0.5847326", "0.5799906", "0.57676506", "0.5762494", "0.5755946", "0.5755923", "0.57378805", "0.5735693", "0.57350516", "0.5708686", "0.5698537", "0.5685658" ]
0.7060566
0
Obtenemos datos de una marca por su ID
function verMarcaPorID() { $idMarca = $_GET['idMarca']; $link = conectar(); $sql = "SELECT idMarca, mkNombre FROM marcas WHERE idMarca = ".$idMarca; $resultado = mysqli_query( $link, $sql ) or die( mysqli_error($link) ); $marca = mysqli_fetch_assoc($resultado); return $marca; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getModelosMarca($id){\n\n }", "function dameDatos($id) {\n\trequire_once('conexion.php');\n\t$conexion = new Conexion();\n\t$conexion->conectarBD();\n\t$query = $conexion -> getConexion() -> prepare(\"SELECT p.idProducto, p.descripcionProducto, p.precio, p.ganancia, p.precioventa, m.nombreMarca, m.idMarca, p.stock FROM producto p INNER JOIN marca m ON(p.idMarca = m.idMarca) WHERE idProducto=?\");\n\t$query->execute(array($id));\n\t$res = $query -> fetchObject();\n\t$conexion->desconectarBD();\n\treturn $res;\n}", "public function load($id){\n\t\t$sql = 'SELECT * FROM kelas_jadwal_materi WHERE id_kjm = ?';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\t$sqlQuery->setNumber($id);\n\t\treturn $this->getRow($sqlQuery);\n\t}", "public function busqueda(){\n $idMarca = $_REQUEST[\"id\"];\n $genero = Marca::find($idMarca);\n echo $genero->descripcion;\n }", "public static function getFromTableMembre($id=-1) {\n\t\t//Generated by FactoryGenerator::generateGetAllFromTable()\n\t\t$listeObjet = array();\n\t\t// Lancement de la requete\n\t\tif (empty(self::$_requete)) {\n\t\t\t$requete = 'SELECT * FROM `membre`';\n\t\t} else {\n\t\t\t$requete = self::$_requete;\n\t\t}\n\t\tif (!is_array($id)) {\n\t\t\tif ($id > -1) {\n\t\t\t\t$requete .= ' WHERE id = :id';\n\t\t\t\t//Il faut que le parametre soit dans un array pour le BIND\n\t\t\t\t$id = array(':id' => $id);\n\t\t\t} else {\n\t\t\t\t/* Tous les objets ==> il faut les ordonner */\n\t\t\t\t$requete .= ' ORDER BY id ASC';\n\t\t\t}\n\t\t} else {\n\t\t\t$requete .= ' WHERE id IN ('.implode(\",\",$id).') ORDER BY id ASC';\n\t\t}\n\t\tdatabase::getInstance() -> prepareRequete($requete);\n\t\tif (is_array($id) || $id > -1) {\n\t\t\tdatabase::getInstance() -> bind($id);\n\t\t}\n\t\tif (! database::getInstance() -> executeRequete()) {\n\t\t\tthrow new Exception(__CLASS__.'::'.__FUNCTION__.'(): Impossible de lire la table membre');\n\t\t}\n\t\t// Recuperation des donnees\n\t\t$datas = database::getInstance() -> getTableauResultat();\n\t\t\n\t/*\n\t * Entre ces deux balises vous pourrez mettre votre code specifique a la classe.\n\t * Il sera preserve lors de la reconstruction automatique.\n\t */\n\t/*[TAG-Membre2]*/\t/*[/TAG-Membre2]*/\n\n\t\t/* Traitement des donnees */\n\t\tforeach ($datas AS $data) {\n\t\t\t/* objet par defaut */\n\t\t\t$listeObjet[] = new Membre($data['id'],$data['pseudo'],$data['password'],$data['mail'],$data['date_inscription'],$data['staff'],$data['groupe'],$data['experience'],$data['description'],$data['cle_activation'],$data['avatar'],$data['design'],$data['points'],$data['date_der_connexion']);\n\t\t\n\t/*\n\t * Entre ces deux balises vous pourrez mettre votre code specifique a la classe.\n\t * Il sera preserve lors de la reconstruction automatique.\n\t */\n\t/*[TAG-getFromTableMembre1]*/\t/*[/TAG-getFromTableMembre1]*/\n\n\t\t}\n\t\tif (!empty($listeObjet) && sizeof($listeObjet) == 1) {\n\t\t\t$listeObjet = $listeObjet[0];\n\t\t}\n\t\treturn $listeObjet;\n\t}", "public function load($id){\n\t\t$sql = 'SELECT * FROM destaque WHERE id = ?';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\t$sqlQuery->setNumber($id);\n\t\treturn $this->getRow($sqlQuery);\n\t}", "public function mostrarPorIdBuscador($id){ \n $sql = \"SELECT p.id,nombres,apellidos,email,total,fecha,entregado FROM pedidos p\n INNER JOIN clientes c ON p.cliente_id = c.id WHERE p.id = :id\";\n\n $resultado = $this->cn->prepare($sql); \n\n $_array = array(\n ':id'=> $id\n );\n\n if($resultado->execute($_array))\n return $resultado->fetchAll();\n\n return false;\n }", "public function getIdMarca() {\n\t\treturn $this->idMarca;\n\t}", "public function getChienById($id){\n //je prepare ma requete\n $pdoStatement = $this->connexion->prepare(\n \"SELECT c.id, c.nom, c.age, c.race, m.nom as nomMaitre, m.telephone\n FROM Chiens c\n INNER JOIN Maitres m\n ON c.id_maitre = m.id\n WHERE c.id = :idChien\"\n );\n // j'execute la requete\n $pdoStatement->execute(\n array(\"idChien\" => $id)\n );\n // je recupere et je stoke le rsultat\n $monChien = $pdoStatement->fetchObject(\"Chien\");\n // var_dump($monChien);\n return $monChien;\n }", "public function show($id)\n {\n $mascota = Mascota::find($id);\n return $mascota;\n }", "public function load($id){\n\t\t$sql = 'SELECT * FROM apartamentos WHERE idapartamentos = ?';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\t$sqlQuery->setNumber($id);\n\t\treturn $this->getRow($sqlQuery);\n\t}", "public function load($id){\n\t\t$sql = 'SELECT * FROM carreras WHERE id_carrera = ?';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\t$sqlQuery->setNumber($id);\n\t\treturn $this->getRow($sqlQuery);\n\t}", "public function readIdManga(int $id = null):Manga|Exception\n {\n $sql = \"SELECT * FROM `manga` WHERE `id_manga` = \".intval($id??$this->idManga).\" \";\n $data = $this->PDO->query($sql);\n if($data->affectedRows() != 1)\n return throw new Exception('error');\n \n $data = $data->firstRow();\n $this->name = $data->name;\n $this->mangaka = $data->mangaka;\n $this->idGenre = $data->id_genre;\n $this->idManga = $data->id_manga; // Case where we pass with $id\n // return $this->getAllTomes()->getAllCategories(); // Remove getAllTomes for better load\n return $this->getAllCategories();\n }", "function listar_municipios($id){\n\t\t$sql=\"SELECT * FROM municipio WHERE estado_mun='$id' ORDER BY nombre_mun ASC\";\n\t\t$consulta=mysql_query($sql) or die(mysql_error());\n\t\twhile ($resultado = mysql_fetch_array($consulta)){\n\t\t\t$this->mensaje=\"si\";\n\t\t\t$this->listado2[] = $resultado;\n\t\t}\n\t}", "public function consultarMateria($id)\r\n\t{\r\n\t\t$this->sql = \"SELECT * FROM tbl_materias \r\n\t\t\t\t\t WHERE ide_materia = $id;\";\r\n\r\n\t\t$this->abrirBaseDatos();\r\n\t\treturn $this->res = $this->ejecutarConsulta($this->sql);\r\n\r\n\t\t$this->cerrarBaseDatos();\r\n\t}", "public function buscarTutorModel($id){\n\t\t//Se prepara la consulta\n\t\t$stmt = Conexion::conectar()->prepare(\"SELECT * FROM maestro WHERE idempleado = '$id' AND eliminado=0\");\n\t\t//Se ejecuta la consulta\n\t\t$stmt->execute();\n\t\t//Se retorna el resultado\n\t\treturn $stmt->fetch();\n\t\t//Se cierra la consulta\n\t\t$stmt->close();\n\t}", "public function consultarTModel($id){\n\t\t//Se prepara la consulta\n\t\t$stmt = Conexion::conectar()->prepare(\"SELECT * FROM tutoria WHERE eliminado = 0 AND id_maestro='$id'\");\n\t\t//Se ejecuta la consulta\n\t\t$stmt->execute();\n\t\t//Se retorna los resultados encontrados\n\t\treturn $stmt->fetchAll();\n\t\t//Se cierra la consulta\n\t\t$stmt->close();\n\t}", "function loadPalestrantesById($id) {\n\n\t$palestrantes = new $Palestrantes();\n\t$palestrantes->select($id);\n\treturn $palestrantes;\n\n}", "public function cadastrarMedico()\r\n {\r\n //($nome, $especialidade, $exames, $observacao, $gestante, $idRegistro, $idData) {\r\n\r\n $paciente = $this->db->findStorageRegistro('profile', $_POST['idRegistro']);\r\n $test = false;\r\n if(!empty($paciente[0]) && isset($paciente[0])){\r\n $data = new DataServer($_POST['data'].\" \".$_POST['hora'], \"UFMS\");\r\n $this->db->setStorageData('data', $data);\r\n $med = new Medico($_POST['nome'], $_POST['especializacao'], $_POST['exames'], $_POST['observacao'], $paciente[0]['gestante'], $_POST['idRegistro'], $this->db->getPosicaoBanco('data'));\r\n\r\n $test = $this->db->setStorageMedico('medico', $med);\r\n }\r\n require('View/mostra.php');\r\n }", "public function getById() {\r\n $stmt = $this->conn->prepare(\"SELECT * FROM administrador WHERE codAdministrador=:codAdmin\");\r\n $stmt->bindValue(':codAdmin', $this->getCod());\r\n $stmt->execute();\r\n $this->setRetorno($stmt->fetchAll(PDO::FETCH_ASSOC));\r\n }", "public function selectMarca($UMarca)\n {\n $sql = \"SELECT * FROM `marcas` WHERE `id_marca` = $UMarca\";\n $request = $this->select($sql);\n return $request;\n }", "public function cargarID($id){\n try {\n $query = \"SELECT * from dbozapato where id_zapato = ?\";\n $stmt = $this->CNX->prepare($query);\n $stmt -> execute(array($id));\n return $stmt->fetch(PDO::FETCH_OBJ);\n } catch (Exception $e) {\n die($e->getMessage());\n }\n }", "public function buscarCarreraModel($id){\n\t\t$stmt = Conexion::conectar()->prepare(\"SELECT * FROM carreras WHERE id_carrera = '$id'\");\n\t\t$stmt->execute();\n\t\treturn $stmt->fetch();\n\t\t$stmt->close();\n\n\t}", "function buscar_id($id){\n // $id = 31;\n $sql=\"SELECT id_venta,fecha,cliente,total, CONCAT(usuario.nom,' ',usuario.ape) AS vendedor, totivaex,totbaseivaex,valivaex,totivaap,totbaseivaap,valivaap,basetotal,ivatotal \n FROM venta \n \n JOIN usuario ON vendedor = id_usu\n \n WHERE id_venta = :id\n \";\n $query = $this->acceso->prepare($sql);\n $query->execute(array(':id'=>$id));\n $this->objetos=$query->fetchall();\n return $this->objetos;\n }", "public function get_medio_pago($id) {\n $sql = \"SELECT * FROM mediospago WHERE medi_clave = $id\";\n\n $result = pg_query($this->conn, $sql);\n\n //Si no hay resultados devuelve un arreglo vacio\n if(!$result)\n return array();\n else\n return pg_fetch_assoc($result); \n }", "public static function getData($id)\n {\n return DB::select(\"SELECT\n a.id,\n b.descripcion compromiso,\n a.fecha,\n a.resultados,\n a.dificultades,\n a.recomendaciones\n FROM InicConvenioMarcoCompromisoImplementacion a\n LEFT JOIN (\n SELECT * FROM InicConvenioMarcoCompromiso\n ) b ON b.id = a.codInicCompromiso\n WHERE b.codInicConvenioMarco = $id\");\n }", "public function index($id_carrera)\n {\n $usuario = Auth::user();\n //dd($usuario);\n $materias = Materia::whereHas(\"carrera\", function ($query) use ($id_carrera){\n $query->where(\"id\", $id_carrera);\n })->whereHas(\"usuarios\", function ($query) use ($usuario){\n $query->where(\"id\", $usuario->id);\n })->get();\n\n foreach ($materias as $materia){\n $materia->imagen = asset($materia->imagen);\n }\n\n if(!count($materias))\n return response()->json(null, 204);\n else\n return $materias;\n }", "public function show($id){\n\t\t\t\n\t\t/*============================================\n\t\tMostrar todos los registro\n\t\t============================================*/\n\n\t\t$alumnos = ModeloAlumno::show(\"alumnos\", $id);\n\n\t\tif (!empty($alumnos)) {\n\n\t\t\t$json = array(\n\t\t\t\t\"status\"=>200,\n\t\t\t\t\"detalle\"=> $alumnos\n\t\t\t);\n\n\t\t\techo json_encode($json, true);\n\t\t\treturn;\n\t\t}else{\n\n\t\t\t$json = array(\n\t\t\t\t\"status\"=>200,\n\t\t\t\t\"total_registros\"=>0,\n\t\t\t\t\"detalle\"=> \"No hay ningún registro\"\n\t\t\t);\n\n\t\t\techo json_encode($json, true);\n\t\t\treturn;\n\t\t}\n\n\t}", "public function load($id){\n\t\t$sql = 'SELECT * FROM comentarios WHERE id_comentarios = ?';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\t$sqlQuery->setNumber($id);\n\t\treturn $this->getRow($sqlQuery);\n\t}", "public function getId() {\n // Create query\n $query = 'SELECT p.id, p.descripcion, m.nombre marca, c.nombre categoria,\n GROUP_CONCAT(co.codigo) codigoStr, p.fechaUltimaModificacion, p.fechaBaja\n FROM ' . $this->table . ' p\n INNER JOIN categoria c on c.id = p.categoriaId\n INNER JOIN marca m on m.id = p.marcaId\n INNER JOIN productocodigo pc on pc.productoId = p.id\n INNER JOIN codigo co on co.id = pc.codigoId\n WHERE id = ? LIMIT 0,1';\n\n // Prepare statement\n $stmt = $this->conn->prepare($query);\n\n // Bind ID\n $stmt->bindParam(1, $this->id);\n\n // Execute query\n $stmt->execute();\n\n $row = $stmt->fetch(PDO::FETCH_ASSOC);\n\n // Set properties\n $this->id = $row['id'];\n \n $this->descripcion = $row['descripcion'];\n $this->marca = $row['marca'];\n $this->categoria = $row['categoria'];\n $this->codigoStr = $row['codigoStr'];\n $this->fechaUltimaModificacion = $row['fechaUltimaModificacion'];\n $this->fechaBaja = $row['fechaBaja'];\n }" ]
[ "0.67273295", "0.6486712", "0.6468441", "0.64494276", "0.6349164", "0.6281043", "0.6262903", "0.62606025", "0.62569916", "0.62370914", "0.6225638", "0.62209314", "0.62119234", "0.6203537", "0.6202008", "0.6187352", "0.6181332", "0.61782855", "0.6172607", "0.61724794", "0.61716604", "0.6171122", "0.616473", "0.61548615", "0.6130062", "0.61133575", "0.61110675", "0.6105737", "0.6104572", "0.60949314" ]
0.65949625
1
return true if the database was selected successully, false otherwise
private static function selectDatabaseIfNecessary() { if (strcasecmp(DatabaseManager::$lastDatabaseSelected, SystemDatabaseManager::$dbName) != 0) { if (DatabaseManager::selectDatabase(SystemDatabaseManager::$dbName, SystemDatabaseManager::$instance->connection)) { DatabaseManager::$lastDatabaseSelected = SystemDatabaseManager::$dbName; } else { return false; } } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private function db_select(){\n // Attempt to select the database by name\n $select = mysqli_select_db($this->LINK, $this->NAME);\n // If the select was not successful, return false\n if ($select === false){\n $this->critical_error(\"<strong>cms_database::db_select</strong> : Critical error! Unable to select the database &lt;{$this->NAME}&gt;!<br />[MySQL Error \".mysqli_errno($this->LINK).\"] : &quot;\".mysqli_errno($this->LINK).\"&quot;\");\n return false;\n }\n // Return true\n return true;\n }", "static function in_database() {\n $class = $this->class;\n\n $db = DB::connect();\n\n try {\n $result = $db->prepare(\"SELECT * FROM $class\")->execute();\n } catch (Exception $e) {\n return false;\n }\n\n return true;\n }", "private function db_select(){\n \t// Attempt to select the database by name\n $select = @mysql_select_db($this->NAME);\n // If the select was not successful, return false\n if ($select === false){\n $error_message = \"<strong>plutocms_database::db_select</strong> : Critical error! Unable to select the database &lt;{$this->NAME}&gt;!<br />[MySQL Error \".@mysql_errno().\"] : &quot;\".@mysql_error().\"&quot;\";\n if ($this->CMS){ $this->CMS->message($error_message, PLUTOCMS_ERROR); }\n else { echo $error_message; }\n return false;\n }\n // Return true\n return true;\n }", "private function compareAvailableSelected() {\n\t\tif (in_array($this->couchDB, $this->couches)) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tthrow new Exception(\"Selected Database not available\", 900843510546, $previous);\n\t\t}\n\t}", "public function select_db(){\n return mysqli_select_db($this -> con,$this -> dbase) or die(\"cant select dbase \".mysqli_error($this -> con));\n return true;\n \n }", "private function UseDB(){\nif(!mysql_select_db($this->database, $this->databaseLink)){\n$this->lastError = 'Cannot select database: ' . mysql_error($this->databaseLink);\nreturn false;\n}else{\nreturn true;\n}\n}", "public function sendToDatabase()\n {\n return settings()->get('enable_database') && !$this->disabledFor(\"database\");\n }", "function querySuccess(){\n\t\treturn $this -> result === TRUE;\n\t}", "public function is_valid_db() {\n if ($this->dbcount > 0) {\n return true;\n } else {\n return false;\n }\n }", "public function isnew() {\n $this->result = $this->db->query($this->query);\n \tif (empty($this->result)){\n \t\treturn false;\n \t} else {\n \t\treturn true;\n \t}\n }", "protected function checkSelectQuery()\n\t{\n\t\t// Run the query, check if it picked up anything.\n\t\t$result = $this->db->query($this->query);\n\t\t$totalResults = count($result);\n\t\tif ($totalResults <= 0) {\n\t\t\t$this->error = 'No releases were found to delete, try changing your criteria.';\n\t\t\treturn false;\n\t\t}\n\t\t$this->result = array('total' => $totalResults, 'result' => $result);\n\t\treturn true;\n\t}", "function m_verifyInsertOption()\n\t{\n\t\t$this->obDb->query = \"select iOptionid_PK from \".OPTIONS.\" where vName = '\".$this->request['name1'].\"'\";\n\t\t$row_code = $this->obDb->fetchQuery();\n\t\tif($this->obDb->record_count != 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn true;\n\t}", "public function check_is_same_db() {\n\t\treturn isset($this->options['separate_db'])?(bool)$this->options['separate_db']: false;\n\t}", "private function database_is_valid()\n {\n try {\n $result = $this->db->query('SELECT version FROM db_version');\n if(!$result)\n return false;\n\n //check if our current version matches\n $versionArray = $result->fetch();\n if(sizeof($versionArray) < 1)\n return false;\n\n if($versionArray[0] != self::DB_VERSION)\n return false;\n\n // dummy query to test each table\n foreach($this->db_structure as $table_name => &$tables_def) {\n $testQuery = \"SELECT \";\n $first = true;\n foreach($tables_def as $column => $type) {\n //do not add a comma before the first column\n if(!$first)\n $testQuery .= ',';\n else\n $first = false;\n\n $testQuery .= '`'.$column.'`';\n }\n $testQuery .= \" FROM \".$table_name.\" LIMIT 1\";\n $result = $this->db->query($testQuery);\n if(!$result)\n return false;\n }\n } catch (Exception $e) {\n //something went wrong\n return false;\n }\n\n //all ok\n return true;\n }", "function db_select($db_id)\n {\n $db = $this->db_fetch($db_id);\n if ($db === false) {\n $this->alerts->add(\"error\", '401');\n return false;\n }\n if (empty($db['rights'][$this->user->user_current()['ou_id']]) or $db['rights'][$this->user->user_current()['ou_id']]['db_access_right'] < 1) {\n $this->alerts->add(\"error\", '402');\n return false;\n }\n $this->cache->clear('all');\n $this->current['db_id'] = $db_id;\n $this->db_fields_display_set_default();\n return true;\n }", "final private function connect(){\n\t\t\tif($this->db){\n\t\t\t\treturn true;\n\t\t\t}else{\n\t\t\t\treturn false;\t\t\t\t\t\n\t\t\t}\n\t\t}", "private function exists()\n\t{\n\t\tif ($result = $this->mysqli->query(\"SELECT DATABASE()\")) \n\t\t{\n\t\t $row = $result->fetch_row();\n\n // If the row is empty, then the database doesn't exist.\n\t\t if($row[0] == \"\")\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t $result->close();\n\t\t}\n\n\t\treturn true;\n\t}", "function UseDB() {\r\n if (!mysql_select_db($this->sDatabase, $this->sDBLink)) {\r\n $this->sLastError = 'Cannot select database: ' . mysql_error($this->sDBLink);\r\n return false;\r\n } else {\r\n mysql_charset($this->sDBLink);\r\n return true;\r\n }\r\n }", "function isDataBaseConnectionEstablished() {\n return isset($this->db);\n }", "protected function databaseIsReady()\n {\n $scriptName = basename($_SERVER['SCRIPT_FILENAME']);\n $dbname = $this->dbvc->config->db->dbname;\n \n if (!$this->dbvc()->db()->exists()) {\n $message = \"Database '$dbname' doesn't exist.\";\n if ($this->dbvc()->getDBSchema()) $message .= \" Run `$scriptName create` to create it.\";\n \n $this->writeerr(\"$message\\n\");\n return false;\n }\n\n if (!$this->dbvc()->db()->isInitialised()) {\n $this->writeerr(\"Database '$dbname' isn't initialised yet. Run `$scriptName init`.\\n\");\n return false;\n }\n \n return true;\n }", "public function _selectDB()\r\n\t{\r\n\t\t// Nothing to do\r\n\t}", "public function databaseInitialised()\r\n {\r\n return !empty($this->database_handler);\r\n }", "public function inDB()\n {\n return $this->in_db;\n }", "function checkDbConnection() {\n\t\t$db = owa_coreAPI::dbSingleton();\n\t\t$db->connect();\n\t\tif ($db->connection_status === true) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\n\t}", "public function checkDB()\n\t{\n\t\ttry {\n\t\t\tDB::getPdo();\n\t\t} catch (\\Exception $e) {\n\t\t\t// print($e->getMessage());\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "public function hasDb(): bool;", "public function exists_in_database ()\n {\n $storage = $this->_make_storage ();\n return $storage->object_exists ($this);\n }", "public function select($database)\r\n\t{\r\n\t\tif ( ! $database )\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tif ( !mysql_select_db( $database, $this->resource )) {\r\n\t\t\t$this->errorNum = 3;\r\n\t\t\t$this->errorMsg = 'Could not connect to database';\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\t// if running mysql 5, set sql-mode to mysql40 - thereby circumventing strict mode problems\r\n\t\t$verParts = explode( '.', $this->getVersion() );\r\n\t\tif ( $verParts[0] == 5 ) {\r\n\t\t\t$this->setQuery( \"SET sql_mode = 'HIGH_NOT_PRECEDENCE'\" );\r\n\t\t\t$this->query();\r\n\t\t\t$this->resetErrors();\r\n\t\t}\r\n\r\n\t\treturn true;\r\n\t}", "function select_db( $dbname, $dbh ) {\t\t\r\n\t\tif (!mysql_select_db( $dbname, $dbh )) {\r\n\t\t\t$this->set_error('Could not select database: ' . mysql_error());\r\n\t\t\treturn false;\r\n\t\t} else {\r\n\t\t\t$this->clear_error();\t\t\t\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}", "public function isConnected(){\n if($this->dbconnected){\n echo \"DB Connected\".PHP_EOL;\n } else {\n echo \"DB Not Connected.\".PHP_EOL;\n }\n return $this->dbconnected;\n }" ]
[ "0.7255306", "0.71596456", "0.7059158", "0.70480645", "0.69999737", "0.69633895", "0.6819804", "0.6737391", "0.6730276", "0.6632038", "0.6602275", "0.6583443", "0.6511321", "0.64991385", "0.646936", "0.64585704", "0.6439688", "0.6429316", "0.641289", "0.6398959", "0.637859", "0.6321882", "0.62977725", "0.62671477", "0.62578136", "0.62512845", "0.6234267", "0.6225012", "0.6198527", "0.6184887" ]
0.75423366
0
executes an INSERT/UPDATE/Delete in the database, executeUpdate function runs the query in transaction but this function does not run query in transaction, this kind of function is needed only when you need multiple queries to run in a transaction by calling startTransaction and commitTransaction functions of SystemDatabaseManager class.
public function executeUpdateInTransaction($update, $comment = '') { global $sessionHandler; if (!SystemDatabaseManager::selectDatabaseIfNecessary()) { logError("Failed to select system database while executing $update", ERROR_SEVERITY); return false; } $sessionHandler->setSessionVariable('IdToQueryDescription',$update); SystemDatabaseManager::$writeQueries[] = $update; SystemDatabaseManager::$writeQueryComments[] = $comment; return parent::executeUpdateInTransaction($update); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function executeUpdate($sqlQuery);", "function execute() {\r\n\t\tswitch ( $this->queryType ) {\r\n\t\t\tcase \"select\":\r\n\t\t\t\t$sql = $this->select();\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"insert\":\r\n\t\t\t\t$sql = $this->insert();\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"delete\":\r\n\t\t\t\t$sql = $this->delete();\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"update\":\r\n\t\t\t\t$sql = $this->update();\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\t$result = $this->dataManager->execute($sql);\r\n\t\treturn $result;\r\n\t}", "public function execute()\n\t{\n\t\t$this->statement->execute();\n\t}", "protected function execute()\n {\n $this->statement->execute();\n $this->dispatcher->now('db-query', ['statement' => $this->statement->queryString, 'bindings' => json_encode($this->bindings)]);\n }", "public function execute()\r\n\t{\r\n\t\t$this->forceSystemAuthentication();\r\n\t\t\r\n\t\tmyDbHelper::$use_alternative_con = null;\r\n\t\t\r\n\r\n\t\t$command = $this->getP ( \"command\" );\r\n\r\n\t\tif ( $command == \"updateEntry\" )\r\n\t\t{\r\n\t\t\t$id = $this->getP ( \"id\" );\r\n\t\t\t$entry = entryPeer::retrieveByPK( $id );\r\n\t\t\t\r\n\t\t\tif ( $entry )\r\n\t\t\t{\r\n\t\t\t\t$name = $this->getP ( \"name\" );\r\n\t\t\t\t$value = $this->getP ( \"value\" );\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t$obj_wrapper = objectWrapperBase::getWrapperClass( $entry , 0 );\r\n\t\t\t\t$updateable_fields = $obj_wrapper->getUpdateableFields( \"2\" );\r\n\t\t\t\tif ( ! in_array ( $name , $updateable_fields ) ) die();\r\n\r\n\t\t\t\tif ( $name )\r\n\t\t\t\t{\r\n\t\t\t\t\t$setter = \"set\" . $name;\r\n\t\t\t\t\tcall_user_func( array ( $entry , $setter ) , $value );\t\r\n\t\t\t\t\t$entry->save();\t\t\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tdie();\r\n\t}", "public function executeQuery();", "public function executeQuery();", "private function update() {\n // use prepared statements\n }", "public function executeStatement($params) {\r\n if($this->sql !== $params->sql) { \r\n $this->sql = $params->sql; \r\n $this->prepared = false; \r\n }\r\n try {\r\n $this->prepareStatement(); \r\n\r\n switch ($params->action) {\r\n case \"select\" :\r\n return $this->selectData($params);\r\n break;\r\n\r\n case \"insert\" :\r\n return $this->insertData($params);\r\n break;\r\n\r\n case \"update\" :\r\n return $this->updateData($params);\r\n break;\r\n }\r\n }\r\n catch (Exception $e) { echo json_encode($e->getMessage());\r\n throw new Exception(\"Database_Error\");\r\n } \r\n }", "public function executeUpdate($update, $comment = '') {\n\t\tglobal $sessionHandler; \n\t\tif (!SystemDatabaseManager::selectDatabaseIfNecessary()) {\n\t\t\tlogError(\"Failed to select system database while executing $update\", ERROR_SEVERITY);\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t\n\t\t$sessionHandler->setSessionVariable('IdToQueryDescription',$update); \t\n\t\tSystemDatabaseManager::$writeQueries[] = $update;\n\t\tSystemDatabaseManager::$writeQueryComments[] = $comment;\n\t\treturn parent::executeUpdate($update);\t\t\n\t}", "public function commitTransaction() {\n if (!SystemDatabaseManager::selectDatabaseIfNecessary()) {\n logError(\"Failed to select system database while executing $update\", ERROR_SEVERITY);\n return false;\n }\n return parent::commitTransaction(); \n }", "public function executeUpdate($params = null) \r\n {\r\n\t\tforeach ( (array) $params as $i=>$param ) {\r\n\t\t\t$this->set ( $i + 1, $param );\r\n\t\t\tunset ( $i, $param );\r\n\t\t}\r\n\t\tunset ( $params );\r\n\r\n if($this->resultSet) $this->resultSet->close();\r\n $this->resultSet = null; // reset \r\n $sql = $this->replaceParams(); \r\n $this->updateCount = $this->conn->executeUpdate($sql);\r\n return $this->updateCount;\r\n }", "public function commit(){\n\n\t\t$sql = new Sql( $this->dbAdapter );\n\t\tforeach( $this->prototypeArray as &$prototype ){\n\t\t\t$prototype->updateIds();\n\t\t\t// 1. If the ids aren't populated, then it attempts to populate them based on \n\t\t\t// the other fields of this object.\n\t\t\tif( $prototype->getId() == 0 ){\n\t\t\t\t// Find the existing item in the database\n\t\t\t\t$where = new Where();\n\t\t\t\t$firstloop=true;\n\t\t\t\tforeach( $this->updateKey as $column ){\n\t\t\t\t\tif($firstloop){\n\t\t\t\t\t\t$firstloop=false;\n\t\t\t\t\t}else{\n\t\t\t\t\t\t$where->and;\n\t\t\t\t\t}\n\t\t\t\t\t$where->equalTo($column,$prototype->get($this->columnMap[$column]));\n\t\t\t\t}\n\t\t\t\t$result = $this->runSelect( $this->dbTable, $where );\n\t\t\t\t// If there is a match\n\t\t\t\tif( $result->current() ){\n\t\t\t\t\t$prototype->setId($result->current()[ $this->primaryKey ]);\n\n\t\t\t\t\t// Ensure that there is only one match\n\t\t\t\t\t$result->next();\n\t\t\t\t\tif( $result->current() ){\n\t\t\t\t\t\t$prototype->setId(0);\n\t\t\t\t\t\tthrow new \\LogicException( \"There are multiple entries in the database that match the update key '\".var_export($this->updateKey).\"'. This should be unique.\" );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t$sql = new Sql( $this->dbAdapter );\n\t\tforeach( $this->prototypeArray as &$prototype ){\n\t\t\t// 2. If then the ids still aren't populated, it will create new records in \n\t\t\t// the database\n\t\t\tif( $prototype->getId() > 0 ){\n\t\t\t\t$update = $sql->update( $this->dbTable );\n\t\t\t\t$data = $this->hydrator->extract( $prototype );\n\t\t\t\t$update->set( $data );\n\t\t\t\t$where = new Where();\n\t\t\t\t$where->equalTo( $this->primaryKey, $prototype->getId() );\n\t\t\t\t$update->where( $where );\n\t\t\t\t$stmt = $sql->prepareStatementForSqlObject( $update );\n\t\t\t\t$result = $stmt->execute();\n\n\t\t\t// 3. If the ids are populated, then it will try to update the existing \n\t\t\t// records.\n\t\t\t} else {\n\t\t\t\t$insert = $sql->insert( $this->dbTable );\n\t\t\t\t$data = $this->hydrator->extract( $prototype );\n\t\t\t\t$insert->values( $data );\n\t\t\t\t$stmt = $sql->prepareStatementForSqlObject( $insert );\n\t\t\t\t$result = $stmt->execute();\n\t\t\t\t$prototype->setId( $this->dbAdapter->getDriver()->getLastGeneratedValue() );\n\t\t\t}\n\t\t}\n\t}", "public function executeInsert($sqlQuery);", "function update(){\n\t\t do_dbDelta(Configuration::getQueries());\n }", "public function update ($params) {\r\n try {\r\n $this->setupQuery($params);\r\n return $this->statement->execute((array)$params->data);\r\n }\r\n catch (Exception $e) {\r\n /*TEST*/ echo json_encode($e->getMessage());\r\n throw new Exception(\"Database_Error\");\r\n } \r\n }", "abstract protected function executeQuery($query);", "public function execute($query);", "public function executeTransaction(array $queries);", "public function executeUpdate()\n {\n $this->initImporter();\n Transform\\Transformers\\Transformer::unSerializeMappings();\n EntityPopulator::populateEntities($this->parser);\n $this->serializeLastCreatedIds();\n $this->checkForErrors();\n Transform\\Transformers\\Transformer::serializeMappings();\n }", "public function execute() {\r\n $masterSql = \"\";\r\n switch ( $this->queryType ) {\r\n\t\t\r\n case \"search\";\r\n $sql = $this->select();\r\n $this->tableName = $this->tableName.\"Search\";\r\n break;\r\n\r\n case \"select\":\r\n $sql = $this->select();\r\n break;\r\n\r\n case \"insert\":\r\n $sql = $this->insert();\r\n $this->db->test($sql);\r\n $masterSql = \"insert into masterID ( object_ID, tableName, authoroid ) \";\r\n $masterSql .= \"values ( '\".$this->object_ID.\"', '\".\r\n $this->tableName.\"', '\".$_REQUEST['authoroid'].\"' )\";\r\n break;\r\n\r\n case \"delete\":\r\n $sql = $this->delete();\r\n $masterSql = \"delete from masterID where object_ID = '\".$this->object_ID.\"'\";\r\n break;\r\n\r\n case \"update\":\r\n $sql = $this->update();\r\n $this->db->test('Execute update: '.$sql);\r\n $masterSql = \"update masterID set entryDate = '\".date('Y-m-d H:i:s').\r\n \"' where object_ID = '\".$this->object_ID.\"'\";\r\n break;\r\n }\r\n \r\n // Work first with the masterid table. Manage inserts, updates, and selects.\r\n if ( strlen($masterSql) > 0 ) {\r\n $master_result = $this->db->execute($masterSql);\r\n $this->db->test($masterSql);\r\n if ($master_result != 1) {\r\n $this->db->test(\"Master ID failure.\");\r\n return $master_result;\r\n }\r\n }\r\n \r\n // SQL finished, now execute the constructed statement.\r\n $result = $this->db->execute($sql);\r\n \r\n return $result;\r\n \r\n }", "function executeSQLquery( )\n {\n }", "private function execute()\n\t{\n\t\t$this->connect();\n\t\ttry {\n\t\t\t$this->create->execute($this->data);\n\t\t\t$this->result = $this->connection->lastInsertId();\n\t\t} catch (PDOException $e) {\n\t\t\t$this->result = null;\n\t\t\tErro(\"<b>Erro ao cadastrar:</b> {$e->getMessage()}\", $e->getCode());\n\t\t}\n\t}", "public function commit() {\n $commit = $this->ObjConnection->commit();\n if( $commit === false ) {\n throw new ErrorHandler(EXC_DB_EXEC);\n }\n }", "public function commit()\n\t\t{\n\t\t\tif($this->mode == AFRAME_DB_MODE_MYSQL)\n\t\t\t{\n\t\t\t\t$qry\t=\t\"commit\";\n\t\t\t}\n\t\t\telse if($this->mode == AFRAME_DB_MODE_MYSQLI)\n\t\t\t{\n\t\t\t\t$qry\t=\t\"commit\";\n\t\t\t}\n\t\t\telse if($this->mode == AFRAME_DB_MODE_MSSQL)\n\t\t\t{\n\t\t\t\t$qry\t=\t\"commit transaction\";\n\t\t\t}\n\t\t\t$this->query($qry);\n\t\t\t\n\t\t\t$this->in_transaction\t=\tfalse;\n\t\t}", "public function executeUpdate(UpdateQueryInterface $query): int;", "public function execute(){\r\n /*try{\r\n $exec = $this->stmt->execute();\r\n }catch(Exception $e){\r\n $exec = $e;\r\n }\r\n return $exec;*/\r\n return $this->stmt->execute();\r\n }", "public function execute()\n {\n if ($this->type == self::SELECT) {\n $this->loaded = true;\n if ($this->cacheTime !== false) {\n return $this->fetchFromCache();\n } else {\n return $this->db->fetchAll($this->getSql(), $this->params, $this->paramTypes);\n }\n } else {\n return $this->db->executeUpdate($this->getSql(), $this->params, $this->paramTypes);\n }\n }", "public function execute() {\n\n\t\t// Remueve los resultados previamente almacenados\n\t\t$this->_fetchAll \t = null;\n\t\t$this->_fetchObject = null;\n\t\t$this->_fetch \t\t = null;\n\t\t$this->_lastInsertId = null;\n\n\t\t// Obtiene la consulta\n\t\t$sql = $this->_getSQL() . ';';\n\n\t\t// Obtiene la sentencia preparada\n\t\t$this->_pdoStm = $this->_PDOConnection->prepare($sql, $this->_params);\n\n\t\t// Ejecuta la sentencia\n\t\t$result = $this->_pdoStm->execute();\n\n\t\t// Verifica si se produjo un error\n\t\t$lastError = $this->_PDOConnection->getLastError();\n\t\tif (isset($lastError)) {\n\t\t\tthrow new FwException_QueryBuilder('pdo-exception', null, [ 'code' => $lastError['code'], 'message' => $lastError['message'] ]);\n\t\t}\n\n\t\t// Obtiene el valor de la última llave primaria insertada\n\t\t$this->_lastInsertId = $this->_PDOConnection->getLastInsertId();\n\t}", "private function _update() {\n // SQL query\n $sql = \"UPDATE {$this->getTableQuery()} SET {$this->prepareSet()} {$this->getWhereQuery()}\";\n\n // prepare SQL\n $statement = $this->db->prepare($sql);\n // bind data\n $statement = $this->bindData($statement);\n // bind where clause\n $statement = $this->bindWhere($statement);\n\n // notify\n $this->logger->notify($this->toString($sql));\n\n // reset data\n $this->clearData();\n\n // execute query and return rows affected count\n $statement->execute();\n return $statement->rowCount();\n }" ]
[ "0.6809482", "0.66938263", "0.65661377", "0.6530995", "0.64602494", "0.64433", "0.64433", "0.6268432", "0.6252707", "0.6233105", "0.6047711", "0.598403", "0.5976784", "0.5924512", "0.5917597", "0.58882517", "0.58687675", "0.5847817", "0.58345574", "0.58118534", "0.5801843", "0.5801761", "0.5784638", "0.57713085", "0.57672507", "0.5753259", "0.57255465", "0.57243043", "0.57078475", "0.570119" ]
0.6818715
0
initializes the system database
public static function init() { if (SystemDatabaseManager::$instance == 0) { SystemDatabaseManager::$instance = new SystemDatabaseManager(); } SystemDatabaseManager::$instance->createDatabase(SystemDatabaseManager::$dbName); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private static function initDatabase() {\n self::$db = new Database();\n\t}", "abstract public function initializeDatabase();", "protected static function init () {\r\n // If there's no table to store database versions, create it.\r\n if (!App::database()->tableExists(static::$db_table)) {\r\n $fields = array();\r\n $fields[] = \"uid INT(11) UNSIGNED AUTO_INCREMENT\";\r\n $fields[] = \"version VARCHAR(30) NOT NULL\";\r\n $fields[] = \"updated INT(10) UNSIGNED NOT NULL\";\r\n\r\n // Make the database.\r\n App::database()->createTable(static::$db_table, static::$primary_key, $fields);\r\n }\r\n }", "protected function _initDatabase(){\n\t\t// get config from config/application.ini\n\t\t$config = $this->getOptions();\n\t\n\t\t$db = Zend_Db::factory($config['resources']['db']['adapter'], $config['resources']['db']['params']);\n\t\n\t\t//set default adapter\n\t\tZend_Db_Table::setDefaultAdapter($db);\n\t\n\t\t//save Db in registry for later use\n\t\tZend_Registry::set(\"db\", $db);\n\t}", "public function initializeDatabaseSystem()\n {\n // won't be initialized until it is actually requested.\n require_once DRUPAL_ROOT . '/includes/database/database.inc';\n }", "function initialize_db() {\r\n\t\t\t$name = $this->properties['prefix'] . \"-log\";\r\n\t\t\t$statement = \"id mediumint(9) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\trpc_date datetime,\r\n\t\t\t\tUNIQUE KEY id (id)\";\r\n\t\t\t$this->create_table($name, $statement);\r\n\t\t}", "public function init()\n {\n $this->db = Instance::ensure($this->db, Connection::className());\n }", "private function initDatabase() {\n\t\tif ($this->db) return;\n\t\t// @todo cache for structure\n//\t\tif (file_exists(__DIR__ . '/' . $this->cache)) {\n//\t\t\t$cache = file_get_contents(__DIR__ . '/' . $this->cache);\n//\t\t\t$this->db = unserialize($cache);\n//\t\t\treturn;\n//\t\t}\n\t\t$query = \"\n\t\t\tSELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE\n\t\t\tFROM information_schema.COLUMNS\n\t\t\tWHERE TABLE_SCHEMA = DATABASE()\n\t\t\";\n\t\t$database = $this->connection->query($query)->fetchAll(PDO::FETCH_GROUP + PDO::FETCH_NUM);\n\t\tforeach ($database as $table => $fields) {\n\t\t\tforeach ($fields as $value) {\n\t\t\t\t$this->db[$table][$value[0]] = $value[1];\n\t\t\t}\n\t\t}\n//\t\tif (file_exists($this->cache)) {\n//\t\t\t\\Nette\\Diagnostics\\Debugger::barDump('exists', __METHOD__ . ':' . __LINE__);\n//\t\t}\n//\t\tfile_put_contents(__DIR__ . '/' . $this->cache, serialize($this->db));\n\t}", "protected function initializeDatabase() {\n\t\tif (!$this->client->databaseExists($this->databaseName)) {\n\t\t\t$this->client->createDatabase($this->databaseName);\n\t\t}\n\t}", "protected function _initDatabase()\n {\n //$dsn = $config->db->dsn;\n //$user = $config->db->username;\n //$password = $config->db->password;\n\n //$conn = new Db($dsn, $user, $password);\n //$conn->setAttribute(\\PDO::ATTR_DEFAULT_FETCH_MODE, \\PDO::FETCH_OBJ);\n //$conn->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n\n //\\Zend_Registry::set('conn', $conn);\n }", "public function initDatabase()\n {\n $this->call('migrate');\n\n $userModel = config('idiom.database.rd_cyjl');\n\n /*if ($userModel::count() == 0) {\n $this->call('db:seed', ['--class' => \\Encore\\Admin\\Auth\\Database\\AdminTablesSeeder::class]);\n }*/\n }", "function dbInit()\n {\n if ( $this->IsConnected == false )\n {\n $this->Database = eZDB::globalDatabase();\n $this->IsConnected = true;\n }\n }", "final public function initialise(){\n\t\t$dbconfig = $this->getConfigSection('database');\n\t\t\n\t\t//if(\"dbtb01\"==(string)$dbconfig->database->attributes()->name){\n\t\tDEFINE ('DB_USER', (string)$dbconfig->database->user);\n\t\tDEFINE ('DB_PASSWORD', (string)$dbconfig->database->password);\n\t\tDEFINE ('DB_HOST', (string)$dbconfig->database->host);\n\t\tDEFINE ('DB_NAME', (string)$dbconfig->database->name); \n\t\n\t\t\n\t\t// Make the connnection and then select the database.\n\t\t$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR Die ('Could not connect to MySQL.');\n\t\tmysql_select_db (DB_NAME) OR Die ('Could not select the database.');\n\t\t\n\t}", "private function _init()\n {\n $val = Environment::get(\"database\");\n try\n {\n $connectionString = $val['driver'].\": host = \".$val['host'].';dbname='.$val['dbname'].';charset='.$val['charset'];\n $this->_db = new DataBase($connectionString , $val['user'] , $val['password']);\n }\n catch(\\PDOException $e)\n {\n dump($e->getMessage());\n }\n }", "public function init()\n {\n parent::init();\n $this->db = Instance::ensure($this->db, Connection::className());\n }", "public static function initDatabase()\n {\n static::_deleteDatabase();\n static::_createConnection();\n static::_createTestSchema();\n static::_createMigrations();\n static::_applyMigrations();\n }", "function dbInit()\n {\n if ( $this->IsConnected == false )\n {\n $this->Database =& eZDB::globalDatabase();\n $this->IsConnected = true;\n }\n }", "protected function _initDb() {\n $this->config = new Zend_Config_Ini(APPLICATION_PATH\n . '/configs/application.ini',\n APPLICATION_ENV);\n \n $zendConfig = $this->config->toArray();\n\n Zend_Registry::set('config',$zendConfig);\n // connect to site database\n $db = Zend_Db::factory($zendConfig['resources']['db']['adapter'], $zendConfig['resources']['db']['params']['aon']);\n Zend_Db_Table::setDefaultAdapter($db);\n Zend_Registry::set('db', $db);\n\n\n\t\t\n\n }", "public function init()\n {\n\n// if (! file_exists($this->db_path) ){\n// touch($this->db_path);\n// }\n\n $this->db = new PDO(\"sqlite:$this->db_path\");\n\n try {\n $this->db->exec('\n CREATE TABLE IF NOT EXISTS '.TABLE_NAME.' (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n name TEXT NOT NULL , \n status TEXT, \n time_checked TIMESTAMP DEFAULT current_timestamp\n )');\n } catch(\\PDOException $e) {\n die('Error setting up database: '. $e->getMessage());\n }\n }", "protected function _initDb()\n {\n $this->bootstrap('multidb');\n \t$resource = $this->getPluginResource('multidb');\n \tZend_Registry::set(\"multidb\", $resource);\n \tZend_Registry::set(\"appdb\", $resource->getDb('appdb'));\n \tZend_Registry::set(\"docdb\", $resource->getDb('docdb'));\n }", "function Database() {\n\t\tEnvironment\\DbInit($this->Host, $this->Database, $this->User, $this->Password);\n\t}", "public function init()\r\n {\r\n parent::init();\r\n $this->db = Instance::ensure($this->db, Connection::className());\r\n $this->cache = Yii::$app->cache;\r\n }", "function initDb()\n\t{\n\t\tglobal $xml;\n\t\t$xml \t= simplexml_load_file(XML_DATABASE_PATH);\n\t}", "public function initDatabase()\n {\n $this->call('migrate', ['--path' => './vendor/oyhdd/hyperf-admin/database/migrations/']);\n $userModel = config('admin.database.user_model');\n\n if ($userModel::count() == 0) {\n $this->call('db:seed', ['--path' => './vendor/oyhdd/hyperf-admin/database/seeders/']);\n }\n }", "function initialize_database()\n{\n\t$model = $this->getModel(\"filemanager\");\n\t$model->initialize_database();\n\t\n}", "function db_init()\n{\n\tglobal $db, $db_type, $db_host, $db_port, $db_user, $db_password, $db_dbname,\n\t\t$table_prefix;\n\tif ($db)\n\t\treturn;\n\t$db_class = 'Dbal_' . $db_type;\n\t$db = new $db_class;\n\tif (defined('ORZOJ_DEBUG_MODE'))\n\t\t$db->record_query = TRUE;\n\t$db->connect($db_host, $db_port, $db_user, $db_password, $db_dbname);\n\tif (!defined('ORZOJ_DEBUG_MODE'))\n\t\t$db_password = '';\n\t$db->set_prefix($table_prefix);\n}", "function __construct() {\n\t\t$dbPath = \"db/\";\n\t\t$dbName = \"status.db\";\n\n// create new database\n\t\tif (!file_exists($dbPath.$dbName)) {\n\t\t\t$this->db = new Database($dbPath.$dbName);\n\n\t\t\t$this->db->create_table(\"route\",\"ID integer PRIMARY KEY AUTOINCREMENT,name text\");\n\t\t\t$this->db->create_table(\"block\",\"ID integer PRIMARY KEY AUTOINCREMENT,name text,status integer,lock integer,time integer,error integer\");\n\t\t\t$this->db->create_table(\"fifo\",\"ID integer PRIMARY KEY AUTOINCREMENT,name text,block integer,route integer\");\n\n\t\t\t$this->db->create_table(\"signal\",\"ID integer PRIMARY KEY AUTOINCREMENT,name text,status integer,time integer,error integer\");\n\t\t\t$this->db->create_table(\"switch\",\"ID integer PRIMARY KEY AUTOINCREMENT,name text,status integer,time integer,error integer\");\n\t\t}\n\n// open database\n\t\telse\n\t\t\t$this->db = new Database($dbPath.$dbName);\n\t}", "public function initialize()\n {\n $this->setSchema(\"carrillo_dbaurora\");\n }", "protected function initDbTable()\r\n {\r\n }", "public function loadDatabase() {\n\t\t$this->db = new SQLiteDatabase(['db_path' => 'data/opencircuits.db']);\n\t\t$this->db->connect();\n\t}" ]
[ "0.8073244", "0.78492373", "0.7815794", "0.77742803", "0.7766492", "0.7665237", "0.76515114", "0.7648681", "0.7612509", "0.76121056", "0.75961554", "0.7537326", "0.7526428", "0.75238925", "0.74477226", "0.73863363", "0.7346927", "0.7267524", "0.72391194", "0.7231917", "0.71802056", "0.71507525", "0.7116052", "0.70513403", "0.7039862", "0.69941926", "0.6975382", "0.69637316", "0.6961657", "0.6930917" ]
0.8128225
0
returns an array of all the read queries (SELECT QUERIES) performed in the system database
public static function getReadQueries() { return SystemDatabaseManager::$readQueries; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "abstract protected function getQueries();", "public function getQueries(): array;", "public static function getCountReadQueries() {\n\t\treturn count(SystemDatabaseManager::$readQueries);\n\t}", "public function queries()\r\n\t{\r\n\t\treturn $this->query_log;\r\n\t}", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function queryAll(){\n\t\t$sql = 'SELECT * FROM rfi';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\treturn $this->getList($sqlQuery);\n\t}", "function QueryAll()\n\t{\n\t\tglobal $conn;\n\t\t$dalSQL = \"select * from \".AddTableWrappers($this->m_TableName);\n\t\t$rs = db_query($dalSQL,$conn);\n\t\treturn $rs;\n\t}", "public function get_database_calls () {\n\n return $this->SQL_list;\n }", "public function queryAll(){\n\t\t$sql = 'SELECT * FROM cluster';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\treturn $this->getList($sqlQuery);\n\t}", "public function getQueries()\n {\n return $this->queries;\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public function getQueries() {\r\n return $this->queries;\r\n }", "public function getQueries() {\r\n return array_keys(self::$queries);\r\n }", "public static function read_all() { return static::find_by_query( static::$find_all_sql ); }", "public static function queries()\n\t{\n\t\t$result = array();\n\t\t$count = $time = $memory = 0;\n\n\t\t$groups = Profiler::groups();\n\t\tforeach(Database::$instances as $name => $db)\n\t\t{\n\t\t\t\n\t\t\t$group_name = 'database (' . strtolower($name) . ')';\n\t\t\t$group = arr::get($groups, $group_name, FALSE);\n\n\t\t\tif ($group)\n\t\t\t{\t\t\t\t\t\n\t\t\t\t$sub_time = $sub_memory = $sub_count = 0;\n\t\t\t\tforeach ($group as $query => $tokens)\n\t\t\t\t{\n\t\t\t\t\t$sub_count += count($tokens);\n\t\t\t\t\tforeach ($tokens as $token)\n\t\t\t\t\t{\n\t\t\t\t\t\t$total = Profiler::total($token);\n\t\t\t\t\t\t$sub_time += $total[0];\n\t\t\t\t\t\t$sub_memory += $total[1];\n\t\t\t\t\t\t$result[$name][] = array('name' => $query, 'time' => $total[0], 'memory' => $total[1]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$count += $sub_count;\n\t\t\t\t$time += $sub_time;\n\t\t\t\t$memory += $sub_memory;\n\t\t\t\t$result[$name]['total'] = array('count'=>$sub_count, 'time'=>$sub_time, 'memory'=>$sub_memory);\n\t\t\t}\t\t\n\t\t}\n\t\treturn array('count' => $count, 'time' => $time, 'memory' => $memory, 'data' => $result);\n\t}", "function QueryAll()\n\t{\n\t\t$dalSQL = \"select * from \".$this->_connection->addTableWrappers( $this->m_TableName );\n\t\treturn $this->_connection->query( $dalSQL );\n\t}", "public function getQueries() {\n return $this->queries;\n }", "public function queryAll(){\n\t\t$sql = 'SELECT * FROM tbl_coa';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\treturn $this->getList($sqlQuery);\n\t}", "public function queryAll(){\n\t\t$sql = 'SELECT * FROM uavm_task';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\treturn $this->getList($sqlQuery);\n\t}", "public function queryAll();", "public function queryAll();", "public function queryAll();", "public function queryAll();", "public function queryAll();", "public function queryAll();", "public function queryAll();" ]
[ "0.73369443", "0.72143626", "0.69583684", "0.6953019", "0.69425833", "0.69425833", "0.69425833", "0.6868156", "0.6868156", "0.6837517", "0.6730825", "0.6693891", "0.66826487", "0.66781074", "0.66781074", "0.66699004", "0.6665177", "0.6660916", "0.6653199", "0.663729", "0.6600543", "0.65582544", "0.6542116", "0.65353125", "0.65353125", "0.65353125", "0.65353125", "0.65353125", "0.65353125", "0.65353125" ]
0.81731063
0
returns the total number of read queries (SELECT QUERIES) performed in the system database
public static function getCountReadQueries() { return count(SystemDatabaseManager::$readQueries); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getTotalQueries() : int\n {\n return 1;\n }", "public function queries () {\n\t\t$queries = 0;\n\t\t/**\n\t\t * @var DB\\_Abstract $c\n\t\t */\n\t\tforeach ($this->connections[self::CONNECTIONS_MASTER] as $c) {\n\t\t\t$queries += $c->queries_count();\n\t\t}\n\t\tforeach ($this->connections[self::CONNECTIONS_MIRROR] as $c) {\n\t\t\t$queries += $c->queries_count();\n\t\t}\n\t\treturn $queries;\n\t}", "function num_queries()\n\t{\n\t\treturn $this->queries;\n\t}", "function getNumQueries()\n\t{\n\t\treturn $this->query_count;\n\t}", "public function getNumQueries() {\n\t\t$n = 0;\n\t\tforeach($this->connections as $c) {\n\t\t\t$n += $c->getNumQueries();\n\t\t}\n\t\treturn $n;\n\t}", "public static function get_count() {\n\t\tglobal $database;\n\t\t$result = $database->query_db( static::$find_all_sql );\n\t\treturn $result;\n\t}", "public static function getReadQueries() {\n\t\treturn SystemDatabaseManager::$readQueries;\n\t}", "Function GetQueriesCount() \n {\t\n return $this->__iQrCnt; \n }", "function num_queries( )\n\t{\n\t\treturn $this->querycount;\n\t}", "protected function _queryCount() {\n\t\treturn count($this->_queries());\n\t}", "public function getCountQuery()\r\n {\r\n return $this->_countQuery++;\r\n }", "public function getNumQueries()\n {\n return self::$numQueries;\n }", "public function number_of_dbs(){\n $this->cpanel_api_ver = 'api1';\n return $this->_check_result($this->api1_query($this->user, 'Mysql', __FUNCTION__));\n }", "public function getTotalQueries()\n {\n $logger = $this->getConfiguration()->getSQLLogger();\n\n if (! $logger instanceof QueryCounter) {\n // We can't get the number of queries.\n return 0;\n }\n\n return $logger->getNumQueries();\n }", "function getTotalRecords(){\n $ss=\"SELECT COUNT(*) FROM \".$this->ops['mysqlPrefix'].$this->getCurrentTable()->getName().\";\";\n $res=mysql_query($ss);\n return mysql_result($res,0);\n\t}", "public function getSQLQueries() \n\t{\n\t\treturn $this->_sql_count;\n\t}", "public function queryCount()\n {\n return $this->data[\"queryCount\"];\n }", "public static function getQueriesCount() {\n\t\tif (!is_object(self::$instance)) return 0;\n\t\treturn self::$instance->queries_count;\n\t}", "public static function getCountWriteQueries() {\n\t\treturn count(SystemDatabaseManager::$writeQueries);\n\t}", "public function getCount(){\n\t\t$db = $this->getDb();\n\n\t\t$query = \"SELECT COUNT(*) AS count FROM \". $this->_nametable .\"\";\n\n\t\t$rst = $db->query($query);\n\t\t$res = $rst->fetch();\n\t\treturn $res[\"count\"];\n\t}", "public function getQueryCount()\r\n\t{\r\n\t\treturn self::$queryCount;\r\n\t}", "public function count()\n {\n // get database connection\n $db = $this->getDBConnection(\"READ\");\n if ($this->_fetch4countQuery) {\n $querySQL = $this->_fetch4countQuery;\n } else {\n $querySQL = $this->getSQLHelper()->buildQuerySQL($this);\n }\n $this->_fetch4countQuery = null;\n return $this->_getNumberRecords($db, $querySQL);\n }", "public function count() {\n\t\tt3lib_div::logDeprecatedFunction();\n\t\treturn $this->execute()->count();\n\t}", "public function get_query_count() {\n\t\treturn $this->query_count;\n\t}", "private function _count() {\n // SQL query\n $sql = \"SELECT COUNT (*) FROM {$this->getTableQuery()} {$this->getWhereQuery()}\";\n\n // prepare SQL\n $statement = $this->db->prepare($sql);\n // bind where clause\n $statement = $this->bindWhere($statement);\n\n // notify\n $this->logger->notify($this->toString($sql));\n\n // reset data\n $this->clearData();\n\n // execute statement and return number of items\n $statement->execute();\n return $statement->fetchColumn();\n }", "public function getQueryCount() {\r\n\t\treturn $this->queryCount;\r\n\t}", "public function getQueryCount()\n {\n return $this->query_count;\n }", "public static function count_all() {\n\t\tglobal $database;\n\t\t$sql = \"SELECT COUNT(*) FROM `\".static::$table_name.\"` WHERE `\" . static::primary_key_field() . \"` >= 1\";\n\t\t//if the table contains is_deleted, make sure to include WHERE is_deleted = 0\n\t\tif(in_array(\"is_deleted\", static::$db_fields)) \n\t\t\t$sql .= \" AND `is_deleted` = 0\";\n\t\t$sql .= \";\";\n\t\t\n \t\t$result_set = $database->query($sql);\n\t\t//return the total # of rows\n\t\t$row = $database->fetch_array($result_set);\n\t\treturn array_shift($row);\n\t}", "public function getQueryCount();", "public function getQueryCount();" ]
[ "0.74571073", "0.7346767", "0.71040595", "0.7067131", "0.70526654", "0.7043354", "0.70305914", "0.6985928", "0.69459796", "0.6832142", "0.6801824", "0.6753656", "0.67027915", "0.66810524", "0.66767347", "0.6643857", "0.66160613", "0.6604251", "0.6578563", "0.65460014", "0.6525236", "0.65167975", "0.64723814", "0.6464534", "0.64396864", "0.6436378", "0.6418814", "0.6409125", "0.64036024", "0.64036024" ]
0.8533899
0
returns an array of all the comments on read queries (SELECT QUERIES) performed in the system database
public static function getReadQueryComments() { return SystemDatabaseManager::$readQueryComments; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function getReadQueries() {\n\t\treturn SystemDatabaseManager::$readQueries;\n\t}", "public function getQueriedComments(array $args = []): array;", "public function queries()\r\n\t{\r\n\t\treturn $this->query_log;\r\n\t}", "abstract protected function getQueries();", "public static function getCountReadQueries() {\n\t\treturn count(SystemDatabaseManager::$readQueries);\n\t}", "public static function getWriteQueryComments() {\n\t\treturn SystemDatabaseManager::$writeQueryComments;\n\t}", "public function getQueries(): array;", "public function readAll() {\r\n $sql = \"select * from P4_t_comment order by billet_id desc\";\r\n $result = $this->getDb()->fetchAll($sql);\r\n $dataComment = array();\r\n foreach ($result as $row) {\r\n $commentId = $row['com_id'];\r\n $dataComment[$commentId] = $this->buildDomainObject($row);\r\n }\r\n return $dataComment;\r\n }", "public function get_database_calls () {\n\n return $this->SQL_list;\n }", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function queryAll(){\n\t\t$sql = 'SELECT * FROM notes_note';\n\t\t$sqlQuery = new SqlQuery($sql);\n\t\treturn $this->getList($sqlQuery);\n\t}", "function db_read() {\n\t\tdisplay_notification(__FUNCTION__. ' is not defined...');\n\t\treturn array();\n\t}", "function sql_getAllNotes(){\n\t\treturn \"SELECT * FROM `notes` ORDER BY dt_added ASC\";\n\t}", "public function queryComments()\n\t{\n\t\t$comments = GWF_Comment::table();\n\t\t$commentTable = $this->gdoCommentTable();\n\t\t$commentTable instanceof GWF_CommentTable;\n\t\treturn $commentTable->select('gwf_comment.*')->fetchTable(GWF_Comment::table())->joinObject('comment_id')->where(\"comment_object=\".$this->getID());\n\t}", "protected function getArtifactComments()\r\n {\r\n $sql = \"SELECT * FROM artifact_comment\";\r\n $stmt = $this->connect()->prepare($sql);\r\n $stmt->execute([]);\r\n //put all table entries into an array\r\n $results = $stmt->fetchAll();\r\n return $results; //return the array\r\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries() {\r\n return $this->queries;\r\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public function getAllComments()\n {\n $result = self::$dbInterface -> query(\"SELECT commentID, comment, card_cardID, user_userID \n FROM comment\");\n return $result;\n }", "public function gatherQueryData() {\n\t\t$queryTotals = array();\n\t\t$queryTotals['count'] = 0;\n\t\t$queryTotals['time'] = 0;\n\t\t$queries = array();\n\t\t\n\t\tif($this->db != '') {\n\t\t\t$queryTotals['count'] += $this->db->queryCount;\n\t\t\tforeach($this->db->queries as $key => $query) {\n\t\t\t\t$query = $this->attemptToExplainQuery($query);\n\t\t\t\t$queryTotals['time'] += $query['time'];\n\t\t\t\t$query['time'] = $this->getReadableTime($query['time']);\n\t\t\t\t$queries[] = $query;\n\t\t\t}\n\t\t}\n\t\t\n\t\t$queryTotals['time'] = $this->getReadableTime($queryTotals['time']);\n\t\t$this->output['queries'] = $queries;\n\t\t$this->output['queryTotals'] = $queryTotals;\n\t}", "function get_Comments(){\n // add connection credentials\n include(\"dbinfo.inc.php\");\n \n // create connection \n $pdo = new \\PDO(\"mysql:host={$host};dbname={$database}\", $username, $password);\n // For error handling\n $pdo->setAttribute(\\PDO::ATTR_ERRMODE, \\PDO::ERRMODE_EXCEPTION);\n // Create PDO statement object\n $sth = $pdo->prepare(\"\n SELECT * FROM Comment\n ORDER BY submittime DESC\n LIMIT 10\n \");\n // Comment class variables must reflect Table column names or a\n // proper array will not be returned.\n $sth->execute();\n $result = $sth->fetchAll(\\PDO::FETCH_CLASS, \"Comment\");\n\n return $result;\n }", "function getAllComments(){\n\n\t$result = mysql_query(\"SELECT * FROM comments\");\n\n\t$data = array();\n\n\twhile($record = mysql_fetch_assoc($result)){\n\n\t\tarray_push($data, $record);\n\t}\n\n\treturn $data;\n}", "public function getQueries() {\n return $this->queries;\n }", "public function getQueries() {\r\n return array_keys(self::$queries);\r\n }", "public function getSQLQueries() \n\t{\n\t\treturn $this->_sql_count;\n\t}", "final public static function getQueryLog() {\n return self::$__QUERIES__;\n }" ]
[ "0.7717375", "0.66906846", "0.6690313", "0.6655782", "0.66459364", "0.65351963", "0.6449757", "0.6333366", "0.63217103", "0.6300784", "0.6300784", "0.62999076", "0.6295894", "0.6238383", "0.6220676", "0.6205911", "0.61617166", "0.61617166", "0.61617166", "0.6140972", "0.6135594", "0.6135594", "0.6129643", "0.6124073", "0.6113103", "0.6101128", "0.60638326", "0.6014016", "0.5999607", "0.5982618" ]
0.8157178
0
returns an array of all the write queries (INSERT/UPDATE QUERIES) performed in the system databas
public static function getWriteQueries() { return SystemDatabaseManager::$writeQueries; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function getCountWriteQueries() {\n\t\treturn count(SystemDatabaseManager::$writeQueries);\n\t}", "public function getSqlQueries() {\n return array_keys($this->queries);\n }", "public function get_database_calls () {\n\n return $this->SQL_list;\n }", "public static function getReadQueries() {\n\t\treturn SystemDatabaseManager::$readQueries;\n\t}", "public function queries()\r\n\t{\r\n\t\treturn $this->query_log;\r\n\t}", "public static function getWriteQueryComments() {\n\t\treturn SystemDatabaseManager::$writeQueryComments;\n\t}", "public function getSQLQueries() \n\t{\n\t\treturn $this->_sql_count;\n\t}", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function toAsyncSqls(): array\n {\n return array_map(\n function ($query) {\n /** @var self $query */\n return ['query' => $query->toSql(), 'files' => $query->getFiles()];\n },\n $this->getAsyncQueries()\n );\n }", "public function update_sql() {\n if (NULL === $this->_update_sql) {\n $prim_tbl_upd = new DB_Query_Update;\n $prim_tbl_upd->table = $this->_schema->table;\n $this->_update_sql = array(\n $this->_schema->table => $prim_tbl_upd\n );\n if ($this->_schema->secondary_tables != NULL) {\n foreach ($this->_schema->secondary_tables as $sec_table => $join_metadata) {\n $upd_sql = new DB_Query_Update;\n $upd_sql->table = $sec_table;\n $this->_update_sql[$sec_table] = $upd_sql;\n }\n }\n }\n return $this->_update_sql;\n }", "public function getSqlArray()\n {\n return $this->_sql;\n }", "public function getQueries()\n {\n return [self::$queries, self::$params];\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public static function queries()\n\t{\n\t\t$result = array();\n\t\t$count = $time = $memory = 0;\n\n\t\t$groups = Profiler::groups();\n\t\tforeach(Database::$instances as $name => $db)\n\t\t{\n\t\t\t\n\t\t\t$group_name = 'database (' . strtolower($name) . ')';\n\t\t\t$group = arr::get($groups, $group_name, FALSE);\n\n\t\t\tif ($group)\n\t\t\t{\t\t\t\t\t\n\t\t\t\t$sub_time = $sub_memory = $sub_count = 0;\n\t\t\t\tforeach ($group as $query => $tokens)\n\t\t\t\t{\n\t\t\t\t\t$sub_count += count($tokens);\n\t\t\t\t\tforeach ($tokens as $token)\n\t\t\t\t\t{\n\t\t\t\t\t\t$total = Profiler::total($token);\n\t\t\t\t\t\t$sub_time += $total[0];\n\t\t\t\t\t\t$sub_memory += $total[1];\n\t\t\t\t\t\t$result[$name][] = array('name' => $query, 'time' => $total[0], 'memory' => $total[1]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$count += $sub_count;\n\t\t\t\t$time += $sub_time;\n\t\t\t\t$memory += $sub_memory;\n\t\t\t\t$result[$name]['total'] = array('count'=>$sub_count, 'time'=>$sub_time, 'memory'=>$sub_memory);\n\t\t\t}\t\t\n\t\t}\n\t\treturn array('count' => $count, 'time' => $time, 'memory' => $memory, 'data' => $result);\n\t}", "abstract protected function getQueries();", "public function getQueries() {\n return $this->queries;\n }", "public function getQueries() {\r\n return $this->queries;\r\n }", "protected function executeQuery() {\n return array();\n }", "public function query()\n {\n return \\SOE\\DB\\Nonmember::on('mysql-write');\n }", "public function queries () {\n\t\t$queries = 0;\n\t\t/**\n\t\t * @var DB\\_Abstract $c\n\t\t */\n\t\tforeach ($this->connections[self::CONNECTIONS_MASTER] as $c) {\n\t\t\t$queries += $c->queries_count();\n\t\t}\n\t\tforeach ($this->connections[self::CONNECTIONS_MIRROR] as $c) {\n\t\t\t$queries += $c->queries_count();\n\t\t}\n\t\treturn $queries;\n\t}", "public function getQueries() {\r\n return array_keys(self::$queries);\r\n }", "function write_sets()\n\t{\n\t\t$db_settings = array(\n\t\t\t'db_host',\n\t\t\t'db_name',\n\t\t\t'db_pass',\n\t\t\t'db_port',\n\t\t\t'db_socket',\n\t\t\t'db_user',\n\t\t\t'dbtype',\n\t\t\t'installed',\n\t\t\t'include_path',\n\t\t\t'admin_email'\n\t\t);\n\n\t\t$sets = array();\n\t\tforeach ($this->sets as $set => $val)\n\t\t{\n\t\t\tif (!in_array($set, $db_settings)) {\n\t\t\t\t$sets[$set] = $val;\n\t\t\t}\n\t\t}\n\n\t\t$this->db->dbquery(\"UPDATE settings SET settings_data='%s'\", serialize($sets));\n\t}", "function dumpSQL() {\n $db = Zend_Db_Table::getDefaultAdapter();\n $dbProfiler = $db->getProfiler();\n $dbQuery = $dbProfiler->getLastQueryProfile();\n $dbSQL = $dbQuery->getQuery();\n\n print_r($dbSQL);\n\n return;\n}", "public function getQueries(): array;", "public function adminAssignQueries() {\n\t\t$queries = Query::model()->findAll();\n\t\t$cmd = Yii::app()->db->createCommand();\n\t\t$cmd->text = 'INSERT INTO tbl_user_query(userID, queryID) VALUES (:userID, :queryID)';\n\t\t$cmd->bindValue(':userID', $this->userID, PDO::PARAM_INT);\n\t\t\n\t\tforeach ($queries as $query) {\n\t\t\t$cmd->bindValue(':queryID', $query->queryID, PDO::PARAM_INT);\n\t\t\t$cmd->execute();\n\t\t}\n\t}" ]
[ "0.68079114", "0.6478209", "0.6379766", "0.63489455", "0.6333527", "0.6325479", "0.6307164", "0.6243039", "0.6243039", "0.6243039", "0.6193876", "0.6193876", "0.6108703", "0.60460424", "0.60239494", "0.602178", "0.6002955", "0.6002955", "0.6001998", "0.59545213", "0.5914106", "0.5897513", "0.58286893", "0.58272773", "0.5808187", "0.57908916", "0.5777964", "0.576978", "0.57128936", "0.5709012" ]
0.80514467
0
returns the total number of write queries (INSERT/UPDATE QUERIES) performed in the system database
public static function getCountWriteQueries() { return count(SystemDatabaseManager::$writeQueries); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function getWriteQueries() {\n\t\treturn SystemDatabaseManager::$writeQueries;\n\t}", "public function getTotalQueries() : int\n {\n return 1;\n }", "public function getSQLQueries() \n\t{\n\t\treturn $this->_sql_count;\n\t}", "public static function getCountReadQueries() {\n\t\treturn count(SystemDatabaseManager::$readQueries);\n\t}", "public function queries () {\n\t\t$queries = 0;\n\t\t/**\n\t\t * @var DB\\_Abstract $c\n\t\t */\n\t\tforeach ($this->connections[self::CONNECTIONS_MASTER] as $c) {\n\t\t\t$queries += $c->queries_count();\n\t\t}\n\t\tforeach ($this->connections[self::CONNECTIONS_MIRROR] as $c) {\n\t\t\t$queries += $c->queries_count();\n\t\t}\n\t\treturn $queries;\n\t}", "function getNumQueries()\n\t{\n\t\treturn $this->query_count;\n\t}", "function num_queries( )\n\t{\n\t\treturn $this->querycount;\n\t}", "public function getNumQueries() {\n\t\t$n = 0;\n\t\tforeach($this->connections as $c) {\n\t\t\t$n += $c->getNumQueries();\n\t\t}\n\t\treturn $n;\n\t}", "function num_queries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function getNumberOfExecutedQueries()\n {\n return static::$executedQueriesCount;\n }", "protected function _queryCount() {\n\t\treturn count($this->_queries());\n\t}", "public function getTotalQueries()\n {\n $logger = $this->getConfiguration()->getSQLLogger();\n\n if (! $logger instanceof QueryCounter) {\n // We can't get the number of queries.\n return 0;\n }\n\n return $logger->getNumQueries();\n }", "public function getWriteCount() {\n if(isset($this->_writeCount)) {\n return $this->_writeCount;\n }\n return 1;\n }", "public static function getQueriesCount() {\n\t\tif (!is_object(self::$instance)) return 0;\n\t\treturn self::$instance->queries_count;\n\t}", "Function GetQueriesCount() \n {\t\n return $this->__iQrCnt; \n }", "public function getNumQueries()\n {\n return self::$numQueries;\n }", "public function countExecutedQueries () {\n $i = 0;\n foreach ($this->getQueries() as $backtraces) {\n $i += count($backtraces);\n }\n\n return $i;\n }", "public function countUniqueQueries () {\n return count($this->queries);\n }", "public function getCountQuery()\r\n {\r\n return $this->_countQuery++;\r\n }", "function db_conn_count () {\n\treturn count ($GLOBALS['db_list']);\n}", "public function number_of_dbs(){\n $this->cpanel_api_ver = 'api1';\n return $this->_check_result($this->api1_query($this->user, 'Mysql', __FUNCTION__));\n }", "public function count() {\n\t\tt3lib_div::logDeprecatedFunction();\n\t\treturn $this->execute()->count();\n\t}", "public function getUpdateRowsCount()\n {\n return $this->count(self::UPDATE_ROWS);\n }", "public function getUpdateRowsCount()\n {\n return $this->count(self::UPDATE_ROWS);\n }", "public function getNumberOfSuccessfulQueries()\n {\n return static::$successfulQueriesCount;\n }", "public function count()\n\t{\n\t\t$result = $this->execute();\n\t\treturn ($result !== false) ? count($result) : 0;\n\t}", "public function getNbQueries()\n {\n return count($this->queries);\n }", "public static function get_count() {\n\t\tglobal $database;\n\t\t$result = $database->query_db( static::$find_all_sql );\n\t\treturn $result;\n\t}", "public function get_query_count() {\n\t\treturn $this->query_count;\n\t}", "public function countDatabases();" ]
[ "0.72611755", "0.71566665", "0.70418346", "0.70385486", "0.703575", "0.6948503", "0.6941696", "0.6899561", "0.683103", "0.683048", "0.6786267", "0.6783385", "0.676045", "0.6700147", "0.66605216", "0.66501313", "0.6620067", "0.6528553", "0.64082575", "0.6387127", "0.6377279", "0.6354527", "0.6338754", "0.6338754", "0.63319916", "0.6330379", "0.63282526", "0.6304994", "0.62726414", "0.6203208" ]
0.85925126
0
returns an array of all the comments on write queries (INSERT/UPDATE QUERIES) performed in the system database
public static function getWriteQueryComments() { return SystemDatabaseManager::$writeQueryComments; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function getWriteQueries() {\n\t\treturn SystemDatabaseManager::$writeQueries;\n\t}", "public static function getReadQueryComments() {\n\t\treturn SystemDatabaseManager::$readQueryComments;\n\t}", "public function queries()\r\n\t{\r\n\t\treturn $this->query_log;\r\n\t}", "public static function getCountWriteQueries() {\n\t\treturn count(SystemDatabaseManager::$writeQueries);\n\t}", "public static function getReadQueries() {\n\t\treturn SystemDatabaseManager::$readQueries;\n\t}", "public function get_database_calls () {\n\n return $this->SQL_list;\n }", "public function getSQLQueries() \n\t{\n\t\treturn $this->_sql_count;\n\t}", "function dumpSQL() {\n $db = Zend_Db_Table::getDefaultAdapter();\n $dbProfiler = $db->getProfiler();\n $dbQuery = $dbProfiler->getLastQueryProfile();\n $dbSQL = $dbQuery->getQuery();\n\n print_r($dbSQL);\n\n return;\n}", "public function getSqlQueries() {\n return array_keys($this->queries);\n }", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "public function getQueries()\n\t{\n\t\treturn $this->queries;\n\t}", "protected function getStatementStructure()\n {\n return [\n 'statement',\n 'cache',\n 'optimizer',\n 'projection',\n 'table',\n 'as',\n [\n 'join',\n 'inner join',\n 'left join',\n 'right join',\n 'outer join',\n ],\n 'where',\n 'group by',\n 'having',\n 'order by',\n 'limit',\n 'offset',\n ];\n }", "public static function getWrites()\n {\n return self::$_analytics['writes'];\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public function getQueries()\n {\n return $this->queries;\n }", "public function query()\n {\n return \\SOE\\DB\\Nonmember::on('mysql-write');\n }", "public function getQueries() {\r\n return $this->queries;\r\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries(): array\n {\n return $this->queries;\n }", "public function getQueries() {\n return $this->queries;\n }", "abstract protected function getQueries();", "public function getQueriesLog() {\n return $this->_queries_log;\n }", "public function queryComments()\n\t{\n\t\t$comments = GWF_Comment::table();\n\t\t$commentTable = $this->gdoCommentTable();\n\t\t$commentTable instanceof GWF_CommentTable;\n\t\treturn $commentTable->select('gwf_comment.*')->fetchTable(GWF_Comment::table())->joinObject('comment_id')->where(\"comment_object=\".$this->getID());\n\t}", "public function explain()\n\t{\n\t\t//get columns from database\n\t\t$columns = array_keys($this->db->list_fields($this->table_name, TRUE));\n\t\t$data = array();\n\n\t\t//assign default empty values\n\t\tforeach ($columns as $column) \n\t\t{ \n\t\t\t$data[$column] = '';\n\t\t}\n\t\treturn $data;\n\t}", "protected function getStatementStructure()\n {\n return [\n 'statement',\n 'table',\n ];\n }", "public function getAllComments()\n {\n $result = self::$dbInterface -> query(\"SELECT commentID, comment, card_cardID, user_userID \n FROM comment\");\n return $result;\n }", "function sql_getAllNotes(){\n\t\treturn \"SELECT * FROM `notes` ORDER BY dt_added ASC\";\n\t}", "public function getSqlArray()\n {\n return $this->_sql;\n }", "protected function getArtifactComments()\r\n {\r\n $sql = \"SELECT * FROM artifact_comment\";\r\n $stmt = $this->connect()->prepare($sql);\r\n $stmt->execute([]);\r\n //put all table entries into an array\r\n $results = $stmt->fetchAll();\r\n return $results; //return the array\r\n }" ]
[ "0.76319706", "0.68539023", "0.6487652", "0.6481477", "0.62889785", "0.62756586", "0.62181777", "0.604315", "0.6023696", "0.59830993", "0.59830993", "0.58892447", "0.5876463", "0.5813316", "0.5813316", "0.57757175", "0.5749511", "0.57295775", "0.57295775", "0.57295775", "0.5727352", "0.57236665", "0.5694436", "0.56772536", "0.5674884", "0.56606", "0.5625189", "0.56156814", "0.5599421", "0.55457765" ]
0.818615
0
$dato = ContactType::find( $id);
public function show($id) { $dato = ContactType::where( 'ctype_id', '=', $id) ->first(); return $this->showOne($dato,200); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function contacto()\n {\n return $this->belongsTo('App\\Contacto','id_contacto');\n }", "public function show($id)\n {\n return Contactos::findOrfail($id); \n }", "public function contacto()\n {\n return $this->belongsTo('App\\Contacto','CONTACTO_ID');\n }", "public function show($id)\n\t{\n\t\treturn Contact::findOrFail($id);\n\t}", "public function contact()\n {\n return $this->belongsTo('App\\Contact', 'contact_id');\n }", "public function contact()\n {\n return $this->belongsTo('App\\Contact', 'contact_id');\n }", "public function getById(int $id){\n\n //\n return self::find(1);\n\n }", "public function contact() {\n\t\treturn $this->belongsTo('App\\Contact');\n\t}", "public function model()\n {\n return Contact::class;\n }", "public function findOne($id) {\n $contact = Contact::findOrFail($id);\n broadcast(new ContactsRetrieved($contact));\n return response()->json('retrieved');\n }", "public function getById($id) \n { \n return $this->model->find($id); \n }", "public function show($id)\n {\n //\n $contact = User::findOrFail($id);\n return $contact;\n }", "public function findContactById($id) {\n return null;\n }", "public function getContact()\n {\n return $this->db->where(\"id\", 1)->get('contact_db')->row_array();\n\n }", "public function getContactoId($id){\n\t\t\t$this->db->query(\"SELECT * FROM contactos WHERE id_contactos=:id\");\n\n\t\t\t$this->db->bind(':id', \t$id);\n\n\t\t\treturn $this->db->single();\n\t\t}", "public function getContactoId($id){\n\t\t$id = (int) $id;\n\n\t\t$cont = $this->_db->prepare(\"SELECT distinct c.id, c.nombre, c.telefono, c.encuesta, c.rut, c.comuna, c.region, c.codigo, c.dato1, c.dato2, c.dato3, c.dato4, c.dato5, c.dato6, c.dato7, c.dato8, c.dato9, c.dato10, c.dato11, c.fecha1, c.fecha2, c.fecha3, c.telefono2, c.telefono3, c.telefono4, c.telefono5, c.telefono6, c.telefono7, c.telefono8, c.telefono9, c.telefono10, c.created_at as creado, c.num_carga, c.estado_contacto, ec.nombre as e_contacto, c.estado_llamada, c.modified_at as modificado, ell.nombre as llamada, e.nombre as nom_encuesta, car.usuario_id, u.nombre as usuario FROM contactos c INNER JOIN estado_llamadas ell ON c.estado_llamada = ell.id INNER JOIN encuestas e ON c.encuesta = e.id INNER JOIN cargas car ON c.num_carga = car.id INNER JOIN usuarios u ON car.usuario_id = u.id INNER JOIN estado_contactos ec ON c.estado_contacto = ec.id WHERE c.id = ?\");\n\t\t$cont->bindParam(1, $id);\n\t\t$cont->execute();\n\n\t\treturn $cont->fetch();\n\t}", "public function getType($id) {\n try {\n $this->openDb();\n $res = $this->contactsGateway->selectByIdType($id);\n $this->closeDb();\n return $res;\n } catch (Exception $e) {\n $this->closeDb();\n throw $e;\n }\n return $this->contactsGateway->find($id);\n }", "function contact() \n\t{\n\t\t// Load up a new instance of \n\t\t// whatever your alias is. \n\t\t$contact = app('contact');\n\n\t\t$contact->first();\n\n\t}", "public function show($id)\n {\n return ContactUs::find($id);\n }", "public static function get_data_detail($id){\n $data = DB::table('data_form')->where('id',$id)->first();\n return $data;\n }", "public function tbl_contacts() {\n return $this->belongsTo('App\\Tbl_contacts', 'contact_id')->withDefault();\n }", "public function getId()\n {\n return $this->contact_id;\n }", "public function contact()\n {\n return $this->belongsTo(Contact::class)->withDefault();\n }", "public function get_single_contact_data($id){\n\t\t$this->db->where('id',$id);\n\t\t$query = $this->db->get('contact_settings');\n\t\treturn $query->row();\n\t}", "public function show($id)\n {\n return $this->contact->find($id);\n }", "public function getByID(int $id) {\n return $this->model->find($id);\n }", "public function show($id)\n {\n $contact = Contact::find($id);\n if(!$contact){\n return response()->json([\n 'message'=>'data not found'\n ],404);\n }\n return response()->json($contact);\n\n //pulls 1 data from the database by the id\n //if we cant retrieve that single piece of data(id) it will say 404 data not found\n }", "private function contact($id)\n\t{\n\t\tif(is_numeric($id)) {\n\t\t\t$Contact = Contact::find($id);\n\t\t\tif ($Contact) {\n\t\t\t\treturn $Contact;\n\t\t\t}\n\t\t}\n\n\t\t$query = Contact::where('external_key', $id);\n $count = $query->count();\n\n\t\tif (!$count) {\n\t\t\tresponse()->json([\n\t\t\t\t'status' => 'error',\n\t\t\t\t'data' => [],\n\t\t\t\t'messages' => ['Record not found'],\n\t\t\t])->send();\n\t\t\texit;\n\t\t}\n\n\t\tif ($count > 1) {\n\t\t\tresponse()->json([\n\t\t\t\t'status' => 'error',\n\t\t\t\t'data' => [],\n\t\t\t\t'messages' => ['Multiple records found'],\n\t\t\t])->send();\n\t\t\texit;\n\t\t}\n\n\t\treturn $query->first();\n\t}", "public function find($id){}", "public function show($id)\n {\n $contactTypes = ContactType::orderBy('id', 'asc')->get();\n $contactType = ContactType::find($id);\n return view('admin.contact-type.show',compact('contactType','contactTypes'));\n }" ]
[ "0.69607306", "0.6894272", "0.68894315", "0.6522567", "0.65079373", "0.65079373", "0.63741225", "0.6287316", "0.62828344", "0.62776613", "0.62710905", "0.6240578", "0.62175554", "0.6158854", "0.61500263", "0.61003613", "0.6092505", "0.6078204", "0.6069668", "0.60660493", "0.60568726", "0.60554886", "0.6047439", "0.6047383", "0.60318834", "0.60265625", "0.60186404", "0.6014584", "0.6002916", "0.59814185" ]
0.7128034
0
Function to format forgot password message.
public static function forgotPassword($message, $user) { $formattedMessage = str_replace(['{name}', '{email}', '{password}', '{address}'], [ $user->first_name.''.$user->last_name, $user->email, PasswordHelper::decode($user->password), $user->address], $message); return $formattedMessage; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function message()\n {\n if ($this->count > 1) {\n return \"This password has appeared in {$this->count} data breaches and should never be used. Please use a different password.\";\n } else {\n return 'This password has appeared in a data breach and should never be used. Please use a different password.';\n }\n }", "public function message()\n {\n return 'Provide a strong password';\n }", "public function message()\n {\n return 'Password lama yang di inputkan tidak sesuai.';\n }", "public function passwordsent()\n {\n $message = _t(\n 'SilverStripe\\\\Security\\\\Security.PASSWORDRESETSENTTEXT',\n \"Thank you. A reset link has been sent, provided an account exists for this email address.\"\n );\n\n return [\n 'Title' => _t(\n 'SilverStripe\\\\Security\\\\Security.PASSWORDRESETSENTHEADER',\n \"Password reset link sent\"\n ),\n 'Content' => DBField::create_field('HTMLFragment', \"<p>$message</p>\"),\n ];\n }", "public function message()\n {\n return __('The password must include letters, capital letters, numbers, special characters and a minimum of 8 characters.');\n }", "private function forgotPassword() {\n $this->_template->title = 'Forgot Password';\n if (filter_has_var(INPUT_POST, 'forgotPassword')) {\n $this->_user->forgotPassword();\n $passToken = $this->_user->getPassToken();\n $email = $this->_user->getSanitizedValue('email');\n $token = $this->_user->getSanitizedValue('token');\n $this->_security->checkCsrfToken($token);\n if ($this->_user->isTokenInserted() == true) {\n $this->_mail->sendPasswordToken($email, $passToken);\n } else {\n $this->_template->token = $this->_security->generateToken();\n $this->_template->forgotError = '<p class=\"error\">Please try again.</p>';\n $this->_template->errors = $this->_user->getErrors();\n $this->_template->missing = $this->_user->getMissingValues();\n $this->_template->buildFromTemplates('header.php', 'sidebar.php', 'main.forgotpass.php', 'footer.php');\n }\n } else {\n $this->_template->token = $this->_security->generateToken();\n $this->_template->buildFromTemplates('header.php', 'sidebar.php', 'main.forgotpass.php', 'footer.php');\n }\n }", "protected function msg($code) {\n\t\t$this->load_plugin_textdomain();\n\t\tswitch ($code) {\n\t\t\tcase self::E_ASCII:\n\t\t\t\treturn __(\"Passwords must use ASCII characters.\", 'login-security-solution');\n\t\t\tcase self::E_CASE:\n\t\t\t\treturn sprintf(__(\"Passwords must either contain upper-case and lower-case letters or be %d characters long.\", 'login-security-solution'), $this->options['pw_complexity_exemption_length']);\n\t\t\tcase self::E_COMMON:\n\t\t\t\treturn __(\"Password is too common.\", 'login-security-solution');\n\t\t\tcase self::E_DICT:\n\t\t\t\treturn __(\"Passwords can't be variations of dictionary words.\", 'login-security-solution');\n\t\t\tcase self::E_EMPTY:\n\t\t\t\treturn __(\"Password not set.\", 'login-security-solution');\n\t\t\tcase self::E_NUMBER:\n\t\t\t\treturn sprintf(__(\"Passwords must either contain numbers or be %d characters long.\", 'login-security-solution'), $this->options['pw_complexity_exemption_length']);\n\t\t\tcase self::E_PUNCT:\n\t\t\t\treturn sprintf(__(\"Passwords must either contain punctuation marks / symbols or be %d characters long.\", 'login-security-solution'), $this->options['pw_complexity_exemption_length']);\n\t\t\tcase self::E_REUSED:\n\t\t\t\treturn __(\"Passwords can not be reused.\", 'login-security-solution');\n\t\t\tcase self::E_SEQ_CHAR:\n\t\t\t\treturn __(\"Passwords can't have that many sequential characters.\", 'login-security-solution');\n\t\t\tcase self::E_SEQ_KEY:\n\t\t\t\treturn __(\"Passwords can't be sequential keys.\", 'login-security-solution');\n\t\t\tcase self::E_SHORT:\n\t\t\t\treturn __(\"Password is too short.\", 'login-security-solution');\n\t\t\tcase self::E_STRING:\n\t\t\t\treturn __(\"Passwords must be strings.\", 'login-security-solution');\n\t\t\tcase self::E_SITE:\n\t\t\t\treturn __(\"Passwords can't contain site info.\", 'login-security-solution');\n\t\t\tcase self::E_USER:\n\t\t\t\treturn __(\"Passwords can't contain user data.\", 'login-security-solution');\n\t\t}\n\t}", "public function message()\n {\n return 'Entered One Time Password is invalid.';\n }", "function wpse_71284_custom_post_password_msg( $form )\n{\n // No cookie, the user has not sent anything until now.\n if ( ! isset ( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) )\n return $form;\n\n // Translate and escape.\n $msg = esc_html__( 'Sorry, your password is wrong.', 'your_text_domain' );\n\n // We have a cookie, but it doesn’t match the password.\n $msg = \"<p class='custom-password-message text-center'>$msg</p>\";\n\n return $msg . $form;\n}", "public function message()\n {\n return trans('user.error.regex_password');\n }", "function mailshot_affiche_password_masque($pass){\n\t$l = strlen($pass);\n\tif ($l<=8){\n\t\treturn str_pad('',$l,'*');\n\t}\n\t$e = intval(ceil($l/10));\n\t$mid = str_pad('',$l-2*$e,'*');\n\tif (strlen($mid)>8){\n\t\t$mid = '***...***';\n\t}\n\treturn substr($pass,0,$e) . $mid . substr($pass,-$e);\n}", "protected function recoveryAccountCaption():string{\n\t\treturn 'Forgot your password?';\n\t}", "function replace_retrieve_password_message( $message, $key, $user_login, $user_data ) {\n // Create new message\n $msg = __( 'Hello!', 'forgotten-password' ) . \"\\r\\n\\r\\n\";\n $msg .= sprintf( __( 'You asked us to reset your password for your account using the login %s.', 'forgotten-password' ), $user_login ) . \"\\r\\n\\r\\n\";\n $msg .= __( \"If this was a mistake, or you didn't ask for a password reset, just ignore this email and nothing will happen.\", 'forgotten-password' ) . \"\\r\\n\\r\\n\";\n $msg .= __( 'To reset your password, visit the following address:', 'forgotten-password' ) . \"\\r\\n\\r\\n\";\n $msg .= site_url( \"wp-login.php?action=rp&key=$key&login=\" . rawurlencode( $user_login ), 'login' ) . \"\\r\\n\\r\\n\";\n $msg .= __( 'Thanks!', 'forgotten-password' ) . \"\\r\\n\";\n\n return $msg;\n}", "public function message()\n {\n return __('Old password does not match');\n }", "function format($str, $type = '')\n{\n\tif ($type === 'password')\n\t\treturn '*******';\n\telseif ($type === 'email')\n\t\treturn $str;\n\telse\n\t\treturn ucwords(str_replace(\"_\", \" \", $str));\n\n}", "public function message()\n {\n return 'Don\\'t use an old password';\n }", "function forgot_password()\n\t{\n\t}", "public function message()\n {\n return 'The password you provided is invalid.';\n }", "public function getForgetpass() {\n return strval($this->forgetpass);\n }", "public function getPasswordMissingMsg()\r\n {\r\n return \"Password is missing\";\r\n }", "public function password_hint($hint = '') {\n\t\t$this->load_plugin_textdomain();\n\t\treturn $this->hsc_utf8(sprintf(__(\"The password should either be: A) at least %d characters long and contain upper and lower case letters (except languages that only have one case) plus numbers and punctuation, or B) at least %d characters long. The password can not contain words related to you or this website.\", 'login-security-solution'), $this->options['pw_length'], $this->options['pw_complexity_exemption_length']));\n\t}", "public function sendPasswordReset() {\n $state = sha1 ( md5( uniqid( getmypid() . gethostname() . mt_rand() . microtime() . memory_get_usage(), true ) ) . mt_rand() );\n $cstrong = false;\n // generate some cool randomness\n $bytes = openssl_random_pseudo_bytes(160, $cstrong);\n $hex = bin2hex($bytes);\n // build a password\n $pass = ( substr( base_convert( sha1( $state . $bytes ), 16, 32 ) , 0, 11 ) ); \n \n // get mail from the DB\n $email = Message::getMessage( \"forgotpassword-email\" );\n $emailsubj = Message::getMessage( \"forgotpassword-email-subject\" );\n // subst in the password\n $email = str_replace( '$1', $pass, $email );\n \n Mail::send( $this->getEmail() , $emailsubj, $email );\n \n $this->setPassword( $pass );\n $this->save();\n }", "public function lostpassword()\n {\n\n $message = _t(\n 'SilverStripe\\\\Security\\\\Security.NOTERESETPASSWORD',\n 'Enter your e-mail address and we will send you a link with which you can reset your password'\n );\n\n return [\n 'Content' => DBField::create_field('HTMLFragment', \"<p>$message</p>\"),\n 'Form' => $this->lostPasswordForm(),\n ];\n }", "public function password()\n {\n return View::make('backoffice.pw_reset');\n }", "function formatMessage($msg) {\n\t\t$msg = str_ireplace($this->badwords, '****', $msg); foreach($this->smilies as $acii => $img) { $msg = str_ireplace($acii, '<img src=\"'.$this->smiliesPath.$img.'\" width=\"16\" height=\"16\" align=\"absmiddle\" />', $msg); }\n\t\t$patterns = array('/([^\\w\\/])(www\\.[a-z0-9\\-]+\\.[a-z0-9\\-]+)/i','/([\\w]+:\\/\\/[\\w-?&;#~=\\.\\/\\@]+[\\w\\/])/i','/([\\w-?&;#~=\\.\\/]+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?))/i',\n\t\t\t\t\t\t '~\\[@([^\\]]*)\\]~','~\\[([^\\]]*)\\]~','~{([^}]*)}~','~_([^_]*)_~','/\\s{2}/');\n\t\t$replacements = array('$1http://$2','<a href=\\\"$1\\\">$1</a>','<a href=\\\"mailto:$1\\\">$1</a>','<b class=\"reply\">@\\\\1</b>','<b>\\\\1</b>','<i>\\\\1</i>','<u>\\\\1</u>','<br />');\n\t\t$msg = preg_replace($patterns, $replacements, $msg); return stripslashes(stripslashes(utf8_decode($msg)));\n\t}", "public function forgot_password()\n\t{\n\t\t$tag_vars = array(array(\n\t\t\t'email' => FALSE,\n\t\t\t'error:email' => FALSE,\n\t\t));\n\n\t\tif ($this->EE->input->post('forgot_password'))\n\t\t{\n\t\t\t$tag_vars[0]['email'] = $this->EE->input->post('email', TRUE);\n\n\t\t\t// generate reset code and URL\n\t\t\t$reset_code = random_string('alnum', 10);\n\t\t\tif ($reset_url = $this->EE->TMPL->fetch_param('reset'))\n\t\t\t{\n\t\t\t\t$reset_url = $this->EE->functions->create_url($reset_url.'/'.$reset_code);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$reset_url = $this->EE->functions->fetch_site_index(0, 0).QUERY_MARKER.\n\t\t\t\t\t'ACT='.$this->EE->functions->fetch_action_id('Member', 'reset_password').'&id='.$reset_code;\n\t\t\t}\n\n\t\t\t// valide email address and send reset instructions\n\t\t\t$errors = $this->_member_forgot_password($reset_code, $reset_url);\n\n\t\t\tif (empty($errors))\n\t\t\t{\n\t\t\t\t$return_url = $this->EE->functions->create_url($this->EE->input->post('return_url'));\n\t\t\t\t$this->EE->functions->redirect($return_url);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$tag_vars = $this->_display_errors($tag_vars, $errors);\n\t\t\t}\n\t\t}\n\n\t\t// start our form output\n\t\t$out = $this->_form_open(array(\n\t\t\t'hidden_fields' => array('forgot_password' => 1),\n\t\t));\n\n\t\t// parse tagdata variables\n\t\t$out .= $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $tag_vars);\n\n\t\t// end form output and return\n\t\treturn $out.'</form>';\n\t}", "public function message(): string\n {\n return __('validationRules::messages.matchUserPassword');\n }", "public function showUpdateForgottenPassword(array $input) {\n global $CFG_GLPI;\n\n echo \"<div class='center'>\";\n try {\n if (!$this->updateForgottenPassword($input)) {\n Html::displayMessageAfterRedirect();\n } else {\n echo __('Reset password successful.');\n }\n } catch (ForgetPasswordException $e) {\n echo $e->getMessage();\n } catch (PasswordTooWeakException $e) {\n // Force display on error\n foreach ($e->getMessages() as $message) {\n Session::addMessageAfterRedirect($message);\n }\n Html::displayMessageAfterRedirect();\n }\n\n echo \"<br>\";\n echo \"<a href=\\\"\".$CFG_GLPI['root_doc'].\"/index.php\\\">\".__s('Back').\"</a>\";\n echo \"</div>\";\n }", "static function showPasswordForgetRequestForm() {\n global $CFG_GLPI;\n\n echo \"<div class='center'>\";\n echo \"<form method='post' name='forgetpassword' action='\".$CFG_GLPI['root_doc'].\n \"/front/lostpassword.php'>\";\n echo \"<table class='tab_cadre'>\";\n echo \"<tr><th colspan='2'>\" . __('Forgotten password?').\"</th></tr>\";\n\n echo \"<tr class='tab_bg_1'><td colspan='2'>\" .\n __('Please enter your email address. An email will be sent to you and you will be able to choose a new password.').\n \"</td></tr>\";\n\n echo \"<tr class='tab_bg_2 center'>\";\n echo \"<td><input type='text' size='60' name='email' value=''></td>\";\n echo \"<td><input type='submit' name='update' value=\\\"\".__s('Save').\"\\\" class='submit'>\";\n echo \"</td></tr>\";\n\n echo \"</table>\";\n Html::closeForm();\n echo \"</div>\";\n }", "public function forgotPassword()\n {\n return view('auth.passwords.email');\n }" ]
[ "0.6578904", "0.64635193", "0.63273656", "0.6324264", "0.6301098", "0.6269529", "0.6239511", "0.6182411", "0.6163232", "0.61484826", "0.60932475", "0.6092763", "0.6073217", "0.6042427", "0.60302", "0.60216486", "0.5985199", "0.5983315", "0.5907896", "0.59078014", "0.5905589", "0.5883292", "0.58611774", "0.58436483", "0.5799412", "0.57991076", "0.5787793", "0.57746285", "0.57727116", "0.5754951" ]
0.6923527
0
/ Handles the "connect" event invoked by the client and emits it to all
public function connect() { $this->socket->event->addEvent("connect",function($socket,$uid) { $socket->event->emitMessage('connect',$uid); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function onconnect(){\n debug('socket connected - writing packet');\n $this->nsp->connected[$this->id] = $this;\n $this->join($this->id);\n $skip = $this->nsp->name === '/' && $this->nsp->fns.length === 0;\n if (skip) {\n debug('packet already sent in initial handshake');\n } else {\n $this->packet(Helper::toStdClass([ 'type'=>Parser::CONNECT ]));\n }\n }", "public function on_client_server_connect(Event &$event) {\n $this->request->setAttribute('result_on_client_server_connect', 'successful call');\n $this->request->setAttribute('result', 'successful call');\n \n echo \"here is connection\\r\\n\";\n \n }", "public function onConnect(): void;", "public function onClientConnect(ClientEvent $event)\n {\n if ($this->logger) {\n $this->logger->info('clank connected '.$event->resourceId);\n }\n }", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "public function connect();", "private function connect( )\n {\n }", "public abstract function connect();", "public abstract function connect();", "function onConnected()\n\t{\n\t}", "abstract public function onConnect($connection);", "abstract public function connect();", "abstract public function connect();", "abstract public function connect();" ]
[ "0.75227296", "0.73297995", "0.7300178", "0.71735257", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.69928396", "0.6917163", "0.6915761", "0.6915761", "0.6822162", "0.6820632", "0.6800294", "0.6800294", "0.6800294" ]
0.78593254
0
/ Handles the "add_user" event invoked by the client. Emits and broadcasts it to all
public function add_user () { $this->socket->event->addEvent("add user",function($socket, $username,$userid) { $socket->username=$username; //add the client's username to the global list $socket->usernames["$username"] = $username; $socket->socketID["$userid"] = $username; $socket->numUsers++; //inform me that my login was successful $socket->event->emitMessage('login', array( 'numUsers'=>$socket->numUsers, 'users' =>$socket->ids_to_username_keys(), )); //broadcast to others that i have joined $socket->event->broadcastMessage('user joined', array( 'username'=>$socket->username, 'numUsers'=>$socket->numUsers, 'usersnames' =>$socket->ids_to_username_keys() )); $socket->addedUser=true; }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private function addAdminUser(): void\n {\n DB::table('users')->insert([\n 'id' => env('ADMIN_ID', 1),\n 'name' => env('ADMIN_NAME'),\n 'email' => env('ADMIN_MAIL'),\n 'approved' => true,\n 'password' => bcrypt(env('ADMIN_PASSWORD')),\n 'created_at' => Carbon::now(),\n 'updated_at' => Carbon::now(),\n ]);\n\n /** @var User $user */\n $user = User::find(env('ADMIN_ID', 1));\n\n event(new Registered($user));\n }", "function addUser($user) {\n $this->setValue('users', $user);\n }", "public function addUser() {\n\t\t$user = new User();\n\t\t$user -> setId('999999999') -> setName('john') -> setEmail('[email protected]') -> setPassword('test');\n\n\t\t$this -> userService -> addUser($user);\n\n\t\t$this -> users[] = $user;\n\t}", "function addUser()\n {\n if (APP_INSTALLED)\n {\n $this->_template->setRedirection(APP_URL);\n return ;\n }\n \n // Check post values and populate db\n if (isset($_POST['name']) && isset($_POST['pass']))\n {\n $newName = htmlspecialchars($_POST['name']);\n\n // Username lenght check\n if (strlen($newName) == 0)\n {\n $this->set('error', 'User Name needs to be at least 1 character long');\n return ;\n }\n\n // Username uniqueness check\n $user = new UserModel;\n $uNames = $user->getUserNames();\n\n $alreadyPresent = false;\n foreach ($uNames as $key => $value) {\n if ($value['name'] == $newName)\n $alreadyPresent = true;\n }\n\n if (!$alreadyPresent)\n {\n // success, lets add it to the database and inform the user\n $user->addUser($newName, hash(\"sha256\", $_POST['pass'] . BACK_HASH_SALT));\n $this->set('success', 'Added user <strong>' . $newName . '</strong> to SerieLast.');\n }\n else {\n $this->set('error', 'This name is already used');\n }\n }\n }", "public function addUser(\\PHPAuth\\User $user);", "public function addUser(User $user)\n {\n array_push($this->users, $user->userData());\n $this->dataIO->writeData($this->users);\n }", "public function addUser()\n {\n // if we have POST data to create a new user entry\n if (isset($_POST[\"submit_add_user\"])) {\n // do addUser() in model/userModel.php\n // TODO : Retourner une erreur si jamais les champs ne sont pas correctement complétés.\n $this->userModel->addUser($_POST[\"login\"], $_POST[\"password\"], $_POST[\"firstname\"], $_POST[\"lastname\"]);\n }\n // where to go after user has been added\n header('location: ' . URL . 'user/index');\n }", "function ac_all_add_user(){\n\t\tglobal $i18n;\n\t\t$this->menu();\n\t\t$this->run_view('new_user');\n\t}", "public function post_user()\n\t{\n\t\t$this->get_user();\n\t}", "public function post_user()\n\t{\n\t\t$this->get_user();\n\t}", "public function appendEvent(User $user, Event $event)\n {\n $this->events[] = $event;\n }", "function og_ui_add_users_submit($form, &$form_state) {\n $account = user_load_by_name($form_state['values']['og_add_user']);\n $group = array(\n 'gid' => $form_state['values']['group']->gid,\n 'state' => $form_state['values']['og_add_user_state'],\n );\n\n og_subscribe_user(array($group), $account);\n}", "public function add(User $user) {\r\n\t\t$this->dal->saveSelection($user);\r\n $this->users[] = $this->dal->getSavedUser();\r\n\t}", "function add() {\n $this->send();\n }", "public function onExternalUserCreation(ExternalUserWasCreated $event) {\n\n logger('user created');\n\n $this->mailer->sendMailForExternalUserCreation($event->user);\n\n }", "public function adduser()\t\t\t\t\t\t\t//\n\t\t{\t\t\t\t\t\t\t\t\t\t//\n\t\t\tif ($this->session->userdata('logged_in'))\t\t\t\t// Check to see if the user is logged in\n\t\t\t{\t\t\t\t\t\t\t\t\t//\n\t\t\t\t$this->cfg->adduser();\t\t\t\t\t\t// Call add user function\n\t\t\t}\t\t\t\t\t\t\t\t\t//\n\t\t\telse\t\t\t\t\t\t\t\t\t// If user isn't logged in\n\t\t\t{\t\t\t\t\t\t\t\t\t//\n\t\t\t\tredirect('main', 'refresh');\t\t\t\t\t// Redirect to main page\n\t\t\t}\t\t\t\t\t\t\t\t\t//\n\t\t}", "public function registeruser() {\n $this->register();\n\n }", "public function add( Entity $user ) {\n\t}", "public function addUser() {\n\t\t$userGroups=$this->UserGroup->getGroups();\n\t\t$this->set('userGroups', $userGroups);\n\t\tif ($this->request -> isPost()) {\n\t\t\t$time = strtotime ( \"now\" );\n\t\t\t$token = $time . $this->__randomStr ( 3 );\n\n\t\t\t$this->User->set($this->data);\n\t\t\tif ($this->User->RegisterValidate()) {\n\t\t\t\t$this->request->data['User']['username']=$this->request->data['User']['email'];\n\t\t\t\t$this->request->data['User']['email_verified']=1;\n\t\t\t\t$this->request->data['User']['active']=1;\n\t\t\t\t$this->request->data['User']['user_group_id']=3;\n\t\t\t\t$salt=$this->UserAuth->makeSalt();\n\t\t\t\t$this->request->data['User']['salt'] = $salt;\n\t\t\t\t$this->request->data['User']['token'] = $token;\n\t\t\t\t$this->request->data['User']['password'] = $this->UserAuth->makePassword($token, $salt);\n\t\t\t\t$this->User->save($this->request->data,false);\n\t\t\t\t$this->Session->setFlash('El participante se agregó correctamente.', 'default', array('class' => 'success_message'));\n\t\t\t\t$this->redirect('/allUsers');\n\t\t\t}\n\t\t}\n\t}", "public function createUsersEvent(string $widgetId, array $users, array $payload, string $uniqueId = '');", "function admin_add_user()\n\t{\n\t\t$this->set('title_for_layout','Create New USer');\n\t\tif(!empty($this->data))\n\t\t{\n\t\t\tif($this->Admin->create($this->data))\n\t\t\t{\n\t\t\t\t$this->data['Admin']['password'] = md5($this->data['Admin']['password']);\n\t\t\t\t$this->data['Admin']['role'] = 1;\n\t\t\t\t$this->data['Admin']['status'] = 1;\n\t\t\t\t$this->data['Admin']['created'] = date('Y-m-d H:i:s');\n\t\t\t\t$this->data['Admin']['modified'] = '0000-00-00 00:00:00';\n\t\t\t\tif($this->Admin->save($this->data,false))\n\t\t\t\t{\n\t\t\t\t\t$this->Session->setFlash('User added successfully','flash_success');\n\t\t\t\t\t$this->redirect('/admin/samples/view_user');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t$get_pcc_list = $this->Lab->find('all',array('conditions'=>array('Lab.status'=>1)));\n\t\t$this->set('get_pcc_list',$get_pcc_list);\n\t}", "public function createUser()\n\t\t{\n\t\t\t\t\tlog_message('info', \"userCtrl\");\n\t\t\t\t\t$userData = $this->jsonbourne->decodeReqBody(); //get json\n\t\t\t\t\t$resultFromCreateANewUser = $this->userModel->create($userData); // pass arguments as array\n\t\t\t\t\techo count($resultFromCreateANewUser) > 1 ? $this->jsonbourne->forge(0, \"The user has been created\", $resultFromCreateANewUser): $this->jsonbourne->forge(1, \"error in the creation of user\", null);\n\t\t}", "public function postAddUserEvent()\n {\n $response = array(\n \"method\" => \"adduserevent\",\n \"success\" => false,\n \"log\" => \"\",\n \"user_id\" => \"\",\n \"error_code\" => 0,\n \"error_message\" => \"\"\n );\n\n try {\n $data = json_decode(file_get_contents(\"php://input\"));\n if (empty($data)) {\n $data = (object) $_POST;\n }\n // Check required fields\n $requiredParams = array('event');\n $params = (array) $data;\n foreach ($requiredParams as $param) {\n if (empty($params[$param])) {\n throw new \\Exception($param .' is required.');\n }\n }\n\n if (!array_key_exists(\"event_data\", $params)) {\n $data->event_data = \"\";\n }\n\n if(!is_array($data->event_data)) {\n $data->event_data = array(\"data\" => $data->event_data);\n }\n\n if (!array_key_exists(\"event_source\", $params)) {\n $data->event_source = \"front_end\";\n }\n\n $data->event_type = $params['event'];\n $data->event_data = array_merge($data->event_data, array(\"source\" => $data->event_source));\n\n $logModel = new Log();\n $user = new User();\n $basicAuth = new BasicAuthenticator($user);\n $currentUser = $basicAuth->currentUser();\n\n $logId = $logModel->create($currentUser->getUserId(), $data->event_type, $data->event_data);\n\n $entity = $logModel->findById($logId);\n\n $output = array('id' => $entity->getId(),\n 'event' => $entity->getEventLog(),\n 'event_data'=> $entity->getEventData(),\n 'created_at'=> $entity->getCreatedAt()\n );\n\n $response['log'] = $output;\n $response['user_id'] = $currentUser->getUserId();\n $response['success'] = true;\n $this->setStatusCode(200);\n } catch (\\Exception $e) {\n $response['error_message'] = $e->getMessage();\n $response['error_code'] = $e->getCode();\n }\n\n $this->setContent($response);\n }", "function user_add($data)\n{\n\tif (user_find($data[0],NULL))\n\t\treturn false;\n\t\n\t$GLOBALS[\"users\"][] = $data;\n\treturn _saveUsers();\n}", "function add($user) {\n\t\t$this->db->insert('users', $user);\n\t}", "public function onFirstUserRegistrationAddAdminRole(FilterUserResponseEvent $event)\n {\n $user_repo = $this->em->getRepository('InouireUserBundle:User'); \n $users = $user_repo->findAll();\n \n // get the user who just registered\n $registered_user = $event->getUser();\n \n // if this is the first user to be created, add admin role to the user\n if(count($users)==1){\n $registered_user->addRole('ROLE_ADMIN');\n $this->em->persist($registered_user);\n $this->em->flush();\n }else{ // notify admin that a new account has been created\n \n // find admin user\n foreach($users as $user){// its fine to loop on users as there are very few + this action does not occur often\n foreach($user->getRoles() as $role){\n if($role == \"ROLE_ADMIN\"){\n $admin_user = $user;\n break;\n }\n }\n }\n\n // send a notif email to admin\n $template_content = $this->twig->loadTemplate('InouireMininetBundle:Admin:registration_notification_email.txt.twig');\n $body = $template_content->render(array('user' => $registered_user));\n $message = \\Swift_Message::newInstance()\n ->setSubject('Nouvel utilisateur inscrit: '.$registered_user->getUsername().' / '.$registered_user->getEmail())\n ->setFrom($admin_user->getEmail())\n ->setTo($admin_user->getEmail())\n ->setBody($body);\n $this->swift->send($message);\n \n }\n \n }", "public function post_users()\n\t{\n\t\t$this->get_users();\n\n\t\tFormUI::build('add_user', 'add_user')->get();\n\n\t\t$wsse = Utils::WSSE( $this->handler_vars['nonce'], $this->handler_vars['timestamp'] );\n\t\tif ( $this->handler_vars['password_digest'] != $wsse['digest'] ) {\n\t\t\tSession::error( _t( 'WSSE authentication failed.' ) );\n\t\t\treturn Session::messages_get( true, 'array' );\n\t\t}\n\n\t\t$this->fetch_users();\n\n\t\t$extract = $this->handler_vars->filter_keys( 'newuser', 'delete', 'new_pass1', 'new_pass2', 'new_email', 'new_username' );\n\t\tforeach ( $extract as $key => $value ) {\n\t\t\t$$key = $value;\n\t\t}\n\n\t\tif ( isset( $delete ) ) {\n\t\t\t$action = 'delete';\n\t\t}\n\n\t\tif ( isset( $action ) && ( 'delete' == $action ) ) {\n\n\t\t\t$this->update_users( $this->handler_vars );\n\n\t\t}\n\n\t\tUtils::redirect(URL::get('admin', array('page' => 'users')));\n\t}", "public function addUser($userid)\n {\n if ($this->locked == true)\n return;\n\n if (Guardian::hasClients())\n if (Guardian::getClientId() != $this->{Guardian::getClientColumn()})\n return;\n\n if (! $this->users()->get()->contains($userid))\n $this->users()->attach($userid);\n }", "public function add(){\r\n\t\t//view\r\n\t\trequire_once('Views/user/addUser.php');\r\n\t}", "public function addUser(){\n if(isset($_POST['easy_submit'])){\n $user_name = $_POST['easy_name'];\n $user_login = $_POST['easy_login'];\n $user_password = $_POST['easy_password'];\n\n $new_user = new User();\n $new_user->setName($user_name);\n $new_user->setLogin($user_login);\n $new_user->setPassword($user_password);\n\n $query = $this->model->add($new_user);\n if($query){\n AlertManager::add(EASY_NEW_USER_ADDED, AlertManager::SUCCESS);\n header('Location: ' . URL . 'home/');\n }else{\n AlertManager::add($query, AlertManager::DANGER);\n header('Location: ' . URL . 'home/');\n }\n }else{\n header('Location: ' . URL . 'home/');\n }\n }" ]
[ "0.63842124", "0.6380449", "0.6364542", "0.6179044", "0.6077291", "0.6075032", "0.6026776", "0.5925491", "0.5916863", "0.5916863", "0.5910828", "0.58882153", "0.5880165", "0.5856222", "0.5846552", "0.58452624", "0.5839057", "0.5836708", "0.58166707", "0.5813291", "0.5780272", "0.5779618", "0.57239825", "0.57228553", "0.5716008", "0.5706929", "0.5705706", "0.56986797", "0.56969917", "0.5694845" ]
0.8095548
0
/ Handles the typing event invoked by the client and broadcast it to all
public function typing () { // when the client emits 'typing', we broadcast it to others $this->socket->event->addEvent('typing', function ($socket,$data) { $socket->event->broadcastMessage('typing', array( 'username'=>$socket->socketID[$socket->user->id], )); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function stop_typing () {\r\n\r\n // when the client emits 'stop typing', we broadcast it to others\r\n $this->socket->event->addEvent('stop typing', function ($socket,$data) {\r\n\r\n $socket->event->broadcastMessage('stop typing', array(\r\n 'username'=>$socket->socketID[$socket->user->id],\r\n ));\r\n\r\n });\r\n\r\n }", "public function broadcastTyping(): ExtendedPromiseInterface\n {\n if (! $this->isTextBased()) {\n return reject(new \\RuntimeException('You cannot broadcast typing to a voice channel.'));\n }\n\n return $this->http->post(Endpoint::bind(Endpoint::CHANNEL_TYPING, $this->id));\n }", "public function emitTyping(): self\n {\n $this->broadcaster\n ->toPresence($this->resolveThread())\n ->with(PresenceEvents::makeTypingEvent($this->messenger->getProvider()))\n ->broadcast(PresenceEvents::getTypingClass());\n\n return $this;\n }", "public function emitTyping(): self\n {\n $this->broadcaster\n ->toPresence($this->resolveThread())\n ->with(PresenceEvents::makeTypingEvent($this->messenger->getProvider()))\n ->broadcast(PresenceEvents::getTypingClass());\n\n return $this;\n }", "public function onReceive(string $str)\n {\n }", "public function onData($data, $client) {\n\t\t\n\t\t$action = $data->action;\n\t\t$data = htmlspecialchars ($data->data);\n\t\t\n\t\tswitch($action) {\n\t\t\tcase 'nickselect':\n\t\t\t\t$this->checkPseudo($client, $data);\n\t\t\tbreak;\n\t\t\tcase 'msg':\n\t\t\t\t$this->hasMessage($client, $data);\n\t\t\tbreak;\n\t\t}\n\t}", "public function broadcastOn();", "function chat_on() {\n \n }", "abstract public function broadcastOn();", "public function chat_message () {\r\n //for client 2 example only\r\n $this->socket->event->addEvent('chat message', function ($socket,$data,$sender) {\r\n $socket->event->broadcastMessage('chat message', $data,true);\r\n });\r\n }", "final public function listensEverything()\n {\n $this->eventTypes = '*';\n }", "function broadcastOn()\n {\n }", "public function handle_input($server,$client,$input)\n {\n // $trim = trim($input); // Trim the input, Remove Line Endings and Extra Whitespace.\n\n\n echo $input;\n if (strtolower($input) == \"quit\") // User Wants to quit the server\n {\n TCPController::socket_write_smart($client->socket, \"Oh... Goodbye...\"); // Give the user a sad goodbye message, meany!\n $server->disconnect($client->server_clients_index); // Disconnect this client.\n return; // Ends the function\n }\n\n\n\n\n // $output = \"#200#\"; // Reverse the String\n // socket_write($client->socket,$input);\n // TCPController::socket_write_smart($client->socket, $output); // Send the Client back the String\n // TCPController::socket_write_smart($client->socket, \"String?\", \"#\"); // Request Another String\n }", "public function listensTo($type)\n {\n $this->eventTypes = (array) $type;\n }", "function textEvent($params) { \r\n\t\t$te = self::$events['text'];\r\n\t\tforeach ($te as $e) {\r\n\t\t\tif ($e['target'] == \"#\") { $e['target'] = \"*\"; }\r\n\t\t\tif ($this->isWildCardMatch($params['chan'],$e['target'])) {\r\n\t\t\t\tif (strstr($e['level'],'$') !== false) { \r\n\t\t\t\t\tif ($this->functions->regex($params['text'],$e['matchtext'])) { \r\n\t\t\t\t\t\t$t = $params['text'];\r\n\t\t\t\t\t\tunset($params['text']);\r\n\t\t\t\t\t\t$this->_scope['defined'] = $params;\r\n\t\t\t\t\t\t$this->execScript($e['code'],explode(\" \",$t));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse { \r\n\t\t\t\t\tif ($this->isWildCardMatch($params['text'],$e['matchtext'])) { \r\n\t\t\t\t\t\t$t = $params['text'];\r\n\t\t\t\t\t\tunset($params['text']);\r\n\t\t\t\t\t\t$this->_scope['defined'] = $params;\r\n\t\t\t\t\t\t$this->execScript($e['code'],explode(\" \",$t));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public function broadcastOn()\n {\n // TODO: Implement broadcastOn() method.\n }", "public function testPostConversationsChatCommunicationTyping()\n {\n }", "function interact($sock) {\n\n}", "public function listen ()\n\t{\n\n\t\t// Do some config checks\n\t\tforeach ($this->config['input'] as $index => $input)\n\t\t{\n\t\t\tif ( ! isset($input['filters']))\n\t\t\t{\n\t\t\t\t$input['filters'] = array();\n\t\t\t}\n\t\t\tif (substr($input['source'], -5) === '.json')\n\t\t\t{\n\t\t\t\tif ( ! in_array('json', $input['filters']))\n\t\t\t\t{\n\t\t\t\t\t$input['filters'][] = 'json';\n\t\t\t\t}\n\t\t\t}\n\t\t\t$this->config['input'][$index] = $input;\n\t\t}\n\n\t\t// Keep listening forever until we say to stop\n\t\t$rps = 10;\n\t\twhile (true)\n\t\t{\n\t\t\t// Safe guard against losing file handlers\n\t\t\tif ($count % ($rps * 60) === 0)\n\t\t\t{\n\t\t\t\t$this->sync_file_handles();\n\t\t\t}\n\t\t\t$count++;\n\n\t\t\t// Loop over each input to build listenders\n\t\t\tforeach ($this->config['input'] as $input)\n\t\t\t{\n\n\t\t\t\t$filename = $input['source'];\n\t\t\t\t$filehash = md5($filename);\n\t\t\t\t$file = $this->input_handles[$filehash];\n\t\t\t\tif ( ! $file)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfseek($file['handle'], $file['position']);\n\t\t\t\twhile ($line = fgets($file['handle']))\n\t\t\t\t{\n\t\t\t\t\t$line = trim($line);\n\t\t\t\t\tif ($line)\n\t\t\t\t\t{\n\t\t\t\t\t\t$this->publish($input, $line);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$position = ftell($file['handle']);\n\t\t\t\t$this->input_handles[$filehash]['position'] = $position;\n\t\t\t}\n\t\t\tusleep( 1000000 / $rps );\n\t\t}\n\t}", "public function dispatch(BotKeywordEvent $keywordEvent)\n {\n }", "public function respond()\n\t{\n\t\tif (!PhandaStr::startsIn('client-', $this->payload->event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t$channel = $this->channelManager->find($this->connection->getApplication()->getAppId(), $this->payload->channel);\n\t\t$channel->broadcastToOthers($this->connection, $this->payload);\n\t}", "public function doRecognise($typeStr);", "abstract public function accept($text);", "public function listenTo(): string\n {\n }", "public function onWebServerCall($data)\n {\n $dataset = json_decode($data, true);\n\n //Routers ===============================================================\n switch ($dataset['url'])\n {\n //User enters into the chat room----------------------------\n case \"chatroom/user\":\n $topic = $this->subscribedTopics[\"ChatRoom\"];\n $topic->broadcast($data);\n echo $dataset['from'] . \" entered.\\n\";\n break;\n\n //User sends a msg------------------------------------------\n case \"chatroom/msg\":\n $toList = $dataset['to'];\n\n //BROADCAST to everyone in the room----\n if (count($toList) == 1 && $toList[0] == $dataset['from'])\n {\n $topic = $this->subscribedTopics[\"ChatRoom\"];\n $topic->broadcast($data);\n echo \"Message from : \" . $dataset['from'] . \".\\n\";\n }\n //MULTICAST to selected users---------\n else if (count($toList) > 1)\n {\n foreach ($toList as $toUser)\n {\n if (trim($toUser) != \"\")\n {\n $topic = $this->subscribedTopics[\"ChatRoom\" . $toUser];\n $topic->broadcast($data);\n echo \"Messaged to : \" . $toUser . \".\\n\";\n }\n }\n }\n break;\n\n //Article publish-----------------------------------------\n case \"article\":\n $channel = \"Articles\" . $dataset['topic'];\n $topic = $this->subscribedTopics[$channel];\n $topic->broadcast($data);\n echo \"Article published.\\n\";\n break;\n }\n }", "public function handleWebhook()\n\t{\n\t\t$this->webhook_received = false;\n\t\t$input = file_get_contents('php://input');\n\t\t$payload = json_decode($input, true);\n\t\tif($payload && isset($payload['message_type'])) {\n\t\t\t$this->webhook_received = true;\n\t\t\t$this->message_type = $payload['message_type'];\n\t\t\t$this->first_interaction = $payload['first_interaction'];\n\t\t\t$this->message = $payload['message'];\n\t\t\t$this->user = new OMBotUser($this->app_id, $this->api_key);\n\t\t\t$this->user->setUserData($payload['user']);\n\t\t\ttry {\n\t\t\t\tswitch($this->message_type) {\n\t\t\t\t\tcase 'first_message':\n\t\t\t\t\t\t//TODO: If firstmessage not implemented, fallback to text/callback/files\n\t\t\t\t\t\t$this->onFirstMessage($this->user, $this->message['text']);\n\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'text':\n\t\t\t\t\t\t$this->onTextReceived($this->user, $this->message['text']);\n\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'callback':\n\t\t\t\t\t\t$this->onCallbackReceived($this->user, $this->message['callback']);\n\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'files':\n\t\t\t\t\t\t$this->onFilesReceived($this->user, $this->message['files'], $this->message['text']);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(Exception $e) {\n\t\t\t\t//Only if user is admin!\n\t\t\t\t$this->user->sendText('Exception: ' . $e);\n\t\t\t}\n\t\t}\n\t}", "public function _filmTypeCallback (CakeEvent $event) {\n\n\t}", "protected function handleMessage( $e ) {\n\n if( $this->rawMode )\n return;\n\n $message = $e->message;\n $raw = $e->raw;\n\n static $namesReply = null,\n $listReply = null;\n switch( $message->command ) {\n case self::CMD_PING: \n //Reply to pings\n $this->send( self::CMD_PONG, $message->getArg( 0, $this->server ) );\n break;\n case self::CMD_JOIN:\n //Emit channel join events\n $nick = $message->nick ? $message->nick : $this->nick;\n $channel = $message->getArg( 0 );\n\n $this->emit( \"join, join:$channel, join:$nick, join:$channel:$nick\", array( \n 'nick' => $nick, \n 'channel' => $channel \n ) );\n break;\n case self::CMD_PART:\n //Emit channel part events\n $nick = $message->nick ? $message->nick : $this->nick;\n $channel = $this->addAllChannel( $message->getArg( 0 ) );\n\n $this->emit( \"part, part:$channel, part:$nick, part:$channel:$nick\", array( \n 'nick' => $nick, \n 'channel' => $channel \n ) );\n break;\n case self::CMD_KICK:\n //Emit kick events\n $channel = $message->getArg( 0 );\n $nick = $message->getArg( 1 );\n\n $this->emit( \"kick, kick:$channel, kick:$nick, kick:$channel:$nick\", array( \n 'nick' => $nick, \n 'channel' => $channel \n ) );\n break;\n case self::CMD_NOTICE:\n //Emit notice message events\n $from = $message->nick;\n $to = $message->getArg( 0 );\n $text = $message->getArg( 1, '' );\n\n $this->emit( \"notice, notice:$to, notice:$to:$from\", array( \n 'from' => $from, \n 'to' => $to, \n 'text' => $text \n ) );\n break;\n case self::CMD_PRIVMSG:\n //Handle private messages (Normal chat messages)\n $from = $message->nick;\n $to = $message->getArg( 0 );\n $text = $message->getArg( 1, '' );\n\n if( $this->isChannel( $to ) ) {\n\n $this->emit( \"chat, chat:$to, chat:$to:$from\", array( \n 'from' => $from, \n 'channel' => $to,\n 'text' => $text\n ) );\n break;\n }\n\n $this->emit( \"pm, pm:$to, pm:$to:$from\", array( \n 'from' => $from, \n 'to' => $to, \n 'text' => $text \n ) );\n break;\n case self::RPL_NAMREPLY:\n\n $namesReply = (object)array(\n 'nick' => $message->getArg( 0 ),\n 'channelType' => $message->getArg( 1 ),\n 'channel' => $message->getArg( 2 ),\n 'names' => array_map( 'trim', explode( ' ', $message->getArg( 3 ) ) )\n );\n case self::RPL_ENDOFNAMES:\n\n if( empty( $namesReply ) )\n break;\n\n $channel = $namesReply->channel;\n\n $this->emit( \"names, names:$channel\", array( \n 'names' => $namesReply, \n 'channel' => $channel \n ) );\n $namesReply = null;\n break;\n case self::RPL_LISTSTART:\n\n $listReply = array();\n break;\n case self::RPL_LIST:\n\n $channel = $message->getArg( 1 );\n $listReply[ $channel ] = (object)array(\n 'channel' => $channel,\n 'userCount' => $message->getArg( 2 ),\n 'topic' => $message->getArg( 3 )\n );\n break;\n case self::RPL_LISTEND:\n\n $this->emit( 'list', array( 'list' => $listReply ) );\n $listReply = null;\n break;\n case self::RPL_WELCOME:\n //correct internal nickname, if given a new one by the server\n $this->nick = $message->getArg( 0, $this->nick );\n\n $this->emit( 'welcome' );\n break;\n case self::RPL_ISUPPORT:\n\n $args = $message->args;\n unset( $args[0], $args[ count( $args ) - 1 ] );\n\n foreach( $args as $arg ) {\n\n $explode = explode( '=', $arg );\n $key = $explode[0];\n $val = $explode[1] ?? null;\n\n //handle some keys specifically\n switch( strtolower( $key ) ) {\n case 'prefix':\n\n list( $modes, $prefixes ) = explode( ')', ltrim( $val, '(' ) );\n $modes = str_split( $modes );\n $prefixes = str_split( $prefixes );\n $val = array();\n foreach( $modes as $k => $v )\n $val[ $prefixes[ $k ] ] = $v;\n\n break;\n case 'chantypes':\n case 'statusmsg':\n case 'elist':\n\n $val = str_split( $val );\n break;\n case 'chanmodes':\n case 'language':\n\n $val = explode( ',', $val );\n break;\n }\n\n $this->options[ $key ] = $val;\n }\n\n $this->emit( 'options', array( 'options' => $this->options ) );\n break;\n }\n }", "public function MinionPlugin_Token_Handler($sender) {\n $state = &$sender->EventArguments['State'];\n\n if (!$state['Method'] && in_array($state['CompareToken'], array('play', 'playing'))) {\n $sender->consume($state, 'Method', 'play');\n\n $sender->consume($state, 'Gather', array(\n 'Node' => 'Phrase',\n 'Delta' => ''\n ));\n }\n }", "function _voip_asterisk_generic_event_handler($ecode, $data, $server, $port) {\n voip_error_reset();\n\n // by default, we do not do anything with unsolicited events coming from the server\n return TRUE;\n}" ]
[ "0.70453453", "0.5855227", "0.5774532", "0.5774532", "0.5360096", "0.52571106", "0.52554893", "0.5196566", "0.5188541", "0.51236516", "0.51182026", "0.5015346", "0.4981036", "0.49527025", "0.4942235", "0.49226397", "0.4914236", "0.48906317", "0.48713952", "0.48436457", "0.47730514", "0.47591248", "0.47589976", "0.4753758", "0.47401568", "0.46806917", "0.4680531", "0.4671438", "0.46647906", "0.4651526" ]
0.845436
0
/ Handles the stop typing event invoked by the client and broadcast it to all
public function stop_typing () { // when the client emits 'stop typing', we broadcast it to others $this->socket->event->addEvent('stop typing', function ($socket,$data) { $socket->event->broadcastMessage('stop typing', array( 'username'=>$socket->socketID[$socket->user->id], )); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function typing () {\r\n\r\n // when the client emits 'typing', we broadcast it to others\r\n $this->socket->event->addEvent('typing', function ($socket,$data) {\r\n $socket->event->broadcastMessage('typing', array(\r\n 'username'=>$socket->socketID[$socket->user->id],\r\n ));\r\n\r\n });\r\n\r\n }", "public function emitStopTyping(): self\n {\n $this->broadcaster\n ->toPresence($this->resolveThread())\n ->with(PresenceEvents::makeStopTypingEvent($this->messenger->getProvider()))\n ->broadcast(PresenceEvents::getStopTypingClass());\n\n return $this;\n }", "public function emitStopTyping(): self\n {\n $this->broadcaster\n ->toPresence($this->resolveThread())\n ->with(PresenceEvents::makeStopTypingEvent($this->messenger->getProvider()))\n ->broadcast(PresenceEvents::getStopTypingClass());\n\n return $this;\n }", "public function onReceive(string $str)\n {\n }", "public function handle_stop() {\n\t\t$this->flag_stop = true;\n\t}", "public function stop()\n {\n $payload = '';\n\n $this->sendRequest(self::FUNCTION_STOP, $payload);\n }", "public function unlisten(): void;", "public function onStop();", "public function stop($event);", "public function isStopWord(array $event)\n {\n $word = $event[1];\n\n if (!in_array($word, $this->_stopWords)) {\n $this->_eventManager->publish(['valid_word', $word]);\n }\n }", "protected function stop() {\n\t$this->_stop = true;\n}", "function stop() {\r\n $this->_stop = TRUE;\r\n }", "public function actionStop()\n {\n if(PHP_OS !== 'Linux')\n {\n echo \"Deprecated in non-linux OS\\n\";\n return;\n }\n $process = $this->getChatProcess();\n if($process)\n {\n if($this->canTerminate($process))\n {\n echo 'Stopping chat ... ';\n `kill {$process['pid']}`;\n sleep(3);\n if(! $this->isRunning())\n echo \"ok\\n\";\n else\n echo \"failed\\n\";\n }\n else\n {\n echo \"You can not stop chat. Owner is {$process['owner']}\\n\";\n }\n }\n else\n {\n echo \"Chat is not running\\n\";\n }\n }", "public function stop();", "public function stop();", "public function stop();", "public function stop();", "public function stop();", "public function stop();", "public function stop()\n {\n $this->client->disconnect();\n $this->valid = false;\n }", "public function stop()\n {\n }", "public function stop()\n {\n }", "function setStop($val){ return $this->setField('stop',$val); }", "public function stop()\n {\n throw new StopEvent;\n }", "public function stop()\n {\n $this->mustStop = true;\n }", "public function stopFirewall()\n {\n $vars = $this->prepareArgs(get_defined_vars());\n return $this->send($vars);\n }", "public function stop()\n {\n $this->pubsub->stop();\n }", "protected function _stop()\n {\n $this->core->stop = TRUE;\n }", "function textEvent($params) { \r\n\t\t$te = self::$events['text'];\r\n\t\tforeach ($te as $e) {\r\n\t\t\tif ($e['target'] == \"#\") { $e['target'] = \"*\"; }\r\n\t\t\tif ($this->isWildCardMatch($params['chan'],$e['target'])) {\r\n\t\t\t\tif (strstr($e['level'],'$') !== false) { \r\n\t\t\t\t\tif ($this->functions->regex($params['text'],$e['matchtext'])) { \r\n\t\t\t\t\t\t$t = $params['text'];\r\n\t\t\t\t\t\tunset($params['text']);\r\n\t\t\t\t\t\t$this->_scope['defined'] = $params;\r\n\t\t\t\t\t\t$this->execScript($e['code'],explode(\" \",$t));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse { \r\n\t\t\t\t\tif ($this->isWildCardMatch($params['text'],$e['matchtext'])) { \r\n\t\t\t\t\t\t$t = $params['text'];\r\n\t\t\t\t\t\tunset($params['text']);\r\n\t\t\t\t\t\t$this->_scope['defined'] = $params;\r\n\t\t\t\t\t\t$this->execScript($e['code'],explode(\" \",$t));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}", "public function stopEngine(){\n }" ]
[ "0.6709212", "0.60764766", "0.60764766", "0.5439648", "0.5370706", "0.53551406", "0.5326029", "0.527387", "0.5164519", "0.51200485", "0.5026436", "0.5021074", "0.49853522", "0.49668574", "0.49668574", "0.49668574", "0.49668574", "0.49668574", "0.49668574", "0.49272117", "0.4834319", "0.4834319", "0.4816359", "0.47852513", "0.47823066", "0.47812974", "0.47410616", "0.472072", "0.4636483", "0.4620687" ]
0.8584391
0
/ Handles the chat message event invoked by the client and broadcast it to all
public function chat_message () { //for client 2 example only $this->socket->event->addEvent('chat message', function ($socket,$data,$sender) { $socket->event->broadcastMessage('chat message', $data,true); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function new_message () {\r\n // when the client emits 'new message', this listens and executes\r\n $this->socket->event->addEvent('new message', function ($socket,$data,$sender) {\r\n // we tell the client to execute 'new message'\r\n $socket->event->broadcastMessage('new message', array(\r\n 'username'=>$socket->socketID[$socket->user->id],\r\n 'message'=>$data\r\n ));\r\n \r\n });\r\n\r\n\r\n }", "public function onMessage($msgData) {\r\n\r\n }", "public function onMessage($msgData) {\r\n\r\n }", "function onMessage($client_id, $message)\n {\n $this->log(\"onMessage: \" . $client_id . ' = ' . $message['message']);\n //$this->send($client_id, 'Server is ok!');\n $msg = json_decode($message['message'], true);\n //判断消息是否合法,不合法消息将返回错误信息\n if (!in_array($msg['cmd'], $this->type) || empty($msg['cmd']) || !method_exists($this, 'cmd_' . $msg['cmd'])) {\n $this->sendErrorMessage($client_id, \\WebIm\\error\\WsErr::E101);\n return;\n }\n //处理消息\n $func = 'cmd_' . $msg['cmd'];\n $this->$func($client_id, $msg);\n }", "public function onReceiveMessage($message) {}", "function onMessage(ConnectionInterface $from, $msg)\n {\n $data = json_decode($msg);\n $data->date = date('d/m/Y H:i:s');\n\n foreach ($this->clients as $client) {\n $client->send(json_encode($data));\n }\n\n echo \"Cliente {$from->resourceId} enviou uma mensagem\" . PHP_EOL;\n }", "function wsOnMessage($clientID, $message, $messageLength, $binary) {\n\tglobal $Server;\n\t$ip = long2ip( $Server->wsClients[$clientID][6] );\n\n\t// check if message length is 0\n\tif ($messageLength == 0) {\n\t\t$Server->wsClose($clientID);\n\t\treturn;\n\t}\n\n\t//The speaker is the only person in the room. Don't let them feel lonely.\n\tif ( sizeof($Server->wsClients) == 1 ){\n\t\t$Server->wsSend($clientID, \"There isn't anyone else in the room\");\n\t}else{\n\t\t//Send the message to everyone but the person who said it\n\t\tforeach ( $Server->wsClients as $id => $client ){\n\t\t\t//not the server ip\n\t\t\tif( ($ip != IP) && !ALLOW_NON_SERVER_MESSAGES ){\n\t\t\t\t//reply to just the client\n\t\t\t\tif ( $id = $clientID ){\n\t\t\t\t\t$Server->wsSend($id, \"You cannot send a message\");\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\t//server Ip, broadcast the message.\n\t\t\t\tif ( $id != $clientID ){\n\t\t\t\t\t$userINFO = md5($id.PRIVATE_KEY);\n\t\t\t\t\tif( SHOW_REMOTE_IP_INFO ){\n\t\t\t\t\t\t$Server->wsSend($id, json_encode( array(\"from\" => $userINFO, \"to\" => $id, \"message\" => $message) ) );\n\t\t\t\t\t}else{\n\t\t\t\t\t\t$Server->wsSend($id, json_encode( array(\"from\" => \"*\", \"to\" => $id, \"message\" => $message) ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "function onMessage(ConnectionInterface $from, $msg)\n {\n }", "public function respond()\n\t{\n\t\tif (!PhandaStr::startsIn('client-', $this->payload->event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t$channel = $this->channelManager->find($this->connection->getApplication()->getAppId(), $this->payload->channel);\n\t\t$channel->broadcastToOthers($this->connection, $this->payload);\n\t}", "function chat_on() {\n \n }", "public function onData(int $clientId, Websocket\\Message $msg);", "public function onMessage(ConnectionInterface $connection, $message)\n {\n //\n }", "public function sendMessage(){\n $user = Auth::user();\n // $chatroom->message = request()->message;\n // $success = request()->user()->chatroom()->save($chatroom);\n $chatroom = $user->chatroom()->create([\n 'message' => request()->get('message')\n ]);\n // event(new MessagePosted($chatroom,$user));\n\n broadcast(new MessagePosted($chatroom, $user))->toOthers();\n\n if($chatroom){\n return ['success' => 'good'];\n }else{\n return ['errors' => 'Message is sent failed'];\n }\n\n }", "public function onMessage(ConnectionInterface $from, $msg) {\n $data = json_decode($msg, true);\n switch ($data['command']) {\n case \"subscribe\":\n $channel = $data['channel'];\n $this->subscriptions[$from->resourceId] = $channel;\n self::info(\"Subscribe to channel '{$channel}' done \");\n break;\n case \"message\":\n $data = $data['message'];\n if (isset($data['channel']) && count($this->subscriptions)) {\n\n // Init subscribed channel\n $subscribedChannels = array();\n\n foreach ($this->subscriptions as $key => $subscription) {\n if($subscription === $data['channel']) {\n $subscribedChannels[$key] = $subscription;\n }\n }\n\n // Send messages to correspendant channels\n if(count($subscribedChannels)){\n foreach($subscribedChannels as $key => $channel){\n if(isset($this->users[$key]) && $this->users[$key]){\n $this->users[$key]->send(json_encode($data));\n }\n }\n }\n\n }\n break;\n }\n }", "function onMessage(ConnectionInterface $from, $msg)\n {\n echo \"Message arrived $msg\\n\";\n foreach($this->clients as $client){\n if($client !== $from){\n $client->send($msg);\n }\n }\n }", "public function onMessage(ConnectionInterface $from, $message) {\n #echo sprintf('Connection %d sending message \"%s\" to %d other connection%s' . \"\\n\", $from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');\n $this->CheckStatusServer();\n $this->CheckDevices();\n $msg = json_decode($message, true);\n\n if ($msg && is_array($msg)) {\n echo \"Message: \";\n echo $message . \"\\n\";\n \n if (array_key_exists('i_am_alive', $msg)) {\n $this->InitUser($from, $msg);\n }\n elseif (array_key_exists('message', $msg)) {\n if ($this->POST()) {\n if ($msg['message'] == 'Call_to_you') $this->SendCall($from, $msg['unix_time']); //from - door\n if ($msg['message'] == 'accept_by_me') $this->SendAnswer($from); //from - Android\n if ($msg['message'] == '30sec_timeout') $this->SendTimeOut($from); //from - door\n if ($msg['message'] == 'webRTC') $this->SendWebRTC($from, $message); //from - door\n if ($msg['message'] == 'getImage') $this->getImage($from, $msg['nameDoor']); //from - admin\n if ($msg['message'] == 'image') $this->SendImage($from, $msg); //from - door\n if ($msg['message'] == 'passage') $this->GetPassage($from, $msg['data']);\n\n }\n else\n $from->send(json_encode(array('WebRTC server is down' => 'Service unavailable. Call to sysadmin')));\n }\n }\n }", "public function sendMessage() {\n // Retrieving data from fetch\n $contentType = isset($_SERVER[\"CONTENT_TYPE\"]) ? trim($_SERVER[\"CONTENT_TYPE\"]) : '';\n if ($contentType === \"application/json\") {\n //Receiving the RAW post data.\n $content = trim(file_get_contents(\"php://input\"));\n $decoded = json_decode($content, true);\n\n // Creating a new message object with appropriate properties, and saving it\n $chat_id = $decoded['chatId'];\n $message_body = filter_var($decoded['newPostMessage'], FILTER_SANITIZE_SPECIAL_CHARS);\n $message = new Messages();\n $message->setChatId($chat_id);\n $message->setMessage($message_body);\n $message->setAuthorId($_SESSION['id']);\n $message->save();\n\n //Updating chat updated at property (used to sort chats according to most recent messages)\n $chat = Chats::find($chat_id);\n $chat->setUpdatedAt(new DateTime());\n $chat->save();\n\n //Sending response to be displayed on appropriate chat\n header('Content-type: application/json');\n header('Access-Control-Allow-Origin', '*');\n header('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE');\n echo json_encode($decoded['chatId']);\n \n }\n \n }", "public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) {\n $this->logger->notice(\"Broadcasting \" . strlen($msg->getData()) . \" bytes\");\n\n foreach($this->getConnections() as $client){\n $client->sendString(\"User {$user->getId()} said: \".$msg->getData());\n }\n }", "function broadcast_message($msgi)\r\n{\r\n\tshout_message(\"\",$msgi);\r\n}", "public function broadcastOn()\n {\n $data['user_id'] = $this->user_id;\n $data['user_name'] = $this->user_name;\n $data['message'] = $this->message;\n $data['created_at'] = $this->created_at;\n $query = \"insert into messages (user_id,user_name,message, created_at) values (:user_id,:user_name,:message, :created_at)\";\n DB::insert($query, $data);\n return new Channel('chat');\n }", "public function onMessage(MessageInterface $message, $sessionId);", "public function broadcastOn()\n {\n //prefix laravel_database_message\n return new Channel('message');\n }", "public function onData(int $clientId, Websocket\\Message $msg) {\n // stream those instead of buffering them.\n $body = yield $msg;\n\n // We use the IP as name for this simple chat app.\n $ip = $this->connections[$clientId];\n\n // If someone mentions an IP, we send the message only to clients with that IP and the sender itself.\n if (preg_match(\"~@(\\\\d+\\\\.\\\\d+\\\\.\\\\d+\\\\.\\\\d+)\\\\b~\", $body, $match)) {\n list($all, $receiver) = $match;\n\n $payload = $ip . \" (private): \" . substr($body, \\strlen($all));\n $clients = array_keys($this->ips[$receiver] ?? []);\n\n if (!empty($clients)) {\n $this->endpoint->multicast($payload, $clients);\n }\n\n $this->endpoint->send($payload, $clientId);\n } else {\n $payload = $ip . \": \" . $body;\n $this->endpoint->broadcast($payload);\n }\n }", "public function onMessage(ConnectionInterface $from, $msg) {\n $data = json_decode($msg, true);\n $identifier = $from->WebSocket->request->getQuery()->get('username');\n\n // The payload sent by the client is not valid.\n if(!is_array($data) or !isset($data['type'])) {\n throw new Exception('Invalid payload');\n }\n\n // The client provided an id. We send a confirm\n // event to confirm that the server received the message.\n if(isset($data['id'])) {\n $from->send($this->clients->createPayload(array(\n 'type' => 'confirm',\n 'id' => $data['id']\n )));\n }\n\n // The client sent leave event, close the conection.\n if($data['type'] == 'leave') {\n $from->close();\n\n return;\n }\n\n // The client sent a message.\n if($data['type'] == 'message') {\n if(!isset($data['message']) or empty($data['message'])) {\n throw new Exception('Invalid payload');\n }\n\n // Broadcast the message to all clients\n // except the one that sent the message.\n $this->clients->broadcast(array(\n 'type' => 'message',\n 'author' => $identifier,\n 'message' => $data['message']\n ), function ($clientIdent) use ($identifier) {\n return $clientIdent != $identifier;\n });\n }\n }", "public function sendMessage()\n\t{\n if ($this->request->is('ajax')) {\n $data = $this->request->getData();\n $client = $this->Client->get($data['clientId']);\n $item = $this->Item->get($data['itemId']);\n $input = [\n 'itemId' => $item->id,\n 'shopId' => $item->shop,\n 'clientId' => $client->id,\n 'roomId' => $data['roomId'],\n 'message' => h($data['message']),\n 'messageFrom' => $data['messageFrom'],\n 'readed' => ($data['messageFrom'] == 'shop') ? 1 : 0\n ];\n $this->Chat->insert($input);\n // Update message of room chat\n $this->getMessage();\n }\n\t}", "public function broadcastWith()\n { \n \n $text = '<div class=\"outgoing_msg\">\n <div class=\"sent_msg\">\n <p>'.$this->message->message.'</p>\n <span class=\"time_date\">'.chatDateFormat($this->message->created_at).'</span>\n </div>\n </div>';\n\n $summary_text = \"<div class='chat_list' id='\".keyGeneration([$this->message->receiver, \n 'individual',\n 'summary-id']).\"'>\n <div class='chat_people' \n onclick=\\\"getAjaxViewForMessage(\".$this->message->receiver.\",\n 'individual')\\\">\n <div class='chat_img'> <img src='\".userImage($this->receiverUser).\"'> </div>\n <div class='chat_ib'>\n <h5>{$this->receiverUser->name} <span class='chat_date'>\".dateInText($this->message->created_at).\"</span></h5>\n <p>You: \".\\Str::limit($this->message->message, 26, '...').\"</p>\n </div>\n </div>\n </div>\";\n\n $element = $this->message->receiver.'-individual-id';\n $summary_element = $this->message->receiver.'-individual-summary-id';\n $message_direction = 'outgoing';\n \n $this->data['id-'.$this->message->sender] = [\n 'text'=> $text,\n 'element' => $element,\n 'message_id' => 'message-'.$this->message->id,\n 'message_direction' => $message_direction,\n 'summary_text' => $summary_text,\n 'summary_element' => $summary_element,\n 'user' => $this->message->receiver \n ];\n \n\n\n $text = '<div class=\"incoming_msg\">\n <div class=\"incoming_msg_img\"> <img src=\"'.userImage($this->authUser).'\">\n </div>\n <div class=\"received_msg\">\n <div class=\"received_withd_msg\">\n <p>'.$this->message->message.'</p>\n <span class=\"time_date\">'.chatDateFormat($this->message->created_at).'</span>\n </div>\n </div>\n </div>';\n\n $summary_text = \"<div class='chat_list' id='\".keyGeneration([$this->message->sender, \n 'individual',\n 'summary-id']).\"'>\n <div class='chat_people' \n onclick=\\\"getAjaxViewForMessage(\".$this->message->sender.\",\n 'individual')\\\">\n <div class='chat_img'> <img src='\".userImage($this->authUser).\"'> </div>\n <div class='chat_ib'>\n <h5>{$this->authUser->name} <span class='chat_date'>\".dateInText($this->message->created_at).\"</span></h5>\n <p \".\\Str::limit($this->message->message, 26, '...').\"</p>\n </div>\n </div>\n </div>\";\n\n\n $element = $this->message->sender.'-individual-id';\n $summary_element = $this->message->sender.'-individual-summary-id';\n $message_direction = 'incoming';\n\n $this->data['id-'.$this->message->receiver] = [\n 'text'=> $text,\n 'element' => $element,\n 'message_id' => 'message-'.$this->message->id,\n 'message_direction' => $message_direction,\n 'summary_text' => $summary_text,\n 'summary_element' => $summary_element,\n 'user' => $this->message->sender \n ];\n \n return $this->data;\n }", "function onMessage(\\Ratchet\\ConnectionInterface $from, $msg)\n {\n $payload = \\json_decode($msg);\n try {\n if (isset($payload->type)) {\n switch ($payload->type) {\n case Packet::MESSAGE:\n $this->processMessage($payload, $from);\n break;\n case Packet::AUTH:\n $this->processAuthenticate($payload, $from);\n break;\n default:\n throw new SocketException('Unknown type ' . $payload->type);\n }\n }\n } catch (SocketException $e) {\n $from->send($this->serializePacket($e));\n }\n }", "public function handle(ReceiveMessage $message)\n {\n if(strtolower($message->getMessage()) == 'start') {\n FaceUser::where('face_id', $message->getSender())->delete();\n $this->newUser($message->getSender());\n }\n else if (strtolower($message->getMessage()) == 'restart') {\n $this->deleteUser($message->getSender());\n }\n else {\n $user = FaceUser::where('face_id', $message->getSender())->first();\n if($user){\n if(strtolower($message->getMessage()) == 'da' || strtolower($message->getMessage()) == 'ne'){\n $this->handleAnswer($message->getSender(), strtolower($message->getMessage()));\n }\n else {\n $this->send(new Text($message->getSender(), 'Odgovarajte sa \"da\" ili \"ne\"'));\n }\n }\n else {\n $this->send(new Text($message->getSender(), 'Za pocetak, unesite: \"start\"'));\n }\n }\n }", "public function onMessage(string $data, AbstractConnection $connection): void\n {\n $this->logger->debug(\n sprintf(\n \"Asterisk web socket server '%s' sent raw message: '%s'\",\n $connection->getIp(),\n $data\n ),\n [__FUNCTION__]\n );\n\n $this->abstractWebSocketClient->onMessageHandlerLogic($data);\n }", "public function listen($message)\n {\n $this->messages[] = $message;\n }" ]
[ "0.7156019", "0.7055862", "0.7055862", "0.7026981", "0.69800705", "0.6976486", "0.67751235", "0.6748553", "0.6671108", "0.6664475", "0.65876454", "0.6550754", "0.6514647", "0.65036744", "0.6501628", "0.64906764", "0.6478413", "0.64562696", "0.63917637", "0.6381156", "0.6329961", "0.6306691", "0.62997127", "0.6262467", "0.62354803", "0.6193921", "0.6157342", "0.61231846", "0.6113938", "0.6102012" ]
0.8602338
0
/ Handles the 'new message' event invoked by the client and broadcast it to all
public function new_message () { // when the client emits 'new message', this listens and executes $this->socket->event->addEvent('new message', function ($socket,$data,$sender) { // we tell the client to execute 'new message' $socket->event->broadcastMessage('new message', array( 'username'=>$socket->socketID[$socket->user->id], 'message'=>$data )); }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function chat_message () {\r\n //for client 2 example only\r\n $this->socket->event->addEvent('chat message', function ($socket,$data,$sender) {\r\n $socket->event->broadcastMessage('chat message', $data,true);\r\n });\r\n }", "public function onReceiveMessage($message) {}", "public function onMessage($msgData) {\r\n\r\n }", "public function onMessage($msgData) {\r\n\r\n }", "function onMessage($client_id, $message)\n {\n $this->log(\"onMessage: \" . $client_id . ' = ' . $message['message']);\n //$this->send($client_id, 'Server is ok!');\n $msg = json_decode($message['message'], true);\n //判断消息是否合法,不合法消息将返回错误信息\n if (!in_array($msg['cmd'], $this->type) || empty($msg['cmd']) || !method_exists($this, 'cmd_' . $msg['cmd'])) {\n $this->sendErrorMessage($client_id, \\WebIm\\error\\WsErr::E101);\n return;\n }\n //处理消息\n $func = 'cmd_' . $msg['cmd'];\n $this->$func($client_id, $msg);\n }", "function onMessage(ConnectionInterface $from, $msg)\n {\n $data = json_decode($msg);\n $data->date = date('d/m/Y H:i:s');\n\n foreach ($this->clients as $client) {\n $client->send(json_encode($data));\n }\n\n echo \"Cliente {$from->resourceId} enviou uma mensagem\" . PHP_EOL;\n }", "public function onData(int $clientId, Websocket\\Message $msg);", "public function listen($message)\n {\n $this->messages[] = $message;\n }", "function wsOnMessage($clientID, $message, $messageLength, $binary) {\n\tglobal $Server;\n\t$ip = long2ip( $Server->wsClients[$clientID][6] );\n\n\t// check if message length is 0\n\tif ($messageLength == 0) {\n\t\t$Server->wsClose($clientID);\n\t\treturn;\n\t}\n\n\t//The speaker is the only person in the room. Don't let them feel lonely.\n\tif ( sizeof($Server->wsClients) == 1 ){\n\t\t$Server->wsSend($clientID, \"There isn't anyone else in the room\");\n\t}else{\n\t\t//Send the message to everyone but the person who said it\n\t\tforeach ( $Server->wsClients as $id => $client ){\n\t\t\t//not the server ip\n\t\t\tif( ($ip != IP) && !ALLOW_NON_SERVER_MESSAGES ){\n\t\t\t\t//reply to just the client\n\t\t\t\tif ( $id = $clientID ){\n\t\t\t\t\t$Server->wsSend($id, \"You cannot send a message\");\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\t//server Ip, broadcast the message.\n\t\t\t\tif ( $id != $clientID ){\n\t\t\t\t\t$userINFO = md5($id.PRIVATE_KEY);\n\t\t\t\t\tif( SHOW_REMOTE_IP_INFO ){\n\t\t\t\t\t\t$Server->wsSend($id, json_encode( array(\"from\" => $userINFO, \"to\" => $id, \"message\" => $message) ) );\n\t\t\t\t\t}else{\n\t\t\t\t\t\t$Server->wsSend($id, json_encode( array(\"from\" => \"*\", \"to\" => $id, \"message\" => $message) ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "function onNewMessage($text) {\n\t\treturn true;\n\t}", "public function getNewMessages();", "public function broadcastOn()\n {\n //prefix laravel_database_message\n return new Channel('message');\n }", "public function webSocketMessage()\n {\n $this->webSocketMessagesCount++;\n }", "function wsOnMessage($clientID, $message, $messageLength, $binary) {\n\t\n\n\t\t$ip = long2ip($this->socket->wsClients[$clientID][6]);\t\t\n\t\n\t//\t$this->socket->log(\"$ip ($clientID) send to message.\");\t\n\n\t\t// check if message length is 0\n\t\tif ($messageLength == 0) {\n\t\t\t$this->socket->wsClose($clientID);\n\t\t\treturn;\n\t\t}\n\t\t$msj=json_decode($message,true);\n\t\tprint_r($msj);\n\t\t//Si es un mensaje tipo {'cliente':'admin'} seteo la posicion 12 \n\t\t//ademas seteo dos variables para mantener el ID del cliente de cada extremo\n\t\tif (isset($msj['cliente'])){\n\t\t\tif($msj['cliente']==\"plataforma\"){\n\t\t\t\t$this->plataformaID=$clientID;\n\t\t\t}\n\t\t\tif($msj['cliente']==\"controlador\"){\n\t\t\t\t$this->controladorID=$clientID;\n\t\t\t}\n\t\t\t$this->socket->wsClients[$clientID][12] = $msj['cliente'];\n\t\t}\n\t\n\n\t\t//foreach ($this->socket->wsClients as $id => $client){\n\t\t\t//verifico si ya tienen definido un tipo en la posicion 12\n\t\t\t//ya se sabe si el mensaje viene desde el controlador o la plataforma\n\t\t\tif(isset($this->socket->wsClients[$clientID][12]) && !isset($msj['cliente'])){\n\t\t\t\techo \"clientID: [\".$clientID.'] === ';\n\t\t\t\techo \"plataformaID: [\".$this->plataformaID.'] === ';\n\t\t\t\techo \"controladorID: [\".$this->controladorID.'], ';\n\t\t\t\t//si el mensaje vino de la plataforma\n\t\t\t\tif($clientID==$this->plataformaID){\n\n\t\t\t\t\t//obtengo la ultima orden escrita en la base de datos por el controlador\n\t\t\t\t\t$ultima_orden = $this->controlador->get_last();\n\t\t\t\t\tif(!is_null($ultima_orden)){\n\t\t\t\t\t\techo 'enviando datos del controlador';\n\t\t\t\t\t\t$this->socket->wsSend($clientID,json_encode($ultima_orden));\n\t\t\t\t\t}\n\n\t\t\t\t\t$datos = array(\n\t\t\t\t\t\t'leido'=>FALSE,\n\t\t\t\t\t\t'fecha'=>microtime(true)\n\t\t\t\t\t);\n\t\t\t\t\t$datos = array_merge($datos,$msj);\n\t\t\t\t\t//guardo los datos en la tabla plataforma\n\t\t\t\t\t$this->plataforma->save($datos);\n\n\t\t\t\t\t//if($this->controladorID)\n\t\t\t\t\t//\t$this->socket->wsSend($this->controladorID,json_encode($msj));\n\t\t\t\t}\n\t\t\t\t//si el mensaje vino del controlador\n\t\t\t\tif($clientID==$this->controladorID){\n\t\t\t\t\techo \"msj from: controlador\".$this->controladorID;\n\t\t\t\t\t$datos = array(\n\t\t\t\t\t\t'leido'=>FALSE,\n\t\t\t\t\t\t'fecha'=>microtime(true)\n\t\t\t\t\t);\n\t\t\t\t\t$datos = array_merge($datos,$msj);\n\t\t\t\t\t//guardo los datos en la tabla controlador\n\t\t\t\t\t$this->controlador->save($datos);\n\t\t\t\t\techo \"plataformaID: [\".$this->plataformaID.'] ';\n\t\t\t\t\tif($this->plataformaID){\n\t\t\t\t\t\techo \"enviando mensaje a plataforma\";\n\t\t\t\t\t\t$this->socket->wsSend($this->plataformaID,json_encode($msj));\n\t\t\t\t\t}\n\t\t\t\t\t//obtengo la ultima posicion escfrita en la base de datos por la plataforma\n\t\t\t\t\t$ultimo_comando = $this->plataforma->get_last();\n\t\t\t\t\tif(!is_null($ultimo_comando)){\n\t\t\t\t\t\t//foreach ($this->socket->wsClients as $d => $c) {\n\t\t\t\t\t\t\t//echo json_encode($ultimo_comando);\n\t\t\t\t\t\t\t//envio la ultima posicion de la plataforma al controlador\n\t\t\t\t\t\t\t$this->socket->wsSend($clientID,json_encode($ultimo_comando));\n\t\t\t\t\t\t//}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t//\t$this->socket->wsSend($clientID,json_encode($msj));\n\t \t//\t$this->socket->log(\"$ip ($clientID) se guardo\");\n\t\t//}\n\t\t \n\t}", "function onMessage(ConnectionInterface $from, $msg)\n {\n }", "function wsOnMessage($clientID, $message, $messageLength, $binary) {\n\tglobal $Server, $gameArray, $wsClientNames;\n\t$ip = long2ip( $Server->wsClients[$clientID][6] );\n\t\n\t$jsonMessage = json_decode($message, true);\n\t\n\t$action = (string) $jsonMessage[\"action\"];\n\t$data = $jsonMessage[\"data\"];\n\t\n\tswitch ($action)\n\t{\n\t\tcase \"new\":\t\t\t\n\t\t\t\n\t\t\t$response = array(\n\t\t\t\t\"action\"=>\"log\",\n\t\t\t\t\"message\"=>\"Creating new game...\"\n\t\t\t);\n\t\t\t\n\t\t\tsendJson($clientID, $response);\n\t\t\t\n\t\t\taddGame($clientID, $data);\n\t\t\tbreak;\n\t\tcase \"join\":\t\t\t\n\t\t\t$response = array(\n\t\t\t\t\"action\"=>\"log\",\n\t\t\t\t\"message\"=>\"Joining a game\"\n\t\t\t);\n\t\t\t\n\t\t\t$gameNumber = (int) $data[\"game\"];\n\t\t\t$teamNumber = (int) $data[\"team\"];\n\t\t\t\n\t\t\tsendJson($clientID, $response);\n\t\t\t\n\t\t\tjoinGame($clientID, $gameNumber, $teamNumber);\n\t\t\tbreak;\n\t\tcase \"leave\":\n\t\t\t$response = array(\n\t\t\t\t\"action\"=>\"log\",\n\t\t\t\t\"message\"=>\"Attempting to leave current game.\"\n\t\t\t);\n\t\t\t\n\t\t\tsendJson($clientID, $response);\n\t\t\t\n\t\t\tleaveGame($clientID);\n\t\t\t\n\t\t\tbreak;\n\t\tcase \"changename\":\n\t\t\t$wsClientNames[$clientID] = (string)$data;\t\n\t\t\t\n\t\t\tforeach ( $Server->wsClients as $id => $client )\n\t\t\t{\n\t\t\t\tif ( $id != $clientID )\n\t\t\t\t{\n\t\t\t\t\t$response = array(\n\t\t\t\t\t\t\"action\"=>\"chat\",\n\t\t\t\t\t\t\"message\"=>(string)$data . \" has entered the lobby.\"\n\t\t\t\t\t);\n\t\t\t\n\t\t\t\t\tsendJson($id, $response);\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\tbreak;\n\t\t\t\n\t\tcase \"confirm\":\n\t\t\tconfirmClient($clientID);\n\t\t\tbreak;\n\t\t\t\n\t\tcase \"game\":\n\t\t\t\n\t\t\tforwardCommand($clientID, $data);\n\t\t\t\n\t\t\tbreak;\n\t\tcase \"chat\":\n\t\t\t\n\t\t\tchat($clientID, (string)$data);\n\t\t\tbreak;\t\t\t\n\t\tdefault:\t\t\t\n\t\t\t$response = array(\n\t\t\t\t\"action\"=>\"log\",\n\t\t\t\t\"message\"=>\"Didn't recognize that command.\"\n\t\t\t);\n\t\t\t\n\t\t\tsendJson($clientID, $response);\t\t\t\t\t\n\t}\n\n\t// check if message length is 0\n\tif ($messageLength == 0) {\n\t\t$Server->wsClose($clientID);\n\t\treturn;\n\t}\n\n\t//foreach ( $Server->wsClients as $id => $client )\n\t\t//$Server->wsSend($id, \"Visitor $clientID ($ip) said \\\"$message\\\"\");\n\t\t//$Server->wsSend($id, \"Server response: ($responseMessage)\");\n\t\t//$arrayCount = (string)count($gameArray);\n\t\t//$Server->wsSend($id, \"number of open games: ($arrayCount)\");\n}", "public function onMessage(ConnectionInterface $connection, $message)\n {\n //\n }", "public function respond()\n\t{\n\t\tif (!PhandaStr::startsIn('client-', $this->payload->event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t$channel = $this->channelManager->find($this->connection->getApplication()->getAppId(), $this->payload->channel);\n\t\t$channel->broadcastToOthers($this->connection, $this->payload);\n\t}", "function msg(){\n $options = array(\n 'cluster' => 'ap2',\n 'encrypted' => false\n );\n\n $pusher = new Pusher\\Pusher(\n '464fe91876e8af33346d',\n '2440b551c629f13b1d19',\n '379900',\n $options\n );\n // print_r($pusher);\n $data['message'] = 'hello world';\n $pusher->trigger('my-channel', 'my-event', $data);\n //$this->render('home');\n exit;\n }", "public function broadcastOn()\n {\n $data['user_id'] = $this->user_id;\n $data['user_name'] = $this->user_name;\n $data['message'] = $this->message;\n $data['created_at'] = $this->created_at;\n $query = \"insert into messages (user_id,user_name,message, created_at) values (:user_id,:user_name,:message, :created_at)\";\n DB::insert($query, $data);\n return new Channel('chat');\n }", "public static function onMessageAdd($messageId, $messageFields);", "public function onData(int $clientId, Websocket\\Message $msg) {\n // stream those instead of buffering them.\n $body = yield $msg;\n\n // We use the IP as name for this simple chat app.\n $ip = $this->connections[$clientId];\n\n // If someone mentions an IP, we send the message only to clients with that IP and the sender itself.\n if (preg_match(\"~@(\\\\d+\\\\.\\\\d+\\\\.\\\\d+\\\\.\\\\d+)\\\\b~\", $body, $match)) {\n list($all, $receiver) = $match;\n\n $payload = $ip . \" (private): \" . substr($body, \\strlen($all));\n $clients = array_keys($this->ips[$receiver] ?? []);\n\n if (!empty($clients)) {\n $this->endpoint->multicast($payload, $clients);\n }\n\n $this->endpoint->send($payload, $clientId);\n } else {\n $payload = $ip . \": \" . $body;\n $this->endpoint->broadcast($payload);\n }\n }", "function onMessage(ConnectionInterface $from, $msg)\n {\n echo \"Message arrived $msg\\n\";\n foreach($this->clients as $client){\n if($client !== $from){\n $client->send($msg);\n }\n }\n }", "public function newChatMessage($conn, $msg) {\r\n\t\tif(trim($msg->message) == '')return;\r\n\t\t$chatmesssage = '<p><b>'.date('G:i').' '.$msg->user.':</b> '.$msg->message.'</p>';\r\n\t\tfile_put_contents(SUNSHINE_CHAT_FILE,$chatmesssage,FILE_APPEND); //should probably use some fancy file stream here but #yolo\r\n\t\t$this->chat .= $chatmesssage;\r\n\t\t\r\n\t\t//send the message to everyone TODO: only clients who want chat.\r\n\t\t$obj = new \\StdClass;\r\n\t\t$obj->action = \"chat.newChatMessage\";\r\n\t\t$obj->data = $chatmesssage;\r\n\t\tforeach($conn->ms->clients as $client)$client->send(json_encode($obj));\r\n\t}", "function process_message() {\n\t\t$this->_log( 'Received message' );\n\n\t\ttry {\n\t\t\t$message = \\Message::fromRawPostData();\n\t\t\t$validator = new \\MessageValidator();\n\t\t\t$error = '';\n\t\t\tif ( $validator->isValid( $message ) ) {\n\t\t\t\t$topic_arn = $this->_config->get_string( 'cluster.messagebus.sns.topic_arn' );\n\n\t\t\t\tif ( empty( $topic_arn ) || $topic_arn != $message->get( 'TopicArn' ) )\n\t\t\t\t\tthrow new \\Exception ( 'Not my Topic. Request came from ' .\n\t\t\t\t\t\t$message->get( 'TopicArn' ) );\n\n\t\t\t\tif ( $message->get( 'Type' ) == 'SubscriptionConfirmation' )\n\t\t\t\t\t$this->_subscription_confirmation( $message );\n\t\t\t\telseif ( $message->get( 'Type' ) == 'Notification' )\n\t\t\t\t\t$this->_notification( $message->get( 'Message' ) );\n\t\t\t} else {\n\t\t\t\t$this->_log( 'Error processing message it was not valid.' );\n\t\t\t}\n\t\t} catch ( \\Exception $e ) {\n\t\t\t$this->_log( 'Error processing message: ' . $e->getMessage() );\n\t\t}\n\t\t$this->_log( 'Message processed' );\n\t}", "public function onMessage(WebSocketTransportInterface $user, WebSocketMessageInterface $msg) {\n $this->logger->notice(\"Broadcasting \" . strlen($msg->getData()) . \" bytes\");\n\n foreach($this->getConnections() as $client){\n $client->sendString(\"User {$user->getId()} said: \".$msg->getData());\n }\n }", "public function onReceiveMessage($rawMessage)\n {\n Stork::debug(\"Received Message\");\n $message = $this->getMessage($rawMessage);\n if(!$message) {\n Stork::debug(\"Invalid Message\");\n return;\n }\n \n $websocketMessage = $message->getWebsocketMessage();\n if(!$websocketMessage) {\n Stork::debug(\"Invalid Websocket Message\");\n return false;\n }\n\n foreach($message->getTopics() as $topicId) {\n $this->broadcastMessageToTopic($websocketMessage, (string) $topicId);\n }\n }", "abstract function receive($message);", "function onReceive($server, $client_id, $from_id, $data)\n {\n }", "public function onData(int $clientId, Websocket\\Message $msg) {\n // stream those instead of buffering them.\n $body = yield $msg;\n $payload = $body;\n $boardUrl = $this->connections[$clientId];\n $this->addTask($boardUrl, json_decode($body, true));\n $receivers = array_keys($this->boards[$boardUrl]);\n $this->endpoint->send($receivers, $payload);\n }" ]
[ "0.7576303", "0.70052344", "0.67762566", "0.67762566", "0.6676685", "0.6440748", "0.6391005", "0.6342484", "0.6223168", "0.6212243", "0.6170553", "0.61659104", "0.61316633", "0.6061272", "0.6049612", "0.60316855", "0.6000273", "0.59713936", "0.5961922", "0.5952435", "0.59113073", "0.5895872", "0.5894052", "0.58610845", "0.5852078", "0.58328795", "0.57970434", "0.5792814", "0.5756076", "0.5737794" ]
0.857592
0
Resolve the base URL of the service.
public function resolveBaseUrl(): string { return match($this->apiType) { 'search' => 'https://search.bandsintown.com', default => 'https://rest.bandsintown.com', }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private function getBaseUrl() {\n return $this->protocol . '://' . $this->address . '/webapi/';\n }", "abstract function getBaseUrl();", "public function getBaseUrl()\n {\n if (!$this->isValid) {\n return $this->default;\n }\n\n if (NULL !== $this->baseurl) {\n return $this->baseurl;\n }\n\n $this->baseurl = $this->getScheme() . self::SEPARATOR . $this->getHost();\n\n return $this->baseurl;\n }", "public function resolveBaseUrl(): string\n {\n return 'https://slack.com/api/';\n }", "public function getBaseUrl()\n {\n $url = ($this->urlType == 'publicURL') \n ? $this->endpoint->getPublicUrl() \n : $this->endpoint->getPrivateUrl();\n\n if ($url === null) {\n throw new Exceptions\\ServiceException(sprintf(\n\t \t'The base %s could not be found. Perhaps the service '\n\t \t. 'you are using requires a different URL type, or does '\n\t \t. 'not support this region.',\n\t \t$this->urlType\n\t\t ));\n }\n \n return $url;\n }", "public function getFullQualifiedBaseUrl() {\n $routerContext = $this->router->getContext();\n $port = $routerContext->getHttpPort();\n return sprintf('%s://%s%s%s',\n $routerContext->getScheme(),\n $routerContext->getHost(),\n ($port !== 80 ? ':'. $port : ''),\n $routerContext->getBaseUrl()\n );\n }", "public function getBaseUri()\n {\n return $this->getSchemeAndHttpHost() . $this->getBasePath() . '/';\n }", "public static function getBaseURL() {\n return \"http\".(self::getEnv('SERVER_PORT') == 443 ? \"s://\" : \"://\").\n self::getEnv('HTTP_HOST').self::$ini_config['kernel']->getKey('BasePathRouter').'/'.\n explode('_', \\session::get('language'))[0];\n }", "protected function getServiceRootUrl()\n {\n if (!isset($this->serviceRootUrl)) {\n $this->serviceRootUrl = $this->getContext()->getUrl() . ClientContext::$ServicePath;\n }\n return $this->serviceRootUrl;\n }", "private function getBaseUrl() {\n $uri = $this->getRequest()->getUri();\n return sprintf('%s://%s', $uri->getScheme(), $uri->getHost());\n }", "public function getBaseUrl();", "public function getBaseUrl();", "public function getBaseUri() {\n // get the router context to retrieve URI information\n $context = $this->container->get('router')->getContext();\n // return scheme, host and base URL\n return $context->getScheme() . '://' . $context->getHost() . $context->getBaseUrl();\n }", "private function getBaseUrl() {\n $uri = $this->getRequest()->getUri();\n return sprintf('%s://%s', $uri->getScheme(), $uri->getHost());\n }", "public static function guess_base_url() {\n\t\t$base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';\t// protocol\n\t\t$base_url .= preg_replace('%:(80|443)$%', '', $_SERVER['HTTP_HOST']);\t\t\t\t\t\t\t// host[:port]\n\t\t$base_url .= str_replace('\\\\', '/', dirname($_SERVER['SCRIPT_NAME']));\t\t\t\t\t\t\t// path\n\n\t\treturn $base_url;\n\t}", "public function getUrlBase() {\n return 'http'\n . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '')\n . '://'.$_SERVER['SERVER_NAME']\n . ($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '');\n // . $this->getUrlSub();\n }", "private function buildBaseURL(): string\n {\n return $this->service . '/' . $this->version . '/' . $this->profile;\n }", "abstract public static function get_base_url();", "public function getBaseUrl () {\n\t\t$urlParts = $this->getUrlParts();\n\t\t$path = $urlParts['scheme'] . '://' . $urlParts['host'] \n\t\t\t\t. self::LOCAL_BASE_PATH;\n\t\tif ( substr($path, strlen($path) - 2, 1) ) {\n\t\t\t$path .= '/';\n\t\t}\n\t\treturn $path;\n\t}", "public function getBaseUri(): string\n {\n return $this->getServerUri();\n }", "protected function getBaseHttpUrl() {\n return str_replace('https://', 'http://', $this->minkParameters['base_url']);\n }", "public function returnBaseUri() {\n\t\tif (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'\n\t\t\t\t|| $_SERVER['SERVER_PORT'] == 443) {\n\n\t\t\t$protocol = 'https';\n\t\t} else {\n\t\t\t$protocol = 'http';\n\t\t}\n\t\t\n\t\treturn $protocol . '://' . $_SERVER['SERVER_NAME'];\n\t}", "public function getBaseUri() {\n // get the router context to retrieve URI information\n $context = $this->get('router')->getContext();\n // return scheme, host and base URL\n return $context->getScheme() . '://' . $context->getHost() . $context->getBaseUrl() . '/';\n }", "public function getBaseUri() {\n // get the router context to retrieve URI information\n $context = $this->get('router')->getContext();\n // return scheme, host and base URL\n return $context->getScheme() . '://' . $context->getHost() . $context->getBaseUrl() . '/';\n }", "public function getUrlBase()\n { \n return 'http'\n .(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '')\n .'://'.$_SERVER['SERVER_NAME']\n .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '');\n }", "private function getBaseUri(){\n return \"{$this->config['api_url']}/v{$this->config['api_version']}/\";\n }", "protected function getBaseUri(): string\n {\n $baseUri = '';\n\n $routeSuffixPatterns = [\n '(api|widgets|modules|include)\\/.+',\n 'main(\\.get)?\\.php',\n '(?<!administration\\/)authentication\\/.+',\n ];\n if ($this->httpServerBag?->has('REQUEST_URI')) {\n /**\n * @var string\n */\n $requestUri = $this->httpServerBag->get('REQUEST_URI');\n if (preg_match('/^(.+?)\\/?(' . implode('|', $routeSuffixPatterns) . ')/', $requestUri, $matches)) {\n $baseUri = $matches[1];\n }\n }\n\n return rtrim($baseUri, '/');\n }", "public function getBaseUrl()\n {\n return URL::to('/');\n }", "public function getBaseUri();", "function getBaseUrl() {\n\t\tstatic $baseUrl;\n\n\t\tif (!isset($baseUrl)) {\n\t\t\t$serverHost = PKPRequest::getServerHost(null);\n\t\t\tif ($serverHost !== null) {\n\t\t\t\t// Auto-detection worked.\n\t\t\t\t$baseUrl = PKPRequest::getProtocol() . '://' . PKPRequest::getServerHost() . PKPRequest::getBasePath();\n\t\t\t} else {\n\t\t\t\t// Auto-detection didn't work (e.g. this is a command-line call); use configuration param\n\t\t\t\t$baseUrl = Config::getVar('general', 'base_url');\n\t\t\t}\n\t\t\tHookRegistry::call('Request::getBaseUrl', array(&$baseUrl));\n\t\t}\n\n\t\treturn $baseUrl;\n\t}" ]
[ "0.69778645", "0.6894418", "0.68571365", "0.68549365", "0.68095", "0.68000454", "0.6775735", "0.6759157", "0.6752166", "0.6742702", "0.6736128", "0.6736128", "0.670628", "0.6682101", "0.6675213", "0.6669279", "0.6651291", "0.66406125", "0.6639728", "0.66252035", "0.6602591", "0.65525776", "0.65432274", "0.65432274", "0.65418756", "0.65396726", "0.6511278", "0.648417", "0.6466742", "0.64488596" ]
0.7097757
0
Returns the value of firstName
public function firstName() { return $this->firstName; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function firstName()\n {\n return $this->firstName;\n }", "public function getFirstName(): string\n {\n return $this->firstName;\n }", "public function getFirstName()\r\n {\r\n return $this->firstName;\r\n }", "public function getFirstName() {\n return $this->firstName;\n }", "public function getFirstName() {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName()\n\t\t{\n\t\t\treturn($this->firstName);\n\t\t}", "public function getFirstName() {\n\t\treturn $this->firstName;\n\t}", "public function getFirstName()\n\t{\n\t\treturn $this->firstName;\n\t}", "public function getFirstName()\n\t{\n\t\treturn $this->firstName;\n\t}", "public function getFirstName()\n\t\t{\n\t\t\treturn $this->firstName;\n\t\t}", "public function getFirstName() {\r\n\t\treturn $this->first_name;\r\n\t}", "public function getFirstName()\n {\n return $this->FirstName;\n }", "public function getFirstName()\n {\n return $this->firstName;\n }", "public function getFirstName() {\r\n return $this->first_name;\r\n }", "public function getFirstName()\n {\n return $this->first_name;\n }" ]
[ "0.86835265", "0.8609117", "0.85297006", "0.8525855", "0.8525855", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8521588", "0.8512225", "0.84705377", "0.8463568", "0.8463568", "0.8434863", "0.84325373", "0.84255165", "0.84184486", "0.83994174", "0.83760124" ]
0.8686786
0
Returns the value of lastName
public function lastName() { return $this->lastName; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function lastName()\n {\n return $this->lastName;\n }", "public function lastName();", "public function getUserlastName(){\n\t\treturn $this->userLastName;\n \n\t}", "public function getLastName()\r\n {\r\n return $this->lastName;\r\n }", "public function getLastName()\r\n {\r\n return $this->_lastName;\r\n }", "public function getLastName() {\n return $this->lastName;\n }", "public function getLastName() {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName()\n {\n return $this->lastName;\n }", "public function getLastName() {\r\n return $this->last_name;\r\n }", "public function getLastName() {\r\n\t\treturn $this->last_name;\r\n\t}", "public function getLastName()\n\t\t{\n\t\t\treturn($this->lastName);\n\t\t}", "public function getProfileLastName(): string {\n\t\treturn ($this->profileLastName);\n\t}", "public function getLastName()\n {\n return $this->_lastName;\n }", "public function getLastName(){\n return $this->_lastName;\n }", "public function getLastName()\n\t{\n\t\treturn $this->lastName;\n\t}", "public function getLastName()\n\t{\n\t\treturn $this->lastName;\n\t}" ]
[ "0.856048", "0.85291195", "0.8369867", "0.83099806", "0.825193", "0.82418966", "0.82418966", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8240539", "0.8235232", "0.8207616", "0.81763643", "0.81759876", "0.81719196", "0.81716955", "0.8168324", "0.816709", "0.816709" ]
0.85455143
1
Test updating a template.
public function test_update_template() { $cat = $this->getDataGenerator()->create_category(); $this->resetAfterTest(true); $this->setAdminUser(); $syscontext = context_system::instance(); $template = api::create_template((object) array('shortname' => 'testing', 'contextid' => $syscontext->id)); $this->assertEquals('testing', $template->get('shortname')); $this->assertEquals($syscontext->id, $template->get('contextid')); // Simple update. api::update_template((object) array('id' => $template->get('id'), 'shortname' => 'success')); $template = api::read_template($template->get('id')); $this->assertEquals('success', $template->get('shortname')); // Trying to change the context. api::update_template((object) array('id' => $template->get('id'), 'contextid' => context_coursecat::instance($cat->id))); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function updateTemplate(ApiTester $I) : void\n {\n $userData = $I->apiLogin();\n $updatedName = 'Updated Test Name 2';\n\n $I->haveHttpHeader('Authorization', $userData->token);\n $I->sendGet(\"/v1/{$this->model}\");\n\n $I->seeResponseIsSuccessful();\n $response = $I->grabResponse();\n $data = json_decode($response, true);\n\n $I->sendPUT('/v1/' . $this->model . '/' . $data[count($data) - 1]['id'], [\n 'template' => $updatedName\n ]);\n\n $I->seeResponseIsSuccessful();\n $response = $I->grabResponse();\n $data = json_decode($response, true);\n\n $I->assertTrue($data['template'] == $updatedName);\n }", "public function testUpdateObjectTemplate()\n {\n }", "function test_template()\n {\n $t = $this->template;\n $t->setTemplate( 'case1.php' );\n $t->test = 'case1';\n $content = $t->render();\n $this->assertEquals( 'test:case1', $content );\n }", "function test_update_new() {\n\t}", "public function updatetemplateAction()\n {\n $templateid = $this->getRequest()->getPost('templateid');\n $templatename = $this->getRequest()->getPost('templatename');\n $templatebody = $this->getRequest()->getPost('templatebody');\n $this->_getService()->updatetemplateAction($templateid, $templatename, $templatebody);\n $this->_redirect('smsservice/adminhtml/template');\n }", "function test_update_existing() {\n\t}", "public function edit(Template $template)\n {\n //\n }", "public function testUpdateAction()\n {\n $res = $this->controller->updateAction(2);\n $this->assertInstanceOf(\"\\Anax\\Response\\Response\", $res);\n\n $body = $res->getBody();\n $exp = \"<h1>Update a question</h1>\";\n $this->assertContains($exp, $body);\n }", "public function testTemplateEditAccess() {\n $node = Node::create([\n 'title' => 'Test',\n 'type' => 'page',\n 'template' => TRUE,\n 'status' => NodeInterface::PUBLISHED,\n ]);\n\n $node->save();\n\n $this->account->hasPermission('administer content templates', Argument::cetera())\n ->willReturn(TRUE);\n\n $this->assertTrue($node->access('view'));\n $this->assertTrue($node->access('update'));\n $this->assertTrue($node->access('delete'));\n }", "public function testUpdateDeviceTemplate()\n {\n }", "function test_template()\n {\n $t = $this->template;\n $case = __DIR__ . '/templates/case1.php';\n $content = $t->render( $case, array( 'test' => 'case1' ) );\n $this->assertEquals( 'test:case1', $content );\n }", "public function update(TemplateCreate $request, $id) {\n// try {\n\n// $template = $this->repository->findById($id);\n\n// $data = $request->all();\n \n// $template->update($data);\n\n return $this->redirect('templates.index');\n// } catch (ModelNotFoundException $e) {\n// return $this->redirectNotFound();\n// }\n }", "public function testRenderUpdateSuccess()\n {\n // Populate data\n $this->_populate();\n \n // Set data\n $ID = rand(0, 1)+1;\n $user = $this->user->getOne($ID);\n \n // Request\n $this->withSession($this->adminSession)\n ->call('GET', '/user/edit', ['ID' => $ID]);\n \n // Verify\n $this->assertResponseOk();\n $this->assertViewHas('user', $user);\n $this->assertViewHas('types', $this->userTypes);\n }", "public function testTicketPostCanBeUpdated()\n {\n $ticket = factory(Ticket::class)->states('open')->create(['department_id' => 1]);\n $post = factory(TicketPost::class)->create(['ticket_id' => $ticket->id]);\n\n $content = str_random();\n $response = $this->put(route('api.tickets.posts.update', [$ticket, $post]), [\n 'content' => $content,\n ]);\n\n $response->assertSuccessful();\n\n $post = $post->fresh();\n $this->assertEquals($content, $post->content);\n }", "function modifyTemplate($template_data) {\r\n\t\r\n\t\tglobal $CONN, $CONFIG;\r\n\r\n\t\t$name\t \t\t= $template_data['name'];\r\n\t\t$description\t= $template_data['description'];\r\n\t\t$summary_fields\t= $template_data['summary_fields'];\t\t\r\n\t\t$template_key\t= $template_data['template_key'];\r\n\r\n\t\tif ($CONN->Execute(\"UPDATE {$CONFIG['DB_PREFIX']}kb_templates SET name='$name', description='$description', summary_fields='$summary_fields' WHERE template_key='$template_key'\")==true) {\r\n\t\t\r\n\t\t\treturn $this->_kb_strings['template_modified'];\r\n\t\t\r\n\t\t} else {\r\n\t\t\r\n\t\t\t$message = $this->_kb_strings['template_modify_error'].' - '.$CONN->ErrorMsg();\r\n\t\t\treturn $message;\r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t\t\t\r\n\t}", "public function updateTemplate($event_id)\n\t{\n\t}", "public function update($templateId, $data) {\n\t\ttry {\t\t \n\t\t\t$datajson = $this->pest->put('/templates/'.$templateId .'/', $data);\n\t\t\treturn json_decode($datajson,true);\n\t\t}\n\t\tcatch (Exception $e) {\n\t\t\techo \"<br>Caught exception when editing template : \" . $e->getMessage() . \"<br>\";\n\t\t}\n\t}", "public function testUserUpdate(): void\n {\n /** @var User $user */\n $user = User::factory()->create();\n $response = $this\n ->actingAs($user)\n ->call('put', '/users/' . $user->id, [\n 'name' => 'Henk',\n 'email' => '[email protected]',\n 'editor' => 'vim',\n ]);\n $response->assertRedirect('/projects')->assertSessionHas('successes');\n }", "public function testUpdateProjectTest()\n {\n // request to get current project values\n $response = $this->json('GET', 'api/v1/projects/1', [],\n ['HTTP_Authorization' => 'Bearer ' . self::$accessToken]);\n // get responce body\n $content = json_decode($response->getContent());\n\n // request to update the project\n $responseUpdate = $this->json('PUT', 'api/v1/projects/1', \n [\n 'title' => $content->data->title . ' [edited-phpunit]',\n 'description' => $content->data->description,\n ],\n [\n 'HTTP_Authorization' => 'Bearer ' . self::$accessToken\n ]\n );\n // response must be OK\n $responseUpdate->assertStatus(200);\n }", "public function testArticleUpdateSuccess() {\n$article = Article::where('title', 'like', 'Testing Article title')->first();\nif(empty($article)) {\n$data = array(\"title\" => \"Testing Article title\", \"content\" =>\"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do\neiusmod tempor incididunt ut labore et dolore magna aliqua.\", \"writer\"\n=> \"Ujang\");\n$post = $this->action('POST', 'ArticlesController@store', $data);\n}\n$update_data = array(\"title\" => \"Edit Article Testing \" .\nstr_random(10), \"content\" => str_random(10).\"Lorem ipsum dolor sit\namet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut\nlabore et dolore magna aliqua.\", \"author\" => \"Ujang\");\n$this->call('PUT', 'articles/'.$article->first()->id,\n$update_data);\n$this->assertRedirectedTo('articles');\n$this->assertSessionHas('flash');\n}", "public function testBasicUpdate()\n {\n $this->asSuper();\n\n $this->putJson(\"/api/users/0\", [])->assertStatus(404);\n $this->putJson(\"/api/users/bla\", [])->assertStatus(404);\n $this->putJson(\"/api/users/[email protected]\", [])->assertStatus(404);\n\n $user = factory(User::class)->create();\n\n // Test empty endpoint\n $this->putJson(\"/api/users/{$user->id}\", [])->assertStatus(200);\n\n\n\n // Test change each\n $this->putJson(\"/api/users/{$user->name}\", [\n 'name' => 'updated-user'\n ])->assertStatus(200);\n $this->assertDatabaseHas('users',[\n 'id' => $user->id,\n 'name' => 'updated-user',\n 'email' => $user->email,\n ]);\n $this->putJson(\"/api/users/{$user->id}\", [\n 'name' => 'updated-user'\n ])->assertStatus(200);\n\n $this->putJson(\"/api/users/{$user->id}\", [\n 'email' => 'updated-email'\n ])->assertStatus(422);\n $this->putJson(\"/api/users/{$user->id}\", [\n 'email' => '[email protected]'\n ])->assertStatus(200);\n $this->assertDatabaseHas('users',[\n 'id' => $user->id,\n 'name' => 'updated-user',\n 'email' => '[email protected]',\n ]);\n $this->putJson(\"/api/users/{$user->id}\", [\n 'email' => '[email protected]'\n ])->assertStatus(200);\n\n $personA = factory(Person::class)->create();\n $this->putJson(\"/api/users/{$user->id}\", [\n 'person' => $personA->id,\n ])->assertStatus(200);\n $this->assertDatabaseHas('users',[\n 'id' => $user->id,\n 'name' => 'updated-user',\n 'email' => '[email protected]',\n 'person_id' => $personA->id,\n ]);\n\n $this->putJson(\"/api/users/{$user->id}\", [\n 'person' => null,\n ])->assertStatus(200);\n $this->assertDatabaseHas('users',[\n 'id' => $user->id,\n 'name' => 'updated-user',\n 'email' => '[email protected]',\n 'person_id' => null,\n ]);\n\n\n // Test update all\n $personB = factory(Person::class)->create();\n $this->putJson(\"/api/users/{$user->id}\", [\n 'name' => 'updated-user-name2',\n 'email' => '[email protected]',\n 'person' => strval($personB->id),\n ])->assertStatus(200);\n $this->assertDatabaseHas('users',[\n 'id' => $user->id,\n 'name' => 'updated-user-name2',\n 'email' => '[email protected]',\n 'person_id' => $personB->id,\n ]);\n\n\n // Test no duplicates\n $user2 = factory(User::class)->create();\n $this->putJson(\"/api/users/{$user2->id}\", [\n 'name' => 'updated-user-name2',\n ])->assertStatus(422);\n $this->putJson(\"/api/users/{$user2->id}\", [\n 'email' => '[email protected]',\n ])->assertStatus(422);\n }", "public function testRenderUpdateSuccess()\n {\n // Populate data\n $productModelIDs = $this->_populate();\n \n // Set data\n $ID = $this->_pickRandomItem($productModelIDs);\n $productModel = $this->product_model->getOne($ID);\n \n // Request\n $this->withSession($this->adminSession)\n ->call('GET', '/product/model/edit', ['ID' => $ID]);\n \n // Verify\n $this->assertResponseOk();\n $this->assertViewHas('product', $productModel);\n $this->assertViewHas('product_category');\n $this->assertViewHas('product_categories');\n $this->assertViewHas('product');\n\n $this->assertPageContain('Edit Product Model');\n }", "public function testMeetingUpdate()\n {\n }", "public function update(Template $template)\n {\n $this->cache->delete($template->getId());\n $this->load($template);\n }", "public function testUserUpdate()\n {\n $userAdmin = $this->createUserAdmin();\n $user = factory(\\App\\Models\\User::class)->create();\n\n $dataRequest = $this->generateUserData();\n\n $this->actingAs($userAdmin)\n ->put(route('backend.users.update', array('id' => $user->id)), $dataRequest) \n ->assertStatus(302)\n ->assertSessionHasNoErrors()\n ->assertRedirect('/administrativo/usuarios');\n }", "public function testGenericPut() {\r\n\r\n $preference_data = array(\r\n \"items\" => array(\r\n array(\r\n \"title\" => \"test2\",\r\n \"quantity\" => 1,\r\n \"currency_id\" => \"ARS\",\r\n \"unit_price\" => 20.55\r\n )\r\n )\r\n );\r\n\r\n $request = array(\r\n \"uri\" => \"/checkout/preferences\",\r\n \"data\" => $preference_data\r\n );\r\n\r\n $preference = $this->mp->post($request);\r\n\r\n // Start updating\r\n\r\n $preference_data = array(\r\n \"items\" => array(\r\n array(\r\n \"title\" => \"test2Modified\",\r\n \"quantity\" => 2,\r\n \"currency_id\" => \"USD\",\r\n \"unit_price\" => 100\r\n )\r\n )\r\n );\r\n\r\n $request = array(\r\n \"uri\" => \"/checkout/preferences/\".$preference[\"response\"][\"id\"],\r\n \"data\" => $preference_data\r\n );\r\n\r\n $preferenceUpdatedResult = $this->mp->put($request);\r\n\r\n $this->assertTrue($preferenceUpdatedResult[\"status\"] == 200);\r\n\r\n $preferenceUpdatedResult = $this->mp->get_preference($preference[\"response\"][\"id\"]);\r\n\r\n $this->assertTrue((double) $preferenceUpdatedResult[\"response\"][\"items\"][0][\"unit_price\"] == 100\r\n && (double) $preferenceUpdatedResult[\"response\"][\"items\"][0][\"quantity\"] == 2\r\n && $preferenceUpdatedResult[\"response\"][\"items\"][0][\"title\"] == \"test2Modified\"\r\n && $preferenceUpdatedResult[\"response\"][\"items\"][0][\"currency_id\"] == \"USD\");\r\n }", "public function testGetObjectTemplate()\n {\n }", "public function testUpdateRoute()\n {\n print \"\\nTesting update route.\\n\";\n\n $body = [\n 'name' => 'teste',\n 'brand' => 'BUNZL',\n 'type' => 'luva'\n ];\n\n $update = $this\n ->withHeaders(['Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'])\n ->json('PUT', route('api.v1.products.index').\"/21?api_token=kxBDR7b01xC4VNg2o97F5SSs4XCcJyn9y6dxkaYkwF5odjeL9OpQDAMjW7cS\", $body);\n\n $update\n ->assertStatus(200)\n ->assertJsonFragment([\n 'name' => 'teste',\n 'brand' => 'BUNZL',\n 'type' => [\n 'name' => 'luva'\n ]\n ]);\n }", "public function testValidTemplate() {\n $t = new Template('foo-succeed');\n }", "public function update(Request $request, Template $template)\n {\n // Validate form data\n $request->validate([\n 'title' => 'required|string|max:255',\n 'print_title' => 'nullable|string|max:255',\n 'sections_title.*' => 'required|string|max:255',\n /*'question_title.*' => 'required|string|max:255',\n 'type.*' => 'required|string|max:255',\n 'answer.*' => 'nullable|string|max:65535',*/\n ]);\n\n // Find the Template model instance assign form values & save to DB\n $template = Template::find($template->id);\n $template->title = $request->title;\n $template->print_title = (isset($request->print_title)) ? $request->print_title: $request->title;\n $template->is_show_patients_address = (isset($request->is_show_patients_address)) ? true: false;\n $template->is_show_patients_dob = (isset($request->is_show_patients_dob)) ? true: false;\n $template->is_show_patients_nhs_number = (isset($request->is_show_patients_nhs_number)) ? true: false;\n $template->is_show_patients_referral_source = (isset($request->is_show_patients_referral_source)) ? true: false;\n $template->is_show_patients_occupation = (isset($request->is_show_patients_occupation)) ? true: false;\n $template->save();\n\n // Check if there is any section\n if (isset($request->sections_title) && !empty($request->sections_title)) {\n // Loop over each section\n foreach ($request->sections_title as $index => $sectionsTitle) {\n // If existing section then update it otherwise create new\n if (isset($request->section_id[$index])) {\n // Find Section model instance assign form values & save to DB\n $section = Section::find($request->section_id[$index]);\n $section->title = $sectionsTitle;\n $section->save();\n } else {\n // Create a new Section model instance assign form values & save to DB\n $section = new Section();\n $section->title = $sectionsTitle;\n $section->template_id = $template->id;\n $section->save();\n }\n\n // Check if section has question\n if (isset($request->question_title[$index]) && !empty($request->question_title[$index])) {\n // Loop over each question under this section\n foreach ($request->question_title[$index] as $i => $questionTitle) {\n // If existing question then update it otherwise create new\n if (isset($request->question_id[$index][$i])) {\n // Find Question model instance assign form values & save to DB\n $question = Question::find($request->question_id[$index][$i]);\n $question->title = $questionTitle;\n $question->type = $request->type[$index][$i];\n $question->save();\n } else {\n // Create a new Question model instance assign form values & save to DB\n $question = new Question();\n $question->title = $questionTitle;\n $question->type = $request->type[$index][$i];\n $question->section_id = $section->id;\n $question->template_id = $template->id;\n $question->save();\n }\n\n // Check if question has answer\n if (isset($request->answer[$index][$i]) && !empty($request->answer[$index][$i])) {\n // Loop over each answer under this question\n foreach ($request->answer[$index][$i] as $key => $ans) {\n if ($ans) {\n // If existing answer then update it otherwise create new\n if (isset($request->answer_id[$index][$i][$key])) {\n // Find Answer model instance assign form values & save to DB\n $answer = Answer::find($request->answer_id[$index][$i][$key]);\n $answer->answer = $ans;\n $answer->save();\n } else {\n // Create a new Answer model instance assign form values & save to DB\n $answer = new Answer();\n $answer->answer = $ans;\n $answer->question_id = $question->id;\n $answer->section_id = $section->id;\n $answer->template_id = $template->id;\n $answer->save();\n }\n }\n }\n }\n }\n }\n }\n }\n\n return redirect()->back()->with('success', 'Template updated successfully.');\n }" ]
[ "0.78782284", "0.7573967", "0.6951934", "0.69137174", "0.6835739", "0.66659385", "0.6616687", "0.65442777", "0.65330565", "0.6480422", "0.63538694", "0.63347477", "0.63221776", "0.6234262", "0.62139827", "0.61914545", "0.6136337", "0.6117954", "0.607969", "0.60290253", "0.5999782", "0.5994196", "0.5956607", "0.594814", "0.5939922", "0.59393764", "0.5935421", "0.5919292", "0.5910897", "0.5906803" ]
0.7885382
0
Test duplicate a framework.
public function test_duplicate_framework() { $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $this->resetAfterTest(true); $this->setAdminUser(); $syscontext = context_system::instance(); $params = array( 'shortname' => 'shortname_a', 'idnumber' => 'idnumber_c', 'description' => 'description', 'descriptionformat' => FORMAT_HTML, 'visible' => true, 'contextid' => $syscontext->id ); $framework = $lpg->create_framework($params); $competency1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $competency2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $competency3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $competency4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $competency41 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'), 'parentid' => $competency4->get('id')) ); $competency42 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'), 'parentid' => $competency4->get('id')) ); $competencyidnumbers = array($competency1->get('idnumber'), $competency2->get('idnumber'), $competency3->get('idnumber'), $competency4->get('idnumber'), $competency41->get('idnumber'), $competency42->get('idnumber') ); $config = json_encode(array( 'base' => array('points' => 4), 'competencies' => array( array('id' => $competency41->get('id'), 'points' => 3, 'required' => 0), array('id' => $competency42->get('id'), 'points' => 2, 'required' => 1), ) )); $competency4->set('ruletype', 'core_competency\competency_rule_points'); $competency4->set('ruleoutcome', \core_competency\competency::OUTCOME_EVIDENCE); $competency4->set('ruleconfig', $config); $competency4->update(); api::add_related_competency($competency1->get('id'), $competency2->get('id')); api::add_related_competency($competency3->get('id'), $competency4->get('id')); $frameworkduplicated1 = api::duplicate_framework($framework->get('id')); $frameworkduplicated2 = api::duplicate_framework($framework->get('id')); $this->assertEquals($framework->get('idnumber').'_1', $frameworkduplicated1->get('idnumber')); $this->assertEquals($framework->get('idnumber').'_2', $frameworkduplicated2->get('idnumber')); $competenciesfr1 = api::list_competencies(array('competencyframeworkid' => $frameworkduplicated1->get('id'))); $competenciesfr2 = api::list_competencies(array('competencyframeworkid' => $frameworkduplicated2->get('id'))); $competencyidsfr1 = array(); $competencyidsfr2 = array(); foreach ($competenciesfr1 as $cmp) { $competencyidsfr1[] = $cmp->get('idnumber'); } foreach ($competenciesfr2 as $cmp) { $competencyidsfr2[] = $cmp->get('idnumber'); } $this->assertEmpty(array_diff($competencyidsfr1, $competencyidnumbers)); $this->assertEmpty(array_diff($competencyidsfr2, $competencyidnumbers)); $this->assertCount(6, $competenciesfr1); $this->assertCount(6, $competenciesfr2); // Test the related competencies. reset($competenciesfr1); $compduplicated1 = current($competenciesfr1); $relatedcompetencies = $compduplicated1->get_related_competencies(); $comprelated = current($relatedcompetencies); $this->assertEquals($comprelated->get('idnumber'), $competency2->get('idnumber')); // Check if config rule have been ported correctly. $competency4duplicated = competency::get_record(array( 'idnumber' => $competency4->get('idnumber'), 'competencyframeworkid' => $frameworkduplicated2->get('id') )); $configduplicated = json_decode($competency4duplicated->get('ruleconfig'), true); $configorigin = json_decode($config, true); // Check that the 2 config have the same base. $this->assertEquals($configorigin['base'], $configduplicated['base']); $this->assertEquals(count($configorigin['competencies']), count($configduplicated['competencies'])); $competencyidsrules = array(); foreach ($configduplicated['competencies'] as $key => $value) { // Check that the only difference between the 2 config is id competency. $this->assertEquals(1, count(array_diff($value, $configorigin['competencies'][$key]))); $competencyidsrules[] = $value['id']; } $this->assertTrue($competency4duplicated->is_parent_of($competencyidsrules)); // Test duplicate an empty framework. $emptyfrm = $lpg->create_framework(); $emptyfrmduplicated = api::duplicate_framework($emptyfrm->get('id')); $this->assertEquals($emptyfrm->get('idnumber').'_1', $emptyfrmduplicated->get('idnumber')); $nbcomp = api::count_competencies(array('competencyframeworkid' => $emptyfrmduplicated->get('id'))); $this->assertEquals(0, $nbcomp); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private function duplicateSuite()\n\t{\n\t\t// Uses $this->equalSuites() method to test for equality.\n\t}", "public function testDuplicate()\n {\n $bundleThree = new \\Slab\\Tests\\Bundle\\Mocks\\NamespaceCharlie\\Configuration();\n $this->stack->pushBundle($bundleThree);\n }", "public function testCreateDuplicate()\n {\n\n }", "function framework() {\n $this->_runTest(implode('/', func_get_args()), 'framework');\n }", "public function testVersionDuplication(): void {\n $this->drupalLogin($this->rootUser);\n $this\n ->config('devportal_api_reference.settings')\n ->set('allow_version_duplication', TRUE)\n ->save();\n\n $this->drupalGet('node/add/api_reference');\n $this->uploadFile('petstore-openapi.yaml');\n $this->clickSubmit();\n\n $this->assertSession()->pageTextContains('Swagger Petstore');\n $this->assertSession()->pageTextContains('1.0.0');\n\n $this->clickLink('Edit');\n\n $this->uploadFile('petstore-openapi-duplicate.yaml');\n $this->clickSubmit();\n\n $this->assertSession()->pageTextContains('Swagger Petstore');\n $this->assertSession()->pageTextContains('1.0.0');\n $this->assertSession()->pageTextContains('petstore-openapi-duplicate.yaml');\n }", "public function testDuplicate()\n {\n $this->duplicate(\n [\n 'bulletDesignBlockModel' => [\n 'marginTop' => 10,\n 'borderBottomWidth' => 7,\n 'borderColorHover' => 'rgb(0,255,0)',\n 'backgroundColorFromHover' => 'rgba(255,0,255,0.5)',\n ],\n 'hasAutoPlay' => true,\n 'playSpeed' => 10,\n ],\n [\n 'bulletDesignBlockModel' => [\n 'marginTop' => 10,\n 'borderBottomWidth' => 7,\n 'borderColorHover' => 'rgb(0,255,0)',\n 'backgroundColorFromHover' => 'rgba(255,0,255,0.5)',\n ],\n 'hasAutoPlay' => true,\n 'playSpeed' => 10,\n ]\n );\n }", "public function testClone()\n\t{\n\t\t$loader = LoadManager::getInstance();\n\t\ttry {\n\t\t\t$loader2 = clone $loader;\n\t\t\t$this->fail('Did not throw an exception when cloning');\n\t\t} catch (Vcms\\Exception\\SingletonCopy $e) {}\n\t}", "public function testSuppressDuplicate()\n {\n\n }", "public function testBundle()\n {\n new ReplBundle();\n }", "public function testDuplicate()\n {\n $this->duplicate(\n [\n 'originalName' => 'Original_name.jpg',\n 'type' => 'image/jpeg',\n 'size' => 1024000,\n 'uniqueName' => 'akr84ndkro.jpg',\n ],\n [\n 'uniqueName' => ['required']\n ]\n );\n }", "public function testDuplicate()\n {\n $this->duplicate(\n [\n 'catalogInstanceId' => 1,\n 'linkCatalogInstanceId' => 2,\n ],\n [],\n self::EXCEPTION_MODEL\n );\n }", "function duplicate() {\n \n }", "public function testCreateDuplicate()\n {\n $site_name = 'site_name';\n\n $this->sites->expects($this->once())\n ->method('nameIsTaken')\n ->with($this->equalTo($site_name))\n ->willReturn(true);\n\n $this->expectWorkflowProcessing();\n $this->setExpectedException(TerminusException::class, \"The site name $site_name is already taken.\");\n\n $out = $this->command->create($site_name, $site_name, 'upstream');\n $this->assertNull($out);\n }", "public function testPredefinedProfilesClone()\n {\n }", "public function testPingTreeTargetCheckIfDuplicate()\n {\n }", "public function testInstance()\n\t{\n\t\t$loader = LoadManager::getInstance();\n\t\t$this->assertIsA($loader, 'Vcms\\LoadManager');\n\t\t$loader2 = $loader;\n\t\t$this->assertReference(\n\t\t\t$loader,\n\t\t\t$loader2,\n\t\t\t'Copy refrences are different'\n\t\t);\n\t}", "public function CreateFailDuplicateElementManager()\n {\n // Test user login\n $user = ['email' => '[email protected]', 'password' => 'Password!23'];\n $this->browse(function ($browser) use ($user) {\n $browser->visit(new loginPage)\n ->loginUser($user['email'], $user['password'])\n ->assertSee('Welcome');\n\n // Skeletal elements search set up\n $browser->visit(new specimenPage)\n ->pause(1000)\n ->press('@se-menu')\n ->pause(1000)\n ->press('@se-new')\n ->pause(1000)\n\n // New Specimen Assertions\n ->assertPathIs('/skeletalelements/create')\n ->assertSee('New Specimen')\n\n // Validate a duplicate record cannot be created\n ->select('@accession-number', 'UNO 2016-212')\n ->select('@provenance1', 'G-01')\n ->select('@provenance2', 'X-233E')\n ->type('@designator', '401')\n ->select('sb_id','2')\n ->select('side','Left')\n ->select('completeness','Complete')\n ->pause(500)\n ->press('Save')\n ->pause(500)\n ->assertSee('Specimen add unsuccessful Duplicate composite key violation.')\n\n ->logoutUser();\n });\n }", "public function testDeleteDuplicate()\n {\n\n }", "public function testAddPluginReturnsSamePluginWhenAskedTwice()\n {\n $plugin_name = 'Mock';\n $this->handler->addPath(dirname(__FILE__), 'Phergie_Plugin_');\n\n $plugin1 = $this->handler->addPlugin($plugin_name);\n $plugin2 = $this->handler->addPlugin($plugin_name);\n $this->assertSame($plugin1, $plugin2);\n }", "#[@test]\n public function implementation_accessors() {\n $impl= newinstance('util.collections.HashImplementation', array(), '{\n public function hashOf($str) { /* Intentionally empty */ }\n }');\n\n $backup= $this->fixture->getImplementation(); // Backup\n $this->fixture->setImplementation($impl);\n $cmp= $this->fixture->getImplementation();\n $this->fixture->setImplementation($backup); // Restore\n\n $this->assertEquals($impl, $cmp);\n }", "public function testSubmitApplication1()\n {\n }", "public function test_add_existing_item_does_not_duplicate()\n\t{\n\t\t$basket = new Model_Basket;\n\n\t\t$item_1 = $this->get_item();\n\t\t$basket->add_item($item_1);\n\n\t\t$item_2 = $this->get_item();\n\t\t$basket->add_item($item_2);\n\n\t\t$this->assertSame($basket->item_count(), 1);\n\t}", "public function testCloneTemplate() {\n $targetDir = '/tmp/_phpant_template/';\n $Creator = new AppCreator(\".\");\n $Creator->getTemplate($targetDir);\n\n $targetFiles = [];\n $targetFiles[] = $targetDir . 'ant-app-template.php';\n $targetFiles[] = $targetDir . 'autoloader-template.php';\n\n foreach($targetFiles as $target) {\n $this->assertFileExists($target, \"$target is missing, and should have been cloned from the repo.\");\n $this->assertIsReadable($target);\n }\n }", "public function testGetDuplicateCartById()\n {\n }", "public function testPlatformsWithDemo(): void\n {\n $app = $this->porter->importOne(new Import(new ScrapeAppDetails(206190)));\n\n self::assertTrue($app['windows']);\n self::assertTrue($app['mac']);\n self::assertTrue($app['linux']);\n }", "public function testInstance() { }", "public function testCreate()\n\t{\n\t\t\\Simple\\Application::getInstance()['sapi_name'] = 'cli';\n\t\t$request = \\Simple\\RequestFactory::create('Test');\n\t\t$this->assertTrue($request instanceof \\Simple\\Cli\\Request);\n\t\t// alias\n\t\t$request = \\Simple\\RequestFactory::factory('Test');\n\t\t$this->assertTrue($request instanceof \\Simple\\Cli\\Request);\n\n\t\t\\Simple\\Application::getInstance()['sapi_name'] = 'cgi';\n\t\t$request = \\Simple\\RequestFactory::create('Test');\n\t\t$this->assertTrue($request instanceof \\Simple\\Http\\Request);\n\t\t// alias\n\t\t$request = \\Simple\\RequestFactory::factory('Test');\n\t\t$this->assertTrue($request instanceof \\Simple\\Http\\Request);\n\t}", "public function testBuildRegistrationLaunchLink()\n {\n }", "public function testFactory()\n\t{\n\t}", "public function testGetDuplicateZoneById()\n {\n }" ]
[ "0.65815055", "0.6528431", "0.6010439", "0.59228086", "0.58269274", "0.5748038", "0.57094955", "0.5654318", "0.5484585", "0.54564863", "0.54392135", "0.54318404", "0.54219544", "0.53136295", "0.53016317", "0.52955586", "0.5287207", "0.5263287", "0.5250106", "0.52391696", "0.5225006", "0.5223305", "0.5222256", "0.52147686", "0.52118176", "0.51748145", "0.5170678", "0.5152563", "0.5152515", "0.5140455" ]
0.6794344
0
Setup the workflow data (review, active, ...).
protected function setup_workflow_data() { $this->resetAfterTest(); $dg = $this->getDataGenerator(); $user = $dg->create_user(); $reviewer = $dg->create_user(); $otheruser = $dg->create_user(); $syscontext = context_system::instance(); $userrole = $dg->create_role(); $reviewerrole = $dg->create_role(); $otheruserrole = $dg->create_role(); assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $userrole, $syscontext->id); assign_capability('moodle/competency:planmanage', CAP_ALLOW, $reviewerrole, $syscontext->id); assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $reviewerrole, $syscontext->id); $dg->role_assign($userrole, $user->id, $syscontext->id); $dg->role_assign($reviewerrole, $reviewer->id, $syscontext->id); accesslib_clear_all_caches_for_unit_testing(); $lpg = $dg->get_plugin_generator('core_competency'); $tpl = $lpg->create_template(); $plan = $lpg->create_plan(array('userid' => $user->id)); $tplplan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tpl->get('id'))); return array( 'dg' => $dg, 'lpg' => $lpg, 'user' => $user, 'reviewer' => $reviewer, 'otheruser' => $otheruser, 'plan' => $plan, 'tplplan' => $tplplan, ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "protected function _initWorkflow()\n {\n if (is_null($this->_workflow)) {\n\n $this->_workflow = array(\n 'unknown' => array('pending', 'active', 'suspended', 'canceled'),\n 'pending' => array('active', 'canceled'),\n 'active' => array('suspended', 'canceled', 'finished'),\n 'suspended' => array('active', 'canceled'),\n 'canceled' => array(),\n 'expired' => array(),\n 'finished' => array()\n );\n }\n }", "public function __construct()\n {\n $this->initWorkflow();\n }", "public function __construct()\n {\n $this->initWorkflow();\n }", "public function __construct()\n {\n $this->config = config('Workflows');\n $this->jobs = model($this->config->jobModel); // @phpstan-ignore-line\n }", "protected function setup()\n {\n parent::setup();\n\n $db_assignment = $this->get_record();\n\n //TODO throw an exception if no particpant id is set\n\n // set the view's items\n $db_participant = $db_assignment->get_participant();\n $this->set_item( 'uid', $db_participant->uid, true );\n $this->set_item( 'cohort', $db_participant->get_cohort()->name, true );\n $this->set_item( 'user', $db_assignment->get_user()->name, true );\n\n //TODO if the user is a typist, consider not showing the order of tests to process\n try\n {\n $this->test_entry_list->process();\n $this->set_variable( 'test_entry_list', $this->test_entry_list->get_variables() );\n }\n catch( \\cenozo\\exception\\permission $e ) {}\n }", "public function __construct()\n\t{\t\t\n\t\t$this->config = config('Workflows');\n\t\t$this->jobs = model($this->config->jobModel);\n\t}", "public function setupAction()\n {\n $this->questions->setup();\n }", "protected function setUp()\n {\n parent::setUp();\n\n $this->data['createdTime'] = new \\DateTime();\n $this->data['dueDate'] = new \\DateTime();\n $this->data['activeDate'] = new \\DateTime();\n $this->data['completedDate'] = new \\DateTime();\n $this->task = new Task();\n }", "public function setup() {\n\n\t\t$this->setRole(\"authSubmit\");\n\n\t\t$this->setSubNotificationElmAttributes(array(\"src\" => self::$DEFAULT_IMG_SRC, \"class\" => \"sc-main-image\"));\n\n\t\t$this->_subDefaultsStatus = null;\n\t}", "public function setUp() {\n\t\t$this->student = StudentData::getStudent();\n\t\t$this->school = SchoolData::getSchool();\n\t}", "protected function setUp() {\n\t\t// require_once(t3lib_extMgm::extPath('wec_assessment') . 'model/class.tx_wecassessment_question.php');\n\t\trequire_once(t3lib_extMgm::extPath('wec_assessment') . 'model/class.tx_wecassessment_recommendation.php');\n }", "public function setup() {\n \\RightNow\\Libraries\\AbuseDetection::check();\n $objectTypes = $this->input->get('object_types');\n if ($objectTypes && in_array('user', explode(',', $objectTypes))) {\n echo PHP_EOL . \" ========================= Creating social users - Start ========================= \" . PHP_EOL;\n $this->createSocialUsers();\n echo PHP_EOL . \" ========================= Creating social users - End ========================= \" . PHP_EOL;\n if ($objectTypes && in_array('question', explode(',', $objectTypes))) {\n echo PHP_EOL . \" ========================= Creating social questions - Start ========================= \" . PHP_EOL;\n $this->createSocialQuestions();\n echo PHP_EOL . \" ========================= Creating social questions - End ========================= \" . PHP_EOL;\n if ($objectTypes && in_array('comment', explode(',', $objectTypes))) {\n echo PHP_EOL . \" ========================= Creating social comments - Start ========================= \" . PHP_EOL;\n $this->createSocialComments();\n echo PHP_EOL . \" ========================= Creating social comments - End ========================= \" . PHP_EOL;\n }\n }\n }\n }", "public function setup()\n {\n\n $this->crud->setModel(\\Sitebill\\Realty\\app\\Models\\Data::class);\n $this->crud->setRoute(config('sitebill.realty.account_prefix', 'account').'/data');\n $this->crud->setEntityNameStrings('data', 'data');\n $this->setEntityRequest(DataRequest::class);\n $this->defaultSetup();\n\n /*\n |--------------------------------------------------------------------------\n | LIST OPERATION\n |--------------------------------------------------------------------------\n */\n\n\n /*\n |--------------------------------------------------------------------------\n | CREATE & UPDATE OPERATIONS\n |--------------------------------------------------------------------------\n */\n }", "public function setUp(): void\n\t{\n\t\tparent::setUp();\n\n\t\t// Reset some parameters\n\t\t$this->resetLabels();\n\t\t$this->former->framework('TwitterBootstrap');\n\t\t$this->former->horizontal_open()->__toString();\n\t}", "protected function init($data)\n\t{\n\t\t// initialize\n\t\t// read history data\n\t\t// train your parmaters\n\t\t$this->show_status();\n\t}", "public function resetWorkflow()\n {\n $this->setWorkflowState('initial');\n \n $serviceManager = ServiceUtil::getManager();\n $workflowHelper = $serviceManager->get('rk_team_module.workflow_helper');\n \n $schemaName = $workflowHelper->getWorkflowName($this['_objectType']);\n $this['__WORKFLOW__'] = [\n 'module' => 'RKTeamModule',\n 'state' => $this['workflowState'],\n 'obj_table' => $this['_objectType'],\n 'obj_idcolumn' => 'id',\n 'obj_id' => 0,\n 'schemaname' => $schemaName\n ];\n }", "protected function workflowInitialisation() {\n\t\t$deploymentSource = $this->replaceMarkers( $this->workflowConfiguration->getDeploymentSource() );\n\t\t$localDownloadTargetFolder = rtrim($this->replaceMarkers( '/tmp/tracker_###projectname###_###environment###_###releaseversion###' ),'/').'/';\n\t\t$this->addTask('check that we are on correct deploy node',new \\EasyDeployWorkflows\\Tasks\\Common\\CheckCorrectDeployNode());\n\n\t\t$downloadTask = new \\EasyDeployWorkflows\\Tasks\\Common\\Download();\n\t\t$downloadTask->addServerByName('localhost');\n\t\t$downloadTask->setDownloadSource( $deploymentSource );\n\t\t$downloadTask->setTargetFolder( $localDownloadTargetFolder );\n\t\t$this->addTask('Download tracker war to local delivery folder', $downloadTask);\n\n\t\t$deployWarTask = new \\EasyDeployWorkflows\\Tasks\\Servlet\\DeployWarInTomcat();\n\t\t\t//the deployment is running on localhost\n\t\t$deployWarTask->addServersByName(array('localhost'));\n\t\t\t//and deployment to the tomcat host\n\t\t$deployWarTask->setTomcatHostname( $this->workflowConfiguration->getTomcatHostname() );\n\n\t\t$deployWarTask->setWarFileSourcePath( $localDownloadTargetFolder.$this->getFilenameFromPath($deploymentSource) );\n\n\t\t$deployWarTask->setTomcatPassword( $this->workflowConfiguration->getTomcatPassword() );\n\t\t$deployWarTask->setTomcatUser( $this->workflowConfiguration->getTomcatUsername() );\n\t\t$deployWarTask->setTomcatPath( $this->workflowConfiguration->getTargetPath() );\n\t\t$deployWarTask->setTomcatPort( $this->workflowConfiguration->getTomcatPort() );\n\t\t$deployWarTask->setTomcatVersion( $this->workflowConfiguration->getTomcatVersion() );\n\n\t\t$this->addTask('deploy the war file to the tomcat servers',$deployWarTask);\n\n\t\t$deleteWarFolder = new \\EasyDeployWorkflows\\Tasks\\Common\\DeleteFolder();\n\t\t$deleteWarFolder->setFolder($localDownloadTargetFolder);\n\t\t$deleteWarFolder->addServersByName(array('localhost'));\n\n\t\t$this->addTask('removing download folder',$deleteWarFolder);\n\t}", "public function setupData();", "public function setUp()\r\n {\r\n $this->criteria = new CreditScoreCriteria();\r\n\r\n $this->reference = new ReferencingApplication();\r\n $this->decisionDetails = new ReferencingDecisionDetails();\r\n $this->creditReference = new CreditReference();\r\n $this->rrpReference = new RentRecoveryPlusReference();\r\n\r\n $this->rrpReference->setParent($this->reference);\r\n $this->rrpReference->setDecisionDetails($this->decisionDetails);\r\n $this->decisionDetails->setCreditReference($this->creditReference);\r\n }", "public function setup() {\n\n $this->_stepsCount = count( $this->_stepsMap);\n\n // prepare data for controller\n $properties = array();\n\n $properties['_defaultController'] = 'wizard';\n $properties['_defaultTask'] = '';\n $properties['_defaultModel'] = '';\n $properties['_defaultView'] = 'wizard';\n $properties['_defaultLayout'] = 'default';\n\n $properties['_returnController'] = 'default';\n $properties['_returnTask'] = '';\n $properties['_returnView'] = 'default';\n $properties['_returnLayout'] = 'default';\n $properties['_pageTitle'] = JText::_('COM_SH404SEF_IMPORTING_TITLE');\n\n return $properties;\n\n }", "private function initializeInitData() {\n $dataSet = new YamlDataSet(dirname(__FILE__) . '/files/init_data.yml');\n $this->databaseTester = null;\n $this->getDatabaseTester()->setSetUpOperation($this->getSetUpOperation());\n $this->getDatabaseTester()->setDataSet($dataSet);\n $this->getDatabaseTester()->onSetUp();\n }", "public function setup()\n\t{\n\t\t// Load up the settings, set the Kayako URL and initialize the API object.\n\t\t$this->_load_settings();\n\n\t\tglobal $current_user;\n\t\twp_get_current_user();\n\t\tif ($current_user->ID) {\n\t\t\t$this->user = $current_user;\n\t\t}\n\t}", "protected function setUp() {\n $this->object = new WorkVisitDefinitionModel;\n }", "private function init() {\n $this->resetAfterTest(true);\n\n /**\n * Get a new data generator\n */\n $this->datagenerator = $this->getDataGenerator();\n }", "protected function setup() {\n\t\t\n\t}", "public function setUp()\n\t{\n\t\tparent::setUp();\n\t\t\n\t\t$this->_props = array(\n\t\t\t'cm_key' \t\t\t=> '[DateOfBirth]',\n\t\t\t'label'\t\t\t\t=> 'Date of Birth',\n\t\t\t'member_field_id' \t=> 'm_field_id_10'\n\t\t);\n\t}", "private function setup()\n {\n $this->runner = $this->specHelper->getRunner();\n\n $this->setupWorkspace();\n $this->setupTargets();\n\n // call initializers\n foreach ($this->application->config('spec.initializers.*') as $initializer) {\n $initializer($this->application);\n }\n }", "public function setup()\n {\n $this->totalSteps = 1;\n }", "Public static function setup() {\n\t\tself::$data = require PPAC_ROOT . \"config.php\";\n\t}", "protected function setUp(): void\n\t{\n\t\tglobal $txt;\n\t\t// Load in the common items so the system thinks we have an active login\n\t\tparent::setUp();\n\t\tparent::setSession();\n\n\t\tnew ElkArte\\Themes\\ThemeLoader();\n\t\t$lang = new Loader('english', $txt, database());\n\t\t$lang->load('Manual+Help');\n\t}" ]
[ "0.72236013", "0.64827555", "0.64827555", "0.6231503", "0.622101", "0.61244524", "0.6061042", "0.60026956", "0.59907025", "0.5936253", "0.5931709", "0.58929247", "0.588657", "0.57815516", "0.57756317", "0.5731808", "0.57118136", "0.56631947", "0.5645115", "0.56326693", "0.56197727", "0.5617705", "0.5609824", "0.5609278", "0.5598419", "0.5593244", "0.5587382", "0.55758804", "0.55713946", "0.5563172" ]
0.68672127
1
Testing requesting the review of a plan.
public function test_plan_request_review() { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; $user = $data['user']; $reviewer = $data['reviewer']; $otheruser = $data['otheruser']; $plan = $data['plan']; $tplplan = $data['tplplan']; $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status')); $this->assertEquals(plan::STATUS_DRAFT, $tplplan->get('status')); // Foreign user cannot do anything. $this->setUser($otheruser); try { api::plan_request_review($plan); $this->fail('The user can not read the plan.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Can not change a plan based on a template. $this->setUser($user); try { api::plan_request_review($tplplan); $this->fail('The plan is based on a template.'); } catch (coding_exception $e) { $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage()); } // Can not send for review when not draft. $this->setUser($user); $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); try { api::plan_request_review($plan); $this->fail('The plan cannot be sent for review at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage()); } // Can not send for review when not draft. $this->setUser($user); $plan->set('status', plan::STATUS_ACTIVE); try { api::plan_request_review($plan); $this->fail('The plan cannot be sent for review at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage()); } // Can not send for review when not draft. $this->setUser($user); $plan->set('status', plan::STATUS_IN_REVIEW); try { api::plan_request_review($plan); $this->fail('The plan cannot be sent for review at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage()); } // Can not send for review when not draft. $this->setUser($user); $plan->set('status', plan::STATUS_COMPLETE); try { api::plan_request_review($plan); $this->fail('The plan cannot be sent for review at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage()); } // Sending for review as a reviewer. $this->setUser($reviewer); $plan->set('status', plan::STATUS_DRAFT); try { api::plan_request_review($plan); $this->fail('The user can not request a review.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Sending for review. $this->setUser($user); api::plan_request_review($plan); $plan->read(); $this->assertEquals(plan::STATUS_WAITING_FOR_REVIEW, $plan->get('status')); // Sending for review by ID. $plan->set('status', plan::STATUS_DRAFT); $plan->update(); api::plan_request_review($plan->get('id')); $plan->read(); $this->assertEquals(plan::STATUS_WAITING_FOR_REVIEW, $plan->get('status')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_plan_start_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_start_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_start_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Starting as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_start_review($plan);\n $this->fail('The user can not start a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Starting review.\n $this->setUser($reviewer);\n api::plan_start_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status'));\n $this->assertEquals($reviewer->id, $plan->get('reviewerid'));\n\n // Starting review by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->set('reviewerid', null);\n $plan->update();\n api::plan_start_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status'));\n $this->assertEquals($reviewer->id, $plan->get('reviewerid'));\n }", "public function test_approve_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::approve_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are already approved./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Approve as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not approve the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Approve plan from in review.\n $this->setUser($reviewer);\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::approve_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from draft.\n $plan->set('status', plan::STATUS_DRAFT);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from waiting for review.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n }", "public function test_plan_cancel_review_request() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($user);\n try {\n api::plan_cancel_review_request($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Cancelling as a reviewer.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not cancel a review request.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Cancelling review request.\n $this->setUser($user);\n api::plan_cancel_review_request($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Cancelling review request by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::plan_cancel_review_request($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function test_plan_stop_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_stop_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Stopping as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not stop a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Stopping review.\n $this->setUser($reviewer);\n api::plan_stop_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Stopping review by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::plan_stop_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function test_unapprove_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_ACTIVE);\n $tplplan->update();\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::unapprove_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are always approved./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Unapprove as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not unapprove the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Unapprove plan.\n $this->setUser($reviewer);\n api::unapprove_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Unapprove plan by ID.\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n api::unapprove_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function test_create_paid_access_plan() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 10,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Now test that if the frequency is 0 (default) and we enable the trial, the trial is still disabled.\n\t\t$sample_args['trial_enabled'] = true;\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t\t'frequency' => 0,\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Test that a frequency > 0 unlocks trials.\n\t\t$sample_args['frequency'] = 1;\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$this->assertTrue(\n\t\t\tllms_parse_bool(\n\t\t\t\t( new LLMS_Access_Plan( $response->get_data()['id'] ) )->get( 'trial_offer' )\n\t\t\t)\n\t\t);\n\t}", "public function test_create_and_get_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t$create_response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$access_plan = $create_response->get_data();\n\n\t\t// Success.\n\t\t$this->assertResponseStatusEquals( 201, $create_response );\n\n\t\t// Get the access plan.\n\t\t$get_response = $this->perform_mock_request(\n\t\t\t'GET',\n\t\t\ttrailingslashit( $this->route ) . $access_plan['id'],\n\t\t\tarray(),\n\t\t\tarray( 'context' => 'edit' )\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 200, $get_response );\n\t\t$this->assertEquals( $access_plan, $get_response->get_data() );\n\n\t\t$this->assertEqualSets( $this->schema_properties, array_keys( $get_response->get_data() ) );\n\n\t}", "public function test_access_plan_limit() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\tforeach ( array( 'course', 'llms_membership' ) as $pt ) {\n\n\t\t\t// Create 5 access plans, by default the limit is 6 per product.\n\t\t\t$access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) );\n\n\t\t\t$product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\n\t\t\tforeach ( $access_plan_ids as $access_plan_id ) {\n\t\t\t\tupdate_post_meta( $access_plan_id, '_llms_product_id', $product );\n\t\t\t}\n\n\t\t\t// Create an ap through api with same product id.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t\t$sixth_ap = $response->get_data()['id'];\n\t\t\t// The 6th passes.\n\t\t\t$this->assertResponseStatusEquals( 201, $response, $pt );\n\n\t\t\t// Create the 7th ap.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\n\t\t\t// Update the 6th.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $sixth_ap,\n\t\t\t\tarray(\n\t\t\t\t\t'title' => 'Updated',\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Update passes.\n\t\t\t$this->assertResponseStatusEquals( 200, $response, $pt );\n\n\t\t\t// Create an ap linked to a different product.\n\t\t\t$access_plan = $this->factory->post->create( array( 'post_type' => $this->post_type ) );\n\t\t\t$new_product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\t\t\tupdate_post_meta( $access_plan, '_llms_product_id', $new_product );\n\n\t\t\t// Update its post_id so that it becomes the 7th ap of the first product.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $access_plan,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\t\t}\n\t}", "public function test_create_free_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$free_props = array(\n\t\t\t'is_free' => 'yes',\n\t\t\t'price' => 0,\n\t\t\t'frequency' => 0,\n\t\t\t'on_sale' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Check again, that even the passed properties are \"reset\".\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t\t'frequency' => 6,\n\t\t\t\t'sale_enabled' => true,\n\t\t\t\t'trial_enabled' => true,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t}", "public function test_altering_access_plan_allowed_to_who_can_edit_parent_post() {\n\n\t\t$instructor = $this->factory->user->create(\n\t\t\tarray( 'role' => 'instructor' )\n\t\t);\n\t\t$assistant = $this->factory->user->create(\n\t\t\tarray( 'role' => 'instructors_assistant' )\n\t\t);\n\t\t$course = $this->factory->course->create_and_get();\n\n\t\t// Assign the instructors to the course.\n\t\t$course->set_instructors(\n\t\t\tarray(\n\t\t\t\tarray(\n\t\t\t\t\t'id' => $instructor\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'id' => $assistant\n\t\t\t\t),\n\t\t\t)\n\t\t);\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Instructors of the Course with post_id can manipulate.\n\t\twp_set_current_user( $instructor );\n\n\t\t// Creation is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 201, $response );\n\t\t$new_plan_id = $response->get_data()['id'];\n\n\t\t// Update is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $new_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Title can change',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\n\t\t// Deletion is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'DELETE',\n\t\t\t$this->route . '/' . $new_plan_id\n\t\t);\n\t\t$this->assertResponseStatusEquals( 204, $response );\n\n\t\t// Check the same happens with intructors assistants\n\n\t\t// Instructor's Assistant of the Course with post_id can manipulate.\n\t\twp_set_current_user( $assistant );\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Creation is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 201, $response );\n\t\t$new_plan_id = $response->get_data()['id'];\n\n\t\t// Update is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $new_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Title can change',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\n\t\t// Deletion is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'DELETE',\n\t\t\t$this->route . '/' . $new_plan_id\n\t\t);\n\t\t$this->assertResponseStatusEquals( 204, $response );\n\n\t}", "public function test_update_free_access_plan() {\n\t\t// Create free access plan.\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$access_plan_id = $response->get_data()['id'];\n\n\t\t// Update the title.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $access_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Updated Title',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$ap = new LLMS_Access_Plan( $access_plan_id );\n\t\t$this->assertEquals( $ap->get('title'), 'Updated Title' );\n\n\t}", "public function test_create_access_plan_bad_request() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Creating an access plan passing an id produces a bad request.\n\t\t$sample_args['id'] = '123';\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Bad request.\n\t\t$this->assertResponseStatusEquals( 400, $response );\n\t\t$this->assertResponseMessageEquals( 'Cannot create existing Access Plans.', $response );\n\n\t\tunset( $sample_args['id'] );\n\n\t\t// Create an access plan without title.\n\t\tunset( $sample_args['title'] );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Bad request.\n\t\t$this->assertResponseStatusEquals( 400, $response );\n\t\t$this->assertResponseMessageEquals( 'Missing parameter(s): title', $response );\n\n\t\t$sample_args['title'] = $this->sample_access_plan_args['title'];\n\n\t\t// Create an access plan without price.\n\t\tunset( $sample_args['price'] );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Bad request.\n\t\t$this->assertResponseStatusEquals( 400, $response );\n\t\t$this->assertResponseMessageEquals( 'Missing parameter(s): price', $response );\n\n\n\t\t// Create an access plan without post_id.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$this->sample_access_plan_args\n\t\t);\n\n\t\t// Bad request.\n\t\t$this->assertResponseStatusEquals( 400, $response );\n\t\t$this->assertResponseMessageEquals( 'Missing parameter(s): post_id', $response );\n\n\t}", "public function testReviewFind()\n {\n\n }", "public function test_customer_can_view_a_rentRequest()\n {\n // Given authorized user\n $customer = factory(User::class)->create();\n Passport::actingAs($customer);\n\n $owner = User::first();\n $listing = $owner->listings()->first();\n\n\n $today = Carbon::today();\n\n // and valid new rentRequest\n $res = $this->json('POST', 'api/rentRequests', [\n 'listing_id' => $listing->id,\n 'days' => json_encode([$today->addDays(1)->format('d-m-Y'), $today->addDays(1)->format('d-m-Y')]),\n ], ['Accept' => 'application/json', 'Content-type' => 'application/json']);\n\n // when customer try to see the made request\n $res = $this->json('GET', 'api/rentRequests/' . json_decode($res->getContent())->data->id,\n [],\n ['Accept' => 'application/json', 'Content-type' => 'application/json']);\n\n $res->assertJsonStructure([\n 'data' => [\n 'id',\n 'customer_id',\n 'listing_id',\n 'days',\n 'cost',\n 'status'\n ]\n ]);\n\n }", "public function testReviewCreate()\n {\n\n }", "public function test_get_rate()\n {\n $travelers = [];\n array_push($travelers, array(\"TravelerDOB\" => \"02/14/1990\", \"TravelCost\" => \"300\"));\n array_push($travelers, array(\"TravelerDOB\" => \"02/14/1990\", \"TravelCost\" => \"300\"));\n\n $data = [\"departuredate\" => \"10/16/2018\",\n \"returndate\" => \"2/20/2019\",\n \"destinationcountry\" => \"France\",\n \"planname\" => \"Renter's Collision\",\n \"statecode\" => \"CA\",\n ];\n\n $solartis = new \\App\\Solartis\\API;\n $data['plancode'] = $solartis->plan_code($data['planname']);\n $res = $solartis->get_rating($data, $travelers);\n $this->assertEquals($res['RequestStatus'], \"SUCCESS\");\n $this->assertEquals($res['PremiumInformation']['PlanName'], $data['planname']);\n assert(array_key_exists('TotalGrossPremium', $res['PremiumInformation']));\n }", "abstract protected function get_paid_plan_for_api();", "public function test_create_access_plan_forbidden() {\n\t\twp_set_current_user( $this->user_forbidden );\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $this->factory->course->create(),\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Forbidden.\n\t\t$this->assertResponseStatusEquals( 403, $response );\n\n\t\t// Check that a generic instructor can't create an access plan.\n\t\twp_set_current_user( $this->factory->user->create( array( 'role' => 'instructor' ) ) );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t}", "public function test_update_non_existent_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/12569',\n\t\t\t$this->sample_access_plan_args\n\t\t);\n\n\t\t// Not found.\n\t\t$this->assertResponseStatusEquals( 404, $response );\n\n\t}", "public function test_create_access_plan_without_permissions() {\n\t\twp_set_current_user( 0 );\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $this->factory->course->create(),\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Unauthorized.\n\t\t$this->assertResponseStatusEquals( 401, $response );\n\n\t}", "function verifyPlan($plan, $clientId) {\n\t\tif (!$plan || ($plan->client_id != $clientId)) {\n\t\t\t$data = array(\n\t\t\t\t'template' => platform() . '/my/permission_denied'\n\t\t\t);\n\t\t\t$this->load->view(platform() . '/page', $data);\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}", "public function canReviewPayment()\n {\n }", "public function testReviewCount()\n {\n\n }", "public function createAReview()\n {\n }", "public function testViewer()\n {\n\n $user = User::viewers()->first();\n\n $response = $this->actingAs($user)->get(route(\"home\"));\n \n $response->assertSee(\"<h3>\" . __(\"Questionnaire compilations\") . \"</h3>\");\n $response->assertSeeText(__(\"Compilation form\"));\n $response->assertDontSeeText(__(\"New compilation\"));\n $response->assertSeeText(__(\"All compilations\"));\n $response->assertDontSeeText(__(\"My compilations\"));\n $response->assertSeeText(__(\"Statistics\"));\n\n $response->assertSee(\"<h3>\" . __(\"Stages\") . \"</h3>\");\n $response->assertSeeText(__(\"Locations\"));\n $response->assertSeeText(__(\"Wards\"));\n\n $response->assertSee(\"<h3>\" . __(\"Users\") . \"</h3>\");\n $response->assertDontSeeText(__(\"Register new viewer or administrator\"));\n $response->assertSee(__(\"Register new viewer\") . \"</a>\");\n $response->assertDontSeeText(__(\"Administrators\"));\n $response->assertSeeText(__(\"Viewers\"));\n $response->assertSeeText(__(\"Students\"));\n\n }", "public function review()\n {\n return true;\n }", "public function testAddProductionPlan() {\n $model = new ProductionPlanModel();\n $payload = array('month' => '06', 'skis' => array('1' => 50, '2' => 100));\n\n $model->addProductionPlan($payload);\n $this->tester->seeInDatabase('production_plan', ['month' => '2021-06-01']);\n $this->tester->seeNumRecords(2, 'production_skis', ['production_plan_id' => 2]);\n $this->tester->seeNumRecords(2, 'production_skis', ['ski_type_id' => 2]);\n $this->tester->seeNumRecords(2, 'production_skis', ['ski_type_id' => 1]);\n }", "public function AssistantFormTest()\n {\n\n $response = $this->json('POST','/formAux', ['p1' => '1','p2' => '1','p3' => '1','p4' => '1','p5' => '1','comment' => 'pruebaunitaria','id_user_evaluator' => '1','id_user_evaluated' => '1','id_course' => '1']);\n $this->assertDatabaseHas('reviews', ['comment' => 'pruebaunitaria']);\n }", "public function testReviewFindOne()\n {\n\n }", "public function testReviewFindById()\n {\n\n }" ]
[ "0.7680038", "0.74915516", "0.7435039", "0.6822688", "0.66322905", "0.6530397", "0.6514882", "0.6482915", "0.64630765", "0.64611965", "0.64114", "0.631501", "0.61199576", "0.6079685", "0.60569686", "0.60032386", "0.59673816", "0.5951567", "0.59339905", "0.5932865", "0.59208226", "0.58694154", "0.58634496", "0.58441585", "0.5806737", "0.5800104", "0.5799836", "0.5784703", "0.5781487", "0.57340616" ]
0.84183025
0
Testing cancelling the review request.
public function test_plan_cancel_review_request() { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; $user = $data['user']; $reviewer = $data['reviewer']; $otheruser = $data['otheruser']; $plan = $data['plan']; $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $tplplan->update(); $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $plan->update(); // Foreign user cannot do anything. $this->setUser($otheruser); try { api::plan_cancel_review_request($plan); $this->fail('The user can not read the plan.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Can not change a plan based on a template. $this->setUser($user); try { api::plan_cancel_review_request($tplplan); $this->fail('The plan is based on a template.'); } catch (coding_exception $e) { $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage()); } // Can not cancel review request when not waiting for review. $this->setUser($user); $plan->set('status', plan::STATUS_DRAFT); try { api::plan_cancel_review_request($plan); $this->fail('The plan cannot be sent for review at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage()); } // Can not cancel review request when not waiting for review. $this->setUser($user); $plan->set('status', plan::STATUS_IN_REVIEW); try { api::plan_cancel_review_request($plan); $this->fail('The plan review cannot be cancelled at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage()); } // Can not cancel review request when not waiting for review. $this->setUser($user); $plan->set('status', plan::STATUS_ACTIVE); try { api::plan_cancel_review_request($plan); $this->fail('The plan review cannot be cancelled at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage()); } // Can not cancel review request when not waiting for review. $this->setUser($user); $plan->set('status', plan::STATUS_COMPLETE); try { api::plan_cancel_review_request($plan); $this->fail('The plan review cannot be cancelled at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage()); } // Cancelling as a reviewer. $this->setUser($reviewer); $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); try { api::plan_cancel_review_request($plan); $this->fail('The user can not cancel a review request.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Cancelling review request. $this->setUser($user); api::plan_cancel_review_request($plan); $plan->read(); $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status')); // Cancelling review request by ID. $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $plan->update(); api::plan_cancel_review_request($plan->get('id')); $plan->read(); $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function testCancelSettleLater()\n {\n }", "public function test_plan_stop_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_stop_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Stopping as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not stop a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Stopping review.\n $this->setUser($reviewer);\n api::plan_stop_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Stopping review by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::plan_stop_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function cancel() {\n\t\techo \"Cancel request\\n\";\n\t\t$this->_cancel = true;\n\t}", "public function cancelRequest(Request $request): void;", "public function cancel()\n\t{\n\t}", "function cancel_test()\n\t{\n\t\techo 'cancelled';\n\t}", "function appthemes_cancel_review( $id, $trash = false ) {\n\t$review = appthemes_get_review( $id );\n\treturn $review->cancel( $trash );\n}", "function cancel(array $requestParams)\n {\n }", "public function testCancelAllDunningPending()\n {\n }", "private function _cancel_action(){\n $r_stat = (new Remover($this->_project_id, $this->_user_id))->innocentlyRemove();\n if($r_stat === Remover::R_DELETE_INPUT){ // Reverted\n $this->_log(\"Reverted back to the previous result.\", Logger::GREEN);\n }else{ // Couldn't revert back\n $this->_log(\"The project files are deleted.\", Logger::RED);\n }\n }", "public function testCancelForOrderWithFailedRequest()\n {\n $this->withCaseEntity();\n\n $this->gateway->expects(self::once())\n ->method('cancelGuarantee')\n ->with(self::equalTo(self::$caseId))\n ->willThrowException(new GatewayException('Something wrong.'));\n\n $this->logger->expects(self::once())\n ->method('error')\n ->with(self::equalTo('Something wrong.'));\n\n $this->updatingFactory->expects(self::never())\n ->method('create');\n\n $result = $this->service->cancelForOrder(self::$orderId);\n self::assertFalse($result);\n }", "public function cancel()\n {\n $this->_cancel = true;\n }", "public function cancelWithoutChecks(): void {\n\t\t$this->cancelled = true;\n\t}", "function cancel()\r\n\t{\r\n\t\t$msg = JText::_( 'OPERATION_CANCELLED' );\r\n\t\t$this->setRedirect( 'index.php?option=com_suggestvotecommentbribe', $msg );\r\n\t}", "public function cancelRequest( Request $request ){\n try{\n $companyUser = $request->user();\n if(!$companyUser || !$companyUser->hasRole('company'))\n throw new Exception(\"You need to logged in as company\");\n if( !$request->input('solder_request_id'))\n throw new Exception(\"Must be need request ID\");\n $currentRequest = SolderItemRequest::find( $request->input('solder_request_id'));\n if( !$currentRequest )\n throw new Exception(\"Sorry didn't find your request data\");\n $currentRequest->status = 3;\n $currentRequest->save();\n $actionItem = SolderKits::find( $currentRequest->solder_kit_id );\n $actionItem->status = 3; // cancel and re-usable\n $actionItem->save();\n $actionItem->soldier_device_id = User::find($actionItem->user_id)->device_id;\n\n return ['success'=>true ,'message'=>'Item request cancel!', 'data'=>$actionItem];\n }catch (Exception $e){\n return ['success'=>false, 'message'=>$e->getMessage()];\n }\n }", "public function cancelAction()\n {\n $helper = Mage::helper('innobyte_payu_lite');\n try {\n $order = Mage::getModel('sales/order')\n ->loadByIncrementId($this->_getCheckout()->getData('payulite_order_increment_id'));\n if ($order->getIncrementId() !== $this->getRequest()->getParam('order', '')) {\n Mage::throwException(Mage::helper('innobyte_payu_lite')->__('Invalid order.'));\n }\n $this->_getCheckout()->unsetData('payulite_order_increment_id');\n $quote = Mage::getModel('sales/quote')->load($order->getQuoteId());\n \n /* cancel order */\n $order->cancel();\n $order->getStatusHistoryCollection()->getLastItem()->setComment($helper->__('Payment timeout.'));\n $order->save();\n \n /* reactivate quote */\n if ($quote->getId()) {\n $quote->setIsActive(true)->save();\n $this->_getCheckout()->setQuoteId($quote->getId());\n }\n /* debug error */\n $order->getPayment()->getMethodInstance()->debugData(\n 'Payment timeout expired for order \"' . $order->getIncrementId() . '\" in ' . __METHOD__\n );\n Mage::throwException($helper->__('Payment failed. The order has been canceled.'));\n } catch (Mage_Core_Exception $e) {\n $this->_getCheckout()->addError($e->getMessage());\n } catch (Exception $e) {\n $this->_getCheckout()->addError($helper->__('An error occurred. Please try again later.'));\n Mage::logException($e);\n }\n $this->_redirect('checkout/cart', array('_secure' => true));\n }", "public function testPostingAPICancelFbsPosting()\n {\n\n }", "public function cancel() {\n\t\t$this->state->status = WorkflowState::STATUS_CANCELLED;\n\t\t$this->state->save();\n\t}", "public function testCancelForOrder()\n {\n $case = $this->withCaseEntity();\n\n $this->gateway->expects(self::once())\n ->method('cancelGuarantee')\n ->with(self::equalTo(self::$caseId))\n ->willReturn(CaseInterface::GUARANTEE_CANCELED);\n\n $this->logger->expects(self::never())\n ->method('error');\n\n $service = $this->getMockBuilder(StubUpdatingService::class)\n ->setMethods(['update'])\n ->getMock();\n $this->updatingFactory->expects(self::once())\n ->method('create')\n ->willReturn($service);\n\n $service->expects(self::once())\n ->method('update')\n ->with(self::equalTo($case), self::equalTo(['guaranteeDisposition' => CaseInterface::GUARANTEE_CANCELED]));\n\n $result = $this->service->cancelForOrder(self::$orderId);\n self::assertTrue($result);\n }", "public function cancel( $id );", "public function cancel()\n {\n $this->resetInput();\n $this->updateMode = false;\n }", "public function handle_cancel_request() {\n $cancel = optional_param('cancel', 0, PARAM_BOOL);\n if ($cancel) {\n // Redirect to frontpage, needed for loginhttps\n redirect(new moodle_url('/'));\n }\n }", "public function testCancelInvoice()\n {\n }", "public function cancelSpotInstanceRequests($request);", "public function cancel()\r\n {\r\n if( is_null( $this->getOrderId() ) || is_null( $this->getId() ) ) return false;\r\n\r\n $this->_type = 'POST';\r\n $uri = $this->restAdminUri() . 'orders' .\r\n DIRECTORY_SEPARATOR . $this->getOrderId() .\r\n DIRECTORY_SEPARATOR . 'fulfillments' .\r\n DIRECTORY_SEPARATOR . $this->getId() .\r\n DIRECTORY_SEPARATOR . 'cancel.json';\r\nAssist::consoleLog( $uri ) ; \r\n return $this->request( $uri ) ;\r\n\r\n }", "public function testPostingAPICancelFbsPostingProduct()\n {\n\n }", "public function cancelRequestAction()\n {\n \t$params = $this->getRequest()->getParams();\n \t\n \t$flag1 = false;\n \tif( isset($params[\"type\"]) && $params[\"type\"] == \"request\" )\n \t{\n \t\t$flag1 = true;\n \t}\n \t\n \t$result = \\Extended\\link_requests::unlinkUsersByLinkReqId( $params[\"cancel_request\"], $flag1 );\n \t\n \tswitch ( $result ) \n \t{\n \t\tcase 0:\n \t\tcase 1:\n \t\tcase 2:\n \t\t\techo Zend_Json::encode( $result );\n \t\tbreak;\n \t\tcase 3:\n\t\t\t\tif( $params[\"profileID\"] )\n\t\t\t\t{\t\n\t\t\t\t\t$currentUser = Auth_UserAdapter::getIdentity()->getId();\n\t\t\t\t\t$TagsExist=\\Extended\\link_tags::getAssignedTags($currentUser, $params[\"profileID\"] );\n\t\t\t\t\t$tagsarr=array();\n\t\t\t\t\t$removeLinks=\\Extended\\link_tags::removeAllTags($currentUser,$params[\"profileID\"],$tagsarr);\n\t\t\t\t\t\\Extended\\socialise_photo_custom_privacy::deleteViewerfromCustomViewersList($currentUser, $params['profileID']);\n\t\t\t\t}\n\t\t\t\techo Zend_Json::encode( $result );\n \t\tbreak;\n \t\t\n \t\tdefault:\n \t\t\techo Zend_Json::encode( $result );\n \t\tbreak;\n \t}\n \tdie;\n }", "function cancel()\n {\n $data = false;\n if ($this->Session->check('Support.id')) {\n $id = $this->Session->read('Support.id');\n $data = $this->EasySupport->cancel($id);\n $this->Session->delete('Support.id');\n }\n $this->set('data', $data);\n }", "public function cancelPayment() {\n $body = $this->request->all(); \n $res = $this->client()->request('POST', '100005/10', \n ['json' => $body]);\n\n $resBody = json_decode($res->getBody());\n \n return response()->json($resBody);\n }", "public function testCancelTransaction()\n {\n }" ]
[ "0.68138427", "0.67507213", "0.66837287", "0.66250795", "0.6461616", "0.64544797", "0.6436522", "0.6422637", "0.63670874", "0.62856114", "0.62443227", "0.62395585", "0.61933595", "0.6164562", "0.6161907", "0.6133411", "0.60837865", "0.6072425", "0.6061959", "0.6038838", "0.6033015", "0.59960055", "0.59890324", "0.59805405", "0.5973736", "0.595324", "0.5945739", "0.59418505", "0.5913919", "0.5894016" ]
0.7688021
0
Testing starting the review.
public function test_plan_start_review() { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; $user = $data['user']; $reviewer = $data['reviewer']; $otheruser = $data['otheruser']; $plan = $data['plan']; $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $tplplan->update(); $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $plan->update(); // Foreign user cannot do anything. $this->setUser($otheruser); try { api::plan_start_review($plan); $this->fail('The user can not read the plan.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Can not change a plan based on a template. $this->setUser($reviewer); try { api::plan_start_review($tplplan); $this->fail('The plan is based on a template.'); } catch (coding_exception $e) { $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage()); } // Can not start a review when not waiting for review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_DRAFT); try { api::plan_start_review($plan); $this->fail('The plan review cannot be started at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage()); } // Can not start a review when not waiting for review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_IN_REVIEW); try { api::plan_start_review($plan); $this->fail('The plan review cannot be started at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage()); } // Can not start a review when not waiting for review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_ACTIVE); try { api::plan_start_review($plan); $this->fail('The plan review cannot be started at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage()); } // Can not start a review when not waiting for review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_COMPLETE); try { api::plan_start_review($plan); $this->fail('The plan review cannot be started at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage()); } // Starting as the owner. $this->setUser($user); $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); try { api::plan_start_review($plan); $this->fail('The user can not start a review.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Starting review. $this->setUser($reviewer); api::plan_start_review($plan); $plan->read(); $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status')); $this->assertEquals($reviewer->id, $plan->get('reviewerid')); // Starting review by ID. $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $plan->set('reviewerid', null); $plan->update(); api::plan_start_review($plan->get('id')); $plan->read(); $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status')); $this->assertEquals($reviewer->id, $plan->get('reviewerid')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function testReviewCreate()\n {\n\n }", "public function startTest() {}", "public function testStartInstance()\n {\n $this->markTestSkipped('Test start instance skipped');\n }", "public function testAddReview()\n {\n // @see https://symfony.com/doc/current/testing.html#logging-in-users-authentication\n $client = static::createClient();\n \n $userRepository = static::$container->get(UserRepository::class);\n\n // retrieve the test user\n $testUser = $userRepository->findOneByEmail('[email protected]');\n\n // simulate $testUser being logged in\n $client->loginUser($testUser);\n\n // test e.g. the profile page\n $client->request('GET', '/review/add');\n $this->assertResponseIsSuccessful();\n $this->assertSelectorTextContains('h1', 'Connexion');\n }", "public function actionStep1Review(){}", "public function testReviewCreate()\n {\n //レビュー作成に必要なインスタンス作成(お店情報など)\n $admin_user = User::factory()->state(['role_id' => '1'])->create();\n $this->actingAs($admin_user);\n $shop = Shop::factory()->state(['name' => '中華B', 'description' => '餃子が絶品'])\n ->for(Area::factory()->state(['area_name' => '新橋']))\n ->for(Category::factory()->state(['category_name' => '中華']))->create();\n\n $response = $this->get(action('App\\Http\\Controllers\\ReviewsController@create', compact('shop')));\n $response ->assertStatus(200)->assertViewIs('review.post');\n }", "function PreRunTest()\n {\n\n }", "public function run()\n {\n ReviewAgree::create(array(\n 'evaluator_id' => 2,\n 'evaluatee_id' => 1,\n 'movie_id' => 1,\n 'agree' => 0,\n 'disagree' => 0,\n ));\n }", "public function testReviewFind()\n {\n\n }", "public function run()\n {\n // try {\n // factory(App\\Models\\ItemReview::class, 1)->create();\n // }catch (Exception $e) {}\n }", "public function testReviewCreateChangeStreamPostReviewsChangeStream()\n {\n\n }", "public function testInit() {\n\t\t$result = $this->testAction ( '/login/init' );\n\t\tdebug ( $result );\n\t}", "protected function setUp() {\r\n $this->app = new TestApplication();\r\n\r\n $this->window = $this->app->getWindow();\r\n\r\n $this->counter = 0;\r\n }", "public function testRunLook()\n {\n }", "public function test()\n {\n $this->executeScenario();\n }", "public function test()\n {\n $this->executeScenario();\n }", "public function test()\n {\n $this->executeScenario();\n }", "public function test()\n {\n $this->executeScenario();\n }", "public function test()\n {\n $this->executeScenario();\n }", "public function test()\n {\n $this->executeScenario();\n }", "public function testReviewCount()\n {\n\n }", "public function testGuiMainPage()\n {\n $this->visit('/rules')\n ->see('Create new Rules Here');\n }", "public function testStart() {\n $request = $this->getAuthorisedHttpRequest('http://'.self::$coreApplication.'/job/'.self::TEST_CANONICAL_URL.'/start/?type=single+URL'); \n $this->getHttpClient()->redirectHandler()->enable();\n $response = $this->getHttpClient()->getResponse($request);\n \n $responseObject = json_decode($response->getBody()); \n \n // Verify results\n $this->assertEquals(self::HTTP_STATUS_OK, $response->getResponseCode());\n $this->assertInternalType('integer', $responseObject->id);\n $this->assertEquals(self::PUBLIC_USER_USERNAME, $responseObject->user);\n $this->assertEquals(self::TEST_CANONICAL_URL, $responseObject->website);\n $this->assertEquals('new', $responseObject->state);\n $this->assertEquals(0, $responseObject->url_count);\n $this->assertEquals(0, $responseObject->task_count);\n \n self::$jobId = $responseObject->id;\n }", "function startTest()\n {\n // to be able to specify $autoConnect => false\n $config =& new GOOGLE_ANALYTICS_CONFIG();\n $this->db =& new GoogleAnalyticsSource(\n $config->googleAnalytics_test, false);\n }", "public function start_scenario() {\n $this->check_behat_setup();\n $this->fix_moodle_setup();\n $this->ionicurl = $this->start_or_reuse_ionic();\n}", "public function testReviewPrototypeCreateLikes()\n {\n\n }", "public function testMain()\n {\n echo \"\\n >----------- Test Main : ---------> \\n\";\n // error_log($this->save());\n // $this->update(2, \"ECE\");\n // $this->delete(2);\n // error_log($this->findOne(2));\n // $this->getCurrentLoggedUserID();\n $this->getAllEducation(1000);\n\n // $this->insertingManyEducation();\n }", "function actionBegin()\r\n\t{\r\n\t\tglobal $preview;\r\n\r\n\t\tif($_REQUEST[\"qid\"] && $preview)\r\n\t\t\t$this->checkCaptcha();\r\n\t}", "public function testReviewExistsHeadReviewsid()\n {\n\n }", "protected function setUp() {\n parent::setUp();\n\n // Login.\n $this->user = $this->drupalCreateUser(\n [\n 'run security checks',\n 'access security review list',\n 'access administration pages',\n 'administer site configuration',\n ]\n );\n $this->drupalLogin($this->user);\n\n // Get checks.\n $this->checks = security_review_security_review_checks();\n }" ]
[ "0.653842", "0.65043294", "0.63309014", "0.62762415", "0.6274987", "0.6218029", "0.6182858", "0.6140301", "0.61213076", "0.61020106", "0.60270774", "0.59829104", "0.59786254", "0.5961479", "0.59603584", "0.59603584", "0.59603584", "0.59603584", "0.59603584", "0.59603584", "0.59595186", "0.5955182", "0.59446037", "0.5935028", "0.5928692", "0.5896082", "0.58578396", "0.58566976", "0.5835729", "0.5834394" ]
0.71549994
0
Testing stopping the review.
public function test_plan_stop_review() { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; $user = $data['user']; $reviewer = $data['reviewer']; $otheruser = $data['otheruser']; $plan = $data['plan']; $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set('status', plan::STATUS_IN_REVIEW); $tplplan->update(); $plan->set('status', plan::STATUS_IN_REVIEW); $plan->update(); // Foreign user cannot do anything. $this->setUser($otheruser); try { api::plan_stop_review($plan); $this->fail('The user can not read the plan.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Can not change a plan based on a template. $this->setUser($reviewer); try { api::plan_stop_review($tplplan); $this->fail('The plan is based on a template.'); } catch (coding_exception $e) { $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage()); } // Can not stop a review whe not in review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_DRAFT); try { api::plan_stop_review($plan); $this->fail('The plan review cannot be stopped at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage()); } // Can not stop a review whe not in review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); try { api::plan_stop_review($plan); $this->fail('The plan review cannot be stopped at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage()); } // Can not stop a review whe not in review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_ACTIVE); try { api::plan_stop_review($plan); $this->fail('The plan review cannot be stopped at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage()); } // Can not stop a review whe not in review. $this->setUser($reviewer); $plan->set('status', plan::STATUS_COMPLETE); try { api::plan_stop_review($plan); $this->fail('The plan review cannot be stopped at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage()); } // Stopping as the owner. $this->setUser($user); $plan->set('status', plan::STATUS_IN_REVIEW); try { api::plan_stop_review($plan); $this->fail('The user can not stop a review.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Stopping review. $this->setUser($reviewer); api::plan_stop_review($plan); $plan->read(); $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status')); // Stopping review by ID. $plan->set('status', plan::STATUS_IN_REVIEW); $plan->update(); api::plan_stop_review($plan->get('id')); $plan->read(); $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function stopTest()\n {\n $questions = Session::get('testing.questions');\n $answered = Session::get('testing.answers');\n\n // STOP THE TEST\n // Is there a test attempt, and some questions?\n if ($this->id && ! empty($questions)) {\n // Save the answers in DB \n // Stored in answers as json \n $this->answers = json_encode($answered);\n $this->end_time = date('Y-m-d H:i:s');\n $this->save();\n \n // Score the test behind the scenes\n $this->score();\n\n // Rid session of any testing stuff\n Session::forget('testing');\n Session::forget('disable_menu');\n }\n }", "public function test_plan_cancel_review_request() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($user);\n try {\n api::plan_cancel_review_request($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Cancelling as a reviewer.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not cancel a review request.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Cancelling review request.\n $this->setUser($user);\n api::plan_cancel_review_request($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Cancelling review request by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::plan_cancel_review_request($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function tearDown()\n {\n $this->ratingIndex->open();\n if ($this->reviewInitial instanceof Review) {\n foreach ($this->reviewInitial->getRatings() as $rating) {\n $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]);\n $this->ratingEdit->getPageActions()->delete();\n $this->ratingEdit->getModalBlock()->acceptAlert();\n }\n }\n }", "public function testStopInstance()\n {\n $this->markTestSkipped('Test stop instance skipped');\n }", "public function testReviewPrototypeDestroyVideo()\n {\n\n }", "function exitSurvey()\n\t{\n\t\tif(!$this->preview)\n\t\t{\n\t\t\t$this->backToRepository();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$this->ctrl->setParameterByClass(\"ilobjsurveygui\", \"pgov\", $_REQUEST[\"pgov\"]);\n\t\t\t$this->ctrl->redirectByClass(\"ilobjsurveygui\", \"questions\");\n\t\t}\n\t}", "function setFailureAndStop()\n {\n $this->failed = true;\n $this->stop();\n }", "function setFailureAndStop()\n {\n $this->failed = true;\n $this->stop();\n }", "public function close_reviews() {\n\t\tupdate_post_meta( absint( $_GET['post'] ), 'edd_reviews_status', 'closed' );\n\t}", "public function testStopEvent()\n\t{\n\t\t$this->manager->response(true);\n\t\t$this->manager->on($this->eventType.\":brithday\", function($event){\n\t\t\tif ($event->isCancelable() === true) {\n\t\t\t\t$event->stop();\n\t\t\t}\n\t\t\treturn \"2\";\n\t\t});\t\n\t\t$this->manager->on($this->eventType, new Person);\n\t\t$this->manager->on($this->eventType.\":brithday\", function($event){\n\t\t\treturn \"3\";\n\t\t});\n\n\t\t$this->manager->run($this->eventType.\":brithday\",null,array(),false);\n\t\t$this->assertEquals(3,sizeof($this->manager->getResponses()));\n\n\t\t$this->manager->run($this->eventType.\":brithday\",null,array(),true);\n\t\t$this->assertEquals(1,sizeof($this->manager->getResponses()));\n\t}", "public function stop() {\n $this->halt = true;\n }", "public function testReviewPrototypeDestroyByIdLikes()\n {\n\n }", "public function stop()\n {\n $this->mustStop = true;\n }", "protected function stop() {\n\t$this->_stop = true;\n}", "public function testCancelSettleLater()\n {\n }", "public function testReviewPrototypeDestroyImage()\n {\n\n }", "public function stop()\n {\n }", "public function stop()\n {\n }", "public function testProductAPIDeactivateProduct()\n {\n\n }", "public function review_dismiss() {\n\t\t$review = get_option( 'monsterinsights_review', array() );\n\t\t$review['time'] = time();\n\t\t$review['dismissed'] = true;\n\t\tupdate_option( 'monsterinsights_review', $review );\n\n\t\tif ( is_super_admin() && is_multisite() ) {\n\t\t\t$site_list = get_sites();\n\t\t\tforeach ( (array) $site_list as $site ) {\n\t\t\t\tswitch_to_blog( $site->blog_id );\n\n\t\t\t\tupdate_option( 'monsterinsights_review', $review );\n\n\t\t\t\trestore_current_blog();\n\t\t\t}\n\t\t}\n\n\t\tdie;\n\t}", "public function teardown()\n {\n \n }", "public function testProductAPIDeactivateProduct2()\n {\n\n }", "public function stop();", "public function stop();", "public function stop();", "public function stop();", "public function stop();", "public function stop();", "protected function _stop()\n {\n $this->core->stop = TRUE;\n }", "public function terminate() {\n if (!defined(\"PHPUNIT_WTSA1_TESTSUITE\")) session_destroy();\n $this->clearUser();\n self::$instance = null;\n }" ]
[ "0.7451937", "0.65090096", "0.6460951", "0.630399", "0.629442", "0.5984094", "0.5860194", "0.5860194", "0.58529675", "0.5795901", "0.5750976", "0.5702002", "0.56888634", "0.56881016", "0.5678232", "0.56439793", "0.5629871", "0.5629871", "0.5628559", "0.5626446", "0.56087315", "0.56056833", "0.5604946", "0.5604946", "0.5604946", "0.5604946", "0.5604946", "0.5604946", "0.55905706", "0.55545056" ]
0.77747035
0
Testing approving the plan.
public function test_approve_plan() { $data = $this->setup_workflow_data(); $dg = $data['dg']; $lpg = $data['lpg']; $user = $data['user']; $reviewer = $data['reviewer']; $otheruser = $data['otheruser']; $plan = $data['plan']; $tplplan = $data['tplplan']; // Set waiting for review. $tplplan->set('status', plan::STATUS_IN_REVIEW); $tplplan->update(); $plan->set('status', plan::STATUS_IN_REVIEW); $plan->update(); // Foreign user cannot do anything. $this->setUser($otheruser); try { api::approve_plan($plan); $this->fail('The user can not read the plan.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Can not change a plan based on a template. $this->setUser($reviewer); try { api::approve_plan($tplplan); $this->fail('The plan is based on a template.'); } catch (coding_exception $e) { $this->assertRegExp('/Template plans are already approved./', $e->getMessage()); } // Can not approve a plan already approved. $this->setUser($reviewer); $plan->set('status', plan::STATUS_ACTIVE); try { api::approve_plan($plan); $this->fail('The plan cannot be approved at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage()); } // Can not approve a plan already approved. $this->setUser($reviewer); $plan->set('status', plan::STATUS_COMPLETE); try { api::approve_plan($plan); $this->fail('The plan cannot be approved at this stage.'); } catch (coding_exception $e) { $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage()); } // Approve as the owner. $this->setUser($user); $plan->set('status', plan::STATUS_IN_REVIEW); try { api::approve_plan($plan); $this->fail('The user can not approve the plan.'); } catch (required_capability_exception $e) { $this->assertEquals('nopermissions', $e->errorcode); } // Approve plan from in review. $this->setUser($reviewer); api::approve_plan($plan); $plan->read(); $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status')); // Approve plan by ID. $plan->set('status', plan::STATUS_IN_REVIEW); $plan->update(); api::approve_plan($plan->get('id')); $plan->read(); $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status')); // Approve plan from draft. $plan->set('status', plan::STATUS_DRAFT); $plan->update(); api::approve_plan($plan); $plan->read(); $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status')); // Approve plan from waiting for review. $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW); $plan->update(); api::approve_plan($plan); $plan->read(); $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_plan_request_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n $this->assertEquals(plan::STATUS_DRAFT, $tplplan->get('status'));\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_request_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($user);\n try {\n api::plan_request_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not send for review when not draft.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_request_review($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());\n }\n\n // Can not send for review when not draft.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_request_review($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());\n }\n\n // Can not send for review when not draft.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_request_review($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());\n }\n\n // Can not send for review when not draft.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_request_review($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());\n }\n\n // Sending for review as a reviewer.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_request_review($plan);\n $this->fail('The user can not request a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Sending for review.\n $this->setUser($user);\n api::plan_request_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_WAITING_FOR_REVIEW, $plan->get('status'));\n\n // Sending for review by ID.\n $plan->set('status', plan::STATUS_DRAFT);\n $plan->update();\n api::plan_request_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_WAITING_FOR_REVIEW, $plan->get('status'));\n }", "public function testWorkflow_Trial_Active_Prorated_Alt()\n {\n Setting::set('is_trial_inclusive', false);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->addDays(10)->day;\n $plan->trial_days = 14;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generateMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Status::STATUS_TRIAL, $service->status->code);\n $this->assertEquals(Carbon::now(), $service->current_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addDays(14), $service->current_period_end, '', 5);\n $this->assertEquals(1, $service->is_active);\n\n $now = $this->timeTravelDay(5);\n $this->workerProcess();\n\n // Pay the first invoice, activate membership\n $invoice->submitManualPayment('Testing');\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n $expectedDate = clone $now;\n $expectedPrice = $plan->adjustPrice(100, $expectedDate->addDays(9));\n\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($expectedPrice, $invoice->total);\n $this->assertEquals($now->addMonth()->addDays(5), $service->service_period_end, '', 5);\n }", "public function test_plan_start_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_start_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_start_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Starting as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_start_review($plan);\n $this->fail('The user can not start a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Starting review.\n $this->setUser($reviewer);\n api::plan_start_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status'));\n $this->assertEquals($reviewer->id, $plan->get('reviewerid'));\n\n // Starting review by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->set('reviewerid', null);\n $plan->update();\n api::plan_start_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status'));\n $this->assertEquals($reviewer->id, $plan->get('reviewerid'));\n }", "public function test_create_paid_access_plan() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 10,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Now test that if the frequency is 0 (default) and we enable the trial, the trial is still disabled.\n\t\t$sample_args['trial_enabled'] = true;\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t\t'frequency' => 0,\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Test that a frequency > 0 unlocks trials.\n\t\t$sample_args['frequency'] = 1;\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$this->assertTrue(\n\t\t\tllms_parse_bool(\n\t\t\t\t( new LLMS_Access_Plan( $response->get_data()['id'] ) )->get( 'trial_offer' )\n\t\t\t)\n\t\t);\n\t}", "public function test_unapprove_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_ACTIVE);\n $tplplan->update();\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::unapprove_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are always approved./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Unapprove as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not unapprove the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Unapprove plan.\n $this->setUser($reviewer);\n api::unapprove_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Unapprove plan by ID.\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n api::unapprove_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function testWorkflow_Trial_Active_Prorated()\n {\n Setting::set('is_trial_inclusive', false);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->addDays(10)->day;\n $plan->trial_days = 7;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generateMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Status::STATUS_TRIAL, $service->status->code);\n $this->assertEquals(Carbon::now(), $service->current_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addDays(7), $service->current_period_end, '', 5);\n $this->assertEquals(1, $service->is_active);\n\n $now = $this->timeTravelDay(5);\n $this->workerProcess();\n\n // Pay the first invoice, activate membership\n $invoice->submitManualPayment('Testing');\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n $expectedDate = clone $now;\n $expectedPrice = $plan->adjustPrice(100, $expectedDate->addDays(2));\n\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($expectedPrice, $invoice->total);\n $this->assertEquals($now->addDays(5), $service->service_period_end, '', 5);\n }", "public function test_update_free_access_plan() {\n\t\t// Create free access plan.\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$access_plan_id = $response->get_data()['id'];\n\n\t\t// Update the title.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $access_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Updated Title',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$ap = new LLMS_Access_Plan( $access_plan_id );\n\t\t$this->assertEquals( $ap->get('title'), 'Updated Title' );\n\n\t}", "public function test_create_free_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$free_props = array(\n\t\t\t'is_free' => 'yes',\n\t\t\t'price' => 0,\n\t\t\t'frequency' => 0,\n\t\t\t'on_sale' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Check again, that even the passed properties are \"reset\".\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t\t'frequency' => 6,\n\t\t\t\t'sale_enabled' => true,\n\t\t\t\t'trial_enabled' => true,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t}", "abstract protected function local_has_paid_plan();", "public function test_access_plan_limit() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\tforeach ( array( 'course', 'llms_membership' ) as $pt ) {\n\n\t\t\t// Create 5 access plans, by default the limit is 6 per product.\n\t\t\t$access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) );\n\n\t\t\t$product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\n\t\t\tforeach ( $access_plan_ids as $access_plan_id ) {\n\t\t\t\tupdate_post_meta( $access_plan_id, '_llms_product_id', $product );\n\t\t\t}\n\n\t\t\t// Create an ap through api with same product id.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t\t$sixth_ap = $response->get_data()['id'];\n\t\t\t// The 6th passes.\n\t\t\t$this->assertResponseStatusEquals( 201, $response, $pt );\n\n\t\t\t// Create the 7th ap.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\n\t\t\t// Update the 6th.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $sixth_ap,\n\t\t\t\tarray(\n\t\t\t\t\t'title' => 'Updated',\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Update passes.\n\t\t\t$this->assertResponseStatusEquals( 200, $response, $pt );\n\n\t\t\t// Create an ap linked to a different product.\n\t\t\t$access_plan = $this->factory->post->create( array( 'post_type' => $this->post_type ) );\n\t\t\t$new_product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\t\t\tupdate_post_meta( $access_plan, '_llms_product_id', $new_product );\n\n\t\t\t// Update its post_id so that it becomes the 7th ap of the first product.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $access_plan,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\t\t}\n\t}", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function testWorkflow_Active_FromSignup()\n {\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_signup';\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generatePaidMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Carbon::now(), $service->service_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addMonth(), $service->service_period_end, '', 5);\n $this->assertEquals(100, $invoice->total);\n }", "public function testWorkflow_Active_Prorated_SameDay()\n {\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->day;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generatePaidMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(1, $service->count_renewal);\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals(Carbon::now(), $service->service_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addMonth(), $service->service_period_end, '', 5);\n $this->assertEquals(100, $invoice->total);\n }", "public function test_altering_access_plan_allowed_to_who_can_edit_parent_post() {\n\n\t\t$instructor = $this->factory->user->create(\n\t\t\tarray( 'role' => 'instructor' )\n\t\t);\n\t\t$assistant = $this->factory->user->create(\n\t\t\tarray( 'role' => 'instructors_assistant' )\n\t\t);\n\t\t$course = $this->factory->course->create_and_get();\n\n\t\t// Assign the instructors to the course.\n\t\t$course->set_instructors(\n\t\t\tarray(\n\t\t\t\tarray(\n\t\t\t\t\t'id' => $instructor\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'id' => $assistant\n\t\t\t\t),\n\t\t\t)\n\t\t);\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Instructors of the Course with post_id can manipulate.\n\t\twp_set_current_user( $instructor );\n\n\t\t// Creation is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 201, $response );\n\t\t$new_plan_id = $response->get_data()['id'];\n\n\t\t// Update is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $new_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Title can change',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\n\t\t// Deletion is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'DELETE',\n\t\t\t$this->route . '/' . $new_plan_id\n\t\t);\n\t\t$this->assertResponseStatusEquals( 204, $response );\n\n\t\t// Check the same happens with intructors assistants\n\n\t\t// Instructor's Assistant of the Course with post_id can manipulate.\n\t\twp_set_current_user( $assistant );\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Creation is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 201, $response );\n\t\t$new_plan_id = $response->get_data()['id'];\n\n\t\t// Update is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $new_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Title can change',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\n\t\t// Deletion is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'DELETE',\n\t\t\t$this->route . '/' . $new_plan_id\n\t\t);\n\t\t$this->assertResponseStatusEquals( 204, $response );\n\n\t}", "public function testVoucherMarkAsPaid()\n {\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_create_and_get_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t$create_response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$access_plan = $create_response->get_data();\n\n\t\t// Success.\n\t\t$this->assertResponseStatusEquals( 201, $create_response );\n\n\t\t// Get the access plan.\n\t\t$get_response = $this->perform_mock_request(\n\t\t\t'GET',\n\t\t\ttrailingslashit( $this->route ) . $access_plan['id'],\n\t\t\tarray(),\n\t\t\tarray( 'context' => 'edit' )\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 200, $get_response );\n\t\t$this->assertEquals( $access_plan, $get_response->get_data() );\n\n\t\t$this->assertEqualSets( $this->schema_properties, array_keys( $get_response->get_data() ) );\n\n\t}", "public function createPlan() {\n $plan = new Plan();\n // # Basic Information\n // Fill up the basic information that is required for the plan\n $plan->setName('Daily Edition')->setDescription('Template creation 20.')->setType('fixed');\n // # Payment definitions for this billing plan.\n $paymentDefinition = new PaymentDefinition();\n // The possible values for such setters are mentioned in the setter method documentation.\n // Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method.\n // You should be able to see the acceptable values in the comments.\n $paymentDefinition\n ->setName('Regular Payments')\n ->setType('REGULAR')\n ->setFrequency('DAY')\n ->setFrequencyInterval(\"2\")\n ->setCycles(\"700\")\n ->setAmount(new Currency(array('value' => 1, 'currency' => 'EUR')));\n // Charge Models\n// $chargeModel = new ChargeModel();\n// $chargeModel->setType('SHIPPING')->setAmount(new Currency(array('value' => 10, 'currency' => 'USD')));\n// $paymentDefinition->setChargeModels(array($chargeModel));\n $merchantPreferences = new MerchantPreferences();\n $baseUrl = PaypalManager::getBaseUrl();\n // ReturnURL and CancelURL are not required and used when creating billing agreement with payment_method as \"credit_card\".\n // However, it is generally a good idea to set these values, in case you plan to create billing agreements which accepts \"paypal\" as payment_method.\n // This will keep your plan compatible with both the possible scenarios on how it is being used in agreement.\n $merchantPreferences\n ->setReturnUrl(\"$baseUrl/ExecuteAgreement.php?success=true\")\n ->setCancelUrl(\"$baseUrl/ExecuteAgreement.php?success=false\")\n ->setAutoBillAmount(\"yes\")->setInitialFailAmountAction(\"CONTINUE\")\n ->setMaxFailAttempts(\"0\")\n ->setSetupFee(new Currency(array('value' => 1, 'currency' => 'EUR')));\n\n $plan->setPaymentDefinitions(array($paymentDefinition));\n $plan->setMerchantPreferences($merchantPreferences);\n// For Sample Purposes Only.\n $request = clone $plan;\n// ### Create Plan\n try {\n $output = $plan->create($this->apiContext);\n } catch (\\Exception $ex) {\n // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY\n ResultPrinter::printError(\"Created Plan\", \"Plan\", null, $request, $ex);\n exit(1);\n }\n// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY\n //ResultPrinter::printResult(\"Created Plan\", \"Plan\", $output->getId(), $request, $output);\n return $output;\n }", "public function testEntity()\n {\n $client = static::createClient();\n $project = $client->getContainer()->getParameter('cerad_tourn_project');\n \n $personPlan = new PersonPlan();\n $personPlan->setPlanProperties($project['plan']);\n \n $this->assertEquals('na', $personPlan->attending);\n \n $personPlan->attending = 'yes';\n $this->assertEquals('yes', $personPlan->attending);\n \n $this->assertTrue (isset($personPlan->refereeing));\n $this->assertFalse(isset($personPlan->refereeingx)); \n }", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_plan_cancel_review_request() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($user);\n try {\n api::plan_cancel_review_request($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Cancelling as a reviewer.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not cancel a review request.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Cancelling review request.\n $this->setUser($user);\n api::plan_cancel_review_request($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Cancelling review request by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::plan_cancel_review_request($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function test_plan_stop_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_stop_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Stopping as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not stop a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Stopping review.\n $this->setUser($reviewer);\n api::plan_stop_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Stopping review by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::plan_stop_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function youCanApproveUsers()\n {\n // Arrange...\n $this->login();\n\n // Act...\n $this->json('put', \"users/{$this->user->id}\", [\n 'approved' => true\n ]);\n\n // Assert...\n $this->seeStatusCode(Response::HTTP_OK);\n $this->seeJson([\n 'approved' => true\n ])->seeInDatabase('users', [\n 'approved' => true\n ]);\n }", "public function testWorkflow_Active_FreeDays_Alt()\n {\n $nowOriginal = clone $this->engine->now();\n $now = Carbon::now()->day(15);\n $this->engine->now($now);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_free';\n $plan->plan_month_day = 10;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generatePaidMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $now2 = clone $now;\n $this->assertEquals(1, $service->count_renewal);\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($now, $service->service_period_start, '', 5);\n $this->assertEquals($now2->addMonth()->day(10), $service->service_period_end, '', 5);\n $this->assertEquals(100, $invoice->total);\n\n // It is now the 26th of the month\n $this->timeTravelDay(11);\n $this->workerProcess();\n\n // Another invoice should not be raised yet\n $this->assertEquals(1, $service->invoices()->count());\n\n // It is now the 26th of the next month\n $this->timeTravelMonth();\n $this->workerProcess();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n // Second invoice is ready to go 1 month + 11 days later\n $this->assertEquals(2, $service->invoices()->count());\n\n // Reset\n $this->engine->now($nowOriginal);\n }", "public function testGetPendingPayments()\n {\n\n }", "public function test_update_non_existent_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/12569',\n\t\t\t$this->sample_access_plan_args\n\t\t);\n\n\t\t// Not found.\n\t\t$this->assertResponseStatusEquals( 404, $response );\n\n\t}", "abstract protected function get_paid_plan_for_api();", "public function testActivateOrgSurveyPass()\n {\n $communityId = 6;\n $this->assertAlertable($communityId, 'activateOrganizationsSurvey');\n }", "public static function enforcePlan($plan) {\n\t\tif (!UserConfig::$IGNORE_CURRENT_ACCOUNT_PLAN_VERIFICATION && !$plan) {\n\t\t\theader('Location: ' . UserConfig::$USERSROOTURL . '/plans.php');\n\t\t\texit;\n\t\t}\n\t}" ]
[ "0.7241233", "0.7235388", "0.7160573", "0.7069354", "0.7063218", "0.7060309", "0.7011474", "0.68910927", "0.65738857", "0.6534264", "0.6499439", "0.6488575", "0.64624053", "0.64388007", "0.6390567", "0.63162273", "0.63001853", "0.6280699", "0.6277369", "0.62723255", "0.6269394", "0.62325054", "0.6214011", "0.61981887", "0.6192671", "0.6189667", "0.61641306", "0.60886765", "0.607115", "0.60659164" ]
0.82762897
0
Test update plan and the managing of archived user competencies.
public function test_update_plan_manage_archived_competencies() { global $DB; $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create users and roles for the test. $user = $dg->create_user(); $manageownrole = $dg->create_role(array( 'name' => 'User manage own', 'shortname' => 'manageown' )); assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id); assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id); assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id); assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id); $dg->role_assign($manageownrole, $user->id, $syscontext->id); $this->setUser($user); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create two plans and assign competencies. $plan = $lpg->create_plan(array('userid' => $user->id)); $otherplan = $lpg->create_plan(array('userid' => $user->id)); $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id'))); $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id'))); $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id'))); $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id'))); $uclist = array( $lpg->create_user_competency(array( 'userid' => $user->id, 'competencyid' => $c1->get('id'), 'proficiency' => true, 'grade' => 1 )), $lpg->create_user_competency(array( 'userid' => $user->id, 'competencyid' => $c2->get('id'), 'proficiency' => false, 'grade' => 2 )) ); // Change status of the plan to complete. $record = $plan->to_record(); $record->status = \core_competency\plan::STATUS_COMPLETE; try { $plan = api::update_plan($record); $this->fail('We cannot complete a plan using api::update_plan().'); } catch (coding_exception $e) { // All good. } api::complete_plan($plan); // Check that user compretencies are now in user_competency_plan objects and still in user_competency. $this->assertEquals(2, \core_competency\user_competency::count_records()); $this->assertEquals(3, \core_competency\user_competency_plan::count_records()); $usercompetenciesplan = \core_competency\user_competency_plan::get_records(); $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid')); $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid')); $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency')); $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade')); $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid')); $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid')); $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid')); $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency')); $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade')); $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid')); $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid')); $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid')); $this->assertNull($usercompetenciesplan[2]->get('proficiency')); $this->assertNull($usercompetenciesplan[2]->get('grade')); $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid')); // Change status of the plan to active. $record = $plan->to_record(); $record->status = \core_competency\plan::STATUS_ACTIVE; try { api::update_plan($record); $this->fail('Completed plan can not be edited'); } catch (coding_exception $e) { // All good. } api::reopen_plan($record->id); // Check that user_competency_plan objects are deleted if the plan status is changed to another status. $this->assertEquals(2, \core_competency\user_competency::count_records()); $this->assertEquals(0, \core_competency\user_competency_plan::count_records()); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_delete_plan_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $managerole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);\n $dg->role_assign($managerole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create completed plan with records in user_competency.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n\n api::delete_plan($completedplan->get('id'));\n\n // Check that achived user competencies are deleted.\n $this->assertEquals(0, \\core_competency\\plan::count_records());\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_list_plan_competencies_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $viewrole = $dg->create_role(array(\n 'name' => 'User view',\n 'shortname' => 'view'\n ));\n assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);\n assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);\n $dg->role_assign($viewrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create draft plan with records in user_competency.\n $draftplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n // Check that user_competency objects are returned when plan status is not complete.\n $plancompetencies = api::list_plan_competencies($draftplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[0]->usercompetency);\n $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[1]->usercompetency);\n $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[2]->usercompetency);\n $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetencyplan);\n\n // Create completed plan with records in user_competency_plan.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'),\n 'planid' => $completedplan->get('id')));\n\n // Check that user_competency_plan objects are returned when plan status is complete.\n $plancompetencies = api::list_plan_competencies($completedplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[0]->usercompetencyplan);\n $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[1]->usercompetencyplan);\n $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[2]->usercompetencyplan);\n $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetency);\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_approve_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::approve_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are already approved./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Approve as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not approve the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Approve plan from in review.\n $this->setUser($reviewer);\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::approve_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from draft.\n $plan->set('status', plan::STATUS_DRAFT);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from waiting for review.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n }", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function test_unapprove_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_ACTIVE);\n $tplplan->update();\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::unapprove_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are always approved./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Unapprove as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not unapprove the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Unapprove plan.\n $this->setUser($reviewer);\n api::unapprove_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Unapprove plan by ID.\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n api::unapprove_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function upgradePlanAction()\n\t\t{\n\t\t\t$usersNs = new Zend_Session_Namespace(\"members\");\n\t $Doctor = new Application_Model_Doctor();\n\t\t\t$User = new Application_Model_User();\n\t $docObject = $Doctor->fetchRow(\"user_id='{$usersNs->userId}'\");\n\t\t\t$userObject = $User->fetchRow(\"id='{$usersNs->userId}'\");\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t$first_name=$userObject->firstName;\n\t\t\t$last_name=$userObject->firstName;\n\t\t\t$address=$docObject->street;\n\t\t\t$city=$docObject->city;\n\t\t\t$state=$docObject->state;\n\t\t\t$country='United State';\n\t\t\t$zip=$docObject->zipcode;\n\t\t\t$billing_address=$docObject->street;\n\t\t\t$billing_city=$docObject->city;\n\t\t\t$billing_state=$docObject->state;\n\t\t\t$billing_country='United State';\n\t\t\t$billing_zip=$docObject->zipcode;\n\t\t\t$email=$userObject->email;\n\t\t\t\n\t\t\t$settings = new Admin_Model_GlobalSettings();\n\t\t\t$premium_monthly_upgrade = $settings->settingValue('premium_monthly_upgrade');\n\t\t\t$premium_annual_upgrade = $settings->settingValue('premium_annual_upgrade');\n\t\t\t$this->view->premium_upgrade=$premium_monthly_upgrade.'?first_name='.$first_name.'&last_name='.$last_name.'&address='.$address.'&city='.$city.'&state='.$state.'&country='.$country.'&zip='.$zip.'&billing_address='.$billing_address.'&billing_city='.$billing_city.'&billing_state='.$billing_state.'&billing_country='.$billing_country.'&billing_zip='.$billing_zip.'&email='.$email.'';\n\t\t\t\n\t\t\t$this->view->yearly=$premium_annual_upgrade.'?first_name='.$first_name.'&last_name='.$last_name.'&address='.$address.'&city='.$city.'&state='.$state.'&country='.$country.'&zip='.$zip.'&billing_address='.$billing_address.'&billing_city='.$billing_city.'&billing_state='.$billing_state.'&billing_country='.$billing_country.'&billing_zip='.$billing_zip.'&email='.$email.'';\n\t\t\t\n\t\t\t$customer_premium_id= $this->_getParam('customer_premium_id');\n\t\t\t$yearly= $this->_getParam('plan');\n\t\t\tif($yearly==\"yearly\"){\n\t\t\t$expiry=strtotime('+12 month', time());\n\t\t\t$subscription_type=\"Yearly\";\n\t\t\t}else\n\t\t\t{\n\t\t\t$expiry=strtotime('+1 month', time());\n\t\t\t$subscription_type=\"Monthly\";\n\t\t\t}\n\t\t\t\n\t\t\tif($customer_premium_id)\n\t\t\t{ \n\t\t\t\t\n\t\t\t\t\t$ids=$docObject->id;\n\t\t\t\t\t//echo $ids;die;\n\t\t\t\t\t$idArray = explode(',', $ids);\n\t\t\t\t\t\t$model = new Application_Model_Doctor();\n\t\t\t\t\t\t\tforeach ($idArray as $id) {\n\t\t\t\t\t\t\t//echo $id;die;\n\t\t\t\t\t\t\t\t$object = $model->fetchRow(\"id=\".$id);\n\t\t\t\t\t\t\tif($object){\n\t\t\t\t\t\t\t\t$object->setStatus('1');\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t$object->setSubscriptionType($subscription_type);\t\n\t\t\t\t\t\t\t\t$object->setMembershipLevel(\"Premium\");\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t$object->setMembershipLevelNo('3');\t\t\t\t\n\t\t\t\t\t\t\t\t$object->setExpiration($expiry);\n\t\t\t\t\t\t\t\t$object->setCustomerId($customer_premium_id);\n\t\t\t\t\t\t\t\t$object->save();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t$this->_helper->redirector('upgrade-plan', 'index', \"user\");\t\t \n\t \n\t\t\t}\n\t\t\n\t\t\t$this->view->membership=$docObject;\t\t\n\t\t\t\n\t\t\n\t\t}", "public function testUpdate()\n {\n foreach ($this->users as $user) {\n $payload = [\n 'name' => $this->faker->company,\n 'version' => '1.0.0',\n 'description' => $this->faker->text,\n 'price' => $this->faker->randomFloat(2, 0, 10),\n ];\n\n $res = $this->actingAs($user, 'api')\n ->json('PATCH', '/api/v1/android_apps/1', $payload);\n\n switch ($user->role_id) {\n case $this->roles['admin']->id:\n $res->assertStatus(200)->assertJson([\n 'data' => $payload\n ]);\n break;\n case $this->roles['vendor']->id:\n case $this->roles['user']->id:\n default:\n $res->assertForbidden();\n break;\n }\n }\n }", "public function test_update_free_access_plan() {\n\t\t// Create free access plan.\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$access_plan_id = $response->get_data()['id'];\n\n\t\t// Update the title.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $access_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Updated Title',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$ap = new LLMS_Access_Plan( $access_plan_id );\n\t\t$this->assertEquals( $ap->get('title'), 'Updated Title' );\n\n\t}", "public function testPostLicenseUsers()\n {\n }", "function testTeamUpdate() {\n //========================================= \n \n // To verify update Parlay Team is valid\n //========================================= \n }", "public function testAddViewUpdateMilestone()\n {\n \t$property_flip_id = $this->createPropertyFlip('Test address line 1000');\n \t\n \t$transaction_type_description = 'Test Transaction Type 1';\n \t$transaction_type_id = $this->createTestTransactionType($transaction_type_description);\n \t\n \t$transaction_type_description2 = 'Test Transaction Type 2';\n \t$transaction_type_id2 = $this->createTestTransactionType($transaction_type_description2);\n \t\n \t$account_name = 'Account ABC';\n \t$account_id = $this->createTestAccount($account_name);\n \t\n \t$this->visit('/')\n\t \t->visit('/login')\n\t \t->type('[email protected]', 'email')\n\t \t->type('password', 'password')\n\t \t->press('Login')\n\t \t->see('Home')\n\t \t->visit('/search-property')\n\t \t \n\t \t->type($property_flip_id, 'property_flip_id')\n\t \t->press('Search')\n\t \t->click('View') //View Property\n\t \t \n\t \t->click('View') //View Property Flip\n\t \t->see('View Property Flip')\n\t \t->see('General')\n\t \t->see('Investors')\n\t \t\n\t \t->click('transactions-tab')\n\t \t->see('Transactions')\n\t \t->press('Add Transaction')\n\t \t->type('2016-11-30', 'effective_date')\n\t \t->type('Test Description', 'description')\n\t \t->type('Test Reference', 'reference')\n\t \t->select($account_id, 'account_id')\n\t \t->select($transaction_type_id, 'transaction_type_id')\n\t \t->type('1000000', 'debit_amount')\n\t \t->press('Add Transaction')\n\t \t\n\t \t->see('View Property Flip')\n\t \t->see('Transactions')\n\t \t->see($account_name)\n\t \t->see($transaction_type_description)\n\t \t \n\t \t->click('view-transaction')\n\t \t->see('View Transaction')\n\t \t->see($account_name)\n\t \t->see($transaction_type_description)\n \t\n \t\t->press('Update Transaction')\n \t\t->see('Update Transaction')\n \t\t->select($transaction_type_id2, 'transaction_type_id')\n \t\t->type('2000000', 'debit_amount')\n \t\t->press('Update Transaction')\n \t\t\n \t\t->see('View Property Flip')\n \t\t->see('Transactions')\n \t\t->see('Transaction updated')\n \t\t->see($transaction_type_description2);\n }", "public function testAdministrator_is_able_to_update_users()\n {\n $user = factory(\\App\\User::class)->create();\n\n $existing = factory(\\App\\User::class)->create(['name' => 'Holaholo']);\n\n $this->actingAs($user)\n ->visit('/users/'.$existing->id.'/edit')\n ->see($existing->name)\n ->type('Foo bar', 'name')\n ->press('Submit')\n ->seeInDatabase('users', ['id' => $existing->id, 'name' => 'Foo bar'])\n ->see('Data has been updated successfully');\n }", "public function testWorkflow_Active_FromSignup()\n {\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_signup';\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generatePaidMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Carbon::now(), $service->service_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addMonth(), $service->service_period_end, '', 5);\n $this->assertEquals(100, $invoice->total);\n }", "public function testCloudPosCheckUpdateCoursesInCheck()\n {\n }", "function testScheduleUpdate() {\n //========================================= \n \n // To verify update Parlay Schedule is valid\n //========================================= \n }", "public function testCloudPosCheckUpdateItemInCourse()\n {\n }", "public function testOverview()\n {\n $user = factory(App\\User::class)->create();\n\n Artisan::call('bouncer:seed');\n $role = Bouncer::assign('verhuur')->to($user);\n $this->assertTrue($role);\n\n $new = $this->actingAs($user);\n $new->visit('backend/rental/overview/all');\n $new->seeStatusCode(200);\n\n $all = $this->actingAs($user);\n $all->visit('backend/rental/overview/new');\n $all->seeStatusCode(200);\n\n $option = $this->actingAs($user);\n $option->visit('backend/rental/overview/option');\n $option->seeStatusCode(200);\n }", "public function testUsersMustBeManuallyApprovedByAnAdmin() {\n\t\t$this->markTestIncomplete('Requires manual testing for now');\n\t}", "public function api_updates_vacancies_for_authorized_users_correctly()\n {\n seed_teachers();\n seed_departments();\n first_or_create_speciality('CAS' , 'Curs Accés Grau Superior', '','');\n $newSpeciality = first_or_create_speciality('AN' , 'Anglès', '','');\n $vacancy = vacancy_first_or_create(\n obtainSpecialityIdByCode('CAS'),\n $deparment = obtainDepartmentIdByEspecialityCode('CAS'),\n 1,\n $teacher = obtainTeacherIdByCode('02'),\n \"assigned\"\n );\n\n $this->assertDatabaseHas('vacancies', [ 'id' => $vacancy->id ]);\n $newVacancy = [\n 'speciality_id' => $newSpeciality->id,\n 'department_id' => $deparment,\n 'order' => '1',\n 'owner' => $teacher,\n 'state' => 'active',\n ];\n $this->signInAsStaffManager('api')\n ->json('PUT', '/api/v1/vacancies/' . $vacancy->id, $newVacancy)\n ->assertStatus(200)\n ->assertJson( [\n 'message' => 'Vacancy successfully updated.'\n ]);\n\n $this->assertDatabaseHas('vacancies', $newVacancy);\n }", "public function testTaskUpdate()\n {\n\n }", "public function test_list_plans_with_competency() {\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $u1 = $this->getDataGenerator()->create_user();\n $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign the competency to each.\n $plan1 = $lpg->create_plan(array('userid' => $u1->id));\n $plan2 = $lpg->create_plan(array('userid' => $u1->id));\n\n $lpg->create_plan_competency(array('planid' => $plan1->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create one more plan without the competency.\n $plan3 = $lpg->create_plan(array('userid' => $u1->id));\n\n $plans = api::list_plans_with_competency($u1->id, $c1);\n\n $this->assertEquals(2, count($plans));\n\n $this->assertEquals(reset($plans)->get('id'), $plan1->get('id'));\n $this->assertEquals(end($plans)->get('id'), $plan2->get('id'));\n }", "public function testMeetingPollUpdate()\n {\n }", "public function runUpdate()\r\n\t{\r\n\t\t$dbh = $this->dbh;\r\n\r\n\t\tforeach ($this->ids as $cid)\r\n\t\t{\r\n\t\t\t$cust = CAntObject::factory($dbh, \"customer\", $cid, $this->user);\r\n\t\t\t$cust->setValue(\"name\", \"Regression Test \" . $i . \"-r2\");\r\n\t\t\t$cust->save();\r\n\t\t}\r\n\t}", "public function youCanApproveUsers()\n {\n // Arrange...\n $this->login();\n\n // Act...\n $this->json('put', \"users/{$this->user->id}\", [\n 'approved' => true\n ]);\n\n // Assert...\n $this->seeStatusCode(Response::HTTP_OK);\n $this->seeJson([\n 'approved' => true\n ])->seeInDatabase('users', [\n 'approved' => true\n ]);\n }", "public function createUserPlan($model_data)\n {\n $data = array(\n 'user_id' => $model_data['user_id'],\n 'plan_id' => $model_data['plan_id'],\n 'remaining_service' => $model_data['remaining_service'],\n 'purchase_date' => date('Y-m-d H:i:s'),\n 'expire_date' => $model_data['expire_date'],\n );\n $this->db->insert('user_plans', $data); \n return true; \n // $count = $this->user_helper->countUserPlan($model_data['user_id']);\n\n // if($count > 0 && $count != 0)\n // {\n // $CheckUserPlan = $this->user_helper->UpdateCheckUserPlan($model_data['user_id']);\n\n // $this->db->where('user_id', $model_data['user_id']);\n // $this->db->where('deleted_date', '0000-00-00');\n // $delete_plan = array(\n // 'deleted_date' => date('Y-m-d H:i:s'),\n // );\n // $this->db->update('user_plans', $delete_plan);\n\n // // $delete_product = array(\n // // 'product_deleted_date' => date('Y-m-d H:i:s'),\n // // );\n // // $this->db->where('user_id', $model_data['user_id']);\n // // $this->db->update('product', $delete_product);\n\n // if (!empty($CheckUserPlan)) \n // {\n // $currentdate = date('Y-m-d');\n // $datetime1 = strtotime($CheckUserPlan->expire_date);\n // $datetime2 = strtotime($currentdate);\n \n // $secs = $datetime1 - $datetime2;\n // $days = $secs / 86400;\n\n // $actualDate = date('Y-m-d', strtotime($model_data['expire_date']. ' + '.$days.' days'));\n\n // $total_remaining_serive = $model_data['remaining_service'] + $CheckUserPlan->remaining_service;\n\n // $data = array (\n // 'user_id' => $model_data['user_id'],\n // 'plan_id' => $model_data['plan_id'],\n // 'remaining_service' => $total_remaining_serive,\n // 'purchase_date' => date('Y-m-d H:i:s'),\n // 'expire_date' => $actualDate,\n // );\n // $this->db->insert('user_plans', $data);\n // return true;\n // } \n // else \n // { \n // $data = array (\n // 'user_id' => $model_data['user_id'],\n // 'plan_id' => $model_data['plan_id'],\n // 'remaining_service' => $model_data['remaining_service'],\n // 'purchase_date' => date('Y-m-d H:i:s'),\n // 'expire_date' => $model_data['expire_date'],\n // );\n // $this->db->insert('user_plans', $data);\n // return true;\n // }\n // } \n // else \n // {\n // $this->db->where('user_id', $model_data['user_id']);\n // $this->db->where('deleted_date', '0000-00-00');\n // $delete_plan = array(\n // 'deleted_date' => date('Y-m-d H:i:s'),\n // );\n // $this->db->update('user_plans', $delete_plan);\n // // $delete_product = array(\n // // 'product_deleted_date' => date('Y-m-d H:i:s'),\n // // );\n // // $this->db->where('user_id', $model_data['user_id']);\n // // $this->db->update('product', $delete_product);\n\n // $data = array(\n // 'user_id' => $model_data['user_id'],\n // 'plan_id' => $model_data['plan_id'],\n // 'remaining_service' => $model_data['remaining_service'],\n // 'purchase_date' => date('Y-m-d H:i:s'),\n // 'expire_date' => $model_data['expire_date'],\n // );\n // $this->db->insert('user_plans', $data); \n // return true; \n // }\n }", "public function testHandleUpdateDealerUpdateTarget()\n {\n // Populate data\n $promotorTargetIDs = $this->_populate();\n\n // Set data\n $ID = $this->_pickRandomItem($promotorTargetIDs);\n $promotorTarget = $this->promotor_target->getOne($ID);\n $month = '2016-11';\n \n // Set parameter\n $params = [\n 'ID' => $promotorTarget->dealer_ID,\n 'date' => $month,\n 'type' => 'dealer',\n 'total' => 1000000\n ];\n \n // Request\n $response = $this->withSession($this->adminSession)\n ->call('POST', '/sales-target/edit', $params, [], [], ['HTTP_REFERER' => '/sales-target/edit']);\n \n // Verify response\n $this->assertRedirectedTo('/sales-target/edit');\n $this->assertSessionHas('target-updated', '');\n \n // Verify data\n $totals = DB::table('promotor_targets')\n ->where('dealer_ID', $params['ID'])\n ->where('month', $month)\n ->pluck('total');\n \n foreach ($totals as $total)\n {\n $this->assertEquals($total, floor($params['total']/count($totals)));\n }\n \n }", "public function testProductsUpdate()\n {\n }", "public function testWorkflow_Trial_Active_Prorated_Alt()\n {\n Setting::set('is_trial_inclusive', false);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->addDays(10)->day;\n $plan->trial_days = 14;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generateMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Status::STATUS_TRIAL, $service->status->code);\n $this->assertEquals(Carbon::now(), $service->current_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addDays(14), $service->current_period_end, '', 5);\n $this->assertEquals(1, $service->is_active);\n\n $now = $this->timeTravelDay(5);\n $this->workerProcess();\n\n // Pay the first invoice, activate membership\n $invoice->submitManualPayment('Testing');\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n $expectedDate = clone $now;\n $expectedPrice = $plan->adjustPrice(100, $expectedDate->addDays(9));\n\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($expectedPrice, $invoice->total);\n $this->assertEquals($now->addMonth()->addDays(5), $service->service_period_end, '', 5);\n }" ]
[ "0.69808936", "0.6785393", "0.6508193", "0.65008897", "0.6499267", "0.64740443", "0.6198012", "0.6196624", "0.6057125", "0.5931636", "0.5831252", "0.57763845", "0.575359", "0.5694014", "0.5660726", "0.5655956", "0.56018215", "0.55816317", "0.55797476", "0.55648804", "0.55646217", "0.55501837", "0.5538823", "0.5530037", "0.55276865", "0.5516297", "0.55154324", "0.55112976", "0.55058646", "0.5502172" ]
0.750521
0
Test completing plan does not change the order of competencies.
public function test_complete_plan_doesnot_change_order() { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create users and roles for the test. $user = $dg->create_user(); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create two plans and assign competencies. $plan = $lpg->create_plan(array('userid' => $user->id)); $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id'))); $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id'))); $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id'))); // Changing competencies order in plan competency. api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id')); $competencies = api::list_plan_competencies($plan); $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id')); $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id')); $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id')); // Completing plan. api::complete_plan($plan); $competencies = api::list_plan_competencies($plan); // Completing plan does not change order. $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id')); $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id')); $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id')); // Testing plan based on template. $template = $lpg->create_template(); $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $lpg->create_template_competency(array( 'templateid' => $template->get('id'), 'competencyid' => $c1->get('id') )); $lpg->create_template_competency(array( 'templateid' => $template->get('id'), 'competencyid' => $c2->get('id') )); $lpg->create_template_competency(array( 'templateid' => $template->get('id'), 'competencyid' => $c3->get('id') )); // Reorder competencies in template. api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id')); // Create plan from template. $plan = api::create_plan_from_template($template->get('id'), $user->id); $competencies = api::list_plan_competencies($plan); // Completing plan does not change order. $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id')); $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id')); $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id')); // Completing plan. api::complete_plan($plan); $competencies = api::list_plan_competencies($plan); // Completing plan does not change order. $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id')); $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id')); $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function test_delete_plan_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $managerole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);\n $dg->role_assign($managerole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create completed plan with records in user_competency.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n\n api::delete_plan($completedplan->get('id'));\n\n // Check that achived user competencies are deleted.\n $this->assertEquals(0, \\core_competency\\plan::count_records());\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function testParallelSuiteProgressOverhead(): void\n {\n $suite = $this->getSuiteWithResult('mixed-results.xml', 100);\n $this->printer->addTest($suite);\n\n $this->printer->start();\n $this->printer->printFeedback($suite);\n $this->printer->printResults();\n\n static::assertStringContainsString('FAILURES', $this->output->fetch());\n }", "public function testCancelAllDunningPending()\n {\n }", "public function testGetNextToBeExecutedCrystalTasksByPriorityStrategyShouldWorkWithDivideTotalValueEquallyPriorityStrategy()\n {\n $priorityStrategyFactoryMock = $this->createPriorityStrategyFactoryMock(\n $this->getConfigDependeeTaskWithDivideTotalValueEquallyPriorityStrategy()\n );\n\n /** @var ExecuteHeartbeat $executeHeartbeatMock */\n $executeHeartbeatMock = $this->createExecuteHeartbeatMock(\n $this->getConfigDependeeTaskWithDivideTotalValueEquallyPriorityStrategy(),\n $priorityStrategyFactoryMock\n );\n\n $dataDependeeTask = [\n 'class' => DependeeTask::class,\n 'entity_uid' => 'some.id',\n 'range' => 1,\n 'timeout' => 11,\n 'cooldown' => 1,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n\n $dataThirtySecondsTask = [\n 'class' => ThirtySecondsTask::class,\n 'entity_uid' => 'some.id',\n 'range' => 2,\n 'timeout' => 11,\n 'cooldown' => 1,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n\n $dataDependentTask = [\n 'class' => DependentTask::class,\n 'entity_uid' => 'some.id',\n 'range' => 3,\n 'timeout' => 11,\n 'cooldown' => 1,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 1]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 2]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 3]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 4]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 5]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 6]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 7]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 8]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 9]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 10]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 11]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 12]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 13]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 14]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 15]));\n\n $availableExecutionSlots = 7;\n $crystalTasksArray = $executeHeartbeatMock->getNextToBeExecutedCrystalTasksByPriorityStrategy($availableExecutionSlots);\n\n $crystalTaskRanges = array_column($crystalTasksArray, 'range');\n $crystalTaskClasses = array_column($crystalTasksArray, 'class');\n sort($crystalTaskRanges);\n sort($crystalTaskClasses);\n\n $this->assertEquals(['1', '2', '3', '4', '6', '11', '12'], $crystalTaskRanges);\n $this->assertEquals([\n DependeeTask::class,\n DependeeTask::class,\n DependeeTask::class,\n DependeeTask::class,\n DependentTask::class,\n DependentTask::class,\n ThirtySecondsTask::class,\n ], $crystalTaskClasses);\n }", "public function testRescheduleCrystalTasksMultipleShouldNot()\n {\n $rescheduleCooldown = CrystalTask::STATE_CRYSTAL_TASK_RESCHEDULE_COOLDOWN;\n\n $dataDependeeCompleted = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '100',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_COMPLETED,\n ];\n $dataDependeeRunning = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '99',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n $dataDependeeDead = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '22100',\n 'date_start' => (new DateTime)->sub(new DateInterval('P9Y'))->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n $dataDependeeNotCompleted = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '3399',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->sub(new DateInterval('PT' . (2 + $rescheduleCooldown) . 'S'))->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NOT_COMPLETED,\n ];\n $dataDependeeNew = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '1003333',\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n $dataDependentCompleted = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '101',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_COMPLETED,\n ];\n $dataDependentNotCompleted = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '939',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->sub(new DateInterval('PT' . (2 + $rescheduleCooldown) . 'S'))->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NOT_COMPLETED,\n ];\n $dataDependentNew = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => 'abc',\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n $dataDependentRunning = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '939222',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n $dataDependentDead = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '9399',\n 'date_start' => (new DateTime)->sub(new DateInterval('P9Y'))->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n\n $dataDependency = [\n 'class' => DependentTask::class,\n 'depend_on' => DependeeTask::class,\n ];\n\n $this->_fixtureHelper->setupCrystalTask($dataDependeeCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeRunning);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeDead);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeNotCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeNew);\n $this->_fixtureHelper->setupCrystalTask($dataDependentCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependentRunning);\n $this->_fixtureHelper->setupCrystalTask($dataDependentDead);\n $this->_fixtureHelper->setupCrystalTask($dataDependentNotCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependentNew);\n\n $this->_fixtureHelper->setupCrystalTaskDependency($dataDependency);\n\n $this->assertCount(10, $this->_crystalTasksTable->getAll());\n\n $this->_rescheduleHeartbeat->rescheduleCrystalTasks();\n $this->assertTrue($this->_testHandler->hasRecordThatContains(\n 'Rescheduled CrystalTask',\n Logger::INFO\n ));\n\n $this->assertCount(10, $this->_crystalTasksTable->getAll());\n\n $dataDependeeDead = array_merge($dataDependeeDead, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataDependeeNotCompleted = array_merge($dataDependeeNotCompleted, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataDependentDead = array_merge($dataDependentDead, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataDependentNotCompleted = array_merge($dataDependentNotCompleted, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n // Should be rescheduled\n $this->assertArraySubset($dataDependeeDead, (array)$this->_crystalTasksTable->getByPK(3));\n $this->assertArraySubset($dataDependeeNotCompleted, (array)$this->_crystalTasksTable->getByPK(4));\n $this->assertArraySubset($dataDependentDead, (array)$this->_crystalTasksTable->getByPK(8));\n $this->assertArraySubset($dataDependentNotCompleted, (array)$this->_crystalTasksTable->getByPK(9));\n\n // Should not be rescheduled\n $this->assertArraySubset($dataDependeeCompleted, (array)$this->_crystalTasksTable->getByPK(1));\n $this->assertArraySubset($dataDependeeRunning, (array)$this->_crystalTasksTable->getByPK(2));\n $this->assertArraySubset($dataDependeeNew, (array)$this->_crystalTasksTable->getByPK(5));\n $this->assertArraySubset($dataDependentCompleted, (array)$this->_crystalTasksTable->getByPK(6));\n $this->assertArraySubset($dataDependentRunning, (array)$this->_crystalTasksTable->getByPK(7));\n $this->assertArraySubset($dataDependentNew, (array)$this->_crystalTasksTable->getByPK(10));\n }", "public function testRunner() {\n\t\t$this->markTestIncomplete();\n\t}", "public function testTaskWorkTaskWorkTakeCharge()\n {\n }", "public function testOptOutListings()\n {\n\n }", "public function testCloudPosCheckCancelAllCoursesInCheck()\n {\n }", "public function test_list_plan_competencies_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $viewrole = $dg->create_role(array(\n 'name' => 'User view',\n 'shortname' => 'view'\n ));\n assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);\n assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);\n $dg->role_assign($viewrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create draft plan with records in user_competency.\n $draftplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n // Check that user_competency objects are returned when plan status is not complete.\n $plancompetencies = api::list_plan_competencies($draftplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[0]->usercompetency);\n $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[1]->usercompetency);\n $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[2]->usercompetency);\n $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetencyplan);\n\n // Create completed plan with records in user_competency_plan.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'),\n 'planid' => $completedplan->get('id')));\n\n // Check that user_competency_plan objects are returned when plan status is complete.\n $plancompetencies = api::list_plan_competencies($completedplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[0]->usercompetencyplan);\n $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[1]->usercompetencyplan);\n $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[2]->usercompetencyplan);\n $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetency);\n }", "public function testTaskWorkCanFinalizeTaskByIds()\n {\n }", "public function testStatementComplete() : void {\n $provider = $this->getReference('provider.1');\n $deposit = $this->getReference('deposit.2');\n $crawler = $this->client->request(\n 'GET',\n '/api/sword/2.0/cont-iri/' . $provider->getUuid() . '/' . $deposit->getUuid() . '/state'\n );\n $response = $this->client->getResponse();\n $this->assertSame(200, $response->getStatusCode());\n $this->assertStringContainsStringIgnoringCase('LOCKSS boxes have harvested', $response->getContent());\n }", "public function testRescheduleCrystalTasksDeadMultiple()\n {\n $dataDead1 = [\n 'class' => DependeeTask::class,\n 'timeout' => '99',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '32',\n 'date_start' => (new DateTime)->sub(new DateInterval('P10Y'))->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING\n ];\n $dataDead2 = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '4',\n 'date_start' => (new DateTime)->sub(new DateInterval('P10Y'))->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING\n ];\n $dataRunning = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '99',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING\n ];\n $dataCompleted = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '100',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_COMPLETED\n ];\n $dataNew = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '101',\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW\n ];\n $this->_fixtureHelper->setupCrystalTask($dataDead1);\n $this->_fixtureHelper->setupCrystalTask($dataDead2);\n $this->_fixtureHelper->setupCrystalTask($dataRunning);\n $this->_fixtureHelper->setupCrystalTask($dataCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataNew);\n\n $this->assertCount(5, $this->_crystalTasksTable->getAll());\n\n $this->_rescheduleHeartbeat->rescheduleCrystalTasks();\n $this->assertTrue($this->_testHandler->hasRecordThatContains(\n 'Rescheduled CrystalTask',\n Logger::INFO\n ));\n\n $this->assertCount(5, $this->_crystalTasksTable->getAll());\n\n $dataRescheduled1 = array_merge($dataDead1, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataRescheduled2 = array_merge($dataDead2, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $this->assertArraySubset($dataRescheduled1, (array)$this->_crystalTasksTable->getByPK(1));\n $this->assertArraySubset($dataRescheduled2, (array)$this->_crystalTasksTable->getByPK(2));\n $this->assertArraySubset($dataRunning, (array)$this->_crystalTasksTable->getByPK(3));\n $this->assertArraySubset($dataCompleted, (array)$this->_crystalTasksTable->getByPK(4));\n $this->assertArraySubset($dataNew, (array)$this->_crystalTasksTable->getByPK(5));\n }", "public function test_list_plans_with_competency() {\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $u1 = $this->getDataGenerator()->create_user();\n $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign the competency to each.\n $plan1 = $lpg->create_plan(array('userid' => $u1->id));\n $plan2 = $lpg->create_plan(array('userid' => $u1->id));\n\n $lpg->create_plan_competency(array('planid' => $plan1->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create one more plan without the competency.\n $plan3 = $lpg->create_plan(array('userid' => $u1->id));\n\n $plans = api::list_plans_with_competency($u1->id, $c1);\n\n $this->assertEquals(2, count($plans));\n\n $this->assertEquals(reset($plans)->get('id'), $plan1->get('id'));\n $this->assertEquals(end($plans)->get('id'), $plan2->get('id'));\n }", "public function testGetRegistrationProgress()\n {\n }", "public function testPeppolPostSendOrder()\n {\n }", "public function runningUnitTests()\n {\n }", "public function runningUnitTests()\n {\n }", "public function testGetNextToBeExecutedCrystalTasksByPriorityStrategyShouldFallbackSortByDateCreatedPriorityStrategy()\n {\n $config = $this->getConfigDependeeTaskWithDivideTotalValueEquallyPriorityStrategy();\n\n $config['tasks'][] = ['class' => 'foo'];\n\n $priorityStrategyFactoryMock = $this->createPriorityStrategyFactoryMock(\n $config\n );\n\n /** @var ExecuteHeartbeat $executeHeartbeatMock */\n $executeHeartbeatMock = $this->createExecuteHeartbeatMock(\n $config,\n $priorityStrategyFactoryMock\n );\n\n $dataDependeeTask = [\n 'class' => DependeeTask::class,\n 'entity_uid' => 'some.id',\n 'range' => 1,\n 'timeout' => 11,\n 'cooldown' => 1,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n\n $dataThirtySecondsTask = [\n 'class' => ThirtySecondsTask::class,\n 'entity_uid' => 'some.id',\n 'range' => 2,\n 'timeout' => 11,\n 'cooldown' => 1,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n\n $dataDependentTask = [\n 'class' => DependentTask::class,\n 'entity_uid' => 'some.id',\n 'range' => 3,\n 'timeout' => 11,\n 'cooldown' => 1,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 1]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 2]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 3]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 4]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependeeTask, ['range' => 5]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 6]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 7]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 8]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 9]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataThirtySecondsTask, ['range' => 10]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 11]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 12]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 13]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 14]));\n $this->_fixtureHelper->setupCrystalTask(array_merge($dataDependentTask, ['range' => 15]));\n\n $availableExecutionSlots = 7;\n $crystalTasksArray = $executeHeartbeatMock->getNextToBeExecutedCrystalTasksByPriorityStrategy($availableExecutionSlots);\n\n $crystalTaskRanges = array_column($crystalTasksArray, 'range');\n $crystalTaskClasses = array_column($crystalTasksArray, 'class');\n sort($crystalTaskRanges);\n sort($crystalTaskClasses);\n\n $this->assertEquals(['1', '2', '3', '4', '5', '6', '7'], $crystalTaskRanges);\n $this->assertEquals([\n DependeeTask::class,\n DependeeTask::class,\n DependeeTask::class,\n DependeeTask::class,\n DependeeTask::class,\n ThirtySecondsTask::class,\n ThirtySecondsTask::class,\n ], $crystalTaskClasses);\n }", "public function testNextUnfinishedAllCompleted()\n {\n $completed = $this->getMockForAbstractClass('Manhattan\\FormWizardBundle\\Wizard\\AbstractStep', array('completed', 'foo', 'barbarfoo'));\n $completed->expects($this->any())->method('completed')->will($this->returnValue(true));\n\n $completedTwo = $this->getMockForAbstractClass('Manhattan\\FormWizardBundle\\Wizard\\AbstractStep', array('completed', 'completed', 'barbarfoo'));\n $completedTwo->expects($this->any())->method('completed')->will($this->returnValue(true));\n\n $advertismentWizard = $this->getMockForAbstractClass('Manhattan\\FormWizardBundle\\Wizard\\AbstractWizard', array(\n $this->mockSession, $this->mockEntityManager, array($completed, $completedTwo)\n ));\n\n // Confirm abstract steps have been passed into the Wizard\n $this->assertEquals(2, $advertismentWizard->count(), '->count() returns 2 when two steps are passed.');\n\n $nextUnfinished = $advertismentWizard->nextUnfinished();\n\n $this->assertEquals($completedTwo, $nextUnfinished, '->nextUnfinished() returns the last step, even though it is completed.');\n\n $this->assertEquals('completed', $nextUnfinished->getRoute(), '->nextUnfinished() returns the last step, even though it is completed.');\n }", "public function testGetRegistrationInstanceProgress()\n {\n }", "public function testCloudPosCheckBumpCourseOnCheck()\n {\n }", "public function testDeleteRegistrationProgress()\n {\n }", "public function testAcquisitionAssignmentsSave()\n {\n }", "public function testApplyChain()\n {\n $this->todo('stub');\n }", "public function testRunsWithoutWaitingForFinish()\n {\n $startTime = time();\n\n Mage::getModel('parallels/driver_exec')->exec('sleep 10');\n\n $resultTime = time() - $startTime;\n $this->assertLessThan(2, $resultTime);\n }", "public function prove()\n {\n $this->getHarness()->run();\n }" ]
[ "0.7259307", "0.68027973", "0.6046314", "0.59895396", "0.5856757", "0.5782862", "0.57603407", "0.57431906", "0.570644", "0.5698812", "0.56291676", "0.5600058", "0.55986536", "0.55949175", "0.5590743", "0.5590391", "0.55826396", "0.55792713", "0.5569076", "0.55041736", "0.55041736", "0.5498922", "0.5453811", "0.5435596", "0.54303104", "0.5429044", "0.54106086", "0.5383333", "0.5366058", "0.53479433" ]
0.758738
0
Test remove plan and the managing of archived user competencies.
public function test_delete_plan_manage_archived_competencies() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create user and role for the test. $user = $dg->create_user(); $managerole = $dg->create_role(array( 'name' => 'User manage own', 'shortname' => 'manageown' )); assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id); assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id); $dg->role_assign($managerole, $user->id, $syscontext->id); $this->setUser($user); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create completed plan with records in user_competency. $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \core_competency\plan::STATUS_COMPLETE)); $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id'))); $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id'))); $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'))); $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'))); $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'), 'planid' => $completedplan->get('id'))); $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'), 'planid' => $completedplan->get('id'))); api::delete_plan($completedplan->get('id')); // Check that achived user competencies are deleted. $this->assertEquals(0, \core_competency\plan::count_records()); $this->assertEquals(2, \core_competency\user_competency::count_records()); $this->assertEquals(0, \core_competency\user_competency_plan::count_records()); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_unapprove_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_ACTIVE);\n $tplplan->update();\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::unapprove_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are always approved./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Unapprove as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not unapprove the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Unapprove plan.\n $this->setUser($reviewer);\n api::unapprove_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Unapprove plan by ID.\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n api::unapprove_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function testRemoveUser()\n {\n // add few users to Perforce\n $user0 = P4Cms_User::create(\n array(\n 'id' => 'own',\n 'email' => '[email protected]',\n 'fullName' => 'O OWn',\n 'config' => array('own'=>'me')\n )\n )->save();\n $user1 = P4Cms_User::create(\n array(\n 'id' => 'bob',\n 'email' => '[email protected]',\n 'fullName' => 'Bob Bobson',\n 'config' => array('foo'=>'bar')\n )\n )->save();\n $user2 = P4Cms_User::create(\n array(\n 'id' => 'pat',\n 'email' => '[email protected]',\n 'fullName' => 'Pat Patty',\n )\n )->save();\n $user3 = P4Cms_User::create(\n array(\n 'id' => 'bill',\n 'email' => '[email protected]',\n 'fullName' => 'Bill Billy',\n 'config' => array('foo1'=>'bar1')\n )\n )->save();\n\n // add role and assign it to users\n $role = new P4Cms_Acl_Role;\n $role->setId('Role2')\n ->setUsers(array($user1, $user2, $user3))\n ->addOwner($user0)\n ->save();\n\n $this->assertSame(\n 3,\n count(P4Cms_Acl_Role::fetch('Role2')->getUsers()),\n \"Expected number of users having new role\"\n );\n\n // remove user and verify\n $role->removeUser($user2)\n ->save();\n\n $this->assertSame(\n 2,\n count(P4Cms_Acl_Role::fetch('Role2')->getUsers()),\n \"Expected number of users having new role after removing user\"\n );\n $this->assertSame(\n 2,\n count(\n array_intersect(\n array($user1->getId(), $user3->getId()),\n P4Cms_Acl_Role::fetch('Role2')->getUsers()\n )\n ),\n \"Expected users having the role after update.\"\n );\n\n // remove another user and verify\n $role->removeUser($user1)\n ->save();\n\n $this->assertSame(\n 1,\n count(P4Cms_Acl_Role::fetch('Role2')->getUsers()),\n \"Expected number of users having new role after removing user\"\n );\n $this->assertSame(\n 1,\n count(\n array_intersect(\n array($user3->getId()),\n P4Cms_Acl_Role::fetch('Role2')->getUsers()\n )\n ),\n \"Expected users having the role after update.\"\n );\n\n // remove last user and verify (make some user active to prevent failure due to saving empty associated group)\n P4Cms_User::setActive($user1);\n $role->removeUser($user3)\n ->save();\n\n $this->assertSame(\n 0,\n count(P4Cms_Acl_Role::fetch('Role2')->getUsers()),\n \"Expected no users having new role after removing last user\"\n );\n }", "public function test_list_plan_competencies_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $viewrole = $dg->create_role(array(\n 'name' => 'User view',\n 'shortname' => 'view'\n ));\n assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);\n assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);\n $dg->role_assign($viewrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create draft plan with records in user_competency.\n $draftplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n // Check that user_competency objects are returned when plan status is not complete.\n $plancompetencies = api::list_plan_competencies($draftplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[0]->usercompetency);\n $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[1]->usercompetency);\n $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[2]->usercompetency);\n $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetencyplan);\n\n // Create completed plan with records in user_competency_plan.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'),\n 'planid' => $completedplan->get('id')));\n\n // Check that user_competency_plan objects are returned when plan status is complete.\n $plancompetencies = api::list_plan_competencies($completedplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[0]->usercompetencyplan);\n $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[1]->usercompetencyplan);\n $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[2]->usercompetencyplan);\n $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetency);\n }", "public function testRemoveUserMerchant()\n {\n\n }", "public function testAcquisitionAssignmentsDelete()\n {\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function testAcquisitionAssignmentsUndelete()\n {\n }", "function command_member_plan_delete () {\n global $esc_post;\n \n // Verify permissions\n if (!user_access('member_plan_edit')) {\n error_register('Permission denied: member_plan_edit');\n return 'index.php?q=members';\n }\n\n // Delete plan\n $sql = \"DELETE FROM `plan` WHERE `pid`='$esc_post[pid]'\";\n $res = mysql_query($sql);\n if (!$res) die(mysql_error());\n\n return 'index.php?q=plans';\n}", "public function test_plan_stop_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_stop_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Stopping as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not stop a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Stopping review.\n $this->setUser($reviewer);\n api::plan_stop_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Stopping review by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::plan_stop_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function delete_plans(){\n\t\tif ($this->checkLogin('A') == ''){\n\t\t\tredirect(ADMIN_PATH);\n\t\t}else {\n\t\t\t$plan_id = $this->uri->segment(4,0);\n\t\t\t$condition = array('id' => $plan_id);\n\t\t\t$this->plans_model->commonDelete(PLANS,$condition);\n\t\t\t$this->setErrorMessage('success','Plan deleted successfully');\n\t\t\tredirect(ADMIN_PATH.'/plans/display_plans');\n\t\t}\n\t}", "public function testUserDestroyAdminUser(): void\n {\n /** @var User $user */\n $user = User::factory()->create();\n /** @var User $otherUser */\n $otherUser = User::factory()->create();\n $otherUser->admin = true;\n $otherUser->save();\n $response = $this\n ->actingAs($otherUser)\n ->call('delete', '/users/' . $user->id);\n $response->assertRedirect('/')->assertSessionHas('successes');\n }", "public function test_approve_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::approve_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are already approved./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Approve as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not approve the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Approve plan from in review.\n $this->setUser($reviewer);\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::approve_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from draft.\n $plan->set('status', plan::STATUS_DRAFT);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from waiting for review.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n }", "public function planner_delete_planification() {\n \n // Delete planification rule meta\n (new MidrubBaseUserAppsCollectionPlannerHelpers\\Planify)->planner_delete_planification();\n \n }", "protected function deleteUnneeded(): void\n {\n $auth = Yii::$app->authManager;\n\n $manageUsers = $auth->getPermission('manageUsers');\n $usePremiumContent = $auth->getPermission('usePremiumContent');\n\n $manageUsersRemoved = $auth->remove($manageUsers);\n $this->removedMessage($manageUsersRemoved, 'manageUsers');\n\n $usePremiumContentRemoved = $auth->remove($usePremiumContent);\n $this->removedMessage($usePremiumContentRemoved, 'usePremiumContent');\n\n $employee = $auth->getRole('employee');\n $premium = $auth->getRole('premium');\n\n $employeeRemoved = $auth->remove($employee);\n $this->removedMessage($employeeRemoved, 'employee');\n\n $premiumRemoved = $auth->remove($premium);\n $this->removedMessage($premiumRemoved, 'premium');\n\n $this->stdout(\"\\nDeleting unneeded roles and permission done.\\n\", Console::FG_GREEN);\n\n $admin = $auth->getRole('admin');\n $member = $auth->getRole('member');\n\n $addedChild = $auth->addChild($admin, $member);\n if ($addedChild) {\n $this->stdout(\"\\nAdded member as child to admin.\\n\", Console::FG_GREEN);\n } else {\n $this->stdout(\"\\nDidn't add member as child to admin.\\n\", Console::FG_RED);\n }\n }", "public function test_plan_cancel_review_request() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($user);\n try {\n api::plan_cancel_review_request($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Cancelling as a reviewer.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not cancel a review request.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Cancelling review request.\n $this->setUser($user);\n api::plan_cancel_review_request($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Cancelling review request by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::plan_cancel_review_request($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function testAdministrator_is_able_to_delete_users()\n {\n// $this->withoutMiddleware();\n $user = factory(\\App\\User::class)->create();\n\n $existing = factory(\\App\\User::class)->create();\n $this->actingAs($user);\n $response = $this->call('GET', '/users/'.$existing->id.'/delete');\n $this->dontSeeInDatabase('users', ['name' => $existing->name]);\n }", "public static function removePlanDaysCompleteByPlanId(int $plan_id, int $user_id) : void\n {\n \\DB::transaction(function () use ($plan_id, $user_id) {\n $playlist_ids_by_plan = PlanDay::getPlaylistIdsByPlanAndUser($plan_id, $user_id);\n PlaylistItemsComplete::removeItemsByPlayListsAndUser($playlist_ids_by_plan, $user_id);\n PlanDayComplete::removeDaysByPlanAndUser($plan_id, $user_id);\n });\n }", "protected function tearDown() {\n $this->service->deleteAll();\n // $this->createTestUserAcls();\n }", "public function testDeleteAssocation()\n {\n }", "public function deleted(PlanUser $planUser)\n {\n if ($planUser->bill) {\n $plan_income_sum = PlanIncomeSummary::where('month', Carbon::parse($planUser->bill->date)->month)\n ->where('year', Carbon::parse($planUser->bill->date)->year)\n ->where('plan_id', $planUser->plan_id)->first();\n if ($plan_income_sum) {\n $plan_income_sum->amount -= $planUser->bill->amount;\n $plan_income_sum->quantity -= 1;\n $plan_income_sum->save();\n }\n $planUser->bill->delete();\n }\n }", "protected function tearDown(){\n $this->admin = null;\n }", "public function cancelPlanChange()\n {\n\n $subscription = app('subscription');\n if ( $subscription->planChangeRequest ) {\n $subscription->planChangeRequest->delete();\n }\n\n }", "public function testPingTreeTargetRemoveBuyerFromTargetGroup()\n {\n }", "public function testPrivilegeToDelete(): void\n\t{\n\t\t$this->assertTrue(self::$recordMultiCompany->privilegeToDelete());\n\t}", "function testTeamDelete() {\n //========================================= \n \n // To verify delete Parlay Team is valid\n //========================================= \n }", "public function testDeleteAccount()\r\n {\r\n }", "public function testSpacesProjectsDelete()\n {\n }" ]
[ "0.6974854", "0.65856946", "0.63690794", "0.6314413", "0.62731296", "0.6260254", "0.6251977", "0.62191683", "0.62003034", "0.61754614", "0.59248066", "0.59098613", "0.58802503", "0.5875348", "0.58697945", "0.58585536", "0.5852537", "0.5844458", "0.5809935", "0.5785669", "0.5774824", "0.577267", "0.57724154", "0.5759119", "0.5741592", "0.5736812", "0.5735482", "0.5721002", "0.5711894", "0.5700703" ]
0.7464307
0
Test listing of plan competencies.
public function test_list_plan_competencies_manage_archived_competencies() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create user and role for the test. $user = $dg->create_user(); $viewrole = $dg->create_role(array( 'name' => 'User view', 'shortname' => 'view' )); assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id); assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id); $dg->role_assign($viewrole, $user->id, $syscontext->id); $this->setUser($user); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create draft plan with records in user_competency. $draftplan = $lpg->create_plan(array('userid' => $user->id)); $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id'))); $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id'))); $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id'))); $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'))); $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'))); // Check that user_competency objects are returned when plan status is not complete. $plancompetencies = api::list_plan_competencies($draftplan); $this->assertCount(3, $plancompetencies); $this->assertInstanceOf('\core_competency\user_competency', $plancompetencies[0]->usercompetency); $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id')); $this->assertNull($plancompetencies[0]->usercompetencyplan); $this->assertInstanceOf('\core_competency\user_competency', $plancompetencies[1]->usercompetency); $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id')); $this->assertNull($plancompetencies[1]->usercompetencyplan); $this->assertInstanceOf('\core_competency\user_competency', $plancompetencies[2]->usercompetency); $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id')); $this->assertNull($plancompetencies[2]->usercompetencyplan); // Create completed plan with records in user_competency_plan. $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \core_competency\plan::STATUS_COMPLETE)); $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id'))); $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id'))); $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id'))); $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'), 'planid' => $completedplan->get('id'))); $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'), 'planid' => $completedplan->get('id'))); $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'), 'planid' => $completedplan->get('id'))); // Check that user_competency_plan objects are returned when plan status is complete. $plancompetencies = api::list_plan_competencies($completedplan); $this->assertCount(3, $plancompetencies); $this->assertInstanceOf('\core_competency\user_competency_plan', $plancompetencies[0]->usercompetencyplan); $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id')); $this->assertNull($plancompetencies[0]->usercompetency); $this->assertInstanceOf('\core_competency\user_competency_plan', $plancompetencies[1]->usercompetencyplan); $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id')); $this->assertNull($plancompetencies[1]->usercompetency); $this->assertInstanceOf('\core_competency\user_competency_plan', $plancompetencies[2]->usercompetencyplan); $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id')); $this->assertNull($plancompetencies[2]->usercompetency); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_list_plans_with_competency() {\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $u1 = $this->getDataGenerator()->create_user();\n $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign the competency to each.\n $plan1 = $lpg->create_plan(array('userid' => $u1->id));\n $plan2 = $lpg->create_plan(array('userid' => $u1->id));\n\n $lpg->create_plan_competency(array('planid' => $plan1->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create one more plan without the competency.\n $plan3 = $lpg->create_plan(array('userid' => $u1->id));\n\n $plans = api::list_plans_with_competency($u1->id, $c1);\n\n $this->assertEquals(2, count($plans));\n\n $this->assertEquals(reset($plans)->get('id'), $plan1->get('id'));\n $this->assertEquals(end($plans)->get('id'), $plan2->get('id'));\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_delete_plan_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $managerole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);\n $dg->role_assign($managerole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create completed plan with records in user_competency.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n\n api::delete_plan($completedplan->get('id'));\n\n // Check that achived user competencies are deleted.\n $this->assertEquals(0, \\core_competency\\plan::count_records());\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function testOptOutListings()\n {\n\n }", "public function testListListings()\n {\n\n }", "public function testOfferListWihoutParam() {\n $client = static::createClient();\n $client->request('GET', $this->successAPI);\n $this->assertEquals(200, $client->getResponse()->getStatusCode());\n }", "public function testGetProductionPlan() {\n $model = new ProductionPlanModel();\n\n $res = $model->getProductionPlan(\"5\");\n $this->tester->assertEquals($res, array(array('month' => '05', 'skis' => array('1' => 100, '2' => 50))));\n }", "public function getAllPlan(): array;", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "public function test_access_plan_limit() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\tforeach ( array( 'course', 'llms_membership' ) as $pt ) {\n\n\t\t\t// Create 5 access plans, by default the limit is 6 per product.\n\t\t\t$access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) );\n\n\t\t\t$product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\n\t\t\tforeach ( $access_plan_ids as $access_plan_id ) {\n\t\t\t\tupdate_post_meta( $access_plan_id, '_llms_product_id', $product );\n\t\t\t}\n\n\t\t\t// Create an ap through api with same product id.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t\t$sixth_ap = $response->get_data()['id'];\n\t\t\t// The 6th passes.\n\t\t\t$this->assertResponseStatusEquals( 201, $response, $pt );\n\n\t\t\t// Create the 7th ap.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\n\t\t\t// Update the 6th.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $sixth_ap,\n\t\t\t\tarray(\n\t\t\t\t\t'title' => 'Updated',\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Update passes.\n\t\t\t$this->assertResponseStatusEquals( 200, $response, $pt );\n\n\t\t\t// Create an ap linked to a different product.\n\t\t\t$access_plan = $this->factory->post->create( array( 'post_type' => $this->post_type ) );\n\t\t\t$new_product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\t\t\tupdate_post_meta( $access_plan, '_llms_product_id', $new_product );\n\n\t\t\t// Update its post_id so that it becomes the 7th ap of the first product.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $access_plan,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\t\t}\n\t}", "function have_payment_plans( $category = array() ) {\r\n return \\query\\payments::have_plans( $category );\r\n}", "public function testListAllVolunteers()\n {\n $this->browse(function (Browser $browser) {\n\n $browser->logout()\n ->visit('/login')\n ->type('@email-input', '[email protected]')\n ->type('@password-input', 'helloworld')\n ->click('@login-button')\n ->assertSee('Jill')\n ->click('@reports-link')\n ->assertSee('Generate Reports')\n ->select('report', '/reports/listVolunteers')\n ->assertPresent('@listVolunteer-heading');\n });\n }", "public function testCatalog()\n {\n $this->get('/api/v1/catalog')\n ->assertResponseStatus(200)\n ->seeJsonStructure([\n '*' => [\n 'id',\n 'name',\n 'plans' => [\n '*' => [\n 'id',\n 'name',\n 'specs' => [\n '*' => [\n 'id',\n 'ram',\n 'cpu',\n 'disk',\n 'transfer',\n 'dollars_per_hr',\n 'dollars_per_mo',\n ],\n ],\n ],\n ],\n ],\n ]);\n }", "function fn_get_affiliate_plans_list($lang_code = CART_LANGUAGE)\n{\n $plans_list = db_get_hash_single_array(\"SELECT object_id, object FROM ?:affiliate_plans LEFT JOIN ?:common_descriptions ON plan_id=object_id AND lang_code = ?s AND object_holder = 'affiliate_plans' WHERE status = 'A' ORDER BY object\", array('object_id', 'object'), $lang_code);\n\n return empty($plans_list) ? false : $plans_list;\n}", "abstract protected function local_has_paid_plan();", "public function test_plans_visibility(){\n $planType = $this->createPlanType();\n\n $isVisible = true;\n $visiblePlan = $this->createPlan('visible_plan', $planType, false, [], $isVisible);\n\n $isVisible = false;\n $visiblePlan = $this->createPlan('hidden_plan', $planType, false, [], $isVisible);\n\n $this->assertEquals($planType->plans()->visible()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->hidden()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->count(), 2);\n }", "public function run()\n {\n $linode = Company::where('name', 'Linode')->first();\n $linode_plans = collect((new LinodeVps)->avail->linodePlans());\n\n foreach($linode_plans as $linode_plan) {\n Plan::create([\n 'company_id' => $linode->id,\n 'name' => $linode_plan['LABEL'],\n 'api_id' => $linode_plan['PLANID'],\n 'cost_per_hour' => $linode_plan['HOURLY'],\n 'monthly_cap' => $linode_plan['PRICE'],\n 'cpu_cores' => $linode_plan['CORES'],\n 'memory' => $linode_plan['RAM'],\n 'storage' => $linode_plan['DISK'],\n 'transfer' => $linode_plan['XFER'],\n ]);\n }\n\n $aws = Company::where('name', 'Amazon Web Services')->first();\n $digital_ocean = Company::where('name', 'Digital Ocean')->first();\n $vultr = Company::where('name', 'Vultr')->first();\n $lightsail = Company::where('name', 'Amazon Lightsail')->first();\n\n $company_plans = [\n $digital_ocean->id => [\n [\n 'name' => 'Standard 512MB',\n 'cost_per_hour' => 0.007,\n 'monthly_cap' => 5,\n 'cpu_cores' => 1,\n 'memory' => 0.5,\n 'storage' => 20,\n 'transfer' => 1,\n ],\n [\n 'name' => 'Standard 1GB',\n 'cost_per_hour' => 0.015,\n 'monthly_cap' => 10,\n 'cpu_cores' => 1,\n 'memory' => 1,\n 'storage' => 30,\n 'transfer' => 2,\n ],\n [\n 'name' => 'Standard 2GB',\n 'cost_per_hour' => 0.03,\n 'monthly_cap' => 20,\n 'cpu_cores' => 2,\n 'memory' => 2,\n 'storage' => 40,\n 'transfer' => 3,\n ],\n [\n 'name' => 'Standard 4GB',\n 'cost_per_hour' => 0.06,\n 'monthly_cap' => 40,\n 'cpu_cores' => 2,\n 'memory' => 4,\n 'storage' => 60,\n 'transfer' => 4,\n ],\n [\n 'name' => 'Standard 8GB',\n 'cost_per_hour' => 0.119,\n 'monthly_cap' => 80,\n 'cpu_cores' => 4,\n 'memory' => 8,\n 'storage' => 80,\n 'transfer' => 5,\n ],\n [\n 'name' => 'Standard 16GB',\n 'cost_per_hour' => 0.238,\n 'monthly_cap' => 160,\n 'cpu_cores' => 8,\n 'memory' => 16,\n 'storage' => 160,\n 'transfer' => 6,\n ],\n [\n 'name' => 'Standard 32GB',\n 'cost_per_hour' => 0.476,\n 'monthly_cap' => 320,\n 'cpu_cores' => 12,\n 'memory' => 32,\n 'storage' => 320,\n 'transfer' => 7,\n ],\n [\n 'name' => 'Standard 48GB',\n 'cost_per_hour' => 0.714,\n 'monthly_cap' => 480,\n 'cpu_cores' => 16,\n 'memory' => 48,\n 'storage' => 480,\n 'transfer' => 8,\n ],\n [\n 'name' => 'Standard 64GB',\n 'cost_per_hour' => 0.952,\n 'monthly_cap' => 640,\n 'cpu_cores' => 20,\n 'memory' => 64,\n 'storage' => 640,\n 'transfer' => 9,\n ],\n [\n 'name' => 'High Memory 16GB',\n 'cost_per_hour' => 0.18,\n 'monthly_cap' => 120,\n 'cpu_cores' => 2,\n 'memory' => 16,\n 'storage' => 30,\n 'transfer' => 6,\n ],\n [\n 'name' => 'High Memory 32GB',\n 'cost_per_hour' => 0.36,\n 'monthly_cap' => 240,\n 'cpu_cores' => 4,\n 'memory' => 32,\n 'storage' => 90,\n 'transfer' => 7,\n ],\n [\n 'name' => 'High Memory 64GB',\n 'cost_per_hour' => 0.71,\n 'monthly_cap' => 480,\n 'cpu_cores' => 8,\n 'memory' => 64,\n 'storage' => 200,\n 'transfer' => 8,\n ],\n [\n 'name' => 'High Memory 128GB',\n 'cost_per_hour' => 1.43,\n 'monthly_cap' => 960,\n 'cpu_cores' => 16,\n 'memory' => 128,\n 'storage' => 340,\n 'transfer' => 9,\n ],\n [\n 'name' => 'High Memory 224GB',\n 'cost_per_hour' => 2.5,\n 'monthly_cap' => 1680,\n 'cpu_cores' => 32,\n 'memory' => 224,\n 'storage' => 500,\n 'transfer' => 10,\n ],\n ],\n $aws->id => [\n [\n 'name' => 'T2 Nano',\n 'cost_per_hour' => 0.006,\n 'monthly_cap' => 4.745,\n 'cpu_cores' => 1,\n 'memory' => 0.5,\n ],\n [\n 'name' => 'T2 Micro',\n 'cost_per_hour' => 0.013,\n 'monthly_cap' => 9.49,\n 'cpu_cores' => 1,\n 'memory' => 1,\n ],\n [\n 'name' => 'T2 Small',\n 'cost_per_hour' => 0.026,\n 'monthly_cap' => 18.98,\n 'cpu_cores' => 1,\n 'memory' => 2,\n ],\n [\n 'name' => 'T2 Medium',\n 'cost_per_hour' => 0.052,\n 'monthly_cap' => 37.96,\n 'cpu_cores' => 2,\n 'memory' => 4,\n ],\n [\n 'name' => 'T2 Large',\n 'cost_per_hour' => 0.104,\n 'monthly_cap' => 75.92,\n 'cpu_cores' => 2,\n 'memory' => 8,\n ],\n [\n 'name' => 'T2 Extra Large',\n 'cost_per_hour' => 0.188,\n 'monthly_cap' => 137.24,\n 'cpu_cores' => 4,\n 'memory' => 16,\n ],\n [\n 'name' => 'T2 Double Extra Large',\n 'cost_per_hour' => 0.376,\n 'monthly_cap' => 274.48,\n 'cpu_cores' => 8,\n 'memory' => 32,\n ],\n [\n 'name' => 'C4 High-CPU Large',\n 'cost_per_hour' => 0.105,\n 'monthly_cap' => 76.65,\n 'cpu_cores' => 2,\n 'memory' => 3.75,\n 'network_in' => 500,\n 'network_out' => 500,\n ],\n [\n 'name' => 'C4 High-CPU Extra Large',\n 'cost_per_hour' => 0.209,\n 'monthly_cap' => 152.57,\n 'cpu_cores' => 4,\n 'memory' => 7.5,\n 'network_in' => 750,\n 'network_out' => 750,\n ],\n [\n 'name' => 'C4 High-CPU Double Extra Large',\n 'cost_per_hour' => 0.419,\n 'monthly_cap' => 305.87,\n 'cpu_cores' => 8,\n 'memory' => 15,\n 'network_in' => 1000,\n 'network_out' => 1000,\n ],\n [\n 'name' => 'C4 High-CPU Quadruple Extra Large',\n 'cost_per_hour' => 0.838,\n 'monthly_cap' => 611.74,\n 'cpu_cores' => 16,\n 'memory' => 30,\n 'network_in' => 2000,\n 'network_out' => 2000,\n ],\n [\n 'name' => 'C4 High-CPU Eight Extra Large',\n 'cost_per_hour' => 1.675,\n 'monthly_cap' => 1222.75,\n 'cpu_cores' => 36,\n 'memory' => 60,\n 'network_in' => 4000,\n 'network_out' => 4000,\n ],\n [\n 'name' => 'M4 Large',\n 'cost_per_hour' => 0.12,\n 'monthly_cap' => 87.6,\n 'cpu_cores' => 2,\n 'memory' => 8,\n 'network_in' => 450,\n 'network_out' => 450,\n ],\n [\n 'name' => 'M4 Extra Large',\n 'cost_per_hour' => 0.239,\n 'monthly_cap' => 174.47,\n 'cpu_cores' => 4,\n 'memory' => 16,\n 'network_in' => 750,\n 'network_out' => 750,\n ],\n [\n 'name' => 'M4 Double Extra Large',\n 'cost_per_hour' => 0.479,\n 'monthly_cap' => 349.67,\n 'cpu_cores' => 8,\n 'memory' => 32,\n 'network_in' => 1000,\n 'network_out' => 1000,\n ],\n [\n 'name' => 'M4 Quadruple Extra Large',\n 'cost_per_hour' => 0.958,\n 'monthly_cap' => 699.34,\n 'cpu_cores' => 16,\n 'memory' => 64,\n 'network_in' => 2000,\n 'network_out' => 2000,\n ],\n [\n 'name' => 'M4 Deca Extra Large',\n 'cost_per_hour' => 2.394,\n 'monthly_cap' => 1747.62,\n 'cpu_cores' => 40,\n 'memory' => 160,\n 'network_in' => 4000,\n 'network_out' => 4000,\n ],\n [\n 'name' => 'M4 Sixteen Extra Large',\n 'cost_per_hour' => 3.83,\n 'monthly_cap' => 2795.90,\n 'cpu_cores' => 64,\n 'memory' => 256,\n 'network_in' => 10000,\n 'network_out' => 10000,\n ],\n [\n 'name' => 'R4 Large',\n 'cost_per_hour' => 0.133,\n 'monthly_cap' => 97.09,\n 'cpu_cores' => 2,\n 'memory' => 15.25,\n 'network_in' => 10000,\n 'network_out' => 10000,\n ],\n [\n 'name' => 'R4 Extra Large',\n 'cost_per_hour' => 0.266,\n 'monthly_cap' => 194.18,\n 'cpu_cores' => 4,\n 'memory' => 30.5,\n 'network_in' => 10000,\n 'network_out' => 10000,\n ],\n [\n 'name' => 'R4 Double Extra Large',\n 'cost_per_hour' => 0.532,\n 'monthly_cap' => 388.36,\n 'cpu_cores' => 8,\n 'memory' => 61,\n 'network_in' => 10000,\n 'network_out' => 10000,\n ],\n [\n 'name' => 'R4 Quadruple Extra Large',\n 'cost_per_hour' => 1.064,\n 'monthly_cap' => 776.72,\n 'cpu_cores' => 16,\n 'memory' => 122,\n 'network_in' => 10000,\n 'network_out' => 10000,\n ],\n [\n 'name' => 'R4 Eight Extra Large',\n 'cost_per_hour' => 2.128,\n 'monthly_cap' => 1553.44,\n 'cpu_cores' => 32,\n 'memory' => 244,\n 'network_in' => 10000,\n 'network_out' => 10000,\n ],\n [\n 'name' => 'R4 Sixteen Extra Large',\n 'cost_per_hour' => 4.256,\n 'monthly_cap' => 3106.88,\n 'cpu_cores' => 64,\n 'memory' => 488,\n 'network_in' => 20000,\n 'network_out' => 20000,\n ],\n ],\n $lightsail->id => [\n [\n 'name' => '512MB',\n 'cost_per_hour' => 0.007,\n 'monthly_cap' => 5,\n 'cpu_cores' => 1,\n 'memory' => 0.5,\n 'storage' => 20,\n 'transfer' => 1,\n ],\n [\n 'name' => '1GB',\n 'cost_per_hour' => 0.015,\n 'monthly_cap' => 10,\n 'cpu_cores' => 1,\n 'memory' => 1,\n 'storage' => 30,\n 'transfer' => 2,\n ],\n [\n 'name' => '2GB',\n 'cost_per_hour' => 0.03,\n 'monthly_cap' => 20,\n 'cpu_cores' => 1,\n 'memory' => 2,\n 'storage' => 40,\n 'transfer' => 3,\n ],\n [\n 'name' => '4GB',\n 'cost_per_hour' => 0.06,\n 'monthly_cap' => 40,\n 'cpu_cores' => 2,\n 'memory' => 4,\n 'storage' => 60,\n 'transfer' => 4,\n ],\n [\n 'name' => '8GB',\n 'cost_per_hour' => 0.119,\n 'monthly_cap' => 80,\n 'cpu_cores' => 2,\n 'memory' => 8,\n 'storage' => 80,\n 'transfer' => 5,\n ],\n ], \n ];\n\n foreach($company_plans as $company_id => $plans) {\n $company = Company::find($company_id);\n\n foreach($plans as $plan) {\n $plan['company_id'] = $company->id;\n Plan::create($plan);\n }\n }\n }", "public function testOfferListWithParam() {\n $client = static::createClient();\n $client->request('GET', $this->successAPI.'?filter='.$this->filterType);\n $this->assertEquals(200, $client->getResponse()->getStatusCode());\n }", "public function display_plans(){\n\t\tif ($this->checkLogin('A') == ''){\n\t\t\tredirect(ADMIN_PATH);\n\t\t}else {\n\t\t\t$this->data['heading'] = 'Plans Lists';\n\t\t\t$condition = array();\n\t\t\t$this->data['plansList'] = $this->plans_model->get_all_details(PLANS,$condition);\n\t\t\t$this->load->view(ADMIN_PATH.'/plans/display_plans',$this->data);\n\t\t}\n\t}", "public function test_get_access_plans_with_pagination() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$access_plan_ids = $this->factory->post->create_many( 25, array( 'post_type' => $this->post_type ) );\n\t\t$course = $this->factory->course->create();\n\t\tforeach ( $access_plan_ids as $id ) {\n\t\t\tupdate_post_meta( $id, '_llms_product_id', $course );\n\t\t}\n\t\t$start_access_plan_id = $access_plan_ids[0];\n\t\t$this->pagination_test( $this->route, $start_access_plan_id );\n\t}", "public function testOptInListings()\n {\n\n }", "public function test_create_paid_access_plan() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 10,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Now test that if the frequency is 0 (default) and we enable the trial, the trial is still disabled.\n\t\t$sample_args['trial_enabled'] = true;\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t\t'frequency' => 0,\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Test that a frequency > 0 unlocks trials.\n\t\t$sample_args['frequency'] = 1;\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$this->assertTrue(\n\t\t\tllms_parse_bool(\n\t\t\t\t( new LLMS_Access_Plan( $response->get_data()['id'] ) )->get( 'trial_offer' )\n\t\t\t)\n\t\t);\n\t}", "public function list() {\n return new CollectionRequestBuilder(\n $this->identity,\n $this,\n 'licensing_plans',\n function ($project)\n {\n return new LicensingPlan((array) $project);\n },\n new LicensingPlanCollection()\n );\n }", "abstract protected function get_paid_plan_for_api();", "public function testProductAPIProductCertificationList()\n {\n\n }", "public function testAddProductionPlan() {\n $model = new ProductionPlanModel();\n $payload = array('month' => '06', 'skis' => array('1' => 50, '2' => 100));\n\n $model->addProductionPlan($payload);\n $this->tester->seeInDatabase('production_plan', ['month' => '2021-06-01']);\n $this->tester->seeNumRecords(2, 'production_skis', ['production_plan_id' => 2]);\n $this->tester->seeNumRecords(2, 'production_skis', ['ski_type_id' => 2]);\n $this->tester->seeNumRecords(2, 'production_skis', ['ski_type_id' => 1]);\n }", "public function getPlans(): Collection\n {\n return $this->plans;\n }" ]
[ "0.75378424", "0.6620047", "0.6604951", "0.6401793", "0.6344127", "0.6338518", "0.5988864", "0.58888286", "0.5871384", "0.58294576", "0.58000046", "0.5736901", "0.56999046", "0.5671016", "0.56654775", "0.56620365", "0.5638297", "0.5632852", "0.5631253", "0.5622378", "0.5617104", "0.55552244", "0.5532185", "0.5521659", "0.55163246", "0.55004454", "0.54870695", "0.54779476", "0.54503095", "0.5449997" ]
0.7078179
1
Test add evidence for existing user_competency.
public function test_add_evidence_existing_user_competency() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create users. $user = $dg->create_user(); $this->setUser($user); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'))); $this->assertSame(null, $uc->get('grade')); $this->assertSame(null, $uc->get('proficiency')); // Create an evidence and check it was created with the right usercomptencyid and information. $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \core_competency\evidence::ACTION_OVERRIDE, 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2); $this->assertEquals(1, \core_competency\evidence::count_records()); $evidence->read(); $uc->read(); $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid')); $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier')); $this->assertEquals('core_competency', $evidence->get('desccomponent')); $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca')); $this->assertEquals('http://moodle.org', $evidence->get('url')); $this->assertEquals(\core_competency\evidence::ACTION_OVERRIDE, $evidence->get('action')); $this->assertEquals(2, $evidence->get('actionuserid')); $this->assertEquals(1, $evidence->get('grade')); $this->assertEquals(1, $uc->get('grade')); $this->assertEquals(0, $uc->get('proficiency')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "public function testIfAttendanceIsCreatedWhenUserIsAddedToTeam()\n {\n /** FIRST LET'S CREATE SOME TEAM WITH SCHEDULE */\n\n $team = $this->createTestTeam(__FUNCTION__);\n\n /** LET'S ADD NEW USER TO TEAM */\n\n $newUser = new User();\n $newUser\n ->setEmail('user.' . strtolower(__FUNCTION__) . rand() . '@example.com')\n ->setPlainPassword(__FUNCTION__);\n\n $team->addUser($newUser);\n\n $this->em()->persist($team);\n $this->em()->flush();\n\n /** ATTENDANCES SHOULD BE CREATED */\n\n $attendances = $this->getRepo('AttendeeApiBundle:Attendance')->findBy(array(\n 'user' => $newUser\n ));\n\n $this->assertEquals(7, count($attendances), 'New user should have some attendances.');\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public static function addNewExpense($data, $user){\n\t\t$expenceAmountCommaReplacement = str_replace(',','.',$data['expenceAmount']);\n\t\t$expenceFloatFormat = floatval($expenceAmountCommaReplacement);\n\t\t$userId = $user->id;\n\t\t$cathegory_assigned_to_user = $data['expenceCat'];\n\t\t$paymentWay = $data['payment'];\n\t\t$dateValue = $data['dateExpence'];\n\t\t\n\t\t$db = static::getDB();\n\t\t\n\t\t$comment = htmlspecialchars($data['commentExpence']);\n\n\t\t$insert_expence_query = $db->exec(\"INSERT INTO expenses VALUES(NULL, '$userId', '$cathegory_assigned_to_user', '$paymentWay', '$expenceFloatFormat','$dateValue','$comment')\");\n\t\t\n\t\tif($insert_expence_query > 0) return true;\n\t\telse return false;\n\t}", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "private function set_participant_as_captain($event, $user){\n\n\t\tif($event->event_type === 'multifacility'){\n\t\t\tEventTeamUser::where('event_id', '=', $event->id)->where('captain', '=', 1)->update(array(\n\t\t\t\t'captain' => 0\n\t\t\t));\n\t\t}\n\t\t$event_team_user = EventTeamUser::where('event_id', '=', $event->id)->where('user_id', '=', $user->id)->get();\n\t\tif($event_team_user->count() > 0){\n\t\t\t$event_team_user->first()->update(array(\n\t\t\t\t'captain' => 1\n\t\t\t));\n\t\t}\n\t\telse{\n\t\t\t$this->create_event_team_user($event->id, null, null, $user->sex, $user->id, 1);\n\t\t}\n\n\t}", "function addCompetency($table, $prodid)\n {\n $db = atkGetDb();\n //before we do anything we will check if this user realy may delete items otherwise we will do nothing\n $node = atkGetNode('competency.competencymatch');\n $userId = $_GET['userId'];\n if ($this->acl->allowCompetencyChange($userId))\n {\n $niveau = \"\";\n $competency = \"\";\n $compNiveau = $this->getCompetencyNiveau($prodid);\n switch ($table)\n {\n case \"competency\":\n $niveau = - 1;\n $competency = $prodid;\n break;\n case \"niveau\":\n $niveau = $prodid;\n $competency = $compNiveau[\"id\"];\n break;\n default:\n break;\n }\n //we check if we added a competency with a different date then today\n if ($this->date == \"undefined\")\n {\n $date = date(\"Y-m-d\");\n }\n else\n {\n $date = $this->date;\n }\n $node = getNode('competency.competences');\n $node->getAttribute(\"person_id\");\n $node->getAttribute(\"niveau_id\");\n $node->getAttribute(\"added\");\n $node->getAttribute(\"competency_id\");\n if ($table == \"niveau\")\n {\n $query = $db->createQuery();\n $query->addTable(\"competency_niveau\");\n $query->addCondition(\"level <\" . $compNiveau[\"level\"]);\n $query->addCondition(\"competency_id =\" . $compNiveau[\"id\"]);\n $query->addCondition(\"id NOT IN(SELECT niveau_id FROM competency_competences WHERE competency_id='\" . $db->escapeSQL($competency) . \"' AND person_id='\" . $db->escapeSQL($userId) . \"')\");\n $query->addField(\"id\");\n $niveaus = $db->getrows($query->buildselect());\n foreach ($niveaus as $niv)\n {\n $dataRec['person_id'] = $userId;\n $dataRec[\"competency_id\"] = $competency;\n $dataRec[\"niveau_id\"] = $niv[id];\n $dataRec[\"added\"] = $date;\n $node->validate($dataRec, 'insert');\n $node->addDb($dataRec);\n atkGetDB()->commit();\n }\n }\n $dataRec['person_id'] = $userId;\n $dataRec[\"competency_id\"] = $competency;\n $dataRec[\"niveau_id\"] = $niveau;\n $dataRec[\"added\"] = $date;\n $node->validate($dataRec, 'insert');\n $node->addDb($dataRec);\n atkGetDB()->commit();\n }\n }", "private function add_or_update_user_event_substitute_record($event, $user_id){\n\n\t\t$all_participants = $this->get_all_participants($event->id);\n\t\t$participant = $all_participants->filter(function($participant)use($user_id){\n\t\t\treturn $participant->id == $user_id;\n\t\t})->first();\n\t\tif($participant){\n\t\t\t$event->users()->updateExistingPivot($user_id, array(\n\t\t\t\t'substitute' => 1,\n\t\t\t\t'unavailable' => 0\n\t\t\t));\n\t\t\t$status = 'unavailable';\n\t\t}\n\t\telse{\n\t\t\t$event->users()->sync(array(\n\t\t\t\t$user_id => array(\n\t\t\t\t\t'confirmed' => 0,\n\t\t\t\t\t'waitlisted' => 0,\n\t\t\t\t\t'substitute' => 1,\n\t\t\t\t\t'unavailable' => 0\n\t\t\t\t)\n\t\t\t), false);\n\t\t\t$status = 'available';\n\t\t}\n\t\treturn $status;\n\n\t}", "public function test_set_ruleoutcome_course_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $course = $dg->create_course();\n\n $this->setAdminUser();\n $f = $lpg->create_framework();\n $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id')));\n $cc = api::add_competency_to_course($course->id, $c->get('id'));\n\n // Check record was created with default rule value Evidence.\n $this->assertEquals(1, \\core_competency\\course_competency::count_records());\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_EVIDENCE,\n $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n\n // Check ruleoutcome value is updated to None.\n $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),\n \\core_competency\\course_competency::OUTCOME_NONE));\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n }", "public function can_add_expense()\n {\n $expense=new IncomeExpense;\n $newexpense=$expense->newExpense(1,\"dashboard printer\",4000,\"very costful printer\");\n\n $this->assertDatabaseHas(\"income\", [\n \"expense_category\" => 1,\n \"expense_title\" => \"dashboard printer\",\n \"amount\"=>4000,\n \"notes\"=>\"very costful printer\"\n ]);\n }", "function testEnrolments() {\n $url = $this->_getURL('/v1/courses/3/users');\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3'),\n );\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a non-existent user\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0099', 'role_id' => 5)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // Add a student to a course\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5)\n );\n $expected = array(array('username' => 'redshirt0005', 'role_id' => 5));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a duplicate student to a course\n $input = array_merge($input, array(array('username' => 'redshirt0029', 'role_id' => 5)));\n $expected = array();\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add an instructor to a course\n $input[] = array('username' => 'instructor2', 'role_id' => 3);\n $expected = array(array('username' => 'instructor2', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add an instructor with duplicate usernames to a course\n $input = array_merge($input, array(array('username' => 'instructor1', 'role_id' => 3),\n array('username' => 'INStructor1', 'role_id' => 3)));\n $expected = array(array('username' => 'instructor1', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a tutor to a course\n $input[] = array('username' => 'tutor2', 'role_id' => 4);\n $expected = array(array('username' => 'tutor2', 'role_id' => 4));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // update course enrolment - remove instructor1\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor2', 'role_id' => 3),\n array('username' => 'tutor2', 'role_id' => 4)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // check enrolment\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '9', 'role_id' => '5', 'username' => 'redshirt0005'),\n array('id' => '3', 'role_id' => '3', 'username' => 'instructor2'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '36', 'role_id' => '4', 'username' => 'tutor2'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3')\n );\n $this->assertEqual(json_decode($actual, true), $expected);\n\n // update course enrolment - remove instructor1\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor2', 'role_id' => 3),\n array('username' => 'tutor2', 'role_id' => 4)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // check enrolment\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '9', 'role_id' => '5', 'username' => 'redshirt0005'),\n array('id' => '3', 'role_id' => '3', 'username' => 'instructor2'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '36', 'role_id' => '4', 'username' => 'tutor2'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3')\n );\n $this->assertEqual(json_decode($actual, true), $expected);\n\n // Remove a student from a course\n $expected = array(array('username' => 'redshirt0005', 'role_id' => 5));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Remove an instructor from a course\n $expected = array(array('username' => 'instructor2', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Remove a tutor from a course\n $expected = array(array('username' => 'tutor2', 'role_id' => 4));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n }", "public function addAttendeeToEvent($data) {\n try {\n $queryString = \"insert into attendee_event(event, attendee, paid) values (:event, :attendee, :paid)\";\n $stmt = $this->dbh->prepare($queryString);\n $stmt->execute(\n [\n \"event\" => $data['addEventAssoc'],\n \"attendee\" => $data['addUserID'],\n \"paid\" => $data['addEventPaid']\n ]\n );\n return $stmt->rowCount();\n }\n catch(PDOException $e) {\n exit();\n }\n }", "function addCompetencesAction()\n {\n $item = explode(\"!\", $_GET['compId']);\n $table = $item[0];\n $prodid = $item[1];\n //we check if we got a competency id and if we got one we check in the database if the competency already exists for this user\n if (isset($_GET['compId']) && $this->checkDatabase($table, $prodid))\n {\n $this->addCompetency($table, $prodid);\n }\n }", "static function createNewUserRecords($a_user_id, $a_exc_id)\n\t{\n\t\tglobal $ilDB;\n\t\t\n\t\t$ass_data = ilExAssignment::getAssignmentDataOfExercise($a_exc_id);\n\t\tforeach ($ass_data as $ass)\n\t\t{\n//echo \"-\".$ass[\"id\"].\"-\".$a_user_id.\"-\";\n\t\t\t$ilDB->replace(\"exc_mem_ass_status\", array(\n\t\t\t\t\"ass_id\" => array(\"integer\", $ass[\"id\"]),\n\t\t\t\t\"usr_id\" => array(\"integer\", $a_user_id)\n\t\t\t\t), array(\n\t\t\t\t\"status\" => array(\"text\", \"notgraded\")\n\t\t\t\t));\n\t\t}\n\t}", "public function testAddVictoruies() {\n $player = new Player();\n $victoriesBeforeAdd = $player->getVictories();\n\n $player->addVictory();\n $this->assertTrue(($victoriesBeforeAdd + 1) === $player->getVictories());\n }", "public function testCanCreateEventSaveAndRetrieve()\n\t{\n\t\t// echo \"\\nEvent Test...\\n\";\n\t\t\n \t$faker = \\Faker\\Factory::create();\n\n\t\t$user = parent::createFakeUserWithFakeHousehold();\n\t\t// print_r( $user );\n\n\t\t$newevent = new \\Models\\Event();\t\t\n $newevent->title = ucwords($faker->bs);\n $newevent->description = $faker->text;\n $newevent->location = $faker->address;\n $newevent->event_date = $faker->date;\n $newevent->start_time = $faker->time($format = 'H:i:s');\n $newevent->end_time = $faker->time($format = 'H:i:s');\n $newevent->all_day = $faker->boolean;\n $newevent->notify = $faker->boolean;\n $newevent->minutes_before = $faker->randomDigitNotNull;\n $newevent->type = 'travel';\n\n $newevent->setOwner( $user );\n \n //Add Attendees\n \t// $attendees = \\Models\\User::where('id','!=',$user->id)->take(5)->get();\n \tfor($i = 0; $i < 2; $i++){\n \t\t$attendee = parent::createFakeUser( $user->household );\n \t\t// print_r($attendee);\n \t\t$newevent->addAttendee($attendee);\n \t}\n\n\t\t$id = $newevent->id;\n\n\t\t// Add Tags\n\t\t$tag1 = parent::createFakeTag( $user );\n\t\t$newevent->addTag( $tag1 );\n\n\t\t$tag2 = parent::createFakeTag( $user );\n\t\t$newevent->addTag( $tag2 );\n\n\t\t//get Event from database\n\t\t$found = \\Models\\Event::with('tags')->where('id', '=', $id)->firstOrFail();\n\t\t\n\t\t$this->assertTrue($found->id == $id);\n\n\t\t// Test Event\n\t\t$this->assertTrue($found->id == $newevent->id);\t\t\n\t\t$this->assertTrue($found->title == $newevent->title);\n\t\t$this->assertTrue($found->description == $newevent->description);\n\t\t$this->assertTrue($found->location == $newevent->location);\n\t\t$this->assertTrue($found->event_date == $newevent->event_date);\n\t\t$this->assertTrue($found->event_start_time == $newevent->event_start_time);\n\t\t$this->assertTrue($found->event_end_time == $newevent->event_end_time);\n\t\t$this->assertTrue($found->all_day == $newevent->all_day);\n\t\t$this->assertTrue($found->notify == $newevent->notify);\n\t\t$this->assertTrue($found->minutes_before == $newevent->minutes_before);\n\t\t$this->assertTrue($found->type == $newevent->type);\n\n\t\t//Test User\t\n\t\t$this->assertTrue($found->owner->id == $newevent->owner_id);\n\n\t\t//Test Attendees\n\t\t$this->assertTrue(count($found->attendees) == 2);\n\n\t\t//Test Tags\n\t\t$this->assertTrue(count($found->tags) == 2);\n\n\t\t// echo \"\\nEvent Test: User Id: \" . $user->id;\n\t\t// echo \"\\nEvent Test: User Household Id: \" . $user->household->id . \"\\n\";\n\t\t\n\t\t// Delete\n\t\t$this->assertTrue( $found->delete() );\n\n\t}", "public function test_venue_can_upload_his_profile()\n {\n $venue = User::factory()->create(['role' => 'venue']);\n\n $this->actingAs($venue)\n ->put( 'venue.update', [\n 'organization' => 'My Organization',\n ] );\n\n $this->assertDatabaseHas('users', ['organization' => 'My Organization']);\n }", "public function test_inviting_a_user_to_a_company()\n {\n $company = Company::factory()->create();\n //Need to attach the company to the user\n $company->users()->attach($company->user_id);\n\n $faker = Faker::create();\n $this->browse(function (Browser $browser) use ($faker, $company) {\n $browser\n ->visit('/signin')\n ->type('username', $company->owner->email)\n ->type('password', 'secret')\n ->press('SIGN IN')\n ->assertPathIs('/' . $company->domain_name . '/dashboard')\n ->visit('/' . $company->domain_name . '/company/users')\n ->clickLink('Invite User')\n ->type('#email_0', $faker->unique()->safeEmail);\n $browser->script('jQuery(\"#roles_0\").selectize()[0].selectize.setValue(\"user\");');\n $browser\n ->press('INVITE')\n ->assertPresent('#users-table')\n ->assertPathIs('/' . $company->domain_name . '/company/users');\n $browser->script('jQuery(\".signmeout-btn\").click()');\n $browser->assertPathIs('/');\n });\n }", "public function testSaveWithAdvertising()\n {\n $this->expectHMSet();\n $this->expectAddEvent();\n $this->runSave(true);\n }", "public function enroll_user_to_course_builds_views(\\ApiTester $I){\n $userData1 = [\n 'forename' => 'Jane',\n 'surname' => 'Awesome',\n ];\n $userData2 = [\n 'forename' => 'Danny',\n 'surname' => 'Cool',\n ];\n $courseData1 = [\n 'title' => 'Course 1',\n 'course_code' => 'course_1'\n ];\n $courseData2 = [\n 'title' => 'Course 1',\n 'course_code' => 'course_1'\n ];\n $I->amHttpAuthenticated('service_user', '123456');\n $I->haveHttpHeader('Content-Type', 'application/json');\n $I->addNewUser($userData1);\n $userId1 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addNewUser($userData2);\n $userId2 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addCourse($courseData1);\n $courseId1 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addCourse($courseData2);\n $courseId2 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n\n // Enroll just one user and check the views\n $this->enrollSingleUser($I, $courseId1, $userId1);\n\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n ]); // Nobody should be on this course\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n ]); // This user should not be enrolled\n\n // Enroll a Second user and check the views\n $this->enrollSingleUser($I, $courseId1, $userId2);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1,\n $userId2 => $userData2\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n ]); // Nobody should be on this course\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n\n // Enroll a user to a different course and ensure only that user\n // is on the course\n $this->enrollSingleUser($I, $courseId2, $userId1);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1,\n $userId2 => $userData2\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n $userId1 => $userData1,\n ]);\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1,\n $courseId2 => $courseData2\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n\n // Update a user's data and ensure all views correctly update\n $userData1Updated = [\n 'forename' => 'Stupendous',\n 'surname' => 'Ralph'\n ];\n $I->updateUser($userId1, $userData1Updated);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1Updated,\n $userId2 => $userData2,\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n $userId1 => $userData1Updated,\n ]);\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1,\n $courseId2 => $courseData2\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n }", "public function testDoAddUser() {\n\t\t$result = $this->testAction ( '/EditUser/doAddUser' );\n\t\tdebug ( $result );\n\t}", "public function add( Entity $user ) {\n\t}", "protected function add_experience(){\n\t\t$input=Input::all();\n\t\t//input\n\t\t$user_id=$input['user_id'];\n\t\t\n\t\tif(isset($input['experience_tags']))\n\t\t\t$experience_tags=explode(',', $input['experience_tags']);\n\t\telse\n\t\t\t$experience_tags=array();\n\n\t\t$user_description=$input['user_description'];\n\t\t$pdo=DB::connection()->getPdo();\n\n\n\t\t$query = $pdo->prepare(\"SELECT * FROM experience WHERE user_id=:user_id ORDER BY created_at DESC\");\n\t\t$query->bindParam(':user_id', $user_id);\n\t\t$query->execute();\n\t\t$experience=$query->fetch();\n\n\t\tif(!$experience){\n\t\t\t$sql=$pdo->prepare(\"INSERT INTO experience (user_id,description,created_at) VALUES (:user_id,:user_description,NOW())\");\n\t\t\t$sql->bindParam(':user_id',$user_id);\n\t\t\t$sql->bindParam(':user_description',$user_description);\n\t\t\t$sql->execute();\n\t\t\t$experience_id=$pdo->lastInsertId();\n\n\t\t\tforeach ($experience_tags as $tag) {\n\t\t\t\t$tag=substr($tag, 1);\n\t\t\t\t$query = $pdo->prepare(\"SELECT tag_id FROM tag WHERE tag_name = :tag\");\n\t\t\t\t$query->bindParam(':tag', $tag);\n\t\t\t\t$query->execute();\n\t\t\t\t$row=$query->fetchAll();\n\t\t\t\t$tag_id=-1;\n\t\t\t\tif(!$row){\n\t\t\t\t\t$sql=$pdo->prepare(\"INSERT INTO tag (tag_name,tag_description) VALUES (:tag,'')\");\n\t\t\t\t\t$sql->bindParam(':tag', $tag);\n\t\t\t\t\t$sql->execute();\n\t\t\t\t\t$tag_id=$pdo->lastInsertId();\t\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$tag_id=$row[0]['tag_id'];\n\t\t\t\t}\n\t\t\t\t$sql=$pdo->prepare(\"INSERT INTO experience_tag (experience_id,tag_id) VALUES (:experience_id,:tag_id)\");\n\t\t\t\t$sql->bindParam(':experience_id', $experience_id);\n\t\t\t\t$sql->bindParam(':tag_id', $tag_id);\n\t\t\t\t$sql->execute();\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\t$query=$pdo->prepare(\"UPDATE experience SET description=:user_description WHERE user_id=:user_id\");\n\n\t\t\t$query->bindParam(':user_id', $user_id);\n\t\t\t$query->bindParam(':user_description', $user_description);\n\t\t\t$query->execute();\n\n\t\t\t$experience_id=$experience['experience_id'];\n\t\t\t$sql=\"DELETE FROM experience_tag WHERE experience_id=\".$experience_id;\n\t\t\t$pdo->exec( $sql );\n\t\t\tforeach ($experience_tags as $tag) {\n\t\t\t\t$tag=substr($tag, 1);\n\t\t\t\t$query = $pdo->prepare(\"SELECT tag_id FROM tag WHERE tag_name = :tag\");\n\t\t\t\t$query->bindParam(':tag', $tag);\n\t\t\t\t$query->execute();\n\t\t\t\t$row=$query->fetch();\n\t\t\t\t$tag_id=-1;\n\t\t\t\tif(!$row){\n\t\t\t\t\t$sql=$pdo->prepare(\"INSERT INTO tag (tag_name,tag_description) VALUES (:tag,'')\");\n\t\t\t\t\t$sql->bindParam(':tag', $tag);\n\t\t\t\t\t$sql->execute();\n\t\t\t\t\t$tag_id=$pdo->lastInsertId();\t\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t$tag_id=$row['tag_id'];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t \n\t\t\t\t$sql=$pdo->prepare(\"INSERT INTO experience_tag (experience_id,tag_id) VALUES (:experience_id,:tag_id)\");\n\t\t\t\t$sql->bindParam(':experience_id', $experience_id);\n\t\t\t\t$sql->bindParam(':tag_id', $tag_id);\n\t\t\t\t$sql->execute();\n\n\n\t\t\t}\t\t\t\n\t\t}\n\t\treturn 'ok';\n\n\t}", "function add_to_team($user_id,$tl_id) {\n\n //Make sure the user is not a team leader\n if (check_supervisor($user_id))\n $_SESSION['notifications'][] = \"That user is a team leader!\";\n\n //If not, do things.\n else {\n //If he's already part of a team, drop him from that team.\n if (!is_orphan($user_id))\n remove_from_team($user_id);\n $sql = \"INSERT INTO teams (tl_id,user_id) VALUES (\".$tl_id.','.$user_id.\")\";\n $_SESSION['dbconn']->query($sql) or die(\"Error adding to team: \".$_SESSION['dbconn']->error);\n $_SESSION['notifications'][] = \"Added user to team\";\n }\n}", "function addelifeImprov()\n\t{\n\t\t$this->load->model('Surveymodel');\n\t\t$this->Surveymodel->insert_lifeImprovement();\n\t\t\n\t}", "public function testAddReview()\n {\n // @see https://symfony.com/doc/current/testing.html#logging-in-users-authentication\n $client = static::createClient();\n \n $userRepository = static::$container->get(UserRepository::class);\n\n // retrieve the test user\n $testUser = $userRepository->findOneByEmail('[email protected]');\n\n // simulate $testUser being logged in\n $client->loginUser($testUser);\n\n // test e.g. the profile page\n $client->request('GET', '/review/add');\n $this->assertResponseIsSuccessful();\n $this->assertSelectorTextContains('h1', 'Connexion');\n }", "public static function get_user_competencies_by_userevidenceid($userevidenceid) {\n global $DB;\n\n $sql = \"SELECT uc.*\n FROM {\" . user_competency::TABLE . \"} uc\n JOIN {\" . self::TABLE . \"} uec\n ON uc.competencyid = uec.competencyid\n JOIN {\" . user_evidence::TABLE . \"} ue\n ON uec.userevidenceid = ue.id\n AND uc.userid = ue.userid\n AND ue.id = ?\n ORDER BY uc.id ASC\";\n\n $usercompetencies = array();\n $records = $DB->get_recordset_sql($sql, array($userevidenceid));\n foreach ($records as $record) {\n $usercompetencies[] = new user_competency(0, $record);\n }\n $records->close();\n return $usercompetencies;\n }" ]
[ "0.79999447", "0.68535554", "0.68386155", "0.6567731", "0.6226532", "0.6139708", "0.57810277", "0.55717814", "0.5544279", "0.54525375", "0.5380609", "0.5263708", "0.52389705", "0.51767904", "0.51756185", "0.5132443", "0.5126634", "0.51179874", "0.50511444", "0.50494605", "0.5015019", "0.50059664", "0.49883878", "0.49878234", "0.497573", "0.49628732", "0.49303257", "0.49010348", "0.48801386", "0.48745033" ]
0.82371485
0
Test add evidence for nonexisting user_competency.
public function test_add_evidence_no_existing_user_competency() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create users. $user = $dg->create_user(); $this->setUser($user); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $this->assertEquals(0, \core_competency\user_competency::count_records()); // Create an evidence without a user competency record. $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \core_competency\evidence::ACTION_OVERRIDE, 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2); $this->assertEquals(1, \core_competency\evidence::count_records()); $this->assertEquals(1, \core_competency\user_competency::count_records()); $uc = \core_competency\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id'))); $evidence->read(); $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid')); $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier')); $this->assertEquals('core_competency', $evidence->get('desccomponent')); $this->assertEquals('Hello world!', $evidence->get('desca')); $this->assertEquals('http://moodle.org', $evidence->get('url')); $this->assertEquals(\core_competency\evidence::ACTION_OVERRIDE, $evidence->get('action')); $this->assertEquals(2, $evidence->get('actionuserid')); $this->assertEquals(1, $evidence->get('grade')); $this->assertEquals(1, $uc->get('grade')); $this->assertEquals(0, $uc->get('proficiency')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "public function testIfAttendanceIsCreatedWhenUserIsAddedToTeam()\n {\n /** FIRST LET'S CREATE SOME TEAM WITH SCHEDULE */\n\n $team = $this->createTestTeam(__FUNCTION__);\n\n /** LET'S ADD NEW USER TO TEAM */\n\n $newUser = new User();\n $newUser\n ->setEmail('user.' . strtolower(__FUNCTION__) . rand() . '@example.com')\n ->setPlainPassword(__FUNCTION__);\n\n $team->addUser($newUser);\n\n $this->em()->persist($team);\n $this->em()->flush();\n\n /** ATTENDANCES SHOULD BE CREATED */\n\n $attendances = $this->getRepo('AttendeeApiBundle:Attendance')->findBy(array(\n 'user' => $newUser\n ));\n\n $this->assertEquals(7, count($attendances), 'New user should have some attendances.');\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function testCannotPutOtherUsersExhibits()\n {\n $this->_setPut(array());\n $this->dispatch('neatline/exhibits/'.$this->exhibit->id);\n $this->assertAction('forbidden');\n }", "public function an_user_who_isnt_in_list_cant_generate_petition()\n {\n\n //1. Given -> Teniendo un usuario\n $user = factory(User::class)->make([\n 'ID' => 'V'.random_int(1000000,20000000)\n ]);\n $petition = factory(Petition::class)->make([\n 'ID_user' => $user->ID,\n ]);\n\n $this->browse(function (Browser $browser) use($user,$petition) {\n\n //Se divide la CI de la nacionalidad por formato de planilla HTML\n $ID = substr($user->ID, 1);\n $nationality = substr($user->ID, 0 , 1);\n\n $test=$browser->visit(route('petitions'))\n ->select('nationality',$nationality)\n ->type('ID', $ID )\n ->click('#name')\n ->pause(2000)\n ->type('name', $user->name)\n ->type('email', $user->email)\n ->select('request_type', $petition->request_type)\n ->select('area',$user->area)\n ->press('#Enviar')\n ->assertSee('La CI '. $user->ID. ' no aparece en la lista de usuarios, por favor comunicarse con la escuela de sistema')\n ->assertUrlIs(\"http://tesis.test/Solicitud\");\n });\n\n }", "public function testAddVoucherNonExistingVoucher()\n {\n modConfig::getInstance()->setConfigParam( 'blEnterNetPrice', true );\n // deleting discounts\n foreach ( $this->aDiscounts as $oDiscount )\n $oDiscount->delete();\n\n $oBasket = new oxbasket();\n $oBasket->addToBasket( $this->oArticle->getId(), 10 );\n $oBasket->addToBasket( $this->oVariant->getId(), 10 );\n $oBasket->calculateBasket( false );\n $oBasket->addVoucher( '_xxx' );\n $this->assertEquals( 0, count( $oBasket->getVouchers() ) );\n }", "public static function addNewExpense($data, $user){\n\t\t$expenceAmountCommaReplacement = str_replace(',','.',$data['expenceAmount']);\n\t\t$expenceFloatFormat = floatval($expenceAmountCommaReplacement);\n\t\t$userId = $user->id;\n\t\t$cathegory_assigned_to_user = $data['expenceCat'];\n\t\t$paymentWay = $data['payment'];\n\t\t$dateValue = $data['dateExpence'];\n\t\t\n\t\t$db = static::getDB();\n\t\t\n\t\t$comment = htmlspecialchars($data['commentExpence']);\n\n\t\t$insert_expence_query = $db->exec(\"INSERT INTO expenses VALUES(NULL, '$userId', '$cathegory_assigned_to_user', '$paymentWay', '$expenceFloatFormat','$dateValue','$comment')\");\n\t\t\n\t\tif($insert_expence_query > 0) return true;\n\t\telse return false;\n\t}", "private function add_or_update_user_event_substitute_record($event, $user_id){\n\n\t\t$all_participants = $this->get_all_participants($event->id);\n\t\t$participant = $all_participants->filter(function($participant)use($user_id){\n\t\t\treturn $participant->id == $user_id;\n\t\t})->first();\n\t\tif($participant){\n\t\t\t$event->users()->updateExistingPivot($user_id, array(\n\t\t\t\t'substitute' => 1,\n\t\t\t\t'unavailable' => 0\n\t\t\t));\n\t\t\t$status = 'unavailable';\n\t\t}\n\t\telse{\n\t\t\t$event->users()->sync(array(\n\t\t\t\t$user_id => array(\n\t\t\t\t\t'confirmed' => 0,\n\t\t\t\t\t'waitlisted' => 0,\n\t\t\t\t\t'substitute' => 1,\n\t\t\t\t\t'unavailable' => 0\n\t\t\t\t)\n\t\t\t), false);\n\t\t\t$status = 'available';\n\t\t}\n\t\treturn $status;\n\n\t}", "function addCompetency($table, $prodid)\n {\n $db = atkGetDb();\n //before we do anything we will check if this user realy may delete items otherwise we will do nothing\n $node = atkGetNode('competency.competencymatch');\n $userId = $_GET['userId'];\n if ($this->acl->allowCompetencyChange($userId))\n {\n $niveau = \"\";\n $competency = \"\";\n $compNiveau = $this->getCompetencyNiveau($prodid);\n switch ($table)\n {\n case \"competency\":\n $niveau = - 1;\n $competency = $prodid;\n break;\n case \"niveau\":\n $niveau = $prodid;\n $competency = $compNiveau[\"id\"];\n break;\n default:\n break;\n }\n //we check if we added a competency with a different date then today\n if ($this->date == \"undefined\")\n {\n $date = date(\"Y-m-d\");\n }\n else\n {\n $date = $this->date;\n }\n $node = getNode('competency.competences');\n $node->getAttribute(\"person_id\");\n $node->getAttribute(\"niveau_id\");\n $node->getAttribute(\"added\");\n $node->getAttribute(\"competency_id\");\n if ($table == \"niveau\")\n {\n $query = $db->createQuery();\n $query->addTable(\"competency_niveau\");\n $query->addCondition(\"level <\" . $compNiveau[\"level\"]);\n $query->addCondition(\"competency_id =\" . $compNiveau[\"id\"]);\n $query->addCondition(\"id NOT IN(SELECT niveau_id FROM competency_competences WHERE competency_id='\" . $db->escapeSQL($competency) . \"' AND person_id='\" . $db->escapeSQL($userId) . \"')\");\n $query->addField(\"id\");\n $niveaus = $db->getrows($query->buildselect());\n foreach ($niveaus as $niv)\n {\n $dataRec['person_id'] = $userId;\n $dataRec[\"competency_id\"] = $competency;\n $dataRec[\"niveau_id\"] = $niv[id];\n $dataRec[\"added\"] = $date;\n $node->validate($dataRec, 'insert');\n $node->addDb($dataRec);\n atkGetDB()->commit();\n }\n }\n $dataRec['person_id'] = $userId;\n $dataRec[\"competency_id\"] = $competency;\n $dataRec[\"niveau_id\"] = $niveau;\n $dataRec[\"added\"] = $date;\n $node->validate($dataRec, 'insert');\n $node->addDb($dataRec);\n atkGetDB()->commit();\n }\n }", "public function an_user_cannot_generation_petition_without_email()\n {\n //1. Given -> Teniendo un usuario\n $user = factory(User::class)->make([\n 'area' => random_int(1,3)\n ]);\n $petition = factory(Petition::class)->make([\n 'ID_user' => $user->ID,\n ]);\n\n $this->browse(function (Browser $browser) use($user,$petition) {\n\n //Se divide la CI de la nacionalidad por formato de planilla HTML\n $ID = substr($user->ID, 1);\n $nationality = substr($user->ID, 0 , 1);\n\n $browser->visit(route('petitions'))\n ->select('nationality',$nationality)\n ->type('ID', $ID)\n ->type('name', $user->name)\n ->type('email', \"\")\n ->select('request_type', $petition->request_type)\n ->select('area',$user->area)\n ->press('#Enviar')\n ->assertDontSee('Email envíado correctamente a: '.$user->email)\n ->assertUrlIs(\"http://tesis.test/Solicitud\");\n\n });\n }", "private function set_participant_as_captain($event, $user){\n\n\t\tif($event->event_type === 'multifacility'){\n\t\t\tEventTeamUser::where('event_id', '=', $event->id)->where('captain', '=', 1)->update(array(\n\t\t\t\t'captain' => 0\n\t\t\t));\n\t\t}\n\t\t$event_team_user = EventTeamUser::where('event_id', '=', $event->id)->where('user_id', '=', $user->id)->get();\n\t\tif($event_team_user->count() > 0){\n\t\t\t$event_team_user->first()->update(array(\n\t\t\t\t'captain' => 1\n\t\t\t));\n\t\t}\n\t\telse{\n\t\t\t$this->create_event_team_user($event->id, null, null, $user->sex, $user->id, 1);\n\t\t}\n\n\t}", "public function testGetRecommendationThrownAnExceptionOnUserWithNoPrimaryKey() {\n\t\t$this->User->getRecommendation();\n\t}", "public function testCreateOfficialsSurveyFailSurveyExists()\n {\n $communityId = 5;\n $survey = $this->surveys->find()->where(['type' => 'official'])->first();\n $survey->community_id = $communityId;\n $this->surveys->save($survey);\n $this->assertUnalertable($communityId, \"createOfficialsSurvey\");\n }", "public function an_user_cannot_generation_petition_without_ID()\n {\n //1. Given -> Teniendo un usuario\n $user = factory(User::class)->make([\n 'area' => random_int(1,3)\n ]);\n $petition = factory(Petition::class)->make([\n 'ID_user' => $user->ID,\n ]);\n\n $this->browse(function (Browser $browser) use($user,$petition) {\n\n //Se divide la CI de la nacionalidad por formato de planilla HTML\n $ID = substr($user->ID, 1);\n $nationality = substr($user->ID, 0 , 1);\n\n $browser->visit(route('petitions'))\n ->select('nationality',$nationality)\n ->type('ID', \"\" )\n ->type('name', $user->name)\n ->type('email', $user->email)\n ->select('request_type', $petition->request_type)\n ->select('area',$user->area)\n ->press('#Enviar')\n ->assertDontSee('Email envíado correctamente a: '.$user->email)\n ->assertUrlIs(\"http://tesis.test/Solicitud\");\n\n });\n }", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "public function an_user_cannot_generation_petition_without_name()\n {\n //1. Given -> Teniendo un usuario\n $user = factory(User::class)->make([\n 'area' => random_int(1,3)\n ]);\n $petition = factory(Petition::class)->make([\n 'ID_user' => $user->ID,\n ]);\n\n $this->browse(function (Browser $browser) use($user,$petition) {\n\n //Se divide la CI de la nacionalidad por formato de planilla HTML\n $ID = substr($user->ID, 1);\n $nationality = substr($user->ID, 0 , 1);\n\n $test=$browser->visit(route('petitions'))\n ->select('nationality',$nationality)\n ->type('ID', $ID )\n ->click('#name')\n ->pause(2000)\n ->type('name', \"\")\n ->type('email', $user->email)\n ->select('request_type', $petition->request_type)\n ->select('area',$user->area)\n ->press('#Enviar')\n ->assertDontSee('Email envíado correctamente a: '.$user->email)\n ->assertUrlIs(\"http://tesis.test/Solicitud\");\n });\n }", "function addCompetencesAction()\n {\n $item = explode(\"!\", $_GET['compId']);\n $table = $item[0];\n $prodid = $item[1];\n //we check if we got a competency id and if we got one we check in the database if the competency already exists for this user\n if (isset($_GET['compId']) && $this->checkDatabase($table, $prodid))\n {\n $this->addCompetency($table, $prodid);\n }\n }", "public function an_user_cannot_generation_petition_with_email_no_ula()\n {\n //1. Given -> Teniendo un usuario\n $user = factory(User::class)->make([\n 'area' => random_int(1,3)\n ]);\n $petition = factory(Petition::class)->make([\n 'ID_user' => $user->ID,\n ]);\n\n $this->browse(function (Browser $browser) use($user,$petition) {\n\n //Se divide la CI de la nacionalidad por formato de planilla HTML\n $ID = substr($user->ID, 1);\n $nationality = substr($user->ID, 0 , 1);\n //Se crea un Faker para emular datos incorrectos\n $faker = Faker::create();\n\n $browser->visit(route('petitions'))\n ->select('nationality',$nationality)\n ->type('ID', $ID)\n ->type('name', $user->name)\n ->type('email', $faker->unique()->safeEmail)\n ->select('request_type', $petition->request_type)\n ->select('area',$user->area)\n ->press('#Enviar')\n ->assertDontSee('Email envíado correctamente a: '.$user->email)\n ->assertUrlIs(\"http://tesis.test/Solicitud\");\n\n });\n }", "public function test_set_ruleoutcome_course_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $course = $dg->create_course();\n\n $this->setAdminUser();\n $f = $lpg->create_framework();\n $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id')));\n $cc = api::add_competency_to_course($course->id, $c->get('id'));\n\n // Check record was created with default rule value Evidence.\n $this->assertEquals(1, \\core_competency\\course_competency::count_records());\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_EVIDENCE,\n $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n\n // Check ruleoutcome value is updated to None.\n $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),\n \\core_competency\\course_competency::OUTCOME_NONE));\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n }", "public function testGetInvalidEventByEventCategoryId(): void {\n\t\t//grab a profile id that exceeds the max allowable profile Id\n\t\t$event = Event::getEventByEventCategoryId($this->getPDO(), generateUuidV4());\n\t\t$this->assertCount(0, $event);\n\t}", "function reportAsSuitable($user)\n {\n $this->_reaktorfile->setReported(0);\n $this->_reaktorfile->setMarkedUnsuitable(0);\n $this->_reaktorfile->save();\n \n HistoryPeer::logAction(2, $user, $this); \n }", "function reportAsUnsuitable($user)\n {\n $this->_reaktorfile->setReported($this->_reaktorfile->getReported() + 1);\n $this->_reaktorfile->setTotalReportedEver($this->_reaktorfile->getTotalReportedEver() + 1);\n $this->_reaktorfile->setReportedAt(time());\n $this->_reaktorfile->save();\n \n HistoryPeer::logAction(1, $user, $this);\n }", "function add_to_team($user_id,$tl_id) {\n\n //Make sure the user is not a team leader\n if (check_supervisor($user_id))\n $_SESSION['notifications'][] = \"That user is a team leader!\";\n\n //If not, do things.\n else {\n //If he's already part of a team, drop him from that team.\n if (!is_orphan($user_id))\n remove_from_team($user_id);\n $sql = \"INSERT INTO teams (tl_id,user_id) VALUES (\".$tl_id.','.$user_id.\")\";\n $_SESSION['dbconn']->query($sql) or die(\"Error adding to team: \".$_SESSION['dbconn']->error);\n $_SESSION['notifications'][] = \"Added user to team\";\n }\n}", "public function an_user_cannot_generation_petition_with_bad_ID()\n {\n //1. Given -> Teniendo un usuario\n $user = factory(User::class)->make([\n 'area' => random_int(1,3)\n ]);\n $petition = factory(Petition::class)->make([\n 'ID_user' => $user->ID,\n ]);\n\n $this->browse(function (Browser $browser) use($user,$petition) {\n\n //Se divide la CI de la nacionalidad por formato de planilla HTML\n $ID = substr($user->ID, 1);\n $nationality = substr($user->ID, 0 , 1);\n\n $browser->visit(route('petitions'))\n ->select('nationality',$nationality)\n ->type('ID', random_int(0,999999) )\n ->type('name', $user->name)\n ->type('email', $user->email)\n ->select('request_type', $petition->request_type)\n ->select('area',$user->area)\n ->press('#Enviar')\n ->assertDontSee('Email envíado correctamente a: '.$user->email)\n ->assertUrlIs(\"http://tesis.test/Solicitud\");\n\n });\n }", "public function testUsersAlsoViewedException()\n {\n $this->setExpectedException('InvalidArgumentException');\n $this->easyrec->usersAlsoViewed(self::ITEM_ID, null, 'not a number of results');\n }", "function attendeeAdded($cal_id, $event_id, $user_id){\n\t\t// noop\n\t}", "public function seenEpisode($userId, $episodeId) {\n // Check if the given episodeID was indeed not seen yet\n if ($this->hasSeen($userId, $episodeId) === 0) {\n Users::find($userId)->episodes()->attach($episodeId);\n }\n }" ]
[ "0.79114354", "0.67762583", "0.60609365", "0.6048211", "0.5815554", "0.5562579", "0.55099916", "0.54545826", "0.54542875", "0.54359055", "0.53954625", "0.53615624", "0.5317775", "0.53033173", "0.5221119", "0.51331645", "0.5105674", "0.5094925", "0.50782263", "0.50610536", "0.5049512", "0.50310034", "0.50159", "0.5000151", "0.49927276", "0.49893674", "0.4983205", "0.49686277", "0.49637702", "0.4959889" ]
0.83292097
0
Tests for the user_competency_course data when api::add_evidence() is invoked when grading a user competency in the system context.
public function test_add_evidence_for_user_competency_course_grade_outside_course() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $syscontext = context_system::instance(); // Create a student. $student = $dg->create_user(); // Create a competency for the course. $lpg = $dg->get_plugin_generator('core_competency'); $framework = $lpg->create_framework(); $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Add evidence. api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE, 'commentincontext', 'core', null, false, null, 1); // Query for user_competency_course data. $filterparams = array( 'userid' => $student->id, 'competencyid' => $comp->get('id'), ); $usercompcourse = \core_competency\user_competency_course::get_record($filterparams); // There should be no user_competency_course object created when grading. $this->assertFalse($usercompcourse); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "public function test_set_ruleoutcome_course_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $course = $dg->create_course();\n\n $this->setAdminUser();\n $f = $lpg->create_framework();\n $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id')));\n $cc = api::add_competency_to_course($course->id, $c->get('id'));\n\n // Check record was created with default rule value Evidence.\n $this->assertEquals(1, \\core_competency\\course_competency::count_records());\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_EVIDENCE,\n $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n\n // Check ruleoutcome value is updated to None.\n $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),\n \\core_competency\\course_competency::OUTCOME_NONE));\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n }", "protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1) {\n $beforecount = evidence::count_records();\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n $this->assertEquals($beforecount + 1, evidence::count_records());\n $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $compid));\n $records = evidence::get_records(array(), 'id', 'DESC', 0, 1);\n $evidence = array_pop($records);\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n }", "public function test_course_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n // Enrol students in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id);\n $dg->enrol_user($u1->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id);\n $dg->enrol_user($u2->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id);\n $dg->enrol_user($u3->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id);\n $dg->enrol_user($u4->id, $c1->id, $studentrole->id);\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 6 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id));\n\n // Rate some competencies.\n // User 1.\n api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test');\n // User 2.\n api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test');\n // User 3.\n api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test');\n api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test');\n // User 4.\n api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test');\n api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test');\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id);\n $this->assertEquals(4, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id);\n $this->assertEquals(0, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id);\n $this->assertEquals(2, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id);\n $this->assertEquals(0, $result);\n\n $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2);\n // We should get 5 and 6 in repeatable order.\n $valid = false;\n if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $valid = false;\n if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $expected = $result[1]->get('id');\n $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1);\n $this->assertEquals($result[0]->get('id'), $expected);\n }", "public function test_shouldWork_whenSpecificUser()\n {\n // given\n User::query()->delete();\n $user = User::create([ 'name' => 'E2EScenario', 'email' => '[email protected]' ]);\n\n // when\n $this->artisan('e2e:scenario --user-id=' . $user->id)\n\n // then\n ->expectsOutput('Created a new course:')\n ->assertExitCode(0);\n $user = User::find($user->id);\n $this->assertEquals(1, $user->courses->count());\n $course = $user->courses->first();\n $this->assertNotEmpty($course->requirements);\n $this->assertNotEmpty($course->participants);\n $this->assertNotEmpty($course->blocks);\n $this->assertGreaterThanOrEqual(2, $course->users->count());\n }", "protected function checkUserCoursesView(ApiTester $I, $userId, $courseData){\n\n $expectedCourseData = [];\n foreach($courseData as $id => $data){\n $data['uniqueId'] = $id;\n $expectedCourseData[] = (object)[\n \"type\" => \"courses\",\n \"id\" => $id,\n \"attributes\" => (object)$data\n ];\n }\n\n $I->getCoursesByUsers($userId);\n $I->seeResponseCodeIs(200);\n $I->seeResponseContainsExactJson((object)[\n \"links\" => (object)[\n \"self\" => \"http://api-core/\". $this->instanceName .\"/courses/get/by/user/$userId\"\n ],\n \"data\" => $expectedCourseData,\n \"meta\" => (object)[\n \"total\" => count($expectedCourseData)\n ]\n ]);\n }", "public function enroll_user_to_course_builds_views(\\ApiTester $I){\n $userData1 = [\n 'forename' => 'Jane',\n 'surname' => 'Awesome',\n ];\n $userData2 = [\n 'forename' => 'Danny',\n 'surname' => 'Cool',\n ];\n $courseData1 = [\n 'title' => 'Course 1',\n 'course_code' => 'course_1'\n ];\n $courseData2 = [\n 'title' => 'Course 1',\n 'course_code' => 'course_1'\n ];\n $I->amHttpAuthenticated('service_user', '123456');\n $I->haveHttpHeader('Content-Type', 'application/json');\n $I->addNewUser($userData1);\n $userId1 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addNewUser($userData2);\n $userId2 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addCourse($courseData1);\n $courseId1 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addCourse($courseData2);\n $courseId2 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n\n // Enroll just one user and check the views\n $this->enrollSingleUser($I, $courseId1, $userId1);\n\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n ]); // Nobody should be on this course\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n ]); // This user should not be enrolled\n\n // Enroll a Second user and check the views\n $this->enrollSingleUser($I, $courseId1, $userId2);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1,\n $userId2 => $userData2\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n ]); // Nobody should be on this course\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n\n // Enroll a user to a different course and ensure only that user\n // is on the course\n $this->enrollSingleUser($I, $courseId2, $userId1);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1,\n $userId2 => $userData2\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n $userId1 => $userData1,\n ]);\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1,\n $courseId2 => $courseData2\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n\n // Update a user's data and ensure all views correctly update\n $userData1Updated = [\n 'forename' => 'Stupendous',\n 'surname' => 'Ralph'\n ];\n $I->updateUser($userId1, $userData1Updated);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1Updated,\n $userId2 => $userData2,\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n $userId1 => $userData1Updated,\n ]);\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1,\n $courseId2 => $courseData2\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n }", "function collectCourseUserInforamtion($courseUserID, $courseUserLogData, $courseActionItem, $courseStandardArray, &$userPass) {\n $userPass = true;\n $courseUserTableForm = array();\n \n //compare time or score\n $courseTime = calculateInteTime($courseUserLogData);\n $courseTimeStandard = (($courseStandardArray['course']['timeCheck']==\"0\")?'':\n (($courseStandardArray['course']['time']==\"0\")?'':\n $courseStandardArray['course']['time']));\n $courseTimePass = (($courseTime >= $courseTimeStandard) ?true :false);\n $courseScore = 0;\n $courseScoreStandard = 0;\n $courseScorePass = (($courseScore >= $courseScoreStandard) ?true :false);\n \n //course\n $courseUserTableForm['course'] = array('time'=>$courseTime,\n 'score'=>$courseScore,\n 'timeStandard'=>$courseTimeStandard,\n 'scoreStandard'=>$courseScoreStandard,\n 'timePass'=>$courseTimePass,\n 'scorePass'=>$courseScorePass\n );\n //user pass array edit\n if ( !($courseUserTableForm['course']['timePass'] AND\n $courseUserTableForm['course']['scorePass']) ) {\n $userPass = false;\n }\n \n //action item\n foreach($courseActionItem as $courseActionItemOne) {\n \n\n //insert switch action item\n if ( !$courseActionItemOne = courseActionItemCheck($courseActionItemOne) ) {\n //if not need action item break the count\n break; //once error all not count (nerro error capical\n }\n //setup action time\n $courseActionTime = 0;\n switch ($courseActionItemOne->itemmodule) {\n case 'lesson': //單元課程\n $courseActionTime = 0; //setup action time\n $lessonID = $courseActionItemOne->iteminstance;\n if ( $lessonTime = caculateLessonTime($userID, $courseID, $lessonID) ) {\n $courseActionTime = $lessonTime;\n }\n break;\n case 'assignment': //作業\n $courseActionTime = 0; //setup action time\n break;\n case 'quiz': //考試\n $courseActionTime = 0; //setup action time\n $quizID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateQuizTime($userID, $courseID, $quizID) ) {\n $courseActionTime = $quizTime;\n }\n break;\n case 'hotpot': //hot potato test\n $courseActionTime = 0; //setup action time\n $hotpotID = $courseActionItemOne->iteminstance;\n if ( $hotpotTime = caculateHotPotTime($userID, $courseID, $hotpotID) ) {\n $courseActionTime = $hotpotTime;\n }\n break;\n case 'scorm': //SCORM/AICC 課程包\n $courseActionTime = 0; //setup action time\n $scormID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateScormTime($userID, $courseID, $scormID) ) {\n $courseActionTime = $quizTime;\n }\n break;\n }\n\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $courseUserID);\n $courseActionScore = round($courseActionScore->finalgrade, 1);\n //read action time standard\n $courseActionTimeStandard = (($courseStandardArray[$courseActionItemOne->id]['timeCheck']==\"0\")?'':\n (($courseStandardArray[$courseActionItemOne->id]['time']==\"0\")?'':\n $courseStandardArray[$courseActionItemOne->id]['time']));\n \n $courseActionScoreStandard = (($courseStandardArray[$courseActionItemOne->id]['scoreCheck']==\"0\")?'':\n (($courseStandardArray[$courseActionItemOne->id]['score']==\"0\")?'':\n $courseStandardArray[$courseActionItemOne->id]['score']));\n \n $courseActionTimePass = ($courseActionTime >= $courseActionTimeStandard) ?true :false;\n $courseActionScorePass = ($courseActionScore >= $courseActionScoreStandard) ?true :false;\n \n $courseUserTableForm[$courseActionItemOne->itemname] = array('time'=>$courseActionTime,\n 'score'=> $courseActionScore,\n 'timeStandard'=>$courseActionTimeStandard,\n 'scoreStandard'=>$courseActionScoreStandard,\n 'timePass'=>$courseActionTimePass,\n 'scorePass'=>$courseActionScorePass\n );\n //user pass array edit\n if ( !($courseUserTableForm[$courseActionItemOne->itemname]['timePass'] AND\n $courseUserTableForm[$courseActionItemOne->itemname]['scorePass']) ) {\n $userPass = false;\n }\n }\n //var_dump($courseUserTableForm);\n return $courseUserTableForm;\n}", "public function dictated( User $user, Course $course){\n\n if($course->user_id == $user->id ){\n return true;\n } else {\n return false;\n }\n\n }", "public function valued( User $user, Course $course ){\n if( Review::where('user_id', $user->id)->where('course_id', $course->id)->count() ){\n return false;\n } else {\n return true;\n }\n }", "public function test_shouldWork_whenDefaultUser()\n {\n // given\n User::query()->delete();\n $user = User::create([ 'name' => 'E2EScenario', 'email' => '[email protected]' ]);\n\n // when\n $this->artisan('e2e:scenario')\n\n // then\n ->expectsOutput('Created a new course:')\n ->assertExitCode(0);\n $user = User::find($user->id);\n $this->assertEquals(1, $user->courses->count());\n /** @var Course $course */\n $course = $user->courses->first();\n $this->assertNotEmpty($course->requirements);\n $this->assertNotEmpty($course->participants);\n $this->assertNotEmpty($course->blocks);\n $this->assertNotEmpty($course->feedback_datas);\n $this->assertNotEmpty($course->feedbacks);\n $this->assertGreaterThanOrEqual(2, $course->users->count());\n }", "function testEnrolments() {\n $url = $this->_getURL('/v1/courses/3/users');\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3'),\n );\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a non-existent user\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0099', 'role_id' => 5)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // Add a student to a course\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5)\n );\n $expected = array(array('username' => 'redshirt0005', 'role_id' => 5));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a duplicate student to a course\n $input = array_merge($input, array(array('username' => 'redshirt0029', 'role_id' => 5)));\n $expected = array();\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add an instructor to a course\n $input[] = array('username' => 'instructor2', 'role_id' => 3);\n $expected = array(array('username' => 'instructor2', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add an instructor with duplicate usernames to a course\n $input = array_merge($input, array(array('username' => 'instructor1', 'role_id' => 3),\n array('username' => 'INStructor1', 'role_id' => 3)));\n $expected = array(array('username' => 'instructor1', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a tutor to a course\n $input[] = array('username' => 'tutor2', 'role_id' => 4);\n $expected = array(array('username' => 'tutor2', 'role_id' => 4));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // update course enrolment - remove instructor1\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor2', 'role_id' => 3),\n array('username' => 'tutor2', 'role_id' => 4)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // check enrolment\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '9', 'role_id' => '5', 'username' => 'redshirt0005'),\n array('id' => '3', 'role_id' => '3', 'username' => 'instructor2'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '36', 'role_id' => '4', 'username' => 'tutor2'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3')\n );\n $this->assertEqual(json_decode($actual, true), $expected);\n\n // update course enrolment - remove instructor1\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor2', 'role_id' => 3),\n array('username' => 'tutor2', 'role_id' => 4)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // check enrolment\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '9', 'role_id' => '5', 'username' => 'redshirt0005'),\n array('id' => '3', 'role_id' => '3', 'username' => 'instructor2'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '36', 'role_id' => '4', 'username' => 'tutor2'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3')\n );\n $this->assertEqual(json_decode($actual, true), $expected);\n\n // Remove a student from a course\n $expected = array(array('username' => 'redshirt0005', 'role_id' => 5));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Remove an instructor from a course\n $expected = array(array('username' => 'instructor2', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Remove a tutor from a course\n $expected = array(array('username' => 'tutor2', 'role_id' => 4));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n }", "function add_sgo_to_cohorts($applicant_user, $sgo_user, $resource_courses_cohort, $support_courses_cohort) {\n global $DB;\n\n // Add the DSL user to the resource courses cohort\n cohort_add_member($resource_courses_cohort->id, $sgo_user->id);\n \n // Add the DSL user to the support courses cohort\n cohort_add_member($support_courses_cohort->id, $sgo_user->id);\n\n $cohort_names = get_applicant_cohort_names($applicant_user);\n $courses = $DB->get_records('course');\n foreach($courses as $course) {\n if(in_array($course->shortname, $cohort_names)) {\n $context = context_course::instance($course->id);\n $cohort = $DB->get_record('cohort', array('idnumber'=>$course->shortname));\n cohort_add_member($cohort->id, $sgo_user->id);\n role_assign(get_role_id('ukfnnoneditingteacher'), $sgo_user->id, $context->id);\n //role_unassign(get_role_id('ukfnstudent'), $sgo_user->id, $context->id);\n }\n }\n}", "public function test_student_save_nouserobject() {\n global $DB, $USER;\n\n // Create Moodle course category.\n $crscat = create_course_category((object)array(\n 'name' => 'Test Course category',\n 'idnumber' => 'MCC-1'\n ));\n\n // Create Moodle course.\n $crsdata = array(\n 'category' => $crscat->id,\n 'fullname' => 'MC-TEST-ELIS-8484',\n 'shortname' => 'MC-TEST-ELIS-8484',\n 'idnumber' => 'MC-TEST-ELIS-8484'\n );\n\n $mdlcrs = new stdClass;\n $mdlcrs->id = $DB->insert_record('course', (object)$crsdata);\n\n $cddata = array(\n 'name' => 'CD-ELIS-8484',\n 'code' => 'CD-ELIS-8484',\n 'idnumber' => 'CD-ELIS-8484',\n 'syllabus' => 'syllabus'\n );\n $cd = new course($cddata);\n $cd->save();\n\n $ci = new pmclass(array(\n 'idnumber' => 'CI-ELIS-8484',\n 'courseid' => $cd->id,\n 'moodlecourseid' => $mdlcrs->id,\n 'autocreate' => 0\n ));\n $ci->save();\n\n $testuser = new user(array(\n 'idnumber' => 'testuserelis8484',\n 'username' => 'testuserelis8484',\n 'firstname' => 'Test',\n 'lastname' => 'User-ELIS8484',\n 'email' => '[email protected]',\n 'city' => 'Waterloo',\n 'country' => 'CA',\n ));\n $testuser->save();\n\n $USER = null;\n $sturec = new stdClass;\n $sturec->userid = $testuser->id;\n $sturec->classid = $ci->id;\n $sturec->grade = 0;\n $sturec->enrolmenttime = time();\n $student = new student($sturec);\n $student->save();\n\n $this->assertFalse(empty($student));\n if (!empty($student)) {\n $this->assertFalse(empty($student->id));\n }\n }", "function hook_course_has_takecourse($node, $user) {\n // @todo document this.\n}", "public static function save_user_legal($user_id, $course_code, $session_id = null)\n {\n // Course plugin legal\n $enabled = api_get_plugin_setting('courselegal', 'tool_enable');\n\n if ($enabled == 'true') {\n require_once api_get_path(SYS_PLUGIN_PATH) . 'courselegal/config.php';\n $plugin = CourseLegalPlugin::create();\n return $plugin->saveUserLegal($user_id, $course_code, $session_id);\n }\n\n $user_id = intval($user_id);\n $course_code = Database::escape_string($course_code);\n $session_id = intval($session_id);\n\n $courseInfo = api_get_course_info($course_code);\n $courseId = $courseInfo['real_id'];\n\n if (empty($session_id)) {\n $table = Database::get_main_table(TABLE_MAIN_COURSE_USER);\n $sql = \"UPDATE $table SET legal_agreement = '1'\n WHERE user_id = $user_id AND c_id = $courseId \";\n Database::query($sql);\n } else {\n $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);\n $sql = \"UPDATE $table SET legal_agreement = '1'\n WHERE user_id = $user_id AND c_id = $courseId AND session_id = $session_id\";\n Database::query($sql);\n }\n }", "public function test_that_authorized_user_can_view_courses_within_other_periods()\n {\n \n }", "public function testCloudPosCheckAddCourseToCheck()\n {\n }", "function gmt_courses_get_user_courses ($email = '') {\n\n\t\t// Variables\n\t\t$course_data = getenv('COURSE_DATA');\n\t\t$purchases = gmt_courses_get_user_purchases($email);\n\t\tif (gettype($purchases) === 'object') {\n\t\t\t$purchases = get_object_vars(gmt_courses_get_user_purchases($email));\n\t\t}\n\n\t\t// Bail if the user has no purchases\n\t\tif (empty($purchases)) return;\n\n\t\t// Get course data\n\t\t$courses = json_decode(file_get_contents(realpath(ABSPATH . DIRECTORY_SEPARATOR . '..') . '/' . trim($course_data, '/'), true));\n\n\t\t// Remove courses the user doesn't have access to\n\t\tforeach ($courses->courses as $key => $course) {\n\n\t\t\t// Determine what level of access the user has to this course\n\t\t\t$has_course = array_intersect($course->courseid, $purchases);\n\t\t\t$has_book = array_intersect($course->bookid, $purchases);\n\n\n\t\t\t// If they have no access, remove it\n\t\t\tif (empty($has_course) && empty($has_book)) {\n\t\t\t\tunset($courses->courses[$key]);\n\t\t\t}\n\n\t\t\t// If they only have access to courses\n\t\t\tif (empty($has_book)) {\n\t\t\t\tunset($courses->courses[$key]->assets);\n\t\t\t}\n\n\t\t\t// If they only have access to the books\n\t\t\tif (empty($has_course)) {\n\t\t\t\tunset($courses->courses[$key]->lessons);\n\t\t\t}\n\n\t\t}\n\n\t\t// Remove JS academy's the user doesn't have access to\n\t\tforeach ($courses->academy as $key => $session) {\n\n\t\t\t// Determine what level of access the user has to this course\n\t\t\t$has_access = in_array($session->id, $purchases);\n\n\t\t\t// If they have no access, remove it\n\t\t\tif (empty($has_access)) {\n\t\t\t\tunset($courses->academy[$key]);\n\t\t\t}\n\n\t\t}\n\n\t\t// Reindex the arrays\n\t\t$courses->courses = array_values($courses->courses);\n\t\t$courses->academy = array_values($courses->academy);\n\n\t\treturn $courses;\n\n\t}", "public function addCourseConvenor(Request $request){\n $courseId = $request->input('courseId');\n\n $userLoggedIn = Auth::user()->id;\n $course = Course::where('id', $courseId)->first();\n $department = $course->department;\n $deptAdminCourseMap = DeptAdminDeptMap::where('user_id', $userLoggedIn)\n ->where('department_id', $department->id)->first();\n $convenorCourseMap = ConvenorCourseMap::where('user_id', $userLoggedIn)\n ->where('course_id', $courseId)->first();\n if(!$courseId || !$course ||\n ((($deptAdminCourseMap && $deptAdminCourseMap->status ==0) || ($convenorCourseMap && $convenorCourseMap->status==0))\n && Auth::user()->role_id != 6)\n ){\n throwException();\n }\n\n $email = $request->input('email');\n $user = User::where('email', $email)->first();\n if(!$user){\n $user = new User();\n $user->email = $email;\n $user->account_registered = 0;\n $user->student_number = $this->getRandomWord(9);\n $user->employee_id = $this->getRandomNumber(7);\n $user->role_id = 5;\n }\n $user->role_id = 4;\n $user->approved = 1; $user->save();\n\n // adding user to the department\n $departmentMap = UserDepartmentMap::where('user_id', $user->id)\n ->where('department_id', $department->id)->first();\n if(!$departmentMap){\n $departmentMap = new UserDepartmentMap();\n $departmentMap->user_id = $user->id;\n $departmentMap->department_id = $department->id;\n $departmentMap->status = 1;\n }\n $departmentMap->status = 1; $departmentMap->save();\n\n // checks if to-be-convenor is already a courseconvenor for the course\n $convenorCourseMap = ConvenorCourseMap::where('course_id', $courseId)\n ->where('user_id', $user->id)->first();\n if(!$convenorCourseMap) {\n $convenorCourseMap = new ConvenorCourseMap();\n $convenorCourseMap->user_id = $user->id;\n $convenorCourseMap->course_id = $courseId;\n }\n $convenorCourseMap->status = 1;\n $convenorCourseMap->save();\n }", "function produceSimpleCourseUserArray($userID, $courseID, $courseUserLogData, &$userPass) {\n //relating function produceUserCourseLog\n //use produceUserCourseLog's return as input $courseUserLogData\n\n global $DB;\n \n if( !$user = $DB->get_record('user', array('id'=>$userID)) ) {\n return false;\n //error('不正確的學員名稱!');\n }\n \n if( !$courseusers = get_course_students($courseID) ) {\n return false;\n //error('這門課程目前沒有學生參加!');\n }\n \n if ( !$courseActionItem = getCourseActionItem($courseID) ) {\n return false;\n //error('課程未有活動!'); \n }\n \n if ( !$courseStandardArray = getReportModuleConfig($courseID) ) {\n return false;\n //error('課程尚未設定!');\n }\n \n //compare time or score\n //compare course action course\n if ($courseStandardArray['course']['timeCheck']) {\n //compare time\n $courseTime = calculateInteTime($courseUserLogData);\n $courseTimeStandard = ($courseStandardArray['course']['time'])\n ?$courseStandardArray['course']['time']\n :\"0\";\n $courseTimePass = ( ($courseTime >= $courseTimeStandard) ?true :false );\n //compare score\n $courseScorePass = true;\n } else {\n //compare time\n $courseTimePass = true;\n //compare score\n $courseScorePass = true;\n }\n \n //include course action data\n $courseUserArray = array();\n //$courseUserArray['course' or 'modID']['timeCheck' or 'score' ...]\n $courseUserArray['course'] = array( 'timePass'=>$courseTimePass,\n 'scorePass'=>$courseScorePass\n );\n //user pass array edit\n if ( !($courseUserArray['course']['timePass'] AND\n $courseUserArray['course']['scorePass']) ) {\n return false;\n }\n \n //compare action item\n foreach($courseActionItem as $courseActionItemOne) {\n //switch action item\n if ( !$courseActionItemOne = courseActionItemCheck($courseActionItemOne) ) {\n //if not need action item break the count\n break;\n }\n \n //setup action time\n switch ($courseActionItemOne->itemmodule) {\n case 'lesson': //單元課程\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $lessonID = $courseActionItemOne->iteminstance;\n if ( $lessonTime = caculateLessonTime($userID, $courseID, $lessonID) ) {\n $courseActionTime = $lessonTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'assignment': //作業\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTimePass = true;\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'quiz': //考試\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $quizID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateQuizTime($userID, $courseID, $quizID) ) {\n $courseActionTime = $quizTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'hotpot': //hot potato test\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $hotpotID = $courseActionItemOne->iteminstance;\n if ( $hotpotTime = caculateHotPotTime($userID, $courseID, $hotpotID) ) {\n $courseActionTime = $hotpotTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'scorm':\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $scormID = $courseActionItemOne->iteminstance;\n if ( $scormTime = caculateScormTime($userID, $courseID, $scormID) ) {\n $courseActionTime = $scormTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScorePass = true;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n }\n \n $courseUserArray[$courseActionItemOne->id] = array('timePass'=>$courseActionTimePass,\n 'scorePass'=>$courseActionScorePass\n );\n //user pass array edit\n if ( !($courseUserArray[$courseActionItemOne->id]['timePass'] AND\n $courseUserArray[$courseActionItemOne->id]['scorePass']) ) {\n return false;;\n }\n }\n return true;\n}", "public function isProfessorInCourse($user) {\n if ($user instanceOf EfrontUser) {\n $user = $user -> user['login'];\n }\n $roles = $this -> getPossibleCourseRoles();\n $courseUsers = $this -> getUsers();\n if (in_array($user, array_keys($courseUsers)) && $roles[$courseUsers[$user]['role']] == 'professor') {\n return true;\n } else {\n return false;\n }\n }", "function user_course_details () {\n\t\t\t$this->gen_contents['page_title']\t= 'User Course Details';\n\t\t\t$this->userid \t\t\t\t\t\t= $this->uri->segment(3);\n\n\t\t\t$this->session->set_flashdata('search_firstname',$this->session->flashdata('search_firstname'));\n\t\t\t$this->session->set_flashdata('search_lastname',$this->session->flashdata('search_lastname'));\n\t\t\t$this->session->set_flashdata('search_email',$this->session->flashdata('search_email'));\n\t\t\t$this->session->set_flashdata(\"course_completed\",$this->session->flashdata('course_completed'));\n\n\t\t\t$this->gen_contents['userid']\t\t= $this->userid;\n\t\t\t$this->gen_contents[\"coursedetails\"]= $this->admin_user_model->select_single_user_course_details($this->userid);\n\t\t\t\n\t\t\t/*** sree 070410**/\n\t\t\t$this->load->model('course_model');\n $this->load->model('user_model');\n\t\t\t$license= $this->course_model->get_license($this->userid);\n $course_user_type= $this->user_model->get_course_user_type($this->userid);\n /* Get new package for sales*/\n $package_type= $this->course_model->get_user_package_type($this->userid);\n //Added to enable course edit to types\n if(1==$course_user_type){\n $course_user_type =2;\n }else if(3==$course_user_type){\n $course_user_type =4;\n }else if(5==$course_user_type){\n $course_user_type =6;\n }else if(7==$course_user_type){\n $course_user_type =8;\n }else {\n $course_user_type =$course_user_type;\n } \n \n if($course_user_type==2 || $course_user_type==4 || $course_user_type==6 || $course_user_type==8 || $package_type==1){\n\n $this->gen_contents['add_status']\t= $this->course_model->check_addcourse($this->userid,$license,$course_user_type);\n }else{\n $this->gen_contents['add_status'] = false;\n \n }\n\t\t\t/*** sree 070410 ***/\n\n\t\t\t$arr_quiz\t\t= array();\n\t\t\t$arr_user_quiz\t= $this->admin_user_model->getQuizCountForUser($this->userid);\n\t\t\tforeach ($arr_user_quiz as $val){\n\t\t\t\t$arr_quiz[] = $val->course_id;\n\t\t\t}\n\t\t\t\n\t\t\t/* Exam attended details exist or not starts here */\n\t\t\t$this->load->model('user_exam_model');\n\t\t\t$exam_attended_exist\t\t\t\t= false;\n\t\t\tforeach ($this->gen_contents[\"coursedetails\"] as $key\t=> $coursedetail){\n\t\t\t\t$this->gen_contents[\"coursedetails\"][$key]->exam_attended_exist\t= $this->user_exam_model->isUserAttendedCourse($this->userid, $coursedetail->courseid);\n if($coursedetail->renewal_status == 'Y'){\n $this->gen_contents[\"coursedetails\"][$key]->renew_expired = $this->user_exam_model->isRenewExpired($coursedetail->id);\n } else{\n $this->gen_contents[\"coursedetails\"][$key]->renew_expired = 'N';\n }\n\t\t\t}\n\t\t\t/* Exam attended details exist or not ends here */\n\t\t\t\n\t\t\t$this->gen_contents[\"arr_quiz\"]\t\t= $arr_quiz;\n\t\t\t$this->gen_contents[\"username\"]\t\t= $this->admin_user_model->select_single_userdetails($this->userid);\n\t\t\t$this->_template('user_course_details',$this->gen_contents);\n\t\t}", "public function addLecturer(Request $request){\n $courseId = $request->input('courseId');\n\n $userLoggedIn = Auth::user()->id;\n $course = Course::where('id', $courseId)->first();\n $department = $course->department;\n $deptAdminCourseMap = DeptAdminDeptMap::where('user_id', $userLoggedIn)\n ->where('department_id', $department->id)->first();\n $convenorCourseMap = ConvenorCourseMap::where('user_id', $userLoggedIn)\n ->where('course_id', $courseId)->first();\n\n if(!$courseId || !$course ||\n ((($deptAdminCourseMap && $deptAdminCourseMap->status ==0) || ($convenorCourseMap && $convenorCourseMap->status==0))\n && Auth::user()->role_id != 6)\n ){\n throwException();\n }\n\n $email = $request->input('email');\n $user = User::where('email', $email)->first();\n if(!$user){\n $user = new User();\n $user->email = $email;\n $user->account_registered = 0;\n $user->student_number = $this->getRandomWord(9);\n $user->employee_id = $this->getRandomNumber(7);\n $user->role_id = 3;\n }\n $user->approved = 1; $user->save();\n\n // adding user to the department\n $departmentMap = UserDepartmentMap::where('user_id', $user->id)\n ->where('department_id', $department->id)->first();\n if(!$departmentMap){\n $departmentMap = new UserDepartmentMap();\n $departmentMap->user_id = $user->id;\n $departmentMap->department_id = $department->id;\n $departmentMap->status = 1;\n }\n $departmentMap->status = 1; $departmentMap->save();\n\n // adding user as a lecturer to the course\n $lecturerCourseMap = LecturerCourseMap::where('user_id', $user->id)\n ->where('course_id', $courseId)->first();\n if(!$lecturerCourseMap) {\n $lecturerCourseMap = new LecturerCourseMap();\n $lecturerCourseMap->user_id = $user->id;\n $lecturerCourseMap->course_id = $courseId;\n }\n $lecturerCourseMap->status = 1;\n $lecturerCourseMap->save();\n }", "public function courseManagement($userid, $courseid)\n {\n $URL = $this->_getCourse->getAddress() . '/course/course/'.$courseid;\n $answer = Request::custom('GET', $URL, array(), '');\n $response['course'] = json_decode($answer['content'], true);\n\n // returns all exerciseTypes\n $URL = $this->_getExerciseType->getAddress() . '/exercisetype';\n $answer = Request::custom('GET', $URL, array(), '');\n $response['exerciseTypes'] = json_decode($answer['content'], true);\n\n // returns all possible exerciseTypes of the course\n $URL = $this->_getApprovalCondition->getAddress() . '/approvalcondition/course/' . $courseid;\n $answer = Request::custom('GET', $URL, array(), '');\n $approvalConditions = json_decode($answer['content'], true);\n\n // returns all users of the given course\n $URL = $this->_getUser->getAddress() . '/user/course/'.$courseid;\n $answer = Request::custom('GET', $URL, array(), '');\n $allUsers = json_decode($answer['content'], true);\n\n // returns all notifications of the given course\n $URL = $this->_getNotification->getAddress() . '/notification/course/'.$courseid;\n $answer = Request::custom('GET', $URL, array(), '');\n $notifications = json_decode($answer['content'], true);\n foreach($notifications as $key => $elem){\n $notifications[$key]['innerId'] = Notification::getIdFromNotificationId($elem['id']);\n }\n $notifications = LArraySorter::orderby($notifications,'innerId',SORT_DESC);\n $response['notifications'] = $notifications;\n \n // load course redirects\n $URL = $this->_getRedirect->getAddress() . '/redirect/course/'.$courseid;\n $answer = Request::custom('GET', $URL, array(), '');\n $redirects = json_decode($answer['content'], true);\n $response['redirect'] = $redirects;\n \n unset($answer);\n unset($URL);\n\n // adds an 'inCourse' flag to the exerciseType if there is\n // an approvalCondition with the same id in the same course\n\n /**\n * @todo Improve running time.\n */\n if(!empty($approvalConditions)) {\n foreach ($approvalConditions as &$approvalCondition) {\n foreach ($response['exerciseTypes'] as &$exerciseType) {\n if ($approvalCondition['exerciseTypeId'] == $exerciseType['id']) {\n $exerciseType['inCourse'] = true;\n }\n }\n }\n }\n\n // only selects the users whose course-status is student, tutor, lecturer or admin\n if(!empty($allUsers)) {\n foreach($allUsers as $user) {\n if ($user['courses'][0]['status'] >= 0 && $user['courses'][0]['status'] < 4) {\n\n // adds the course-status to the user objects in the response\n $user['statusName'] = $this->getStatusName($user['courses'][0]['status']);\n\n // removes unnecessary data from the user object\n unset($user['password']);\n unset($user['salt']);\n unset($user['failedLogins']);\n unset($user['courses']);\n\n // adds the user to the response\n $response['users'][] = $user;\n }\n }\n }\n\n $this->flag = 1;\n\n // adds the user_course_data to the response\n $response['user'] = $this->userWithCourse($userid, $courseid);\n\n $this->app->response->setBody(json_encode($response));\n }" ]
[ "0.76625407", "0.75179493", "0.7492597", "0.7259475", "0.63171226", "0.6217031", "0.61467505", "0.6085446", "0.600624", "0.58242375", "0.5807883", "0.5792726", "0.5627028", "0.55720115", "0.5481543", "0.54460037", "0.5431257", "0.54075", "0.5398585", "0.53969777", "0.5350027", "0.53498113", "0.53134906", "0.5312436", "0.5308559", "0.53018326", "0.52778596", "0.52637154", "0.52581453", "0.5205624" ]
0.8161473
0
Tests for the user_competency_course data when api::add_evidence() is invoked when grading a user competency in a course.
public function test_add_evidence_user_competency_course_grade_in_course() { global $USER; $this->resetAfterTest(true); $dg = $this->getDataGenerator(); // Create and assign a current user. $currentuser = $dg->create_user(); $this->setUser($currentuser); // Create a course. $course = $dg->create_course(); $record = array('courseid' => $course->id, 'pushratingstouserplans' => false); $settings = new course_competency_settings(0, (object) $record); $settings->create(); $coursecontext = context_course::instance($course->id); // Create a student and enrol into the course. $student = $dg->create_user(); $studentarch = get_archetype_roles('student'); $studentrole = array_shift($studentarch); $dg->role_assign($studentrole->id, $student->id, $coursecontext->id); $dg->enrol_user($student->id, $course->id, $studentrole->id); // Create a competency for the course. $lpg = $dg->get_plugin_generator('core_competency'); $framework = $lpg->create_framework(); // Do not push ratings from course to user plans. $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id'))); // Query for user_competency_course data. $filterparams = array( 'userid' => $student->id, 'competencyid' => $comp->get('id'), 'courseid' => $course->id ); // Add evidence that sets a grade to the course. $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE, 'commentincontext', 'core', null, false, null, 3, $USER->id); // Get user competency course record. $usercompcourse = \core_competency\user_competency_course::get_record($filterparams); // There should be a user_competency_course object when adding a grade. $this->assertNotEmpty($usercompcourse); $grade = $evidence->get('grade'); $this->assertEquals($grade, $usercompcourse->get('grade')); $this->assertEquals(3, $usercompcourse->get('grade')); $proficiency = $comp->get_proficiency_of_grade($grade); $this->assertEquals($proficiency, $usercompcourse->get('proficiency')); // Confirm that the user competency's grade/proficiency has not been affected by the grade. $usercompetencyparams = [ 'userid' => $student->id, 'competencyid' => $comp->get('id'), ]; $usercompetency = \core_competency\user_competency::get_record($usercompetencyparams); $this->assertNotEmpty($usercompetency); $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade')); $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1) {\n $beforecount = evidence::count_records();\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n $this->assertEquals($beforecount + 1, evidence::count_records());\n $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $compid));\n $records = evidence::get_records(array(), 'id', 'DESC', 0, 1);\n $evidence = array_pop($records);\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n }", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "public function test_set_ruleoutcome_course_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $course = $dg->create_course();\n\n $this->setAdminUser();\n $f = $lpg->create_framework();\n $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id')));\n $cc = api::add_competency_to_course($course->id, $c->get('id'));\n\n // Check record was created with default rule value Evidence.\n $this->assertEquals(1, \\core_competency\\course_competency::count_records());\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_EVIDENCE,\n $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n\n // Check ruleoutcome value is updated to None.\n $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),\n \\core_competency\\course_competency::OUTCOME_NONE));\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n }", "protected function checkUserCoursesView(ApiTester $I, $userId, $courseData){\n\n $expectedCourseData = [];\n foreach($courseData as $id => $data){\n $data['uniqueId'] = $id;\n $expectedCourseData[] = (object)[\n \"type\" => \"courses\",\n \"id\" => $id,\n \"attributes\" => (object)$data\n ];\n }\n\n $I->getCoursesByUsers($userId);\n $I->seeResponseCodeIs(200);\n $I->seeResponseContainsExactJson((object)[\n \"links\" => (object)[\n \"self\" => \"http://api-core/\". $this->instanceName .\"/courses/get/by/user/$userId\"\n ],\n \"data\" => $expectedCourseData,\n \"meta\" => (object)[\n \"total\" => count($expectedCourseData)\n ]\n ]);\n }", "public function test_course_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n // Enrol students in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id);\n $dg->enrol_user($u1->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id);\n $dg->enrol_user($u2->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id);\n $dg->enrol_user($u3->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id);\n $dg->enrol_user($u4->id, $c1->id, $studentrole->id);\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 6 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id));\n\n // Rate some competencies.\n // User 1.\n api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test');\n // User 2.\n api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test');\n // User 3.\n api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test');\n api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test');\n // User 4.\n api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test');\n api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test');\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id);\n $this->assertEquals(4, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id);\n $this->assertEquals(0, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id);\n $this->assertEquals(2, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id);\n $this->assertEquals(0, $result);\n\n $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2);\n // We should get 5 and 6 in repeatable order.\n $valid = false;\n if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $valid = false;\n if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $expected = $result[1]->get('id');\n $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1);\n $this->assertEquals($result[0]->get('id'), $expected);\n }", "public function dictated( User $user, Course $course){\n\n if($course->user_id == $user->id ){\n return true;\n } else {\n return false;\n }\n\n }", "public function enroll_user_to_course_builds_views(\\ApiTester $I){\n $userData1 = [\n 'forename' => 'Jane',\n 'surname' => 'Awesome',\n ];\n $userData2 = [\n 'forename' => 'Danny',\n 'surname' => 'Cool',\n ];\n $courseData1 = [\n 'title' => 'Course 1',\n 'course_code' => 'course_1'\n ];\n $courseData2 = [\n 'title' => 'Course 1',\n 'course_code' => 'course_1'\n ];\n $I->amHttpAuthenticated('service_user', '123456');\n $I->haveHttpHeader('Content-Type', 'application/json');\n $I->addNewUser($userData1);\n $userId1 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addNewUser($userData2);\n $userId2 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addCourse($courseData1);\n $courseId1 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n $I->addCourse($courseData2);\n $courseId2 = $I->grabDataFromResponseByJsonPath('$.data[0].id')[0];\n\n // Enroll just one user and check the views\n $this->enrollSingleUser($I, $courseId1, $userId1);\n\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n ]); // Nobody should be on this course\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n ]); // This user should not be enrolled\n\n // Enroll a Second user and check the views\n $this->enrollSingleUser($I, $courseId1, $userId2);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1,\n $userId2 => $userData2\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n ]); // Nobody should be on this course\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n\n // Enroll a user to a different course and ensure only that user\n // is on the course\n $this->enrollSingleUser($I, $courseId2, $userId1);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1,\n $userId2 => $userData2\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n $userId1 => $userData1,\n ]);\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1,\n $courseId2 => $courseData2\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n\n // Update a user's data and ensure all views correctly update\n $userData1Updated = [\n 'forename' => 'Stupendous',\n 'surname' => 'Ralph'\n ];\n $I->updateUser($userId1, $userData1Updated);\n $this->checkCourseUsersView($I, $courseId1, [\n $userId1 => $userData1Updated,\n $userId2 => $userData2,\n ]);\n $this->checkCourseUsersView($I, $courseId2, [\n $userId1 => $userData1Updated,\n ]);\n $this->checkUserCoursesView($I, $userId1, [\n $courseId1 => $courseData1,\n $courseId2 => $courseData2\n ]);\n $this->checkUserCoursesView($I, $userId2, [\n $courseId1 => $courseData1\n ]);\n }", "public function test_shouldWork_whenSpecificUser()\n {\n // given\n User::query()->delete();\n $user = User::create([ 'name' => 'E2EScenario', 'email' => '[email protected]' ]);\n\n // when\n $this->artisan('e2e:scenario --user-id=' . $user->id)\n\n // then\n ->expectsOutput('Created a new course:')\n ->assertExitCode(0);\n $user = User::find($user->id);\n $this->assertEquals(1, $user->courses->count());\n $course = $user->courses->first();\n $this->assertNotEmpty($course->requirements);\n $this->assertNotEmpty($course->participants);\n $this->assertNotEmpty($course->blocks);\n $this->assertGreaterThanOrEqual(2, $course->users->count());\n }", "public function valued( User $user, Course $course ){\n if( Review::where('user_id', $user->id)->where('course_id', $course->id)->count() ){\n return false;\n } else {\n return true;\n }\n }", "function collectCourseUserInforamtion($courseUserID, $courseUserLogData, $courseActionItem, $courseStandardArray, &$userPass) {\n $userPass = true;\n $courseUserTableForm = array();\n \n //compare time or score\n $courseTime = calculateInteTime($courseUserLogData);\n $courseTimeStandard = (($courseStandardArray['course']['timeCheck']==\"0\")?'':\n (($courseStandardArray['course']['time']==\"0\")?'':\n $courseStandardArray['course']['time']));\n $courseTimePass = (($courseTime >= $courseTimeStandard) ?true :false);\n $courseScore = 0;\n $courseScoreStandard = 0;\n $courseScorePass = (($courseScore >= $courseScoreStandard) ?true :false);\n \n //course\n $courseUserTableForm['course'] = array('time'=>$courseTime,\n 'score'=>$courseScore,\n 'timeStandard'=>$courseTimeStandard,\n 'scoreStandard'=>$courseScoreStandard,\n 'timePass'=>$courseTimePass,\n 'scorePass'=>$courseScorePass\n );\n //user pass array edit\n if ( !($courseUserTableForm['course']['timePass'] AND\n $courseUserTableForm['course']['scorePass']) ) {\n $userPass = false;\n }\n \n //action item\n foreach($courseActionItem as $courseActionItemOne) {\n \n\n //insert switch action item\n if ( !$courseActionItemOne = courseActionItemCheck($courseActionItemOne) ) {\n //if not need action item break the count\n break; //once error all not count (nerro error capical\n }\n //setup action time\n $courseActionTime = 0;\n switch ($courseActionItemOne->itemmodule) {\n case 'lesson': //單元課程\n $courseActionTime = 0; //setup action time\n $lessonID = $courseActionItemOne->iteminstance;\n if ( $lessonTime = caculateLessonTime($userID, $courseID, $lessonID) ) {\n $courseActionTime = $lessonTime;\n }\n break;\n case 'assignment': //作業\n $courseActionTime = 0; //setup action time\n break;\n case 'quiz': //考試\n $courseActionTime = 0; //setup action time\n $quizID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateQuizTime($userID, $courseID, $quizID) ) {\n $courseActionTime = $quizTime;\n }\n break;\n case 'hotpot': //hot potato test\n $courseActionTime = 0; //setup action time\n $hotpotID = $courseActionItemOne->iteminstance;\n if ( $hotpotTime = caculateHotPotTime($userID, $courseID, $hotpotID) ) {\n $courseActionTime = $hotpotTime;\n }\n break;\n case 'scorm': //SCORM/AICC 課程包\n $courseActionTime = 0; //setup action time\n $scormID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateScormTime($userID, $courseID, $scormID) ) {\n $courseActionTime = $quizTime;\n }\n break;\n }\n\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $courseUserID);\n $courseActionScore = round($courseActionScore->finalgrade, 1);\n //read action time standard\n $courseActionTimeStandard = (($courseStandardArray[$courseActionItemOne->id]['timeCheck']==\"0\")?'':\n (($courseStandardArray[$courseActionItemOne->id]['time']==\"0\")?'':\n $courseStandardArray[$courseActionItemOne->id]['time']));\n \n $courseActionScoreStandard = (($courseStandardArray[$courseActionItemOne->id]['scoreCheck']==\"0\")?'':\n (($courseStandardArray[$courseActionItemOne->id]['score']==\"0\")?'':\n $courseStandardArray[$courseActionItemOne->id]['score']));\n \n $courseActionTimePass = ($courseActionTime >= $courseActionTimeStandard) ?true :false;\n $courseActionScorePass = ($courseActionScore >= $courseActionScoreStandard) ?true :false;\n \n $courseUserTableForm[$courseActionItemOne->itemname] = array('time'=>$courseActionTime,\n 'score'=> $courseActionScore,\n 'timeStandard'=>$courseActionTimeStandard,\n 'scoreStandard'=>$courseActionScoreStandard,\n 'timePass'=>$courseActionTimePass,\n 'scorePass'=>$courseActionScorePass\n );\n //user pass array edit\n if ( !($courseUserTableForm[$courseActionItemOne->itemname]['timePass'] AND\n $courseUserTableForm[$courseActionItemOne->itemname]['scorePass']) ) {\n $userPass = false;\n }\n }\n //var_dump($courseUserTableForm);\n return $courseUserTableForm;\n}", "function gmt_courses_get_user_courses ($email = '') {\n\n\t\t// Variables\n\t\t$course_data = getenv('COURSE_DATA');\n\t\t$purchases = gmt_courses_get_user_purchases($email);\n\t\tif (gettype($purchases) === 'object') {\n\t\t\t$purchases = get_object_vars(gmt_courses_get_user_purchases($email));\n\t\t}\n\n\t\t// Bail if the user has no purchases\n\t\tif (empty($purchases)) return;\n\n\t\t// Get course data\n\t\t$courses = json_decode(file_get_contents(realpath(ABSPATH . DIRECTORY_SEPARATOR . '..') . '/' . trim($course_data, '/'), true));\n\n\t\t// Remove courses the user doesn't have access to\n\t\tforeach ($courses->courses as $key => $course) {\n\n\t\t\t// Determine what level of access the user has to this course\n\t\t\t$has_course = array_intersect($course->courseid, $purchases);\n\t\t\t$has_book = array_intersect($course->bookid, $purchases);\n\n\n\t\t\t// If they have no access, remove it\n\t\t\tif (empty($has_course) && empty($has_book)) {\n\t\t\t\tunset($courses->courses[$key]);\n\t\t\t}\n\n\t\t\t// If they only have access to courses\n\t\t\tif (empty($has_book)) {\n\t\t\t\tunset($courses->courses[$key]->assets);\n\t\t\t}\n\n\t\t\t// If they only have access to the books\n\t\t\tif (empty($has_course)) {\n\t\t\t\tunset($courses->courses[$key]->lessons);\n\t\t\t}\n\n\t\t}\n\n\t\t// Remove JS academy's the user doesn't have access to\n\t\tforeach ($courses->academy as $key => $session) {\n\n\t\t\t// Determine what level of access the user has to this course\n\t\t\t$has_access = in_array($session->id, $purchases);\n\n\t\t\t// If they have no access, remove it\n\t\t\tif (empty($has_access)) {\n\t\t\t\tunset($courses->academy[$key]);\n\t\t\t}\n\n\t\t}\n\n\t\t// Reindex the arrays\n\t\t$courses->courses = array_values($courses->courses);\n\t\t$courses->academy = array_values($courses->academy);\n\n\t\treturn $courses;\n\n\t}", "function testEnrolments() {\n $url = $this->_getURL('/v1/courses/3/users');\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3'),\n );\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a non-existent user\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0099', 'role_id' => 5)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // Add a student to a course\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5)\n );\n $expected = array(array('username' => 'redshirt0005', 'role_id' => 5));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a duplicate student to a course\n $input = array_merge($input, array(array('username' => 'redshirt0029', 'role_id' => 5)));\n $expected = array();\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add an instructor to a course\n $input[] = array('username' => 'instructor2', 'role_id' => 3);\n $expected = array(array('username' => 'instructor2', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add an instructor with duplicate usernames to a course\n $input = array_merge($input, array(array('username' => 'instructor1', 'role_id' => 3),\n array('username' => 'INStructor1', 'role_id' => 3)));\n $expected = array(array('username' => 'instructor1', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Add a tutor to a course\n $input[] = array('username' => 'tutor2', 'role_id' => 4);\n $expected = array(array('username' => 'tutor2', 'role_id' => 4));\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // update course enrolment - remove instructor1\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor2', 'role_id' => 3),\n array('username' => 'tutor2', 'role_id' => 4)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // check enrolment\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '9', 'role_id' => '5', 'username' => 'redshirt0005'),\n array('id' => '3', 'role_id' => '3', 'username' => 'instructor2'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '36', 'role_id' => '4', 'username' => 'tutor2'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3')\n );\n $this->assertEqual(json_decode($actual, true), $expected);\n\n // update course enrolment - remove instructor1\n $input = array(\n array('username' => 'redshirt0004', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor3', 'role_id' => 3),\n array('username' => 'tutor3', 'role_id' => 4),\n array('username' => 'redshirt0005', 'role_id' => 5),\n array('username' => 'redshirt0029', 'role_id' => 5),\n array('username' => 'instructor2', 'role_id' => 3),\n array('username' => 'tutor2', 'role_id' => 4)\n );\n $actual = $this->_oauthReq(\n $url, json_encode($input), OAUTH_HTTP_METHOD_POST);\n $this->assertEqual(json_decode($actual, true), array());\n\n // check enrolment\n $actual = $this->_oauthReq(\"$url\");\n $expected = array(\n array('id' => '8', 'role_id' => '5', 'username' => 'redshirt0004'),\n array('id' => '33', 'role_id' => '5', 'username' => 'redshirt0029'),\n array('id' => '9', 'role_id' => '5', 'username' => 'redshirt0005'),\n array('id' => '3', 'role_id' => '3', 'username' => 'instructor2'),\n array('id' => '4', 'role_id' => '3', 'username' => 'instructor3'),\n array('id' => '36', 'role_id' => '4', 'username' => 'tutor2'),\n array('id' => '37', 'role_id' => '4', 'username' => 'tutor3')\n );\n $this->assertEqual(json_decode($actual, true), $expected);\n\n // Remove a student from a course\n $expected = array(array('username' => 'redshirt0005', 'role_id' => 5));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Remove an instructor from a course\n $expected = array(array('username' => 'instructor2', 'role_id' => 3));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n\n // Remove a tutor from a course\n $expected = array(array('username' => 'tutor2', 'role_id' => 4));\n $actual = $this->_oauthReq(\n $url, json_encode($expected), OAUTH_HTTP_METHOD_DELETE);\n $this->assertEqual($expected, json_decode($actual, true));\n }", "public static function save_user_legal($user_id, $course_code, $session_id = null)\n {\n // Course plugin legal\n $enabled = api_get_plugin_setting('courselegal', 'tool_enable');\n\n if ($enabled == 'true') {\n require_once api_get_path(SYS_PLUGIN_PATH) . 'courselegal/config.php';\n $plugin = CourseLegalPlugin::create();\n return $plugin->saveUserLegal($user_id, $course_code, $session_id);\n }\n\n $user_id = intval($user_id);\n $course_code = Database::escape_string($course_code);\n $session_id = intval($session_id);\n\n $courseInfo = api_get_course_info($course_code);\n $courseId = $courseInfo['real_id'];\n\n if (empty($session_id)) {\n $table = Database::get_main_table(TABLE_MAIN_COURSE_USER);\n $sql = \"UPDATE $table SET legal_agreement = '1'\n WHERE user_id = $user_id AND c_id = $courseId \";\n Database::query($sql);\n } else {\n $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);\n $sql = \"UPDATE $table SET legal_agreement = '1'\n WHERE user_id = $user_id AND c_id = $courseId AND session_id = $session_id\";\n Database::query($sql);\n }\n }", "public function isProfessorInCourse($user) {\n if ($user instanceOf EfrontUser) {\n $user = $user -> user['login'];\n }\n $roles = $this -> getPossibleCourseRoles();\n $courseUsers = $this -> getUsers();\n if (in_array($user, array_keys($courseUsers)) && $roles[$courseUsers[$user]['role']] == 'professor') {\n return true;\n } else {\n return false;\n }\n }", "public function test_shouldWork_whenDefaultUser()\n {\n // given\n User::query()->delete();\n $user = User::create([ 'name' => 'E2EScenario', 'email' => '[email protected]' ]);\n\n // when\n $this->artisan('e2e:scenario')\n\n // then\n ->expectsOutput('Created a new course:')\n ->assertExitCode(0);\n $user = User::find($user->id);\n $this->assertEquals(1, $user->courses->count());\n /** @var Course $course */\n $course = $user->courses->first();\n $this->assertNotEmpty($course->requirements);\n $this->assertNotEmpty($course->participants);\n $this->assertNotEmpty($course->blocks);\n $this->assertNotEmpty($course->feedback_datas);\n $this->assertNotEmpty($course->feedbacks);\n $this->assertGreaterThanOrEqual(2, $course->users->count());\n }", "function produceSimpleCourseUserArray($userID, $courseID, $courseUserLogData, &$userPass) {\n //relating function produceUserCourseLog\n //use produceUserCourseLog's return as input $courseUserLogData\n\n global $DB;\n \n if( !$user = $DB->get_record('user', array('id'=>$userID)) ) {\n return false;\n //error('不正確的學員名稱!');\n }\n \n if( !$courseusers = get_course_students($courseID) ) {\n return false;\n //error('這門課程目前沒有學生參加!');\n }\n \n if ( !$courseActionItem = getCourseActionItem($courseID) ) {\n return false;\n //error('課程未有活動!'); \n }\n \n if ( !$courseStandardArray = getReportModuleConfig($courseID) ) {\n return false;\n //error('課程尚未設定!');\n }\n \n //compare time or score\n //compare course action course\n if ($courseStandardArray['course']['timeCheck']) {\n //compare time\n $courseTime = calculateInteTime($courseUserLogData);\n $courseTimeStandard = ($courseStandardArray['course']['time'])\n ?$courseStandardArray['course']['time']\n :\"0\";\n $courseTimePass = ( ($courseTime >= $courseTimeStandard) ?true :false );\n //compare score\n $courseScorePass = true;\n } else {\n //compare time\n $courseTimePass = true;\n //compare score\n $courseScorePass = true;\n }\n \n //include course action data\n $courseUserArray = array();\n //$courseUserArray['course' or 'modID']['timeCheck' or 'score' ...]\n $courseUserArray['course'] = array( 'timePass'=>$courseTimePass,\n 'scorePass'=>$courseScorePass\n );\n //user pass array edit\n if ( !($courseUserArray['course']['timePass'] AND\n $courseUserArray['course']['scorePass']) ) {\n return false;\n }\n \n //compare action item\n foreach($courseActionItem as $courseActionItemOne) {\n //switch action item\n if ( !$courseActionItemOne = courseActionItemCheck($courseActionItemOne) ) {\n //if not need action item break the count\n break;\n }\n \n //setup action time\n switch ($courseActionItemOne->itemmodule) {\n case 'lesson': //單元課程\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $lessonID = $courseActionItemOne->iteminstance;\n if ( $lessonTime = caculateLessonTime($userID, $courseID, $lessonID) ) {\n $courseActionTime = $lessonTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'assignment': //作業\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTimePass = true;\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'quiz': //考試\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $quizID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateQuizTime($userID, $courseID, $quizID) ) {\n $courseActionTime = $quizTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'hotpot': //hot potato test\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $hotpotID = $courseActionItemOne->iteminstance;\n if ( $hotpotTime = caculateHotPotTime($userID, $courseID, $hotpotID) ) {\n $courseActionTime = $hotpotTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n case 'scorm':\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $courseActionTime = 0; //setup action time\n $scormID = $courseActionItemOne->iteminstance;\n if ( $scormTime = caculateScormTime($userID, $courseID, $scormID) ) {\n $courseActionTime = $scormTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $courseActionScorePass = true;\n } else {\n //compare score\n $courseActionScorePass = true;\n }\n break;\n }\n \n $courseUserArray[$courseActionItemOne->id] = array('timePass'=>$courseActionTimePass,\n 'scorePass'=>$courseActionScorePass\n );\n //user pass array edit\n if ( !($courseUserArray[$courseActionItemOne->id]['timePass'] AND\n $courseUserArray[$courseActionItemOne->id]['scorePass']) ) {\n return false;;\n }\n }\n return true;\n}", "public static function CoursesForUser($user_id)\n {\n $results = &get_instance()->db\n ->query(\"SELECT c.* FROM Courses c JOIN UserCourses uc ON c.course_id = uc.course_id and uc.user_id = ? order by c.course_order asc\", array(intval($user_id)))\n ->result();\n\n $ret = array();\n // $introCourseOnly = false;\n foreach ($results as $row)\n {\n $course = Courses_model::LoadWithData($row);\n// if($course->isIntroCourse() && $course->completionPercentageForUser(intval($user_id), false) < 100) {\n// $introCourseOnly = $course;\n// }\n \t$ret[] = $course;\n }\n\n// if($introCourseOnly != false) {\n// return array($introCourseOnly);\n// }\n\n return $ret;\n }", "public static function get_competencies_by_userevidenceid($userevidenceid) {\n global $DB;\n $sql = \"SELECT c.*\n FROM {\" . self::TABLE . \"} uec\n JOIN {\" . competency::TABLE . \"} c\n ON uec.userevidenceid = ?\n AND uec.competencyid = c.id\n ORDER BY c.shortname\";\n $competencies = array();\n $records = $DB->get_recordset_sql($sql, array($userevidenceid));\n foreach ($records as $record) {\n $competencies[] = new competency(0, $record);\n }\n $records->close();\n return $competencies;\n }", "function add_sgo_to_cohorts($applicant_user, $sgo_user, $resource_courses_cohort, $support_courses_cohort) {\n global $DB;\n\n // Add the DSL user to the resource courses cohort\n cohort_add_member($resource_courses_cohort->id, $sgo_user->id);\n \n // Add the DSL user to the support courses cohort\n cohort_add_member($support_courses_cohort->id, $sgo_user->id);\n\n $cohort_names = get_applicant_cohort_names($applicant_user);\n $courses = $DB->get_records('course');\n foreach($courses as $course) {\n if(in_array($course->shortname, $cohort_names)) {\n $context = context_course::instance($course->id);\n $cohort = $DB->get_record('cohort', array('idnumber'=>$course->shortname));\n cohort_add_member($cohort->id, $sgo_user->id);\n role_assign(get_role_id('ukfnnoneditingteacher'), $sgo_user->id, $context->id);\n //role_unassign(get_role_id('ukfnstudent'), $sgo_user->id, $context->id);\n }\n }\n}", "public function addCourseConvenor(Request $request){\n $courseId = $request->input('courseId');\n\n $userLoggedIn = Auth::user()->id;\n $course = Course::where('id', $courseId)->first();\n $department = $course->department;\n $deptAdminCourseMap = DeptAdminDeptMap::where('user_id', $userLoggedIn)\n ->where('department_id', $department->id)->first();\n $convenorCourseMap = ConvenorCourseMap::where('user_id', $userLoggedIn)\n ->where('course_id', $courseId)->first();\n if(!$courseId || !$course ||\n ((($deptAdminCourseMap && $deptAdminCourseMap->status ==0) || ($convenorCourseMap && $convenorCourseMap->status==0))\n && Auth::user()->role_id != 6)\n ){\n throwException();\n }\n\n $email = $request->input('email');\n $user = User::where('email', $email)->first();\n if(!$user){\n $user = new User();\n $user->email = $email;\n $user->account_registered = 0;\n $user->student_number = $this->getRandomWord(9);\n $user->employee_id = $this->getRandomNumber(7);\n $user->role_id = 5;\n }\n $user->role_id = 4;\n $user->approved = 1; $user->save();\n\n // adding user to the department\n $departmentMap = UserDepartmentMap::where('user_id', $user->id)\n ->where('department_id', $department->id)->first();\n if(!$departmentMap){\n $departmentMap = new UserDepartmentMap();\n $departmentMap->user_id = $user->id;\n $departmentMap->department_id = $department->id;\n $departmentMap->status = 1;\n }\n $departmentMap->status = 1; $departmentMap->save();\n\n // checks if to-be-convenor is already a courseconvenor for the course\n $convenorCourseMap = ConvenorCourseMap::where('course_id', $courseId)\n ->where('user_id', $user->id)->first();\n if(!$convenorCourseMap) {\n $convenorCourseMap = new ConvenorCourseMap();\n $convenorCourseMap->user_id = $user->id;\n $convenorCourseMap->course_id = $courseId;\n }\n $convenorCourseMap->status = 1;\n $convenorCourseMap->save();\n }", "public static function get_user_competencies_by_userevidenceid($userevidenceid) {\n global $DB;\n\n $sql = \"SELECT uc.*\n FROM {\" . user_competency::TABLE . \"} uc\n JOIN {\" . self::TABLE . \"} uec\n ON uc.competencyid = uec.competencyid\n JOIN {\" . user_evidence::TABLE . \"} ue\n ON uec.userevidenceid = ue.id\n AND uc.userid = ue.userid\n AND ue.id = ?\n ORDER BY uc.id ASC\";\n\n $usercompetencies = array();\n $records = $DB->get_recordset_sql($sql, array($userevidenceid));\n foreach ($records as $record) {\n $usercompetencies[] = new user_competency(0, $record);\n }\n $records->close();\n return $usercompetencies;\n }", "function hook_course_has_takecourse($node, $user) {\n // @todo document this.\n}", "function produceCourseUserArray($userID, $courseID, $courseUserLogData, &$userPass) {\n global $DB;\n\n //relating function produceUserCourseLog\n //use produceUserCourseLog's return as input $courseUserLogData\n\n if( !$user = $DB->get_record('user', array('id'=>$userID)) ) {\n return false;\n //error('不正確的學員名稱!');\n }\n\n if( !$courseusers = get_course_students($courseID) ) {\n return false;\n //error('這門課程目前沒有學生參加!');\n }\n\n if ( !$courseActionItem = getCourseActionItem($courseID) ) {\n return false;\n //error('課程未有活動!');\n }\n\n if ( !$courseStandardArray = getReportModuleConfig($courseID) ) {\n return false;\n //error('課程尚未設定!');\n }\n\n //set user pass is true, if has any false it will false\n $userPass = true;\n\n //compare time or score\n //compare course action course\n if ($courseStandardArray['course']['timeCheck']) {\n //compare time\n $timeEnable = true;\n $courseTime = calculateInteTime($courseUserLogData);\n $courseTimeStandard = ($courseStandardArray['course']['time'])\n ?$courseStandardArray['course']['time']\n :\"0\";\n $courseFirstDate = calculateFirstDate($courseUserLogData, $courseTimeStandard);\n $courseTimePass = ( ($courseTime >= $courseTimeStandard) ?true :false );\n //compare score\n $scoreEnable = false;\n $courseScore = 0;\n $courseScoreStandard = 0;\n $courseScorePass = true;\n } else {\n //compare time\n $timeEnable = false;\n $courseTime = 0;\n $courseTimeStandard = 0;\n $courseFirstDate = '';\n $courseTimePass = true;\n //compare score\n $scoreEnable = false;\n $courseScore = 0;\n $courseScoreStandard = 0;\n $courseScorePass = true;\n }\n\n //include course action data\n $courseUserArray = array();\n //$courseUserArray['course' or 'modID']['timeCheck' or 'score' ...]\n $courseUserArray['course'] = array( 'timeEnable'=>$timeEnable,\n 'time'=>$courseTime,\n 'date'=>$courseFirstDate,\n 'timeStandard'=>$courseTimeStandard,\n 'timePass'=>$courseTimePass,\n 'scoreEnable'=>$scoreEnable,\n 'score'=>$courseScore,\n 'scoreStandard'=>$courseScoreStandard,\n 'scorePass'=>$courseScorePass\n );\n //user pass array edit\n if ( !($courseUserArray['course']['timePass'] AND\n $courseUserArray['course']['scorePass']) ) {\n $userPass = false;\n }\n\n //compare action item\n foreach($courseActionItem as $courseActionItemOne) {\n //switch action item\n if ( !$courseActionItemOne = courseActionItemCheck($courseActionItemOne) ) {\n //if not need action item break the count\n break;\n }\n\n $courseActionDate = '';\n\n //setup action time\n switch ($courseActionItemOne->itemmodule) {\n case 'lesson': //單元課程\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $timeEnable = true;\n $courseActionTime = 0; //setup action time\n $lessonID = $courseActionItemOne->iteminstance;\n if ( $lessonTime = caculateLessonTime($userID, $courseID, $lessonID) ) {\n $courseActionTime = $lessonTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $timeEnable = false;\n $courseActionTime = 0;\n $courseActionTimeStandard = 0;\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $scoreEnable = true;\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $scoreEnable = false;\n $courseActionScore = 0;\n $courseActionScoreStandard = 0;\n $courseActionScorePass = true;\n }\n break;\n case 'assignment': //作業\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $timeEnable = true;\n $courseActionTime = 0; //setup action time\n $courseActionTimeStandard = 0;\n $courseActionTimePass = true;\n } else {\n //compare time\n $timeEnable = false;\n $courseActionTime = 0;\n $courseActionTimeStandard = 0;\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $scoreEnable = true;\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $scoreEnable = false;\n $courseActionScore = 0;\n $courseActionScoreStandard = 0;\n $courseActionScorePass = true;\n }\n break;\n case 'quiz': //考試\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $timeEnable = true;\n $courseActionTime = 0; //setup action time\n $quizID = $courseActionItemOne->iteminstance;\n if ( $quizTime = caculateQuizTime($userID, $courseID, $quizID) ) {\n $courseActionTime = $quizTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $timeEnable = false;\n $courseActionTime = 0;\n $courseActionTimeStandard = 0;\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $scoreEnable = true;\n $courseActionScore = 0;\n if($courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID))\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n $quizID = $courseActionItemOne->iteminstance;\n if ( $quizDate = caculateQuizDate($userID, $courseID, $quizID) ) {\n $courseActionDate = $quizDate;\n }\n } else {\n //compare score\n $scoreEnable = false;\n $courseActionScore = 0;\n $courseActionScoreStandard = 0;\n $courseActionScorePass = true;\n }\n break;\n case 'hotpot': //hot potato test\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $timeEnable = true;\n $courseActionTime = 0; //setup action time\n $hotpotID = $courseActionItemOne->iteminstance;\n if ( $hotpotTime = caculateHotPotTime($userID, $courseID, $hotpotID) ) {\n $courseActionTime = $hotpotTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $timeEnable = false;\n $courseActionTime = 0;\n $courseActionTimeStandard = 0;\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $scoreEnable = true;\n $courseActionScore = 0;\n $courseActionScore = getCourseActionScore($courseActionItemOne->id, $userID);\n $courseActionScore = round($courseActionScore->finalgrade, 2);\n //read action score standard\n $courseActionScoreStandard = ($courseStandardArray[$courseActionItemOne->id]['score'])\n ?$courseStandardArray[$courseActionItemOne->id]['score']\n :\"0\";\n $courseActionScorePass = ( $courseActionScore >= $courseActionScoreStandard ) ?true :false;\n } else {\n //compare score\n $scoreEnable = false;\n $courseActionScore = 0;\n $courseActionScoreStandard = 0;\n $courseActionScorePass = true;\n }\n break;\n case 'scorm':\n //compare mod time action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['timeCheck']) {\n //compare time\n $timeEnable = true;\n $courseActionTime = 0; //setup action time\n $scormID = $courseActionItemOne->iteminstance;\n if ( $scormTime = caculateScormTime($userID, $courseID, $scormID) ) {\n $courseActionTime = $scormTime;\n }\n //read action time standard\n $courseActionTimeStandard = ($courseStandardArray[$courseActionItemOne->id]['time'])\n ?$courseStandardArray[$courseActionItemOne->id]['time']\n :\"0\";\n $courseActionTimePass = ( ($courseActionTime >= $courseActionTimeStandard) ?true :false );\n } else {\n //compare time\n $timeEnable = false;\n $courseActionTime = 0;\n $courseActionTimeStandard = 0;\n $courseActionTimePass = true;\n }\n //compare mod score action mod id\n if ($courseStandardArray[$courseActionItemOne->id]['scoreCheck']) {\n //compare score\n $scoreEnable = true;\n $courseActionScore = 0;\n $courseActionScoreStandard = 0;\n $courseActionScorePass = true;\n } else {\n //compare score\n $scoreEnable = false;\n $courseActionScore = 0;\n $courseActionScoreStandard = 0;\n $courseActionScorePass = true;\n }\n break;\n }\n\n $courseUserArray[$courseActionItemOne->id] = array(\n 'itemmodule'=>$courseActionItemOne->itemmodule,\n 'timeEnable'=>$timeEnable,\n 'time'=>$courseActionTime,\n 'timeStandard'=>$courseActionTimeStandard,\n 'timePass'=>$courseActionTimePass,\n 'scoreEnable'=>$scoreEnable,\n 'score'=>$courseActionScore,\n 'scoreStandard'=>$courseActionScoreStandard,\n 'scorePass'=>$courseActionScorePass,\n 'scoreDate'=>$courseActionDate\n );\n //user pass array edit\n if ( !($courseUserArray[$courseActionItemOne->id]['timePass'] AND\n $courseUserArray[$courseActionItemOne->id]['scorePass']) ) {\n $userPass = false;\n }\n }\n return $courseUserArray;\n}", "public function test_student_save_nouserobject() {\n global $DB, $USER;\n\n // Create Moodle course category.\n $crscat = create_course_category((object)array(\n 'name' => 'Test Course category',\n 'idnumber' => 'MCC-1'\n ));\n\n // Create Moodle course.\n $crsdata = array(\n 'category' => $crscat->id,\n 'fullname' => 'MC-TEST-ELIS-8484',\n 'shortname' => 'MC-TEST-ELIS-8484',\n 'idnumber' => 'MC-TEST-ELIS-8484'\n );\n\n $mdlcrs = new stdClass;\n $mdlcrs->id = $DB->insert_record('course', (object)$crsdata);\n\n $cddata = array(\n 'name' => 'CD-ELIS-8484',\n 'code' => 'CD-ELIS-8484',\n 'idnumber' => 'CD-ELIS-8484',\n 'syllabus' => 'syllabus'\n );\n $cd = new course($cddata);\n $cd->save();\n\n $ci = new pmclass(array(\n 'idnumber' => 'CI-ELIS-8484',\n 'courseid' => $cd->id,\n 'moodlecourseid' => $mdlcrs->id,\n 'autocreate' => 0\n ));\n $ci->save();\n\n $testuser = new user(array(\n 'idnumber' => 'testuserelis8484',\n 'username' => 'testuserelis8484',\n 'firstname' => 'Test',\n 'lastname' => 'User-ELIS8484',\n 'email' => '[email protected]',\n 'city' => 'Waterloo',\n 'country' => 'CA',\n ));\n $testuser->save();\n\n $USER = null;\n $sturec = new stdClass;\n $sturec->userid = $testuser->id;\n $sturec->classid = $ci->id;\n $sturec->grade = 0;\n $sturec->enrolmenttime = time();\n $student = new student($sturec);\n $student->save();\n\n $this->assertFalse(empty($student));\n if (!empty($student)) {\n $this->assertFalse(empty($student->id));\n }\n }", "function googlecollab_user_complete($course, $user, $mod, $googlecollab) {\n return true;\n}" ]
[ "0.8120201", "0.7335335", "0.73263067", "0.7207535", "0.6308135", "0.62533146", "0.611954", "0.6019751", "0.5923015", "0.57846975", "0.5755991", "0.575195", "0.5687569", "0.56723565", "0.553847", "0.5418427", "0.53251684", "0.53024", "0.52728945", "0.52707684", "0.52698874", "0.52511454", "0.52479404", "0.5223325", "0.522026", "0.5216975", "0.51597005", "0.5134312", "0.51121205", "0.5103321" ]
0.76820153
1
Test update ruleoutcome for course_competency.
public function test_set_ruleoutcome_course_competency() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); $u1 = $dg->create_user(); $u2 = $dg->create_user(); $course = $dg->create_course(); $this->setAdminUser(); $f = $lpg->create_framework(); $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id'))); $cc = api::add_competency_to_course($course->id, $c->get('id')); // Check record was created with default rule value Evidence. $this->assertEquals(1, \core_competency\course_competency::count_records()); $recordscc = api::list_course_competencies($course->id); $this->assertEquals(\core_competency\course_competency::OUTCOME_EVIDENCE, $recordscc[0]['coursecompetency']->get('ruleoutcome')); // Check ruleoutcome value is updated to None. $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'), \core_competency\course_competency::OUTCOME_NONE)); $recordscc = api::list_course_competencies($course->id); $this->assertEquals(\core_competency\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function update($course)\n {\n $changed = $course != $this? true : false;\n\n // Check whether any of the descProperties have changed\n foreach ($this->descProperties as $descProperty)\n {\n //print(\"Checking \".$descProperty.\"\\n\");\n if ($this->$descProperty != $course->$descProperty)\n {\n $this->descMod = time();\n $this->$descProperty = $course->$descProperty;\n }\n }\n\n // Check whether any assignments have changed\n if ($this->assignments != $course->assignments)\n {\n $this->assignments = $course->assignments;\n $this->outcomesMod = time();\n }\n\n if ($this->sampleAssignments != $course->sampleAssignments)\n {\n $this->sampleAssignments = $course->sampleAssignments;\n $this->assignMod = time();\n }\n\n // check whether courseABETOutcomes changed\n if ($this->courseABETOutcomes != $course->courseABETOutcomes)\n {\n $this->courseABETOutcomes = $course->courseABETOutcomes;\n $this->outcomesMod = time();\n }\n\n // don't replace, merge\n // this assumes that courses are only being added, not removed from programs\n if ($this->reqForProgram != $course->reqForProgram)\n {\n foreach ($course->reqForProgram as $progID=>$reqType)\n $this->reqForProgram[$progID] = $reqType;\n }\n\n return $changed;\n }", "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "public function updateCourseStatus( )\n {\n //\n }", "public function test_update() {\n $rowid = \\tool_carcastc\\tool_carcastc_model::save_row((object)[\n 'courseid' => $this->course->id,\n 'name' => 'Row test 1',\n 'completed' => 1,\n 'priority' => 0\n ]);\n\n \\tool_carcastc\\tool_carcastc_model::save_row((object)[\n 'id' => $rowid,\n 'courseid' => $this->course->id,\n 'name' => 'Row test 2',\n 'completed' => 1,\n 'priority' => 0,\n 'descriptionformat' => 0,\n 'description' => 'Description update 1'\n ]);\n\n $row = \\tool_carcastc\\tool_carcastc_model::get_row(['id' => $rowid]);\n $this->assertEquals($this->course->id, $row->courseid);\n $this->assertEquals('Row test 2', $row->name);\n $this->assertEquals('Description update 1', $row->description);\n }", "public function test_elis_createorupdate_updates_course() {\n global $CFG, $DB;\n require_once($CFG->dirroot.'/elis/program/lib/data/course.class.php');\n\n // Set up initial conditions.\n set_config('createorupdate', 1, 'rlipimport_version1elis');\n\n // Create the test course.\n $course = new course(array(\n 'name' => 'testcoursename',\n 'idnumber' => 'testcourseidnumber',\n 'syllabus' => '',\n 'credits' => '0'\n ));\n $course->save();\n\n // Run the course create action.\n $record = new stdClass;\n $record->action = 'update';\n $record->context = 'course';\n $record->idnumber = 'testcourseidnumber';\n $record->credits = '5';\n\n $importplugin = rlip_dataplugin_factory::factory('rlipimport_version1elis');\n $importplugin->fslogger = new silent_fslogger(null);\n $importplugin->process_record('course', $record, 'bogus');\n\n // Validation.\n $this->assertTrue($DB->record_exists(course::TABLE, array(\n 'name' => 'testcoursename',\n 'idnumber' => 'testcourseidnumber',\n 'credits' => 5\n )));\n }", "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function testUpdateValidCourse()\n {\n $data = factory(Course::class)->create(['id' => 'PRJG5']);\n $course = Course::find('PRJG5');\n $course->id = 'DONG5';\n $course->save();\n $other = Course::find('DONG5');\n $this->assertEquals('DONG5', $other->id);\n }", "public function testEditCourse() {\n $test_course = DB::run(\"SELECT * FROM courses WHERE name LIKE 'test course'\")->fetch(PDO::FETCH_ASSOC);\n $test_course_id = $test_course['course_id'];\n $this->assertEquals(\"test course\", $test_course['name']);\n editCourse($test_course_id, \"edited course\");\n $test_course = DB::run(\"SELECT * FROM courses WHERE course_id = ?\", [$test_course_id])->fetch(PDO::FETCH_ASSOC);\n $this->assertEquals(\"edited course\", $test_course['name']);\n }", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_course_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n // Enrol students in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id);\n $dg->enrol_user($u1->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id);\n $dg->enrol_user($u2->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id);\n $dg->enrol_user($u3->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id);\n $dg->enrol_user($u4->id, $c1->id, $studentrole->id);\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 6 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id));\n\n // Rate some competencies.\n // User 1.\n api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test');\n // User 2.\n api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test');\n // User 3.\n api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test');\n api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test');\n // User 4.\n api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test');\n api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test');\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id);\n $this->assertEquals(4, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id);\n $this->assertEquals(0, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id);\n $this->assertEquals(2, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id);\n $this->assertEquals(0, $result);\n\n $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2);\n // We should get 5 and 6 in repeatable order.\n $valid = false;\n if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $valid = false;\n if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $expected = $result[1]->get('id');\n $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1);\n $this->assertEquals($result[0]->get('id'), $expected);\n }", "public function testCloudPosCheckUpdateCoursesInCheck()\n {\n }", "public function testCloudPosCheckUpdateCourse()\n {\n }", "function updateCohortStats($cohortID, $amount, $death_or_sale){\n\t\t\t$stmt = $this->con->prepare(\"SELECT numInit, numDeceased, numSold FROM COHORT WHERE cohortID = ?\");\n\t\t\t$updateC = $this->con->prepare(\"UPDATE COHORT SET numDeceased = ?, numSold = ? , Active = ? WHERE cohortID = ?\");\n\n\t\t\t$stmt->bind_param(\"i\", $cohortID);\n\t\t\t$stmt->bind_result($initial, $dead, $sold);\n\n\t\t\tif($stmt->execute())\n\t\t\t\tif($stmt->fetch()){\n\t\t\t\t\t$newSold = $sold;\n\t\t\t\t\t$newDead = $dead;\n\t\t\t\t\t$isActive = 1;\n\t\t\t\t\tif($death_or_sale == \"SALE\")\n\t\t\t\t\t\t$newSold += $amount;\n\t\t\t\t\t\t\n\t\t\t\t\tif($death_or_sale == \"DEATH\")\n\t\t\t\t\t\t$newDead +=$amount;\n\t\t\t\t\tif(($numInit - ($newDead + $newSold)) == 0)\n\t\t\t\t\t\t\t$isActive = 0;\n\t\t\t\t\t$updateC->bind_param(\"iiii\", $newDead, $newSold, $isActive, $cohortID);\n\n\t\t\t\t\tif($updateC->execute())\n\t\t\t\t\t\treturn true;\n\n\t\t\t\t}\n\t\t\t\treturn false;\n\n\n\t\t}", "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_auth_user_can_update_course()\n {\n $this->actingAs($this->user);\n $course = factory('App\\Course')->create(['description' => 'old_description']);\n $courseData = $course->toArray();\n $courseData['description'] = $this->faker->sentence;\n $start = (Carbon::parse($courseData['start_date'])->format('d/m/Y'));\n $end = (Carbon::parse($courseData['end_date'])->format('d/m/Y'));\n $courseData['start_date'] = $start;\n $courseData['end_date'] = $end;\n $this->json('PUT', route('courses.update', $course->id), $courseData);\n\n $this->assertEquals($courseData['description'], $course->fresh()->description);\n }", "public function set_course_review_2($course_id)\n\t{\n\t\tif (!empty($course_id))\n\t\t{\n\t\t\t$this->db->set('course_review',2);\n\t\t\t$this->db->where('course_id',$course_id);\n\t\t\t$this->db->update('course_tbl');\n\t\t\tif ($this->db->affected_rows()==1)\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\telse return false;\n\t}", "public function testCloudPosCheckBumpCourseOnCheck()\n {\n }", "function testStatusChangeCategoriaChild()\n {\n $categoriaChildGrab = $this->tester->grabRecord('common\\models\\CategoriaChild',['childNome' => 'DIY Components', 'childDescricao' => 'Components for doing it yourself', 'childEstado' => 1]);\n\n $categoriaChild = CategoriaChild::findone(['idchild' => $categoriaChildGrab->idchild]);\n $categoriaChild -> childEstado = 0;\n $this->assertEquals(1, $categoriaChild->update());\n }", "public function testCloudPosCheckUpdateItemInCourse()\n {\n }", "public function testCloudPosCheckCancelCourseInCheck()\n {\n }", "public function testEvaluationCompleteLevelC2()\n {\n $placementTestService = new LevelAssessmentService();\n\n $result = $placementTestService->calculateLevel($this->exercisesDataProviderSet3());\n\n $this->assertEquals('C2', $result);\n }", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1) {\n $beforecount = evidence::count_records();\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n $this->assertEquals($beforecount + 1, evidence::count_records());\n $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $compid));\n $records = evidence::get_records(array(), 'id', 'DESC', 0, 1);\n $evidence = array_pop($records);\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n }", "function update_grade_items_by_course($course_id)\n{\n $grade_items = grade_item::fetch_all(array('courseid' => $course_id, 'needsupdate' => 1));\n foreach ($grade_items as $item) {\n if ($item->needsupdate === 1) {\n $item->regrading_finished();\n }\n }\n return '1';\n}", "public function update(Request $request, RoadmapCourse $roadmapcourse)\n {\n // Check that the roadmapcourse belongs to the user\n if ($roadmapcourse->user_id !== auth()->user()->id){\n return response()->json('Unauthorised', 401);\n }\n\n $data = $request->validate([\n 'course_id' => 'required',\n 'completed' => 'required|boolean'\n ]);\n\n $roadmapcourse->update($data);\n\n return response($roadmapcourse, 200);\n }", "public function testCheckScore()\n {\n session_start();\n $this->initSession();\n\n commandCheck('throw');\n commandCheck('stop');\n\n $actual = $_SESSION['game']['winner'];\n\n $this->assertNotEquals('None', $actual);\n\n destroySession();\n }", "public function testActivateOrgSurveyPass()\n {\n $communityId = 6;\n $this->assertAlertable($communityId, 'activateOrganizationsSurvey');\n }", "public function testUpdateScore()\n {\n\n $rank[1] = array('matchsWon' => 0, 'setsWon' => 0, 'setsLost' => 0, 'gamesWon' => 0, 'gamesLost' => 0, 'points' => 0);\n $rank[2] = array('matchsWon' => 0, 'setsWon' => 0, 'setsLost' => 0, 'gamesWon' => 0, 'gamesLost' => 0, 'points' => 0);\n\n $rankResult[1] = array('matchsWon' => 2, 'setsWon' => 5, 'setsLost' => 3, 'gamesWon' => 35, 'gamesLost' => 38, 'points' => 6);\n $rankResult[2] = array('matchsWon' => 1, 'setsWon' => 3, 'setsLost' => 5, 'gamesWon' => 38, 'gamesLost' => 35, 'points' => 3);\n\n $gameService = new GameService();\n $gameService->setManager($this->em);\n $rank = $gameService->updateScore(\"6/3 2/6 7/5\", $rank, 1, 2);\n $rank = $gameService->updateScore(\"6/4 7/5\", $rank, 1, 2);\n $rank = $gameService->updateScore(\"0/6 6/3 1/6\", $rank, 1, 2);\n $this->assertEquals($rank, $rankResult);\n }" ]
[ "0.62800896", "0.6167871", "0.6032922", "0.59219563", "0.5867495", "0.5822581", "0.57468164", "0.57435834", "0.5720682", "0.5701277", "0.55325824", "0.5530672", "0.55092067", "0.5471686", "0.54479146", "0.54356956", "0.5408911", "0.5402957", "0.5299127", "0.5215114", "0.51976144", "0.51553136", "0.5153831", "0.51362675", "0.5119687", "0.5119486", "0.5114429", "0.50864166", "0.50809014", "0.5078338" ]
0.81557256
0
Test validation on grade on user_competency.
public function test_validate_grade_in_user_competency() { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $user = $dg->create_user(); $s1 = $dg->create_scale(array("scale" => "value1, value2")); $s2 = $dg->create_scale(array("scale" => "value3, value4, value5, value6")); $scaleconfiguration1 = '[{"scaleid":"'.$s1->id.'"},{"name":"value1","id":1,"scaledefault":1,"proficient":0},' . '{"name":"value2","id":2,"scaledefault":0,"proficient":1}]'; $scaleconfiguration2 = '[{"scaleid":"'.$s2->id.'"},{"name":"value3","id":1,"scaledefault":1,"proficient":0},' . '{"name":"value4","id":2,"scaledefault":0,"proficient":1}]'; // Create a framework with scale configuration1. $frm = array( 'scaleid' => $s1->id, 'scaleconfiguration' => $scaleconfiguration1 ); $framework = $lpg->create_framework($frm); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create competency with its own scale configuration. $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'), 'scaleid' => $s2->id, 'scaleconfiguration' => $scaleconfiguration2 )); // Detecte invalid grade in competency using its framework competency scale. try { $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'), 'proficiency' => true, 'grade' => 3 )); $usercompetency->create(); $this->fail('Invalid grade not detected in framework scale'); } catch (\core\invalid_persistent_exception $e) { $this->assertTrue(true); } // Detecte invalid grade in competency using its own scale. try { $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'), 'proficiency' => true, 'grade' => 5 )); $usercompetency->create(); $this->fail('Invalid grade not detected in competency scale'); } catch (\core\invalid_persistent_exception $e) { $this->assertTrue(true); } // Accept valid grade in competency using its framework competency scale. try { $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'), 'proficiency' => true, 'grade' => 1 )); $usercompetency->create(); $this->assertTrue(true); } catch (\core\invalid_persistent_exception $e) { $this->fail('Valide grade rejected in framework scale'); } // Accept valid grade in competency using its framework competency scale. try { $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'), 'proficiency' => true, 'grade' => 4 )); $usercompetency->create(); $this->assertTrue(true); } catch (\core\invalid_persistent_exception $e) { $this->fail('Valide grade rejected in competency scale'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1) {\n $beforecount = evidence::count_records();\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n $this->assertEquals($beforecount + 1, evidence::count_records());\n $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $compid));\n $records = evidence::get_records(array(), 'id', 'DESC', 0, 1);\n $evidence = array_pop($records);\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n }", "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "protected function grade_validation()\n {\n if (is_superadmin_loggedin()) {\n $this->form_validation->set_rules('branch_id', translate('branch'), 'required');\n }\n $this->form_validation->set_rules('name', translate('name'), 'trim|required');\n $this->form_validation->set_rules('grade_point', translate('grade_point'), 'trim|required');\n $this->form_validation->set_rules('lower_mark', translate('mark_from'), 'trim|required');\n $this->form_validation->set_rules('upper_mark', translate('mark_upto'), 'trim|required');\n }", "function checkGPA($studentProfile)\n {\n return array(\n \"result\" => $studentProfile->get(\"GPA\") >= 2,\n \"reason\" => $studentProfile->get(\"GPA\")\n );\n }", "public function test_set_ruleoutcome_course_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $course = $dg->create_course();\n\n $this->setAdminUser();\n $f = $lpg->create_framework();\n $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id')));\n $cc = api::add_competency_to_course($course->id, $c->get('id'));\n\n // Check record was created with default rule value Evidence.\n $this->assertEquals(1, \\core_competency\\course_competency::count_records());\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_EVIDENCE,\n $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n\n // Check ruleoutcome value is updated to None.\n $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),\n \\core_competency\\course_competency::OUTCOME_NONE));\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n }", "function checkPass($grade) {\n\t\tif ((intval ( $grade ) >= 50 && intval ( $grade ) <= 100) || strpos ( $grade, \"P\" ) !== False) {\n\t\t\treturn 1;\n\t\t} else if ($grade == \"Not Completed\") {\n\t\t\treturn \"Not Completed\"; // the student has registerd but not completed\n\t\t} else {\n\t\t\treturn 0; // students hasn't registered\n\t\t}\n\t}", "public static function update_grades($id, $test, $grade){\n\t\tif($test == 1){\n\t\t$query = \"INSERT INTO Grades (userId) VALUES (:userId)\";\n\t\t$db = self::getDB();\n\t\t$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n\t\t$statement = $db->prepare($query);\n \t$statement->bindValue(':userId', $id); \n\t\t$statement->execute();\n\t\t$statement->closeCursor();\n\t\t}\n\t\t\n\t\t$testCol = \"\";\n\t\t\n\t\tswitch($test){\n\t\t\tcase 1:\n\t\t\t\t$testCol= \"Test1_score\";\n\t\t\t\tbreak;\t\t\n\t\t\tcase 2:\n\t\t\t\t$testCol= \"Test2_score\";\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\t$testCol= \"Test3_score\";\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\t$testCol= \"Test4_score\";\n\t\t\t\tbreak;\n\t\t\tcase 5:\n\t\t\t\t$testCol= \"Test5_score\";\n\t\t\t\tbreak;\n\t\t\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t$query1 = \"UPDATE Grades SET \".$testCol.\" = \".$grade.\" WHERE userId = \" .$id;\n\t\t\t$db = self::getDB();\n\t\t\t$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n\t\t\t$statement1 = $db->prepare($query1);\n\t\t\t$statement1->execute();\n\t\t\t$statement1->closeCursor();\n\t\t\n\t\t}", "protected function save_grade($grade, $override) {\n global $USER, $DB;\n\n $success = true;\n\n //need to do two things here\n //1) update the grade in assign_grades table\n //2) update the grade in the gradebook if the grade is NOT overridden or if it IS overridden AND the override check\n // was checked\n\n $assignment = $this->gradingarea->get_assign();\n $usergrade = $this->get_usergrade(true);\n\n $usergrade->grade = $grade;\n $usergrade->grader = $USER->id;\n $usergrade->timemodified = time();\n\n //update the submission\n $success = $DB->update_record('assign_grades', $usergrade);\n\n //now need to update the gradebook\n $gradeoverridden = $this->gradinginfo->items[0]->grades[$this->gradingarea->get_guserid()]->overridden;\n if ($success && !$gradeoverridden) {\n $gradebookgrade = $this->convert_grade_for_gradebook($usergrade);\n\n $assign = clone $assignment->get_instance();\n $assign->cmidnumber = $assignment->get_course_module()->id;\n\n $success = $success && (GRADE_UPDATE_OK == assign_grade_item_update($assign, $gradebookgrade));\n } else if ($success && $override) {\n //try to fetch the gradeitem first\n $params = array('courseid' => $this->courseid, 'itemtype' => 'mod'\n , 'itemmodule' => 'assign', 'iteminstance' => $assignment->get_instance()->id);\n\n $gradeitem = grade_item::fetch($params);\n\n //if no grade item, create a new one\n if (empty($gradeitem)) {\n\n $params['itemname'] = $assignment->get_instance()->name;\n $params['idnumber'] = $assignment->get_course_module()->id;\n\n //set up additional params for the grade item\n if ($assignment->get_instance()->grade > 0) {\n $params['gradetype'] = GRADE_TYPE_VALUE;\n $params['grademax'] = $assignment->get_instance()->grade;\n $params['grademin'] = 0;\n\n } else if ($assignment->assignment->grade < 0) {\n $params['gradetype'] = GRADE_TYPE_SCALE;\n $params['scaleid'] = -$assignment->get_instance()->grade;\n\n } else {\n $params['gradetype'] = GRADE_TYPE_TEXT; // allow text comments only\n }\n\n //create and insert the new grade item\n $gradeitem = new grade_item($params);\n $gradeitem->insert();\n }\n\n //if grade is -1 in assignment_submissions table, it should be passed as null\n $grade = $usergrade->grade;\n if ($grade == -1) {\n $grade = null;\n }\n\n $success = $success && (bool) $gradeitem->update_final_grade($usergrade->userid, $grade, 'local/joulegrader', false\n , FORMAT_MOODLE, $usergrade->grader);\n }\n\n return $success;\n }", "public function test_age_required()\n {\n $this->actingAsUser();\n\n /** @var \\App\\Student $student | typehinting */\n $student = factory(Student::class)->make(['age' => '']);\n\n $response = $this->post('/students',$student->toArray());\n $response->assertSessionHasErrors('age');\n\n //then it should be in the database\n $this->assertCount(0, Student::all() );\n }", "private static function scoreSmoking($user, $prospect)\n {\n if ($user == null or $prospect == null) {\n Log::debug('Smoking(): Age: null values.. skipping');\n\n return 0;\n }\n\n $score = 0;\n\n\n if ($user and $prospect) {\n $score = -20;\n }\n\n Log::debug('Score(): Smoking: ' . $score);\n return $score;\n\n }", "public function testCreateNewScore()\n {\n $this->client->logInAsClient();\n $user = factory(User::class)->create();\n $user->addMembership($this->client->domain);\n $group = UserGroup::create(['name' => 'testGroup', 'permissions' => ['analytics' => ['score-create' => true]]]);\n DB::table('user_user_group')->insert(['user_id' => $user->id, 'user_group_id' => $group->id]);\n $this->be($user);\n\n $this->get('analytics/score/create')->assertSee('CityNexus | Create New Score');\n }", "function give_grade($student_id,$sec_id,$grade){\n\t\t\t$query = \"SELECT COUNT(S_ID) FROM course_registered WHERE (S_ID = '$student_id' and Sec_ID = '$sec_id' AND Grade = 'PENDING')\";\n\t\t\t$result = mysqli_query($GLOBALS['conn'],$query);\n\t\t\t$row = mysqli_fetch_row($result);\n\t\t\tif ($row[0] == 0){\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse{\n\n\t\t\t$query = \"UPDATE course_registered SET Grade = '$grade' WHERE (S_ID = '$student_id' and Sec_ID = '$sec_id' AND Grade = 'PENDING')\";\n\t\t\tmysqli_query($GLOBALS['conn'],$query);\n\t\t\treturn true;\n\t\t\t}\n\t\t}", "public function test_shouldWork_whenSpecificUser()\n {\n // given\n User::query()->delete();\n $user = User::create([ 'name' => 'E2EScenario', 'email' => '[email protected]' ]);\n\n // when\n $this->artisan('e2e:scenario --user-id=' . $user->id)\n\n // then\n ->expectsOutput('Created a new course:')\n ->assertExitCode(0);\n $user = User::find($user->id);\n $this->assertEquals(1, $user->courses->count());\n $course = $user->courses->first();\n $this->assertNotEmpty($course->requirements);\n $this->assertNotEmpty($course->participants);\n $this->assertNotEmpty($course->blocks);\n $this->assertGreaterThanOrEqual(2, $course->users->count());\n }", "public function add_grade_restriction($activity, $gradeactivity, $mingrade) {\n $this->execute('behat_general::click_link', array($this->escape($activity)));\n $this->execute('behat_navigation::i_navigate_to_node_in', array(\"Edit settings\", \"Certificate administration\"));\n\n // Add min grade restrinction step by step see: \n // availability/condition/grade/tests/behat/availability_grade.feature\n\n // And I expand all fieldsets\n $this->execute('behat_forms::i_expand_all_fieldsets');\n\n // And I click on \"Add restriction...\" \"button\"\n $this->execute('behat_general::i_click_on', array(\"Add restriction...\", \"button\"));\n\n // And I click on \"Grade\" \"button\" in the \"Add restriction...\" \"dialogue\"\n $this->execute('behat_general::i_click_on_in_the', array(\"Grade\", \"button\", \"Add restriction...\", \"dialogue\"));\n\n // This not necessary , only if i want not display the resctriction warning to user\n // And I click on \".availability-item .availability-eye img\" \"css_element\"\n // $this->execute('behat_general::i_click_on', array(\".availability-item .availability-eye img\", \"css_element\"));\n\n // And I set the field \"Grade\" to \"A1\"\n $this->select_option_from($this->escape($gradeactivity), 'id');\n // This simple not work at all so i create a new function to do this\n // $this->execute('behat_forms::i_set_the_field_to', array('Grade', $this->escape($gradeactivity)));\n\n // And I click on \"min\" \"checkbox\" in the \".availability-item\" \"css_element\"\n $this->execute('behat_general::i_click_on_in_the', array(\"min\", \"checkbox\", \".availability-item\", \"css_element\"));\n\n // And I set the field \"Minimum grade percentage (inclusive)\" to \"10\"\n $this->execute('behat_forms::i_set_the_field_to', array('Minimum grade percentage (inclusive)', $this->escape($mingrade)));\n\n // Set print grade to modle\n // And I select \"Grade assignment\" from the \"Print Grade\" singleselect\n $this->execute('behat_forms::i_select_from_the_singleselect',\n array($this->escape($gradeactivity), get_string('printgrade', 'simplecertificate'))\n );\n }", "public function testValidation()\n {\n }", "private static function scoreAge(Preferences $user, $prospect)\n {\n\n if ($user->ageMin == null or $prospect == null or $user->ageMax == null) {\n Log::debug('Score(): Age: null values.. skipping');\n\n return 5;\n }\n //FIXME: dob -> date\n\n $score = 0;\n\n $dob = new \\DateTime(date($prospect));\n $now = new \\DateTime(date(\"Y-m-d\"));\n $age = $dob->diff($now);\n\n if ($age->y >= $user->ageMin and $age->y <= $user->ageMax) {\n $score = 20;\n } elseif ($age->y >= ($user->ageMin - 1) and $age->y <= ($user->ageMax + 1)) {\n $score = 10;\n } elseif ($age->y >= ($user->ageMin - 2) and $age->y <= ($user->ageMax + 3)) {\n $score = 7;\n } elseif ($age->y >= ($user->ageMin - 3) and $age->y <= ($user->ageMax + 4)) {\n $score = 5;\n }\n\n Log::debug('Score(): Age: ' . $score);\n return $score;\n }", "public function run()\n {\n DB::table('user_proficiency')->delete();\n\n DB::table('user_proficiency')->insert(array(\n array('user_id' => 4, 'proficiency_id' => 1, 'grade' => 0),\n array('user_id' => 4, 'proficiency_id' => 2, 'grade' => 0),\n array('user_id' => 4, 'proficiency_id' => 3, 'grade' => 0),\n array('user_id' => 4, 'proficiency_id' => 4, 'grade' => 1),\n array('user_id' => 4, 'proficiency_id' => 5, 'grade' => 0),\n array('user_id' => 5, 'proficiency_id' => 1, 'grade' => 0),\n array('user_id' => 5, 'proficiency_id' => 2, 'grade' => 0),\n array('user_id' => 5, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 5, 'proficiency_id' => 4, 'grade' => 0),\n array('user_id' => 5, 'proficiency_id' => 5, 'grade' => 0),\n array('user_id' => 6, 'proficiency_id' => 1, 'grade' => 0),\n array('user_id' => 6, 'proficiency_id' => 2, 'grade' => 0),\n array('user_id' => 6, 'proficiency_id' => 3, 'grade' => 0),\n array('user_id' => 6, 'proficiency_id' => 4, 'grade' => 0),\n array('user_id' => 6, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 7, 'proficiency_id' => 1, 'grade' => 1),\n array('user_id' => 7, 'proficiency_id' => 2, 'grade' => 0),\n array('user_id' => 7, 'proficiency_id' => 3, 'grade' => 0),\n array('user_id' => 7, 'proficiency_id' => 4, 'grade' => 0),\n array('user_id' => 7, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 8, 'proficiency_id' => 1, 'grade' => 0),\n array('user_id' => 8, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 8, 'proficiency_id' => 3, 'grade' => 0),\n array('user_id' => 8, 'proficiency_id' => 4, 'grade' => 0),\n array('user_id' => 8, 'proficiency_id' => 5, 'grade' => 0),\n array('user_id' => 9, 'proficiency_id' => 1, 'grade' => 0),\n array('user_id' => 9, 'proficiency_id' => 2, 'grade' => 0),\n array('user_id' => 9, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 9, 'proficiency_id' => 4, 'grade' => 0),\n array('user_id' => 9, 'proficiency_id' => 5, 'grade' => 0),\n array('user_id' => 10, 'proficiency_id' => 1, 'grade' => 0),\n array('user_id' => 10, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 10, 'proficiency_id' => 3, 'grade' => 0),\n array('user_id' => 10, 'proficiency_id' => 4, 'grade' => 0),\n array('user_id' => 10, 'proficiency_id' => 5, 'grade' => 0),\n array('user_id' => 11, 'proficiency_id' => 1, 'grade' => 1),\n array('user_id' => 11, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 11, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 11, 'proficiency_id' => 4, 'grade' => 1),\n array('user_id' => 11, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 12, 'proficiency_id' => 1, 'grade' => 1),\n array('user_id' => 12, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 12, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 12, 'proficiency_id' => 4, 'grade' => 1),\n array('user_id' => 12, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 13, 'proficiency_id' => 1, 'grade' => 1),\n array('user_id' => 13, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 13, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 13, 'proficiency_id' => 4, 'grade' => 1),\n array('user_id' => 13, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 14, 'proficiency_id' => 1, 'grade' => 1),\n array('user_id' => 14, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 14, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 14, 'proficiency_id' => 4, 'grade' => 1),\n array('user_id' => 14, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 15, 'proficiency_id' => 1, 'grade' => 1),\n array('user_id' => 15, 'proficiency_id' => 2, 'grade' => 1),\n array('user_id' => 15, 'proficiency_id' => 3, 'grade' => 1),\n array('user_id' => 15, 'proficiency_id' => 4, 'grade' => 1),\n array('user_id' => 15, 'proficiency_id' => 5, 'grade' => 1),\n array('user_id' => 16, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 16, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 16, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 16, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 16, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 17, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 17, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 17, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 17, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 17, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 18, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 18, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 18, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 18, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 18, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 19, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 19, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 19, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 19, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 19, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 20, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 20, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 20, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 20, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 20, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 21, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 21, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 21, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 21, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 21, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 22, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 22, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 22, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 22, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 22, 'proficiency_id' => 5, 'grade' => 2),\n array('user_id' => 23, 'proficiency_id' => 1, 'grade' => 2),\n array('user_id' => 23, 'proficiency_id' => 2, 'grade' => 2),\n array('user_id' => 23, 'proficiency_id' => 3, 'grade' => 2),\n array('user_id' => 23, 'proficiency_id' => 4, 'grade' => 2),\n array('user_id' => 23, 'proficiency_id' => 5, 'grade' => 2),\n \n ));\n }", "public static function score(User $user, User $prospect)\n {\n Log::debug('Score(): Scoring ' . $prospect->id . ' for ' . $user->id);\n\n $userProfile = Profile::find($user->id);\n $prospectProfile = Profile::find($prospect->id);\n\n $preferences = Preferences::find($user->id);\n // out of 75 points\n $score = 0;\n\n $score += ProfileScorer::scoreAge($preferences, $prospect->dob);\n $score += ProfileScorer::scoreEthnicity($preferences, $prospectProfile->ethnicity);\n $score += ProfileScorer::scoreHobbies($userProfile, $prospectProfile);\n $score += ProfileScorer::scoreInterests($userProfile, $prospectProfile);\n $score += ProfileScorer::scoreSmoking($preferences->smoking, $prospectProfile->smoking);\n $score += ProfileScorer::scoreDistance($userProfile, $prospectProfile);\n $score += ProfileScorer::scoreReligion($userProfile->religion, $prospectProfile->religion);\n\n return $score;\n }", "abstract public function validate($scenario);", "public function test_course_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n // Enrol students in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id);\n $dg->enrol_user($u1->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id);\n $dg->enrol_user($u2->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id);\n $dg->enrol_user($u3->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id);\n $dg->enrol_user($u4->id, $c1->id, $studentrole->id);\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 6 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id));\n\n // Rate some competencies.\n // User 1.\n api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test');\n // User 2.\n api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test');\n // User 3.\n api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test');\n api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test');\n // User 4.\n api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test');\n api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test');\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id);\n $this->assertEquals(4, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id);\n $this->assertEquals(0, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id);\n $this->assertEquals(2, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id);\n $this->assertEquals(0, $result);\n\n $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2);\n // We should get 5 and 6 in repeatable order.\n $valid = false;\n if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $valid = false;\n if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $expected = $result[1]->get('id');\n $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1);\n $this->assertEquals($result[0]->get('id'), $expected);\n }", "protected function assertExceptionWithGradeCompetencyInCourse($exceptiontype, $exceptiontext, $courseid, $userid, $compid,\n $grade = 1) {\n\n $raised = false;\n try {\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n } catch (moodle_exception $e) {\n $raised = true;\n $this->assertInstanceOf($exceptiontype, $e);\n $this->assertRegExp('@' . $exceptiontext . '@', $e->getMessage());\n }\n\n if (!$raised) {\n $this->fail('Grading should not be allowed.');\n }\n }", "public function valued( User $user, Course $course ){\n if( Review::where('user_id', $user->id)->where('course_id', $course->id)->count() ){\n return false;\n } else {\n return true;\n }\n }", "public static function scoreReligion($user, $prospect)\n {\n\n if ($user == null or $prospect == null) {\n Log::debug('Religion(): Religion: null values.. skipping');\n\n return 0;\n }\n\n $score = 0;\n\n if ($user == $prospect) {\n $score = 10;\n }\n\n Log::debug('Score(): Religion: ' . $score);\n return $score;\n }", "private static function scoreHobbies(Profile $user, Profile $prospect)\n {\n if ($user == null or $prospect == null) {\n Log::debug('Hobbies(): Age: null values.. skipping');\n\n return 0;\n }\n $SCORE_MAX = 10;\n $score = 0;\n\n $user_hobbies = ProfileScorer::buildHobArray($user);\n $prospect_hobbies = ProfileScorer::buildHobArray($prospect);\n\n foreach ($user_hobbies as $uhob) {\n foreach ($prospect_hobbies as $phob) {\n if ($uhob == $phob and $score < $SCORE_MAX) {\n $score += 2;\n }\n }\n }\n\n Log::debug('Score(): Hobbies: ' . $score);\n return $score;\n }", "public function not_graded() {\n $notgraded = false;\n\n $assignment = $this->gradingarea->get_assign();\n $usergrade = $this->get_usergrade();\n\n if ($assignment->get_instance()->grade != 0) {\n //check the submission first\n if (!empty($usergrade) && $usergrade->grade == -1) {\n $notgraded = true;\n } else if (!empty($this->gradinginfo) && is_null($this->gradinginfo->items[0]->grades[$this->gradingarea->get_guserid()]->grade)) {\n //check the gradebook\n $notgraded = true;\n }\n }\n\n return $notgraded;\n }", "public function passes($attribute, $value)\n {\n if(!is_null($this->classsetup_id) && !is_null($this->semester_id)){\n $setup_data=Classsetup::findOrFail($this->classsetup_id);\n $semisters=$setup_data->examinationCurriculars->pluck('semester_id','id')->toArray();\n $exam_curricular_id=(!is_null($semisters) & in_array($this->semester_id,$semisters)) ? $semisters[$this->semester_id] :null;\n \n if(!is_null($exam_curricular_id)){\n $examinations=Examinationcurricular::findOrFail($exam_curricular_id);\n $examinationtype=$examinations->examinationCurriculars->pluck('marks','examinationtype_id')->toArray();\n $max_marks=(!is_null($examinationtype) & array_key_exists($this->examinationtnature_id,$examinationtype)) ? $examinationtype[$this->examinationtnature_id] :null;\n \n if(!is_null($max_marks) && ($value<=$max_marks)){\n return true;\n } \n $this->message = $this->message.$max_marks;\n return false; \n }\n return false;\n }\n return false;\n }" ]
[ "0.7168702", "0.66285306", "0.65662843", "0.6010662", "0.5993279", "0.5896679", "0.5818447", "0.57024187", "0.5548898", "0.5470009", "0.5433953", "0.5429218", "0.5368036", "0.5322332", "0.53005385", "0.5297985", "0.52915674", "0.5275779", "0.52572596", "0.5250085", "0.52357376", "0.52311975", "0.52304924", "0.522928", "0.5220439", "0.5196315", "0.51925564", "0.51847696", "0.5184007", "0.5183631" ]
0.8322669
0
Test when adding competency that belong to hidden framework to plan/template/course.
public function test_hidden_framework() { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $user = $dg->create_user(); // Create a course. $cat1 = $dg->create_category(); $course = $dg->create_course(array('category' => $cat1->id)); // Create a template. $template = $lpg->create_template(); // Create a plan. $plan = $lpg->create_plan(array('userid' => $user->id)); // Create a hidden framework. $frm = array( 'visible' => false ); $framework = $lpg->create_framework($frm); $competency = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Linking competency that belong to hidden framework to course. try { api::add_competency_to_course($course->id, $competency->get('id')); $this->fail('A competency belonging to hidden framework can not be linked to course'); } catch (coding_exception $e) { $this->assertTrue(true); } // Adding competency that belong to hidden framework to template. try { api::add_competency_to_template($template->get('id'), $competency->get('id')); $this->fail('A competency belonging to hidden framework can not be added to template'); } catch (coding_exception $e) { $this->assertTrue(true); } // Adding competency that belong to hidden framework to plan. try { api::add_competency_to_plan($plan->get('id'), $competency->get('id')); $this->fail('A competency belonging to hidden framework can not be added to plan'); } catch (coding_exception $e) { $this->assertTrue(true); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_duplicate_framework() {\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $this->resetAfterTest(true);\n $this->setAdminUser();\n\n $syscontext = context_system::instance();\n $params = array(\n 'shortname' => 'shortname_a',\n 'idnumber' => 'idnumber_c',\n 'description' => 'description',\n 'descriptionformat' => FORMAT_HTML,\n 'visible' => true,\n 'contextid' => $syscontext->id\n );\n $framework = $lpg->create_framework($params);\n $competency1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $competency2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $competency3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $competency4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $competency41 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'parentid' => $competency4->get('id'))\n );\n $competency42 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'parentid' => $competency4->get('id'))\n );\n $competencyidnumbers = array($competency1->get('idnumber'),\n $competency2->get('idnumber'),\n $competency3->get('idnumber'),\n $competency4->get('idnumber'),\n $competency41->get('idnumber'),\n $competency42->get('idnumber')\n );\n\n $config = json_encode(array(\n 'base' => array('points' => 4),\n 'competencies' => array(\n array('id' => $competency41->get('id'), 'points' => 3, 'required' => 0),\n array('id' => $competency42->get('id'), 'points' => 2, 'required' => 1),\n )\n ));\n $competency4->set('ruletype', 'core_competency\\competency_rule_points');\n $competency4->set('ruleoutcome', \\core_competency\\competency::OUTCOME_EVIDENCE);\n $competency4->set('ruleconfig', $config);\n $competency4->update();\n\n api::add_related_competency($competency1->get('id'), $competency2->get('id'));\n api::add_related_competency($competency3->get('id'), $competency4->get('id'));\n\n $frameworkduplicated1 = api::duplicate_framework($framework->get('id'));\n $frameworkduplicated2 = api::duplicate_framework($framework->get('id'));\n\n $this->assertEquals($framework->get('idnumber').'_1', $frameworkduplicated1->get('idnumber'));\n $this->assertEquals($framework->get('idnumber').'_2', $frameworkduplicated2->get('idnumber'));\n\n $competenciesfr1 = api::list_competencies(array('competencyframeworkid' => $frameworkduplicated1->get('id')));\n $competenciesfr2 = api::list_competencies(array('competencyframeworkid' => $frameworkduplicated2->get('id')));\n\n $competencyidsfr1 = array();\n $competencyidsfr2 = array();\n\n foreach ($competenciesfr1 as $cmp) {\n $competencyidsfr1[] = $cmp->get('idnumber');\n }\n foreach ($competenciesfr2 as $cmp) {\n $competencyidsfr2[] = $cmp->get('idnumber');\n }\n\n $this->assertEmpty(array_diff($competencyidsfr1, $competencyidnumbers));\n $this->assertEmpty(array_diff($competencyidsfr2, $competencyidnumbers));\n $this->assertCount(6, $competenciesfr1);\n $this->assertCount(6, $competenciesfr2);\n\n // Test the related competencies.\n reset($competenciesfr1);\n $compduplicated1 = current($competenciesfr1);\n $relatedcompetencies = $compduplicated1->get_related_competencies();\n $comprelated = current($relatedcompetencies);\n $this->assertEquals($comprelated->get('idnumber'), $competency2->get('idnumber'));\n\n // Check if config rule have been ported correctly.\n $competency4duplicated = competency::get_record(array(\n 'idnumber' => $competency4->get('idnumber'),\n 'competencyframeworkid' => $frameworkduplicated2->get('id')\n ));\n $configduplicated = json_decode($competency4duplicated->get('ruleconfig'), true);\n $configorigin = json_decode($config, true);\n // Check that the 2 config have the same base.\n $this->assertEquals($configorigin['base'], $configduplicated['base']);\n $this->assertEquals(count($configorigin['competencies']), count($configduplicated['competencies']));\n $competencyidsrules = array();\n foreach ($configduplicated['competencies'] as $key => $value) {\n // Check that the only difference between the 2 config is id competency.\n $this->assertEquals(1, count(array_diff($value, $configorigin['competencies'][$key])));\n $competencyidsrules[] = $value['id'];\n }\n $this->assertTrue($competency4duplicated->is_parent_of($competencyidsrules));\n\n // Test duplicate an empty framework.\n $emptyfrm = $lpg->create_framework();\n $emptyfrmduplicated = api::duplicate_framework($emptyfrm->get('id'));\n $this->assertEquals($emptyfrm->get('idnumber').'_1', $emptyfrmduplicated->get('idnumber'));\n $nbcomp = api::count_competencies(array('competencyframeworkid' => $emptyfrmduplicated->get('id')));\n $this->assertEquals(0, $nbcomp);\n\n }", "public function test_list_plans_with_competency() {\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $u1 = $this->getDataGenerator()->create_user();\n $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign the competency to each.\n $plan1 = $lpg->create_plan(array('userid' => $u1->id));\n $plan2 = $lpg->create_plan(array('userid' => $u1->id));\n\n $lpg->create_plan_competency(array('planid' => $plan1->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create one more plan without the competency.\n $plan3 = $lpg->create_plan(array('userid' => $u1->id));\n\n $plans = api::list_plans_with_competency($u1->id, $c1);\n\n $this->assertEquals(2, count($plans));\n\n $this->assertEquals(reset($plans)->get('id'), $plan1->get('id'));\n $this->assertEquals(end($plans)->get('id'), $plan2->get('id'));\n }", "public function testCloudPosCheckAddCourseToCheck()\n {\n }", "public function testCloudPosCheckAddItemsToCourse()\n {\n }", "public function testGetReservedCoupons()\n {\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_list_plan_competencies_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $viewrole = $dg->create_role(array(\n 'name' => 'User view',\n 'shortname' => 'view'\n ));\n assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);\n assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);\n $dg->role_assign($viewrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create draft plan with records in user_competency.\n $draftplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n // Check that user_competency objects are returned when plan status is not complete.\n $plancompetencies = api::list_plan_competencies($draftplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[0]->usercompetency);\n $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[1]->usercompetency);\n $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[2]->usercompetency);\n $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetencyplan);\n\n // Create completed plan with records in user_competency_plan.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'),\n 'planid' => $completedplan->get('id')));\n\n // Check that user_competency_plan objects are returned when plan status is complete.\n $plancompetencies = api::list_plan_competencies($completedplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[0]->usercompetencyplan);\n $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[1]->usercompetencyplan);\n $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[2]->usercompetencyplan);\n $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetency);\n }", "public function testCloudPosCheckAddPaymentStateToCourse()\n {\n }", "public function test_delete_plan_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $managerole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);\n $dg->role_assign($managerole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create completed plan with records in user_competency.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n\n api::delete_plan($completedplan->get('id'));\n\n // Check that achived user competencies are deleted.\n $this->assertEquals(0, \\core_competency\\plan::count_records());\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function testCloudPosCheckCancelCourseInCheck()\n {\n }", "public function testMajorDevelopments()\n {\n }", "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function testCloudPosCheckUpdateCoursesInCheck()\n {\n }", "public function testCloudPosCheckCancelItemInCourse()\n {\n }", "public function testCloudPosCheckCancelAllCoursesInCheck()\n {\n }", "public function testCloudPosCheckUpdateCourse()\n {\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_course_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n // Enrol students in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id);\n $dg->enrol_user($u1->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id);\n $dg->enrol_user($u2->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id);\n $dg->enrol_user($u3->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id);\n $dg->enrol_user($u4->id, $c1->id, $studentrole->id);\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 6 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id));\n\n // Rate some competencies.\n // User 1.\n api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test');\n // User 2.\n api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test');\n // User 3.\n api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test');\n api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test');\n // User 4.\n api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test');\n api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test');\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id);\n $this->assertEquals(4, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id);\n $this->assertEquals(0, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id);\n $this->assertEquals(2, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id);\n $this->assertEquals(0, $result);\n\n $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2);\n // We should get 5 and 6 in repeatable order.\n $valid = false;\n if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $valid = false;\n if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $expected = $result[1]->get('id');\n $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1);\n $this->assertEquals($result[0]->get('id'), $expected);\n }", "public function testCloudPosCheckDeleteCourseFromCheck()\n {\n }", "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "function testFunctionalDenyAdd() {\n\t\t$product = $this->objFromFixture('Product', 'p1a');\n\t\t$this->assertFalse($product->AllowPurchase(), 'The flag for allow purchase is set to FALSE.');\n\t\t$response = $this->get($product->URLSegment . '/add');\n\t\t$this->assertTrue($response->getBody() == '', 'Because we can\\'t purchase the product, we get a blank page with no content.');\n\t}", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "function testAddPartneringAgency() {\n $this->mods->addPartneringAgency(\"Purple Rain\", \"pa-purple\");\n $this->assertEqual(3, count($this->mods->partneringagencies));\n $this->assertIsA($this->mods->partneringagencies[2], \"mods_note\");\n $this->assertEqual(\"Purple Rain\", $this->mods->partneringagencies[2]->topic);\n $this->assertEqual(\"pa-purple\", $this->mods->partneringagencies[2]->id);\n // note: pattern is dependent on attribute order; this is how they are created currently\n $this->assertPattern('|ID=\"pa-purple\"|', $this->mods->saveXML());\n }", "public function testCloudPosCheckUpdateItemInCourse()\n {\n }", "public function test_that_authorized_user_can_view_courses_within_other_periods()\n {\n \n }", "public function testElementCategoryGetSecurity()\r\n {\r\n\r\n }", "public function testCloudPosCheckBumpCourseOnCheck()\n {\n }" ]
[ "0.6506787", "0.6283153", "0.62132895", "0.6020738", "0.5993479", "0.5951829", "0.5948896", "0.5936333", "0.5926783", "0.5917692", "0.5894083", "0.58630824", "0.5854003", "0.5804414", "0.57552004", "0.5715634", "0.5702992", "0.5649857", "0.563788", "0.5588708", "0.55859476", "0.55633396", "0.5554142", "0.5537283", "0.5498105", "0.5493773", "0.5476905", "0.5457084", "0.5441741", "0.5440889" ]
0.7316211
0
Test when using hidden template in plan/cohort.
public function test_hidden_template() { $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $user = $dg->create_user(); // Create a cohort. $cohort = $dg->create_cohort(); // Create a hidden template. $template = $lpg->create_template(array('visible' => false)); // Can not link hidden template to plan. try { api::create_plan_from_template($template->get('id'), $user->id); $this->fail('Can not link a hidden template to plan'); } catch (coding_exception $e) { $this->assertTrue(true); } // Can associate hidden template to cohort. $templatecohort = api::create_template_cohort($template->get('id'), $cohort->id); $this->assertInstanceOf('\core_competency\template_cohort', $templatecohort); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function test_no_filter_listing_view_with_shortcode() {\n\t\t$dynamic_view = self::get_view_by_key( 'dynamic-view' );\n\t\t$this->set_current_user_to_1();\n\t\t$dynamic_view->post_content .= 'user_id:[user_id]';\n\t\t$expected_content = array( 'Jamie', 'Steph', 'Steve', 'user_id:1' );\n\n\t\t$d = self::get_default_args( $dynamic_view, $expected_content, array() );\n\n\t\tself::run_get_display_data_tests( $d, 'dynamic view with no filters and shortcode' );\n\t}", "function test_no_filter_detail_view_with_shortcode() {\n\t\t$dynamic_view = self::get_view_by_key( 'single-view' );\n\t\t$this->set_current_user_to_1();\n\t\t$dynamic_view->post_content .= 'user_id:[user_id]';\n\t\t$expected_content = array( 'Jamie', 'user_id:1' );\n\n\t\t$d = self::get_default_args( $dynamic_view, $expected_content, array() );\n\n\t\tself::run_get_display_data_tests( $d, 'single entry view with no filters and shortcode' );\n\t}", "public function isTemplate()\n\t{\n\t}", "public function testAnonymousTemplateAccess() {\n $node = Node::create([\n 'title' => 'Test',\n 'type' => 'page',\n 'template' => TRUE,\n 'status' => NodeInterface::PUBLISHED,\n ]);\n $node->save();\n\n $this->assertFalse($node->access('view'));\n $this->assertFalse($node->access('update'));\n $this->assertFalse($node->access('delete'));\n }", "function get_wiki_page_statistics_reporting_template_name()\r\n {\r\n $this->not_available(Translation :: get('ImpossibleInPreviewMode'));\r\n }", "function get_wiki_statistics_reporting_template_name()\r\n {\r\n $this->not_available(Translation :: get('ImpossibleInPreviewMode'));\r\n }", "function test_template_plugin() {\n $this->demo_plugin->set_current_page('signin');\n $this->assertContains('templates/wpuc-signin.php', $this->demo_plugin->load_template_id('signin'));\n }", "function test_no_filter_listing_view() {\n\t\t$dynamic_view = self::get_view_by_key( 'dynamic-view' );\n\t\t$expected_content = array( 'Jamie', 'Steph', 'Steve' );\n\n\t\t$d = self::get_default_args( $dynamic_view, $expected_content, array() );\n\n\t\tself::run_get_display_data_tests( $d, 'dynamic view with no filters' );\n\n\t\tself::run_frm_vars_test( 1 );\n\t}", "public function testIfPageBlockIsHidden()\n {\n $page = $this->createPage();\n\n $page->blocks()->save($this->createPageBlock('', '', true));\n\n // 2. Act\n $response = $this->get('/home');\n\n // 3. Assert\n $response\n ->assertStatus(200)\n ->assertDontSee('<p>Hello world!</p>');\n }", "public function test_plans_visibility(){\n $planType = $this->createPlanType();\n\n $isVisible = true;\n $visiblePlan = $this->createPlan('visible_plan', $planType, false, [], $isVisible);\n\n $isVisible = false;\n $visiblePlan = $this->createPlan('hidden_plan', $planType, false, [], $isVisible);\n\n $this->assertEquals($planType->plans()->visible()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->hidden()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->count(), 2);\n }", "public function testRender_control_template_scripts0()\n{\n\n // Traversed conditions\n // if (!\\current_user_can('unfiltered_html')) == false (line 266)\n\n $actual = $this->wP_Widget_Custom_HTML->render_control_template_scripts();\n $expected = null; // TODO: Expected value here\n $this->assertEquals($expected, $actual);\n}", "public function isTemplate()\n {\n return true;\n }", "public function testTemplateViewAccess() {\n $node = Node::create([\n 'title' => 'Test',\n 'type' => 'page',\n 'template' => TRUE,\n 'status' => NodeInterface::PUBLISHED,\n ]);\n\n $node->save();\n $this->account->hasPermission('create content from templates', Argument::cetera())\n ->willReturn(TRUE);\n\n $this->assertTrue($node->access('view'));\n $this->assertFalse($node->access('update'));\n $this->assertFalse($node->access('delete'));\n }", "public function testRender_control_template_scripts1()\n{\n\n // Traversed conditions\n // if (!\\current_user_can('unfiltered_html')) == true (line 266)\n // if (!empty($disallowed_html)) == false (line 272)\n\n $actual = $this->wP_Widget_Custom_HTML->render_control_template_scripts();\n $expected = null; // TODO: Expected value here\n $this->assertEquals($expected, $actual);\n}", "public function testRender_control_template_scripts2()\n{\n\n // Traversed conditions\n // if (!\\current_user_can('unfiltered_html')) == true (line 266)\n // if (!empty($disallowed_html)) == true (line 272)\n\n $actual = $this->wP_Widget_Custom_HTML->render_control_template_scripts();\n $expected = null; // TODO: Expected value here\n $this->assertEquals($expected, $actual);\n}", "public function viewFailure(FunctionalTester $I)\n {\n $I->wantTo('Unsuccessfully view hotspot template');\n\n $regularUser = User::findOne(1002);\n $superUser = User::findOne(['status' => User::STATUS['ACTIVE'], 'type' => User::TYPE['SUPER']]);\n\n $I->amGoingTo('try accessing the action unauthorized');\n $I->sendGET('/hotspot-templates/1006');\n $I->seeUnauthorizedResponse();\n\n $I->amGoingTo('authorize as regular user and try to view hotspot template owned by another user');\n $I->haveHttpHeader('Authorization', 'Bearer ' . $regularUser->generateAccessToken());\n $I->sendGET('/hotspot-templates/1006');\n $I->seeNotFoundResponse();\n\n $I->amGoingTo('authorize as super user and try to view unexisting hotspot template');\n $I->haveHttpHeader('Authorization', 'Bearer ' . $superUser->generateAccessToken());\n $I->sendGET('/hotspot-templates/123456');\n $I->seeNotFoundResponse();\n }", "function test_dynamic_view_not_detail_page() {\n\t\tself::clear_get_values();\n\t\t$dynamic_view = self::get_view_by_key( 'dynamic-view' );\n\n\t\t// Red herring\n\t\t$_GET['entry'] = FrmEntry::get_id_by_key( 'steph_entry_key' );\n\n\t\t$expected_content = array( 'Jamie', 'Steph', 'Steve', 'href' );\n\t\t$d = self::get_default_args( $dynamic_view, $expected_content, array() );\n\n\t\tself::run_get_display_data_tests( $d, 'dynamic view not on detail page with extra entry param set' );\n\t}", "function test_template_theme() {\n $this->demo_plugin->set_current_page('signin');\n $this->demo_plugin->create_template('signin');\n $template_path = $this->demo_plugin->load_template_id('signin');\n $this->assertNotContains('templates/wpuc-signin.php', $template_path);\n @unlink($template_path);\n }", "public function testTemplate13()\n {\n }", "public function testThatHasDynamicsReturnFalseForNotDynamicUrl()\n {\n $result = $this->compiler->hasDynamics('foo/baz');\n $this->assertFalse($result);\n }", "public function testViewCommentsAreNotDisplayed()\n {\n $this->view->setContents('{# Testing #}');\n $this->assertEquals('', $this->fortuneCompiler->compile($this->view));\n }", "public function isHidden() {\n return !$this->_config_helper->hasBeenSetUp();\n }", "function worx_blog_vocab_template_access_summary($conf, $context) {\n if ($conf['worx_blog_vocab_template'] == 'worx_blog_vocab_template_one') {\n $template = t('Template One');\n }\n elseif ($conf['worx_blog_vocab_template'] == 'worx_blog_vocab_template_two') {\n $template = t('Template Two');\n }\n else {\n $template = t('Template Three');\n }\n return t('Display template is set to: ' . $template);\n}", "public function testPageSnippetPresence() {\n\n $this->drupalLogin($this->privilegedUser);\n\n // Enable all four projects.\n $edit = [\n 'optimizely_enabled' => 1,\n ];\n\n $this->drupalPostForm($this->update2Page, $edit, t('Update'));\n $this->drupalPostForm($this->update3Page, $edit, t('Update'));\n $this->drupalPostForm($this->update4Page, $edit, t('Update'));\n $this->drupalPostForm($this->update5Page, $edit, t('Update'));\n\n // Test that Project 2 was enabled.\n $this->drupalGet($this->listingPage);\n $this->assertRaw('name=\"project-2\" checked=\"checked\"',\n '<strong>Project 2 is enabled, ready to test path settings for presence of snippet.</strong>',\n 'Optimizely');\n\n $this->drupalLogout();\n\n $this->drupalLogin($this->anonymousUser);\n\n $num_projects = count($this->projectCode);\n for ($project_count = 0; $project_count <= $num_projects; $project_count++) {\n\n // Test project paths for presence of snippet.\n if (!empty($this->projectPaths[$project_count])) {\n $paths = explode(\"\\n\", $this->projectPaths[$project_count]);\n }\n else {\n $paths = [];\n }\n\n foreach ($paths as $path) {\n // End test if path value is invalid.\n if ($path == '') {\n break;\n }\n\n // Only test non wildcard paths.\n if (strpos($path, '/*') === FALSE) {\n // Look up the page defined in the project.\n $this->drupalGet($path);\n\n $target_html =\n '\"//cdn.optimizely.com/js/' . $this->projectCode[$project_count] . '.js\"';\n $this->assertRaw(\"src=$target_html\",\n \"<strong>Optimizely snippet call $target_html found</strong> at: \" . $path,\n 'Optimizely');\n }\n }\n\n }\n\n }", "function test_hidden_tag_should_not_exist()\n\t{\n\t\t$id = $this->factory->post->create( array(\n\t\t\t'post_type' => 'wpcf7_contact_form',\n\t\t\t'post_content' => '[text* your-name]'\n\t\t) );\n\t\t$html = do_shortcode( '[contact-form-7 id=\"'.$id.'\"]' );\n\t\t$res = preg_match( '#<input type=\"hidden\" name=\"__goto\" value=\"http://wp.test/archives/1\".+?>#', $html );\n\t\t$this->assertSame( 0, $res );\n\t}", "function test_template()\n {\n $t = $this->template;\n $t->setTemplate( 'case1.php' );\n $t->test = 'case1';\n $content = $t->render();\n $this->assertEquals( 'test:case1', $content );\n }", "public function testValidTemplate() {\n $t = new Template('foo-succeed');\n }", "public function test_view_route_not_logged_in(){\n // create a course\n $course = $this->getDataGenerator()->create_course();\n // create a course module\n $videoquanda = $this->getDataGenerator()->create_module('videoquanda', array(\n 'course' => $course->id\n ));\n\n $client = new Client($this->_app);\n $client->request('GET', \"/\" . $videoquanda->id);\n $this->assertEquals(500, $client->getResponse()->getStatusCode());\n\n }", "public function testBadTemplate2()\n {\n $t = new \\atk4\\ui\\Template();\n $this->assertFalse($t->tryLoad('bad_template_file'));\n }", "public function testBadTemplate2()\n {\n $t = new \\atk4\\ui\\Template();\n $this->assertFalse($t->tryLoad('bad_template_file'));\n }" ]
[ "0.5896201", "0.5841566", "0.5814852", "0.57891876", "0.57550496", "0.573137", "0.5712137", "0.5690251", "0.56842846", "0.56817824", "0.5589516", "0.55603915", "0.55439156", "0.5509731", "0.5476829", "0.5466159", "0.5464014", "0.5456853", "0.543898", "0.5396591", "0.53903437", "0.5382109", "0.53212905", "0.52930593", "0.5285655", "0.5283011", "0.52444345", "0.522673", "0.52194124", "0.52194124" ]
0.8426517
0
Test that completed plan created form a template does not change when template is modified.
public function test_completed_plan_doesnot_change() { global $DB; $this->resetAfterTest(true); $this->setAdminUser(); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $user = $dg->create_user(); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create template and assign competencies. $tp = $lpg->create_template(); $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id'))); $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id'))); $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id'))); // Create a plan form template and change it status to complete. $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id'))); api::complete_plan($plan); // Check user competency plan created correctly. $this->assertEquals(3, \core_competency\user_competency_plan::count_records()); $ucp = \core_competency\user_competency_plan::get_records(); $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id')); $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id')); $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id')); // Add and remove a competency from the template. api::add_competency_to_template($tp->get('id'), $c4->get('id')); api::remove_competency_from_template($tp->get('id'), $c1->get('id')); // Check that user competency plan did not change. $competencies = $plan->get_competencies(); $this->assertEquals(3, count($competencies)); $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id')); $ucp2 = array(); foreach ($competencies as $id => $cmp) { $ucp2[] = $id; } $this->assertEquals(0, count(array_diff($ucp1, $ucp2))); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_unapprove_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_ACTIVE);\n $tplplan->update();\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::unapprove_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are always approved./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Unapprove as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not unapprove the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Unapprove plan.\n $this->setUser($reviewer);\n api::unapprove_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Unapprove plan by ID.\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n api::unapprove_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function test_approve_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::approve_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are already approved./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Approve as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not approve the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Approve plan from in review.\n $this->setUser($reviewer);\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::approve_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from draft.\n $plan->set('status', plan::STATUS_DRAFT);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from waiting for review.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_replacement_of_default_plan(){\n $planType = $this->createPlanType();\n $isDefault = true;\n\n $firstDefaultPlan = $this->createPlan('first1_plan', $planType, $isDefault);\n $this->assertEquals($planType->getDefaultPlan()->id, $firstDefaultPlan->id);\n\n $secondDefaultPlan = $this->createPlan('second_plan', $planType, $isDefault);\n $this->assertEquals($planType->getDefaultPlan()->id, $secondDefaultPlan->id);\n\n $firstDefaultPlan->refresh();\n $this->assertFalse($firstDefaultPlan->is_default);\n }", "function test_template()\n {\n $t = $this->template;\n $t->setTemplate( 'case1.php' );\n $t->test = 'case1';\n $content = $t->render();\n $this->assertEquals( 'test:case1', $content );\n }", "public function testPostRecurringDepositTemplate()\n {\n }", "public function test_update_free_access_plan() {\n\t\t// Create free access plan.\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$access_plan_id = $response->get_data()['id'];\n\n\t\t// Update the title.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $access_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Updated Title',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$ap = new LLMS_Access_Plan( $access_plan_id );\n\t\t$this->assertEquals( $ap->get('title'), 'Updated Title' );\n\n\t}", "public function test_create_free_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$free_props = array(\n\t\t\t'is_free' => 'yes',\n\t\t\t'price' => 0,\n\t\t\t'frequency' => 0,\n\t\t\t'on_sale' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Check again, that even the passed properties are \"reset\".\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t\t'frequency' => 6,\n\t\t\t\t'sale_enabled' => true,\n\t\t\t\t'trial_enabled' => true,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t}", "public function testPostRecurringDepositTransactionsTemplate()\n {\n }", "public function testGetRecurringDepositTemplate()\n {\n }", "public function testTemplate13()\n {\n }", "public function test_create_paid_access_plan() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 10,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Now test that if the frequency is 0 (default) and we enable the trial, the trial is still disabled.\n\t\t$sample_args['trial_enabled'] = true;\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t\t'frequency' => 0,\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Test that a frequency > 0 unlocks trials.\n\t\t$sample_args['frequency'] = 1;\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$this->assertTrue(\n\t\t\tllms_parse_bool(\n\t\t\t\t( new LLMS_Access_Plan( $response->get_data()['id'] ) )->get( 'trial_offer' )\n\t\t\t)\n\t\t);\n\t}", "public function testGetRecurringDepositTransactionTemplate()\n {\n }", "public function test_hidden_template() {\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a cohort.\n $cohort = $dg->create_cohort();\n // Create a hidden template.\n $template = $lpg->create_template(array('visible' => false));\n\n // Can not link hidden template to plan.\n try {\n api::create_plan_from_template($template->get('id'), $user->id);\n $this->fail('Can not link a hidden template to plan');\n } catch (coding_exception $e) {\n $this->assertTrue(true);\n }\n\n // Can associate hidden template to cohort.\n $templatecohort = api::create_template_cohort($template->get('id'), $cohort->id);\n $this->assertInstanceOf('\\core_competency\\template_cohort', $templatecohort);\n }", "public function test_altering_access_plan_allowed_to_who_can_edit_parent_post() {\n\n\t\t$instructor = $this->factory->user->create(\n\t\t\tarray( 'role' => 'instructor' )\n\t\t);\n\t\t$assistant = $this->factory->user->create(\n\t\t\tarray( 'role' => 'instructors_assistant' )\n\t\t);\n\t\t$course = $this->factory->course->create_and_get();\n\n\t\t// Assign the instructors to the course.\n\t\t$course->set_instructors(\n\t\t\tarray(\n\t\t\t\tarray(\n\t\t\t\t\t'id' => $instructor\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'id' => $assistant\n\t\t\t\t),\n\t\t\t)\n\t\t);\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Instructors of the Course with post_id can manipulate.\n\t\twp_set_current_user( $instructor );\n\n\t\t// Creation is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 201, $response );\n\t\t$new_plan_id = $response->get_data()['id'];\n\n\t\t// Update is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $new_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Title can change',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\n\t\t// Deletion is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'DELETE',\n\t\t\t$this->route . '/' . $new_plan_id\n\t\t);\n\t\t$this->assertResponseStatusEquals( 204, $response );\n\n\t\t// Check the same happens with intructors assistants\n\n\t\t// Instructor's Assistant of the Course with post_id can manipulate.\n\t\twp_set_current_user( $assistant );\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t// Creation is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$this->assertResponseStatusEquals( 201, $response );\n\t\t$new_plan_id = $response->get_data()['id'];\n\n\t\t// Update is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/' . $new_plan_id,\n\t\t\tarray(\n\t\t\t\t'title' => 'Title can change',\n\t\t\t)\n\t\t);\n\n\t\t// Update is allowed.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\n\t\t// Deletion is allowed.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'DELETE',\n\t\t\t$this->route . '/' . $new_plan_id\n\t\t);\n\t\t$this->assertResponseStatusEquals( 204, $response );\n\n\t}", "public function testValidTemplate() {\n $t = new Template('foo-succeed');\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function test_plan_stop_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_stop_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Can not stop a review whe not in review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_stop_review($plan);\n $this->fail('The plan review cannot be stopped at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());\n }\n\n // Stopping as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_stop_review($plan);\n $this->fail('The user can not stop a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Stopping review.\n $this->setUser($reviewer);\n api::plan_stop_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Stopping review by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::plan_stop_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "function testScheduleUpdate() {\n //========================================= \n \n // To verify update Parlay Schedule is valid\n //========================================= \n }", "public function testWorkflow_Trial_Active_Prorated_Alt()\n {\n Setting::set('is_trial_inclusive', false);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->addDays(10)->day;\n $plan->trial_days = 14;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generateMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Status::STATUS_TRIAL, $service->status->code);\n $this->assertEquals(Carbon::now(), $service->current_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addDays(14), $service->current_period_end, '', 5);\n $this->assertEquals(1, $service->is_active);\n\n $now = $this->timeTravelDay(5);\n $this->workerProcess();\n\n // Pay the first invoice, activate membership\n $invoice->submitManualPayment('Testing');\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n $expectedDate = clone $now;\n $expectedPrice = $plan->adjustPrice(100, $expectedDate->addDays(9));\n\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($expectedPrice, $invoice->total);\n $this->assertEquals($now->addMonth()->addDays(5), $service->service_period_end, '', 5);\n }", "public function test_plan_start_review() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_start_review($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::plan_start_review($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Can not start a review when not waiting for review.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_start_review($plan);\n $this->fail('The plan review cannot be started at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());\n }\n\n // Starting as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_start_review($plan);\n $this->fail('The user can not start a review.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Starting review.\n $this->setUser($reviewer);\n api::plan_start_review($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status'));\n $this->assertEquals($reviewer->id, $plan->get('reviewerid'));\n\n // Starting review by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->set('reviewerid', null);\n $plan->update();\n api::plan_start_review($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_IN_REVIEW, $plan->get('status'));\n $this->assertEquals($reviewer->id, $plan->get('reviewerid'));\n }", "function test_template()\n {\n $t = $this->template;\n $case = __DIR__ . '/templates/case1.php';\n $content = $t->render( $case, array( 'test' => 'case1' ) );\n $this->assertEquals( 'test:case1', $content );\n }", "function test_template_theme() {\n $this->demo_plugin->set_current_page('signin');\n $this->demo_plugin->create_template('signin');\n $template_path = $this->demo_plugin->load_template_id('signin');\n $this->assertNotContains('templates/wpuc-signin.php', $template_path);\n @unlink($template_path);\n }", "public function test_update_non_existent_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route . '/12569',\n\t\t\t$this->sample_access_plan_args\n\t\t);\n\n\t\t// Not found.\n\t\t$this->assertResponseStatusEquals( 404, $response );\n\n\t}", "public function test_unique_not_cancelled_subscription_in_plan_type(){\n Event::fake();\n\n $planType = $this->createPlanType('user_membership');\n $plan = $this->createPlan('plan', $planType);\n $periodOne = Subscriptions::period($this->faker->sentence(3), 'period_one', $plan)\n ->create();\n $periodTwo = Subscriptions::period($this->faker->sentence(3), 'period_two', $plan)\n ->create();\n\n $user = $this->createUser();\n\n $this->assertTrue($user->subscribeTo($periodOne));\n Event::assertDispatched(NewSubscription::class);\n\n $this->assertFalse($user->subscribeTo($periodTwo));\n $this->assertTrue($user->hasSubscription($planType));\n $this->assertTrue($user->hasSubscription('user_membership'));\n }", "public function test_create_access_plan_forbidden() {\n\t\twp_set_current_user( $this->user_forbidden );\n\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $this->factory->course->create(),\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Forbidden.\n\t\t$this->assertResponseStatusEquals( 403, $response );\n\n\t\t// Check that a generic instructor can't create an access plan.\n\t\twp_set_current_user( $this->factory->user->create( array( 'role' => 'instructor' ) ) );\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t}", "public function test_creation_defaults_respected() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t/**\n\t\t * see LLMS_REST_Access_Plans_Controller::unset_subordinate_props()\n\t\t */\n\t\t$deps = array(\n\t\t\t'access_length' => 0, // This is not set if 'access_expiration' is not 'limited-period' (default is 'lifetime').\n\t\t\t'access_period' => '', // This is not set if 'access_expiration' is not 'limited-period' (default is 'lifetime').\n\t\t\t'access_expires' => '', // This is not set if 'access_expiration' is not 'limited-period' (default is 'lifetime').\n\n\t\t\t'period' => '' , // This is not set if 'frequency' is 0 (default).\n\n\t\t\t'trial_length' => 0, // This is not set if 'trial_offer' is 'no' (default).\n\t\t\t'trial_period' => '', // This is not set if 'trial_offer' is 'no' (default).\n\t\t);\n\n\t\tforeach ( array_merge( $this->defaults, $deps ) as $prop => $val ) {\n\t\t\t$this->assertEquals( $val, $response->get_data()[$prop], $prop );\n\t\t}\n\n\t}", "public function test_plan_cancel_review_request() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($user);\n try {\n api::plan_cancel_review_request($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan cannot be sent for review at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Can not cancel review request when not waiting for review.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The plan review cannot be cancelled at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());\n }\n\n // Cancelling as a reviewer.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::plan_cancel_review_request($plan);\n $this->fail('The user can not cancel a review request.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Cancelling review request.\n $this->setUser($user);\n api::plan_cancel_review_request($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Cancelling review request by ID.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::plan_cancel_review_request($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "function test_update_new() {\n\t}", "public function createPlan() {\n $plan = new Plan();\n // # Basic Information\n // Fill up the basic information that is required for the plan\n $plan->setName('Daily Edition')->setDescription('Template creation 20.')->setType('fixed');\n // # Payment definitions for this billing plan.\n $paymentDefinition = new PaymentDefinition();\n // The possible values for such setters are mentioned in the setter method documentation.\n // Just open the class file. e.g. lib/PayPal/Api/PaymentDefinition.php and look for setFrequency method.\n // You should be able to see the acceptable values in the comments.\n $paymentDefinition\n ->setName('Regular Payments')\n ->setType('REGULAR')\n ->setFrequency('DAY')\n ->setFrequencyInterval(\"2\")\n ->setCycles(\"700\")\n ->setAmount(new Currency(array('value' => 1, 'currency' => 'EUR')));\n // Charge Models\n// $chargeModel = new ChargeModel();\n// $chargeModel->setType('SHIPPING')->setAmount(new Currency(array('value' => 10, 'currency' => 'USD')));\n// $paymentDefinition->setChargeModels(array($chargeModel));\n $merchantPreferences = new MerchantPreferences();\n $baseUrl = PaypalManager::getBaseUrl();\n // ReturnURL and CancelURL are not required and used when creating billing agreement with payment_method as \"credit_card\".\n // However, it is generally a good idea to set these values, in case you plan to create billing agreements which accepts \"paypal\" as payment_method.\n // This will keep your plan compatible with both the possible scenarios on how it is being used in agreement.\n $merchantPreferences\n ->setReturnUrl(\"$baseUrl/ExecuteAgreement.php?success=true\")\n ->setCancelUrl(\"$baseUrl/ExecuteAgreement.php?success=false\")\n ->setAutoBillAmount(\"yes\")->setInitialFailAmountAction(\"CONTINUE\")\n ->setMaxFailAttempts(\"0\")\n ->setSetupFee(new Currency(array('value' => 1, 'currency' => 'EUR')));\n\n $plan->setPaymentDefinitions(array($paymentDefinition));\n $plan->setMerchantPreferences($merchantPreferences);\n// For Sample Purposes Only.\n $request = clone $plan;\n// ### Create Plan\n try {\n $output = $plan->create($this->apiContext);\n } catch (\\Exception $ex) {\n // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY\n ResultPrinter::printError(\"Created Plan\", \"Plan\", null, $request, $ex);\n exit(1);\n }\n// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY\n //ResultPrinter::printResult(\"Created Plan\", \"Plan\", $output->getId(), $request, $output);\n return $output;\n }" ]
[ "0.635405", "0.630216", "0.62703055", "0.621109", "0.61590326", "0.61323124", "0.60903215", "0.60817814", "0.6051327", "0.59611815", "0.59263104", "0.592496", "0.5916958", "0.5881434", "0.58700234", "0.5862165", "0.58370274", "0.5825353", "0.58052367", "0.57993954", "0.5782634", "0.5773371", "0.57653725", "0.5740849", "0.572769", "0.5704455", "0.5697787", "0.5696022", "0.56956816", "0.56898" ]
0.7699026
0
Assert that a competency was graded in a course.
protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1) { $beforecount = evidence::count_records(); api::grade_competency_in_course($courseid, $userid, $compid, $grade); $this->assertEquals($beforecount + 1, evidence::count_records()); $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $compid)); $records = evidence::get_records(array(), 'id', 'DESC', 0, 1); $evidence = array_pop($records); $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "public function test_course_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n // Enrol students in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id);\n $dg->enrol_user($u1->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id);\n $dg->enrol_user($u2->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id);\n $dg->enrol_user($u3->id, $c1->id, $studentrole->id);\n $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id);\n $dg->enrol_user($u4->id, $c1->id, $studentrole->id);\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 6 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id));\n\n // Rate some competencies.\n // User 1.\n api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test');\n api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test');\n // User 2.\n api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test');\n api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test');\n // User 3.\n api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test');\n api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test');\n // User 4.\n api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test');\n api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test');\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id);\n $this->assertEquals(4, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id);\n $this->assertEquals(0, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id);\n $this->assertEquals(2, $result);\n $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id);\n $this->assertEquals(0, $result);\n\n $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2);\n // We should get 5 and 6 in repeatable order.\n $valid = false;\n if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $valid = false;\n if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) {\n $valid = true;\n }\n $this->assertTrue($valid);\n $expected = $result[1]->get('id');\n $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1);\n $this->assertEquals($result[0]->get('id'), $expected);\n }", "function testCoChairs() {\n $this->mods->addCommittee(\"Harrison\", \"George\", \"chair\");\n $this->assertEqual(2, count($this->mods->chair));\n $this->assertEqual(\"Harrison\", $this->mods->chair[1]->last);\n }", "public function test_set_ruleoutcome_course_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $course = $dg->create_course();\n\n $this->setAdminUser();\n $f = $lpg->create_framework();\n $c = $lpg->create_competency(array('competencyframeworkid' => $f->get('id')));\n $cc = api::add_competency_to_course($course->id, $c->get('id'));\n\n // Check record was created with default rule value Evidence.\n $this->assertEquals(1, \\core_competency\\course_competency::count_records());\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_EVIDENCE,\n $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n\n // Check ruleoutcome value is updated to None.\n $this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get('id'),\n \\core_competency\\course_competency::OUTCOME_NONE));\n $recordscc = api::list_course_competencies($course->id);\n $this->assertEquals(\\core_competency\\course_competency::OUTCOME_NONE, $recordscc[0]['coursecompetency']->get('ruleoutcome'));\n }", "protected function assertExceptionWithGradeCompetencyInCourse($exceptiontype, $exceptiontext, $courseid, $userid, $compid,\n $grade = 1) {\n\n $raised = false;\n try {\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n } catch (moodle_exception $e) {\n $raised = true;\n $this->assertInstanceOf($exceptiontype, $e);\n $this->assertRegExp('@' . $exceptiontext . '@', $e->getMessage());\n }\n\n if (!$raised) {\n $this->fail('Grading should not be allowed.');\n }\n }", "public function testCloudPosCheckAddCourseToCheck()\n {\n }", "public function testEvaluationCompleteLevelC2()\n {\n $placementTestService = new LevelAssessmentService();\n\n $result = $placementTestService->calculateLevel($this->exercisesDataProviderSet3());\n\n $this->assertEquals('C2', $result);\n }", "public function testActivateOrgSurveyPass()\n {\n $communityId = 6;\n $this->assertAlertable($communityId, 'activateOrganizationsSurvey');\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function testCloudPosCheckBumpCourseOnCheck()\n {\n }", "public function test_that_authorized_user_can_view_courses_within_other_periods()\n {\n \n }", "public function testAddCourse()\n {\n $data = ['id' => 'PRJG5'];\n $course1 = factory(Course::class)->create($data);\n $course = Course::find('PRJG5');\n $this->assertDatabaseHas('courses', $data);\n }", "public function testDeleteCourse()\n {\n $data = ['id' => 'PRJG5'];\n $course = factory(Course::class)->create($data);\n Course::destroy('PRJG5');\n $this->assertDatabaseMissing('courses', $data);\n }", "public function testEvaluationNotComplete()\n {\n $placementTestService = new LevelAssessmentService();\n\n $result = $placementTestService->calculateLevel($this->exercisesDataProviderSet1());\n\n $this->assertFalse($result);\n }", "public function testCloudPosCheckDeleteCourseFromCheck()\n {\n }", "public function test_add_evidence_no_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $this->assertEquals(0, \\core_competency\\user_competency::count_records());\n\n // Create an evidence without a user competency record.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', 'Hello world!', false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n $this->assertEquals(1, \\core_competency\\user_competency::count_records());\n\n $uc = \\core_competency\\user_competency::get_record(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $evidence->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals('Hello world!', $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function testCloudPosCheckUpdateCourse()\n {\n }", "function test_makeGame_compScissorsWins()\n {\n //Arrange\n $test_Game = new Game;\n $user = \"paper\";\n $comp = \"scissors\";\n $is_random = false;\n\n //Act\n $result = $test_Game->makeGame($user, $comp, $is_random);\n\n //Assert\n $this->assertEquals(\"You lose.\", $result);\n }", "public function test_add_evidence_existing_user_competency() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $this->assertSame(null, $uc->get('grade'));\n $this->assertSame(null, $uc->get('proficiency'));\n\n // Create an evidence and check it was created with the right usercomptencyid and information.\n $evidence = api::add_evidence($user->id, $c1->get('id'), $syscontext->id, \\core_competency\\evidence::ACTION_OVERRIDE,\n 'invalidevidencedesc', 'core_competency', array('a' => 'b'), false, 'http://moodle.org', 1, 2);\n $this->assertEquals(1, \\core_competency\\evidence::count_records());\n\n $evidence->read();\n $uc->read();\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n $this->assertEquals('invalidevidencedesc', $evidence->get('descidentifier'));\n $this->assertEquals('core_competency', $evidence->get('desccomponent'));\n $this->assertEquals((object) array('a' => 'b'), $evidence->get('desca'));\n $this->assertEquals('http://moodle.org', $evidence->get('url'));\n $this->assertEquals(\\core_competency\\evidence::ACTION_OVERRIDE, $evidence->get('action'));\n $this->assertEquals(2, $evidence->get('actionuserid'));\n $this->assertEquals(1, $evidence->get('grade'));\n $this->assertEquals(1, $uc->get('grade'));\n $this->assertEquals(0, $uc->get('proficiency'));\n }", "public function doTestCrits($turn){\n\t\tif ($this->salvo && $this->mission->arrived){return;}\n\t\tfor ($i = 0; $i < sizeof($this->structures); $i++){\n\t\t\tif ($this->structures[$i]->destroyed){continue;}\n\t\t\t$dmg = $this->structures[$i]->getRelDmg($turn);\n\t\t\tif (!$dmg->new){continue;}\n\t\t\t$this->structures[$i]->determineCrit($dmg, $turn, 0);\n\t\t}\n\t\t$this->isDestroyed();\n\t}", "public function testCloudPosCheckCancelCourseInCheck()\n {\n }", "public function testCloudPosCheckAddPaymentStateToCourse()\n {\n }", "function test_makeGame_compPaperWins()\n {\n //Arrange\n $test_Game = new Game;\n $user = \"rock\";\n $comp = \"paper\";\n $is_random = false;\n\n //Act\n $result = $test_Game->makeGame($user, $comp, $is_random);\n\n //Assert\n $this->assertEquals(\"You lose.\", $result);\n }", "function checkCourseStatus($creditPointsObtained, $coursePoints, $failedUnits,$failedUnitCount)\n {\n // Check if the student has completed more than 66% of the course.\n $completedAvg = ($creditPointsObtained / $coursePoints)*100;\n $completion = ($completedAvg > 66.6 ? true : false );\n\n // Check if student has failed a single unit and is eligible for a supp assessment or conceded pass.\n if(count($failedUnits) == 1)\n {\n foreach ($failedUnits as $unitCode => $unitMark) \n {\n if($unitMark >= 40 && $unitMark <= 45 && $completion)\n {\n return \"Unit ID: <strong>\" . $unitCode . \"</strong> has been given a <strong>Supplementary Assessment</strong><br/>\";\n }\n\n elseif($unitMark >= 46 && $unitMark <= 49 && $completion)\n {\n return \"Unit ID: <strong>\" . $unitCode . \"</strong> has been given a <strong>Conceded Pass</strong><br/>\";\n }\n }\n }\n\n foreach ($failedUnitCount as $unitCode => $attempts) \n {\n if($attempts > 2)\n {\n return \"<strong>EXCLUDED FROM COURSE! </strong><br/>\";\n }\n }\n\n // If obtained more points than the required points, indicate course complete. Else, calculate the number of\n // credit points required for the student to complete the course.\n if($creditPointsObtained > $coursePoints)\n {\n return \"<strong>SUCCESSFULLY COMPLETED! </strong></br>\";\n }\n\n else\n {\n $CPForCompletion = $coursePoints - $creditPointsObtained;\n return \"<strong>$CPForCompletion CP</strong> Required for Completion</br>\";\n }\n }", "public function testCloudPosCheckUpdateCoursesInCheck()\n {\n }", "function test_recuperar_claves()\n\t{\n\t\t$this->assertEqualArray( $this->dt->get_clave(), array('id') );\n\t}", "public function testUpdateValidCourse()\n {\n $data = factory(Course::class)->create(['id' => 'PRJG5']);\n $course = Course::find('PRJG5');\n $course->id = 'DONG5';\n $course->save();\n $other = Course::find('DONG5');\n $this->assertEquals('DONG5', $other->id);\n }" ]
[ "0.6808393", "0.6526491", "0.63460344", "0.6262633", "0.59452534", "0.57278395", "0.57250804", "0.5654679", "0.5631569", "0.5581414", "0.5561453", "0.55598825", "0.5539885", "0.55043125", "0.55029607", "0.54805493", "0.5478935", "0.5461296", "0.5436758", "0.5430341", "0.5423246", "0.54097754", "0.53896993", "0.53545105", "0.5325124", "0.53202283", "0.53178525", "0.5291934", "0.5284077", "0.5279854" ]
0.6648364
1
Assert that grading a competency in course throws an exception.
protected function assertExceptionWithGradeCompetencyInCourse($exceptiontype, $exceptiontext, $courseid, $userid, $compid, $grade = 1) { $raised = false; try { api::grade_competency_in_course($courseid, $userid, $compid, $grade); } catch (moodle_exception $e) { $raised = true; $this->assertInstanceOf($exceptiontype, $e); $this->assertRegExp('@' . $exceptiontext . '@', $e->getMessage()); } if (!$raised) { $this->fail('Grading should not be allowed.'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "protected function assertSuccessWithGradeCompetencyInCourse($courseid, $userid, $compid, $grade = 1) {\n $beforecount = evidence::count_records();\n api::grade_competency_in_course($courseid, $userid, $compid, $grade);\n $this->assertEquals($beforecount + 1, evidence::count_records());\n $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $compid));\n $records = evidence::get_records(array(), 'id', 'DESC', 0, 1);\n $evidence = array_pop($records);\n $this->assertEquals($uc->get('id'), $evidence->get('usercompetencyid'));\n }", "public function test_add_evidence_user_competency_course_grade_in_course() {\n global $USER;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n\n // Create and assign a current user.\n $currentuser = $dg->create_user();\n $this->setUser($currentuser);\n\n // Create a course.\n $course = $dg->create_course();\n $record = array('courseid' => $course->id, 'pushratingstouserplans' => false);\n $settings = new course_competency_settings(0, (object) $record);\n $settings->create();\n $coursecontext = context_course::instance($course->id);\n\n // Create a student and enrol into the course.\n $student = $dg->create_user();\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $dg->role_assign($studentrole->id, $student->id, $coursecontext->id);\n $dg->enrol_user($student->id, $course->id, $studentrole->id);\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n // Do not push ratings from course to user plans.\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('courseid' => $course->id, 'competencyid' => $comp->get('id')));\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n 'courseid' => $course->id\n );\n\n // Add evidence that sets a grade to the course.\n $evidence = api::add_evidence($student->id, $comp, $coursecontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 3, $USER->id);\n // Get user competency course record.\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be a user_competency_course object when adding a grade.\n $this->assertNotEmpty($usercompcourse);\n $grade = $evidence->get('grade');\n $this->assertEquals($grade, $usercompcourse->get('grade'));\n $this->assertEquals(3, $usercompcourse->get('grade'));\n $proficiency = $comp->get_proficiency_of_grade($grade);\n $this->assertEquals($proficiency, $usercompcourse->get('proficiency'));\n\n // Confirm that the user competency's grade/proficiency has not been affected by the grade.\n $usercompetencyparams = [\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n ];\n $usercompetency = \\core_competency\\user_competency::get_record($usercompetencyparams);\n $this->assertNotEmpty($usercompetency);\n $this->assertNotEquals($usercompcourse->get('grade'), $usercompetency->get('grade'));\n $this->assertNotEquals($usercompcourse->get('proficiency'), $usercompetency->get('proficiency'));\n }", "public function test_add_evidence_for_user_competency_course_grade_outside_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $syscontext = context_system::instance();\n\n // Create a student.\n $student = $dg->create_user();\n\n // Create a competency for the course.\n $lpg = $dg->get_plugin_generator('core_competency');\n $framework = $lpg->create_framework();\n $comp = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Add evidence.\n api::add_evidence($student->id, $comp, $syscontext, evidence::ACTION_OVERRIDE,\n 'commentincontext', 'core', null, false, null, 1);\n\n // Query for user_competency_course data.\n $filterparams = array(\n 'userid' => $student->id,\n 'competencyid' => $comp->get('id'),\n );\n $usercompcourse = \\core_competency\\user_competency_course::get_record($filterparams);\n // There should be no user_competency_course object created when grading.\n $this->assertFalse($usercompcourse);\n }", "public function test_validate_grade_in_user_competency() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n $s1 = $dg->create_scale(array(\"scale\" => \"value1, value2\"));\n $s2 = $dg->create_scale(array(\"scale\" => \"value3, value4, value5, value6\"));\n\n $scaleconfiguration1 = '[{\"scaleid\":\"'.$s1->id.'\"},{\"name\":\"value1\",\"id\":1,\"scaledefault\":1,\"proficient\":0},' .\n '{\"name\":\"value2\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n $scaleconfiguration2 = '[{\"scaleid\":\"'.$s2->id.'\"},{\"name\":\"value3\",\"id\":1,\"scaledefault\":1,\"proficient\":0},'\n . '{\"name\":\"value4\",\"id\":2,\"scaledefault\":0,\"proficient\":1}]';\n\n // Create a framework with scale configuration1.\n $frm = array(\n 'scaleid' => $s1->id,\n 'scaleconfiguration' => $scaleconfiguration1\n );\n $framework = $lpg->create_framework($frm);\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create competency with its own scale configuration.\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'),\n 'scaleid' => $s2->id,\n 'scaleconfiguration' => $scaleconfiguration2\n ));\n\n // Detecte invalid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 3 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in framework scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Detecte invalid grade in competency using its own scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 5 ));\n $usercompetency->create();\n $this->fail('Invalid grade not detected in competency scale');\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->assertTrue(true);\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in framework scale');\n }\n\n // Accept valid grade in competency using its framework competency scale.\n try {\n $usercompetency = new user_competency(0, (object) array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => true, 'grade' => 4 ));\n $usercompetency->create();\n $this->assertTrue(true);\n } catch (\\core\\invalid_persistent_exception $e) {\n $this->fail('Valide grade rejected in competency scale');\n }\n }", "public function testAddCourseWithExistingTitle()\n {\n $course1 = factory(Course::class)->create(['title' => 'Abigail',]);\n $this->expectException(\\PDOException::class);\n $course2 = factory(Course::class)->create(['title' => 'Abigail',]);\n }", "public function testAmountException(): void\n {\n $this->expectException(Exception::class);\n\n new PercentageFee(-10);\n }", "public function testUsersAlsoBoughtException()\n {\n $this->setExpectedException('InvalidArgumentException');\n $this->easyrec->usersAlsoBought(self::ITEM_ID, null, 'not a number of results');\n }", "public function testConstructThrowsExceptionIfCIsNotANumber()\n {\n $this->setExpectedException('InvalidArgumentException');\n \n new Quadratic(1, 1, 'foo');\n \n return;\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function testGetScoreBeforeEvaluating()\n {\n $this->expectException(Exception::class);\n\n $evaluator = new LanguageDetector();\n $evaluator->getScores();\n }", "public function testCloudPosCheckAddCourseToCheck()\n {\n }", "public function testAddCourseWithExistingId()\n {\n $course1 = factory(Course::class)->create(['id' => 'DONG5',]);\n $this->expectException(\\PDOException::class);\n $course2 = factory(Course::class)->create(['id' => 'DONG5',]);\n }", "public function testRatedGoodByOtherException()\n {\n $this->setExpectedException('InvalidArgumentException');\n $this->easyrec->ratedGoodByOther(self::ITEM_ID, null, 'not a number of results');\n }", "public function testBadConstruction() {\r\n $scenario = $this->getTestBehatScenario(5);\r\n $result = $this->executeTestBehatScenario($scenario);\r\n $this->assertTestFailed($result);\r\n $exceptionMessages = [\r\n \"Scenario '#5 Bad construction' had steps:\",\r\n \"Failed: Given a badly constructed step\",\r\n ];\r\n $this->assertBehatScenarioAssertion($scenario, UnknownParameterValueException::class, $exceptionMessages);\r\n }", "public function testEvaluationNotComplete()\n {\n $placementTestService = new LevelAssessmentService();\n\n $result = $placementTestService->calculateLevel($this->exercisesDataProviderSet1());\n\n $this->assertFalse($result);\n }", "public function testException() {\n\n $this->setExpectedException($this->klade->addEntry(''));\n }", "public function testCloudPosCheckCancelCourseInCheck()\n {\n }", "private function ensure_category() {\n\t\t/*\n\t\t * Ensure there is at least one manual grading category\n\t\t */\n\t\tif(count($this->gradeParts) === 0) {\n\t\t\t$this->add_manual(100, 'manual', 'Grade');\n\t\t}\n\t}", "public function test_failed_search_type()\n {\n $this->expectException(\\Atomescrochus\\Gracenote\\Exceptions\\UsageErrors::class);\n $this->expectExceptionMessage('This search type is invalid.');\n\n $gracenote = new \\Atomescrochus\\Gracenote\\Gracenote();\n $gracenote->searchType('this_is_wrong');\n }", "public function test_build_called_throwException()\n {\n $data = [\n 'lottery_id' => 1,\n 'numBets' => 3,\n ];\n $this->setExpectedException('\\Exception');\n $sut = new BigWinningGenerator();\n $sut->build($data);\n }", "public function testSaveStrategyInvalid(): void\n {\n $this->expectException(InvalidArgumentException::class);\n $this->expectExceptionMessage('Invalid save strategy `depsert`');\n new BelongsToMany('Test', ['saveStrategy' => 'depsert']);\n }", "public function testarDeveRecusarLanceZerado(){\n $this->setExpectedException('InvalidArgumentException'); \n\n $leilao = new Leilao( 'Macbook pro' );\n \n $renan = new Usuario( 'Renan' );\n\n $leilao->propoe( new Lance( $renan , 0 ) );\n\n }", "public function testActivateOrgSurveyFailInactiveCommunity()\n {\n $communityId = 6;\n $this->deactivateCommunity($communityId);\n $this->assertUnalertable($communityId, 'activateOrganizationsSurvey');\n }", "public function testarDeveRecusarLeilaoSemLance(){\n $this->setExpectedException('InvalidArgumentException'); \n\n $leilao = new Leilao( 'Macbook pro' );\n\n $renan = new Usuario( 'Renan' );\n \n $leiloeiro = new Avaliador();\n $leiloeiro->avalia( $leilao );\n\n }", "public function testNonExistentConstraintThrowsException(): void\n {\n $this->expectException(GeneratorException::class);\n $this->expectExceptionMessage(\"Constraint class 'Symfony\\Component\\Validator\\Constraints\\BlahBlah' doesn't exist.\");\n\n parent::setUp();\n static::bootKernel(['test_case' => 'nonexistentConstraint']);\n }", "public function testException()\n {\n $rules = ['text' => ['required', 'max:5', 'samed:code']];\n $validator = new Validator(['text' => 'code'], $rules);\n try {\n $validator->passed();\n }catch (\\Exception $ex){\n $this->assertInstanceOf(RuleNotFoundException::class, $ex);\n }\n }", "public function testInvalidCardAmountOfBlackHandException()\n {\n $this->setExpectedException('InvalidArgumentException', 'invalid card amount for black hand');\n\n $pokerCards = new PokerCards();\n $pokerCards->setBlackHand(array('3D', '5S', '9C', 'KD', 'AH', 'JD'));\n }", "public function testGetFundingOrganizationInvalid()\n {\n $this->assertSame(\n $this->testFundingOrganization,\n $this->fundingCycle->getFundingOrganization()\n );\n }", "public function testActivateOrgSurveyFailNotPurchased()\n {\n $communityId = 6;\n $this->purchases->deleteAll(['community_id' => $communityId]);\n $this->assertUnalertable($communityId, 'activateOrganizationsSurvey');\n }", "public function testStrategyFailure(): void\n {\n $this->expectException(InvalidArgumentException::class);\n $this->expectExceptionMessage('Invalid strategy `join` was provided');\n $assoc = new BelongsToMany('Test');\n $assoc->setStrategy(BelongsToMany::STRATEGY_JOIN);\n }" ]
[ "0.618541", "0.60569996", "0.60539395", "0.6003477", "0.59639734", "0.59375274", "0.5806424", "0.57742214", "0.57320464", "0.57270974", "0.5662511", "0.56491315", "0.5632842", "0.5623843", "0.5543011", "0.5540197", "0.5539107", "0.5536889", "0.55262995", "0.55130327", "0.5489514", "0.5488352", "0.54784733", "0.54665005", "0.5429719", "0.542908", "0.54202247", "0.5413386", "0.5408046", "0.54017496" ]
0.67678696
0
Test list of evidences for plan completed and not completed.
public function test_list_evidence() { global $DB; $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $syscontext = context_system::instance(); // Create users. $user = $dg->create_user(); $this->setUser($user); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create 2 user plans and add competency to each plan. $p1 = $lpg->create_plan(array('userid' => $user->id)); $p2 = $lpg->create_plan(array('userid' => $user->id)); $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id'))); $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id'))); // Create user competency and add an evidence. $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'))); $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id'))); // Check both plans as one evidence. $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id')))); $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id')))); // Complete second plan. $p2->set('status', plan::STATUS_COMPLETE); $p2->update(); // Add another evidence for the same competency, but in the future (time + 1). $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id'))); $evidencesql = "UPDATE {" . evidence::TABLE . "} SET timecreated = :currenttime WHERE id = :evidenceid"; $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id'))); // Check that the first plan, which is not completed, has all the evidence. $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id')))); // Check that the second plan, completed before the new evidence, only has the first piece of evidence. $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id')); $this->assertEquals(1, count($listevidences)); $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function check_completed()\n\t{\n\t\tif (!is_cli())\n\t\t{\n\t\t\techo \"This script can only be accessed via the command line\" . PHP_EOL;\n\t\t\treturn;\n\t\t}\n\n\t\t// Set the language to Dutch (TODO: set to language of participant?)\n\t\treset_language(L::DUTCH);\n\n\t\t// Get all testinvites that have not yet been completed\n\t\t$testinvites = $this->testInviteModel->get_not_completed_testinvites(); \n\t\tforeach ($testinvites as $testinvite)\n\t\t{\n\t\t\t$testsurvey = $this->testInviteModel->get_testsurvey_by_testinvite($testinvite);\n\t\t\t// If the survey still exists in LimeSurvey...\n\t\t\tif ($this->surveyModel->get_survey_by_id($testsurvey->limesurvey_id))\n\t\t\t{\n\t\t\t\t// Check with LimeSurvey whether the survey has actually been completed\n\t\t\t\t$result = $this->surveyModel->get_result_by_token($testsurvey->limesurvey_id, $testinvite->token);\n\t\t\t\tif ($result) \n\t\t\t\t{\n\t\t\t\t\t// If there is actually a result row, set the survey to completed\n\t\t\t\t\t$this->testInviteModel->set_completed($testinvite->id, $result->submitdate);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "public function videos_could_be_queried_with_status()\n {\n $activeVideoQty = random_int(1, 10);\n factory(Video::class, $activeVideoQty)\n ->states('active')\n ->create();\n\n $inActiveVideoQty = random_int(1, 10);\n factory(Video::class, $inActiveVideoQty)\n ->states('inactive')\n ->create();\n\n //status\n //act + assert\n $queryResult = $this->videoFilter->getList(['active' => true]);\n $this->assertCount($activeVideoQty, $queryResult);\n\n //act + assert\n $queryResult = $this->videoFilter->getList(['active' => false]);\n $this->assertCount($inActiveVideoQty, $queryResult);\n }", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function test_plans_visibility(){\n $planType = $this->createPlanType();\n\n $isVisible = true;\n $visiblePlan = $this->createPlan('visible_plan', $planType, false, [], $isVisible);\n\n $isVisible = false;\n $visiblePlan = $this->createPlan('hidden_plan', $planType, false, [], $isVisible);\n\n $this->assertEquals($planType->plans()->visible()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->hidden()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->count(), 2);\n }", "function hasCompleted($subtasks)\n{\n if (in_array('1', $subtasks->lists('is_complete')))\n {\n return true;\n }\n return false;\n}", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function testOptOutListings()\n {\n\n }", "public function testStatementInProgress() : void {\n $provider = $this->getReference('provider.1');\n $deposit = $this->getReference('deposit.1');\n $crawler = $this->client->request(\n 'GET',\n '/api/sword/2.0/cont-iri/' . $provider->getUuid() . '/' . $deposit->getUuid() . '/state'\n );\n $response = $this->client->getResponse();\n $this->assertSame(200, $response->getStatusCode());\n $this->assertStringContainsStringIgnoringCase('LOCKSS boxes have not completed', $response->getContent());\n }", "public function test_list_plan_competencies_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $viewrole = $dg->create_role(array(\n 'name' => 'User view',\n 'shortname' => 'view'\n ));\n assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);\n assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);\n $dg->role_assign($viewrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create draft plan with records in user_competency.\n $draftplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n // Check that user_competency objects are returned when plan status is not complete.\n $plancompetencies = api::list_plan_competencies($draftplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[0]->usercompetency);\n $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[1]->usercompetency);\n $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[2]->usercompetency);\n $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetencyplan);\n\n // Create completed plan with records in user_competency_plan.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'),\n 'planid' => $completedplan->get('id')));\n\n // Check that user_competency_plan objects are returned when plan status is complete.\n $plancompetencies = api::list_plan_competencies($completedplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[0]->usercompetencyplan);\n $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[1]->usercompetencyplan);\n $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[2]->usercompetencyplan);\n $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetency);\n }", "function allcompleted($showOnlyGamesThatHaveBeenMarked = 0) \n {\n $this->Access->checkAccess('ApproveEvent', 'c');\n $this->Event->recursive = -1;\n $eventPaginate['conditions'] = array('iscompleted'=>1,\n 'is_deleted'=>0);\n if ($showOnlyGamesThatHaveBeenMarked) {\n $eventPaginate['conditions']['emailssent'] = 0; \n }\n $eventPaginate['order'] = array('end_date' => 'desc');\n\n $this->paginate = array('Event' => $eventPaginate);\n $this->set('events', $this->paginate('Event'));\n }", "function test_draft_status_equal_to_complete_entry() {\n\t\tself::clear_get_values();\n\n\t\t$dynamic_view = self::get_view_by_key( 'dynamic-view' );\n\n\t\tself::maybe_create_draft_entry_in_all_fields_form( $dynamic_view->frm_form_id );\n\n\t\t$filter_args = array(\n\t\t\tarray( 'type' => 'col', 'col' => 'is_draft', 'op' => '=', 'val' => '0' ),\n\t\t);\n\t\tself::add_filter_to_view( $dynamic_view, $filter_args );\n\n\t\t// Only non-draft entries should show\n\t\t$d = self::get_default_args( $dynamic_view, array( 'Jamie', 'Steph', 'Steve', 'href' ), array( 'Celeste' ) );\n\t\tself::run_get_display_data_tests( $d, '\"drafts is equal to complete entry\" filter' );\n\t}", "public function testRescheduleCrystalTasksMultipleShouldNot()\n {\n $rescheduleCooldown = CrystalTask::STATE_CRYSTAL_TASK_RESCHEDULE_COOLDOWN;\n\n $dataDependeeCompleted = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '100',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_COMPLETED,\n ];\n $dataDependeeRunning = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '99',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n $dataDependeeDead = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '22100',\n 'date_start' => (new DateTime)->sub(new DateInterval('P9Y'))->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n $dataDependeeNotCompleted = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '3399',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->sub(new DateInterval('PT' . (2 + $rescheduleCooldown) . 'S'))->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NOT_COMPLETED,\n ];\n $dataDependeeNew = [\n 'class' => DependeeTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.id',\n 'range' => '1003333',\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n $dataDependentCompleted = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '101',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_COMPLETED,\n ];\n $dataDependentNotCompleted = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '939',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => (new DateTime)->sub(new DateInterval('PT' . (2 + $rescheduleCooldown) . 'S'))->format('Y-m-d H:i:s'),\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NOT_COMPLETED,\n ];\n $dataDependentNew = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => 'abc',\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ];\n $dataDependentRunning = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '939222',\n 'date_start' => (new DateTime)->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n $dataDependentDead = [\n 'class' => DependentTask::class,\n 'timeout' => '4',\n 'cooldown' => '1',\n 'entity_uid' => 'some.hash',\n 'range' => '9399',\n 'date_start' => (new DateTime)->sub(new DateInterval('P9Y'))->format('Y-m-d H:i:s'),\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_RUNNING,\n ];\n\n $dataDependency = [\n 'class' => DependentTask::class,\n 'depend_on' => DependeeTask::class,\n ];\n\n $this->_fixtureHelper->setupCrystalTask($dataDependeeCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeRunning);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeDead);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeNotCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependeeNew);\n $this->_fixtureHelper->setupCrystalTask($dataDependentCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependentRunning);\n $this->_fixtureHelper->setupCrystalTask($dataDependentDead);\n $this->_fixtureHelper->setupCrystalTask($dataDependentNotCompleted);\n $this->_fixtureHelper->setupCrystalTask($dataDependentNew);\n\n $this->_fixtureHelper->setupCrystalTaskDependency($dataDependency);\n\n $this->assertCount(10, $this->_crystalTasksTable->getAll());\n\n $this->_rescheduleHeartbeat->rescheduleCrystalTasks();\n $this->assertTrue($this->_testHandler->hasRecordThatContains(\n 'Rescheduled CrystalTask',\n Logger::INFO\n ));\n\n $this->assertCount(10, $this->_crystalTasksTable->getAll());\n\n $dataDependeeDead = array_merge($dataDependeeDead, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataDependeeNotCompleted = array_merge($dataDependeeNotCompleted, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataDependentDead = array_merge($dataDependentDead, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n $dataDependentNotCompleted = array_merge($dataDependentNotCompleted, [\n 'date_start' => null,\n 'date_end' => null,\n 'state' => CrystalTask::STATE_CRYSTAL_TASK_NEW,\n ]);\n\n // Should be rescheduled\n $this->assertArraySubset($dataDependeeDead, (array)$this->_crystalTasksTable->getByPK(3));\n $this->assertArraySubset($dataDependeeNotCompleted, (array)$this->_crystalTasksTable->getByPK(4));\n $this->assertArraySubset($dataDependentDead, (array)$this->_crystalTasksTable->getByPK(8));\n $this->assertArraySubset($dataDependentNotCompleted, (array)$this->_crystalTasksTable->getByPK(9));\n\n // Should not be rescheduled\n $this->assertArraySubset($dataDependeeCompleted, (array)$this->_crystalTasksTable->getByPK(1));\n $this->assertArraySubset($dataDependeeRunning, (array)$this->_crystalTasksTable->getByPK(2));\n $this->assertArraySubset($dataDependeeNew, (array)$this->_crystalTasksTable->getByPK(5));\n $this->assertArraySubset($dataDependentCompleted, (array)$this->_crystalTasksTable->getByPK(6));\n $this->assertArraySubset($dataDependentRunning, (array)$this->_crystalTasksTable->getByPK(7));\n $this->assertArraySubset($dataDependentNew, (array)$this->_crystalTasksTable->getByPK(10));\n }", "public function testSchedulePresentationDFailOptedOut()\n {\n $communityId = 7;\n $presentationLetter = 'D';\n $productId = ProductsTable::ORGANIZATIONS_SUMMIT;\n $this->_testDeliverPresFailOptedOut($communityId, $productId, $presentationLetter);\n }", "public function canGetListOfFutureInvoices()\n {\n // Arrange\n $subscription = Ezypay::getSubscription($this->faker->uuid);\n $startDate = Carbon::now()->addDays(30)->toDateString();\n $endDate = Carbon::now()->addDays(60)->toDateString();\n\n // Act\n $futureInvoices = Ezypay::getFutureInvoices(\n $subscription['id'],\n $subscription['customerId'],\n $startDate,\n $endDate,\n true\n );\n\n // Assert\n $this->assertNotNull($futureInvoices);\n $this->assertEquals($subscription['id'], $futureInvoices[0]['subscriptionId']);\n\n $this->futureInvoices = $futureInvoices;\n }", "public function testActiveAndPendingEpisodes()\n {\n factory('Suyabay\\Episode', 1)->create(['status' => 1]);\n factory('Suyabay\\Episode', 1)->create(['status' => 0]);\n\n $this->assertTrue(is_array(self::$episodeRepository->getActiveEpisodes()->toArray()));\n $this->assertTrue(is_array(self::$episodeRepository->getPendingEpisodes()->toArray()));\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function testStatuses() {\n $tasks = $this->CI->tasks->all();\n $complete = $this->getStatusCount($tasks, 2);\n $incomplete = $this->getStatusCount($tasks, 1);\n \n $this->assertGreaterThan($complete, $incomplete);\n \n }", "public function testSchedulePresentationAFailOptedOut()\n {\n $communityId = 7;\n $presentationLetter = 'A';\n $productId = ProductsTable::OFFICIALS_SURVEY;\n $this->_testDeliverPresFailOptedOut($communityId, $productId, $presentationLetter);\n }", "function test_draft_status_equal_to_complete_entry_with_drafts_param() {\n\t\tself::clear_get_values();\n\n\t\t$dynamic_view = self::get_view_by_key( 'dynamic-view' );\n\n\t\tself::maybe_create_draft_entry_in_all_fields_form( $dynamic_view->frm_form_id );\n\n\t\t// Drafts and non-drafts should show with drafts=both\n\t\t$filter_args = array(\n\t\t\tarray( 'type' => 'col', 'col' => 'is_draft', 'op' => '=', 'val' => '0' ),\n\t\t);\n\t\tself::add_filter_to_view( $dynamic_view, $filter_args );\n\n\t\t// All entries should be shown\n\t\t$extra_atts['drafts'] = 'both';\n\n\t\t$d = self::get_default_args( $dynamic_view, array( 'Jamie', 'Steph', 'Celeste', 'Steve', 'href' ), array(), $extra_atts );\n\t\tself::run_get_display_data_tests( $d, '\"drafts is equal to complete entry\" filter with drafts=both param' );\n\t}", "public function test_unapprove_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_ACTIVE);\n $tplplan->update();\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::unapprove_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are always approved./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_DRAFT);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Can not unapprove a non-draft plan.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The plan cannot be sent back to draft at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());\n }\n\n // Unapprove as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::unapprove_plan($plan);\n $this->fail('The user can not unapprove the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Unapprove plan.\n $this->setUser($reviewer);\n api::unapprove_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n\n // Unapprove plan by ID.\n $plan->set('status', plan::STATUS_ACTIVE);\n $plan->update();\n api::unapprove_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_DRAFT, $plan->get('status'));\n }", "public function testStatementComplete() : void {\n $provider = $this->getReference('provider.1');\n $deposit = $this->getReference('deposit.2');\n $crawler = $this->client->request(\n 'GET',\n '/api/sword/2.0/cont-iri/' . $provider->getUuid() . '/' . $deposit->getUuid() . '/state'\n );\n $response = $this->client->getResponse();\n $this->assertSame(200, $response->getStatusCode());\n $this->assertStringContainsStringIgnoringCase('LOCKSS boxes have harvested', $response->getContent());\n }", "public function testGetProcessInstanceStatistics() {\n $restClient = new camundaRestClient(self::$restApi);\n\n $is = $restClient->getProcessInstanceStatistics();\n $this->assertEquals(false, $is[0]->definition->suspended);\n\n \n }", "public function testListPastMeetingPolls()\n {\n }", "public function testAttendeeStatusInvitation()\n {\n $this->markTestIncomplete('Sends mail');\n\n require_once 'Horde/Icalendar/Vfreebusy.php';\n $GLOBALS['KOLAB_FILTER_TESTING'] = new Horde_Icalendar_Vfreebusy();\n $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTSTART', Horde_Icalendar::_parseDateTime('20080926T000000Z'));\n $GLOBALS['KOLAB_FILTER_TESTING']->setAttribute('DTEND', Horde_Icalendar::_parseDateTime('20081126T000000Z'));\n\n $params = array('unmodified_content' => true,\n 'incoming' => true);\n\n $this->sendFixture(dirname(__FILE__) . '/fixtures/attendee_status_invitation.eml',\n dirname(__FILE__) . '/fixtures/null.ret',\n '', '', '[email protected]', '[email protected]',\n 'home.example.org', $params);\n\n $result = $this->auth->authenticate('wrobel', array('password' => 'none'));\n $this->assertNoError($result);\n\n $folder = $this->storage->getFolder('INBOX/Kalender');\n $data = $folder->getData();\n $events = $data->getObjects();\n $summaries = array();\n foreach ($events as $event) {\n foreach ($event['attendee'] as $attendee) {\n switch ($attendee['smtp-address']) {\n case '[email protected]':\n $this->assertEquals('none', $attendee['status']);\n break;\n case '[email protected]':\n $this->assertEquals('accepted', $attendee['status']);\n break;\n case '[email protected]':\n $this->assertEquals('declined', $attendee['status']);\n break;\n case '[email protected]':\n $this->assertEquals('tentative', $attendee['status']);\n break;\n case '[email protected]':\n $this->assertEquals('none', $attendee['status']);\n break;\n default:\n $this->fail('Unexpected attendee!');\n break;\n }\n }\n }\n $result = $data->deleteAll();\n $this->assertNoError($result);\n }", "public function isInvoiced()\n {\n \n }", "public function testListsArePartial() {\n $lists = $this->lists->lists();\n $this->assertFalse($lists[0]->isComplete());\n }", "protected function dqCheckSpecimenCompleteZones($project)\n {\n $this->info(\"\\n\" . \"Running DQ Check Specimen Complete Zones for \" . $project->name);\n try {\n $skeletalelements = SkeletalElement::where('project_id', $project->id )->where('completeness', 'Complete')->get();\n $this->info(\"\\nFor Project \".$project->name.\", \".count($skeletalelements).\" Specimens were found which are marked as Complete\");\n $count = 0; $se_count = 0;\n $sys = __CLASS__;\n\n $bar = $this->output->createProgressBar(count($skeletalelements));\n foreach ($skeletalelements as $skeletalelement) {\n $zones = Zone::where('sb_id', $skeletalelement->sb_id)->get();\n foreach ($zones as $zone){\n if ( $skeletalelement->getZone($zone->id) == null) {\n $skeletalelement->zones()->attach($zone->id, ['org_id' => $skeletalelement->org_id, 'project_id' => $skeletalelement->project_id, 'presence' => true, 'element_complete' => true, 'created_by' => $sys, 'updated_by' => $sys]);\n $count += 1;\n }\n }\n $se_count += 1;\n $bar->advance();\n }\n $this->info(\"\\n\".$count.\" rows added for project \".$project->name);\n } catch (QueryException $ex) {\n $this->info($this->name.\" failed for \".$project->name);\n return;\n }\n }", "public function test_approve_plan() {\n $data = $this->setup_workflow_data();\n $dg = $data['dg'];\n $lpg = $data['lpg'];\n $user = $data['user'];\n $reviewer = $data['reviewer'];\n $otheruser = $data['otheruser'];\n $plan = $data['plan'];\n $tplplan = $data['tplplan'];\n\n // Set waiting for review.\n $tplplan->set('status', plan::STATUS_IN_REVIEW);\n $tplplan->update();\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n\n // Foreign user cannot do anything.\n $this->setUser($otheruser);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not read the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Can not change a plan based on a template.\n $this->setUser($reviewer);\n try {\n api::approve_plan($tplplan);\n $this->fail('The plan is based on a template.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/Template plans are already approved./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_ACTIVE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Can not approve a plan already approved.\n $this->setUser($reviewer);\n $plan->set('status', plan::STATUS_COMPLETE);\n try {\n api::approve_plan($plan);\n $this->fail('The plan cannot be approved at this stage.');\n } catch (coding_exception $e) {\n $this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());\n }\n\n // Approve as the owner.\n $this->setUser($user);\n $plan->set('status', plan::STATUS_IN_REVIEW);\n try {\n api::approve_plan($plan);\n $this->fail('The user can not approve the plan.');\n } catch (required_capability_exception $e) {\n $this->assertEquals('nopermissions', $e->errorcode);\n }\n\n // Approve plan from in review.\n $this->setUser($reviewer);\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan by ID.\n $plan->set('status', plan::STATUS_IN_REVIEW);\n $plan->update();\n api::approve_plan($plan->get('id'));\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from draft.\n $plan->set('status', plan::STATUS_DRAFT);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n\n // Approve plan from waiting for review.\n $plan->set('status', plan::STATUS_WAITING_FOR_REVIEW);\n $plan->update();\n api::approve_plan($plan);\n $plan->read();\n $this->assertEquals(plan::STATUS_ACTIVE, $plan->get('status'));\n }", "function accept_players_from_waitlist_for_run ($EventId,\n\t\t\t\t\t $SrcRunId,\n\t\t\t\t\t $DstRunId,\n\t\t\t\t\t $run_title,\n\t\t\t\t\t $Day,\n\t\t\t\t\t $StartHour,\n\t\t\t\t\t $Hours,\n\t\t\t\t\t $CanPlayConcurrently,\n\t\t\t\t\t $delta_male,\n\t\t\t\t\t $delta_female,\n\t\t\t\t\t $delta_neutral)\n{\n $waitlisted = array ();\n\n $male = max ($delta_male, 0);\n $female = max ($delta_female, 0);\n $neutral = max ($delta_neutral, 0);\n\n // echo \"Male: $delta_male, Female: $delta_female, Neutral: $delta_neutral<BR>\\n\";\n\n $sql = 'SELECT Users.UserId, Users.FirstName, Users.LastName, Users.EMail,';\n $sql .= ' Signup.Counted, Signup.SignupId, Signup.Gender';\n $sql .= ' FROM Signup, Users';\n $sql .= \" WHERE Signup.RunId=$SrcRunId\";\n $sql .= \" AND Signup.State='Waitlisted'\";\n $sql .= ' AND Users.UserId=Signup.UserId';\n $sql .= ' ORDER BY Signup.SignupId';\n\n $wait_result = mysql_query ($sql);\n if (! $wait_result)\n return display_mysql_error (\"Query for users on waitlist for run $row->RunId\");\n while ((($male > 0) || ($female > 0) || ($neutral > 0)) &&\n\t $wait_row = mysql_fetch_object ($wait_result))\n {\n // echo \"Considering $wait_row->FirstName $wait_row->LastName, $wait_row->Gender<BR>\\n\";\n\n $accept_user = false;\n\n if ($neutral > 0)\n $accept_user = true;\n else\n {\n if ('Male' == $wait_row->Gender)\n\t$accept_user = ($male > 0);\n else\n\t$accept_user = ($female > 0);\n }\n\n if ($accept_user)\n {\n $name = trim (\"$wait_row->FirstName $wait_row->LastName\");\n // echo \"Accepting $wait_row->FirstName $wait_row->LastName, $wait_row->Gender<BR>\\n\";\n if (confirm_waitlisted_user ($wait_row->SignupId,\n\t\t\t\t $DstRunId,\n\t\t\t\t $wait_row->UserId,\n\t\t\t\t stripslashes ($name),\n\t\t\t\t $wait_row->EMail,\n\t\t\t\t $wait_row->Gender,\n\t\t\t\t $run_title,\n\t\t\t\t $Day,\n\t\t\t\t $StartHour,\n\t\t\t\t $EventId,\n\t\t\t\t $Hours,\n\t\t\t\t $CanPlayConcurrently))\n {\n\tif ('Male' == $wait_row->Gender)\n\t{\n\t if ($male > 0)\n\t $male--;\n\t else\n\t $neutral--;\n\t}\n\telse\n\t{\n\t if ($female > 0)\n\t $female--;\n\t else\n\t $neutral--;\n\t}\n }\n }\n }\n}", "public function testSchedulePresentationCFailOptedOut()\n {\n $communityId = 7;\n $presentationLetter = 'C';\n $productId = ProductsTable::ORGANIZATIONS_SURVEY;\n $this->_testDeliverPresFailOptedOut($communityId, $productId, $presentationLetter);\n }" ]
[ "0.61458933", "0.5936748", "0.5791805", "0.5391857", "0.5388075", "0.5309562", "0.5275813", "0.5248489", "0.5242116", "0.523932", "0.52222514", "0.5150948", "0.51470476", "0.51376706", "0.51033777", "0.50952286", "0.5093851", "0.50916517", "0.5077512", "0.5066115", "0.50284564", "0.5026415", "0.5014893", "0.50134975", "0.50049734", "0.5004777", "0.5002701", "0.500159", "0.4998439", "0.49747595" ]
0.6424351
0
Get a user competency in a course.
public function test_get_user_competency_in_course() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); $this->setAdminUser(); $user = $dg->create_user(); $c1 = $dg->create_course(); // Enrol the user so they can be rated in the course. $studentarch = get_archetype_roles('student'); $studentrole = array_shift($studentarch); $coursecontext = context_course::instance($c1->id); $dg->role_assign($studentrole->id, $user->id, $coursecontext->id); $dg->enrol_user($user->id, $c1->id, $studentrole->id); $framework = $lpg->create_framework(); $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id)); $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id)); // Create a user competency for comp1. api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test'); // Test for competency already exist in user_competency. $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id')); $this->assertEquals($comp1->get('id'), $uc->get('competencyid')); $this->assertEquals($user->id, $uc->get('userid')); $this->assertEquals(3, $uc->get('grade')); $this->assertEquals(true, $uc->get('proficiency')); // Test for competency does not exist in user_competency. $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id')); $this->assertEquals($comp2->get('id'), $uc2->get('competencyid')); $this->assertEquals($user->id, $uc2->get('userid')); $this->assertEquals(null, $uc2->get('grade')); $this->assertEquals(null, $uc2->get('proficiency')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function CoursesForUser($user_id)\n {\n $results = &get_instance()->db\n ->query(\"SELECT c.* FROM Courses c JOIN UserCourses uc ON c.course_id = uc.course_id and uc.user_id = ? order by c.course_order asc\", array(intval($user_id)))\n ->result();\n\n $ret = array();\n // $introCourseOnly = false;\n foreach ($results as $row)\n {\n $course = Courses_model::LoadWithData($row);\n// if($course->isIntroCourse() && $course->completionPercentageForUser(intval($user_id), false) < 100) {\n// $introCourseOnly = $course;\n// }\n \t$ret[] = $course;\n }\n\n// if($introCourseOnly != false) {\n// return array($introCourseOnly);\n// }\n\n return $ret;\n }", "public function getCourse() {\n \treturn $this->apcSession->getCourseLookupSession()->getCourse($this->getCourseId());\n\t}", "public function getCoursesWithOneUser($user_id = null)\n {\n $courses = Course::open()->get();\n\n $courses->load(['enroll' => function ($query) use ($user_id) {\n $query->owner($user_id);\n }, 'enroll.payment' => function ($query) {\n $query->latest();\n }, 'users']);\n return $courses;\n }", "function pull_courses($user, $grades=false) {\n global $CFG;\n \n $sql = \"SELECT c.id, c.shortname, c.fullname, ra.userid, c.visible,\n {$user->id} AS cps_userid\n FROM {$CFG->prefix}course c, \n {$CFG->prefix}role_assignments ra, \n {$CFG->prefix}context ctx \n WHERE c.id = ctx.instanceid \n AND ra.contextid=ctx.id \n AND ra.roleid IN ({$CFG->gradebookroles}) \n AND ra.userid = {$user->moodleid}\";\n\n $courses = get_records_sql($sql);\n\n if(!$courses) $courses = array();\n\n if (!$grades) {\n return $courses;\n } else {\n return pull_grades_courses($courses);\n }\n}", "public static function getUserWithCourses($id_user) {\n\t\treturn UserDAO::getUserWithCourses($id_user);\n\t}", "public function getCourse()\n {\n $tournament = Tournament::where('active', 1)->first();\n return Hole::where('id_course', $tournament->id_course)->get();\n }", "function getCourses($userID)\n {\n $commands = new SQLHelper();\n $courses = $commands->getUserCourses($userID);\n return $courses;\n }", "public function getCourse()\n\t{\n\t\treturn $this->db->query(\"SELECT * FROM course\");\n\t}", "public function getCourse()\n {\n return $this->course;\n }", "function getActiveCompetences()\n {\n $competencesNode = atkgetNode('competency.competences');\n $competences = $competencesNode->select(\"person_id=\" . $this->user['id'])->includes(array('niveau_id','competency_id','person_id'));\n $level = array();\n $comp = array();\n foreach ($competences as $competency)\n {\n $level[] = $competency[\"niveau_id\"]['id'];\n $comp[] = $competency[\"competency_id\"]['id'];\n }\n $output = array(\n \"level\" => $level ,\n \"comp\" => $comp);\n return ($output);\n }", "public function getCourse()\n {\n return $this->hasOne(Course::className(), ['id' => 'course_id']);\n }", "public function GetCourse()\n\t\t{\n\t\t\treturn Course::Get($this->GetAttribute('course_id'));\n\t\t}", "function GetCompetence()\r\n {\r\n $companyid = $this->companyID;\r\n $emp_seqno = $this->empSeqNO;\r\n $sql_string = <<<eof\r\n select competence_id,\r\n competence,\r\n competence_level,\r\n remark\r\n from ehr_emp_competence_v\r\n where company_id = '$companyid'\r\n and emp_seq_no = '$emp_seqno'\r\neof;\r\n\t\t\t//print $sql_string;\r\n return $this->DBConn->GetArray($sql_string);\r\n }", "public function getCourse($id,$user_id){\n // initialization\n $repo = new LearnRepository();\n\n // Operations\n $resp = $repo->getCourse($id,$user_id);\n if($resp->getResult()){\n return response()->json([\n 'error' => false,\n 'data' => $resp->getData()\n ]);\n }\n\n return response()->json([\n 'error' => true,\n 'message' => 'Kurs getirilirken hata oluştur.Tekrar deneyin.',\n 'errorMessage' => $resp->getError()\n ],400);\n }", "public function getCourse()\n {\n return Course::where('slug', $this->courseSlug())\n ->first();\n }", "function learndash_user_get_course_progress( $user_id = 0, $course_id = 0, $type = 'legacy' ) {\n\t$user_id = absint( $user_id );\n\t$course_id = absint( $course_id );\n\n\tif ( ! empty( $user_id ) ) {\n\t\t$course_progress_object = LDLMS_Factory_User::course_progress( $user_id );\n\t\tif ( $course_progress_object ) {\n\t\t\treturn $course_progress_object->get_progress( $course_id, $type );\n\t\t}\n\t}\n\n\treturn array();\n}", "public function coursesTeaching() {\n \t$user_id = $this->id;\n \treturn Course::whereIn('id', function($q) use ($user_id) {\n \t\t\t\t\t$q\t->select('course_id')\n \t\t\t\t\t\t->from('enrollments')\n \t\t\t\t\t\t->where('user_id', '=', $user_id)\n \t\t\t\t\t\t->where('is_instructor', '=', true);\n\t\t\t\t\t})\n\t\t\t\t\t->get();\n }", "public static function get_competencies_by_userevidenceid($userevidenceid) {\n global $DB;\n $sql = \"SELECT c.*\n FROM {\" . self::TABLE . \"} uec\n JOIN {\" . competency::TABLE . \"} c\n ON uec.userevidenceid = ?\n AND uec.competencyid = c.id\n ORDER BY c.shortname\";\n $competencies = array();\n $records = $DB->get_recordset_sql($sql, array($userevidenceid));\n foreach ($records as $record) {\n $competencies[] = new competency(0, $record);\n }\n $records->close();\n return $competencies;\n }", "abstract public function get_course();", "public function getCourse()\n {\n if (!$this->get('course')) {\n if ($this->getSubject()) {\n $this->set('course', $this->getSubject()->getCourse());\n } else if ($this->getRequest()->has('courseId')) {\n /** @var Course $course */\n try {\n $course = $this->getCourseMapper()->find($this->getRequest()->get('courseId'));\n $this->set('course', $course);\n } catch (\\Exception $e) {}\n }\n }\n return $this->get('course');\n }", "public function get_course() {\n return $this->parent->get_course();\n }", "function getCompetencesInProfile($profile)\n {\n $db = atkGetDb();\n $query = $db->createQuery(); $query = $db->createQuery();\n //we add the table competences //we add the table competences\n $query->addTable(\"competency_profile_comp\");\n $query->addField(\"competency_id\");\n $query->addField(\"niveau_id\");\n $query->addCondition(\"profile_id=\" . $profile);\n $competences = $db->getrows($query->buildSelect());\n\n $level = array();\n $comp = array();\n foreach ($competences as $competency)\n {\n $level[] = $competency[\"niveau_id\"];\n $comp[] = $competency[\"competency_id\"];\n }\n $output = array(\n \"level\" => $level ,\n \"comp\" => $comp);\n return $output;\n }", "function getCourseIdsByUser($userid) {\n $this->CoursesEnrollment->recursive = -1;\n $userEnrollments = $this->CoursesEnrollment->find('all', array('conditions' =>array('user_id'=>$userid), 'fields'=>array('course_id')));\n if($userEnrollments) {\n $courses = [];\n foreach($userEnrollments as $enrollment) {\n array_push($courses, $enrollment['CoursesEnrollment']['course_id']);\n }\n return $courses;\n }\n }", "public function index(Request $request)\n {\n return $request->user()->courses;\n }", "public function getServiceCourses()\n {\n $this->db->select('*');\n $this->db->from($this->table);\n $this->db->where('isCareer', 0);\n $query = $this->db->get();\n return $query->result();\n }", "function getCharityCommission(){\n\t\t$charities_commission = 0;\n\t\t$re = $this->db->query(\"select commission_charities.commission,order_detais.itemprice,order_detais.quality from commission_charities join order_detais on order_detais.id = commission_charities.odetail where commission_charities.rid = 8 and commission_charities.orderid = \".$this->oid);\n\t\tforeach($re->result_array() as $row){\n\t\t\t$price = $row['itemprice'] * $row['quality'];\n\t\t\t$charities_commission += $row['commission'] * $price / 100; \n\t\t}\n\t\treturn $charities_commission; \n\t}", "public function getcomp()\n {\n $domain = $this->structurizeData();\n $this->competences = $this->getActiveCompetences();\n $this->profiles = $this->getCompetencesInProfile($this->getProfile());\n $this->planned = $this->getPlannedCompetences();\n $this->allowed = $allowed;\n $competencyNode = atkGetNode('competency.competencymatch');\n if ($competencyNode->allowed('show_all_users'))\n {\n $params[\"allowed\"] = \"team\";\n }\n $this->domain = $domain;\n }", "public static function getUserAnswersByCourse($user_id,$course_id)\r\n\t{\t\t\r\n\t\t$courseQuestionModel = new self();\r\n\t\t$select = $courseQuestionModel->select();\r\n\t\t$select->setIntegrityCheck(false);\r\n\t\t$select->from(array('ca'=>'course_answer'),array('answer_count'=>new Zend_Db_Expr(\"count(*)\")));\t\t\t\t\r\n\t\t$select->join(array('cq'=>'course_question'),'ca.course_question_id = cq.course_question_id',null);\t\t\r\n\t\t$select->where('ca.user_id = '.$user_id);\r\n\t\t$select->where('cq.course_id = '.$course_id);\r\n\t\t//return $select->__toString();\t\t\r\n\t\treturn $courseQuestionModel->fetchRow($select);\t\t\t\t\t\r\n\t}", "public function getCourt() {\n\t\treturn ($this->courts);\n\t}", "public static function getPreferance(){ //A function to get a preference from database\n \t//$user=getUserId(); //Assigns a user for trial\n \t$user_id = $_SESSION['user']->getUserId(); \n\t\n\t\n \tglobal $pdo; //instantiate a pdo\n \t\n\t \ttry{\n\t \t\t$sql = \"SELECT category,score FROM user_preference WHERE user_id = :u ORDER BY score DESC LIMIT 2\";//retrive data(category) from the database user_preferance based of the user\n\t \t\t$preferance = $pdo->prepare($sql);//assigns the retrived data\n\t \t\t$preferance->bindValue(':u',$user_id);\n\t \t\t$preferance->execute();\n\t \t\t$row=$preferance->fetch();//\n\t \t\t$itemCategory=$row['category'];// assign the itemCategorys name\n\t \t\t//$score=$row['score'];\n\t \t}catch(Exception $e){ //run exception\n\t \t\tprint_r($e->getMessage()); //show exception\n\t \t}\n\n \treturn $itemCategory;//returns the itemCategory\n\t\n\t\n }" ]
[ "0.64209676", "0.6190679", "0.60959935", "0.603763", "0.60349816", "0.5969998", "0.5957141", "0.59213436", "0.5871268", "0.58711296", "0.5859472", "0.5825561", "0.58186126", "0.5811571", "0.5802959", "0.5800552", "0.5780569", "0.57133037", "0.5682565", "0.5654432", "0.55663735", "0.55558443", "0.55290383", "0.55284023", "0.55197465", "0.55036354", "0.5476834", "0.5444472", "0.54382443", "0.5437224" ]
0.65448564
0
Test course statistics api functions.
public function test_course_statistics() { $this->resetAfterTest(true); $dg = $this->getDataGenerator(); $lpg = $dg->get_plugin_generator('core_competency'); $this->setAdminUser(); $u1 = $dg->create_user(); $u2 = $dg->create_user(); $u3 = $dg->create_user(); $u4 = $dg->create_user(); $c1 = $dg->create_course(); $framework = $lpg->create_framework(); // Enrol students in the course. $studentarch = get_archetype_roles('student'); $studentrole = array_shift($studentarch); $coursecontext = context_course::instance($c1->id); $dg->role_assign($studentrole->id, $u1->id, $coursecontext->id); $dg->enrol_user($u1->id, $c1->id, $studentrole->id); $dg->role_assign($studentrole->id, $u2->id, $coursecontext->id); $dg->enrol_user($u2->id, $c1->id, $studentrole->id); $dg->role_assign($studentrole->id, $u3->id, $coursecontext->id); $dg->enrol_user($u3->id, $c1->id, $studentrole->id); $dg->role_assign($studentrole->id, $u4->id, $coursecontext->id); $dg->enrol_user($u4->id, $c1->id, $studentrole->id); // Create 6 competencies. $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Link 6 out of 6 to a course. $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id)); $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id)); $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id)); $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id)); $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id)); $lpg->create_course_competency(array('competencyid' => $comp6->get('id'), 'courseid' => $c1->id)); // Rate some competencies. // User 1. api::grade_competency_in_course($c1, $u1->id, $comp1->get('id'), 4, 'Unit test'); api::grade_competency_in_course($c1, $u1->id, $comp2->get('id'), 4, 'Unit test'); api::grade_competency_in_course($c1, $u1->id, $comp3->get('id'), 4, 'Unit test'); api::grade_competency_in_course($c1, $u1->id, $comp4->get('id'), 4, 'Unit test'); // User 2. api::grade_competency_in_course($c1, $u2->id, $comp1->get('id'), 1, 'Unit test'); api::grade_competency_in_course($c1, $u2->id, $comp2->get('id'), 1, 'Unit test'); api::grade_competency_in_course($c1, $u2->id, $comp3->get('id'), 1, 'Unit test'); api::grade_competency_in_course($c1, $u2->id, $comp4->get('id'), 1, 'Unit test'); // User 3. api::grade_competency_in_course($c1, $u3->id, $comp1->get('id'), 3, 'Unit test'); api::grade_competency_in_course($c1, $u3->id, $comp2->get('id'), 3, 'Unit test'); // User 4. api::grade_competency_in_course($c1, $u4->id, $comp1->get('id'), 2, 'Unit test'); api::grade_competency_in_course($c1, $u4->id, $comp2->get('id'), 2, 'Unit test'); // OK we have enough data - lets call some API functions and check for expected results. $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u1->id); $this->assertEquals(4, $result); $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u2->id); $this->assertEquals(0, $result); $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u3->id); $this->assertEquals(2, $result); $result = api::count_proficient_competencies_in_course_for_user($c1->id, $u4->id); $this->assertEquals(0, $result); $result = api::get_least_proficient_competencies_for_course($c1->id, 0, 2); // We should get 5 and 6 in repeatable order. $valid = false; if (($comp5->get('id') == $result[0]->get('id')) || ($comp6->get('id') == $result[0]->get('id'))) { $valid = true; } $this->assertTrue($valid); $valid = false; if (($comp5->get('id') == $result[1]->get('id')) || ($comp6->get('id') == $result[1]->get('id'))) { $valid = true; } $this->assertTrue($valid); $expected = $result[1]->get('id'); $result = api::get_least_proficient_competencies_for_course($c1->id, 1, 1); $this->assertEquals($result[0]->get('id'), $expected); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_template_statistics() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $u1 = $dg->create_user();\n $u2 = $dg->create_user();\n $u3 = $dg->create_user();\n $u4 = $dg->create_user();\n $c1 = $dg->create_course();\n $framework = $lpg->create_framework();\n\n // Create 6 competencies.\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp6 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Link 5 out of 6 to a course.\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp3->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp4->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp5->get('id'), 'courseid' => $c1->id));\n\n // Put all 6 in a template.\n $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template();\n $tplc1 = $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $comp1->get('id')));\n $tplc2 = $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $comp2->get('id')));\n $tplc3 = $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $comp3->get('id')));\n $tplc4 = $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $comp4->get('id')));\n $tplc5 = $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $comp5->get('id')));\n $tplc6 = $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $comp6->get('id')));\n\n // Create some plans from the template.\n $p1 = $lpg->create_plan(array('templateid' => $tpl->get('id'), 'userid' => $u1->id));\n $p2 = $lpg->create_plan(array('templateid' => $tpl->get('id'), 'userid' => $u2->id));\n $p3 = $lpg->create_plan(array('templateid' => $tpl->get('id'), 'userid' => $u3->id));\n $p4 = $lpg->create_plan(array('templateid' => $tpl->get('id'), 'userid' => $u4->id));\n\n // Rate some competencies.\n // User 1.\n $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $comp1->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $comp2->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u1->id, 'competencyid' => $comp3->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n // User 2.\n $lpg->create_user_competency(array('userid' => $u2->id, 'competencyid' => $comp1->get('id'),\n 'proficiency' => false, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u2->id, 'competencyid' => $comp2->get('id'),\n 'proficiency' => false, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u2->id, 'competencyid' => $comp3->get('id'),\n 'proficiency' => false, 'grade' => 1 ));\n // User 3.\n $lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp2->get('id'),\n 'proficiency' => false, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp3->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp4->get('id'),\n 'proficiency' => false, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u3->id, 'competencyid' => $comp5->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n // User 4.\n $lpg->create_user_competency(array('userid' => $u4->id, 'competencyid' => $comp3->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n $lpg->create_user_competency(array('userid' => $u4->id, 'competencyid' => $comp5->get('id'),\n 'proficiency' => true, 'grade' => 1 ));\n\n // Complete 3 out of 4 plans.\n api::complete_plan($p1->get('id'));\n api::complete_plan($p2->get('id'));\n api::complete_plan($p3->get('id'));\n\n // OK we have enough data - lets call some API functions and check for expected results.\n\n $result = api::count_competencies_in_template_with_no_courses($tpl->get('id'));\n $this->assertEquals(1, $result);\n\n $result = api::count_plans_for_template($tpl->get('id'));\n $this->assertEquals(4, $result);\n\n $result = api::count_plans_for_template($tpl->get('id'), plan::STATUS_COMPLETE);\n $this->assertEquals(3, $result);\n\n // This counts the records of competencies in completed plans for all users with a plan from this template.\n $result = api::count_user_competency_plans_for_template($tpl->get('id'));\n // There should be 3 plans * 6 competencies.\n $this->assertEquals(18, $result);\n\n // This counts the records of proficient competencies in completed plans for all users with a plan from this template.\n $result = api::count_user_competency_plans_for_template($tpl->get('id'), true);\n // There should be 5.\n $this->assertEquals(5, $result);\n\n // This counts the records of not proficient competencies in completed plans for all users with a plan from this template.\n $result = api::count_user_competency_plans_for_template($tpl->get('id'), false);\n // There should be 13.\n $this->assertEquals(13, $result);\n\n // This lists the plans based on this template, optionally filtered by status.\n $result = api::list_plans_for_template($tpl->get('id'));\n\n $this->assertEquals(4, count($result));\n foreach ($result as $one) {\n $this->assertInstanceOf('\\core_competency\\plan', $one);\n }\n // This lists the plans based on this template, optionally filtered by status.\n $result = api::list_plans_for_template($tpl->get('id'), plan::STATUS_COMPLETE);\n\n $this->assertEquals(3, count($result));\n foreach ($result as $one) {\n $this->assertInstanceOf('\\core_competency\\plan', $one);\n $this->assertEquals(plan::STATUS_COMPLETE, $one->get('status'));\n }\n\n $result = api::get_least_proficient_competencies_for_template($tpl->get('id'), 0, 2);\n\n // Our times completed counts should look like this:\n // - comp1 - 1\n // - comp2 - 1\n // - comp3 - 2\n // - comp4 - 0\n // - comp5 - 1\n // - comp6 - 0\n //\n // And this is a fullstop to make CiBoT happy.\n $this->assertEquals(2, count($result));\n $leastarray = array($comp4->get('id'), $comp6->get('id'));\n foreach ($result as $one) {\n $this->assertInstanceOf('\\core_competency\\competency', $one);\n $this->assertContains($one->get('id'), $leastarray);\n }\n }", "public function testCloudPosCheckUpdateCourse()\n {\n }", "public function testListMyCourse()\n {\n $data = [];\n $sales = [];\n\n $sale = new Sale();\n $sales = $sale->getResults($data);\n\n //$this->assertJson($sales);\n\n //dd($sales);\n }", "public function index($course_id)\n {\n $tests = CourseTest::where('course_id',$course_id)->get();\n return ok($tests);\n }", "public function test_that_authorized_user_can_view_courses_within_other_periods()\n {\n \n }", "function admin_exam_stats() {\n\tglobal $conf_base_path;\n\t\n\t$current_exam = \"OR/Ispit6\";\n\t$exam_students = array();\n\n\t// Hardcoded 4 assignments\n\t?>\n\t<p id=\"p-return\"><a href=\"admin.php\">Return to courses list</a></p>\n\t<h1>Exam stats</h1>\n\t<table><tr><th>Username:</th><th>Z1:</th><th>Z2:</th><th>Z3:</th><th>Z4:</th><th>Score</th></tr>\n\t<?php\n\t$tasks = array();\n\t\n\tforeach ($exam_students as $username) {\n\t\tprint \"<tr><td>$username</td>\";\n\t\t$score = 0;\n\t\tfor ($i=1; $i<=4; $i++) {\n\t\t\t$path = $current_exam . \"/Z$i/.at_result\";\n\t\t\t$exists = exec(\"sudo $conf_base_path/bin/wsaccess $username exists \\\"$path\\\"\");\n\t\t\tif ($exists != 1) {\n\t\t\t\t$path = str_replace(\"OR\", \"UUP\", $path);\n\t\t\t\t$exists = exec(\"sudo $conf_base_path/bin/wsaccess $username exists \\\"$path\\\"\");\n\t\t\t}\n\t\t\tif ($exists == 1) {\n\t\t\t\t$at_result = json_decode(shell_exec(\"sudo $conf_base_path/bin/wsaccess $username read \\\"$path\\\"\"), true);\n\t\t\t\t//print_r($at_result);\n\t\t\t\t//return;\n\t\t\t\t$tests = count($at_result[\"test_results\"]);\n\t\t\t\t$passed = 0;\n\t\t\t\tforeach ($at_result[\"test_results\"] as $test) {\n\t\t\t\t\tif ($test['status'] == 1) $passed++;\n\t\t\t\t}\n\t\t\t\tprint \"<td id=\\\"$username-Z$i\\\" style=\\\"width: 50px\\\">$passed/$tests</td>\\n\";\n\t\t\t\tif ($tests > 0)\n \t\t\t\t$score += ($passed/$tests) * 10;\n\t\t\t} else \n\t\t\t\tprint \"<td id=\\\"$username-Z$i\\\" style=\\\"width: 50px\\\">/</td>\\n\";\n\t\t\t$tasks[$username.\"-Z$i\"] = $path;\n\t\t}\n\t\t$score = round($score, 2);\n\t\tprint \"<td style=\\\"width: 50px\\\">$score</td></tr>\\n\";\n\t}\n\t?>\n\t</table>\n\t\n\t<SCRIPT language=\"JavaScript\">\n\t\n\t</SCRIPT>\n\t<?php\n}", "public function testSystemSkillsCountGet()\n {\n\n }", "public function testCollectTestStatistics()\n {\n // Arrange\n $this->loadFixtures();\n $time = 0.1239999;\n $this->StatisticTool->getFixtureManager()->collectDirtyTables();\n $this->StatisticTool->collectTestStatistics($this, $time);\n\n // Act\n $stats = $this->StatisticTool->getStatistics();\n\n // Assert\n $this->assertSame(1, count($stats));\n $stats = $stats[0];\n\n $this->assertSame(0.124, $stats[0]);\n $this->assertSame(self::class, $stats[1]);\n $this->assertSame(__FUNCTION__, $stats[2]);\n $this->assertSame(2, $stats[3]);\n $this->assertSame('test_suite_light.cities, test_suite_light.countries', $stats[4]);\n }", "function display_api_results($test_code){\n\n\t\t$api=new api();\n\t\t$curl_result=$api->connect_api($test_code);\n\t\t$i=0;\n\t\techo \"<pre>\";\n\t\t$size=sizeof($curl_result['report']['completed_test']);\n\t\tfor($i;$i<$size;$i++)\n\t\t\techo $i+1 .\". \" . $curl_result['report']['completed_test'][$i]['candidate_name'].\" & Score : \".$curl_result['report']['completed_test'][$i]['candidate_total_score'] .\"<br>\";\n\n}", "public function testStatistics()\n {\n $this->batteryAdd('AA', 4);\n $this->batteryAdd('AAA', 3);\n $this->batteryAdd('AA', 1);\n\n $crawler = $this->_client->request('GET', self::STATISTICS_PAGE_URL);\n $this->assertEquals(200, $this->_client->getResponse()->getStatusCode());\n $this->assertEquals(\n 1,\n $crawler->filterXPath(\"//tr[td[contains(@class, 'battery-type')]='AA' and\n td[contains(@class, 'battery-count')]='5']\")->count()\n );\n $this->assertEquals(\n 1,\n $crawler->filterXPath(\"//tr[td[contains(@class, 'battery-type')]='AAA' and\n td[contains(@class, 'battery-count')]='3']\")->count()\n );\n }", "public function testTop10TestBase()\n {\n $this->get('/Top10AssistantPerSchool')\n ->assertStatus(200);\n }", "public function test_mod_survey_get_surveys_by_courses() {\n global $DB;\n\n // Create additional course.\n $course2 = self::getDataGenerator()->create_course();\n\n // Second survey.\n $record = new stdClass();\n $record->course = $course2->id;\n $survey2 = self::getDataGenerator()->create_module('survey', $record);\n // Force empty intro.\n $DB->set_field('survey', 'intro', '', array('id' => $survey2->id));\n\n // Execute real Moodle enrolment as we'll call unenrol() method on the instance later.\n $enrol = enrol_get_plugin('manual');\n $enrolinstances = enrol_get_instances($course2->id, true);\n foreach ($enrolinstances as $courseenrolinstance) {\n if ($courseenrolinstance->enrol == \"manual\") {\n $instance2 = $courseenrolinstance;\n break;\n }\n }\n $enrol->enrol_user($instance2, $this->student->id, $this->studentrole->id);\n\n self::setUser($this->student);\n\n $returndescription = mod_survey_external::get_surveys_by_courses_returns();\n\n // Create what we expect to be returned when querying the two courses.\n // First for the student user.\n $expectedfields = array('id', 'coursemodule', 'course', 'name', 'intro', 'introformat', 'introfiles', 'template', 'days',\n 'questions', 'surveydone');\n\n // Add expected coursemodule and data.\n $survey1 = $this->survey;\n $survey1->coursemodule = $survey1->cmid;\n $survey1->introformat = 1;\n $survey1->surveydone = 0;\n $survey1->section = 0;\n $survey1->visible = true;\n $survey1->groupmode = 0;\n $survey1->groupingid = 0;\n $survey1->introfiles = [];\n\n $survey2->coursemodule = $survey2->cmid;\n $survey2->introformat = 1;\n $survey2->surveydone = 0;\n $survey2->section = 0;\n $survey2->visible = true;\n $survey2->groupmode = 0;\n $survey2->groupingid = 0;\n $tempo = $DB->get_field(\"survey\", \"intro\", array(\"id\" => $survey2->template));\n $survey2->intro = nl2br(get_string($tempo, \"survey\"));\n $survey2->introfiles = [];\n\n foreach ($expectedfields as $field) {\n $expected1[$field] = $survey1->{$field};\n $expected2[$field] = $survey2->{$field};\n }\n\n $expectedsurveys = array($expected2, $expected1);\n\n // Call the external function passing course ids.\n $result = mod_survey_external::get_surveys_by_courses(array($course2->id, $this->course->id));\n $result = external_api::clean_returnvalue($returndescription, $result);\n\n $this->assertEquals($expectedsurveys, $result['surveys']);\n $this->assertCount(0, $result['warnings']);\n\n // Call the external function without passing course id.\n $result = mod_survey_external::get_surveys_by_courses();\n $result = external_api::clean_returnvalue($returndescription, $result);\n $this->assertEquals($expectedsurveys, $result['surveys']);\n $this->assertCount(0, $result['warnings']);\n\n // Unenrol user from second course and alter expected surveys.\n $enrol->unenrol_user($instance2, $this->student->id);\n array_shift($expectedsurveys);\n\n // Call the external function without passing course id.\n $result = mod_survey_external::get_surveys_by_courses();\n $result = external_api::clean_returnvalue($returndescription, $result);\n $this->assertEquals($expectedsurveys, $result['surveys']);\n\n // Call for the second course we unenrolled the user from, expected warning.\n $result = mod_survey_external::get_surveys_by_courses(array($course2->id));\n $this->assertCount(1, $result['warnings']);\n $this->assertEquals('1', $result['warnings'][0]['warningcode']);\n $this->assertEquals($course2->id, $result['warnings'][0]['itemid']);\n\n // Now, try as a teacher for getting all the additional fields.\n self::setUser($this->teacher);\n\n $additionalfields = array('timecreated', 'timemodified', 'section', 'visible', 'groupmode', 'groupingid');\n\n foreach ($additionalfields as $field) {\n $expectedsurveys[0][$field] = $survey1->{$field};\n }\n\n $result = mod_survey_external::get_surveys_by_courses();\n $result = external_api::clean_returnvalue($returndescription, $result);\n $this->assertEquals($expectedsurveys, $result['surveys']);\n\n // Admin also should get all the information.\n self::setAdminUser();\n\n $result = mod_survey_external::get_surveys_by_courses(array($this->course->id));\n $result = external_api::clean_returnvalue($returndescription, $result);\n $this->assertEquals($expectedsurveys, $result['surveys']);\n\n // Now, prohibit capabilities.\n $this->setUser($this->student);\n $contextcourse1 = context_course::instance($this->course->id);\n // Prohibit capability = mod/survey:participate on Course1 for students.\n assign_capability('mod/survey:participate', CAP_PROHIBIT, $this->studentrole->id, $contextcourse1->id);\n accesslib_clear_all_caches_for_unit_testing();\n\n $surveys = mod_survey_external::get_surveys_by_courses(array($this->course->id));\n $surveys = external_api::clean_returnvalue(mod_survey_external::get_surveys_by_courses_returns(), $surveys);\n $this->assertFalse(isset($surveys['surveys'][0]['intro']));\n }", "public function test_index()\n {\n factory('App\\Course', 10)->create()->each(function ($u) {\n $u->partecipants()->saveMany(factory('App\\Partecipant', 10)->create());\n });\n $this->actingAs($this->user);\n $response = $this->get('/courses');\n $response->assertStatus(200)\n ->assertSee(Course::first()->description);\n }", "public function testCloudPosCheckAddCourseToCheck()\n {\n }", "public function testCloudPosCheckFastTrackCourse()\n {\n }", "public function getStats() {}", "public function testHoursPerStudent()\n {\n $this->browse(function (Browser $browser) {\n\n $browser->logout()\n ->visit('/login')\n ->type('@email-input', '[email protected]')\n ->type('@password-input', 'helloworld')\n ->click('@login-button')\n ->assertSee('Jill')\n ->click('@reports-link')\n ->assertSee('Generate Reports')\n ->select('report', '/reports/studentHours')\n ->assertPresent('@student-hours-heading');\n });\n }", "public function getStats();", "public function testGetAllCourses() {\n $courses = getAllCourses();\n $this->assertNotEmpty($courses);\n }", "public function testCatalogueLearnv1catalogcalendar()\n {\n\n }", "public function display_stats()\n {\n }", "public function testGetOverall() :void\n {\n $arrCityData = $this->weatherService->getCityData('Brasilia');\n $weatherData = $this->weatherService->getWeatherFromApi($arrCityData['id']);\n $result = $this->weatherService->getMeaningInformation($weatherData);\n $this->assertInstanceOf(\\stdClass::class, $result);\n $this->assertTrue(isset($result->desc));\n $this->assertTrue(isset($result->humidity));\n $this->assertIsString($result->desc);\n $this->assertIsInt($result->humidity);\n }", "function get_athelete_count($course) {\n global $CFG;\n\n $sql = \"SELECT COUNT(cpsst.usersid)\n FROM {$CFG->prefix}block_courseprefs_students cpsst,\n {$CFG->prefix}block_courseprefs_sportusers cpsspou,\n {$CFG->prefix}block_courseprefs_sections sec\n WHERE sec.idnumber = '{$course->idnumber}'\n AND cpsst.sectionsid = sec.id\n AND cpsst.usersid = cpsspou.usersid\n AND cpsst.status = 'enrolled'\";\n\n return count_records_sql($sql);\n}", "function sum_inner_activity_for_courses($courses) {\nglobal $CourseInnerStats;\n\n $res = get_zero_activity_stats();\n foreach ($courses as $courseid) {\n foreach ($CourseInnerStats[$courseid] as $name => $value) {\n $res[$name] += $value;\n }\n }\n return $res;\n}", "public function testSystemSkillsGet()\n {\n\n }", "public function testCatalogueLearnv1catalog()\n {\n\n }", "public function testInfo()\n {\n }", "public function testCloudPosCheckUpdateCoursesInCheck()\n {\n }", "public function testUsersIdScoresGet()\n {\n\n }", "public function testStudent()\n {\n\n $user = User::students()->first();\n\n $response = $this->actingAs($user)->get(route(\"home\"));\n\n $response->assertSee(\"<h3>\" . __(\"Questionnaire compilations\") . \"</h3>\");\n $response->assertDontSeeText(__(\"Compilation form\"));\n $response->assertSeeText(__(\"New compilation\"));\n $response->assertDontSeeText(__(\"All compilations\"));\n $response->assertSeeText(__(\"My compilations\"));\n $response->assertDontSeeText(__(\"Statistics\"));\n\n $response->assertDontSee(\"<h3>\" . __(\"Stages\") . \"</h3>\");\n $response->assertDontSeeText(__(\"Locations\"));\n $response->assertDontSeeText(__(\"Wards\"));\n\n $response->assertDontSee(\"<h3>\" . __(\"Users\") . \"</h3>\");\n $response->assertDontSeeText(__(\"Register new viewer or administrator\"));\n $response->assertDontSee(__(\"Register new viewer\") . \"</a>\");\n $response->assertDontSeeText(__(\"Administrators\"));\n $response->assertDontSeeText(__(\"Viewers\"));\n $response->assertDontSeeText(__(\"Students\"));\n\n }" ]
[ "0.6352974", "0.61806077", "0.6167397", "0.612997", "0.60792965", "0.60592335", "0.60354894", "0.6030895", "0.60265905", "0.6003391", "0.59710455", "0.5880998", "0.5875543", "0.58725125", "0.58580685", "0.5812474", "0.58033454", "0.5790104", "0.5763178", "0.57472724", "0.573283", "0.5716674", "0.56801826", "0.5666083", "0.5659379", "0.5640817", "0.563234", "0.56216455", "0.56094337", "0.5603478" ]
0.71072286
0
Test we can get all of a users plans with a competency.
public function test_list_plans_with_competency() { $this->resetAfterTest(true); $this->setAdminUser(); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $u1 = $this->getDataGenerator()->create_user(); $tpl = $this->getDataGenerator()->get_plugin_generator('core_competency')->create_template(); // Create a framework and assign competencies. $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id'))); // Create two plans and assign the competency to each. $plan1 = $lpg->create_plan(array('userid' => $u1->id)); $plan2 = $lpg->create_plan(array('userid' => $u1->id)); $lpg->create_plan_competency(array('planid' => $plan1->get('id'), 'competencyid' => $c1->get('id'))); $lpg->create_plan_competency(array('planid' => $plan2->get('id'), 'competencyid' => $c1->get('id'))); // Create one more plan without the competency. $plan3 = $lpg->create_plan(array('userid' => $u1->id)); $plans = api::list_plans_with_competency($u1->id, $c1); $this->assertEquals(2, count($plans)); $this->assertEquals(reset($plans)->get('id'), $plan1->get('id')); $this->assertEquals(end($plans)->get('id'), $plan2->get('id')); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function test_list_plan_competencies_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $viewrole = $dg->create_role(array(\n 'name' => 'User view',\n 'shortname' => 'view'\n ));\n assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);\n assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);\n $dg->role_assign($viewrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create draft plan with records in user_competency.\n $draftplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $draftplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n // Check that user_competency objects are returned when plan status is not complete.\n $plancompetencies = api::list_plan_competencies($draftplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[0]->usercompetency);\n $this->assertEquals($uc1->get('id'), $plancompetencies[0]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[1]->usercompetency);\n $this->assertEquals($uc2->get('id'), $plancompetencies[1]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetencyplan);\n\n $this->assertInstanceOf('\\core_competency\\user_competency', $plancompetencies[2]->usercompetency);\n $this->assertEquals(0, $plancompetencies[2]->usercompetency->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetencyplan);\n\n // Create completed plan with records in user_competency_plan.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $pc1 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n $pc3 = $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c3->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp3 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c3->get('id'),\n 'planid' => $completedplan->get('id')));\n\n // Check that user_competency_plan objects are returned when plan status is complete.\n $plancompetencies = api::list_plan_competencies($completedplan);\n\n $this->assertCount(3, $plancompetencies);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[0]->usercompetencyplan);\n $this->assertEquals($ucp1->get('id'), $plancompetencies[0]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[0]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[1]->usercompetencyplan);\n $this->assertEquals($ucp2->get('id'), $plancompetencies[1]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[1]->usercompetency);\n $this->assertInstanceOf('\\core_competency\\user_competency_plan', $plancompetencies[2]->usercompetencyplan);\n $this->assertEquals($ucp3->get('id'), $plancompetencies[2]->usercompetencyplan->get('id'));\n $this->assertNull($plancompetencies[2]->usercompetency);\n }", "public function test_complete_plan() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'proficiency' => true, 'grade' => 1 )),\n $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'proficiency' => false, 'grade' => 2 ))\n );\n\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n\n // Change status of the plan to complete.\n api::complete_plan($plan);\n\n // Check that user competencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Check we can not add competency to completed plan.\n try {\n api::add_competency_to_plan($plan->get('id'), $c4->get('id'));\n $this->fail('We can not add competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Check we can not remove competency to completed plan.\n try {\n api::remove_competency_from_plan($plan->get('id'), $c3->get('id'));\n $this->fail('We can not remove competency to completed plan.');\n } catch (coding_exception $e) {\n // All good.\n }\n\n // Completing a plan that is completed throws an exception.\n api::complete_plan($plan);\n }", "public function test_access_plan_limit() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\tforeach ( array( 'course', 'llms_membership' ) as $pt ) {\n\n\t\t\t// Create 5 access plans, by default the limit is 6 per product.\n\t\t\t$access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) );\n\n\t\t\t$product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\n\t\t\tforeach ( $access_plan_ids as $access_plan_id ) {\n\t\t\t\tupdate_post_meta( $access_plan_id, '_llms_product_id', $product );\n\t\t\t}\n\n\t\t\t// Create an ap through api with same product id.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t\t$sixth_ap = $response->get_data()['id'];\n\t\t\t// The 6th passes.\n\t\t\t$this->assertResponseStatusEquals( 201, $response, $pt );\n\n\t\t\t// Create the 7th ap.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\n\t\t\t// Update the 6th.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $sixth_ap,\n\t\t\t\tarray(\n\t\t\t\t\t'title' => 'Updated',\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// Update passes.\n\t\t\t$this->assertResponseStatusEquals( 200, $response, $pt );\n\n\t\t\t// Create an ap linked to a different product.\n\t\t\t$access_plan = $this->factory->post->create( array( 'post_type' => $this->post_type ) );\n\t\t\t$new_product = $this->factory->post->create( array( 'post_type' => $pt ) );\n\t\t\tupdate_post_meta( $access_plan, '_llms_product_id', $new_product );\n\n\t\t\t// Update its post_id so that it becomes the 7th ap of the first product.\n\t\t\t$response = $this->perform_mock_request(\n\t\t\t\t'POST',\n\t\t\t\t$this->route . '/' . $access_plan,\n\t\t\t\tarray_merge(\n\t\t\t\t\t$this->sample_access_plan_args,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'post_id' => $product,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The 7th is blocked.\n\t\t\t$this->assertResponseStatusEquals( 400, $response, $pt );\n\t\t\t$this->assertResponseMessageEquals(\n\t\t\t\tsprintf(\n\t\t\t\t\t'Only %1$d %2$s allowed per %3$s',\n\t\t\t\t\t6,\n\t\t\t\t\tstrtolower( get_post_type_object( $this->post_type )->labels->name ),\n\t\t\t\t\tstrtolower( get_post_type_object( $pt )->labels->singular_name )\n\t\t\t\t),\n\t\t\t\t$response\n\t\t\t);\n\t\t}\n\t}", "public function test_get_access_plans_with_pagination() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$access_plan_ids = $this->factory->post->create_many( 25, array( 'post_type' => $this->post_type ) );\n\t\t$course = $this->factory->course->create();\n\t\tforeach ( $access_plan_ids as $id ) {\n\t\t\tupdate_post_meta( $id, '_llms_product_id', $course );\n\t\t}\n\t\t$start_access_plan_id = $access_plan_ids[0];\n\t\t$this->pagination_test( $this->route, $start_access_plan_id );\n\t}", "public function test_update_plan_manage_archived_competencies() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n $manageownrole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);\n assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);\n $dg->role_assign($manageownrole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n $otherplan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n $lpg->create_plan_competency(array('planid' => $otherplan->get('id'), 'competencyid' => $c1->get('id')));\n\n $uclist = array(\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c1->get('id'),\n 'proficiency' => true,\n 'grade' => 1\n )),\n $lpg->create_user_competency(array(\n 'userid' => $user->id,\n 'competencyid' => $c2->get('id'),\n 'proficiency' => false,\n 'grade' => 2\n ))\n );\n\n // Change status of the plan to complete.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_COMPLETE;\n\n try {\n $plan = api::update_plan($record);\n $this->fail('We cannot complete a plan using api::update_plan().');\n } catch (coding_exception $e) {\n // All good.\n }\n api::complete_plan($plan);\n\n // Check that user compretencies are now in user_competency_plan objects and still in user_competency.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n\n $usercompetenciesplan = \\core_competency\\user_competency_plan::get_records();\n\n $this->assertEquals($uclist[0]->get('userid'), $usercompetenciesplan[0]->get('userid'));\n $this->assertEquals($uclist[0]->get('competencyid'), $usercompetenciesplan[0]->get('competencyid'));\n $this->assertEquals($uclist[0]->get('proficiency'), (bool) $usercompetenciesplan[0]->get('proficiency'));\n $this->assertEquals($uclist[0]->get('grade'), $usercompetenciesplan[0]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[0]->get('planid'));\n\n $this->assertEquals($uclist[1]->get('userid'), $usercompetenciesplan[1]->get('userid'));\n $this->assertEquals($uclist[1]->get('competencyid'), $usercompetenciesplan[1]->get('competencyid'));\n $this->assertEquals($uclist[1]->get('proficiency'), (bool) $usercompetenciesplan[1]->get('proficiency'));\n $this->assertEquals($uclist[1]->get('grade'), $usercompetenciesplan[1]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[1]->get('planid'));\n\n $this->assertEquals($user->id, $usercompetenciesplan[2]->get('userid'));\n $this->assertEquals($c3->get('id'), $usercompetenciesplan[2]->get('competencyid'));\n $this->assertNull($usercompetenciesplan[2]->get('proficiency'));\n $this->assertNull($usercompetenciesplan[2]->get('grade'));\n $this->assertEquals($plan->get('id'), $usercompetenciesplan[2]->get('planid'));\n\n // Change status of the plan to active.\n $record = $plan->to_record();\n $record->status = \\core_competency\\plan::STATUS_ACTIVE;\n\n try {\n api::update_plan($record);\n $this->fail('Completed plan can not be edited');\n } catch (coding_exception $e) {\n // All good.\n }\n\n api::reopen_plan($record->id);\n // Check that user_competency_plan objects are deleted if the plan status is changed to another status.\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_complete_plan_doesnot_change_order() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users and roles for the test.\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create two plans and assign competencies.\n $plan = $lpg->create_plan(array('userid' => $user->id));\n\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c2->get('id')));\n $lpg->create_plan_competency(array('planid' => $plan->get('id'), 'competencyid' => $c3->get('id')));\n\n // Changing competencies order in plan competency.\n api::reorder_plan_competency($plan->get('id'), $c1->get('id'), $c3->get('id'));\n\n $competencies = api::list_plan_competencies($plan);\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Testing plan based on template.\n $template = $lpg->create_template();\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c1->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c2->get('id')\n ));\n $lpg->create_template_competency(array(\n 'templateid' => $template->get('id'),\n 'competencyid' => $c3->get('id')\n ));\n // Reorder competencies in template.\n api::reorder_template_competency($template->get('id'), $c1->get('id'), $c3->get('id'));\n\n // Create plan from template.\n $plan = api::create_plan_from_template($template->get('id'), $user->id);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n\n // Completing plan.\n api::complete_plan($plan);\n\n $competencies = api::list_plan_competencies($plan);\n\n // Completing plan does not change order.\n $this->assertEquals($c2->get('id'), $competencies[0]->competency->get('id'));\n $this->assertEquals($c3->get('id'), $competencies[1]->competency->get('id'));\n $this->assertEquals($c1->get('id'), $competencies[2]->competency->get('id'));\n }", "public function test_delete_plan_manage_archived_competencies() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create user and role for the test.\n $user = $dg->create_user();\n $managerole = $dg->create_role(array(\n 'name' => 'User manage own',\n 'shortname' => 'manageown'\n ));\n assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);\n assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);\n $dg->role_assign($managerole, $user->id, $syscontext->id);\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create completed plan with records in user_competency.\n $completedplan = $lpg->create_plan(array('userid' => $user->id, 'status' => \\core_competency\\plan::STATUS_COMPLETE));\n\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c1->get('id')));\n $lpg->create_plan_competency(array('planid' => $completedplan->get('id'), 'competencyid' => $c2->get('id')));\n\n $uc1 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $uc2 = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c2->get('id')));\n\n $ucp1 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c1->get('id'),\n 'planid' => $completedplan->get('id')));\n $ucp2 = $lpg->create_user_competency_plan(array('userid' => $user->id, 'competencyid' => $c2->get('id'),\n 'planid' => $completedplan->get('id')));\n\n api::delete_plan($completedplan->get('id'));\n\n // Check that achived user competencies are deleted.\n $this->assertEquals(0, \\core_competency\\plan::count_records());\n $this->assertEquals(2, \\core_competency\\user_competency::count_records());\n $this->assertEquals(0, \\core_competency\\user_competency_plan::count_records());\n }", "public function test_create_paid_access_plan() {\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 10,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Now test that if the frequency is 0 (default) and we enable the trial, the trial is still disabled.\n\t\t$sample_args['trial_enabled'] = true;\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$paid_props = array(\n\t\t\t'is_free' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t\t'frequency' => 0,\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $paid_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Test that a frequency > 0 unlocks trials.\n\t\t$sample_args['frequency'] = 1;\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\t\t$this->assertTrue(\n\t\t\tllms_parse_bool(\n\t\t\t\t( new LLMS_Access_Plan( $response->get_data()['id'] ) )->get( 'trial_offer' )\n\t\t\t)\n\t\t);\n\t}", "abstract protected function get_paid_plan_for_api();", "public function test_completed_plan_doesnot_change() {\n global $DB;\n\n $this->resetAfterTest(true);\n $this->setAdminUser();\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n $user = $dg->create_user();\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create template and assign competencies.\n $tp = $lpg->create_template();\n $tpc1 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c1->get('id')));\n $tpc2 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c2->get('id')));\n $tpc3 = $lpg->create_template_competency(array('templateid' => $tp->get('id'), 'competencyid' => $c3->get('id')));\n\n // Create a plan form template and change it status to complete.\n $plan = $lpg->create_plan(array('userid' => $user->id, 'templateid' => $tp->get('id')));\n api::complete_plan($plan);\n\n // Check user competency plan created correctly.\n $this->assertEquals(3, \\core_competency\\user_competency_plan::count_records());\n $ucp = \\core_competency\\user_competency_plan::get_records();\n $this->assertEquals($ucp[0]->get('competencyid'), $c1->get('id'));\n $this->assertEquals($ucp[1]->get('competencyid'), $c2->get('id'));\n $this->assertEquals($ucp[2]->get('competencyid'), $c3->get('id'));\n\n // Add and remove a competency from the template.\n api::add_competency_to_template($tp->get('id'), $c4->get('id'));\n api::remove_competency_from_template($tp->get('id'), $c1->get('id'));\n\n // Check that user competency plan did not change.\n $competencies = $plan->get_competencies();\n $this->assertEquals(3, count($competencies));\n $ucp1 = array($c1->get('id'), $c2->get('id'), $c3->get('id'));\n $ucp2 = array();\n foreach ($competencies as $id => $cmp) {\n $ucp2[] = $id;\n }\n $this->assertEquals(0, count(array_diff($ucp1, $ucp2)));\n }", "public function test_meetCriteria_called_returnCollectionWithProperData()\n {\n $expected = new PaymentsCollection();\n $expected->addItem('WideCardPaymentStrategy',new WideCardPaymentStrategy());\n $expected->addItem('MoneyMatrixPaymentStrategy',new MoneyMatrixPaymentStrategy());\n $paymentsCollection = $this->getPaymentsCollectionTest();\n $actual = $this->getSut([CountrySelectorType::SPAIN])->meetCriteria($paymentsCollection);\n $this->assertEquals($expected,$actual);\n }", "public function test_get_user_competency_in_course() {\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $dg->get_plugin_generator('core_competency');\n $this->setAdminUser();\n\n $user = $dg->create_user();\n $c1 = $dg->create_course();\n\n // Enrol the user so they can be rated in the course.\n $studentarch = get_archetype_roles('student');\n $studentrole = array_shift($studentarch);\n $coursecontext = context_course::instance($c1->id);\n $dg->role_assign($studentrole->id, $user->id, $coursecontext->id);\n $dg->enrol_user($user->id, $c1->id, $studentrole->id);\n\n $framework = $lpg->create_framework();\n $comp1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $comp2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $lpg->create_course_competency(array('competencyid' => $comp1->get('id'), 'courseid' => $c1->id));\n $lpg->create_course_competency(array('competencyid' => $comp2->get('id'), 'courseid' => $c1->id));\n\n // Create a user competency for comp1.\n api::grade_competency_in_course($c1, $user->id, $comp1->get('id'), 3, 'Unit test');\n\n // Test for competency already exist in user_competency.\n $uc = api::get_user_competency_in_course($c1->id, $user->id, $comp1->get('id'));\n $this->assertEquals($comp1->get('id'), $uc->get('competencyid'));\n $this->assertEquals($user->id, $uc->get('userid'));\n $this->assertEquals(3, $uc->get('grade'));\n $this->assertEquals(true, $uc->get('proficiency'));\n\n // Test for competency does not exist in user_competency.\n $uc2 = api::get_user_competency_in_course($c1->id, $user->id, $comp2->get('id'));\n $this->assertEquals($comp2->get('id'), $uc2->get('competencyid'));\n $this->assertEquals($user->id, $uc2->get('userid'));\n $this->assertEquals(null, $uc2->get('grade'));\n $this->assertEquals(null, $uc2->get('proficiency'));\n }", "public function testGetProductionPlan() {\n $model = new ProductionPlanModel();\n\n $res = $model->getProductionPlan(\"5\");\n $this->tester->assertEquals($res, array(array('month' => '05', 'skis' => array('1' => 100, '2' => 50))));\n }", "public function test_create_free_access_plan() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$course = $this->factory->course->create_and_get();\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t// Check that the access plan has the following properties values:\n\t\t$free_props = array(\n\t\t\t'is_free' => 'yes',\n\t\t\t'price' => 0,\n\t\t\t'frequency' => 0,\n\t\t\t'on_sale' => 'no',\n\t\t\t'trial_offer' => 'no',\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t\t// Check again, that even the passed properties are \"reset\".\n\t\t$sample_args = array_merge(\n\t\t\t$this->sample_access_plan_args,\n\t\t\tarray(\n\t\t\t\t'post_id' => $course->get( 'id' ),\n\t\t\t\t'price' => 0,\n\t\t\t\t'frequency' => 6,\n\t\t\t\t'sale_enabled' => true,\n\t\t\t\t'trial_enabled' => true,\n\t\t\t)\n\t\t);\n\n\t\t$response = $this->perform_mock_request(\n\t\t\t'POST',\n\t\t\t$this->route,\n\t\t\t$sample_args\n\t\t);\n\n\t\t$ap = new LLMS_Access_Plan( $response->get_data()['id'] );\n\t\tforeach ( $free_props as $prop => $value ) {\n\t\t\t$this->assertEquals( $value, $ap->get( $prop ), $prop );\n\t\t}\n\n\t}", "public function testSalesOpportunitiesTypesGet()\n {\n\n }", "function fn_get_affiliate_plans_list($lang_code = CART_LANGUAGE)\n{\n $plans_list = db_get_hash_single_array(\"SELECT object_id, object FROM ?:affiliate_plans LEFT JOIN ?:common_descriptions ON plan_id=object_id AND lang_code = ?s AND object_holder = 'affiliate_plans' WHERE status = 'A' ORDER BY object\", array('object_id', 'object'), $lang_code);\n\n return empty($plans_list) ? false : $plans_list;\n}", "public function test_list_evidence() {\n global $DB;\n\n $this->resetAfterTest(true);\n $dg = $this->getDataGenerator();\n $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');\n\n $syscontext = context_system::instance();\n\n // Create users.\n $user = $dg->create_user();\n $this->setUser($user);\n\n // Create a framework and assign competencies.\n $framework = $lpg->create_framework();\n $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get('id')));\n\n // Create 2 user plans and add competency to each plan.\n $p1 = $lpg->create_plan(array('userid' => $user->id));\n $p2 = $lpg->create_plan(array('userid' => $user->id));\n $pc1 = $lpg->create_plan_competency(array('planid' => $p1->get('id'), 'competencyid' => $c1->get('id')));\n $pc2 = $lpg->create_plan_competency(array('planid' => $p2->get('id'), 'competencyid' => $c1->get('id')));\n\n // Create user competency and add an evidence.\n $uc = $lpg->create_user_competency(array('userid' => $user->id, 'competencyid' => $c1->get('id')));\n $e1 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n\n // Check both plans as one evidence.\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n $this->assertEquals(1, count(api::list_evidence($user->id, $c1->get('id'), $p2->get('id'))));\n\n // Complete second plan.\n $p2->set('status', plan::STATUS_COMPLETE);\n $p2->update();\n\n // Add another evidence for the same competency, but in the future (time + 1).\n $e2 = $lpg->create_evidence(array('usercompetencyid' => $uc->get('id')));\n $evidencesql = \"UPDATE {\" . evidence::TABLE . \"} SET timecreated = :currenttime WHERE id = :evidenceid\";\n $DB->execute($evidencesql, array('currenttime' => time() + 1, 'evidenceid' => $e2->get('id')));\n\n // Check that the first plan, which is not completed, has all the evidence.\n $this->assertEquals(2, count(api::list_evidence($user->id, $c1->get('id'), $p1->get('id'))));\n\n // Check that the second plan, completed before the new evidence, only has the first piece of evidence.\n $listevidences = api::list_evidence($user->id, $c1->get('id'), $p2->get('id'));\n $this->assertEquals(1, count($listevidences));\n $this->assertEquals($e1->get('id'), $listevidences[$e1->get('id')]->get('id'));\n }", "public function listUsersInPlan(){\n $response = array();\n \n $query = $this->db->select('u.id, u.username, u.email, u.id_customer_stripe')\n ->from('users u')\n ->join('record_user_plan r', 'r.id_user = u.id')\n ->where('r.status', 'a')\n ->get();\n $response = $query->result_array();\n //$response['num']= $query->num_rows() ;\n return $response;\n }", "public function test_that_authorized_user_can_view_courses_within_other_periods()\n {\n \n }", "public function testAccountingPaymentsResources()\n {\n $resources = $this->accountingPayments->getCollection();\n\n $this->assertEquals($resources->isCollection(), true);\n $this->assertEquals($resources->isEmpty(), false);\n //$this->assertEquals($resources->hasParent(), true); // TBC\n\n $this->assertEquals($resources->count(), 3);\n $this->assertEquals(count($resources), 3);\n }", "public function test_plans_visibility(){\n $planType = $this->createPlanType();\n\n $isVisible = true;\n $visiblePlan = $this->createPlan('visible_plan', $planType, false, [], $isVisible);\n\n $isVisible = false;\n $visiblePlan = $this->createPlan('hidden_plan', $planType, false, [], $isVisible);\n\n $this->assertEquals($planType->plans()->visible()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->hidden()->count(), 1);\n $this->assertEquals($planType->plans()->withHiddens()->count(), 2);\n }", "public function test_get_rate()\n {\n $travelers = [];\n array_push($travelers, array(\"TravelerDOB\" => \"02/14/1990\", \"TravelCost\" => \"300\"));\n array_push($travelers, array(\"TravelerDOB\" => \"02/14/1990\", \"TravelCost\" => \"300\"));\n\n $data = [\"departuredate\" => \"10/16/2018\",\n \"returndate\" => \"2/20/2019\",\n \"destinationcountry\" => \"France\",\n \"planname\" => \"Renter's Collision\",\n \"statecode\" => \"CA\",\n ];\n\n $solartis = new \\App\\Solartis\\API;\n $data['plancode'] = $solartis->plan_code($data['planname']);\n $res = $solartis->get_rating($data, $travelers);\n $this->assertEquals($res['RequestStatus'], \"SUCCESS\");\n $this->assertEquals($res['PremiumInformation']['PlanName'], $data['planname']);\n assert(array_key_exists('TotalGrossPremium', $res['PremiumInformation']));\n }", "function have_payment_plans( $category = array() ) {\r\n return \\query\\payments::have_plans( $category );\r\n}", "public function testAccountingPaymentResources()\n {\n $resources = $this->accountingPayment->getCollection();\n\n $this->assertEquals($resources->isCollection(), true);\n $this->assertEquals($resources->isEmpty(), false);\n //$this->assertEquals($resources->hasParent(), true); // TBC\n\n $this->assertEquals($resources->count(), 1);\n $this->assertEquals(count($resources), 1);\n }", "public function testListMyCourse()\n {\n $data = [];\n $sales = [];\n\n $sale = new Sale();\n $sales = $sale->getResults($data);\n\n //$this->assertJson($sales);\n\n //dd($sales);\n }", "public function testSalesOpportunitiesTypesCountGet()\n {\n\n }", "function getActivePlansForPricingPage()\r\n {\r\n $this->db->select(\"id, name, is_featured, tagline,price, outlets, employees, clients, treatments, products, stations, suppliers, emails_per_month AS 'Email Campaigns', \r\n texts_per_month AS 'Included Texts', texts_cost_each AS 'Extra Text Cost', has_stock_control AS '*Stock Control', has_reports AS '*Reports', \r\n has_pos AS '*POS', has_online_booking AS '*Online Booking', has_rewards AS '*Rewards Scheme', has_gift_cards AS '*Gift Cards'\");\r\n $this->db->where('is_active', 1);\r\n $this->db->where('is_visible', 1);\r\n $this->db->order_by('price', 'ASC');\r\n $q = $this->db->get('plans');\r\n return $q->result_array();\r\n }", "public function testVoucherGetDependingRecurringVouchers()\n {\n }", "public function testGetLicenseUsers()\n {\n }", "public function test_collection_filtering() {\n\n\t\twp_set_current_user( $this->user_allowed );\n\n\t\t$access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) );\n\n\t\t// Link the plans to two different courses.\n\t\t$course_one = $this->factory->course->create();\n\t\t$course_two = $this->factory->course->create();\n\t\t$i = 0;\n\t\tforeach ( $access_plan_ids as $access_plan_id ) {\n\t\t\tupdate_post_meta( $access_plan_id, '_llms_product_id', ${ 0 === ( ++$i % 2 ) ? 'course_one' : 'course_two' } );\n\t\t}\n\n\t\t// Filter by first course.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'GET',\n\t\t\t$this->route,\n\t\t\tarray(),\n\t\t\tarray(\n\t\t\t\t'post_id' => $course_one,\n\t\t\t)\n\t\t);\n\n\t\t// Success.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$res_data = $response->get_data();\n\t\t$this->assertEquals( array_fill( 0, 2, $course_one ), array_column( $res_data, 'post_id' ) );\n\n\t\t// Filter by second course.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'GET',\n\t\t\t$this->route,\n\t\t\tarray(),\n\t\t\tarray(\n\t\t\t\t'post_id' => $course_two,\n\t\t\t)\n\t\t);\n\n\t\t// Success.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$res_data = $response->get_data();\n\t\t$this->assertEquals( array_fill( 0, 3, $course_two ), array_column( $res_data, 'post_id' ) );\n\n\t\t// Filter by both.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'GET',\n\t\t\t$this->route,\n\t\t\tarray(),\n\t\t\tarray(\n\t\t\t\t'post_id' => array(\n\t\t\t\t\t$course_two,\n\t\t\t\t\t$course_one\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\t// Success.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$res_data = $response->get_data();\n\t\t$array_of_five = array_fill( 0, 5, null );\n\t\t$this->assertEquals(\n\t\t\tarray_map(\n\t\t\t\tfunction( $val, $i ) use ( $course_one, $course_two ){\n\t\t\t\t\treturn ${ 0 === ( ++$i % 2 ) ? 'course_one' : 'course_two' };\n\t\t\t\t},\n\t\t\t\t$array_of_five,\n\t\t\t\tarray_keys( $array_of_five )\n\t\t\t),\n\t\t\tarray_column(\n\t\t\t\t$res_data, 'post_id'\n\t\t\t)\n\t\t);\n\n\t\t// Add another course.\n\t\t$access_plan_id = $this->factory->post->create( array( 'post_type' => $this->post_type ) );\n\t\t$course_three = $this->factory->course->create();\n\t\tupdate_post_meta( $access_plan_id, '_llms_product_id', $course_three );\n\n\t\t// Check again filtering by one and two.\n\t\t$response = $this->perform_mock_request(\n\t\t\t'GET',\n\t\t\t$this->route,\n\t\t\tarray(),\n\t\t\tarray(\n\t\t\t\t'post_id' => array(\n\t\t\t\t\t$course_two,\n\t\t\t\t\t$course_one\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\n\t\t// Success.\n\t\t$this->assertResponseStatusEquals( 200, $response );\n\t\t$res_data = $response->get_data();\n\t\t$array_of_five = array_fill( 0, 5, null );\n\t\t$this->assertEquals(\n\t\t\tarray_map(\n\t\t\t\tfunction( $val, $i ) use ( $course_one, $course_two ){\n\t\t\t\t\treturn ${ 0 === ( ++$i % 2 ) ? 'course_one' : 'course_two' };\n\t\t\t\t},\n\t\t\t\t$array_of_five,\n\t\t\t\tarray_keys( $array_of_five )\n\t\t\t),\n\t\t\tarray_column(\n\t\t\t\t$res_data, 'post_id'\n\t\t\t)\n\t\t);\n\n\t}" ]
[ "0.64486486", "0.63952965", "0.6328305", "0.6114482", "0.6061739", "0.5972143", "0.58744425", "0.5855687", "0.5802279", "0.57965815", "0.5775508", "0.5723052", "0.5668928", "0.56634897", "0.564975", "0.5632493", "0.5626523", "0.5581315", "0.5564412", "0.5563367", "0.5552483", "0.55054647", "0.54871434", "0.5482586", "0.5466325", "0.54570866", "0.5456944", "0.5441343", "0.54261196", "0.5418757" ]
0.73878855
0
Delete file if exist.
public function deleteFileIfExist($path) { if (file_exists($path)) { unlink($path); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function deleteFile();", "public function delete() {\n if ($this->_filepath and is_writable($this->_filepath)) {\n unlink($this->_filepath);\n }\n }", "function ecoder_delete_file ( $path ) {\n\tif ( file_exists ( $path ) ) {\n\t\t@unlink ( $path );\n\t\tecoder_echo( '', '', $path.' ~ file deleted.' );\n\t} else {\n\t\tecoder_echo( '', '', $path.' ~ does not exist.' );\n\t}\t\n}", "function deleteFile($file){\n\t\tif(!isNull($file)){\n\t\t\tif(is_file($file) && file_exists($file)){\n\t\t\t\tunlink($file);\n\t\t\t}\n\t\t}\n\t}", "function deleteFile( $path = '' ){\n\n\t\tif( ! file_exists($path) ) return false;\n\n\t\tunlink($path);\n\t\treturn true;\n\n\t}", "public function delete() {\n if (file_exists($this->src)) unlink($this->src);\n }", "public function deleteFile() {\n if(unlink($this->path . $this->name) && unlink($this->path . $this->thumbnailName)) {\n return true;\n }\n return false;\n }", "public static function DeleteFile($file)\n {\n $path = $file;\n if(File::isFile($path)){\n File::delete($path);\n }\n }", "function delete($file=NULL) {\n\t\tif(unlink(fra_var[\"files_path\"].\"\".$file)) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}", "public function delete(string $filename): void\n {\n if (file_exists ($filename)) {\n unlink($filename);\n } \n }", "public static function del($file_path) {\n if (file_exists($file_path)) {\n try {\n @unlink($file_path);\n } catch (\\exception $e) {\n\n }\n }\n }", "public function deleteFile()\n {\n $baseDir = $this->getFullFilePath();\n $file = $baseDir.$this->getRealpath();\n $thumb = $baseDir.\"thumbnail/\".$this->getThumbpath();\n $mini = $baseDir.\"thumbnail/mini/\".$this->getThumbpath();\n $original = $baseDir.\"original/\".$this->getOriginalpath();\n \n // Check for related artwork, is this the only file?\n if ($this->hasArtwork())\n {\n try\n {\n $parentArtworks = $this->getParentArtworks();\n \n // Remove this file from the artwork\n foreach ($parentArtworks as $parentArtwork)\n {\n $parentArtwork->removeFile($this);\n }\n }\n catch (Exception $e)\n {\n throw new exception($e->getMessage());\n }\n }\n try\n {\n $this->_reaktorfile->delete();\n $this->removeAllTags();\n }\n catch (Exception $e)\n {\n throw new exception($e->getMessage());\n }\n \n if (file_exists($file))\n {\n unlink($file);\n }\n if (file_exists($thumb))\n {\n unlink($thumb);\n }\n if (file_exists($mini))\n {\n unlink($mini);\n }\n if (file_exists($original))\n {\n unlink($original);\n }\n \n // Clean up metadata\n $this->removeAllMeta();\n }", "public function remove()\n {\n\n if( file_exists( $this->getPath().\"/\".$this->getTmpFile() ) ) {\n\n unlink( $this->getPath().\"/\".$this->getTmpFile() );\n\n }\n }", "function deleteFile($file){\n\t\t\treturn @unlink($file);\n\t\t}", "function delete_media($path,$file){\n \n $main = $path.$file;\n \n if(file_exists(FCPATH.$main)):\n unlink( FCPATH.$main);\n endif;\n return TRUE;\n }", "public function deleteFile($path)\n\t{\n\t\t$I = $this;\n\t\t$absolutePath = $this->absolutizePath($path);\n\t\tif (!file_exists($absolutePath)) {\n\t\t\t\\PHPUnit\\Framework\\Assert::fail('file not found.');\n\t\t}\n\t\tunlink($absolutePath);\n\t\t$I->comment('Deleted ' . $absolutePath);\n\t}", "protected function removeFile()\n {\n }", "public function deleteFile($file)\n {\n if(!is_null($file) && $file !== \"\"){\n $filePath = public_path($file);\n if (file_exists($filePath)) {\n if(unlink($filePath)) { return true;} else { return false;}\n }\n return true;\n }\n return true;\n }", "function deleteFile($filePath){\n\t\t\t\n\t\t\t$fullFilePath = $this->UserHomeDir.$filePath;\n\t\t\tif(is_dir($fullFilePath)){\n\t\t\t\tsystem('rm -rf '.$fullFilePath);\n\t\t\t}else{\n\t\t\t\tsystem('rm '.$fullFilePath, $runval);\n\t\t\t}\n\t\t}", "function Delete($dir, $file){\n\t $dir = $this -> Dir($dir);\n\t\t$file = $dir . '/' . $file;\n\t\t\n\t\tif( (file_exists($file)) && (@unlink($file)) ) return 1;\n\t\treturn 0;\n\t}", "protected function _deleteEmptyFile($path)\n {\n $File = new File($path);\n if ($File->exists()) {\n $File->delete();\n $this->out(sprintf('<success>Deleted</success> `%s`', $path), 1, Shell::QUIET);\n }\n }", "abstract public function unlink($filePath);", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}", "public function actionDeleteFile()\n\t{\n\t\tif($fileHash = InCache('fileHash', false, self::CACHE_ID))\n\t\t{\n\t\t\t$document = CMSUploadFileDocument::getByHash($fileHash);\n\t\t\t$document->remove();\n\t\t\tUnSetCacheVar('fileHash', self::CACHE_ID);\n\t\t}\n\n\t\t$this->actionUploadFile();\n\t}" ]
[ "0.79306775", "0.7572899", "0.7563259", "0.7543423", "0.75343585", "0.7135014", "0.70179343", "0.7005157", "0.7002705", "0.696694", "0.69632703", "0.6955235", "0.6877758", "0.6816211", "0.6814454", "0.67814773", "0.67683053", "0.67490387", "0.6726933", "0.6710707", "0.6707753", "0.67040485", "0.67013705", "0.67013705", "0.67013705", "0.67013705", "0.67013705", "0.67013705", "0.67013705", "0.67013705" ]
0.7838157
1
Force the creation of a directory with recursion and capitalization.
public function makeDirCapitalize($path, $mode = 0755) { $path = ucwords($path, '/\\.'); return @mkdir($path, $mode, TRUE); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createDirectory($name);", "abstract function createDirectory($path);", "function create_dir( $dir_name ){\n\n\t$filename = $dir_name . \"/\";\n\tif (!file_exists($filename)) {\n\tmkdir( $dir_name,0777,TRUE );\n\t}\n}", "public function test_make_dir() {\n $path = 'test/data/IO/FS/newdir/nesteddir';\n $parent_path = 'test/data/IO/FS/newdir';\n $dir = IO_FS::make_nested_dir($path);\n $this->\n assert_class('IO.FS.Dir', $dir)->\n assert_true(IO_FS::is_dir($dir))->\n assert_equal($dir->path, $path)->\n assert_true(IO_FS::rm($path))->\n assert_true(IO_FS::rm($parent_path))->\n assert_false(IO_FS::is_dir($path))->\n assert_false(IO_FS::is_dir($parent_path))->\n assert_false(IO_FS::exists($path))->\n assert_false(IO_FS::exists($parent_path));\n }", "private function createDirStructureForUnInstaller(): void\n {\n vfsStream::newFile('file1.txt')->at($this->root->getChild('source'));\n vfsStream::newFile('file1.txt')->at($this->root->getChild('destination'));\n vfsStream::newFile('file2.txt')->at($this->root->getChild('source'));\n vfsStream::newFile('file2.txt')->at($this->root->getChild('destination'));\n vfsStream::newDirectory('folder1')->at($this->root->getChild('source'));\n vfsStream::newDirectory('folder1')->at($this->root->getChild('destination'));\n vfsStream::newFile('file3.txt')->at($this->root->getChild('source/folder1'));\n vfsStream::newFile('file3.txt')->at($this->root->getChild('destination/folder1'));\n }", "function makeUserDirectory(string $dirName): void {\n mkdir('../../../../../social-media-uploads/' . strtolower($dirName), 0777, true);\n}", "function chdir ($directory) {}", "protected function prepareFolder()\n {\n if (!file_exists(Yii::$app->getModule('files')->cacheFullPath))\n mkdir(Yii::$app->getModule('files')->cacheFullPath);\n $lastFolder = '/';\n $explodes = explode('/', $this->fileName);\n array_pop($explodes);\n if (empty($explodes))\n return;\n foreach ($explodes as $folder) {\n if (empty($folder))\n continue;\n $lastFolder = $lastFolder . $folder . '/';\n if (!file_exists($lastFolder))\n mkdir($lastFolder);\n }\n }", "function mkdir ($pathname, $mode = 0777, $recursive = false, $context = null) {}", "function mkFolder($oriFolder, $movieTitle, $lang = 'english')\r\n{\r\n $folderPath = MV_PATH . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR;\r\n // Create target dir\r\n if (is_dir($folderPath . $oriFolder)) {\r\n if (is_dir($folderPath . $movieTitle)) {\r\n echo \"Already Exist Please check\";\r\n }\r\n echo \"YES\";\r\n //if(rename($folderPath, $loc.DIRECTORY_SEPARATOR.$folderName)){\r\n //}\r\n }\r\n}", "function ensure_directory($dir) {\n if(is_dir($dir)) return $dir;\n mkdir($dir, 0777, true);\n return $dir;\n }", "function create_directory($company){ \n\t$thisdir = getcwd(); \n\t\n\t/* create a subfolder; make folder writable (CHMOD 0777)*/ \n\tif(file_exists ($thisdir .\"/userfiles/\". trim($company))){\n\t}\n\telse{\n\t\tif(mkdir($thisdir .\"/userfiles/\". trim($company) , 0777)) {\n\t\t\tmkdir($thisdir .\"/userfiles/\". trim($company).\"/archive\" , 0777); /*making archive folder*/\n\t\t} \n\t\telse { \n\t\t //echo \"Failed to create directory...\"; \n\t\t} \n\t}\n}", "function createDirectory($name) {\n $category = $this->categoryForPath($this->myPath);\n\n $db = rex_sql::factory();\n $db->setTable(rex::getTablePrefix() . 'media_category');\n $db->setValue('name', $name);\n $db->setValue('parent_id', $category->getId());\n $db->setValue('path', $category->getPath() . $category->getId().'|');\n $db->addGlobalCreateFields();\n $db->addGlobalUpdateFields();\n\n $db->insert();\n\n rex_media_cache::deleteCategoryList($category->getId());\n }", "function file_force_contents($dir, $contents){\n $parts = explode(\"/\", $dir);\n $file = array_pop($parts);\n $dir = \"\";\n\n foreach($parts as $part) {\n if (! is_dir($dir .= \"{$part}/\")) mkdir($dir);\n }\n //$contents = htmlspecialchars($contents, ENT_NOQUOTES, 'UTF-8');\n return file_put_contents(\"{$dir}{$file}\", $contents);\n }", "public function testMakeDirectory()\n {\n Storage::mkdir(self::$temp . DS . 'created');\n $this->assertTrue(is_dir(self::$temp . DS . 'created'));\n }", "public static function dir_create($dir_name, $recursive=false, $allow_protected_paths=false) {\n\t\t//--\n\t\t$dir_name = (string) $dir_name;\n\t\t//--\n\t\tif(!defined('SMART_FRAMEWORK_CHMOD_DIRS')) {\n\t\t\tself::log_warning(__METHOD__.'() // Skip: A required constant (SMART_FRAMEWORK_CHMOD_DIRS) has not been defined ...');\n\t\t\treturn 0;\n\t\t} //end if\n\t\t//--\n\t\tif((string)$dir_name == '') {\n\t\t\tself::log_warning(__METHOD__.'() // Create Dir [R='.(int)$recursive.'/S='.(int)$allow_protected_paths.'] // The Dir Name is Empty !');\n\t\t\treturn 0;\n\t\t} //end if\n\t\t//--\n\t\tif($allow_protected_paths === true) {\n\t\t\tself::raise_error_if_unsafe_path($dir_name, 'yes', 'yes'); // deny absolute paths ; allow protected paths (starting with a `#`)\n\t\t\t$is_path_chk_safe = self::check_if_safe_path($dir_name, 'yes', 'yes'); // deny absolute paths ; allow protected paths (starting with a `#`)\n\t\t} else {\n\t\t\tself::raise_error_if_unsafe_path($dir_name);\n\t\t\t$is_path_chk_safe = self::check_if_safe_path($dir_name);\n\t\t} //end if else\n\t\t//--\n\t\tclearstatcache(true, $dir_name);\n\t\t//--\n\t\t$result = false;\n\t\t//--\n\t\tif($is_path_chk_safe) {\n\t\t\t//--\n\t\t\tif(!self::path_exists($dir_name)) {\n\t\t\t\t//--\n\t\t\t\tif($recursive === true) {\n\t\t\t\t\t$result = @mkdir($dir_name, SMART_FRAMEWORK_CHMOD_DIRS, true);\n\t\t\t\t\t$dir_elements = (array) explode('/', $dir_name);\n\t\t\t\t\t$tmp_crr_dir = '';\n\t\t\t\t\tfor($i=0; $i<count($dir_elements); $i++) { // fix: to chmod all dir segments (in PHP the mkdir chmod is applied only to the last dir segment if recursive mkdir ...)\n\t\t\t\t\t\t$dir_elements[$i] = (string) trim((string)$dir_elements[$i]);\n\t\t\t\t\t\tif((string)$dir_elements[$i] != '') {\n\t\t\t\t\t\t\t$tmp_crr_dir .= (string) self::add_dir_last_slash((string)$dir_elements[$i]);\n\t\t\t\t\t\t\tif((string)$tmp_crr_dir != '') {\n\t\t\t\t\t\t\t\tif(self::is_type_dir((string)$tmp_crr_dir)) {\n\t\t\t\t\t\t\t\t\tself::fix_dir_chmod((string)$tmp_crr_dir); // apply separate chmod to each segment\n\t\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t\t} //end if\n\t\t\t\t\t\t} //end if\n\t\t\t\t\t} //end for\n\t\t\t\t} else {\n\t\t\t\t\t$result = @mkdir($dir_name, SMART_FRAMEWORK_CHMOD_DIRS);\n\t\t\t\t\tif(self::is_type_dir($dir_name)) {\n\t\t\t\t\t\tself::fix_dir_chmod($dir_name); // apply chmod\n\t\t\t\t\t} //end if\n\t\t\t\t} //end if else\n\t\t\t\t//--\n\t\t\t} elseif(self::is_type_dir($dir_name)) {\n\t\t\t\t//--\n\t\t\t\t$result = true; // dir exists\n\t\t\t\t//--\n\t\t\t} else {\n\t\t\t\t//--\n\t\t\t\tself::log_warning(__METHOD__.'() // CreateDir [R='.(int)$recursive.'/S='.(int)$allow_protected_paths.'] // FAILED to create a directory because it appear to be a File: '.$dir_name);\n\t\t\t\t//--\n\t\t\t} //end if else\n\t\t\t//--\n\t\t\tif(!self::is_type_dir($dir_name)) {\n\t\t\t\tself::log_warning(__METHOD__.'() // CreateDir [R='.(int)$recursive.'/S='.(int)$allow_protected_paths.'] // FAILED to create a directory: '.$dir_name);\n\t\t\t\t$out = 0;\n\t\t\t} //end if\n\t\t\t//--\n\t\t\tif(!self::have_access_write($dir_name)) {\n\t\t\t\tself::log_warning(__METHOD__.'() // CreateDir [R='.(int)$recursive.'/S='.(int)$allow_protected_paths.'] // The directory is not writable: '.$dir_name);\n\t\t\t\t$out = 0;\n\t\t\t} //end if\n\t\t\t//--\n\t\t} else {\n\t\t\t//--\n\t\t\tself::log_warning(__METHOD__.'() // CreateDir [R='.(int)$recursive.'/S='.(int)$allow_protected_paths.'] // The directory path is not Safe: '.$dir_name);\n\t\t\t//--\n\t\t} //end if\n\t\t//--\n\t\tif($result == true) {\n\t\t\t$out = 1;\n\t\t} else {\n\t\t\t$out = 0;\n\t\t} //end if\n\t\t//--\n\t\treturn (int) $out;\n\t\t//--\n\t}", "private function _createNewDirectories(){\n \n // need to first create the **version** directory\n $topLevel = $this->_dir . $this->_version . '/';\n \n\n try{\n if(!is_dir($topLevel)){\n mkdir($topLevel); \n $this->_showOutput('Creating directory: ' . $topLevel);\n }\n }catch(Exception $e){\n $this->logError($e, '_createNewDirectories'); \n }\n \n\n // iterate through the directories array and create all folders\n if(!empty($this->_dirArray)){\n foreach($this->_dirArray as $folder){\n // create folder\n try{\n if(!is_dir($folder)){\n mkdir($folder, $this->_folderPermissions);\n $this->_showOutput('Creating directory: ' . $folder);\n }\n \n }catch(Exception $e){\n $this->logError($e, '_createNewDirectories'); \n }\n \n }\n }\n \n }", "public function setDirName($newName){\n\t\t$this->directory_name = __DIR__ . $newName;\n\t}", "public function makeDirectory()\n {\n if (!file_exists(config('library.scanner.folder')))\n mkdir(config('library.scanner.folder'), 0755, true);\n }", "function make_new_dir() {\n\t$dir = return_directory_name( 7 );\n\t\n\tif ( !is_dir( $dir ) ) {\n\t\tmkdir( $dir, 0777, true );\n\t\treturn $dir;\n\t} else {\n\t\tmake_new_dir();\n\t}\n}", "protected function createFolders()\n {\n foreach ($this->getFolderStructure() as $folder) {\n $new_folder = $this->twig_string_renderer->renderToString($folder, $this->data);\n $this->fs->mkdir($this->target_path . DIRECTORY_SEPARATOR . $new_folder, self::DIRECTORY_MODE);\n\n $msg = '[mkdir] ' . $this->target_path . DIRECTORY_SEPARATOR . $new_folder;\n if ($this->reporting_enabled) {\n $this->report[] =$msg;\n }\n }\n }", "function ecoder_mkdir ( $path, $mode, $way = '' ) {\n\tumask(0);\n\t$exp = explode( \"/\", $path );\n\tforeach( $exp as $n ) {\n\t\t$way .= $n.'/';\n\t\tif( !file_exists( $way ) ) mkdir( $way, octdec($mode) );\n\t}\n ecoder_echo ( '', '', 'directory '.$path.' created | permissions:'. $mode.'' );\n}", "public function makeDir( $path, $recursive = true ) {\n\t}", "public function newDirectory()\n {\n\n $target_full_path = $this->getTargetFile()->getFilepath(true);\n $this->event(YouweFileManagerEvents::BEFORE_FILE_DIR_CREATED);\n $this->getDriver()->makeDir($target_full_path);\n $this->getCurrentFile()->updateFilepath($target_full_path);\n $this->event(YouweFileManagerEvents::AFTER_FILE_DIR_CREATED);\n }", "public function testMkdirs()\n {\n $root = vfsStream::setup('root');\n\n mkdirs(implode(DIRECTORY_SEPARATOR, [vfsStream::url('root'), 'test']));\n $this->assertTrue($root->hasChild('test'));\n\n mkdirs(implode(DIRECTORY_SEPARATOR, [vfsStream::url('root'), 'test', 'inner']));\n $this->assertTrue($root->hasChild(implode(DIRECTORY_SEPARATOR, ['test', 'inner'])));\n }", "function file_make_dir($dirpath, $mode=0777) {\n return is_dir($dirpath) || mkdir($dirpath, $mode, true);\n}", "protected function ensureDirectoriesExist()\n {\n if (!is_dir($directory = 'resources/js/components/' . Str::kebab($this->argument('name')))) {\n mkdir($directory, 0755, true);\n }\n\n if (!is_dir($directory = 'resources/js/components/' . Str::kebab($this->argument('name')) . '/components/')) {\n mkdir($directory, 0755, true);\n }\n\n if (!is_dir($directory = 'resources/js/components/' . Str::kebab($this->argument('name')) . '/store/')) {\n mkdir($directory, 0755, true);\n }\n }", "public function testDirectory()\n {\n $directorName = 'pydio-test';\n $this->directoryService->createDirectory($this->namespace, $directorName);\n $content = $this->directoryService->ls($this->namespace);\n $listing = $content['tree'];\n // there must be only the bin and the folder\n $this->assertCount(2, $listing);\n // the created folder is the first element of the list\n $this->assertEquals('/'.$directorName, $listing[0]['@attributes']['filename']);\n $this->directoryService->removeDirectory($this->namespace, $directorName);\n\n $content = $this->directoryService->ls($this->namespace);\n $listing = $content['tree'];\n // there must be only the bin\n $this->assertCount(1, $listing);\n }", "function autodir(string $path): string {\n if (!file_exists($path)) {\n mkdir($path);\n }\n return $path;\n}", "function createDirectory($name)\n {\n OssClient::getClient()->createObjectDir(OssClient::$bucket, $name);\n }" ]
[ "0.6137983", "0.5943504", "0.5609457", "0.55803967", "0.55600256", "0.553843", "0.55241835", "0.54231274", "0.54218554", "0.53969675", "0.539186", "0.53670686", "0.53631663", "0.5360914", "0.53600883", "0.5315125", "0.5304955", "0.52981955", "0.5296313", "0.528366", "0.52667403", "0.5263542", "0.52447516", "0.5231054", "0.52088505", "0.5201114", "0.5201008", "0.52003163", "0.5195605", "0.519323" ]
0.68937886
0
Add a pingback url autodiscovery header for single posts, pages, or attachments.
function dotdev_pingback_header() { if ( is_singular() && pings_open() ) { printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) ); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function add_pingback_url_header(): void {\n\t\tif ( is_singular() && pings_open() ) {\n\t\t\techo '<link rel=\"pingback\" href=\"', esc_url( get_bloginfo( 'pingback_url' ) ), '\">';\n\t\t}\n\t}", "function thesaas_pingback_header() {\n\tif ( is_singular() && pings_open() ) {\n\t\tprintf( '<link rel=\"pingback\" href=\"%s\">' . \"\\n\", esc_url( get_bloginfo( 'pingback_url' ) ) );\n\t}\n}", "function pingback_header()\r\n{\r\n if (is_singular() && pings_open()) {\r\n printf(\r\n '<link rel=\"pingback\" href=\"%s\">',\r\n esc_url(get_bloginfo('pingback_url'))\r\n );\r\n }\r\n}", "function blogar_pingback_header()\r\n{\r\n if (is_singular() && pings_open()) {\r\n printf( '<link rel=\"pingback\" href=\"%s\">', esc_url( get_bloginfo( 'pingback_url' ) ) );\r\n }\r\n}", "function ezayo_pingback_header() {\n\n\tif ( is_singular() && pings_open() ) {\n\n\t\techo '<link rel=\"pingback\" href=\"', esc_url( get_bloginfo( 'pingback_url' ) ), '\">';\n\n\t}\n\n}", "function twentyseventeen_pingback_header()\n{\n\tif (is_singular() && pings_open()) {\n\t\tprintf('<link rel=\"pingback\" href=\"%s\">' . \"\\n\", esc_url(get_bloginfo('pingback_url')));\n\t}\n}", "function studioscienceboilerplate_pingback_header() {\n\tif ( is_singular() && pings_open() ) {\n\t\techo '<link rel=\"pingback\" href=\"', esc_url( get_bloginfo( 'pingback_url' ) ), '\">';\n\t}\n}", "function blog_way_pingback_header() {\n\n\tif ( is_singular() && pings_open() ) {\n\n\t\techo '<link rel=\"pingback\" href=\"', bloginfo( 'pingback_url' ), '\">';\n\n\t}\n\t\n}", "function brettwysocki_pingback_header() {\n\tif ( is_singular() && pings_open() ) {\n\t\tprintf( '<link rel=\"pingback\" href=\"%s\">' . \"\\n\", get_bloginfo( 'pingback_url' ) );\n\t}\n}", "function xsl_pingback_header() {\r\r\n if ( is_singular() && pings_open() ) {\r\r\n printf( '<link rel=\"pingback\" href=\"%s\">', esc_url( get_bloginfo( 'pingback_url' ) ) );\r\r\n }\r\r\n}", "function ftheme_pingback_header() {\n if ( is_singular() && pings_open() ) {\n echo '<link rel=\"pingback\" href=\"', bloginfo( 'pingback_url' ), '\">';\n }\n}", "function snazzy_pingback_header() {\n\t\tif ( is_singular() && pings_open() ) {\n\t\t\techo '<link rel=\"pingback\" href=\"', bloginfo( 'pingback_url' ), '\">';\n\t\t}\n\t}", "function gidd_show_pingback_url() {\n\t$pingback = '<link rel=\"pingback\" href=\"'. get_bloginfo( 'pingback_url' ) .'\" />';\n\treturn apply_filters( 'gidd_show_pingback_url', $pingback );\n}", "function harmonica_link_pingback() {\n\tif ( 'open' === get_option( 'default_ping_status' ) )\n\t\techo '<link rel=\"pingback\" href=\"' . get_bloginfo( 'pingback_url' ) . '\" />' . \"\\n\";\n}", "function wp_ozh_yourls_add_head_link() {\r\n\tglobal $wp_ozh_yourls;\r\n\tif(\r\n\t\t( is_single() && $wp_ozh_yourls['link_on_post'] ) ||\r\n\t\t( is_page() && $wp_ozh_yourls['link_on_page'] )\r\n\t) {\r\n\t\twp_ozh_yourls_head_linkrel();\r\n\t}\r\n}", "public function addCookielessDnsPrefetch()\n {\n echo '<link rel=\"dns-prefetch\" href=\"https://' . $this->settings['cookieless_domain'] . '\" />' . PHP_EOL;\n }", "function pshb_template_redirect() {\n\t// get all feeds\n\t$feed_urls = pshb_get_feed_urls();\n\t$comment_feed_urls = pshb_get_comment_feed_urls();\n\n\t// get current url\n\t$urls = array_unique( array_merge( $feed_urls, $comment_feed_urls ) );\n\t$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];\n\n\t// check if current url is one of the feed urls\n\tif ( in_array( $current_url, $urls ) ) {\n\t\t$hub_urls = pshb_get_pubsub_endpoints();\n\t\t// add all \"hub\" headers\n\t\tforeach ( $hub_urls as $hub_url ) {\n\t\t\theader( 'Link: <'.$hub_url.'>; rel=\"hub\"', false );\n\t\t}\n\t\t// add the \"self\" header\n\t\theader( 'Link: <'.$current_url.'>; rel=\"self\"', false );\n\t}\n}", "function wpe_ac_add_cache_header() {\n\tif ( ! is_singular() ) {\n\t\treturn;\n\t}\n\t$post_id = get_the_ID();\n\t$post_type = get_post_type( $post_id );\n\t$last_modified = get_the_modified_date( 'U' );\n\tWPEAC_Core::send_header_cache_control_length( $last_modified, $post_id, $post_type );\n\tWPEAC_Core::send_header_last_modified( $last_modified, $post_id, $post_type );\n}", "function ueb_add_head_link() {\n\tif( is_single() || is_page() ) {\n\t\tglobal $post;\n\t\tswitch ( $post->post_type ) {\n\t\t\tcase 'attachment':\n\t\t\t\treturn;\n\t\t\tcase 'page':\n\t\t\t\tif( ! current_user_can( 'edit_page', $post->ID ) ) return;\n\t\t\t\tbreak;\n\t\t\tcase 'post':\n\t\t\tdefault:\n\t\t\t\tif ( ! current_user_can( 'edit_post', $post->ID ) ) return;\n\t\t\t\tbreak;\n\t\t}\n\n\t\techo '<link rel=\"alternate\" type=\"application/x-wiki\" title=\"Edit this page\" href=\"' . get_edit_post_link($post->ID) . \"\\\" />\\n\";\n\t}\n}", "function thedailysheeple_posted_on($single = false) {\n if ( is_sticky() && is_home() && ! is_paged() ) {\n echo '<span class=\"featured-post\">' . __( 'Sticky', 'thedailysheeple' ) . '</span>';\n }\n\n $post = get_post(get_the_ID());\n $is_redirect = !empty(get_post_meta($post->ID, '_redirect_posts_redirect_url', true));\n\n if ($single) {\n // Set up and print post meta information.\n $website = thedailysheeple_get_authorwebsite($post);\n printf( '<span class=\"entry-date\"><a href=\"%1$s\" rel=\"bookmark\"><time class=\"entry-date\" datetime=\"%2$s\">%3$s</time></a></span> | <span class=\"byline\"><span class=\"author vcard\">%4$s</span></span> | <span class=\"byline\"><span class=\"author-website\"><a href=\"%5$s\">%6$s</a></span>',\n esc_url( get_permalink() ),\n esc_attr( get_the_date( 'c' ) ),\n esc_html( get_the_date('F j, Y') ),\n thedailysheeple_get_authorname($post),\n $website['url'],\n $website['name']\n );\n\n if (function_exists('the_views') && !$is_redirect) {\n echo ' | <span class=\"post-views\">';\n the_views();\n echo '</span>';\n }\n } else {\n // Set up and print post meta information.\n printf( '<span class=\"entry-date\"><time class=\"entry-date\" datetime=\"%1$s\">%2$s</time></span> | <span class=\"byline\"><span class=\"author vcard\">%3$s</span></span>',\n esc_attr( get_the_date( 'c' ) ),\n esc_html( get_the_date('F j, g:ia') ),\n thedailysheeple_get_authorname($post)\n );\n\n if (function_exists('the_views') && !$is_redirect) {\n echo ' | <span class=\"post-views\">';\n the_views();\n echo '</span>';\n }\n }\n}", "function change_canonical_header() {\n\t\t$cdn_engine = $this->_config->get_string( 'cdn.engine' );\n\n\t\tif ( $cdn_engine == 'maxcdn' ) {\n\t\t\trequire_once W3TC_LIB_NETDNA_DIR . '/NetDNA.php';\n\t\t\t$authorization_key = $this->_config->get_string( \"cdn.$cdn_engine.authorization_key\" );\n\t\t\tif ( $authorization_key ) {\n\t\t\t\t$keys = explode( '+', $authorization_key );\n\t\t\t\tif ( sizeof( $keys ) == 3 ) {\n\t\t\t\t\tlist( $alias, $consumer_key, $consumer_secret ) = $keys;\n\t\t\t\t\t$api = new \\NetDNA( $alias, $consumer_key, $consumer_secret );\n\t\t\t\t\t$zone = array();\n\t\t\t\t\t$zone_id = $this->_config->get_string( \"cdn.$cdn_engine.zone_id\" );\n\t\t\t\t\t$zone['canonical_link_headers'] = $this->_config->get_boolean( 'cdn.canonical_header' ) ? 1 : 0;\n\t\t\t\t\ttry {\n\t\t\t\t\t\t$api->update_pull_zone( $zone_id, $zone );\n\t\t\t\t\t} catch ( \\Exception $ex ) {}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}", "function ad_export_add_endpoint() {\n $triggering_endpoint = '^ad_export/?(.*)?/?';\n add_rewrite_rule($triggering_endpoint,'index.php?__ad_export=1&ad_export_options=$matches[1]','top');\n}", "function trackback($trackback_url, $author, $ttl, $excerpt, $link) {\r\n\t\t\t\t$options = array ();\r\n\t\t\t\t$options ['timeout'] = 4;\r\n\t\t\t\t$options ['body'] = array (\r\n\t\t\t\t\t\t'title' => $ttl,\r\n\t\t\t\t\t\t'url' => $link,\r\n\t\t\t\t\t\t'blog_name' => $author,\r\n\t\t\t\t\t\t'excerpt' => $excerpt \r\n\t\t\t\t);\r\n\t\t\t\t\r\n\t\t\t\t$response = wp_remote_post ( $trackback_url, $options );\r\n\t\t\t\t\r\n\t\t\t\tif (is_wp_error ( $response )) {\r\n\t\t\t\t\techo '<br>Trackback Error';\r\n\t\t\t\t\treturn;\r\n\t\t\t\t} else {\r\n\t\t\t\t\techo '<br>No Track back error';\r\n\t\t\t\t}\r\n\t\t\t}", "function bstone_single_post_page_header() {\r\n\t\t\r\n\t\tget_template_part( 'template-parts/single-header' );\r\n\r\n\t}", "function rad_wp_network_tags() {\n if ( 'open' == get_option( 'default_ping_status' ) ) {\n echo '<link rel=\"pingback\" href=\"' . get_bloginfo( 'pingback_url' ) . '\" />';\n }\n}", "function sb_ping_gallery() {\n\tglobal $wpdb;\n\tif((ini_get('allow_url_fopen') | function_exists('curl_init')) & get_option('blog_public') == 1 & get_option('ping_sites') != \"\") {\n\t\t$url = \"http://ping.preachingcentral.com/?sg_ping\";\n\t\t$url .= \"&name=\".rawurlencode(get_option('blogname'));\n\t\t$url .= \"&tagline=\".rawurlencode(get_option('blogdescription'));\n\t\t$url .= \"&site_url=\".rawurlencode(site_url());\n\t\t$url .= \"&sermon_url=\".rawurlencode(sb_display_url());\n\t\t$url .= \"&most_recent=\".rawurlencode($wpdb->get_var(\"SELECT datetime FROM {$wpdb->prefix}sb_sermons ORDER BY datetime DESC LIMIT 1\"));\n\t\t$url .= \"&num_sermons=\".rawurlencode($wpdb->get_var(\"SELECT COUNT(*) FROM {$wpdb->prefix}sb_sermons\"));\n\t\t$url .= \"&ver=\".constant(\"SB_CURRENT_VERSION\");\n\t\t if (ini_get('allow_url_fopen')) {\n\t\t\t$headers = @get_headers($url, 1);\n\t\t\tif ($headers !=\"\") {\n\t\t\t\t$headers = array_change_key_case($headers,CASE_LOWER);\n\t\t\t}\n\t\t} else {\n\t\t\t$curl = curl_init();\n\t\t\tcurl_setopt ($curl, CURLOPT_URL, $url);\n\t\t\tcurl_setopt ($curl, CURLOPT_HEADER, 1);\n\t\t\tcurl_setopt ($curl, CURLOPT_NOBODY, 1);\n\t\t\tcurl_setopt ($curl, CURLOPT_TIMEOUT, 2);\n\t\t\tcurl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);\n\t\t\tcurl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1);\n\t\t\tcurl_setopt ($curl, CURLOPT_MAXREDIRS, 10);\n\t\t\t$execute = curl_exec ($curl);\n\t\t\t$info = curl_getinfo ($curl);\n\t\t\tcurl_close ($curl);\n\t\t}\n\t}\n}", "public function outputHookUp() {\n\t\t// Output the primary header markup, but allow others to short-circuit this\n\t\tif ( true === apply_filters( 'pixelgrade_header_auto_output_header', true ) ) {\n\t\t\tadd_action( 'pixelgrade_header', 'pixelgrade_the_header', 10, 1 );\n\t\t}\n\t}", "public function the_header(){\n\t\t$slug = the_slug();\n\t\t$header = $this->the_header;\n\n\t\tif ( is_url($header) || empty($header) )\n\t\t\treturn $header;\n\n\t\treturn get_image_link( \"/blog/$slug/$header\", \"default\" );\n\t}", "private function addHostHeaderIfNecessary(): void\n {\n $requiresHostHeader = match ($this->requestTargetType) {\n RequestTargetType::OriginForm, RequestTargetType::AsteriskForm, RequestTargetType::AbsoluteForm => true,\n default => false\n };\n\n if ($requiresHostHeader && !$this->headers->containsKey('Host')) {\n $this->headers->add('Host', $this->uri->getAuthority(false) ?? '');\n }\n }", "function storefront_post_header() {\n ?>\n <header class=\"entry-header\">\n <?php\n if (is_single()) {\n storefront_posted_on();\n the_title('<h1 class=\"entry-title\">', '</h1>');\n } else {\n if ('post' == get_post_type()) {\n storefront_posted_on();\n }\n\n the_title(sprintf('<h1 class=\"entry-title\"><a href=\"%s\" rel=\"bookmark\">', esc_url(get_permalink())), '</a></h1>');\n }\n ?>\n </header><!-- .entry-header -->\n <?php\n }" ]
[ "0.76780134", "0.7397902", "0.7394309", "0.73561394", "0.7355556", "0.7255944", "0.7231584", "0.72192216", "0.7177282", "0.7165156", "0.7096415", "0.70775414", "0.5923317", "0.5828149", "0.5581748", "0.5234673", "0.51712775", "0.5162204", "0.515619", "0.51409423", "0.51025593", "0.5071174", "0.50686145", "0.5036631", "0.50336486", "0.49919707", "0.49826235", "0.49081153", "0.49007812", "0.48935807" ]
0.74068445
1
cadastrar aluno no banco de dados
function cadastrar($conexao, $nomeTabela) { // criar a consulta de inserção dos dados na tabela do bd // '' -> texto / varchar $query = "INSERT $nomeTabela VALUES ( '$this->matricula', '$this->uc', $this->nota1, $this->nota2 )"; $enviado = $conexao->query($query) or die($conexao->error); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function cadastrar(){\n $this->variaveis();\n parent::cadastroCliente($this->nome,$this->sexo,$this->cidade);\n echo 'Cadastro Efetuado com Sucesso!';\n\n }", "public function motivo(){\r\n\t\tparent::conectaBDMy();\t \r\n\t\t$this->idMotivo=\"\";\t\t\r\n\t\t$this->nom=\"\";\t\t\r\n\t}", "function cuentas_busca()\n\t{\n\t\tif(!isset($_REQUEST['tipo']))\n\t\t\t$_REQUEST['tipo'] = 1;\n\n\t\tif(!isset($_REQUEST['cp']))\n\t\t\t$_REQUEST['cp'] = 0;\n\n\t\t$lista = $this->AlmacenModel->cuentas($_REQUEST['cp'],$_REQUEST['tipo']);\n\t\t$tabla = \"\";\n\t\twhile($l = $lista->fetch_assoc())\n\t\t{\n\t\t\t$manual_code = $description = \"Ninguna\";\n\t\t\tif($l['manual_code'] != '')\n\t\t\t{\n\t\t\t\t$manual_code = $l['manual_code'];\n\t\t\t\t$description = $l['description'];\n\t\t\t}\n\t\t\tif($l['idcuenta'] == '')\n\t\t\t\t$l['idcuenta'] = 0;\n\t\t\t$tabla .= \"<tr>\n\t\t\t\t\t\t<td>\".$l['nombre'].\"</td>\n\t\t\t\t\t\t<td>($manual_code) $description</td>\n\t\t\t\t\t\t<td><button class='btn btn-default' onclick='editar(\".$_REQUEST['tipo'].\",\".$_REQUEST['cp'].\",\".$l['id'].\",\".$l['idcuenta'].\")'>Editar</button></td>\n\t\t\t\t\t </tr>\";\n\t\t}\n\t\techo $tabla;\n\t}", "public function dar_baja() {\n $objDatos = new clsDatos();\n $sql = \"UPDATE asigna_caso SET(est_aca='I')\";\n $objDatos->ejecutar($sql);\n $objDatos->crerrarconexion();\n }", "public function financas_inserir(){\r\n \r\n //data_hora_brasil_eua()\r\n $valor = \\anti_injection($_POST[\"valor\"]);\r\n $user = (int) $_POST[\"user\"];\r\n $obs = \\anti_injection($_POST[\"obs\"]);\r\n $sucesso = $this->_Modelo->MovExt_Inserir($user,$valor,$obs,1);\r\n $this->Main();\r\n if($sucesso===true){\r\n $mensagens = array(\r\n \"tipo\" => 'sucesso',\r\n \"mgs_principal\" => __('Depositado com Sucesso'),\r\n \"mgs_secundaria\" => 'Valor: '.$valor\r\n );\r\n $this->_Visual->Json_Info_Update('Titulo', __('Depositado com Sucesso'));\r\n }else{\r\n $mensagens = array(\r\n \"tipo\" => 'erro',\r\n \"mgs_principal\" => __('Erro'),\r\n \"mgs_secundaria\" => __('Erro')\r\n );\r\n $this->_Visual->Json_Info_Update('Titulo', __('Erro ao Depositar'));\r\n }\r\n $this->_Visual->Json_IncluiTipo('Mensagens',$mensagens); \r\n // ORGANIZA E MANDA CONTEUDO\r\n $this->_Visual->Json_Info_Update('Historico',0); \r\n }", "function OperacionConexion()\n {\n echo \"<h1>Paises del mundo</h1>\";\n $resultado = $this->conector->query(\"select country.Name,country.IndepYear from country\");\n echo \"El numero de paises es: \".$resultado->num_rows.\"<br><br>\";\n\n foreach ($resultado as $fila)\n {\n if ($fila['IndepYear']==null)\n $fila['IndepYear']=\"NO INDEPENDIZADO\";\n ?>\n <div class=\"row\">\n <div class=\"column left\">\n <?=$fila[\"Name\"] ?>\n </div>\n <div class=\"column right\">\n <?=$fila[\"IndepYear\"] ?>\n </div>\n </div>\n <?php\n }\n }", "public function cadastrarMotorista ()\n {\n /*\n Controller faz a solicitação para a model enviar os dados do banco,\n mostrar dados recebidos ou a menssagem de erro vinda da model.\n */\n try {\n\n /*\n twig é uma api que permite mostrar conteudos na view sem a necessidade de escrever\n codigo php no html da view, assim o codigo não fica misturado.\n sintaxe:\n naview: {{conteudo}}\n na controller: array[conteudo] = nome\n\n o valores na view dentro de {{}} sao substituidos pela valor da chave no array\n\n */\n $loader = new \\Twig\\Loader\\FilesystemLoader('app/view');\n $twig = new \\Twig\\Environment($loader);\n $template = $twig->load('cadastrarMotorista.html');\n\n //array com chaver parametros para substituir na view\n $parametros = array();\n $conteudo = $template->render($parametros);\n\n echo $conteudo;\n\n } catch (PDOException $e) {\n echo $e->getMessage();\n }\n\n \n }", "public function verDados(){\n echo $this->nome.\"<br>\";\n echo $this->idade.\"<br>\";\n echo $this->senha.\"<br>\";\n }", "function prosesTambah()\n {\n\n $this->M_donasi->processInsertDonasi();\n }", "public function altaAction()\n\t{\n\t\t//$rows = $this->_services_simple_crud->getAll($this->_solicitud->getModel());\n\t\t//$this->view->rows = $rows;\n\t}", "public function cadastrar(){\n //INSERIR USUARIO NO BANCO\n $obDatabase = new Database('usuario_comum');\n $this->userC_matricula = $obDatabase->insert([\n 'userC_matricula' => $this->userC_matricula,\n 'userC_nome' => $this->userC_nome,\n 'userC_email' => $this->userC_email,\n 'userC_idUser' => $this->userC_idUser,\n ]);\n\n //RETORNA SUCESSO\n return true;\n }", "function lerUm()\n {\n // selecionar consultar todos\n $query = \"SELECT\n c.nome as categoria_nome, p.id, p.nome, p.descricao, p.preco, p.categoria_id, p.criado\n FROM\n \" . $this->tabela_nome . \" p\n LEFT JOIN\n categorias c\n ON p.categoria_id = c.id\n WHERE\n p.id = ?\n LIMIT\n 0,1\";\n\n //preparar declaração de consulta\n $stmt = $this->conn->prepare($query);\n\n // ID de ligação do produto a ser atualizado\n $stmt->bindParam(1, $this->id);\n\n // executar consulta\n $stmt->execute();\n\n // obter linha recuperada\n $row = $stmt->fetch(PDO::FETCH_ASSOC);\n\n // definir valores para propriedades do objeto\n $this->nome= $row['nome'];\n $this->preco= $row['preco'];\n $this->descricao= $row['descricao'];\n $this->categoria_id= $row['categoria_id'];\n $this->categoria_nome = $row['categoria_nome'];\n \n }", "function mostrar_crucero(){\n\t\tif (isset($_GET['id']) && $_GET['id']!=\"\"){\n\t\t\t$id=$_GET['id'];\n\t\t\t$sql=\"SELECT * FROM crucero WHERE id_cru='$id'\";\n\t\t\t$consulta=mysql_query($sql) or die(mysql_error());\n\t\t\t$resultado = mysql_fetch_array($consulta);\n\t\t\tsetlocale(LC_ALL, 'es_ES');\n\t\t\t//$this->nombre=ucwords(strtolower($resultado['nombre_pro']));\n\t\t\t\n\t\t\t$this->suiche=false;\n\t\t\t$this->ruta=\"\"; $this->categoria=\"\";\n\t\t\t$this->buscar_ruta_nodo($resultado['categoria_cru']);\n\t\t\tfor($i=count($this->ruta)-1;$i>=0;$i--){\n\t\t\t\t$this->categoria.=\" &raquo; \".$this->ruta[$i]['nombre_cat'];\n\t\t\t}\n\t\t\t\n\t\t\t$this->id=$id;\n\t\t\t$this->nombre=$resultado['nombre_cru'];\n\t\t\t$this->codigo=$resultado['codigo_cru'];\n\t\t\t$this->id_cat=$resultado['categoria_cru'];\n\t\t\t$this->prioridad=$resultado['prioridad_cru'];\n\t\t\t$this->vistas=$resultado['vistas_cru'];\n\t\t\t$this->fecha=$resultado['fecha_cru'];\n\t\t\t$this->descripcion=$resultado['descripcion_cru'];\n\t\t\t$this->condiciones=$resultado['condiciones_cru'];\n\t\t\t$this->claves=$resultado['claves_cru'];\n\t\t\t$this->disponible=$resultado['disponible_cru'];\n\t\t\n\t\t} \n\t}", "public function dar_baja() {\n $objDatos = new clsDatos();\n $sql = \"DELETE FROM trabajo_campo WHERE (id_tca='$this->id_tca')\";\n $objDatos->ejecutar($sql);\n $objDatos->crerrarconexion();\n }", "public function BuscarCorCabelo(){\n require_once('model/filiado_class.php');\n $class = new Acompanhante();\n $rs = $class->SelectCorCabelo();\n \n return $rs;\n \n }", "function cadastrar()\n {\n $codigo = $_REQUEST['codigo_veiculo'];\n $nomeveiculo = $_REQUEST['nomeveiculo'];\n $anoinicial = $_REQUEST['anoinicial'];\n $anofinal = $_REQUEST['anofinal'];\n $idmontadora = $_REQUEST['idmontadora'];\n $modelo = $_REQUEST['modeloveiculo'];\n\n $veiculo = new Veiculo();\n\n $veiculo->setCodigo($codigo);\n $veiculo->setNome($nomeveiculo);\n $veiculo->setAnoinicial($anoinicial);\n $veiculo->setAnofinal($anofinal);\n $veiculo->setCodigo_montadora($idmontadora);\n $veiculo->setModelo($modelo);\n\n $retorno = $veiculo->inserir($veiculo);\n\n if ($retorno == 1) {\n header('Location:../view/Veiculos/cadastrar/?r=1');\n } else {\n header('Location:../view/Veiculos/cadastrar/?r=0');\n }\n }", "public function mostrar($id){\n\t$sql=\"SELECT * FROM cuenta_cliente WHERE id='$id'\";\n\treturn ejecutarConsultaSimpleFila($sql);\n}", "function Cadastrar($id=\"\"){\r\n\t\t\r\n\t\t$funcao=(empty($id))?\"Insert into\":\"Update\";\r\n\t\t$where=(empty($id))?\" \":\" where id = $id\";\r\n\t\t$dados=$_POST;\r\n\t\t\r\n $campos=\"\";\t\t\r\n\t\tforeach ($dados as $campo=>$valor){\r\n\t\t\t$campos.=$campo.\"='$valor', \";\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\t$campos=strip_tags($campos);\r\n\t\t$campos=substr($campos,0,-2);\r\n\t\t\r\n\t\t//teste:\r\n\t\t//echo \"$funcao $this->tabela SET $campos $where\";\r\n\t\t//die();\r\n\t\t\r\n\t\t$this->conexaoDB->ExecutaQuery(\"$funcao $this->tabela SET $campos $where\");\r\n\t\theader(\"Location:main.php\");\r\n\t\t\r\n\t\t\r\n\t}", "protected function _acaoPadrao() {\n $combobox = new Modelo\\ComboBoxDescritores();\n $codigo = $combobox->montarDescritorPrimeiroNivel();\n echo $codigo;\n }", "public function consultarjuego(){\n $id = $_POST['id'];\n $juegos = $this->tiendaModel->consultarjuego($id);\n echo $juegos;\n }", "public function obtenerClientesActivos(){\r\n try{\r\n $consulta = ' SELECT * '.\r\n ' FROM cliente '.\r\n ' WHERE activo = 1 ';\r\n\r\n }\r\n catch(Exception $e ) {\r\n\t\t\t $this->error = 1;\r\n throw $e;\r\n }\r\n }", "public function Insertar(){\n $_id =$this->_id;\n $_nombre=$this->_nombre;\n $_apellido = $this->_apellido;\n $_ciudad = $this->_ciudad;\n $_direccion = $this->_direccion;\n $_correo = $this->_correo;\n $_telefono = $this->_telefono;\n $_fechanac = $this->_fechanac;\n $_usuario = $this->_usuario;\n $conexion = new Conexion();\n $conexion->EstablecerConexion()->query(\"INSERT INTO cliente(idCl, nombreCl, apellidoCl, ciudadCl, direccionCl, correoCl, telefonoCl, fechanacCl, user) \n VALUES('$_id','$_nombre','$_apellido','$_ciudad','$_direccion','$_correo','$_telefono','$_fechanac','$_usuario')\");\n echo \"<CENTER>Se registro correctamente</CENTER>\";\n }", "public function cadastrar(){\n\t\t\n\t\t$dados = elements(array('nome', 'email', 'mensagem'), $this->input->post());\n\t\t$this->Mensagem->do_insert($dados);\n\t\t\n\t\tredirect(base_url().\"Contato\");\n\t}", "public function Buscar(){\n // $usuario = new Usuario(null, null, $email, null, null, null, null); \n // $find = $this->daoUsuario->buscarPorId($usuario); \n // if($find){\n // echo(\"ok\");\n // }else{\n // echo(\"error\");\n // }\n }", "public function AgregarCocheraBD()\r\n {\r\n $id = 0;\r\n $objetoAccesoDato = AccesoDatos::DameUnObjetoAcceso();\r\n\r\n $consulta =$objetoAccesoDato->RetornarConsulta(\"INSERT INTO cocheras (numero, piso, sector, discapacitado)\" \r\n . \"VALUES(:numero, :piso, :sector, :discapacitado)\");\r\n\r\n $consulta->bindValue(':numero', $this->_numero, PDO::PARAM_INT);\r\n $consulta->bindValue(':piso', $this->_piso, PDO::PARAM_INT);\r\n $consulta->bindValue(':sector', $this->_sector, PDO::PARAM_STR);\r\n $consulta->bindValue(':discapacitado', $this->_discapacitado, PDO::PARAM_STR);\r\n $consulta->execute();\r\n $id = $objetoAccesoDato->ObtenerUltimoId();\r\n\r\n return $id;\r\n }", "public function buscarUsuario($nome){\n $db = parent::criarConexao();\n $query = $db->prepare(\"SELECT * FROM usuarios WHERE nome = ?\");\n $query->execute([$nome]);\n // var_dump ($query);\n // exit;\n\n $usuarioObjeto = $query->fetchAll(PDO::FETCH_OBJ);\n // var_dump($usuarioObjeto);\n // exit;\n return $usuarioObjeto[0];\n }", "private static function conectarBanco() {\n try {\n if (self::$conexao == null):\n $dsn = 'mysql:host=' . self::$host . ';dbname=' . self::$banco;\n $options = [ PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'];\n self::$conexao = new PDO($dsn, self::$usuario, self::$senha, $options);\n endif;\n } catch (PDOException $e) {\n echo $e->getCode().'<br>' .$e->getMessage(). '<br>' .$e->getFile(). '<br>' .$e->getLine();\n die;\n }\n\n self::$conexao->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n return self::$conexao;\n }", "function mostrar_administrativo(){\n require_once('../Config/c_conexion.php');\n $link=Conectarse();\n $consulta= \"SELECT * FROM administrativo ORDER BY Cargo\";\n $result= mysql_query($consulta,$link) or die(\"Problemas en la instrucción select:\".mysql_error());\n return $result; \n mysql_close($conexion);\n }", "function busca_fuente($cod)\n{\ntry{\n\t$result=mysql_query(\"select id from bd_materiasprimas.tbl_fuente where id_codigo='\".$cod.\"'\")or throw_ex(mysql_error());\n\t$row=mysql_fetch_object($result);\n\treturn $row->id;\n}\n\tcatch(Exception $e)\n{\n\techo \"Error:\". $e;\n}\n\t\n}", "public function cadastro(){\n // Estou usando o '$results' ao inves de usar a '$query->rowCount > 0', pois da na mesma, e caso eu precise no '$results'\n // eu ja tenho tambem os dados para manipular.\n // Se o $results retornou alguma coisa, entao o email ja existe no banco de dados, e eu nao deixo cadastrar de novo\n if(!empty($this->results)){ \n $this->validacao = false; \n echo \"<h3>\";\n echo \"<font color=red>\";\n echo \"Usuário já cadastrado! Efetue Login para acessar o site!\";\n echo \"</font>\";\n echo \"<br>\";\n echo \"<a href='index.php'>Voltar para pagina inicial</a>\";\n }\n else{ // Caso nao exista o email, eu crio uma nova sql e instancio um objeto de conexao com os dados para inserir.\n $this->validacao = true;\n $senha_hash = password_hash($this->senha, PASSWORD_DEFAULT);\n\n ///// Descomente a variavel abaixo para testar o codigo sem a senha criptografada. Fiz isso porque a verificacao\n ///// de login nao esta funcionando com a senha criptografada\n \n // $senha_hash = $this->senha;\n\n $inserir= \"INSERT INTO usuarios (nome, email, senha) VALUES ('$this->nome', '$this->email', '$senha_hash')\"; \n $conexao = new ConexaoDB(\"localhost\",\"bdteste\",\"root\",\"\",$inserir);\n $resultado = $conexao->conectar();\n } \n return $this->validacao;\n }" ]
[ "0.6841085", "0.6672253", "0.6581443", "0.6513797", "0.6456575", "0.6442487", "0.64067537", "0.6398538", "0.63297856", "0.6323891", "0.63005495", "0.62813693", "0.6275298", "0.6273252", "0.62650895", "0.6251515", "0.6244999", "0.62449276", "0.6237081", "0.62302613", "0.6229643", "0.6222626", "0.6221235", "0.62201124", "0.6210751", "0.619557", "0.61886615", "0.61850685", "0.6183532", "0.6181525" ]
0.7012378
0
Determine if the given user can update a profile.
public function update(User $user, $profile) { if($user->hasRole(['Admin', 'Superuser'])) { return true; } return $profile->id === $user->id; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function update(User $user, Profile $profile)\n {\n return $user->id == $profile->user_id;\n }", "public function update(User $user)\n {\n if ($user->can('update_user') || $user->can('manage_users')) {\n return true;\n }\n\n return false;\n }", "public function canUpdate(Model_User $user)\n\t{\n\t\treturn false;\n\t}", "public function canUpdateUser($request): bool\n {\n $userId = (int)$request->get_param('id');\n\n //Bypass security, by constant\n if (RESOURCE_BOOKING_DISABLE_SECURITY) {\n return true;\n }\n\n if (is_user_logged_in() && is_super_admin()) {\n return true;\n }\n\n if (is_user_logged_in() && self::$userId === $userId) {\n return true;\n }\n\n return false;\n }", "private static function is_profile_update( $entry ) {\n\t\t$user_id_field = FrmRegEntryHelper::get_user_id_field_for_form( $entry->form_id );\n\t\tself::$user_id_field = $user_id_field;\n\n\t\tif ( $user_id_field && isset( $entry->metas[ $user_id_field ] ) && $entry->metas[ $user_id_field ] ) {\n\t\t\t$is_profile_update = true;\n\t\t\tself::$entry_user_id = (int) $entry->metas[ $user_id_field ];\n\t\t} else {\n\t\t\t$is_profile_update = false;\n\t\t}\n\n\t\treturn $is_profile_update;\n\t}", "public function update(User $user)\n {\n return $user->can('update_education');\n }", "public function update(User $user)\n {\n if($user->can($this->common_permission.'update') || $user->can($this->common_permission.'update')) {\n return true;\n }\n return false;\n }", "public function editProfile(User $user, User $profile)\n {\n if (in_array($user->role, ['admin', 'staff'])) {\n return true;\n }\n\n return $user->id === $profile->id;\n }", "public function update(User $user)\n {\n return $user->can('update_pages');\n }", "public function update(User $user, Config $config)\n {\n return $user->id == 1 ? true : false;\n }", "function um_can_edit_my_profile() {\r\n\tif (!is_user_logged_in()) return false;\r\n\tif (!um_user( 'can_edit_profile' )) return false;\r\n\r\n\treturn true;\r\n}", "public function update(User $user, Account $account)\n {\n return $user->can('accounts.update');\n }", "public function updatePolicy(User $user)\n {\n return $user->may(static::PERMISSION_UPDATE);\n }", "public function update(User $user, Projeler $model)\n {\n return $user->hasPermissionTo('update projelers');\n }", "public function update(User $current, User $user)\n {\n if($user->isSuperAdmin()){//only super admin can delete other superadmin\n return $current->isSuperAdmin();\n }\n return $current->can('update_user');\n }", "public function allowsUpdatesByUser($user);", "public function update(User $userWithRequest, User $user): bool\n {\n $name = $this->getOwnerName($user);\n return $userWithRequest->hasPermissionTo(\"{$name}..user.update.{$user->id}\");\n }", "public function update(User $user, Member $member)\n {\n return $user->can(\"edit_members\");\n }", "public function update(User $user)\n {\n return $user->can('edit-asset');\n }", "public function update(User $user)\n {\n if($user->hasPermissionTo('edit_educational_tool')){\n return true;\n }\n return false;\n }", "public function update(User $user)\n {\n return $user->hasPermissionTo('pointing_edit');\n }", "public function update_profile($id = 0, $update_data) {\n $is_update = 0;\n if (!empty($id) && is_numeric($id)) {\n $is_update = $this->update($this->users_table, $update_data, array('user_id' => $id));\n }\n return $is_update;\n }", "public function update(User $user, User $model)\n {\n return $user->role->permissions->contains('key','update-users') ||\n $user->id == $model->created_id ||\n $user->id == $model->updated_id;\n }", "public function authorize()\n {\n return $this->user()->can('update', $this->user);\n }", "public function updateProfile(){\r\n\t\t\r\n\t\t$query = sprintf(\"\tUPDATE users SET fname='%s', lname='%s'\r\n\t\t\t\t\t\t\tWHERE username='%s'\",\r\n\t\t\t\t\t\t\t$this -> getFName(),\r\n\t\t\t\t\t\t\t$this -> getLName(),\r\n\t\t\t\t\t\t\t$this -> getUName());\r\n\t\t\r\n\t\tif($result = dbCon::execute_query($query)){\r\n\t\t\treturn true;\t\r\n\t\t}\r\n\t\telse return false;\r\n\t}", "public function update(User $user): bool\n {\n return $user->hasAnyRole(['admin', 'webmaster']);\n }", "public function authorize()\n {\n return $this->user()->can('update', $this->user());\n }", "public function update(User $userProfile, User $signedInUser)\n {\n return $userProfile->id == $signedInUser->id;\n }", "public function update(User $user, $model, $parent = null)\n {\n $allow = !$user->hasRole(['staff']);\n if ($parent) $allow = $allow && $user->can('update', $parent);\n return $allow;\n }", "public function update(User $user, Model $model)\n {\n return $user->isSuper() ||\n (\n $user->isAdmin() &&\n $user->belongsToCompany($model->company)\n ) ||\n $this->isAllowedFor($user, 'update');\n }" ]
[ "0.76298755", "0.74075496", "0.7403561", "0.7279533", "0.7220238", "0.7188763", "0.7182973", "0.7091441", "0.70604384", "0.69404906", "0.6930382", "0.688025", "0.6867527", "0.6863119", "0.6837284", "0.68288106", "0.6745607", "0.6723212", "0.67172754", "0.6683981", "0.66652215", "0.6659583", "0.6658366", "0.66390395", "0.6596908", "0.65963185", "0.6562233", "0.6561438", "0.65603125", "0.6552299" ]
0.7651353
0
Determine if the given user can delete a profile.
public function destroy(User $user, $profile) { if($user->hasRole(['Admin', 'Superuser'])) { return true; } return $profile->id === $user->id; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function delete(User $user)\n {\n if ($user->can('delete_user') || $user->can('manage_users')) {\n return true;\n }\n\n return false;\n }", "public function checkIfUserCanDelete($user) {\n return $this->owner==$user->getUsername() || $user->isAdmin();\n }", "public function delete(User $user)\n {\n return $user->can('delete_education');\n }", "public function canDelete(Model_User $user)\n\t{\n\t\treturn false;\n\t}", "public function delete(User $user)\n {\n if($user->can($this->common_permission.'delete') || $user->can($this->common_permission.'delete')) {\n return true;\n }\n return false;\n }", "public function delete($user)\n {\n return $user->permission == 1 ? true : false ;\n }", "public function delete($user, $model = null)\n {\n return $user->can($this->authorisationPrefix() . '.delete');\n }", "public function delete(User $user)\n {\n return $user->can('delete_pages');\n }", "function canDelete(User $user) {\n return $this instanceof IState ? $this->state()->canDelete($user) : false;\n }", "public function delete(User $current, User $user)\n {\n if($user->id==$current->id){\n \treturn false;\n }\n \tif($user->isSuperAdmin()){//only super admin can delete other superadmin\n \treturn $current->isSuperAdmin();\n }\n return $current->can('delete_user');\n }", "public function delete(User $user, Config $config)\n {\n return $user->id == 1 ? true : false;\n }", "public function userCanDelete($user) {\n // if the user is a guest\n if (!isset($user)) return false;\n\n // if the user is the author of the post\n if ($this->author->user_id == $user->user_id) return true;\n\n // if the user can delete posts for this post's page\n $permissions = Permission::where('user_id', '=', $user->user_id)\n ->where('charity_id', '=', $this->page->charity->charity_id)\n ->where(function($query) {\n $query->where('page_id', '=', $this->page->page_id)\n ->orWhere('page_id', '=', 0);\n })\n ->count();\n \n return $permissions > 0;\n\n }", "public function canDelete(IdentityInterface $user, User $resource)\n {\n return $this->isUser($user, $resource);\n }", "function canDelete($user) {\n if($this->isBuiltIn() || $this->isDefault()) {\n return false;\n } // if\n \n return $user->isAdministrator();\n }", "public function delete(User $user)\n {\n return $user->hasAccess(['backup.delete']);\n }", "public function delete(User $user, Account $account)\n {\n return $user->can('accounts.delete');\n }", "function can_delete() {\n\t\tif ($this->permissions['all']) {\n\t\t\treturn $this->check_permission($this->permissions['all']);\n\t\t} elseif ($this->permissions['delete']) {\n\t\t\treturn $this->check_permission($this->permissions['delete']);\n\t\t} elseif ($this->object && $this->permissions['delete_own']) {\n\t\t\tif (current_user()->id == $this->object->author) {\n\t\t\t\treturn $this->check_permission($this->permissions['delete_own']);\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}", "public function can_delete( $entity, $user = null ) {\n\t\tif ( is_null( $user ) ) {\n\t\t\t$user = get_current_user_id();\n\t\t} elseif ( is_object( $user ) ) {\n\t\t\t$user = $user->ID;\n\t\t}\n\t\t$entity = self::get_entity_by_post( $entity );\n\t\t$entity_cap = $entity->get_capabilities();\n\n\t\tif ( ! isset( $entity_cap->delete_post ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn user_can( $user, $entity_cap->delete_post, $entity->get_id() );\n\t}", "public function delete(User $userWithRequest, User $user): bool\n {\n $name = $this->getOwnerName($user);\n return $userWithRequest->hasPermissionTo(\"{$name}..user.delete.{$user->id}\");\n }", "public function deletePolicy(User $user)\n {\n return $user->may(static::PERMISSION_DELETE);\n }", "public function delete(User $user)\n {\n return $user->hasAccess('delete-conference-gallery');\n }", "public function delete(User $user, Personcard $personcard)\n {\n return $user->hasPermission('delete-myservice-personcard');\n }", "public function delete(User $user)\n {\n return $this->hasPermission($user, 'delete', $this->modelName);\n }", "public function delete(Person $user, Person $person): bool\n {\n return $user->isAdmin();\n }", "public function delete(User $user)\n {\n if($user->hasPermissionTo('destroy_educational_tool')){\n return true;\n }\n return false;\n }", "public function delete(User $user, Perspective $perspective)\n {\n return false;\n }", "public function canDelete()\n {\n if ($this->created_by == Yii::$app->user->id) {\n return true;\n }\n\n return false;\n }", "public function canDelete($user_guid = 0) {\n\t\treturn _elgg_services()->userCapabilities->canDelete($this, $user_guid);\n\t}", "public function destroy(User $user)\n {\n return $user->can('destroy-student');\n }", "public function delete(User $user, Guide $guide)\n {\n if($user->hasPermission('guide-delete-any')) {\n return true;\n }\n\n return (($user->hasPermission('guide-delete')) && ($user->ownsGuide($guide)));\n }" ]
[ "0.71576625", "0.7083995", "0.7062465", "0.7011966", "0.6990168", "0.69499856", "0.6945337", "0.6877687", "0.686232", "0.6861428", "0.68400204", "0.68343985", "0.68290204", "0.6782247", "0.6695397", "0.6687825", "0.66683596", "0.66570365", "0.66500634", "0.6645281", "0.6585097", "0.6553137", "0.6550225", "0.65359396", "0.651087", "0.64870036", "0.6481711", "0.6431166", "0.6422699", "0.6422498" ]
0.7418588
0
Store language to cookie.
public function storeLanguageToCookie($lang) { $cookie = new Cookie(['name' => $this->languageParam, 'value' => $lang]); Yii::$app->getResponse()->getCookies()->add($cookie); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cookieLANG() { \n\n setcookie(lang,$this->lang,time()+365*24*3600);\n\n }", "private function _setLanguage() \r\n {\r\n //write the Config.language with the value from the Cookie\r\n if ($this->Cookie->read('lang') && !$this->Session->check('Config.language')) {\r\n $this->Session->write('Config.language', $this->Cookie->read('lang'));\r\n } else if (isset($this->params['language']) && ($this->params['language'] != $this->Session->read('Config.language'))) {\r\n //then update the value in Session and the one in Cookie\r\n $this->Session->write('Config.language', $this->params['language']);\r\n $this->Cookie->write('lang', $this->params['language'], false, '20 days');\r\n }\r\n }", "public static function setCookieLanguage($cookie = null)\n {\n }", "private function getLanguageFromCookie()\n {\n if (Cookie::has('language')){\n $this->language = Cookie::get('language');\n } else {\n $this->language = 'fr';\n }\n }", "public function saveLanguage()\n\t{\n\t\t$language = Piwik_Common::getRequestVar('language');\n\t\tPiwik_LanguagesManager::setLanguageForSession($language);\n\t\tPiwik_Url::redirectToReferer();\n\t}", "public function setLang($lang)\n\t{\n\t\t$cookieName = $this->getCookieName();\n\t\t$this->httpResponse->setCookie($cookieName, $lang, \"+ 100 days\");\n\t}", "public function set_language($lang) {\n\t\t// Convert BR to PT.\n\t\tif ($lang == \"br\") {\n\t\t\t$lang = \"pt\";\n\t\t}\n\n\t\tsetcookie(\"lang\", $lang, time() + 31536000, \"/\");\n\t\t$this->cl = $lang;\n\t}", "function SetLang($lang) {\n if (is_dir('lang/' . $lang)) {\n $key = IBC1_PREFIX . '_Language';\n $GLOBALS[$key] = $lang;\n setcookie($key, $lang, time() + 7 * 24 * 60 * 60);\n }\n}", "function createCookie($cookie){\n\t\tsetcookie('lang', $cookie, time() + 365*24*3600, null, null, false, true);\n\t}", "public function setLanguage($language)\n\t{\r\n\t\tYii::app()->setLanguage($language);\r\n\t\tsetLocale(LC_ALL, $language.'.'.Yii::app()->charset);\n\t\tYii::app()->getUser()->setState($this->languageVarName, $language);\n\t\tYii::app()->getRequest()->getCookies()->add($this->languageVarName, new CHttpCookie($this->languageVarName, $language, array('expire' => time() + $this->cookieExpire)));\r\n\t}", "public static function SetLanguage($lng = DEFAULT_LANGUAGE)\n {\n Yii::app()->language = $lng;\n\n /* set language in user state */\n Yii::app()->user->setState('language', $lng);\n\n /* set language in cookie */\n Yii::app()->request->cookies['language'] = new CHttpCookie('lng', $lng);\n\n /* if user has language - set it*/\n if (Yii::app()->user->hasState('language')){Yii::app()->language = Yii::app()->user->getState('language');}\n\n /* if not, but if have in cookie - set from cookie */\n elseif(isset(Yii::app()->request->cookies['language'])){Yii::app()->language = Yii::app()->request->cookies['language']->value;}\n }", "private function defaultCookieLang()\n {\n if(!Cookie::get('lang'))\n {\n $this->cookieLang = app()->getLocale();\n }\n }", "public function getCookieLanguage()\n {\n return isset($_COOKIE['lang']) ? $_COOKIE['lang'] : null;\n }", "public static function setLanguage($language) {\r\n $_SESSION[Config::$lang_session] = $language;\r\n }", "public function switchLanguage() {\n $this->autoRender = false;\n $this->Cookie->write('site_language', $this->request->data['lang']);\n echo json_encode(['success' => __('Language successfully switched')]);\n }", "public function langSetter($lang) {\n if (Session::has('cookieString')) {\n $responseArray = \\LangAPI::setLang($lang);\n\n if (isset($responseArray['data']['status']) && $responseArray['data']['status'] === 'success') {\n //TO DO: \n \\Session::put('language', $lang);\n \\App::setLocale($lang);\n\n \\UI::setNavigation($responseArray);\n\n \\Cache::forget('leftNav');\n }\n\n\n return Redirect::route('home')\n ->with('success', $responseArray['message']);\n }\n \n return Redirect::route('logout');\n }", "function change_language($lang = null)\n\t{\n\t\tif (!empty($lang)) {\n\t\t\tset_cookie('lang', $lang);\n\t\t\tredirect_to_page(DEFAULT_PAGE);\n\t\t} else {\n\t\t\t$this->render_view(\"info/change_language.php\", null, \"info_layout.php\");\n\t\t}\n\t}", "function language_selector_set_logged_out_user_language() {\n\tglobal $CONFIG;\n\t\n\tif (elgg_is_logged_in()) {\n\t\treturn;\n\t}\n\n\tif (!empty($_COOKIE['client_language'])) {\n\t\t// switched with language selector\n\t\t$new_lang = $_COOKIE['client_language'];\n\t} else {\n\n\t\t$browserlang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);\n\n\t\tif (!empty($browserlang)) {\n\t\t\t// autodetect language\n\n\t\t\tif (elgg_get_plugin_setting(\"autodetect\", \"language_selector\") == \"yes\") {\n\t\t\t\t$new_lang = $browserlang;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!empty($new_lang) && ($new_lang !== $CONFIG->language)) {\n\t\t$allowed = language_selector_get_allowed_translations();\n\t\tif (in_array($new_lang, $allowed)) {\n\t\t\t// set new language\n\t\t\t$CONFIG->language = $new_lang;\n\n\t\t\t// language has been change; reload language keys\n\t\t\tif (elgg_is_active_plugin(\"translation_editor\")) {\n\t\t\t\ttranslation_editor_load_translations();\n\t\t\t} else {\n\t\t\t\treload_all_translations();\n\t\t\t}\n\t\t}\n\t}\n}", "function setLanguage($language);", "function switchLanguage() {\n\t\t$lang = $this->input->get('lang');\n\t\t$language = ($lang != \"\") ? $lang : \"english\";\n\t\t$this->session->set_userdata('site_lang', $language);\n\t}", "public static function setLang(){\n $langCode = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);\n if(!empty($_REQUEST[LANG_CTRL_VAR]) && file_exists(PATH_ENGINE_LANG.$langCode.'.php')){\n $langCode = $_REQUEST[LANG_CTRL_VAR];\n if(ThisUser::islogged()){\n $User = Usuario::find(ThisUser::get(\"id_user\"));\n $User->lang = $_REQUEST[LANG_CTRL_VAR];\n $User->save();\n ThisUser::set(\"lang\",$_REQUEST[LANG_CTRL_VAR]);\n }\n }else{\n if(ThisUser::islogged() && ThisUser::get(\"lang\") != \"\"){\n $langCode = ThisUser::get(\"lang\");\n }\n }\n\n if(file_exists(PATH_ENGINE_LANG.$langCode.'.php')){\n Lang::load($langCode.'.php');\n }else{\n Lang::load(Sys::get('config')->lang_default.'.php');\n }\n }", "public function Store()\n {\n setcookie($this->_getName(), $this->_getValue(), $this->_getExpire(), $this->_getPath(), $this->_getDomain(), $this->_getSecure(), $this->_getHttponly());\n }", "public function actionLanguage()\n { \n if(Yii::$app->request->post('language')) //If the request is a POST and lang is set.\n {\n $language = Yii::$app->request->post('language'); // Gets the language.\n \n $previousLanguage = Yii::$app->language; //Save the previous language.\n \n // If $language is an available language.\n if(in_array($language, Yii::$app->params['app.available_languages']))\n {\n Yii::$app->language = $language;\n }\n else\n {\n throw new \\yii\\web\\NotFoundHttpException(Yii::t(__CLASS__, 'Language not supported')); // Not found.\n }\n \n // Sets the language session variable.\n Yii::$app->session['language'] = Yii::$app->language;\n \n // Sets the language cookie to remeber the language between site accesses.\n Yii::$app->response->cookies->add(new \\yii\\web\\Cookie([\n 'name' => 'language',\n 'value' => Yii::$app->language\n ]));\n }\n \n Yii::$app->response->format = \\yii\\web\\Response::FORMAT_JSON;\n \n // Return the current language.\n return Yii::$app->language;\n }", "public static function setLanguage($daysExpires = 100)\n {\n if (Yii::app()->request->getPost('languagePicker') !== null && in_array($_POST['languagePicker'], self::getLanguages(), true)) {\n Yii::app()->setLanguage($_POST['languagePicker']);\n $cookie = new CHttpCookie('language', $_POST['languagePicker']);\n $cookie->expire = time() + 60 * 60 * 24 * $daysExpires;\n Yii::app()->request->cookies['language'] = $cookie;\n } else if (isset(Yii::app()->request->cookies['language']) && in_array(Yii::app()->request->cookies['language']->value, self::getLanguages(), true)) {\n Yii::app()->setLanguage(Yii::app()->request->cookies['language']->value);\n } else if (isset(Yii::app()->request->cookies['language'])) {\n unset(Yii::app()->request->cookies['language']);\n } else {\n $preferredLang = explode('_', Yii::app()->getRequest()->getPreferredLanguage());\n if (in_array($preferredLang[0], self::getLanguages(), true))\n Yii::app()->setLanguage($preferredLang[0]);\n }\n }", "public static function save() {\n\t\t$self = CookieStore::get_current();\n\t\t$expiration_date = time() + 30*60;\n\t\tif(!empty($self->_stored)) {\n\t\t\tforeach($self->_stored as $ckey => $cval) {\n\t\t\t\tif(empty($self->_saved[$ckey])) {\n\t\t\t\t\tsetcookie($ckey, $self->_to_cookie_val($cval), $expiration_date, '/', DOMAIN);\n\t\t\t\t\t$self->_saved[$ckey] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(!empty($self->_destroyed)) {\n\t\t\tforeach($self->_destroyed as $ckey => $cval) {\n\t\t\t\tsetcookie($ckey, 0, time() - 86400, '/', DOMAIN);\n\t\t\t}\n\t\t}\n\t}", "public function set_locale($language_id){\n\n\n // Via the global helper...\n session(['language_id_from_dropdown' => $language_id]);\n\n $language_id_from_dropdown = session()->get('language_id_from_dropdown');\n\n $language = Language::find($language_id_from_dropdown);\n\n session(['language_name_from_dropdown' => $language->language_name]);\n session(['language_code_from_dropdown' => $language->language_code]);\n session(['language_direction_from_dropdown' => $language->direction]);\n\n\n return redirect()->back();\n\n }", "public function setCurrentLanguage($strLanguage);", "public function selected_language() \n {\n // return the selected language if its set already\n if(!empty($this->language)) return $this->language;\n \n // Load language cookie\n $this->language = $this->Input->cookie('language', true);\n\n //Load the default language if the user hasnt selected a language yet\n if($this->language == false || !in_array($this->language, $this->found_languages))\n {\n // Get the users prefered language\n $prefered = null;\n if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))\n {\n $prefered = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);\n }\n \n // Check and make sure the language is installed\n $this->language = (!in_array($prefered, $this->found_languages)) ? $this->default_language() : $prefered;\n \n // Update the language cookie\n $this->Input->set_cookie('language', $this->language);\n }\n\n // Set globals\n return $this->language;\n }", "function detect_language(){\n //Try to read cookie.\n header('Cache-control: private');\n if (isSet($_COOKIE['lang'])){\n $lang = $_COOKIE['lang'];\n if ($lang == 'es' || $lang == 'en' || $lang == 'eu'){\n return $lang;\n }\n else{\n return null;\n }\n }\n }", "public static function set_language(string $language) { self::$language = $language; }" ]
[ "0.79680043", "0.78805643", "0.7580553", "0.732604", "0.73246074", "0.7128898", "0.70190746", "0.7005874", "0.6829365", "0.6635506", "0.6593478", "0.6518692", "0.6511397", "0.6427586", "0.64262444", "0.64053696", "0.63978744", "0.6298695", "0.6249602", "0.61391443", "0.61101156", "0.61010695", "0.60618156", "0.6059752", "0.6018874", "0.59813064", "0.5943495", "0.5942342", "0.5907262", "0.58961874" ]
0.8065144
0
Appends raw XML data to a DOMDocumentFragment. This method is not part of the DOM standard. It was created as a simplier approach for appending an XML DocumentFragment in a DOMDocument. If you want to stick to the standards, you will have to create a temporary DOMDocument with a dummy root and then loop through the child nodes of the root of your XML data to append them.
public function appendXML($data);
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function flush()\n {\n if($this->domDocument instanceof \\DOMDocument){\n $this->getWritingStream()->write(\n $this->domDocument->saveXML(null, LIBXML_NOEMPTYTAG),\n false,\n OutputInterface::OUTPUT_RAW\n );\n }\n\n parent::flush();\n }", "abstract protected function buildUpdateSection(DOMDocument $xml, DOMElement $data);", "abstract protected function buildUpdateSection(DOMDocument $xml, DOMElement $data);", "private function _format_rawxml($data = array(), $structure = null, $basenode = 'xml')\n\t{\n\t\t// turn off compatibility mode as simple xml throws a wobbly if you don't.\n\t\tif (ini_get('zend.ze1_compatibility_mode') == 1)\n\t\t{\n\t\t\tini_set('zend.ze1_compatibility_mode', 0);\n\t\t}\n\n\t\tif ($structure == null)\n\t\t{\n\t\t\t$structure = simplexml_load_string(\"<?xml version='1.0' encoding='utf-8'?><$basenode />\");\n\t\t}\n\n\t\t// loop through the data passed in.\n\t\t$data = self::_force_loopable($data);\n\t\tforeach ($data as $key => $value)\n\t\t{\n\t\t\t// no numeric keys in our xml please!\n\t\t\tif (is_numeric($key))\n\t\t\t{\n\t\t\t\t// make string key...\n\t\t\t\t//$key = \"item_\". (string) $key;\n\t\t\t\t$key = \"item\";\n\t\t\t}\n\n\t\t\t// replace anything not alpha numeric\n\t\t\t$key = preg_replace('/[^a-z0-9_-]/i', '', $key);\n\n\t\t\t// if there is another array found recrusively call this function\n\t\t\tif (is_array($value) or is_object($value))\n\t\t\t{\n\t\t\t\t$node = $structure->addChild($key);\n\t\t\t\t// recrusive call.\n\t\t\t\tself::_format_rawxml($value, $node, $basenode);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// Actual boolean values need to be converted to numbers\n\t\t\t\tis_bool($value) and $value = (int) $value;\n\n\t\t\t\t// add single node.\n\t\t\t\t$value = htmlentities($value, ENT_NOQUOTES, \"UTF-8\");\n\n\t\t\t\t$UsedKeys[] = $key;\n\n\t\t\t\t$structure->addChild($key, $value);\n\t\t\t}\n\t\t}\n\n\t\t// pass back as string. or simple xml object if you want!\n\t\treturn $structure->asXML();\n\t}", "public function add(DOMDocument $dom)\n {\n $this->addElement($dom->documentElement);\n }", "protected abstract function doWriteEndElement();", "public function testAppendXml()\n {\n $imp = new DOMImplementation();\n \n $dtd = $imp->createDocumentType('AirSync', \"-//AIRSYNC//DTD AirSync//EN\", \"http://www.microsoft.com/\");\n $testDom = $imp->createDocument('uri:AirSync', 'Sync', $dtd);\n $testDom->formatOutput = true;\n $testDom->encoding = 'utf-8';\n \n $collections = $testDom->documentElement->appendChild($testDom->createElementNS('uri:AirSync', 'Collections'));\n $collection = $collections->appendChild($testDom->createElementNS('uri:AirSync', 'Collection'));\n $commands = $collection->appendChild($testDom->createElementNS('uri:AirSync', 'Commands'));\n $add = $commands->appendChild($testDom->createElementNS('uri:AirSync', 'Add'));\n $appData = $add->appendChild($testDom->createElementNS('uri:AirSync', 'ApplicationData'));\n \n \n $controller = new ActiveSync_Controller_Calendar($this->objects['deviceIPhone'], new Tinebase_DateTime(null, null, 'de_DE'));\n \n $controller->appendXML($appData, null, $this->objects['event']->getId(), array());\n \n // namespace === uri:Calendar\n $endTime = $this->objects['event']->dtend->format(\"Ymd\\THis\") . 'Z';\n $this->assertEquals($endTime, @$testDom->getElementsByTagNameNS('uri:Calendar', 'EndTime')->item(0)->nodeValue, $testDom->saveXML());\n $this->assertEquals($this->objects['event']->uid, @$testDom->getElementsByTagNameNS('uri:Calendar', 'UID')->item(0)->nodeValue, $testDom->saveXML());\n \n // try to encode XML until we have wbxml tests\n $outputStream = fopen(\"php://temp\", 'r+');\n $encoder = new Wbxml_Encoder($outputStream, 'UTF-8', 3);\n $encoder->encode($testDom);\n }", "protected function loadXML($data)\n {\n $xml = new \\DOMDocument();\n if ($data instanceof Fs_Node) $xml->load((string)$data);\n else $xml->loadXML($data);\n \n return $xml;\n }", "protected function buildData(DOMDocument $xml)\n\t{\n\t\t$data = $xml->createElement('DATA');\n\t\t$data->appendChild($xml->createElement('NAMEFIRST', htmlentities($this->application->getNameFirst())));\n\t\t$data->appendChild($xml->createElement('NAMEMIDDLE', NULL));\n\t\t$data->appendChild($xml->createElement('NAMELAST', htmlentities($this->application->getNameLast())));\n\t\t$data->appendChild($xml->createElement('STREET1', htmlentities($this->application->getStreet1())));\n\t\t$data->appendChild($xml->createElement('STREET2', htmlentities($this->application->getStreet2())));\n\t\t$data->appendChild($xml->createElement('CITY', htmlentities($this->application->getCity())));\n\t\t$data->appendChild($xml->createElement('STATE', htmlentities($this->application->getState())));\n\t\t$data->appendChild($xml->createElement('ZIP', htmlentities($this->application->getZip())));\n\t\t$data->appendChild($xml->createElement('PHONEHOME', htmlentities($this->application->getPhoneHome())));\n\t\t$data->appendChild($xml->createElement('PHONECELL', htmlentities($this->application->getPhoneCell())));\n\t\t$data->appendChild($xml->createElement('PHONEWORK', htmlentities($this->application->getPhoneWork())));\n\t\t$data->appendChild($xml->createElement('PHONEEXT', htmlentities($this->application->getPhoneExt())));\n\t\t$data->appendChild($xml->createElement('EMAIL', htmlentities($this->application->getEmail())));\n\t\t$data->appendChild($xml->createElement('DOB', htmlentities($this->application->getDOB())));\n\t\t$data->appendChild($xml->createElement('SSN', htmlentities($this->application->getSSN())));\n\t\t$data->appendChild($xml->createElement('DRIVERLICENSENUMBER', htmlentities($this->application->getDriverLicenseNumber())));\n\t\t$data->appendChild($xml->createElement('DRIVERLICENSESTATE', htmlentities($this->application->getDriverLicenseState())));\n\t\t$data->appendChild($xml->createElement('WORKNAME', htmlentities($this->application->getWorkName())));\n\t\t$data->appendChild($xml->createElement('WORKSTREET1', htmlentities($this->application->getWorkStreet1())));\n\t\t$data->appendChild($xml->createElement('WORKSTREET2', htmlentities($this->application->getWorkStreet2())));\n\t\t$data->appendChild($xml->createElement('WORKCITY', htmlentities($this->application->getWorkCity())));\n\t\t$data->appendChild($xml->createElement('WORKSTATE', htmlentities($this->application->getWorkState())));\n\t\t$data->appendChild($xml->createElement('WORKZIP', htmlentities($this->application->getWorkZip())));\n\t\t$data->appendChild($xml->createElement('BANKNAME', htmlentities($this->application->getBankName())));\n\t\t$data->appendChild($xml->createElement('BANKABA', htmlentities($this->application->getBankAba())));\n\t\t$data->appendChild($xml->createElement('BANKACCTNUMBER', htmlentities($this->application->getBankAcctNumber())));\n\t\t$data->appendChild($xml->createElement('PAYPERIOD', htmlentities($this->application->getPayPeriod())));\n\t\t$data->appendChild($xml->createElement('DIRECTDEPOSIT', htmlentities($this->application->getDirectDeposit())));\n\t\t$data->appendChild($xml->createElement('MONTHLYINCOME', htmlentities($this->application->getMonthlyIncome())));\n\t\t$this->buildUpdateSection($xml, $data, $this->application);\n\t\t\n\t\treturn $data;\n\t}", "protected function xml_start(){\r\n\t\treturn \"<data>\";\r\n\t}", "public function renderXML() {\n header('Content-type: text/plain;');\n \n $this->end(XML::array2XML($this->data, 'data'));\n }", "function addSelfToDocument($domtree, $parentElement) {\n $parentElement->appendChild($domtree->createElement('homeurl', home_url()));\n $parentElement->appendChild($domtree->createElement('selectiondate', $this->selectionDate->format('Y-m-d')));\n $parentElement->appendChild($domtree->createElement('selectiondate_long', $this->selectionDate->format('D, d M Y')));\n\n if( $this->lastCompletedAllocScraperJob ) {\n $parentElement->appendChild($domtree->createElement('last_completed_job', \n DateTime::createFromFormat('Y-m-d H:i:s', $this->lastCompletedAllocScraperJob)->format('D, d M Y H:i:s')));\n }\n\n if( $this->isRefreshJobInProgress ) {\n $parentElement->appendChild($domtree->createElement('job_in_progress', 'true' ));\n }\n\n // did the last job fail to run?\n if( $this->lastJob ) {\n $parentElement->appendChild($domtree->createElement('last_job_id', $this->lastJob['jobId'] ));\n $parentElement->appendChild($domtree->createElement('last_job_status', $this->lastJob['status'] ));\n $parentElement->appendChild($domtree->createElement('check_credentials', $this->lastJob['lastJobFailedDueToCredentials'] ? 'true' : 'false' ));\n $parentElement->appendChild($domtree->createElement('last_job_error_log', \n get_option('hbo_log_directory_url') . $this->lastJob['jobId'] ));\n }\n\n $xmlRoot = $parentElement->appendChild($domtree->createElement('bedcounts'));\n foreach( $this->bedcountData as $row ) {\n $roomRoot = $xmlRoot->appendChild($domtree->createElement('room'));\n $roomRoot->appendChild($domtree->createElement('id', htmlspecialchars($row->room)));\n $roomRoot->appendChild($domtree->createElement('capacity', $row->capacity));\n $roomRoot->appendChild($domtree->createElement('room_type', $row->room_type));\n $roomRoot->appendChild($domtree->createElement('num_empty', $row->num_empty));\n $roomRoot->appendChild($domtree->createElement('num_staff', $row->num_staff));\n $roomRoot->appendChild($domtree->createElement('num_paid', $row->num_paid));\n $roomRoot->appendChild($domtree->createElement('num_noshow', $row->num_noshow));\n }\n }", "public function append($data) {\n if (gettype($data) == 'array') {\n foreach ($data as $str) {\n $this->rawData .= $str;\n }\n } else {\n $this->rawData .= $data;\n }\n }", "private function appendXmlNode($domDocument, $parentNode, $name, $value)\n {\n $childNode = $domDocument->createElement($name);\n $childNodeValue = $domDocument->createTextNode($value);\n $childNode->appendChild($childNodeValue);\n $parentNode->appendChild($childNode);\n }", "function execute($data) {\n $doc = new \\DOMDocument();\n $doc->loadXML($data);\n \n return $doc;\n }", "private function _xml($data = array(), $structure = NULL, $basenode = 'xml')\n {\n \t// turn off compatibility mode as simple xml throws a wobbly if you don't.\n\t\tif (ini_get('zend.ze1_compatibility_mode') == 1)\n\t\t{\n\t\t\tini_set ('zend.ze1_compatibility_mode', 0);\n\t\t}\n\n\t\tif ($structure == NULL)\n\t\t{\n\t\t\t$structure = simplexml_load_string(\"<?xml version='1.0' encoding='utf-8'?><$basenode />\");\n\t\t}\n\n\t\t// loop through the data passed in.\n\t\tforeach($data as $key => $value)\n\t\t{\n\t\t\t// no numeric keys in our xml please!\n\t\t\tif (is_numeric($key))\n\t\t\t{\n\t\t\t\t// make string key...\n\t\t\t\t//$key = \"item_\". (string) $key;\n\t\t\t\t$key = \"item\";\n\t\t\t}\n\n\t\t\t// replace anything not alpha numeric\n\t\t\t$key = preg_replace('/[^a-z0-9_-]/i', '', $key);\n\n\t\t\t// if there is another array found recrusively call this function\n\t\t\tif (is_array($value))\n\t\t\t{\n\t\t\t\t$node = $structure->addChild($key);\n\t\t\t\t// recrusive call.\n\t\t\t\t$this->_xml($value, $node, $basenode);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// add single node.\n\n\t\t\t\t$value = htmlentities($value, ENT_NOQUOTES, \"UTF-8\");\n\n\t\t\t\t$UsedKeys[] = $key;\n\n\t\t\t\t$structure->addChild($key, $value);\n\t\t\t}\n\n\t\t}\n \t\n\t\t// pass back as string. or simple xml object if you want!\n\t\treturn $structure->asXML();\n }", "public function testAppendChild()\n {\n $root = new Node('<b>Test 1</b>');\n $element = new Node('<b>Test 2</b>');\n $root->appendChild($element);\n $this->assertEquals('<b>Test 1</b><b>Test 2</b>', $root->outerHtml());\n }", "public function xml() {\n\t\t$domtree = new DOMDocument('1.0', 'UTF-8');\n\n\t\t// Create root element of the xml tree\n\t\t$xmlRoot = $domtree->createElement('xml');\n\t\t$xmlRoot = $domtree->appendChild($xmlRoot);\n\n\t\t// Create title element\n\t\t$title = $domtree->createElement('title', htmlspecialchars($this->data['title']));\n\t\t$xmlRoot->appendChild($title);\n\n\t\t// Create description element\n\t\t$description = $domtree->createElement('description', htmlspecialchars($this->data['description']));\n\t\t$xmlRoot->appendChild($description);\n\n\t\t// Create url element\n\t\t$url = $domtree->createElement('url', utf8_encode($this->data['url']));\n\t\t$xmlRoot->appendChild($url);\n\n\t\t// Create updated element\n\t\t$updated = $domtree->createElement('updated', $this->data['updated']);\n\t\t$xmlRoot->appendChild($updated);\n\n\t\t// Create dataset element\n\t\t$dataset = $domtree->createElement('dataset');\n\t\t$dataset = $xmlRoot->appendChild($dataset);\n\n\t\tforeach ($this->data['dataset'] as $array_item) {\n\t\t\t// Create item element\n\t\t\t$itemNode = $domtree->createElement('item');\n\t\t\t$dataset->appendChild($itemNode);\n\n\t\t\tforeach ($array_item as $name => $value) {\n\t\n\t\t\t\tif (is_array($value)) {\n\t\t\t\t\tif (count($value) > 0) {\n\t\t\t\t\t\t$item = $domtree->createElement($name);\n\t\t\t\t\t\t$itemNode->appendChild($item);\n\t\t\t\t\n\t\t\t\t\t\tforeach ($value as $sub_value) {\n\t\t\t\t\t\t\t$sub = $domtree->createElement('item');\n\t\t\t\t\t\t\t$sub->appendChild($domtree->createTextNode(utf8_encode($sub_value)));\n\t\t\t\t\t\t\t$item->appendChild($sub);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$item = $domtree->createElement($name);\n\t\t\t\t\t\t$item->appendChild($domtree->createTextNode(''));\n\t\t\t\t\t\t$itemNode->appendChild($item);\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\t$item = $domtree->createElement($name);\n\t\t\t\t\t\n\t\t\t\t\tif (empty($value)) {\n\t\t\t\t\t\t$item->appendChild($domtree->createTextNode(''));\n\t\t\t\t\t\n\t\t\t\t\t} else {\t\n\t\t\t\t\t\t$item->appendChild($domtree->createTextNode($value));\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t$itemNode->appendChild($item);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t$domtree->formatOutput = true;\n\n \treturn $domtree->saveXML();\n\t}", "function loadXMLappendElementdAndSave()\n {\n $strXML =\n'<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<eZREST function=\"This is the functionName\"/>\n<eZREST function=\"This is the functionName2\"/>\n';\n\n $domDocument = $this->createDocument();\n $domDocument->loadXML( $strXML );\n $rootElement =& $domDocument->createElement( 'eZREST2' );\n $rootElement->setAttribute( 'function', 'This is the functionName added 2' );\n $domDocument->appendChild( $rootElement );\n return $domDocument->saveXML();\n }", "public function appendXML( ExtendedSimpleXMLElement $append)\n {\n if ($append) {\n if (strlen(trim((string)$append)) == 0) {\n $xml = $this->addChild($append->getName());\n } else {\n $xml = $this->addChild($append->getName(), (string)$append);\n }\n\n foreach ($append->children() as $child) {\n $xml->appendXML($child);\n }\n\n foreach ($append->attributes() as $n => $v) {\n $xml->addAttribute($n, $v);\n }\n }\n }", "function run()\n {\n $test = new DOMDocumentTest();\n $DOMDocument = $this->createDocument();\n\n // Tests\n //echo $test->createElement();\n //echo $test->createElements();\n //echo $test->createDocumentAndSave();\n echo $test->loadXMLappendElementdAndSave();\n //echo $test->createMultipleRootElements();\n\n //echo $test->importNode();\n //echo $test->subElements();\n //echo $test->childNodes();\n}", "public function append($content)\n {\n $content = $this->contentResolve($content);\n\n return $this->each(function (HtmlNode $node, $index) use ($content) {\n $content->each(function (DOMNode $newNode) use ($node, $index) {\n $newNode = $this->newNode($newNode, $index);\n $node->append($newNode);\n });\n });\n }", "static public function renderXML($data) {\n\t}", "public function raw(): XMLElement\n {\n return $this->raw;\n }", "private function buildDocument(array $data)\n {\n $xml = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>';\n $xml .= '<Root';\n $xml .= ' xmlns:'.self::EDOC.'=\"'.self::NS_EDOC.'\"';\n $xml .= ' xmlns:'.self::FESD.'=\"'.self::NS_FESD.'\"';\n $xml .= '/>';\n\n return XmlHelper::array2xml($data, $xml);\n }", "public function appendChild($node)\n {\n if (false === $node instanceof HtmlNode) {\n throw new \\InvalidArgumentException('Unsupported node type');\n }\n\n $this->element->appendChild($node->getDomElement());\n }", "protected function _appendNode(\\SimpleXMLElement $xml,\n \\SimpleXMLElement $node)\n {\n $dom = dom_import_simplexml($xml);\n $dom2 = dom_import_simplexml($node);\n\n $dom->appendChild($dom->ownerDocument->importNode($dom2, true));\n }", "public function toXhtml(\\DOMDocument $document, \\DOMElement $root)\n {\n $this->storeAsset();\n parent::toXhtml($document, $root);\n }", "protected function _ensureAppended()\n {\n if (!$this->_appended) {\n $parentDom = $this->_parentElement->getDom();\n if (!$parentDom->ownerDocument->isSameNode($this->_element->ownerDocument)) {\n $this->_element = $parentDom->ownerDocument->importNode($this->_element, true);\n }\n\n $parentDom->appendChild($this->_element);\n $this->_appended = true;\n $this->_parentElement->_ensureAppended();\n }\n }", "public static function unitedDOM(DOMDocument $xmlDOM, DOMDocument $repXMLDOM /*replace*/)\n {\n if (is_null($repXMLDOM))\n return $xmlDOM;\n \n if (is_null($xmlDOM))\n return $repXMLDOM;\n \n $result = clone $repXMLDOM;\n \n $childs = $xmlDOM->documentElement->childNodes;\n foreach($childs as $item)\n {\n $repChilds = $repXMLDOM->documentElement->childNodes;\n foreach($repChilds as $repItem)\n {\n if ($item->nodeName != $repItem->nodeName)\n $result->documentElement->appendChild($result->importNode($item, true));\n }\n }\n \n return $result;\n }" ]
[ "0.5081751", "0.50806963", "0.50806963", "0.50101674", "0.49589702", "0.49231812", "0.49205703", "0.4847815", "0.48098275", "0.47580215", "0.46832532", "0.46574044", "0.46183202", "0.46078706", "0.45885053", "0.44660166", "0.44634312", "0.44558927", "0.4438743", "0.43703887", "0.43694928", "0.43547922", "0.43497124", "0.4346453", "0.43411198", "0.43319148", "0.43230233", "0.43082142", "0.43077257", "0.42994952" ]
0.643011
0
Note that the fdesigners_id refers to the key field in your database table.
public function _construct() { $this->_init('fdesigners/fdesigners', 'fdesigners_id'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function designers()\n {\n return $this->belongsToMany(DesignerFavorite::class, 'guests', 'id', 'id', 'id', 'id_guest');\n }", "public function getFkdcaid()\n\t{\n\t\treturn $this->fkdcaid;\n\t}", "protected function setupForeignKeysFromFilter($f)\n {\n $masterTblVar = Get(\"t\", \"\");\n if ($masterTblVar == \"grupo\") {\n $find = \"`id_grupo`=\";\n $x = strpos($f, $find);\n if ($x !== false) {\n $x += strlen($find);\n $val = substr($f, $x);\n $val = $this->unquoteValue($val, \"DB\");\n $this->id_grupo->setQueryStringValue($val);\n }\n }\n }", "public function add_fencer_to_coach() {\n\t\tif ( ! current_user_can( 'edit_users' ) )\n\t\t\tdie();\n\n\t\t$fencer_id = $_POST['fencer_id'];\n\t\t$coach_id = $_POST['coach_id'];\n\n\t\ttry {\n\t\t\t$fencer = Fence_Plus_Fencer::wp_id_db_load( $fencer_id );\n\t\t}\n\t\tcatch ( InvalidArgumentException $e ) {\n\t\t\techo \"Fencer not found.\";\n\t\t\tdie();\n\t\t}\n\n\t\tif ( false === $fencer->add_editable_by_user( $coach_id ) ) {\n\t\t\techo (int) $fencer->get_usfa_id(); // if this fencer is already in the coach db, return the fencer's USFA ID\n\t\t\tdie();\n\t\t}\n\n\t\t$fencer->save();\n\n\t\ttry {\n\t\t\t$coach = new Fence_Plus_Coach( $coach_id );\n\t\t}\n\t\tcatch ( InvalidArgumentException $e ) {\n\t\t\techo \"Coach not found.\";\n\t\t\tdie();\n\t\t}\n\n\t\t$coach->add_editable_user( $fencer_id );\n\t\t$coach->save();\n\n\t\t$fencer->short_box();\n\n\t\tdie();\n\t}", "function Fencer($fid) {\r\n\t\t$this->getFencer($fid);\r\n\t}", "function doBrowseFK() {\n\t\tglobal $data, $misc, $lang;\n\n\t\t$ops = array();\n\t\tforeach($_REQUEST['fkey'] as $x => $y) {\n\t\t\t$ops[$x] = '=';\n\t\t}\n\t\t$query = $data->getSelectSQL($_REQUEST['table'], array(), $_REQUEST['fkey'], $ops);\n\t\t$_REQUEST['query'] = $query;\n\n\t\t$fkinfo =& getFKInfo();\n\n\t\t$max_pages = 1;\n\t\t// Retrieve page from query. $max_pages is returned by reference.\n\t\t$rs = $data->browseQuery('SELECT', $_REQUEST['table'], $_REQUEST['query'], \n\t\t\tnull, null, 1, 1, $max_pages);\n\n\t\techo \"<a href=\\\"\\\" style=\\\"display:table-cell;\\\" class=\\\"fk_delete\\\"><img alt=\\\"[delete]\\\" src=\\\"\". $misc->icon('Delete') .\"\\\" /></a>\\n\";\n\t\techo \"<div style=\\\"display:table-cell;\\\">\";\n\n\t\tif (is_object($rs) && $rs->recordCount() > 0) {\n\t\t\t/* we are browsing a referenced table here\n\t\t\t * we should show OID if show_oids is true\n\t\t\t * so we give true to withOid in functions below\n\t\t\t * as 3rd parameter */\n\t\t\n\t\t\techo \"<table><tr>\";\n\t\t\t\tprintTableHeaderCells($rs, false, true);\n\t\t\techo \"</tr>\";\n\t\t\techo \"<tr class=\\\"data1\\\">\\n\";\n\t\t\t\tprintTableRowCells($rs, $fkinfo, true);\n\t\t\techo \"</tr>\\n\";\n\t\t\techo \"</table>\\n\";\n\t\t}\n\t\telse\n\t\t\techo $lang['strnodata'];\n\n\t\techo \"</div>\";\n\n\t\texit;\n\t}", "public function getFactures_id()\n {\n return $this->factures_id;\n }", "public function factory(){\n return $this->belongsTo('App\\Factory', 'factory_id', 'id');\n }", "public function GetFreelancer()\n {\n return $this->belongsTo('Freelancer','freelancer_id','id');\n }", "function GetWerfByWerfID($werf){\n\t\t\t\n global $db;\n\t\t\t\n\t\t\t$result = $db->query(\"SELECT * FROM werven where ID = '$werf'\");\n\t\t\t$werf = $result->fetchrow(MDB2_FETCHMODE_ASSOC);\n\t\t\treturn $werf;\n\t\t}", "function addelderFamRel()\n\t{\n\t\t$this->load->model('Surveymodel');\n\t\t$this->Surveymodel->insert_elderFamilyRelation();\n\t\t\n\t}", "public function fallowers()\n {\n return $this->belongsToMany(static::class, 'fallows', 'fallowed_id', 'fallower_id')\n ->withTimestamps();\n }", "protected function __foreignKey()\n {\n }", "public function faculdade() {\n return $this->HasOne('\\App\\Faculdade', 'id', 'fk_faculdade_id');\n }", "public function getFkidformaCalificacion()\n\t{\n\t\treturn $this->fkidformaCalificacion;\n\t}", "public function getOfferFnacId()\n {\n return $this->offer_fnac_id;\n }", "public function getForeignKey()\n {\n return 'match_id';\n }", "function &getFKInfo() {\n\t\tglobal $data, $misc, $lang;\n\t\t \n\t\t// Get the foreign key(s) information from the current table\n\t\t$fkey_information = array('byconstr' => array(), 'byfield' => array());\n\n\t\tif (isset($_REQUEST['table'])) {\n\t\t\t$constraints = $data->getConstraintsWithFields($_REQUEST['table']);\n\t\t\tif ($constraints->recordCount() > 0) {\n\n\t\t\t\t$fkey_information['common_url'] = $misc->getHREF('schema') .'&amp;subject=table';\n\n\t\t\t\t/* build the FK constraints data structure */\n\t\t\t\twhile (!$constraints->EOF) {\n\t\t\t\t\t$constr =& $constraints->fields;\n\t\t\t\t\tif ($constr['contype'] == 'f') {\n\n\t\t\t\t\t\tif (!isset($fkey_information['byconstr'][$constr['conid']])) {\n\t\t\t\t\t\t\t$fkey_information['byconstr'][$constr['conid']] = array (\n\t\t\t\t\t\t\t\t'url_data' => 'table='. urlencode($constr['f_table']) .'&amp;schema='. urlencode($constr['f_schema']),\n\t\t\t\t\t\t\t\t'fkeys' => array(),\n\t\t\t\t\t\t\t\t'consrc' => $constr['consrc']\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t$fkey_information['byconstr'][$constr['conid']]['fkeys'][$constr['p_field']] = $constr['f_field'];\n\n\t\t\t\t\t\tif (!isset($fkey_information['byfield'][$constr['p_field']]))\n\t\t\t\t\t\t\t$fkey_information['byfield'][$constr['p_field']] = array();\n\n\t\t\t\t\t\t$fkey_information['byfield'][$constr['p_field']][] = $constr['conid'];\n\t\t\t\t\t}\n\t\t\t\t\t$constraints->moveNext();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn $fkey_information;\n\t}", "public function setKeyfield()\n {\n $list = $this->fields;\n foreach ($list as $col) {\n if (array_key_exists('primary', $col)) {\n $this->keyfield = $col['field'];\n }\n }\n }", "public function fos(){\n return $this->belongsTo(FieldOfStudyRemote::class,'fos_id','fos_id');\n }", "public function factions()\n {\n // $this hace referencia al objeto que tengamos en ese momento de Avión.\n return $this->belongsTo('App\\factions',\"faction_id\",\"id\");\n }", "public function get_designation_name($id){\n\t\t$data = $this->HrEmployee->HrDesignation->findById($id, array('fields' => 'desig_name'));\t\t\n\t\t$this->set('desig_data', $data);\n\t}", "public function getFrisdrank($frisdrankId){\n $frisdrankdao = new frisdrankDAO();\n $frisdrank = $frisdrankdao->getById($frisdrankId);\n return $frisdrank;\n }", "public function federation()\n {\n return $this->belongsTo(Federation::class);\n }", "public function designation()\n {\n return $this->belongsTo(Designation::class);\n }", "function get_designation($id)\n {\n return $this->db->get_where('designation',array('id'=>$id))->row_array();\n }", "function getFactId() {\n\t\treturn $this->fact_id;\n\t}", "final function getFact_id() {\n\t\treturn $this->getFactId();\n\t}", "public function getFkSwUf()\n {\n return $this->fkSwUf;\n }", "public function edit_designation($designation_id)\n {\n $data['title'] = \"Edit Designation\";\n $data['designation'] = $this->db->where('designation_id',$designation_id)->get('tbl_designation')->result_object();\n $this->load->view('back/lib/header',$data);\n $this->load->view('back/lib/sidebar');\n $this->load->view('back/designation/edit_designation');\n $this->load->view('back/lib/footer'); \n }" ]
[ "0.57083315", "0.5501184", "0.53784513", "0.5372985", "0.52928615", "0.52744687", "0.52527493", "0.5171484", "0.5150394", "0.5145125", "0.51379216", "0.51003206", "0.5092785", "0.49743083", "0.4971375", "0.4970588", "0.49434897", "0.49374202", "0.49311668", "0.49217412", "0.4887499", "0.48807064", "0.48791504", "0.48340428", "0.48091608", "0.47997922", "0.4798274", "0.47847372", "0.47818965", "0.47735265" ]
0.567149
1
Store a newly created role in storage.
public function store() { $this->validate(); if (auth()->user()->can('create roles')) { $this->createRole(); $this->resetAllData(); $this->emit('refreshRolesIndex'); } else { Session::flash('accessDenied', 'no permission to create a role.'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function store()\n\t{\n\t\t$input = Input::only('name', 'active');\n\t\t$this->rolesCreateForm->validate($input);\n\n\t\t$role = new Role;\n\t\t$role->name = $input['name'];\n\t\t$role->active = (Input::has('active') ? 1 : 0);\n\t\t$role->save();\n\n\t\treturn Redirect::route('admin.index')->withMessage(Bootstrap::success('Role created successfully.', true));\n\t}", "public function store(RoleStoreRequest $request)\n {\n abort_unless(Gate::allows('role-create'), 403);\n\n try {\n $role = Role::create($request->all());\n $role->permissions()->sync($request->input('permissions'));\n\n Alert::toast(\n __('gennix.model_role.alert_messages.store_success'),\n 'success'\n )->timerProgressBar();\n } catch (Throwable $t) {\n Alert::error(\n __('gennix.opps'),\n __('gennix.model_role.alert_messages.store_error')\n )->autoClose(2000)->timerProgressBar();\n\n Auth::user()->saveActivity(\n __('gennix.model_role.alert_messages.store_error') . ' Permission: ' . $request->title,\n [\n 'message' => $t->getMessage(),\n 'code_error' => $t->getCode(),\n 'line' => $t->getLine(),\n 'file' => $t->getFile(),\n ],\n 'error'\n );\n }\n\n return redirect()->route('role.index');\n }", "public function store(CreateRoleRequest $request)\n {\n\n\n $role = Role::create([\n 'store_id'=>Auth::user()->store->id,\n 'name' => $request->name]);\n\n return redirect()->back();\n }", "public function store(StoreRoleRequest $request)\n {\n $role = new Role;\n $role->code = $request->code;\n $role->name = $request->name;\n $role->label = $request->label;\n $role->save();\n return redirect('role/'.$role->id)\n ->with('successMessage', \"Role tersimpan\");\n }", "public function store(RoleCreateRequest $request)\n {\n Role::create($request->all());\n Session::flash('message', 'Rol creado correctamente');\n return Redirect::to('/roles/create');\n }", "public function store(RoleRequest $request)\n {\n $this->roles->createOrUpdate($request);\n\n return message(\"A new role has been created\");\n }", "public function store(RoleRequest $request)\n {\n $role = Role::create($request->all());\n $role->syncPermissions($request->input('permissions'));\n flash(trans('roles.messages.created'));\n\n return redirect()->route('dashboard.roles.show', $role);\n }", "public function store(RoleStoreRequest $request)\n {\n $this->authorize('store', Role::class);\n\n DB::beginTransaction();\n try {\n\n // 创建角色\n $data = $request->only([\n 'name',\n 'description',\n ]);\n $data['guard_name'] = 'api';\n $role = Role::create($data);\n\n // 更新权限\n $role->syncPermissionsWithChecking($request->input('permissions'));\n\n DB::commit();\n } catch (Exception $e) {\n DB::rollback();\n throw new StoreResourceFailedException($e->getMessage());\n }\n\n return $this->response->created();\n }", "public function storeRole(string $role)\n {\n $this->storeRoles([$role]);\n }", "public function store(RoleRequest $request)\n\t{\n\t\t$role = new Role;\n $role->name = $request->name;\n $role->display_name = $request->display_name;\n $role->description = $request->description;\n $role->save();\n $url = session('SOURCE_URL');\n\n return redirect()->to($url)->with('message', 'Role created successfully.')->with('active_role', $role ->id);\n\t}", "public function store(RoleRequest $request)\n {\n $validated = $request->validated();\n\n $role = Role::create(['name' => $validated['name']]);\n $role->syncPermissions($validated['permission']);\n $request->session()->flash('message',__('roles.massages.updated_successfully'));\n return redirect(route('roles.index'));\n }", "public function store(StoreRoleRequest $request)\n {\n $this->authorize('roles.create', FTW\\User::class);\n $request->validated();\n return $this->model->store($request->all());\n }", "public function store() {\n // $permission = Permission::create(['name' => 'dashboard-view']);\n\n // Assign permission to role\n // $role->givePermissionTo($permission);\n\n // Assign role to permission\n // $permission->assignRole($role);\n\n // $user = Auth::user();\n $user = User::find(2);\n // dd($user->hasRole('administrator'));\n $user->assignRole('customer');\n }", "public function store()\n {\n $data = \\Request::all();\n $data['guard_name'] = User::$types[User::ADMINISTRATOR_ID]['route'];\n $role = RoleService::create($data);\n \\Msg::success($role->name . ' role has been <strong>added</strong>.');\n return redir('admin/administrator-roles');\n }", "public function store(StoreRoleRequest $request)\n {\n DB::beginTransaction();\n try\n {\n // 添加 role\n $role = new Role;\n $role->name = $request->name;\n $role->sort = $role->count()+1;\n $role->save();\n\n // 添加关联数据\n if ( $request->permissions )\n {\n foreach ( $request->permissions as $v )\n {\n $tmp[] = [\n 'role_id' => $role->id,\n 'permission_id' => $v,\n ];\n }\n PermissionRelationship::insert($tmp);\n }\n DB::commit();\n return redirect()->route('role_index')->with('message', '添加成功');\n }\n catch (Exception $e)\n {\n DB::rollBack();\n return back()->withErrors('添加失败')->withInput();\n }\n }", "public function store(Request $request)\n {\n // return $request;\n $this->validate($request, [\n 'name' => 'required|max:50|unique:roles'\n ]);\n\n $role = new role;\n $role->name = $request->name;\n $role->save();\n $role->permissions()->sync($request->permissions);\n\n return redirect(route('dash.role.index'));\n }", "public function store(StoreRequest $request)\n {\n Role::create($request->input());\n flash(trans('cms::cms.stored'))->important()->success();\n return redirect()->back();\n }", "public function store(Request $request)\n {\n \n $request->validate([\n 'display_name' => 'required|max:255',\n 'name' => 'required|unique:roles|max:255'\n ]);\n \n $role = new Role();\n\n $role->name = $request->input('name');\n $role->display_name = $request->input('display_name');\n $role->description = $request->input('description');\n $role->save();\n\n Session::flash('message', 'Successfully Created!');\n\n $role->permissions()->sync($request->input('permissions'));\n\n\n return redirect()->route('roles.edit', $role->id);\n\n }", "public function store(RoleRequest $request)\n {\n $request->request->add(['created_by' => Auth::user()->id]);\n $role = Role::create($request->all());\n if ($role) {\n $request->session()->flash('success_message', 'Role Created Successfully');\n return redirect()->route('role.index');\n } else\n $request->session()->flash('error_message', 'Role Creation Failed');\n return redirect()->route('role.create');\n }", "public function store(RoleRequest $request)\n {\n try {\n DB::beginTransaction();\n if (auth()->user()->can('add-role')) {\n $param = $request->all();\n $role = Role::create([\n 'name' => Str::slug($param['display_name'], '-'),\n 'display_name' => $param['display_name'],\n 'description' => $param['description']\n ]);\n if (!empty($param['permissions'])) {\n $role->syncPermissions($param['permissions']);\n }\n DB::commit();\n return redirect()->route('admin.role.index')->withSuccess('Role has been create successfully!');\n } else {\n DB::rollBack();\n return redirect()->route('admin.dashboard')->withInfo('Permission denied!');\n }\n } catch (Throwable $th) {\n DB::rollBack();\n dd($th->getMessage());\n }\n }", "public function store(Request $request)\n {\n $role = Role::create($request->all());\n\n $role->permissions()->sync($request->get('permissions'));\n\n return redirect()->route('roles.index')\n ->with('info', 'Role guardado con exito');\n }", "public function store(Request $request)\n {\n $this->validate($request, [\n 'name'=>'required',\n \n ]);\n\n $role = new Role;\n $role->name = $request->name;\n $role->save();\n $role->permissions()->sync($request->permission);\n return redirect(route('roles.index'))->with('success', 'role added');\n }", "public function store(Request $request)\n {\n $role = Role::create($request->all());\n\n if ($request->input('permissions')) {\n $role->perms()->sync($request->input('permissions'));\n } else {\n $role->perms()->sync([]);\n }\n\n flash('The role has been created.', 'success');\n\n return redirect('/roles');\n }", "public function store(CreateRoleRequest $request)\n {\n $this->roleRepository->create($request->except('_token'));\n\n return redirect()->route('roles.index')\n ->with(config('core.session_success'), _t('role') . ' ' . _t('create_success'));\n }", "public function store(Request $request)\n {\n $request->validate([\n\n 'name'=>'required',\n ]);\n\n $role = Role::updateOrCreate(\n [\n 'id'=>$request->id\n ],\n [\n 'name'=>$request->name,\n ]\n );\n if($request->permissions){\n foreach ($request->permissions as $permission){\n $roleName = Role::findByName($request->name);\n $permissionId = Permission::findById($permission);\n $roleName->syncPermissions($permissionId);\n }\n }\n if($role->wasChanged()){\n session()->flash('update', 'role has been updated successfully');\n }elseif($role->wasRecentlyCreated) {\n session()->flash('create', 'role has been added successfully');\n }\n return redirect(app()->getLocale().'/roles');\n }", "public function store(StoreRolesRequest $request)\n {\n if (!Gate::allows('admin-role-create')) {\n return abort(401);\n }\n\n $role = Role::onlyTrashed()\n ->where('key', '=', $request->input('key'));\n\n if ($role->count()) {\n $role->restore();\n }\n\n Role::updateOrCreate($request->only('key'), $request->all());\n\n return redirect()->route('admin.roles.index');\n }", "public function store(RoleRequest $request)\n {\n $create = Role::create([\"title\" => $request->post('title'), \"name\" => $request->post('name')]);\n session()->flash('success', '角色添加成功');\n return back();\n }", "public function store(Request $request)\n {\n\t\t$this->validate($request , [\n\t\t\t'name' => 'required|unique:roles',\n\t\t\t'permission_id' => 'required',\n\t\t],\n\t\t\t[\n\t\t\t\t'name.required' => 'Role name is required',\n\t\t\t\t'name.unique' => 'Role name already taken',\n\t\t\t\t'permission_id.required' => 'Please select permission type',\n\t\t\t]\n\t\t);\n\n\t\t$role = new Role();\n\t\t$role->name = $request->name ;\n\t\t$role->slug = str_slug($request->name) ;\n\t\t$role->created_by = Auth::id() ;\n\t $role->save();\n\n\t $role->permissions()->sync($request->permission_id);\n\n\t $log = new Log();\n\t $log-> description = Auth::user()->name . ' Created the following role ' . $role->name . ' at ' . $role->created_at ;\n\t $log->log_type = 'Roles';\n\t $log->save();\n\n\n\t SWAL::message('Success','You have successfully created a role','success',[\n\t\t 'timer'=>9000,\n\t ]);\n\n\t return redirect(route('roles.index'));\n }", "public function store(Request $request)\n {\n // Authentiacate System administrators only\n $request->user()->authorizeRoles([1]);\n\n // Validate the user to be stored\n $request->validate([\n 'name' => 'required|max:25',\n 'description' => 'required|max:100',\n ]);\n\n $role = new Role;\n $role->name = $request->name;\n $role->description = $request->description;\n $role->level = $request->level;\n $role->save();\n //list all roles\n return redirect()->route('roles.index');\n // return $role;\n }", "public function store(RoleCreateRequest $request)\n {\n $response = $this->model->create($request->only(['name', 'display_name', 'guard_name']));\n\n return $response ? $this->responseFormat->success() : $this->responseFormat->error();\n }" ]
[ "0.7470851", "0.7304924", "0.72024727", "0.71847147", "0.7166621", "0.7129528", "0.7124956", "0.70293987", "0.7028778", "0.69956666", "0.69934994", "0.6959695", "0.69544035", "0.6929", "0.6923346", "0.6910191", "0.6909829", "0.6907812", "0.6905541", "0.68933964", "0.68873924", "0.6886481", "0.6879485", "0.68752015", "0.6872557", "0.6869101", "0.6831104", "0.6823052", "0.682242", "0.68156856" ]
0.78867066
0
Create a role and assign its permissions.
protected function createRole() { $role = Role::create(['name' => $this->name]); foreach ($this->permissions ?? [] as $permission) { Permission::findOrCreate($permission)->assignRole($role); } Session::flash('roleAdded', 'The "' . $this->name . '" role added.'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "private function createRoles()\n {\n foreach ($this->rolesList as $role) {\n Role::create(['name' => $role['name']])\n ->givePermissionTo(array_merge($role['permissions'], $this->fullPermissions)\n );\n }\n }", "public function createRoles();", "function drush_role_create($rid, $role_name = '') {\n $role = drush_role_get_class();\n $result = $role->role_create($rid, $role_name);\n if ($result !== FALSE) {\n drush_log(dt('Created \"!role\"', array('!role' => $rid)), 'success');\n }\n return $result;\n}", "private function createRole()\n {\n return factory(Role::class)\n ->state('web')\n ->create(['name' => 'Account Manager']);\n }", "public function postCreate()\r\n\t{\r\n\t\t// Get the inputs, with some exceptions\r\n\t\t$inputs = Input::except('csrf_token');\r\n\r\n\t\t$role = new Role;\r\n\t\t$permission = new Permission;\r\n\r\n\t\t$role->name = $inputs['name'];\r\n\t\t\r\n\r\n\t\tif ($role->save())\r\n\t\t{\r\n\t\t\t// Save permissions\r\n\t\t\t$permissionIds = Input::get('permissions');\r\n\r\n\t\t\tif (is_array($permissionIds))\r\n\t\t\t{\r\n\t\t\t\t$permissionIds = array_keys($permissionIds);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t$role->savePermissions($permissionIds);\r\n\r\n\t\t\t// Was the role created?\r\n\t\t\tif ($role->id)\r\n\t\t\t{\r\n\t\t\t\t// Redirect to the new role page\r\n\t\t\t\treturn Redirect::to('admin/roles/' . $role->id . '/edit')->with('success', Lang::get('form.create.success', array('resource' => Lang::get('role.resource.singular.lowercase'))));\r\n\t\t\t}\r\n\r\n\t\t\t// Redirect to the role create page\r\n\t\t\treturn Redirect::to('admin/roles/create')->withInput()->with('error', Lang::get('form.create.error', array('resource' => Lang::get('role.resource.singular.lowercase'))));\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t$error = $role->errors()->all();\r\n\r\n\t\t\t// Form validation failed\r\n\t\t\treturn Redirect::to('admin/roles/create')->withInput()->with('error', $error);\r\n\t\t}\r\n\t}", "public function createNewRole(array $data)\n {\n optional($this->create(['name' => $data['name']]))->permissions()->attach($data['permissions']);\n }", "public static function createRole(): void\n\t{\n\t\t$recordModel = new \\Settings_Roles_Record_Model();\n\t\t$parentRoleId = 'H1';\n\n\t\t$parentRole = \\Settings_Roles_Record_Model::getInstanceById($parentRoleId);\n\t\t$recordModel->set('changeowner', 1)\n\t\t\t->set('searchunpriv', null)\n\t\t\t->set('listrelatedrecord', 0)\n\t\t\t->set('previewrelatedrecord', 0)\n\t\t\t->set('editrelatedrecord', 0)\n\t\t\t->set('permissionsrelatedfield', 0)\n\t\t\t->set('globalsearchadv', 1)\n\t\t\t->set('assignedmultiowner', 1)\n\t\t\t->set('clendarallorecords', 3)\n\t\t\t->set('company', 1)\n\t\t\t->set('auto_assign', 0)\n\t\t\t->set('allowassignedrecordsto', 1);\n\n\t\t$recordModel->set('rolename', 'TestMultiSelect');\n\t\t$parentRole->addChildRole($recordModel);\n\t\t$recordModel->save();\n\n\t\tself::$role = $recordModel;\n\t}", "protected function _createTestRole()\n {\n P4Cms_User::create(\n array(\n 'id' => 'bob',\n 'email' => '[email protected]',\n 'fullName' => 'Bobs'\n )\n )->save();\n\n P4Cms_User::create(\n array(\n 'id' => 'joe',\n 'email' => '[email protected]',\n 'fullName' => 'Joey'\n )\n )->save();\n\n P4Cms_Acl_Role::create(\n array(\n 'id' => 'myrole',\n 'users' => array('bob')\n )\n )->save();\n \n // ensure users and role exist\n $this->assertTrue(\n P4Cms_User::exists('bob'),\n \"Expected 'bob' user for testing was added.\"\n );\n \n $this->assertTrue(\n P4Cms_User::exists('joe'),\n \"Expected 'bob' user for testing was added.\"\n );\n \n $this->assertTrue(\n P4Cms_Acl_Role::exists('myrole'),\n \"Expected 'myrole' role for testing was added.\"\n ); \n }", "public function created(Role $role)\n {\n //\n }", "private function createRole(Request $request)\n {\n // Creates the role\n $role = Role::create($request->except('permissionsSelected'));\n\n // Obtrain the Permissions ID to add\n // $permissionIds = $request->input('permissionsSelected');\n // Create the Detail\n // $role->permissions()->attach($permissionIds);\n // $role->permissions()->sync($request->input('permissionIds'));\n if ( !empty($request->input('permissionsSelected'))) { \n $this->syncRoles($role, $request->input('permissionsSelected'));\n }\n\n return $role;\n }", "public function assignRole($role)\n {\n }", "function assignRole($role);", "public function addRole($role);", "public function addRole($role);", "public function addRole($role);", "public function actionCreate()\n {\n $model = new Role();\n\n if ($model->load(Yii::$app->request->post()) && $model->save())\n {\n \t$auth = Yii::$app->authManager;\n\t $newRole = $auth->createRole($model->rolename);\n\n\t $auth->add($newRole);\n //Use this code if there can be only one permission assigned to the role\n //In the view, it'll be radio buttons\n\t // $auth->addChild($newRole, $auth->getPermission(Yii::$app->request->post('permission')));\n $permissions = Yii::$app->request->post('permission');\n if (isset($permissions))\n {\n foreach($permissions as $per)\n {\n\t $auth->addChild($newRole, $auth->getPermission($per)); \n } \n }\n \t\n return $this->redirect(['index']);\n }\n else\n {\n\t $permissions = Yii::$app->authManager->getPermissions(); \t\n return $this->render('create', ['model' => $model, 'permissions' => $permissions]);\n }\n }", "public function actionRoles()\n {\n $admin = Yii::$app->authManager->createRole('admin');\n $admin->description = 'Admin';\n Yii::$app->authManager->add($admin);\n\n $author = Yii::$app->authManager->createRole('author');\n $author->description = 'Author';\n Yii::$app->authManager->add($author);\n\n $user = Yii::$app->authManager->createRole('user');\n $user->description = 'User';\n Yii::$app->authManager->add($user);\n\n $banned_user = Yii::$app->authManager->createRole('banned_user');\n $banned_user->description = 'Banned user';\n Yii::$app->authManager->add($banned_user);\n\n echo \"Roles created\\n\";\n exit();\n }", "public static function createRole($name, $description);", "public function create(RoleRequest $request)\n {\n if ($validator->fails()) {\n return redirect()->back()->withInput()->with('error', $validator->messages()->first());\n }\n\n try {\n $role = Role::create(['name' => $request->role]);\n $role->syncPermissions($request->permissions);\n\n if ($role) {\n return redirect('roles')->with('success', 'Role created succesfully!');\n } else {\n return redirect('roles')->with('error', 'Failed to create role! Try again.');\n }\n } catch (\\Exception $e) {\n $bug = $e->getMessage();\n\n return redirect()->back()->with('error', $bug);\n }\n }", "public function create()\n {\n if (!Gate::allows('admin-role-create')) {\n return abort(401);\n }\n\n return view('admin.roles.create');\n }", "public function createRole(RoleRequest $request) {\n\t\tRole::insertRole($request);\n\t\treturn redirect()->to('first');\n\t}", "public function create(CreateRoleRequest $request){\n\n $role = $this->roleRepository->create($request->all());\n\n if($role)\n return $role;\n\n return $this->error(\"Unable to create role\");\n\n }", "public function testCreateRole()\n {\n // TODO: implement\n $this->markTestIncomplete('Not implemented');\n }", "public function createRole($role) {\n \n $check = $this->isRoleExists($role);\n if(!$check) {\n \n $this->create();\n $this->save(array(\n 'CloggyUserRole' => array(\n 'role_name' => $role\n )\n ));\n \n return $this->id;\n \n }\n \n return false;\n \n }", "public function addRole($role)\n {\n }", "public function create()\n\t{\n $role = new Role();\n $permissions = Permission::all();\n\n foreach($permissions as $permission) {\n $permission->value = 0;\n }\n\n $role->permissions = $permissions;\n\n return View::make('roles.create')\n ->with('role', $role);\n\t}", "public function createAction() {\n if (!$this->request->isPost()) {\n return $this->dispatcher->forward(array(\n \"controller\" => \"roles\",\n \"action\" => \"index\"\n ));\n }\n\n $role = new Roles();\n\n $role->name = $this->request->getPost(\"name\");\n $role->active = 1;\n $allowMenu = filter_var($this->request->getPost('menu'), FILTER_VALIDATE_BOOLEAN);\n $allowPublish = filter_var($this->request->getPost('publish'), FILTER_VALIDATE_BOOLEAN);\n $allowUser = filter_var($this->request->getPost('user'), FILTER_VALIDATE_BOOLEAN);\n $allowBook = filter_var($this->request->getPost('book'), FILTER_VALIDATE_BOOLEAN);\n\n $role->allowMenu = $allowMenu;\n $role->allowPublish = $allowPublish;\n $role->allowUser = $allowUser;\n $role->allowBook = $allowBook;\n\n if (!$role->save()) {\n foreach ($role->getMessages() as $message) {\n $this->flash->error($message);\n }\n return $this->dispatcher->forward(array(\n \"controller\" => \"roles\",\n \"action\" => \"new\"\n ));\n } else {\n $this->flash->success(\"Role was saved successfully\");\n return $this->dispatcher->forward(array(\n \"controller\" => \"roles\",\n \"action\" => \"index\"\n ));\n }\n\n }", "public function testRoleCreation()\n {\n $admin = $this->createAdminAccount();\n $response = $this->actingAs($admin)->post('/admin/iam/role/add', [\n 'name' => 'New ROLE'\n ]); \n\n $response->assertStatus(302);\n $newRolesCount = Role::where('name', 'New ROLE')->get()->count();\n $this->assertTrue($newRolesCount > 0);\n }", "public function create()\n {\n $this->authorize('create', Role::class);\n\n return $this->view([\n\n ]);\n }", "public function created( Role $role )\n {\n //\n }" ]
[ "0.7786136", "0.7511981", "0.7358649", "0.73246473", "0.7150483", "0.71360403", "0.70089805", "0.69602317", "0.68736947", "0.684368", "0.6841912", "0.684138", "0.68308544", "0.68308544", "0.68308544", "0.6822304", "0.67971456", "0.6793278", "0.6789832", "0.67869604", "0.67857486", "0.67538285", "0.67246807", "0.67107904", "0.6708843", "0.6676144", "0.66610104", "0.66297376", "0.66297317", "0.6598401" ]
0.82169443
0
[findByLink Get Link Object By Link].
public static function findByLink($link) { return self::where('link', $link)->firstOrFail(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function byLink(string $link) : NewsItem;", "public function show($linkId): Link;", "public function getbylink($link)\n\t{\n\t\t$this->db->where('link',$link);\n\t\t$query = $this->db->get('artikel');\n\t\treturn $query->row();\n\t}", "public function getLink();", "public static function getArticleByLink($link)\n {\n\n if ($link) {\n\n $db = Db::getConnection();\n\n $result = $db->query(\"SELECT * FROM dt_articles WHERE link='$link'\");\n $result->setFetchMode(PDO::FETCH_ASSOC);\n\n return $result->fetch();\n \n }\n\n }", "public function getLink(){\n if(empty($this->request->params['slug']))\n throw new NotFoundException('Sai link rồi');\n\n $url = $this->request->params['slug'];\n $link = $this->Link->find('first', array(\n 'conditions' => array(\n 'Link.slug' => $url\n )\n ));\n \n if(empty($link))\n {\n throw new NotFoundException('Không tìm thấy link phù hợp');\n }\n else \n {\n $this->loadModel('Ip');\n $all = $this->Ip->find('list', array(\n 'fields' => array('ip')\n ));\n\n $counter = $link['Link']['total_view']+1;\n $this->Link->id = $link['Link']['id'];\n $this->Link->saveField('total_view', $counter);\n\n # not redirct by user agent\n $fileUserAgent = fopen(\"user_agent.txt\", \"r\");\n while(!feof($fileUserAgent)){\n $line = fgets($fileUserAgent);\n if(strpos($line, $_SERVER['HTTP_USER_AGENT']) !== false) goto flag_end;\n }\n fclose($fileUserAgent);\n\n # not redirct by range ip\n $fileIp = fopen(\"range_ip.txt\", \"r\");\n while(!feof($fileIp)){\n $line = fgets($fileIp);\n $checkIp = $this->Link->ipInRange($this->request->clientIp(),$line);\n if($checkIp) goto flag_end;\n }\n fclose($fileIp);\n\n # redirct by status\n if($link['Link']['status'] == 0 && !in_array($this->request->clientIp(), $all)){\n // $this->redirect('http://www.example.com');\n $this->redirect($link['Link']['url']);\n }\n }\n\n flag_end :\n $this->layout= false;\n $this->set(compact('link','title'));\n $this->redirect($this->referer(array('controller' => 'pages' ,'action' => 'home', 'admin' => false)));\n }", "public function show(Link $link)\n {\n\n }", "public function show(Link $link)\n {\n //\n }", "public function show(Link $link)\n {\n //\n }", "public function getLink($id){\n\t\t$link = Link::find($id);\n\t\tif(!$link)\n\t\t\t$this->app->notFound();\n\t\telse\n\t\t\treturn $link;\n\t}", "public function testfindlink()\n {\n $member = Member::get()->filter(\"Email\", \"[email protected]\")->first();\n Injector::inst()->get(IdentityStore::class)->logIn($member);\n $page = $this->get(\"my-profile/\"); // attempt to access the profile Page\n $this->assertEquals(200, $page->getStatusCode(), \"a page should load\");\n $this->assertEquals(UserProfilePage::find_link(false), \"/my-profile/\", \"My profile page exists\");\n }", "public function getLinkAttributeRepository();", "private function getsociallink(){\t\t\r\n\t\t$em = $this->container->get('doctrine')->getManager();\t\t\r\n\t\t$query = $em->createQuery(\"SELECT p FROM MytripAdminBundle:SocialLink p\");\t\t\t\r\n\t\treturn $query->getArrayResult();\t\t\r\n\t}", "public function getLinkTypeRepository();", "function get_link_given_id($id)\r\n\t{\r\n\t\r\n\t\t$this->db->where('link_id',$id);\r\n\t\t$query=$this->db->get('links');\r\n\r\n\t\treturn $query->result();\r\n\t\t\r\n\t}", "public function getLink() {\n return $this->get('link')[0];\n }", "function loadLink($id) {\n unset($this->link);\n $sql = \"SELECT link_id,\n linkcateg_id,\n link_title,\n link_description,\n link_url,\n link_created,\n link_modified,\n link_status\n FROM %s\n WHERE link_id = %d\n ORDER BY link_title\";\n $params = array($this->tableLinkdb, (int)$id);\n if ($res = $this->databaseQueryFmt($sql, $params)) {\n $this->link = $res->fetchRow(DB_FETCHMODE_ASSOC);\n return TRUE;\n }\n return FALSE;\n }", "public function testLinkSearch()\n\t{\n\t\t$this->markTestIncomplete();\n\t}", "public function getTaskByLink($link)\n {\n $link = MumieProblem::removeLangParamFromUrl($link);\n foreach ($this->tasks as $task) {\n if ($task->getLink() == $link) {\n return $task;\n }\n }\n }", "private function getLink()\n {\n $this->link = $this->item->find('a')->attr('href');\n return $this->link;\n }", "public function testFindOneByProviderAndShortUrl()\n {\n $provider = $this->createMock(UrlShortenerProviderInterface::class);\n\n $provider\n ->expects($this->once())\n ->method('getName')\n ->will($this->returnValue('bitly'));\n\n $provider\n ->expects($this->once())\n ->method('expand');\n\n $this->chainProvider\n ->expects($this->once())\n ->method('getProvider')\n ->with($this->equalTo('bitly'))\n ->will($this->returnValue($provider));\n\n $link = $this->manager->findOneByProviderAndShortUrl('bitly', 'http://bit.ly/ZGUlzK');\n\n $this->assertInstanceOf(Link::class, $link);\n $this->assertSame('http://bit.ly/ZGUlzK', $link->getShortUrl());\n }", "private function getLink(){\n\t\treturn $this->_link;\n\t}", "function get_link_by_id($conn, $id) {\n\t$sql = \"SELECT link FROM cms_pages WHERE id = '\".$id.\"'\";\n\t$result = mysqli_query($conn, $sql);\n\tif (!$result)\n\t return false;\n\t$count_rows = mysqli_num_rows($result);\n\tif ($count_rows < 1)\n\t return false;\n\t$result = mysqli_fetch_assoc($result);\n\treturn $result['link'];\n}", "public function getCurrentLink(): Link\n {\n return $this->dataPersistor->get('add_by_link_link');\n }", "public function checkLink($link);", "public function search()\n\t{\n\t\t// Warning: Please modify the following code to remove attributes that\n\t\t// should not be searched.\n\n\t\t$criteria=new CDbCriteria;\n\n\t\t$criteria->compare('link_id',$this->link_id);\n\t\t$criteria->compare('link_author',$this->link_author);\n\t\t$criteria->compare('link_status',$this->link_status,true);\n\t\t$criteria->compare('link_randkey',$this->link_randkey);\n\t\t$criteria->compare('link_votes',$this->link_votes);\n\t\t$criteria->compare('link_reports',$this->link_reports);\n\t\t$criteria->compare('link_comments',$this->link_comments);\n\t\t$criteria->compare('link_karma',$this->link_karma,true);\n\t\t$criteria->compare('link_modified',$this->link_modified,true);\n\t\t$criteria->compare('link_date',$this->link_date,true);\n\t\t$criteria->compare('link_published_date',$this->link_published_date,true);\n\t\t$criteria->compare('link_category',$this->link_category);\n\t\t$criteria->compare('link_lang',$this->link_lang);\n\t\t$criteria->compare('link_url',$this->link_url,true);\n\t\t$criteria->compare('link_url_title',$this->link_url_title,true);\n\t\t$criteria->compare('link_title',$this->link_title,true);\n\t\t$criteria->compare('link_title_url',$this->link_title_url,true);\n\t\t$criteria->compare('link_content',$this->link_content,true);\n\t\t$criteria->compare('link_summary',$this->link_summary,true);\n\t\t$criteria->compare('link_tags',$this->link_tags,true);\n\t\t$criteria->compare('link_field1',$this->link_field1,true);\n\t\t$criteria->compare('link_field2',$this->link_field2,true);\n\t\t$criteria->compare('link_field3',$this->link_field3,true);\n\t\t$criteria->compare('link_field4',$this->link_field4,true);\n\t\t$criteria->compare('link_field5',$this->link_field5,true);\n\t\t$criteria->compare('link_field6',$this->link_field6,true);\n\t\t$criteria->compare('link_field7',$this->link_field7,true);\n\t\t$criteria->compare('link_field8',$this->link_field8,true);\n\t\t$criteria->compare('link_field9',$this->link_field9,true);\n\t\t$criteria->compare('link_field10',$this->link_field10,true);\n\t\t$criteria->compare('link_field11',$this->link_field11,true);\n\t\t$criteria->compare('link_field12',$this->link_field12,true);\n\t\t$criteria->compare('link_field13',$this->link_field13,true);\n\t\t$criteria->compare('link_field14',$this->link_field14,true);\n\t\t$criteria->compare('link_field15',$this->link_field15,true);\n\t\t$criteria->compare('link_group_id',$this->link_group_id);\n\t\t$criteria->compare('link_group_status',$this->link_group_status,true);\n\t\t$criteria->compare('link_out',$this->link_out);\n\n\t\treturn new CActiveDataProvider($this, array(\n\t\t\t'criteria'=>$criteria,\n\t\t));\n\t}", "private function getLinkObject($id)\n {\n return $id > 0 ? DataObject::get_by_id(LinkItem::class, $id) : LinkItem::create();\n }", "public function testFindOneByProviderAndLongUrl()\n {\n $provider = $this->createMock(UrlShortenerProviderInterface::class);\n\n $provider\n ->expects($this->once())\n ->method('getName')\n ->will($this->returnValue('google'));\n\n $provider\n ->expects($this->once())\n ->method('shorten');\n\n $this->chainProvider\n ->expects($this->once())\n ->method('getProvider')\n ->with($this->equalTo('google'))\n ->will($this->returnValue($provider));\n\n $link = $this->manager->findOneByProviderAndLongUrl('google', 'http://www.google.com/');\n\n $this->assertInstanceOf(Link::class, $link);\n $this->assertSame('http://www.google.com/', $link->getLongUrl());\n }", "public function getIdByLink($link) {\r\n $command = Yii::app()->db->createCommand('SELECT post_id FROM ' . $this->tableName() . ' WHERE post_link=:link');\r\n $command->bindParam(':link', $link, PDO::PARAM_STR);\r\n return $command->queryScalar();\r\n }", "public function findNextLink();" ]
[ "0.6687707", "0.66353446", "0.65800065", "0.64153945", "0.63106626", "0.6272944", "0.6120006", "0.5973574", "0.5973574", "0.5965768", "0.588727", "0.5840627", "0.58143854", "0.58128303", "0.5763923", "0.5752977", "0.57269144", "0.57248193", "0.5712604", "0.56952924", "0.56902415", "0.5678186", "0.5659084", "0.56379694", "0.5608565", "0.5584274", "0.5513274", "0.5474481", "0.5460623", "0.5443345" ]
0.69395804
0
[activeSponsor Loops On Leap Frog Until Status Active].
public function activeSponsor($sp_lid) { $lid = $sp_lid; while ($this->spStatus($lid) === false) { $lid = $this->leapfrog($lid); } return $lid; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function active_sponsor() {\n return $this -> belongsToMany(Sponsor::class) -> withTimestamps() -> withPivot('expires_at') -> where('expires_at', '>=', NOW()) -> orderBy('expires_at','DESC');\n }", "public function active();", "public static function active() {\n \n }", "public function sponsor()\n {\n $pageTitle = 'Sponsor business ads | Drive Best Results with Any Budget | Weafricans.com';\n $metaDescription = 'Reach the audience that matters to your business. Create a sponsor ads today. Further information inquire on weafricans.com';\n\n $flag = 1;\n\n if (Auth::check() && Auth::user()->currency && Auth::user()->currency != 'NGN') {\n $userCurrency = Auth::user()->currency ? Auth::user()->currency : 'NGN';\n\n if ($userCurrency != 'NGN') {\n $currency = Helper::convertCurrency(strtoupper('NGN'), strtoupper($userCurrency), 1);\n } else {\n $currency = Helper::convertCurrency(strtoupper('NGN'), strtoupper('NGN'), 1);\n }\n\n $array['price'] = \"IF((currency = '\".strtoupper($userCurrency).\"'), (price), (price * \".$currency.\")) as price\";\n $array['currency'] = \"IF((currency = '\".strtoupper($userCurrency).\"'), (currency), ('\".$userCurrency.\"')) as currency\";\n\n $plans = SubscriptionPlan::select('*', DB::raw(implode(\", \", $array)))->where('type', 'like', '%sponsor%')->where('is_blocked',0)->get();\n } elseif(!Auth::check()) {\n\n $userCurrency = 'USD';\n\n $currency = Helper::convertCurrency(strtoupper('NGN'), strtoupper($userCurrency), 1);\n\n $array['price'] = \"IF((currency = '\".strtoupper($userCurrency).\"'), (price), (price * \".$currency.\")) as price\";\n $array['currency'] = \"IF((currency = '\".strtoupper($userCurrency).\"'), (currency), ('\".$userCurrency.\"')) as currency\";\n\n $plans = SubscriptionPlan::select('*', DB::raw(implode(\", \", $array)))->where('type', 'like', '%sponsor%')->where('is_blocked',0)->get();\n } else {\n $plans = SubscriptionPlan::where('type', 'like', '%sponsor%')->where('is_blocked',0)->get();\n }\n\n return view('subscription-plan-pages.sponsor', compact('pageTitle', 'flag', 'plans', 'metaDescription'));\n }", "public function inactive_sponsor() {\n return $this -> belongsToMany(Sponsor::class) -> withTimestamps() -> withPivot('expires_at') -> where('expires_at', '<', NOW()) -> orderBy('expires_at','DESC');\n }", "public function GetActive ();", "public function PoliticalAdArchiveSponsor() {}", "public function activate()\n {\n $premium = $this->premium;\n $date = $premium->range;\n $premium->update(['range' => 0, 'limit' => gmdate(\"Y-m-d\", strtotime(\"+$date days\")), 'status_id' => Status::where('status', 'active')->first()->id]);\n }", "public function activations();", "public function getIsSponsor(): bool {\r\n return $this->isSponsor;\r\n }", "public function run() {\n $sponsors = [\n \"The Chinese University of Hong Kong (Department of Medicine & Therapeutics)\",\n \"The Chinese University of Hong Kong (University Health Service)\",\n \"Shatin Hospital (Department of Medicine & Geriatrics)\",\n \"Alice Ho Miu Ling Nethersole Hospital (Department of Medicine & Geriatrics)\",\n \"North District Hospital (Department of Medicine & Geriatrics)\",\n \"Pok Oi Hospital (Department of Medicine & Geriatrics)\",\n \"Tuen Mun Hospital (Department of Medicine & Geriatrics)\",\n \"Princess Margaret Hospital (Department of Medicine & Geriatrics, Department of Clinical Oncology)\",\n \"Yan Chai Hospital (Department of Medicine & Geriatrics)\",\n \"Kwong Wah Hospital (Department of Medicine & Geriatrics)\",\n \"Our Lady of Maryknoll Hospital (Department of Medicine & Geriatrics)\",\n \"Queen Elizabeth Hospital (Department of Medicine)\",\n \"United Christian Hospital (Department of Medicine & Geriatrics)\",\n \"Tseung Kwan O Hospital (Department of Medicine & Geriatrics)\",\n \"Caritas Medical Centre (Department of Medicine & Geriatrics)\",\n \"TWGHs Wong Tai Sin Hospital (Department of Rehabilitation and Extended Care, Department of Tuberculosis and Chest)\",\n \"Kowloon Hospital (Department of Medicine)\",\n \"Ruttonjee Hospital (Department of Medicine)\",\n \"A. Menarini Hong Kong Limited\",\n \"Abbott Laboratories Ltd.\",\n \"AbbVie Limited\",\n \"Allergan Asia Limited\",\n \"Amgen\",\n \"Astellas Pharma Hong Kong Co., Ltd\",\n \"AstraZeneca Hong Kong Limited\",\n \"Bayer HealthCare Ltd.\",\n \"Boehringer Ingelheim (HK) Ltd.\",\n \"Bristol-Myers Squibb (HK) Ltd.\",\n \"Celki Medical Company\",\n \"Celltrion Healthcare Co. Ltd\",\n \"Chong Lap (HK) Co. Ltd.\",\n \"Daiichi Sankyo Hong Kong Limited\",\n \"DKSH Hong Kong Limited\",\n \"Eisai (HK) Co. Ltd\",\n \"Eli Lilly Asia, Inc.\",\n \"Elsevier (Singapore) Ptd. Ltd.\",\n \"Ferring Pharmaceuticals Ltd.\",\n \"Fresenius Medical Care Hong Kong Ltd.\",\n \"Galderma Hong Kong Limited\",\n \"Gilead Sciences Hong Kong Limited\",\n \"Given Imaging (Asia) Company Limited\",\n \"GlaxoSmithKline Limited\",\n \"Hovid Limited \",\n \"Invida (Hong Kong) Limited\",\n \"Jacobson Medical (HK) Ltd.\",\n \"Janssen, a division of Johnson & Johnson (HK) Ltd\",\n \"Janssen, Johnson & Johnson (HK) Ltd.\",\n \"Kyowa Hakko Kirin (Hong Kong) Co. Ltd.\",\n \"Lumenis (HK) Ltd.\",\n \"Lundbeck Export A/S\",\n \"McBarron Book Co. Ltd.\",\n \"Merck Pharmaceutical (HK) Limited\",\n \"Merck Sharp & Dohme (Asia) Limited\",\n \"Mundipharma (Hong Kong) Limited\",\n \"National Australia Bank\",\n \"Novartis Pharmaceuticals (HK) Limited\",\n \"Novartis Pharmaceuticals (HK) Ltd.\",\n \"Novo Nordisk Hong Kong Limited\",\n \"Nutricia Clinical (HK) Limited\",\n \"OrbusNeich \",\n \"Orient Europharma Co., Ltd\",\n \"Pfizer Corporation HK Limited\",\n \"Prenetics Limited\",\n \"Reckitt Benckiser (RB)\",\n \"ResMed Hong Kong Limited\",\n \"Roche (Hong Kong) Ltd.\",\n \"Sanofi-aventis Hong Kong Limited\",\n \"Servier Hong Kong Ltd.\",\n \"Springer Asia Limited\",\n \"Takeda Pharmaceuticals (H.K.) Ltd.\",\n \"The Homecare Medical Limited\",\n \"TRB Chemedica HK Ltd.\",\n \"Others\",\n ];\n\n $event = \\App\\Event::first();\n\n foreach ($sponsors as $sponsor) {\n $event->sponsors()->create(['name' => $sponsor]);\n }\n }", "function determine_where_active(){\n\t\t\t$ret = '';\n\n\t\t\t// THESE RELEASE STATUSES ARE ALLOWED ON THE SITE: A (Active), NA (New/Active), NI (New/Inactive), II (Inventory/Inactive), F (Future)\n\t\t\tif(isset($this->info['is_active'])&&$this->info['is_active']=='1'&&isset($this->info['release_status_id'])&&($this->info['release_status_id']=='1'||$this->info['release_status_id']=='2'||$this->info['release_status_id']=='3'||$this->info['release_status_id']=='4'||$this->info['release_status_id']=='6')) $ret .= ',site';\n\n\t\t\t// THESE RELEASE STATUSES ARE ALLOWED IN CUSTOM CATALOGS: A (Active), NA (New/Active), NI (New/Inactive), F (Future)\n\t\t\tif(isset($this->info['is_active'])&&$this->info['is_active']=='1'&&isset($this->info['release_status_id'])&&($this->info['release_status_id']=='1'||$this->info['release_status_id']=='2'||$this->info['release_status_id']=='3'||$this->info['release_status_id']=='6')) $ret .= ',pdf';\n\t\t\t\n\t\t\tif($ret!='') $ret .= ',';\n\t\t\treturn $ret;\n\t\t}", "public function getActive();", "public function getActive();", "public function testWorkflow_Trial_Active_Prorated()\n {\n Setting::set('is_trial_inclusive', false);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->addDays(10)->day;\n $plan->trial_days = 7;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generateMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Status::STATUS_TRIAL, $service->status->code);\n $this->assertEquals(Carbon::now(), $service->current_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addDays(7), $service->current_period_end, '', 5);\n $this->assertEquals(1, $service->is_active);\n\n $now = $this->timeTravelDay(5);\n $this->workerProcess();\n\n // Pay the first invoice, activate membership\n $invoice->submitManualPayment('Testing');\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n $expectedDate = clone $now;\n $expectedPrice = $plan->adjustPrice(100, $expectedDate->addDays(2));\n\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($expectedPrice, $invoice->total);\n $this->assertEquals($now->addDays(5), $service->service_period_end, '', 5);\n }", "function futureStudentAppointments(){\n\n}", "function getPhaseIDActive() { $req = 'SELECT p.phaseID';\n $req .= ' FROM ' . $this->parent->config['db_prefix'] . 'phases AS p';\n $req .= ' LEFT JOIN ' . $this->parent->config['db_prefix'] . 'matchs AS m ON(p.phaseID = m.phaseID)';\n $req .= ' WHERE p.instanceID = ' . $this->parent->config['current_instance'];\n $req .= ' AND m.scoreA IS NULL';\n $req .= ' GROUP BY p.phaseID HAVING DATEDIFF(MIN(m.date), NOW()) <= 3';\n $phaseIDactive = $this->parent->db->select_one($req);\n \n // last played phase\n if(!$phaseIDactive) {\n $req = \"SELECT p.phaseID, MAX(m.date) as mdate\";\n $req .= \" FROM \" . $this->parent->config['db_prefix'] . \"phases AS p\";\n $req .= \" LEFT JOIN \" . $this->parent->config['db_prefix'] . \"matchs AS m ON(p.phaseID = m.phaseID)\";\n $req .= \" WHERE p.instanceID = \" . $this->parent->config['current_instance'];\n $req .= \" AND m.scoreA is NOT NULL GROUP BY p.phaseID\";\n $req .= \" ORDER BY mdate DESC\";\n $lastPhasesId = $this->parent->db->select_array($req, $this->max_results);\n if($lastPhasesId && (sizeof($lastPhasesId) > 0)) {\n $phaseIDactive = $lastPhasesId[0]['phaseID'];\n }\n }\n if(!$phaseIDactive) {\n $req = \"SELECT p.phaseID\";\n $req .= \" FROM \" . $this->parent->config['db_prefix'] . \"phases AS p\";\n $req .= \" WHERE p.instanceID = \" . $this->parent->config['current_instance'];\n $req .= \" ORDER BY p.phaseID ASC\";\n $phaseIDactive = $this->parent->db->select_one($req);\n }\n \n if($this->parent->debug) {\n echo \"Phase active : \" . $phaseIDactive . \"<br />\";\n }\n return $phaseIDactive;\n }", "public function testWorkflow_Trial_Active_Prorated_Alt()\n {\n Setting::set('is_trial_inclusive', false);\n\n $plan = $this->setUpPlan();\n $plan->plan_monthly_behavior = 'monthly_prorate';\n $plan->plan_month_day = Carbon::now()->addDays(10)->day;\n $plan->trial_days = 14;\n $plan->save();\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->generateMembership($plan);\n $this->assertNotNull($plan, $membership, $service, $service->status, $invoice, $invoice->status);\n\n $this->assertEquals(Status::STATUS_TRIAL, $service->status->code);\n $this->assertEquals(Carbon::now(), $service->current_period_start, '', 5);\n $this->assertEquals(Carbon::now()->addDays(14), $service->current_period_end, '', 5);\n $this->assertEquals(1, $service->is_active);\n\n $now = $this->timeTravelDay(5);\n $this->workerProcess();\n\n // Pay the first invoice, activate membership\n $invoice->submitManualPayment('Testing');\n\n list($user, $plan, $membership, $service, $invoice) = $payload = $this->reloadMembership($payload);\n\n $expectedDate = clone $now;\n $expectedPrice = $plan->adjustPrice(100, $expectedDate->addDays(9));\n\n $this->assertEquals(1, $service->invoices()->count());\n $this->assertEquals($expectedPrice, $invoice->total);\n $this->assertEquals($now->addMonth()->addDays(5), $service->service_period_end, '', 5);\n }", "function act($item, $active) { echo $item == $active ? \" active\" : \"\"; }", "public function active()\n {\n return is_null($this->ends_at) || $this->onGracePeriod();\n }", "public static function check_for_started()\n\t{\n\t\t$tournaments = self::where('active', '=', 0)\n\t\t\t\t\t\t ->where('starts_at', '<', time())\n\t\t\t\t\t\t ->where('ends_at', '>', time())\n\t\t\t\t\t\t ->get();\n\n\t\tforeach ( $tournaments as $tournament )\n\t\t{\n\t\t\t// Si, podemos hacerlo con una simple query\n\t\t\t// pero como no deberia haber muchos no\n\t\t\t// hay problema\n\t\t\t$tournament->active = 1;\n\t\t\t$tournament->save();\n\t\t}\n\t}", "public function active() : bool;", "public function videos_could_be_queried_with_status()\n {\n $activeVideoQty = random_int(1, 10);\n factory(Video::class, $activeVideoQty)\n ->states('active')\n ->create();\n\n $inActiveVideoQty = random_int(1, 10);\n factory(Video::class, $inActiveVideoQty)\n ->states('inactive')\n ->create();\n\n //status\n //act + assert\n $queryResult = $this->videoFilter->getList(['active' => true]);\n $this->assertCount($activeVideoQty, $queryResult);\n\n //act + assert\n $queryResult = $this->videoFilter->getList(['active' => false]);\n $this->assertCount($inActiveVideoQty, $queryResult);\n }", "public static function is_active() {\n\t\treturn defined( 'WS_PLUGIN__S2MEMBER_VERSION' );\n\t}", "public function isActive()\n {\n // no body\n }", "function checkSpotAvaliability($spot,$currentTime,$beginTime,$endTime){\r\n\t\r\n\t$currentTime=strtotime($currentTime);\r\n\t$beginTime = strtotime($beginTime);\r\n\t$endTime = strtotime($endTime);\r\n\t$p1 = ($beginTime-$currentTime)/1800;\r\n\t$p2 = ($endTime-$currentTime)/1800;\r\n\tif($p1>32){//if both larger than 32, check second future state only\r\n\t\t$p1 = $p1-32;\r\n\t\t$p2 = $p2-32;\r\n\t\t$checkBits = ((1<<$p2)-1)&(1<<($p1-1));\r\n\t\tif($checkBits&$spot['futurestate2']){//if result is 0, then available\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn true;\t\t\t\r\n\t}\r\n\t\r\n\telse if($p2>32){//if only p2 larger than 32, needs to check second future state\r\n\t\t$checkBits1 = (0-1)<<($p1-1);\r\n\t\t$checkBits2 = (1<<($p2-31)-1);\r\n\t\tif( ($checkBits1&$spot['futurestate1'])|| ($checkBits2&$spot['futurestate2']) ){\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\telse{//check futurestate1 only\r\n\t\t$checkBits = ((1<<$p2)-1)&(1<<($p1-1));\r\n\t\tif($checkBits&$spot['futurestate1']){//if result is 0, then available\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn true;\t\t\t\r\n\t}\r\n}", "function PDC_getCamperSponsoredValue($personType, $volunteerType)\n{\n\t//echo(\"<h1>in PDC_getCamperSponsoredValue: type=\" . $personType . \" and volunteerType = \" . $volunteerType . \"</h2>\");\n\nswitch ( $personType )\n{\ncase \"Aide\":\ncase \"Tagalong\":\n\t$sponsored = \"1\";\t// aides and tags are guaranteed admission\n\tbreak;\ncase \"Adult\":\n\t$sponsored = \"staff\";\t// staff are guaranteed \n\tbreak;\ncase \"Camper\":\n\t{\n\tswitch ($volunteerType)\n\t\t{\n\t\tcase \"VolunteerFullTime\":\n\t\tcase \"Volunteer5Day\":\n\t\tcase \"Volunteer3Day\":\n\t\t\t$sponsored = \"1\";\t// guaranteed admission to camp\n\t\t\tbreak;\n\t\tcase \"VolunteerAtHome\":\n\t\t\t$sponsored = \"2\";\t// priority 2\n\t\t\tbreak;\n\t\tcase VolunteerNone:\n\t\tdefault:\n\t\t\t$sponsored = \"3\";\t// priority 3\n\t\t\tbreak;\n\t\t}\n\tbreak;\n\t}\ndefault:\n\t$sponsored = \"\";\t// nobody should get here\n\tbreak;\n\n}\n\n\nreturn $sponsored;\n}", "function getPaperSponsor() {\n\t\tif (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');\n\t\treturn $this->getLocalizedSponsor();\n\t}", "public function isActive() {\n\t\treturn in_array($this->get('presence'), array(0,2));\n\t}", "public function rec_status_list_active()\n {\n return false;\n }" ]
[ "0.5649566", "0.55560493", "0.531502", "0.5253371", "0.523359", "0.5221378", "0.52212447", "0.520099", "0.5196943", "0.5180865", "0.5168397", "0.5166136", "0.513624", "0.513624", "0.51308763", "0.5109166", "0.50178176", "0.501115", "0.49999496", "0.4986112", "0.49563694", "0.49089503", "0.49060926", "0.48766878", "0.48723716", "0.48256242", "0.48232666", "0.4805898", "0.47999057", "0.479593" ]
0.63880664
0
enable the rest route for the entire application.
protected function _initRestRoute() { $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); // Specifying all controllers as RESTful: //$restRoute = new Zend_Rest_Route($front); //$router->addRoute('default', $restRoute); // Specifying the \"api\" module only as RESTful: $restRoute = new Zend_Rest_Route($front, array(), array( 'api', )); $router->addRoute('rest', $restRoute); // Specifying the \"mymodule\" module as RESTful, and the \"customer\" controller of the // \"api\" module as RESTful: /*$restRoute = new Zend_Rest_Route($front, array(), array( 'mymodule', 'api' => array('customer'), )); $router->addRoute('rest', $restRoute);*/ }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function addRestRoutes()\n {\n }", "function smartrest_activate() {\n smartrest_add_endpoint();\n // flush rewrite rules - only do this on activation as anything more frequent is bad!\n flush_rewrite_rules();\n}", "public function register_route() {\n\n\t\tregister_rest_route(\n\t\t\tself::ROUTE_NAMESPACE,\n\t\t\t'/' . self::ROUTE_NORMAL,\n\t\t\tarray(\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'callback' => array( $this, 'save_options_callback' ),\n\t\t\t\t'permission_callback' => '__return_true',\n\t\t\t)\n\t\t);\n\t}", "public static function add_rest_route() {\n register_rest_route(\n 'wp-react/v1',\n '/settings',\n array(\n 'methods' => 'GET',\n 'callback' => function() {\n return array(\n 'title' => get_bloginfo('name'),\n 'description' => get_bloginfo('descriptiong'),\n 'url' => get_bloginfo('url'),\n 'timezone' => get_option('timezone_string'),\n 'date_format' => get_option('date_format'),\n 'time_format' => get_option('time_format'),\n 'start_of_week' => get_option('start_of_week'),\n 'language' => get_bloginfo('language'),\n 'default_category' => get_option('default_category'),\n 'default_post_format' => get_option('default_post_format'),\n 'posts_per_page' => get_option('posts_per_page'),\n 'post_types' => get_post_types(array(\n 'public' => true\n )),\n );\n }\n )\n );\n }", "public function restRegister()\n {\n $this->registerRoute('current', [$this, 'current']);\n }", "public function registerRoutes()\n {\n register_rest_route(\n 'kma/v1',\n $this->restCollection,\n [\n 'methods' => 'GET',\n 'callback' => [$this, 'restCollection'],\n 'permission_callback' => '__return_true'\n ]\n );\n\n register_rest_route(\n 'kma/v1',\n $this->restSingleton,\n [\n 'methods' => 'GET',\n 'callback' => [$this, 'restSingleton'],\n 'permission_callback' => '__return_true'\n ]\n );\n\n $this->addRestRoutes();\n }", "public function register_rest() {\n\n\t\t// Get runner status\n\t\t$route_args = array(\n\t\t\t'methods' => 'GET',\n\t\t\t'callback' => array( $this, 'status' ),\n\t\t);\n\t\tregister_rest_route( 'cron-master/v1', '/status', $route_args );\n\t\t// Set cron runner\n\t\t$route_args = array(\n\t\t\t'methods' => 'GET',\n\t\t\t'callback' => array( $this, 'do_cron' ),\n\t\t);\n\t\tregister_rest_route( 'cron-master/v1', '/cron', $route_args );\n\t\t// Run daemon Process.\n\t\t$route_args = array(\n\t\t\t'methods' => 'GET',\n\t\t\t'permission_callback' => array( $this, 'verify' ),\n\t\t\t'callback' => array( $this, 'daemon' ),\n\t\t);\n\t\tregister_rest_route( 'cron-master/v1', '/daemon', $route_args );\n\t}", "public function register_routes()\n {\n // ping\n register_rest_route(static::$namespace, '/ping', array(\n 'methods' => 'GET',\n 'callback' => array($this, 'ping'),\n 'permission_callback' => '__return_true',\n ));\n\n // Right now we only have a survey disconnect endpoint.\n register_rest_route(static::$namespace, \"/survey/disconnect\", array(\n 'methods' => 'POST',\n 'callback' => array($this, 'post_disconnect_survey'),\n 'permission_callback' => array($this, 'permission_callback'),\n ));\n\n // Sync Stats\n register_rest_route(static::$namespace, '/sync/stats', array(\n 'methods' => 'GET',\n 'callback' => array($this, 'get_sync_stats'),\n 'permission_callback' => array($this, 'permission_callback'),\n ));\n\n // remove review banner\n register_rest_route(static::$namespace, \"/review-banner\", array(\n 'methods' => 'GET',\n 'callback' => array($this, 'dismiss_review_banner'),\n 'permission_callback' => array($this, 'permission_callback'),\n ));\n }", "protected function iniRoutes() {\n \n }", "public function register_rest_routes() {\n\t\tforeach ( $this->get_rest_namespaces() as $namespace => $controllers ) {\n\t\t\tforeach ( $controllers as $controller_name => $controller_class ) {\n\t\t\t\t$this->controllers[ $namespace ][ $controller_name ] = new $controller_class();\n\t\t\t\t$this->controllers[ $namespace ][ $controller_name ]->register_routes();\n\t\t\t}\n\t\t}\n\t}", "public function registerRestRoutes()\n {\n //Get user id\n self::$userId = get_current_user_id();\n\n //Create user account\n register_rest_route(\n \"ModularityResourceBooking/v1\",\n \"CreateUser\",\n array(\n 'methods' => \\WP_REST_Server::CREATABLE,\n 'callback' => array($this, 'create'),\n )\n );\n\n //Modify user account\n register_rest_route(\n \"ModularityResourceBooking/v1\",\n \"ModifyUser/(?P<id>[\\d]+)\",\n array(\n 'methods' => \\WP_REST_Server::EDITABLE,\n 'callback' => array($this, 'modify'),\n 'permission_callback' => array($this, 'canUpdateUser'),\n 'args' => array(\n 'id' => array(\n 'validate_callback' => function ($param, $request, $key) {\n return is_numeric($param);\n },\n 'sanitize_callback' => 'absint',\n 'required' => true,\n 'type' => 'integer',\n 'description' => 'The user id.'\n ),\n ),\n )\n );\n }", "public function registerRoutes()\n {\n foreach (self::routes() as $route) {\n register_rest_route(Constants::HYPHEN_NAME, '/' . $route['slug'], [\n [\n 'methods' => $route['method'],\n 'callback' => $route['callback'],\n ]\n ]);\n }\n }", "public function register_routes()\n {\n $namespace = $this->namespace();\n $routes = $this->routes();\n\n foreach ($routes as [\n 'route' => $route,\n 'args' => $args\n ]) {\n register_rest_route(\n $namespace,\n $route,\n $args\n );\n }\n }", "public function register_routes() {\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base, array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_items' ),\n\t\t\t\t'permission_callback' => array( $this, 'get_items_permissions_check' ),\n\t\t\t\t'args' => array(),\n\t\t\t)\n\t\t) );\n }", "function registerRoutes() {\n register_rest_route( $this->namespace, $this->rest_base,\n array(\n 'methods' => \\WP_REST_Server::READABLE,\n 'callback' => array( $this, 'newsFeedPosts' ),\n 'show_in_index' => true,\n ) );\n register_rest_route( $this->namespace . '/' . $this->rest_base, '/(?P<id>[\\d]+)',\n array(\n 'methods' => \\WP_REST_Server::READABLE,\n 'callback' => array( $this, 'newsFeedPost' ),\n 'show_in_index' => true,\n 'args' => array(\n 'context' => array(\n 'default' => 'view',\n ),\n 'per_page' => array(\n 'default' => 1,\n 'sanitize_callback' => 'absint',\n ),\n ),\n ) );\n }", "public function setRoutes(): void\n {\n $versions = $this->_versions;\n $default = 'api/v1/v0';\n\n Router::scope('/api', function ($routes) use ($versions, $default) {\n // Setting up fallback non-versioned API url calls.\n // It can handle `api/controller/index.json` as well\n // as `api/controller.json` calls.\n Router::prefix('api', function ($routes) use ($default) {\n $routes->setExtensions(['json']);\n $routes->connect('/:controller', ['prefix' => $default], ['routeClass' => DashedRoute::class]);\n $routes->connect('/:controller/:action/*', ['prefix' => $default], ['routeClass' => DashedRoute::class]);\n $routes->fallbacks(DashedRoute::class);\n });\n\n foreach ($versions as $version) {\n Router::prefix($version['prefix'], ['path' => $version['path']], function ($routes) {\n $routes->setExtensions(['json']);\n $routes->fallbacks(DashedRoute::class);\n });\n }\n });\n }", "public function loadCustomRoutes()\n {\n if (strpos($this->app->version(), 'Lumen') !== false) {\n\n $this->app->group([\n 'namespace' => 'SumanIon\\TelegramBot\\Controllers',\n 'prefix' => 'api'\n ], function () {\n\n $router = $this->app;\n\n require __DIR__ . '/../../routes/api.php';\n });\n\n } else {\n\n $this->app['router']->group([\n 'middleware' => 'api',\n 'namespace' => 'SumanIon\\TelegramBot\\Controllers',\n 'prefix' => 'api',\n ], function () {\n\n $router = $this->app['router'];\n\n require __DIR__ . '/../../routes/api.php';\n });\n }\n }", "public function register_routes() {\n register_rest_route(\n $this->namespace,\n '/resting-state', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_resting_state' ),\n \t \t),\n \t )\n );\n\n // register portrait grid\n register_rest_route(\n $this->namespace,\n '/portrait-grid/(?P<slug>[a-zA-Z0-9-_]+)', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_portrait_grid' ),\n \t \t\t'args' => TQNT_Portrait_Grid_Controller::get_portrait_grid_args(),\n \t \t),\n \t )\n );\n\n // register icon grid\n register_rest_route(\n $this->namespace,\n '/icon-grid/(?P<slug>[a-zA-Z0-9-_]+)', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_icon_grid' ),\n \t \t\t'args' => TQNT_Icon_Grid_Controller::get_icon_grid_args(),\n \t \t),\n \t )\n );\n\n // register event\n register_rest_route(\n $this->namespace,\n '/event/(?P<slug>[a-zA-Z0-9-_]+)', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_event' ),\n \t \t\t'args' => TQNT_Events_Controller::get_event_args(),\n \t \t),\n \t )\n );\n // get all available events\n register_rest_route(\n $this->namespace,\n '/events', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_events' ),\n \t \t),\n \t )\n );\n\n // register nav\n register_rest_route(\n $this->namespace,\n '/nav/(?P<slug>[a-zA-Z0-9-_]+)', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_nav' ),\n \t \t\t'args' => TQNT_Nav_Controller::get_nav_args(),\n \t \t),\n \t )\n );\n //\n register_rest_route(\n $this->namespace,\n '/navs-available', // resource\n array( // Valid methods\n \t \tarray(\n \t \t\t'methods' => 'GET',\n \t \t\t'callback' => array( $this, 'get_navs_avail' ),\n \t \t),\n \t )\n );\n }", "function smartrest_add_endpoint() {\n // register a \"json\" endpoint to be applied to posts and pages\n add_rewrite_endpoint( 'json', EP_ALL );\n}", "public function register_routes() {\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base, array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_posts' ),\n\t\t\t)\n\t\t) );\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>.+)', array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_post' ),\n\t\t\t)\n\t\t) );\n\t}", "public function init(){\n\t\tadd_action( 'rest_api_init', array( $this, 'register_routes' ) );\n\t}", "public function enterprise_plugin_register_external_resources_rest_route() {\n\t\tregister_rest_route(\n\t\t\t'external-resources/v1',\n\t\t\t'/post/',\n\t\t\tarray(\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'callback' => array( $this, 'enterprise_plugin_external_resources_endpoint' ),\n\t\t\t)\n\t\t);\n\t}", "public function register_routes() {\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base, array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_rooms' ),\n\t\t\t)\n\t\t) );\n\n\t\tregister_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<number>.+)', array(\n\t\t\tarray(\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => array( $this, 'get_room' ),\n\t\t\t)\n\t\t) );\n\n\t}", "public function register_route() {\n\t\t$namespace = 'utec/v1';\n\n\t\tregister_rest_route(\n\t\t\t$namespace,\n\t\t\t'get-users', \n\t\t\t[\n\t\t\t\t'methods' => 'POST',\n\t\t\t\t'callback' => [ $this, 'process_request' ],\n\t\t\t]\n\t\t);\n\t}", "public function registerRoutes()\n {\n register_rest_route(\n 'kerigansolutions/v1',\n '/submit-contact-form',\n [\n 'methods' => 'POST',\n 'callback' => [$this, 'submitContactForm'],\n 'permission_callback' => '__return_true'\n ]\n );\n }", "public function init() {\n\t\tadd_action( 'rest_api_init', array( $this, 'register_rest_routes' ), 10 );\n\t}", "public function enterprise_plugin_register_locations_rests_route() {\n\t\tregister_rest_route(\n\t\t\t'locations/v1',\n\t\t\t'/post/',\n\t\t\tarray(\n\t\t\t\t'method' => 'GET',\n\t\t\t\t'callback' => array( $this, 'enterprise_plugin_locations_endpoint' ),\n\t\t\t)\n\t\t);\n\t}", "public function register_routes() {\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/dashboard',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ $this, 'get_dashboard' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/keywordsOverview',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ $this, 'get_keywords_overview' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/postsSummary',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ Stats::get(), 'get_posts_summary' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/postsRowsByObjects',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ Stats::get(), 'get_posts_rows_by_objects' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/post/(?P<id>\\d+)',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ $this, 'get_post' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/keywordsSummary',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ Stats::get(), 'get_analytics_summary' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/analyticsSummary',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ $this, 'get_analytics_summary' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/keywordsRows',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::READABLE,\n\t\t\t\t'callback' => [ Stats::get(), 'get_keywords_rows' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/userPreferences',\n\t\t\t[\n\t\t\t\t'methods' => WP_REST_Server::CREATABLE,\n\t\t\t\t'callback' => [ $this, 'update_user_preferences' ],\n\t\t\t\t'permission_callback' => [ $this, 'has_permission' ],\n\t\t\t]\n\t\t);\n\t}", "public function registerRoutes()\n {\n register_rest_route($this->namespace, \"/{$this->route}\", [\n [\n 'methods' => 'GET',\n 'callback' => [$this, 'getItem'],\n 'permission_callback' => [$this, 'getItemsPermissionsCheck'],\n ],\n [\n 'methods' => 'PUT', // WP_REST_Server::CREATABLE\n 'callback' => [$this, 'updateItem'],\n 'permission_callback' => [$this, 'updateItemPermissionsCheck'],\n 'args' => $this->getItemSchemaProperties(),\n ],\n 'schema' => [$this, 'getItemSchema'],\n ]);\n }", "public function register_routes() {\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/' . $this->rest_base,\n\t\t\tarray(\n\t\t\t\tarray(\n\t\t\t\t\t'methods' => RestServer::READABLE,\n\t\t\t\t\t'callback' => [ $this, 'get_items' ],\n\t\t\t\t\t'args' => $this->get_collection_params(),\n\t\t\t\t),\n\t\t\t\t'schema' => array( $this, 'get_public_item_schema' ),\n\t\t\t)\n\t\t);\n\t\tregister_rest_route(\n\t\t\t$this->namespace,\n\t\t\t'/' . $this->rest_base . '/(?P<id>[\\d]+)',\n\t\t\tarray(\n\t\t\t\t'args' => array(\n\t\t\t\t\t'id' => array(\n\t\t\t\t\t\t'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),\n\t\t\t\t\t\t'type' => 'integer',\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'methods' => RestServer::READABLE,\n\t\t\t\t\t'callback' => array( $this, 'get_item' ),\n\t\t\t\t\t'args' => array(\n\t\t\t\t\t\t'context' => $this->get_context_param(\n\t\t\t\t\t\t\tarray(\n\t\t\t\t\t\t\t\t'default' => 'view',\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\t'schema' => array( $this, 'get_public_item_schema' ),\n\t\t\t)\n\t\t);\n\t}" ]
[ "0.76840657", "0.6882759", "0.67484033", "0.6702438", "0.6676265", "0.66731054", "0.66623944", "0.6566483", "0.6566477", "0.6487645", "0.64720017", "0.64360374", "0.64017516", "0.6396281", "0.6338559", "0.6335565", "0.6331788", "0.62829316", "0.6259995", "0.62502176", "0.6239697", "0.62386286", "0.6189318", "0.6157609", "0.61540025", "0.6134819", "0.613168", "0.6125917", "0.61178434", "0.6109726" ]
0.7288869
1
Actualiza Saldo del Cliente por medio de un pago
public function actualizarSaldo($param) { $idcliente = $param["idcliente"]; $total_abono = $param["total_abono"]; $query = Controller::$connection->query("SELECT saldo FROM cliente WHERE idcliente = '$idcliente'"); $data = $query->fetchAll(PDO::FETCH_ASSOC); $saldo = $data[0]["saldo"]; if(($saldo - $total_abono) >= 0 ) { $query = Controller::$connection->query("UPDATE cliente as C SET C.saldo = C.saldo - $total_abono WHERE C.idcliente = '$idcliente'"); return true; } else { return false; } header('Content-Type: application/json'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function actualizar_cliente($datos){\n\t\tif(array_key_exists('password', $datos)){\n\t\t\t$datos['password'] = md5($datos['email'].\"|\".$datos['password']);\t\n\t\t}\n\t\t\t\t\n\t\t\n\t\t$this->query = \"UPDATE CMS_IntCliente SET salutation = '\".$datos['salutation'].\"',\n\t\t\t\t\t\t\t\t\t\t\t\t fname = '\".$datos['fname'].\"',\n\t\t\t\t\t\t\t\t\t\t\t\t lname = '\".$datos['lname'].\"',\n\t\t\t\t\t\t\t\t\t\t\t\t email = '\".$datos['email'].\"',\n\t\t\t\t\t\t\t\t\t\t\t\t password ='\".$datos['password'].\"'\t \n\t\t WHERE id_clienteIn = '\" . $datos['id_clienteIn'] . \"'\";\n\t\t$res = $this->execute_single_query();\n\t\treturn $res;\t\t\n\t}", "public function actualizarCreditoDisponible_2($venta_id,$operacion,$monto_pago)\r\n {\r\n $model=Venta::model()->findByPk($venta_id);\r\n if($model->forma_pago_id==1){\r\n $_monto = $operacion==0 ? $monto_pago : \r\n $monto_pago*(-1);\r\n $_cliente = $this->findByPk($model->cliente_id);\r\n $_cliente->credito_disponible+=$_monto;\r\n $_cliente->save();\r\n\r\n }\r\n \r\n }", "public function actualizar(){\n\t\t$id = $this->input->post('id');\n\t\t$rut = $this->input->post('rut');\n\t\t\n\t\t# se crea un array con los datos del formulario\n\t\t$data = array(\n\t\t\t'nombre' => $this->input->post('nombre'),\n\t\t\t'especie' => $this->input->post('especie'),\n\t\t\t'raza' => $this->input->post('raza'),\n\t\t\t'sexo' => $this->input->post('sexo'),\n\t\t\t'fechaNacimiento' => date(\"Y-m-d H:i:s\",strtotime(str_replace('/','-',$this->input->post('fecha')))),\n\t\t\t'modificado' => $this->session->userdata('username'),\n\t\t\t'fechaModificacion' => date('Y-m-d H:i:s', time())\n\t\t);\n\t\t\n\t\t# se agrega el cliente en la BD\n\t\t$id = $this->paciente_model->actualizar_paciente($id, $data);\n\n\t\t\n\t\t# pasamos el rut a la siguiente pagina\n $url = 'info_cliente/cliente/'.$rut;\n\t\t\n \n\t\t# redirigimos a la siguiente ventana\n\t\tredirect($url);\n\t}", "public function actualizarDatos(){\n if(isset($_POST)){\n $id = $_SESSION['login']->id_cliente;\n $nombre = isset($_POST['name']) ? $_POST['name'] : false;\n $apellidos = isset($_POST['lastname']) ? $_POST['lastname'] : false;\n $email = isset($_POST['email']) ? $_POST['email'] : false;\n \n if ($nombre && $apellidos && $email) {\n $cliente = new Cliente();\n $cliente->setId($id);\n $cliente->setNombre($nombre);\n $cliente->setApellidos($apellidos);\n $cliente->setEmail($email);\n \n $datosActualizados = $cliente->actualizar();\n //Llenar la sesion con los nuevos datos\n $_SESSION['login'] = $cliente->recargaSesion();\n }\n }else{\n $_SESSION['fallo']=\"Fallo la actualización de los datos\";\n }\n header('location:'. root . 'cliente/datos');\n }", "public function update(PedidoFormRequest $request,$codigo) {\n if ($request->get('tipo_pago')=='puntos') {\n\n $Punto_cliente = new Punto_cliente;\n\n $valor_actual = $this->encontrar_valor_actual();\n $cedula = $this->encontrar_cedula_natural($codigo);\n $rif = $this->encontrar_rif_juridico($codigo);\n\n if ($cedula){\n $Punto_cliente->fk_naturale = $cedula[0]->id;\n }\n else if ($rif){\n $Punto_cliente->fk_juridico = $rif[0]->id;\n }\n\n $Punto_cliente->adquirido = -1*($request->get('monto')/$valor_actual[0]->valor);\n $Punto_cliente->fk_punto = $valor_actual[0]->codigo;\n $Punto_cliente->valor = $valor_actual[0]->valor;\n $Punto_cliente->fk_pedido = $codigo;\n\n $Punto_cliente->save();\n\n $pedido = Pedido::findOrFail($codigo);\n $presupuesto = Presupuesto::findOrFail($pedido->c_presupuesto);\n $presupuesto->total -= $request->get('monto');\n\n if ($presupuesto->total <= 0){\n $presupuesto->total = 0;\n }\n $pedido->save();\n $presupuesto->save();\n\n }\n else if ($request->get('tipo_pago')=='medios'){\n\n $pago = new Pago;\n $pago->monto = $request->get('monto');\n $pago->fecha = date('Y-m-d H:i:s');\n $pago->fk_pedido = $codigo;\n $pago->fk_medio_pago = $request->get('fk_medio_pago');\n $pago->save();\n $pedido = Pedido::findOrFail($codigo);\n $presupuesto = Presupuesto::findOrFail($pedido->c_presupuesto);\n $presupuesto->total -= $request->get('monto');\n\n if ($presupuesto->total <= 0){\n $presupuesto->total = 0;\n }\n $pedido->save();\n $presupuesto->save();\n }\n\n return Redirect::to('cliente/pedido');\n }", "public function actualizar_cliente_controlador(){\r\n\t\t\t$cuenta=mainModel::decryption($_POST['cuenta-up']);\r\n\r\n\t\t\t$dni=mainModel::limpiar_cadena($_POST['dni-up']);\r\n\t\t\t$nombre=mainModel::limpiar_cadena($_POST['nombre-up']);\r\n\t\t\t$apellido=mainModel::limpiar_cadena($_POST['apellido-up']);\r\n\t\t\t$telefono=mainModel::limpiar_cadena($_POST['telefono-up']);\r\n\t\t\t$ocupacion=mainModel::limpiar_cadena($_POST['ocupacion-up']);\r\n\t\t\t$direccion=mainModel::limpiar_cadena($_POST['direccion-up']);\r\n\r\n\r\n\t\t\t$query1=mainModel::ejecutar_consulta_simple(\"SELECT * FROM cliente WHERE CuentaCodigo='$cuenta'\");\r\n\t\t\t$DatosCliente=$query1->fetch();\r\n\r\n\t\t\tif($dni!=$DatosCliente['ClienteDNI']){\r\n\t\t\t\t$consulta1=mainModel::ejecutar_consulta_simple(\"SELECT ClienteDNI FROM cliente WHERE ClienteDNI='$dni'\");\r\n\t\t\t\tif($consulta1->rowCount()>=1){\r\n\t\t\t\t\t$alerta=[\r\n\t\t\t\t\t\t\"Alerta\"=>\"simple\",\r\n\t\t\t\t\t\t\"Titulo\"=>\"Ocurrió un error inesperado\",\r\n\t\t\t\t\t\t\"Texto\"=>\"El DNI que acaba de ingresar ya se encuentra registrado en el sistema\",\r\n\t\t\t\t\t\t\"Tipo\"=>\"error\"\r\n\t\t\t\t\t];\r\n\t\t\t\t\treturn mainModel::sweet_alert($alerta);\r\n\t\t\t\t\texit();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t$dataClient=[\r\n\t\t\t\t\"DNI\"=>$dni,\r\n\t\t\t\t\"Nombre\"=>$nombre,\r\n\t\t\t\t\"Apellido\"=>$apellido,\r\n\t\t\t\t\"Telefono\"=>$telefono,\r\n\t\t\t\t\"Ocupacion\"=>$ocupacion,\r\n\t\t\t\t\"Direccion\"=>$direccion,\r\n\t\t\t\t\"Codigo\"=>$cuenta\r\n\t\t\t];\r\n\r\n\t\t\tif(clienteModelo::actualizar_cliente_modelo($dataClient)){\r\n\t\t\t\t$alerta=[\r\n\t\t\t\t\t\"Alerta\"=>\"recargar\",\r\n\t\t\t\t\t\"Titulo\"=>\"¡Datos actualizados!\",\r\n\t\t\t\t\t\"Texto\"=>\"Tus datos han sido actualizados con éxito\",\r\n\t\t\t\t\t\"Tipo\"=>\"success\"\r\n\t\t\t\t];\r\n\t\t\t}else{\r\n\t\t\t\t$alerta=[\r\n\t\t\t\t\t\"Alerta\"=>\"simple\",\r\n\t\t\t\t\t\"Titulo\"=>\"Ocurrió un error inesperado\",\r\n\t\t\t\t\t\"Texto\"=>\"No hemos podido actualizar tus datos por favor intente nuevamente\",\r\n\t\t\t\t\t\"Tipo\"=>\"error\"\r\n\t\t\t\t];\r\n\t\t\t}\r\n\r\n\t\t\treturn mainModel::sweet_alert($alerta);\r\n\t\t}", "function actualizarCliente(){\n $nombre = $_POST['nombre'];\n $apellidos = $_POST['apellidos'];\n $dni = $_POST['dni'];\n $direccion = $_POST['direccion'];\n $telefono = $_POST['telefono'];\n $email = $_POST['email'];\n\n //en caso de poder actualizar el campo devuelvo los nuevos valores ya modificados a la vista\n if($this->model->update(['nombre' => $nombre,'apellidos' => $apellidos,'dni' => $dni,'direccion' => $direccion,'telefono' => $telefono,'email' => $email])){\n\n $cliente = new Cliente();\n $cliente->nombre = $nombre;\n $cliente->apellidos = $apellidos;\n $cliente->dni = $dni;\n $cliente->direccion = $direccion;\n $cliente->telefono = $telefono;\n $cliente->email = $email;\n\n $this->view->cliente = $cliente;\n $this->view->mensaje = \"alumno actualizado correctamente\";\n }else{\n $this->view->mensaje = \"no se pudo actualizar el alumno\";\n }\n $this->view->render('consulta/detalle');\n }", "public static function actualizar()\n {\n $actualizarPersona = new Persona((int)$_REQUEST['id'],$_REQUEST['nombre'],$_REQUEST['edad'],$_REQUEST['sexo']);\n $resultado = PersonaDAL::update($actualizarPersona);\n\n if($resultado)\n {\n $message = \"<div class='alert alert-success'>\n <strong>Success!</strong> !Dato Actualizado Correctamente.</div>\";\n }\n else\n { \n $message = \"<div class='alert alert-warning'>\n <strong>Warning!</strong> !Error al actualizar el dato.</div>\";\n }\n $listaPersonas = PersonaDAL::listAll();\n include_once(\"views-persona/listar.php\");\n }", "public function AnularProcesarDocumentoImp($origenc,$origend,$totalh)\r\n {\r\n $sql=\"UPDATE tbcompra\r\n SET \r\n estatus='Registrado',\r\n saldoh='$totalh',\r\n fechadb=NOW()\r\n WHERE idcompra=(SELECT idcompra FROM tbcompra WHERE cod_compra='$origenc' AND tipo='$origend')\";\r\n return ejecutarConsulta($sql);\r\n }", "public function obtenerSaldo();", "protected function dbUpdateComentContSitio(){\n\t\t\treturn dbConsultas::update(array(\n\t\t\t\t'tabla' => $this->t_sitio,\n\t\t\t\t'valores' => array(\n\t\t\t\t\t'total_c' => 'total_c+1'\n\t\t\t\t),\n\t\t\t\t'filtro' => \"1\",\n\t\t\t));\n\t\t}", "public function update() {\n $datos=array(\"idCliente\"=>$this->idCliente,\"nombre\"=>$this->nombre, \"apellidos\"=>$this->apellidos,\"empresa\"=>$this->empresa,\"email\"=>$this->email,\"telefono\"=>$this->telefono);\n try {\n $sentencia=$this->conexion->prepare(\"UPDATE Cliente SET nombre = :nombre, apellidos = :apellidos, empresa = :empresa, email = :email, telefono = :telefono WHERE idCliente = :idCliente\");\n $sentencia->execute($datos);\n $this->conexion=null;\n } catch (PDOException $e) {\n $this->conexion=null;\n }\n }", "private function salva() {\n $this->enderecoModel = $this->enderecoView->recebeDadosDaEntrada();\n\n //II - validar dados\n //III - se dados ok então continua\n // senão mensagem de erro e sai\n //IV - incluir dados no BD\n //var_dump($this->cursoModel);\n $incluiu = $this->enderecoModel->insereObjeto();\n //V - se incluiu então mensagem de ok\n // senão mensagem de erro\n if ($incluiu) {\n $this->enderecoView->addMensagem(\"Inclusão bem sucedida!\");\n } else {\n $this->enderecoView->addMensagem(\"Inclusão mal sucedida! Contate o responsável.\");\n }\n }", "public function realizarPedido()\n {\n\n try\n {\n if($this->verificarBot())\n {\n\n //Guardar cliente nuevo\n $cliente = new Cliente($this->conexion, null, $_POST['nombre'], $_POST['email'], $_POST['telefono']);\n $cliente->save();\n $idCliente = $cliente->getIdByEmail()['idCliente'];\n\n //Guardar datos pedido\n $pedido = new Pedido($this->conexion, null, date($_POST['fecha']), \"0\", 0, $idCliente);\n $pedido->save();\n $pedidoId = $pedido->getIdByClienteId()['idPedido'];\n $precioTotal = 0;\n $cart = $this->getCart();\n $cartHtml = \"\";\n foreach ($cart as $producto) //Calcular el precio total consultando a base de datos\n {\n $productId = $producto['id'];\n $productCuantity = $producto['cantidad'];\n $product = new Producto($this->conexion);\n $product->setId($productId);\n $datosProduct = $product->getPrecioAndVecesCompradoByID();\n $precioTmp = intval($datosProduct['precio']) * intval($productCuantity);\n $precioTotal += $precioTmp;\n\n $cartHtml = $cartHtml . $this->generateCartHtml($datosProduct['nombre'], intval($productCuantity), $precioTmp);\n\n $pedHprod = new PedidoHasProducto($this->conexion, $pedidoId, $productId, $productCuantity);\n $pedHprod->save();\n\n //Estadísticas\n $vecesComprado = intval($datosProduct['vecesComprado']) + intval($productCuantity);\n $product->setVecesComprado($vecesComprado);\n $product->saveVecesComprado();\n\n }\n $this->deleteCart(true);\n $pedido->setPrecioTotal($precioTotal);\n $pedido->savePrecioTotal();\n $datosEmail = [\"idPedido\" => $pedidoId, \"fecha\" => $pedido->getFecha(), \"cartHtml\" =>$cartHtml, \"precioTotal\" => $precioTotal];\n $this->enviarEmail($cliente->getEmail(), 1, $datosEmail);\n\n $this->twigView(\"orderConfirmation.php.twig\", [\"fechaPedido\" => $pedido->getFecha()]);\n header( \"refresh:7;url=index.php\" );\n\n }\n } catch (Exception $e) {\n echo 'Excepción capturada: ', $e->getMessage(), \"\\n\";\n }\n }", "public function salvar() {\n\n $oDaoItemExame = new cl_lab_requiitem();\n if (!empty($this->iCodigo)) {\n\n $oDaoItemExame->la21_i_codigo = $this->iCodigo;\n $oDaoItemExame->la21_c_situacao = $this->getSituacao();\n $oDaoItemExame->la21_observacao = $this->sObservacao;\n $oDaoItemExame->alterar($this->iCodigo);\n if ($oDaoItemExame->erro_status == 0) {\n throw new BusinessException( _M( MENSAGEM_REQUISICAO_EXAME . \"erro_salvar\" ) );\n }\n }\n }", "public function salvaMySQL(){\r\n parent::salvaMySQL();\r\n \r\n //Estabelece conexão\r\n $con = mysql_connect(\"localhost:3306\",\"root\",\"\");\r\n if(!$con){\r\n die('Não foi possível estabelecer conexão com o banco de dados: '.mysql_error());\r\n }\r\n mysql_select_db(\"mydb\", $con);\r\n \r\n //Gera SQL para salvar/atualizar Cliente no banco\r\n $sql = \"SELECT * FROM TB_Pessoa p, TB_Cliente c WHERE p.login = '\" . $this->login .\r\n \"' and p.senha = '\" . $this->senha . \"' and p.cdPessoa = c.cdPessoa\";\r\n $result = mysql_query($sql, $con);\r\n if($result){\r\n $result = mysql_fetch_array($result);\r\n $sql = \"UPDATE TB_Cliente SET rua = '\" . $this->rua .\r\n \"', numeroEnd = \" . $this->numeroEnd . \", complementoEnd = '\".\r\n $this->complementoEnd . \"', medicamentos = '\" . $this->medicamentos .\r\n \"' WHERE cdPessoa = \" . $result['cdPessoa'];\r\n }\r\n else{\r\n //Busca chave de pessoa e de bairro para inserir em cliente\r\n $sql = \"SELECT * FROM TB_Pessoa p, TB_Bairro b WHERE p.login = '\" . $this->login .\r\n \"' and p.senha = '\" . $this->senha . \"' and b.cdBairro = \" . $this->bairro->getCdBairro();\r\n $result = mysql_query($sql, $con);\r\n \r\n if(!$result){\r\n die('Não foi possível carregar pessoa do banco de dados: '.mysql_error());\r\n }\r\n \r\n $result = mysql_fetch_array($result);\r\n $sql = \"INSERT INTO TB_Cliente(cdPessoa, cdBairro, rua, numeroEnd, complementoEnd, medicamentos) \"\r\n . \"VALUES (\" . $result['cdPessoa'] . \",\". $result['cdBairro'] . \",'\" . $this->rua . \"','\" .\r\n $this->numeroEnd . \"','\" . $this->complementoEnd . \"','\" . $this->medicamentos . \"')\";\r\n }\r\n \r\n //Executa SQL e testa sucesso\r\n $result = mysql_query($sql, $con);\r\n if(!$result){\r\n die('Não foi possível salvar medico no banco de dados: '.mysql_error());\r\n }\r\n \r\n mysql_close($con);\r\n }", "public function actualizarCreditoDisponible($model,$operacion)\r\n {\r\n if($model->r_venta->forma_pago_id==1){\r\n $_monto = $operacion==0 ? $model->cantidad*$model->precio_unitario : \r\n $model->cantidad*$model->precio_unitario*(-1);\r\n $_cliente = $this->findByPk($model->r_venta->cliente_id);\r\n $_cliente->credito_disponible+=$_monto;\r\n $_cliente->save();\r\n\r\n }\r\n \r\n }", "public function atualizarCliente($dados,$id){\n if($id != null && $dados != null){\n //se foi passado os dados ele atualiza\n $this->db->update('clientes',$dados,array('Id'=>$id));\n }\n }", "public function atualizar() {\n\n\t\t$params = array (\n\t\t\t\"c_nome\" => $this->c_nome,\n\t\t\t\"c_email\" => $this->c_email,\n\t\t\t\"c_telefone\" => $this->c_telefone\n\t\t);\n\n\t\t# where c_id = $this->c_id\n\t\t$this->__con->where('c_id', $this->c_id);\n\t\t$atualizar = $this->__con->update('cliente', $params);\n\n\t\tif ($atualizar>0) {\n\n\t\t\treturn $atualizar;\n\n\t\t} else {\n\t\t\tthrow new \\Exception(\"Verifique os parâmetros da query de atualização.\", 1);\n\t\t}\n\t\n\t}", "public function atualizar(){\n // $Usuario = new UsuarioModel;\n //\n //\n // $migracao = $Migracao->listar();\n //\n // foreach($migracao as $r):\n // $usuario = $Usuario->buscar_nome($r->nome);\n // if($usuario):\n // $dados = array(\n // 'cpf' => $usuario->documento\n // );\n // $update = $Migracao->update($dados, \"`nome` = '{$r->nome}'\");\n // endif;\n // endforeach;\n // exit();\n }", "public function editarComent(){\n\t\t \n$sql=\"Update usuarios set id_usuario=$this->id_usuario,observaciones='$this->observaciones' where id_usuario=\".$this->id_usuario;\n\t\t $this->con->query($sql);\n\t\t \n\t\t \n\t\t }", "public function modificar() {\n $objDatos = new clsDatos();\n $sql = \"UPDATE asigna_caso\n SET id_aca = '$this->id_aca',\n id_pac = '$this->id_pac',\n id_usu = '$this->id_usu',\n tip_aca = '$this->tip_aca',\n est_aca = '$this->est_aca';\";\n $objDatos->ejecutar($sql);\n $objDatos->crerrarconexion();\n }", "function Modif_client($id,$NUMERO_INDENTIFIANT){\n $requette=\"update client set NUMERO_INDENTIFIANT='$NUMERO_INDENTIFIANT' where ID_CLIENT=$id\";\nExecuteRequette($requette);\n }", "public function actualizar($param) {\n extract($param);\n // error_log(print_r($param, TRUE)); // quitar comentario para ver lo que se recibe del front-end\n\n $sql = \"UPDATE proveedores\n SET id_proveedor=:id_proveedor, nombre=:nombre, telefono=:telefono, correo=:correo\n WHERE id_proveedor = :id_actual\";\n\n // Prepara la instrucción SQL para ejecutarla luego de recibir los parámetros de inserción\n $instruccion = $conexion->pdo->prepare($sql);\n\n if ($instruccion) {\n $instruccion->bindParam(':id_actual', $data['id_actual']);\n $instruccion->bindParam(':id_proveedor', $data['id_proveedor']);\n $instruccion->bindParam(':nombre', $data['nombre']);\n $instruccion->bindParam(':telefono', $data['telefono']);\n $instruccion->bindParam(':correo', $data['correo']);\n\n if ($instruccion->execute()) {\n echo $conexion->errorInfo($instruccion);\n } else {\n echo $conexion->errorInfo($instruccion);\n }\n } else {\n echo json_encode(['ok' => FALSE, 'mensaje' => 'Falló en la instrucción de actualización para clientes']);\n }\n }", "public function actualizar(){\n }", "public function run()\n {\n $saldo = new Saldo();\n $saldo->saldo = 100000000;\n $saldo->save();\n }", "function atualizarPedido($id, $num_pedido, $cliente, $data, $status)\n{\n $pdo = conectar();\n $agora = date(\"Y-m-d H:i:s\");\n \n $sql = \"UPDATE pedidos SET \"\n . \"status = '$status',\"\n . \"num_pedido = '$num_pedido', \"\n . \"cliente = '$cliente',\"\n . \"data_pedido = '$data',\"\n . \"data_atualizacao = '$agora' \"\n . \" WHERE id = $id\";\n \n $total = $pdo->exec($sql);\n \n return $total;\n \n}", "function procesar_modificar_cliente()\n {\n //si quiero acceder tengo que explicitar con la palabra global\n global $cnx;\n global $cliente;\n\n global $id;\n //global $precio;\n //global $cantidad;\n global $nombre;\n global $email;\n global $direccion;\n global $login;\n global $password;\n global $telefono;\n\n global $error;\n\n $id = $_POST[\"txt_id\"];\n $nombre = $_POST[\"txt_nombre\"];\n $email = $_POST[\"txt_email\"];\n $direccion = $_POST[\"txt_direccion\"];\n $login = $_POST[\"txt_login\"];\n $password = $_POST[\"txt_password\"];\n $telefono = $_POST[\"txt_telefono\"];\n\n\n\n $cliente->inicializar($id,$nombre,$email,$direccion,$login,$password,$telefono);\n if($cliente->modificar())\n header(\"location:frm_cliente.php?msg=modificado correctamente!!!\");\n else\n $error = \"Error al modificar revise los datos !!!\";\n \n }", "function actualizar()\n\t{\n\t\t$datos = $this->input->post();\n\t\tif (isset($datos)) \n\t\t{\n\t\t\t$id \t\t\t\t= $datos[\"id\"];\n\t\t\t$nombre\t\t\t\t= $datos[\"nombre\"];\n\t\t\t$dni \t\t\t\t= $datos[\"dni\"];\n\t\t\t$sexo \t\t\t\t= $datos[\"sexo\"];\n\t\t\t$direccion \t\t\t= $datos[\"direccion\"];\n\t\t\t$correo \t\t\t= $datos[\"correo\"];\n\t\t\t$contrasena\t\t\t= $datos[\"contrasena\"];\n\t\t\t$estado\t\t\t\t= $datos[\"estado\"];\n\t\t\t$telefono\t\t\t= $datos[\"telefono\"];\n\t\t\t$celular\t\t\t= $datos[\"celular\"];\n\t\t\t$distrito\t\t\t= $datos[\"distrito\"];\n\t\t\t$referencia\t\t\t= $datos[\"referencia\"];\n\t\t\t$this->model_cliente->updateCliente($id,$nombre,$dni,$sexo,$direccion,$estado,$telefono,$celular,$distrito,$referencia);\n\t\t\t$this->load->model('model_usuario');\n\t\t\t$this->model_usuario->updateUsuario($id,$correo,$contrasena);\n\t\t\tredirect(base_url('clientes'));\n\t\t}\n\t}", "public function obtenerSaldo()\n {\n $saldo = $this->costo;\n\n foreach ($this->cobrosConsulta as $pago) {\n $saldo -= $pago->getAbono();\n }\n\n return $saldo;\n }" ]
[ "0.6312993", "0.61336946", "0.60029477", "0.596523", "0.59218556", "0.58130497", "0.5787097", "0.5780497", "0.57616", "0.5750488", "0.5746712", "0.5737239", "0.57364815", "0.57269996", "0.5713444", "0.5685016", "0.56807804", "0.5678272", "0.56758296", "0.56736153", "0.5657804", "0.56530505", "0.5636728", "0.5626681", "0.5621913", "0.5614191", "0.5610188", "0.5594084", "0.55924124", "0.55896753" ]
0.6314408
0
Registers the hook to add required scopes.
private function register_scopes_hook() { add_filter( 'googlesitekit_auth_scopes', function( array $scopes ) { return array_merge( $scopes, $this->get_scopes() ); } ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function register() {\n\t\t$this->register_scopes_hook();\n\t}", "public function register_hooks() {\n\t\tadd_action( 'login_form_oauth1_authorize', array( $this, 'handle_request' ) );\n\t\tadd_action( 'oauth1_authorize_form', array( $this, 'page_fields' ) );\n\t}", "public function addHooks() {\n\t\t// Hooks go here\n\t}", "public function registerHooks();", "function addHooks() {\n\t}", "abstract public function registerHooks();", "public function register() {\n\t\t$this->consent->register();\n\n\t\tadd_filter( 'googlesitekit_inline_base_data', $this->get_method_proxy( 'inline_js_base_data' ) );\n\t\tadd_filter( 'googlesitekit_rest_routes', $this->get_method_proxy( 'get_rest_routes' ) );\n\n\t\tadd_filter(\n\t\t\t'googlesitekit_apifetch_preload_paths',\n\t\t\tfunction( $routes ) {\n\t\t\t\treturn array_merge(\n\t\t\t\t\t$routes,\n\t\t\t\t\tarray(\n\t\t\t\t\t\t'/' . REST_Routes::REST_ROOT . '/core/user/data/tracking',\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t}", "public function register_hooks() {\n\t\tadd_action( 'rest_api_init', array( $this, 'register_endpoints' ) );\n\t}", "protected function register_hooks() {\n\t\tadd_action( 'wp_enqueue_scripts', array( $this, 'add_css' ) );\n\t\tadd_action( 'wp_footer', array( $this, 'append_html' ) );\n\t}", "public static function bootApprovalTrait()\n\t{\n\t\tstatic::addGlobalScope( static::makeApprovalScope() );\n\t}", "public function useTokenScope(): void;", "public function register_hooks() {\n\n\t\t// General Filters.\n\t\tadd_filter( 'excerpt_more', array( $this, 'filter_excerpt_more' ) );\n\t\tadd_filter( 'widget_text', 'do_shortcode', 999 );\n\t\tadd_filter( 'plugin_row_meta', array( $this, 'force_plugin_link_new_tab' ), 10, 4 );\n\n\t\t// Make all themes available for main site.\n\t\tadd_filter( 'pre_option_allowedthemes', array( $this, 'filter_allowedthemes' ) );\n\n\t\t// Force all users to have a strong password.\n\t\tadd_filter( 'slt_fsp_caps_check', '__return_empty_array' );\n\n\t\t// Actions.\n\t\tadd_action( 'init', array( $this, 'json_page_login_check' ) );\n\n\t\t// Disable JetPack markdown on pages.\n\t\tadd_action( 'init', array( $this, 'jetpack_markdown_support' ), 20 );\n\n\t\t// Register stuffs.\n\t\tadd_action( 'init', array( $this, 'register_post_types' ) );\n\t}", "public function add_scopes($scopes) {\n\t\t$this->client->AddScopes(\n\t\t\t$scopes\n\t\t);\n\t}", "protected static function boot()\n {\n parent::boot();\n\n static::addGlobalScope(new LanguageIdScope);\n static::addGlobalScope(new ActiveScope);\n static::addGlobalScope(new PrioritySortScope);\n }", "private function hooks() {\n add_filter( 'dokan_withdraw_methods', [ $this, 'register_methods' ] );\n add_filter( 'dokan_get_processing_fee', [ $this, 'get_order_processing_fee' ], 10, 2 );\n add_filter( 'dokan_get_processing_gateway_fee', [ $this, 'get_processing_gateway_fee' ], 10, 3 );\n add_filter( 'dokan_orders_vendor_net_amount', [ $this, 'dokan_orders_vendor_net_amount' ], 10, 5 );\n add_action( 'template_redirect', [ $this, 'authorize_vendor' ] );\n add_action( 'template_redirect', [ $this, 'deauthorize_vendor' ] );\n }", "public function addScope($scope)\n {\n $this->scopes[] = $scope;\n }", "protected static function booted()\n {\n static::addGlobalScope(new OfUserScope);\n }", "public function registerHooks()\n {\n\n $this->_init();\n\n if (!$this->isActive())\n {\n throw new EngineNotInitialisedException('Listener not enabled');\n }\n\n $listeners = $this->getAll();\n $hooks = $this->_dependencies->hooks;\n\n foreach ($listeners as $listener)\n {\n $hooks->addListener($listener->getHook(), function() use ($listener)\n {\n call_user_func_array([$listener, 'run'], func_get_args());\n });\n }\n\n }", "function _register_hooks()\n {\n add_action('init', array(get_class(), 'register_scripts'), 9);\n add_action('ngg_routes', array(&$this, 'define_routes'));\n\t add_action('init', array(&$this, 'serve_ajax_request'));\n }", "public function registerHookCallbacks() {\r\n\r\n\t\t\tadd_action( 'plugins_loaded', array( $this, 'init' ), 1 );\r\n\t\t\tif ( is_admin() ) {\r\n\t\t\t\tadd_action( 'admin_init', array( $this, 'process_admin_swicher' ) );\r\n\t\t\t\tadd_action( 'admin_bar_menu', __CLASS__ . '::adminLanguageSwitcher', 999 );\r\n\t\t\t\tadd_action( 'zwt_language_switcher', array( $this, 'zwt_language_switcher_temp' ), 1 );\r\n\t\t\t} else {\r\n\r\n\t\t\t\tif ( $this->ls_settings[ 'show_footer_selector' ] ) {\r\n\t\t\t\t\tadd_action( 'wp_footer', array( $this, 'language_selector_footer' ), 19 );\r\n\t\t\t\t}\r\n\t\t\t\tif ( !empty( $this->ls_settings[ 'alt_lang_availability' ] ) ) {\r\n\t\t\t\t\tadd_filter( 'the_content', array( $this, 'post_availability' ), 100 );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif ( !is_admin() ) {\r\n\t\t\t\tadd_action( 'wp_head', array( $this, 'custom_language_switcher_style' ), 20 );\r\n\t\t\t\tadd_action( 'wp_head', array( $this, 'add_header_lang_links' ) );\r\n\t\t\t}\r\n\t\t}", "public function addListener() {\n if($this->hasPermission(\"backend\")) {\n $this->addEventListener(\"backend\", \"defineBackend\");\n }\n }", "public function initHooks() {\n\t\t\tif (AppLoader::includeHooks('CommonHooks')) {\n\t\t\t\t$objCommonHooks = new CommonHooks();\n\t\t\t\t$this->registerPreRunHook(array($objCommonHooks, 'verifyToken'));\n\t\t\t\t$this->registerPostRunHook(array($objCommonHooks, 'trackHistory'), array(5, array('css', 'js', 'xml', 'json', 'jsonp', 'html')));\n\t\t\t}\n\t\t\t\t\n\t\t\tif (AppLoader::includeHooks('CacheHooks')) {\n\t\t\t\t$objCacheHooks = new CacheHooks();\n\t\t\t\t$this->registerPreRunHook(array($objCacheHooks, 'serveCache'));\n\t\t\t\t$this->registerPostRunHook(array($objCacheHooks, 'saveCache'));\n\t\t\t}\n\t\t}", "public function init_hooks()\n {\n register_activation_hook(__FILE__, array('\\WordPress_ACL\\install', 'run_install'));\n register_deactivation_hook(__FILE__, array('\\WordPress_ACL\\uninstall', 'run_uninstall'));\n }", "public function load_hooks() {\n\t\t\tadd_filter( 'plugins_api_result', [ $this, 'plugins_api_result' ], 10, 3 );\n\t\t\tadd_filter( 'upgrader_post_install', [ $this, 'upgrader_post_install' ], 10, 3 );\n\t\t}", "protected static function booted()\n {\n static::addGlobalScope(new TenantScope);\n }", "private function register_hooks() {\n\t\t$this->loader->add_action( 'plugins_loaded', $this->i18n, 'load_plugin_textdomain' );\n\n\t\t$this->loader->add_action( 'admin_init', $this->settings, 'register_settings' );\n\t\t$this->loader->add_action( 'admin_menu', $this->settings, 'add_page_menu_item' );\n\n\t\t$this->loader->add_action( 'admin_enqueue_scripts', $this->assets, 'enqueue_admin_styles' );\n\t\t$this->loader->add_action( 'admin_enqueue_scripts', $this->assets, 'enqueue_admin_scripts' );\n\n\t\t$this->loader->add_action( 'wp_enqueue_scripts', $this->assets, 'enqueue_styles' );\n\t\t$this->loader->add_action( 'wp_enqueue_scripts', $this->assets, 'enqueue_scripts' );\n\n\t\t$this->loader->add_action( 'wp_ajax_nopriv_' . FormController::FORM_ACTION, 'SimpleDonationsStripe\\Controllers\\FormController', 'post_donate' );\n\t\t$this->loader->add_action( 'wp_ajax_' . FormController::FORM_ACTION, 'SimpleDonationsStripe\\Controllers\\FormController', 'post_donate' );\n\t}", "private function register_hooks() {\n\t\t\tadd_action( 'plugins_loaded', array( &$this, 'load_textdomain' ), 10, 0 );\n\n\t\t\tadd_action( 'init', array( '\\Ekko\\Core\\CoursePostType', 'singleton' ), 0, 0 );\n\t\t\tadd_action( 'init', array( &$this, 'add_ekko_image_sizes' ), 2, 0 );\n\n\t\t\tadd_action( 'set_user_role', array( &$this, 'user_role_changed' ), 5, 2 );\n\t\t\tadd_action( 'remove_user_from_blog', array( &$this, 'user_removed_from_blog' ), 10, 2 );\n\t\t}", "protected static function boot()\n {\n parent::boot();\n\n static::addGlobalScope(new EnabledScope);\n }", "protected function set_hooks()\n {}", "private function register_hooks() {\n\t\tforeach ( $this->get_hooking_classes() as $class ) {\n\t\t\t$full_class_name = ( $this->namespace . '\\\\' . $class );\n\t\t\t$reflection = new \\ReflectionClass( $full_class_name );\n\n\t\t\tif ( $reflection->implementsInterface( 'UTEC\\Common\\Interfaces\\Has_Hooks' ) ) {\n\t\t\t\t( new $full_class_name() )->hooks();\n\t\t\t}\n\t\t}\n\t}" ]
[ "0.6776419", "0.62116903", "0.6061136", "0.60554343", "0.60202694", "0.5935842", "0.5752371", "0.56923723", "0.5644502", "0.5622957", "0.5567396", "0.5567014", "0.55160767", "0.55104965", "0.54171205", "0.5393654", "0.5390868", "0.537673", "0.53747886", "0.53727716", "0.5370285", "0.53668666", "0.5365578", "0.53628504", "0.53537947", "0.5338909", "0.5326025", "0.5290439", "0.52901345", "0.52877694" ]
0.8149589
0
Convenience function to create a testable instance of an review.
protected function create_instance($course, $params = [], $options = []) { $params['course'] = $course->id; $generator = $this->getDataGenerator()->get_plugin_generator('mod_review'); $instance = $generator->create_instance($params, $options); $cm = get_coursemodule_from_instance('review', $instance->id); $context = context_module::instance($cm->id); return new mod_review_testable_review($context, $cm, $course); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function createAReview()\n {\n }", "public function test_review_creation()\n {\n $rev = new Review (\"Hola\");\n $this->assertTrue($rev->getName()==\"Hola\");\n }", "public function testReviewCreate()\n {\n\n }", "public function testReviewCreate()\n {\n //レビュー作成に必要なインスタンス作成(お店情報など)\n $admin_user = User::factory()->state(['role_id' => '1'])->create();\n $this->actingAs($admin_user);\n $shop = Shop::factory()->state(['name' => '中華B', 'description' => '餃子が絶品'])\n ->for(Area::factory()->state(['area_name' => '新橋']))\n ->for(Category::factory()->state(['category_name' => '中華']))->create();\n\n $response = $this->get(action('App\\Http\\Controllers\\ReviewsController@create', compact('shop')));\n $response ->assertStatus(200)->assertViewIs('review.post');\n }", "function appthemes_create_review( $comment, $rating, $meta = array() ) {\n\treturn APP_Review_Factory::create_post_review( $comment, $rating, $meta );\n}", "public function __construct(Review $review)\n {\n $this->review = $review;\n }", "public function createtest()\n {\n $tt1 = new Review;\n $tt2=new ReviewController;\n $tt3 = new Book;\n $tt3->setauthor(1000000,'a7med7amdy','2019-03-21 00:00:00','2019-03-21 00:00:00');\n $tt3->setBook(1000000,'ppp',1,'dsds','2019-03-21 00:00:00','fgdg','dfgdg','fdgd',4,5,9,1000000,8,'2019-03-21 00:00:00','2019-03-21 00:00:00');\n $tt3->setgenre(1000000,1000000,'action');\n $user=$tt1->getuserMax(); \n $tt1->setshowReviewOfBook(1000000,((int)$user),1000000,'dsds',0,5,4,4,'2019-03-21 00:00:00','2019-03-21 00:00:00');\n $this->assertTrue(true);\n\n }", "public function testReviewPrototypeCreateLikes()\n {\n\n }", "public function testReviewFindOne()\n {\n\n }", "public function testReviewFind()\n {\n\n }", "public function testReviewFindById()\n {\n\n }", "public function test_likePrototypeGetReview() {\n\n }", "public static function get_instance() {\n\t\tif ( ! isset( self::$instance ) && ! ( self::$instance instanceof EDD_Reviews ) || self::$testing ) {\n\t\t\tself::$instance = new EDD_Reviews;\n\t\t\tself::$instance->setup_globals();\n\t\t\tself::$instance->load_classes();\n\t\t\tself::$instance->hooks();\n\t\t\tself::$instance->updater();\n\t\t\tself::$instance->request_review = new EDD_Reviews_Request_Review;\n\t\t\tself::$instance->reports = new EDD_Reviews_Reports;\n\n\t\t\tif ( class_exists( 'Easy_Digital_Downloads', false ) ) {\n\t\t\t\tself::$instance->upgrade();\n\t\t\t}\n\t\t}\n\n\t\treturn self::$instance;\n\t}", "public static function newFactory()\n {\n return ProductReviewImageFactory::new();\n }", "public function testWithProvider()\n {\n $reviews = new Reviews($this->config);\n\n $this->assertInstanceOf('PodPoint\\\\Reviews\\\\Providers\\\\Foo\\\\Provider', $reviews->withProvider('foo'));\n }", "public function castToReview($obj){\n\t\t$r = new CurtReview();\n\t\tif(isset($obj->reviewID)){\n\t\t\t$r->setReviewID($obj->reviewID); \n\t\t}\n\t\tif(isset($obj->partID)){\n\t\t\t$r->setPartID($obj->partID); \n\t\t}\n\t\tif(isset($obj->rating)){\n\t\t\t$r->setRating($obj->rating); \n\t\t}\n\t\tif(isset($obj->subject)){\n\t\t\t$r->setSubject($obj->subject); \n\t\t}\n\t\tif(isset($obj->review_text)){\n\t\t\t$r->setReview_text($obj->review_text); \n\t\t}\n\t\tif(isset($obj->name)){\n\t\t\t$r->setName($obj->name); \n\t\t}\n\t\tif(isset($obj->email)){\n\t\t\t$r->setEmail($obj->email); \n\t\t}\n\t\tif(isset($obj->createdDate)){\n\t\t\t$r->setCreateDate($obj->createdDate); \n\t\t}\n\t\treturn $r;\n\t}", "public function testSaveReview()\n {\n $this->setRequestParameter(\"recommlistrating\", 3);\n $this->setRequestParameter(\"rvw_txt\", \"testRecommId\");\n\n /** @var oxSession|PHPUnit_Framework_MockObject_MockObject $oSession */\n $oSession = $this->getMock(\\OxidEsales\\Eshop\\Core\\Session::class, array('checkSessionChallenge'));\n $oSession->expects($this->once())->method('checkSessionChallenge')->will($this->returnValue(true));\n \\OxidEsales\\Eshop\\Core\\Registry::set(\\OxidEsales\\Eshop\\Core\\Session::class, $oSession);\n\n /** @var oxRecommList|PHPUnit_Framework_MockObject_MockObject $oRecommList */\n $oRecommList = $this->getMock(\\OxidEsales\\Eshop\\Application\\Model\\RecommendationList::class, array(\"addToRatingAverage\", \"getId\"));\n $oRecommList->expects($this->once())->method('addToRatingAverage');\n $oRecommList->expects($this->any())->method('getId')->will($this->returnValue(\"testRecommListId\"));\n\n /** @var oxUser|PHPUnit_Framework_MockObject_MockObject $oUser */\n $oUser = $this->getMock(\\OxidEsales\\Eshop\\Application\\Model\\User::class, array(\"getId\"));\n $oUser->expects($this->any())->method('getId')->will($this->returnValue(\"testUserId\"));\n\n /** @var RecommList|PHPUnit_Framework_MockObject_MockObject $oView */\n $oView = $this->getMock(\\OxidEsales\\Eshop\\Application\\Controller\\RecommListController::class, array(\"getActiveRecommList\", \"getUser\", \"canAcceptFormData\"));\n $oView->expects($this->any())->method('canAcceptFormData')->will($this->returnValue(true));\n $oView->expects($this->any())->method('getUser')->will($this->returnValue($oUser));\n $oView->expects($this->any())->method('getActiveRecommList')->will($this->returnValue($oRecommList));\n\n $oView->saveReview();\n\n $oDb = oxDb::getDb();\n\n // testing db for records\n $this->assertTrue(\"1\" === $oDb->getOne(\"select 1 from oxratings where oxuserid='testUserId' and oxrating = '3' and oxobjectid = 'testRecommListId'\"));\n $this->assertTrue(\"1\" === $oDb->getOne(\"select 1 from oxreviews where oxuserid='testUserId' and oxobjectid = 'testRecommListId'\"));\n }", "public function testAddReview()\n {\n // @see https://symfony.com/doc/current/testing.html#logging-in-users-authentication\n $client = static::createClient();\n \n $userRepository = static::$container->get(UserRepository::class);\n\n // retrieve the test user\n $testUser = $userRepository->findOneByEmail('[email protected]');\n\n // simulate $testUser being logged in\n $client->loginUser($testUser);\n\n // test e.g. the profile page\n $client->request('GET', '/review/add');\n $this->assertResponseIsSuccessful();\n $this->assertSelectorTextContains('h1', 'Connexion');\n }", "public function testReviewCount()\n {\n\n }", "public function testConstruct()\n {\n $reviews = new Reviews($this->config);\n\n $this->assertEquals($this->config, $reviews->getConfig());\n }", "public function testReviewCreateChangeStreamPostReviewsChangeStream()\n {\n\n }", "public function show(Review $review)\n {\n return new ReviewResource($review);\n }", "public static function buildReviewService() {\n\t$reivewService = new ReviewService(self::$apiKey, self::$secretKey);\n\t\treturn $reivewService;\n\t}", "private static function create($text, MongoId $recruiter = null) {\n // Check if question already exists (model function). If so, return\n // the question.\n $existingQuestion = QuestionModel::getByExactText($text);\n if (!is_null($existingQuestion)) {\n return self::parseRawData($existingQuestion);\n }\n\n // Construct question with parameters.\n $vanilla = is_null($recruiter);\n $question = new Question([\n 'text' => $text,\n 'recruiter' => $recruiter,\n 'vanilla' => $vanilla\n ]);\n\n // Pass (question object or raw data?) to model to store in database with\n // custom flag.\n $id = QuestionModel::insert($question->getData());\n $question->setId($id);\n\n // Return created question.\n return $question;\n }", "public function testReviewPrototypeCreateImage()\n {\n\n }", "function appthemes_get_review( $id ) {\n\treturn APP_Review_Factory::retrieve( $id );\n}", "public function testReviewPrototypeCreateVideo()\n {\n\n }", "public function testReviewPrototypeFindByIdLikes()\n {\n\n }", "public function setReview($review)\n {\n $this->review = $review;\n\n return $this;\n }", "public function setReview($review)\n {\n $this->review = $review;\n\n return $this;\n }" ]
[ "0.70466137", "0.6867093", "0.6713318", "0.6633199", "0.63927084", "0.6307202", "0.62625813", "0.6063826", "0.5970841", "0.5909564", "0.5808505", "0.5783471", "0.5775128", "0.5771659", "0.56472075", "0.56294036", "0.5626073", "0.56027603", "0.550649", "0.550363", "0.5444881", "0.5439413", "0.5436835", "0.5426545", "0.5411922", "0.540323", "0.540169", "0.5361548", "0.5359663", "0.5359663" ]
0.72792673
0
Add a user submission to the review.
protected function add_submission($student, $review, $onlinetext = null, $changeuser = true) { // Add a submission. if ($changeuser) { $this->setUser($student); } if ($onlinetext === null) { $onlinetext = 'Submission text'; } $data = (object) [ 'userid' => $student->id, 'onlinetext_editor' => [ 'itemid' => file_get_unused_draft_itemid(), 'text' => $onlinetext, 'format' => FORMAT_HTML, ] ]; $review->save_submission($data, $notices); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function p_add()\n {\n $_POST = DB::instance(DB_NAME)->sanitize($_POST);\n \n # Associate this post with this user\n $_POST['user_id'] = $this->user->user_id;\n \n # Unix timestamp of when this post was created / modified\n $_POST['created'] = Time::now();\n $_POST['modified'] = Time::now();\n \n # Insert the post date to the database\n DB::instance(DB_NAME)->insert('posts', $_POST);\n \n # Send them to the posts list where they can view their new post\n Router::redirect(\"/posts/index/confirmation\");\n \n }", "public function add(Post $postData, User $user): void\n {\n $postData->setPostedBy($user);\n $this->entityManager->persist($postData);\n $this->entityManager->flush();\n }", "public function p_add(){\n\t\t\t$_POST['user_id'] = $this->user->user_id;\n\n\t\t\t#Add Unix time stamp for the post\n\t\t\t$_POST['created'] = Time::now();\n\t\t\t$_POST['modified'] = Time::now();\n\n\t\t\t#Insert\n\t\t\tDB::instance(DB_NAME)->insert('posts', $_POST);\n\t\t\tRouter::redirect(\"/posts\");\n\t\t}", "public function update(User $user, Submission $submission)\n {\n //\n }", "public function addReviewByStudent_post()\n {\n /* code goes here */\n }", "public function postAddReview(Request $request)\n {\n //validation\n $v = Validator::make($request->all(), \n [\n //Validation parameters\n 'star' => 'required|integer|in:1,2,3,4,5',\n 'review' => 'required|string',\n ]);\n\n //Checking validation outcome\n if ($v->fails()) {\n /**\n * Validation failed\n * Redirecting back to the page with errors and inputs\n */\n return back()->withErrors($v)->withInput();\n\n } else {\n /**\n * Validation passed\n * Checking if the learner has already submitted a review for the instructor\n */\n $no_of_review = Review::where('learner_id', $request->user()->learner->learner_id)->where('Instructor_id', $request->instructor_id)->count();\n\n if ($no_of_review == 0) {\n //If no review has submitted for the selected instructor by the current user\n //Create the review\n $review = Review::create(\n [\n 'learner_id' => $request->user()->learner->learner_id,\n 'instructor_id' => $request->instructor_id,\n 'rating' => $request->star,\n 'review' => $request->review\n ]);\n\n if ($review) {\n //If review is created successfully\n //Send an e-mail to the instructor\n \n /*Write an e-mail function here*/\n\n //Redirect the user\n return redirect()->route('home')->with('message', 'Review added')->with('alert-class', 'alert-success');\n } else {\n //If creating review was unsuccessfull\n return redirect()->route('home')->with('message', 'Review could not be added')->with('alert-class', 'alert-danger');\n } //End of if statement\n \n } else {\n //If review has been submitted previously for the selected instructor by the current user\n return redirect()->route('home')->with('message', 'You have already submitted a review for this instructor!')->with('alert-class', 'alert-danger');\n\n } //End of if statement\n } //End of if statement\n }", "public function p_add() \n {\n $_POST['user_id'] = $this->user->user_id;\n\n // timestamp the post\n $_POST['created'] = Time::now();\n $_POST['modified'] = Time::now();\n\n $rows = DB::instance(DB_NAME)->insert('posts', $_POST);\n\n if ($rows > 0) {\n Router::redirect('/users/index/' . $this->user->user_name);\n //echo \"Your post has been added.\";\n //echo \"<a href='/posts/add'>Add another</a>\";\n } else {\n \n }\n \n //echo Debug::dump($_POST);\n\n }", "public function addReview()\n {\n }", "public function p_add() {\n\t\t\t\t\t$_POST['user_id'] = $this->user->user_id;\n\t\n\t\t\t\t\t# Unix timestamp of when this post was created / modified\n\t\t\t\t\t$_POST['created'] = Time::now();\n\t\t\t\t\t$_POST['modified'] = Time::now();\n\t\n\t\t\t\t\t# Insert to database\n\t\t\t\t\tDB::instance(DB_NAME)->insert('posts', $_POST);\n\t\n\t\t\t\t\t# Redirect after insert\n\t\t\t\t\tRouter::redirect(\"/posts\");\n\t\n\t\t\t}", "private function addQuestionToUser()\n {\n $this->di->dispatcher->forward([\n 'controller' => 'user-question',\n 'action' => 'add',\n 'params' => [$this->userId, $this->lastInsertedId]\n ]);\n }", "public function p_add() {\n \n $_POST['user_id'] = $this->user->user_id;\n $_POST['created'] = Time::now();\n $_POST['modified'] = Time::now();\n \n DB::instance(DB_NAME)->insert('posts',$_POST);\n \n Router::redirect('/posts/');\n \n }", "public function add_author_review(Request $request)\n {\n $requestData = $request->all(); \n $author_review = AuthorReview::create($requestData); \n return redirect(\"/home\");\n }", "public function add()\n {\n $post = new Post;\n $post->setAttribute('name', 'Another Post');\n $post->setAttribute('user_id', '1');\n $post->save();\n }", "public function post_user()\n\t{\n\t\t$this->get_user();\n\t}", "public function post_user()\n\t{\n\t\t$this->get_user();\n\t}", "public function addApproval(BackendUser $backendUser): void;", "public function r_add() {\n $title = $_POST['title'];\n $content = $_POST['content'];\n\n if(empty($title) || empty($content) ){\n echo \"Please fill in both fields\";\n sleep(1);\n Router::redirect(\"/readings/add\");\n }\n\n\n else{\n # Associate this post with this user\n $_POST['user_id'] = $this->user->user_id;\n\n # Unix timestamp of when this post was created / modified\n $_POST['created'] = Time::now();\n $_POST['modified'] = Time::now();\n\n # Insert\n # Note we didn't have to sanitize any of the $_POST data because we're using the insert method which does it for us\n DB::instance(DB_NAME)->insert('posts', $_POST);\n\n #Redirect to user's profile/list of posts\n Router::redirect(\"/users/profile\");\n }\n\n }", "public function addReviewForFood($user_id, $food_id, $rating, $review){\n\t\t$rating = min(max(1, $rating), self::$HIGHEST_RATING);\n\t\t\n\t\tif (!$this->db->query('insert into food_review\n\t\t\t(food_id, user_id, rating, review)\n\t\t\tvalues (?,?,?,?)', array($food_id, $user_id, $rating, $review))){\n\t\t\t\t\n\t\t\tthrow new Exception($this->db->error());\n\t\t}\n\t\t\n\t\treturn $this->db->insert_id();\n\t}", "public function approve(User $user, Submission $submission)\n {\n if ($user->role !== 'dean') {\n return false;\n }\n\n return $user->faculty_id === $submission->lecturer->study->faculty_id;\n }", "public function save(Post $user)\n {\n }", "public function store(Request $request, User $user)\n {\n $user = auth()->user()->id;\n\n \n $game =$request->game_id;\n\n dd($user, $game);\n // $titre = $request->input('titre');\n // $contenu = $request->input('contenu');\n // $note = $request->input('note');\n\n\n\n // $review = new Review();\n // $review->titre = $titre;\n // $review->avis = $contenu;\n // $review->note = $note;\n // $review->game_id = $game_id;\n // $review->user_id = $user;\n \n\n // // $review->save();\n\n // if($review->save()){\n // $request->session()->flash('success', \"Merci pour votre avis\");\n // }else{\n // $request->session()->flash('error', \"L'avis n'as pas pu être posté\");\n // };\n\n // return redirect()->route('member.game.show');\n }", "public function run()\n {\n Submission::create([\n 'user_id' => '12',\n 'reason' => 'baru menikah',\n 'status' => Submission::STATUS_PENDING\n ]);\n }", "public function markUserVote(Submission $submission)\n\t{\n\t\tif ( ! Auth::check()) {\n\t\t\treturn;\n\t\t}\n\n\t\t$submissionVote = $submission->votes()->where('user_id', Auth::user()->id)->first();\n\n\t\tif ( ! $submissionVote) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ($submissionVote->up) {\n\t\t\t$submission->setUserUp();\n\t\t}\n\t\telse {\n\t\t\t$submission->setUserDown();\n\t\t}\n\t}", "public function store(Request $request, Post $post, User $user)\n {\n \t\t$data = $request->validate([\n \t\t\t'comment' => 'required|max:255',\n \t\t]);\n\n \t\t$post->comments()->create(array_merge($data, ['user_id' => auth()->user()->id]));\n\n $post_owner = User::find($post->user_id);\n $commentor = auth()->user();\n\n if($post_owner != $commentor){\n $post_owner->notify(new commented($commentor, $post, $post_owner));\n }\n\n \t\treturn redirect(route('post.show', $post));\n }", "public function create()\n {\n $data = array(\n 'title' => $_POST['title'],\n 'content' => $_POST['content']\n );\n \n // calling the model to insert the user\n $this->model->create($data);\n \n // refreshing the page to display the new added user\n header('location: ' . URL . 'note');\n }", "public function add_submit()\n\t{\n\t\t// Run validation\n\t\tif (!$this->validate_participant(FALSE))\n\t\t{\n\t\t\t// If not succeeded, show form again with error messages\n\t\t\t$language_array = $this->create_language_array();\n\t\t\t$this->add($language_array);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// If succeeded, create the participant\n\t\t\t$participant = $this->post_participant();\n\t\t\t$participant_id = $this->participantModel->add_participant($participant);\n\n\t\t\t// Add (possible) comment\n\t\t\t$comment = $this->post_comment($participant_id);\n\t\t\tif ($comment) $this->commentModel->add_comment($comment);\n\n\t\t\t// Create the languages\n\t\t\t$this->create_languages($participant_id);\n\n\t\t\t// Activate the participant (only on manual creation from the application!)\n\t\t\t$this->participantModel->activate($participant_id);\n\n\t\t\t// Display success\n\t\t\t$p = $this->participantModel->get_participant_by_id($participant_id);\n\t\t\tflashdata(sprintf(lang('new_pp_added'), name($p)));\n\t\t\tredirect('/participant/', 'refresh');\n\t\t}\n\t}", "public function create()\n {\n if(! $userData = session('user') )\n return redirect('auth/login');\n\n return view('submission/new', ['userData' => $userData]); \n }", "public function store(Request $request)\n {\n $this->validate($request, [\n 'path_url' => 'required',\n ]);\n\n $user = User::find(Auth::user()->id);\n $type = 0;\n\n if($user->role_id == 2) {\n if($user->team->progress == 2) {\n $type = 1; // web\n }\n } else {\n if($user->team->progress == 2) {\n $type = 2; // proposal\n } else if ($user->team->progress == 3) {\n $type = 3; // aplikasi\n }\n }\n\n $submission = new Submission;\n $submission->user_id = Auth::user()->id;\n $submission->type = $type;\n $submission->path_url = $request->path_url;\n $submission->save();\n\n Session::flash('message', 'Your submission has sent!');\n return redirect('dashboard');\n }", "function appthemes_create_user_review( $recipient_id, $comment, $rating, $meta = array() ) {\n\treturn APP_Review_Factory::create_user_review( $recipient_id, $comment, $rating, $meta );\n}", "public function noteAdd(){\n $user = $this->_ap_right_check();\n if(!$user){\n return;\n } \n $this->Notes->add($user);\n }" ]
[ "0.6139389", "0.602282", "0.6014315", "0.59671104", "0.5907753", "0.59066385", "0.5896258", "0.58956444", "0.588039", "0.58763057", "0.58556414", "0.58526", "0.5730336", "0.56818026", "0.56818026", "0.56618524", "0.5649345", "0.5546206", "0.55055463", "0.5504938", "0.546079", "0.54384714", "0.5435252", "0.54272", "0.5410299", "0.54064757", "0.53920984", "0.53808016", "0.53740686", "0.53619874" ]
0.6606107
0
Returns the base URL to the gateway.
public function get_base_gateway_url() { return get_option('wc_wallee_base_gateway_url', 'https://app-wallee.com/'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getGatewayUrl()\n {\n if ($this->isTestMode())\n {\n return $this->_getConfig('test_gateway_url');\n } else {\n return $this->_getConfig('gateway_url');\n }\n }", "public function getUrlBase()\n { \n return 'http'\n .(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '')\n .'://'.$_SERVER['SERVER_NAME']\n .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '');\n }", "public function get_base_url()\n {\n return $this->get_config('mode') === self::LIVE_MODE ?\n \"https://login.remita.net\" :\n \"https://remitademo.net\";\n }", "public function getUrlBase() {\n return 'http'\n . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '')\n . '://'.$_SERVER['SERVER_NAME']\n . ($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '');\n // . $this->getUrlSub();\n }", "public static function getBaseURL() {\n return \"http\".(self::getEnv('SERVER_PORT') == 443 ? \"s://\" : \"://\").\n self::getEnv('HTTP_HOST').self::$ini_config['kernel']->getKey('BasePathRouter').'/'.\n explode('_', \\session::get('language'))[0];\n }", "public static function getUrl()\n {\n return self::$baseURL;\n }", "public function getBaseUrl()\n\t{\n\t\treturn $this->base_url;\n\t}", "public function getBaseUrl()\n {\n $storeManager = $this->objectManager->get('Magento\\Store\\Model\\StoreManagerInterface');\n\n return $storeManager->getStore()->getBaseUrl();\n }", "public function getBaseUrl()\n {\n $storeManager = $this->objectManager->get('Magento\\Store\\Model\\StoreManagerInterface');\n\n return $storeManager->getStore()->getBaseUrl();\n }", "private function getBaseUrl() {\n $uri = $this->getRequest()->getUri();\n return sprintf('%s://%s', $uri->getScheme(), $uri->getHost());\n }", "private function getBaseUrl() {\n $uri = $this->getRequest()->getUri();\n return sprintf('%s://%s', $uri->getScheme(), $uri->getHost());\n }", "private function getBaseUrl() {\n return $this->protocol . '://' . $this->address . '/webapi/';\n }", "public function getBaseUrl()\n {\n return $this->base_url;\n }", "public function getBaseUrl()\n {\n return $this->base_url;\n }", "public function getBaseUrl()\n {\n return $this->base_url;\n }", "public function getBaseUrl()\n {\n return $this->base_url;\n }", "public static function base_url()\n\t{\n\t\treturn \\Mooo\\System\\Core\\Mooo::$base_url;\n\t}", "public function _getBaseUrl() {\n\t\treturn Geko_Uri::getBase();\n\t}", "public function getBaseUrl(): string\n {\n return $this->base_url;\n }", "public static function getApiUrl() {\n return static::$gatewayUrl;\n }", "protected function getBaseUrl()\n {\n return $this->utils->getBaseUrl();\n }", "public function getBaseUrl()\n {\n if (!$this->isValid) {\n return $this->default;\n }\n\n if (NULL !== $this->baseurl) {\n return $this->baseurl;\n }\n\n $this->baseurl = $this->getScheme() . self::SEPARATOR . $this->getHost();\n\n return $this->baseurl;\n }", "public function getBaseUrl() {\n return $this->url;\n }", "public function getBaseUrl();", "public function getBaseUrl();", "public function baseUri()\n {\n return $this->base_url;\n }", "public function getGeneralBaseUrl()\n {\n return config(\"devpilot.general.base_url\");\n }", "public function getBaseURL() {\n return $this->getConfig('url', $this->base) ;\n }", "public function getBaseUrl(){\n\t\treturn $this->_objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore(1)->getBaseUrl();\n\t}", "public function getBaseUrl()\n\t{\n\t\treturn self::URL_MANAGEMENT . '/' . $this->_subscriptionId;\n\t}" ]
[ "0.81081206", "0.7877913", "0.78647614", "0.78417355", "0.78289676", "0.77928025", "0.77666277", "0.7763748", "0.7763748", "0.7755838", "0.774174", "0.7713836", "0.77086747", "0.77086747", "0.77086747", "0.77086747", "0.76993644", "0.76984155", "0.7694506", "0.76796526", "0.7675197", "0.76708984", "0.7658927", "0.76436484", "0.76436484", "0.76405865", "0.7600404", "0.7599834", "0.75962585", "0.7580448" ]
0.833687
0
Returns the total amount including tax of the given line items.
public function get_total_amount_including_tax(array $line_items) { $sum = 0; foreach ($line_items as $line_item) { $sum += $line_item->getAmountIncludingTax(); } return $sum; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function item_tax()\n\t{\n\t\t$amount = 0; \n\n\t\tforeach ($this->taxable_items() as $item)\n\t\t{\n\t\t\t$amount += $item->tax() * $item->quantity();\n\t\t}\n\n\t\treturn $amount; \n\t}", "public function totalAmount() {\n \n return $this->subtotal() + $this->allTaxes();\n }", "public function getTotal(): float\n {\n $value = $this->lineItems->reduce(static function (float $value, LineItem $item): float {\n return $value + $item->getTotal();\n }, -$this->discount);\n\n return round($value < 0 ? 0 : $value, 2);\n }", "public function taxableTotal()\r\n {\r\n $total = 0;\r\n \r\n /*\r\n foreach ($this->items as $item)\r\n {\r\n // is the item taxable?\r\n if ($taxable = \\Dsc\\ArrayHelper::get( $item, 'product.taxes.enabled' ))\r\n {\r\n $total = $total + \\Dsc\\ArrayHelper::get( $item, 'price' );\r\n }\r\n } \r\n */\r\n \r\n $total = $total + $this->subtotal();\r\n \r\n if ($shippingMethod = $this->shippingMethod())\r\n {\r\n $total = $total + $shippingMethod->total();\r\n }\r\n \r\n $total = $total - $this->discountTotal() - $this->creditTotal();\r\n \r\n if ($total < 0) {\r\n $total = 0;\r\n }\r\n \r\n return (float) $total;\r\n }", "public function getTotalWithTaxes()\n {\n $total_ttc = 0;\n\n foreach ($this->getItems() as $item)\n {\n if ($this->is_unit_price_ttc)\n {\n $total_ttc += $item->getQuantity() * $item->getPriceDueToday() * (1 - $item->getDiscount() / 100);\n }\n else\n {\n $total_ttc += $item->getQuantity() * $item->getPriceDueToday() * (1 - $item->getDiscount() / 100) * (1 + $this->tax / 100);\n }\n }\n \n $total_ttc = $this->applyDiscounts($total_ttc);\n\n return $total_ttc;\n }", "public function calculate_order_total(){\r\n $this->order_total = 0;\r\n foreach($this->items as $item){\r\n $this->order_total += $this->getItemSubTotal($item);\r\n }\r\n $this->sales_tax_amount = ($this->order_total * $this->sales_tax);\r\n return $this->order_total + $this->sales_tax_amount;\r\n }", "public function getTotalPayed()\n {\n $total = 0;\n\n foreach ($this->getAccountLines() as $accountLine) {\n $total += $accountLine->getValueTaxInclude();\n }\n\n return $total;\n }", "public function getTaxTotal()\n {\n $value = $this->getTax()->multiply($this->qty);\n return $value;\n }", "public function getTotal() : float\n {\n return $this->items->pluck('amount')->sum();\n }", "public function getTaxAmount();", "function calcTotal() {\n\t\t$order = $this->controller->Session->read('Order');\n\t\t$subtotal = 0;\t\n\n\t\tforeach ($order['LineItem'] as $id => $lineItem) {\n\n\t\t\t$lineQuantity = 0;\n\t\t\t$lineTotal = 0;\n\t\t\tforeach ($lineItem['Selection'] as $count => $selection) {\n\t\t\t\t$selectionTotal = $selection['price'] * $selection['quantity'];\n/*\t\t\t\tif ($selection['taxable'])\n\t\t\t\t\t$selectionTotal += $selectionTotal * $this->taxRate;*/\n\t\t\t\t$subtotal += $selectionTotal;\n\n\t\t\t\t$lineQuantity += $selection['quantity'];\n\t\t\t\t$lineTotal += $selectionTotal;\n\t\t\t}\n\n\t\t\t$totals = array(\n\t\t\t\t'quantity' => $lineQuantity,\n\t\t\t\t'subtotal' => $lineTotal,\n\t\t\t\t'numAttribs' => count($selection['attributes']),\n\t\t\t);\n\n\t\t\t$this->controller->Session->write('Order.LineItem.' . $id . '.Totals', $totals);\n\t\t}\n\n\t\t$tax = sprintf('%.2f', $subtotal * $this->taxRate);\n\n\t\t$shipping = 0;\n\t\tif ($this->shipRate > 0) {\n\t\t\t$shipping = ($this->shipFlat) ? $this->shipRate : $subtotal * $this->shipRate;\n\t\t} elseif (!empty($order['Totals']) && $order['Totals'] > 0) {\n\t\t\t$shipping = $order['Totals']['shipping'];\t\n\t\t}\n\n\t\t$total = $subtotal + $tax + $shipping;\n\n\t\t$data = array(\n\t\t\t'subtotal' => $subtotal,\n\t\t\t'tax' => $tax,\n\t\t\t'shipping' => $shipping,\n\t\t\t'total' => $total,\n\t\t);\n\n\t\treturn $this->controller->Session->write('Order.Totals', $data);\n\t}", "public function getTotal()\n {\n $value = $this->getPriceWithTax()->multiply($this->qty);\n return $value;\n }", "public function getTotal(): float\n {\n return $this->gross + $this->taxes;\n }", "function calculate_total_tax() \r\n\t{\r\n\t\t$total = 0;\r\n\r\n\t\tforeach ($this->contents as $product_id=>$product)\r\n\t\t{\r\n\t\t\tif ($product_id == -1)\r\n\t\t\t\tcontinue;\r\n\t\t\t\t\t\r\n\t\t\tforeach ($product[\"color\"] as $color=>$quantity)\r\n\t\t\t{\t\t\t\t\r\n\t\t\t\t$price = $product['price'];\r\n\t\t\t\t$subtotal = $price * $quantity;\r\n\t\t\t\t$total += $subtotal;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn $total;\r\n }", "public function getPurchaseTaxAmount()\n {\n $items = $this->getItemsCollection();\n $tax = 0;\n foreach ($items as $_item) {\n $tax += $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount();\n }\n return $tax;\n }", "public function getTotal(): float\n\t{\n\t\t$total = 0;\n\n\t\tforeach ($this->items as $item) {\n\n\t\t\t$total += $item->getPrice();\n\t\t}\n\n\t\treturn $total;\n\t}", "public function getTotal()\n {\n $total = $this->_getTotal();\n\n if ( ! empty($this->_tax)) {\n foreach ($this->_tax as $tax) {\n $total += $total * $tax;\n }\n }\n\n return number_format($total, 2);\n }", "public function get_total() {\n $total = 0;\n if (!empty($this->items)) {\n foreach ($this->items as $item) {\n if (!empty($item['discount'])) {\n $total += $item['quantity'] * $item['price'] * ($item['discount'] / 100);\n } else {\n if($item['total'] != 0){\n $total = $item['total'];\n }\n }\n }\n \n foreach ($this->items as $item) {\n if (!empty($item['discount'])) {\n $total += $item['quantity'] * $item['price'] * ($item['discount'] / 100);\n } else {\n if($item['price'] > 0 && empty($item['total'])){\n $total += $item['quantity'] * $item['price'];\n }\n }\n }\n }\n return $total;\n }", "public function total()\r\n {\r\n \t// do these calculations before getting the taxes\r\n $total = $this->subtotal();\r\n \t$discount_total = $this->discountTotal(); \r\n \t$giftcard_total = $this->giftCardTotal(); \r\n \t$credit_total = $this->creditTotal();\r\n \t\r\n \t// get taxes\r\n if ($shippingMethod = $this->shippingMethod()) \r\n {\r\n \t$total = $total + $shippingMethod->total();\r\n \t$total = $total + $this->taxTotal();\r\n } \r\n else \r\n {\r\n $total = $total + $this->shippingEstimate();\r\n $total = $total + $this->taxEstimate();\r\n }\r\n \r\n // do these calculations again after getting taxes\r\n $total = $total - $this->discountTotal() - $this->giftCardTotal() - $this->creditTotal();\r\n \r\n if ($total < 0) {\r\n $total = 0;\r\n }\r\n \r\n return (float) $total;\r\n }", "public function getTotal(){\n\t\t$total = 0;\n\n\t\tforeach ($this->items as $id) {\n\t\t\t\t\t\t$subtotal = $id['qty'] * ($id['item']->getPrice());\n\t\t\t\t\t\t$total += $subtotal;\n\t\t\t\t\t}\n\n\t\treturn $total;\t\t\t\n\t}", "public function getLineTotal();", "function getTotalWithOutTax(){\n\n $qrySel = \"SELECT SUM(price * quantity) total\n FROM lineitems i \n WHERE i.endeffdt is NULL\";\n\n $result = $this->objDBConn->execQuery($qrySel);\n if($result){\n $row = $result->fetch_assoc(); \n return $row['total'];\n }\n else{\n return 0;\n }\n }", "public function getTaxTotal()\n {\n return $this->taxTotal;\n }", "public function getBaseTaxAmount()\n {\n $items = $this->getItemsCollection();\n $tax = 0;\n foreach ($items as $_item) {\n $tax += $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() +\n $_item->getBaseWeeeTaxAppliedRowAmount();\n }\n return $tax;\n }", "public function getTotal()\n {\n return $this->getPrixHorsTaxe() + $this->getTaxe() - $this->getRemise();\n }", "function GetItemTotalPrice($item){\n\t\treturn $item['ItemPrice'] * $item['ItemQty'];\n\t}", "private function calculateTotal() {\n $this->total = 0.00;\n if($this->hasItems()) {\n $tot = 0.00;\n foreach($this->items as $item) {\n $tot += $item['subtotal'];\n }\n $this->total = $tot;\n }\n }", "public function getShippingTaxAmount();", "function getTotal(){\n\t\t$items = $this->Items();\n\t\t$sum = 0;\n\t\tif ($items){\n\t\t\tforeach ($items as $item) {\n\t\t\t\t$sum+= $item->getSubTotal();\n\t\t\t}\n\t\t}\n\t\treturn $sum;\n\t}", "function GetItemTotalPrice($item){\n\t\t\treturn $item['ItemPrice'] * $item['ItemQty']; \n\t\t}" ]
[ "0.7507004", "0.71850187", "0.7155653", "0.7142882", "0.71402013", "0.7017709", "0.70176226", "0.7005494", "0.698303", "0.69710124", "0.6953099", "0.68637234", "0.6824574", "0.68005794", "0.67783296", "0.6771207", "0.67667234", "0.6713924", "0.6713708", "0.67072445", "0.6688072", "0.6668026", "0.6666421", "0.66646934", "0.66396195", "0.6630486", "0.66230804", "0.6595923", "0.65812635", "0.655927" ]
0.8674104
0
Cleans the given line items by ensuring uniqueness and introducing adjustment line items if necessary.
public function cleanup_line_items(array $line_items, $expected_sum, $currency) { $effective_sum = $this->round_amount($this->get_total_amount_including_tax($line_items), $currency); $rounded_expected_sum = $this->round_amount($expected_sum, $currency); $inconsistent_amount = $rounded_expected_sum - $effective_sum; if ($inconsistent_amount != 0) { $enforce_consistency = get_option(WooCommerce_Wallee::CK_ENFORCE_CONSISTENCY); switch ($enforce_consistency){ case 'no': $line_item = new \Wallee\Sdk\Model\LineItemCreate(); $line_item->setAmountIncludingTax($this->round_amount($inconsistent_amount, $currency)); $line_item->setName(__('Adjustment', 'woo-wallee')); $line_item->setQuantity(1); $line_item->setSku('adjustment'); $line_item->setUniqueId('adjustment'); $line_item->setShippingRequired(false); $line_item->setType($enforce_consistency > 0 ? \Wallee\Sdk\Model\LineItemType::FEE : \Wallee\Sdk\Model\LineItemType::DISCOUNT); $line_items[] = $line_item; break; default: throw new WC_Wallee_Exception_Invalid_Transaction_Amount($effective_sum, $rounded_expected_sum); } } $data = $this->ensure_unique_ids($line_items); return $data; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function unsetLineItems(): void\n {\n $this->lineItems = [];\n }", "public function ensure_unique_ids(array $line_items)\n {\n $unique_ids = array();\n foreach ($line_items as $line_item) {\n $unique_id = $line_item->getUniqueId();\n if (empty($unique_id)) {\n $unique_id = preg_replace(\"/[^a-z0-9]/\", '', strtolower($line_item->getSku()));\n }\n if (empty($unique_id)) {\n throw new Exception(\"There is an invoice item without unique id.\");\n }\n if (isset($unique_ids[$unique_id])) {\n $backup = $unique_id;\n $unique_id = $unique_id . '_' . $unique_ids[$unique_id];\n $unique_ids[$backup] ++;\n } else {\n $unique_ids[$unique_id] = 1;\n }\n \n $line_item->setUniqueId($unique_id);\n }\n \n return $line_items;\n }", "public function clean()\n {\n return $this->createFrom(array_filter($this->items));\n }", "public function testLineItem() {\n $line_item = LineItem::create([\n 'type' => 'test',\n 'unit_price' => new Price(9.99, 'USD'),\n ]);\n $line_item->save();\n\n $line_item->addAdjustment(new Adjustment([\n 'type' => 'discount',\n 'label' => '10% off',\n 'amount' => new Price(-1.00, 'USD'),\n 'source_id' => '1',\n ]));\n $this->assertEquals(8.99, $line_item->total_price->amount);\n $line_item->addAdjustment(new Adjustment([\n 'type' => 'order_adjustment',\n 'label' => 'Random fee',\n 'amount' => new Price(2.00, 'USD'),\n 'source_id' => '',\n ]));\n $this->assertEquals(10.99, $line_item->total_price->amount);\n\n $adjustments = $line_item->getAdjustments();\n $this->assertEquals(2, count($adjustments));\n\n foreach ($adjustments as $adjustment) {\n $line_item->removeAdjustment($adjustment);\n }\n $this->assertEquals(9.99, $line_item->total_price->amount);\n $line_item->setAdjustments($adjustments);\n $this->assertEquals(10.99, $line_item->total_price->amount);\n }", "public function check_line_syntax_correct($line,$linenumber)\n\t{\n\t\t$fields=explode(\",\",$line);\n\t\t$field_number=-1; //if field_number is 0 it means it is x axis value which should be a string. This is the only field allowed to be a string\n\t\tforeach($fields as $field)\n\t\t{\n\t\t\t$field_number++;\n\n\t\t\tif($field_number==0)\n\t\t\t{\n\t\t\t//validate for x-axis\n\t\t\t\tif(empty($field))\n\t\t\t\t{\n\t\t\t\t\t$this->data['error_details_data']['LINES_TO_REMOVE'][]=$linenumber;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t//validate all y axis values to make sure they are either empty or number and not string\n\t\t\t\tif(!empty($field) && !is_numeric ($field))\n\t\t\t\t{\n\t\t\t\t\tif($field_number==1)\n\t\t\t\t\t{\n\t\t\t\t\t\t//X axis value has a comma in it. Record this error so that it can be fixed later by merging the 2 strings into one. This is to preserve as much user data as possible and use deletion only as a last option.\n\n\t\t\t\t\t\t$this->data['error_details_data']['X_AXIS_STRING_COMMA_LINE_NUMBER'][]=$linenumber;\n\t\t\t\t\t\t$this->data['error_details_data']['ERROR_LINES'][]=$linenumber;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t//Y-axis contains invalid value.We store line number as key and field number as value in the FIELD_ERROR associative array to identify and eventually remove the invalid value and replace it with empty value.\n\t\t\t\t\t\t$this->data['error_details_data']['FIELD_ERROR'][$linenumber][]=$field_number;\n\t\t\t\t\t\t$this->data['error_details_data']['ERROR_LINES'][]=$linenumber;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}", "public function clean()\n\t{\n\t\tif ($this['item'])\n\t\t{\n\t\t\tif (!$this['original']->is_empty())\n\t\t\t{\n\t\t\t//\tGet all the other items in the workflow for this original\n\t\t\t\t$copies = i('workflow', array(\n\t\t\t\t\t'original' => $this['original']->get(),\n\t\t\t\t));\n\t\t\t//\tDelete them\n\t\t\t\tforeach ($copies as $copy) $copy->delete();\n\t\t\t}\n\t\t}\n\t}", "abstract protected function prepareItem(array $item);", "public function clearLines();", "function clean_item ($p_value) {\n\n\tif (is_array ($p_value)) {\n\t\tif ( count ($p_value) == 0) {\n\t\t\t$p_value = null;\n\t\t} else {\n\t\t\tforeach ($p_value as $m_key => $m_value) {\n\t\t\t\t$p_value[$m_key] = clean_item ($m_value);\n\t\t\t\tif (empty ($p_value[$m_key])) unset ($p_value[$m_key]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (empty ($p_value)) {\n\t\t\t$p_value = null;\n\t\t}\n\t}\n\treturn $p_value;\n}", "private function clean() {\n\t\t//--\n\t\tunset($this->input);\n\t\t$this->index = 0;\n\t\t$this->a = $this->b = '';\n\t\tunset($this->c);\n\t\tunset($this->options);\n\t\t//--\n\t}", "protected function cleanAddressLines($lines)\n {\n $finalLines = null;\n\n if (is_string($lines)) {\n $trimmed = trim($lines);\n $addressLines = preg_split(\"/\\n/\", $trimmed, null, PREG_SPLIT_NO_EMPTY);\n\n $newLines = [];\n foreach ($addressLines as $line) {\n $newLines[] = $this->cleanString($line, 70);\n }\n\n if (count($newLines) > 4) {\n // concat lines beyond the four allowed down into the last line\n $newLines[3] = $this->cleanString(implode(' ', array_slice($newLines, 3)), 70);\n }\n\n $finalLines = array_slice($newLines, 0, 4);\n }\n\n return empty($finalLines) ? null : $finalLines;\n }", "protected function resetItems()\n {\n foreach ($this->options as $op => $junk) {\n if (preg_match('#Items#', $op)) {\n unset($this->options[$op]);\n }\n }\n }", "public abstract function format_line($item);", "private function processline($line)\n {\n\t\t\t$productname=$line[1];\n\n\t\t\tif(trim($line[4])!=\"\")$this->quotearrays[$productname][\"buy\"][\"price\"]=$line[4];\n\t\t\tif(trim($line[5])!=\"\")$this->quotearrays[$productname][\"buy\"][\"discrate\"]=$line[5];\n\t\t\tif(trim($line[6])!=\"\")$this->quotearrays[$productname][\"buy\"][\"discamt\"]=$line[6];\n\t\t\tif(trim($line[7])!=\"\")$this->quotearrays[$productname][\"sell\"][\"price\"]=$line[7];\n\t\t\tif(trim($line[8])!=\"\")$this->quotearrays[$productname][\"sell\"][\"discrate\"]=$line[8];\n\t\t\tif(trim($line[9])!=\"\")$this->quotearrays[$productname][\"sell\"][\"discamt\"]=$line[9];\n }", "protected function testGetLineItems() {\n $line_item_1 = $this->lineItemManager->createInstance('payment_basic');\n $line_item_1->setName($this->randomMachineName());\n $line_item_2 = $this->lineItemManager->createInstance('payment_basic');\n $line_item_2->setName($this->randomMachineName());\n $this->assertTrue(spl_object_hash($this->payment->setLineItems([$line_item_1, $line_item_2])), spl_object_hash($this->payment));\n $line_items = $this->payment->getLineItems();\n if ($this->assertTrue(is_array($line_items))) {\n $this->assertEqual(spl_object_hash($line_items[$line_item_1->getName()]), spl_object_hash($line_item_1));\n $this->assertEqual(spl_object_hash($line_items[$line_item_2->getName()]), spl_object_hash($line_item_2));\n }\n }", "function _taxonomy_csv_line_import_check_geotaxonomy($line, $options, $previous_items = array(), &$messages = array()) {\n $checked_items = $line;\n\n switch ($checked_items) { // Simulate a goto with break.\n default:\n if (empty($line[0])) {\n $messages[] = 480; // Warning no first column.\n break;\n }\n if (count($line) < 3) {\n $messages[] = 450; // Warning some items lacks.\n break;\n }\n if (!is_numeric($line[1]) || !is_numeric($line[2])) {\n $messages[] = 451; // Warning item are not numbers.\n break;\n }\n if (count($line) > 8) {\n $messages[] = 564; // Notice too many items.\n }\n // Complete line with NULL if needed and check numeric values.\n $line = array_pad($line, 8, NULL);\n $checked_items = $line = array_slice($line, 0, 8);\n foreach (array_slice($line, 4) as $value) {\n if (!is_numeric($value) && !is_null($value)) {\n $messages[] = 451; // Warning item are not numbers.\n break 2;\n }\n }\n foreach (array($line[0], $line[3]) as $name) {\n if (drupal_strlen($name) > 255) {\n $messages[] = 454; // Warning too long.\n break 2;\n }\n }\n }\n\n return array_values($checked_items);\n}", "private function refill_line()\n\t{\n\t\t$attrs = '';\n\t\t// compile attributes\n\t\tforeach($this->attr as $type => $val)\n\t\t{\n\t\t\t$val = addslashes(trim($val));\n\t\t\t$attrs .= ($this->quotes == \"double\")\n\t\t\t\t\t? \" $type=\\\"$val\\\"\"\n\t\t\t\t\t: \" $type='$val'\";\n\t\t}\n\t\t$replace = array('[[KOHAML::ATTR]]', '&nbsp;');\n\t\t$fill = array($attrs, ' ');\n\t\t$this->line = str_replace($replace, $fill, $this->line);\n\t\t// replace php\n\t\tif ($this->php)\n\t\t{\n\t\t\tforeach($this->php as $php)\n\t\t\t{\n\t\t\t\t$this->line = preg_replace('/\\[\\[KOHAML::PHP\\]\\]/', $php, $this->line, 1);\n\t\t\t}\n\t\t}\n\t}", "public function fixedBrokenData(): void\n {\n $dataForFixed = [];\n foreach ($this->failedImportData as $failedItemKey => $failedItemValue) {\n if ($this->ifFirstRowBroken($failedItemValue)) {\n $dataForFixed[] = $this->getFixedRow($failedItemValue['row']);\n $this->removeFromFailedItemByKey($failedItemKey);\n }\n }\n $this->format($dataForFixed);\n }", "private function remove_user_in_lines($user_id, $replacement_user_id, $lines){\n\n\t\tforeach($lines as $line){\n\t\t\tif($line->line_type === 'singles'){\n\t\t\t\tif($line->pair_one_id == $user_id){\n\t\t\t\t\tLine::find($line->id)->update(array(\n\t\t\t\t\t\t'pair_one_id' => $replacement_user_id\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t\telse if($line->pair_two_id == $user_id){\n\t\t\t\t\tLine::find($line->id)->update(array(\n\t\t\t\t\t\t'pair_two_id' => $replacement_user_id\n\t\t\t\t\t));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if($line->line_type === 'doubles'){\n\t\t\t\t$pair_ids = array(\n\t\t\t\t\t$line->pair_one_id,\n\t\t\t\t\t$line->pair_two_id\n\t\t\t\t);\n\t\t\t\t$pairs = Pair::whereIn('id', $pair_ids)->get();\n\t\t\t\tforeach($pairs as $pair){\n\t\t\t\t\tif($pair->user_one_id == $user_id){\n\t\t\t\t\t\tPair::find($pair->id)->update(array(\n\t\t\t\t\t\t\t'user_one_id' => $replacement_user_id\n\t\t\t\t\t\t));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if($pair->user_two_id == $user_id){\n\t\t\t\t\t\tPair::find($pair->id)->update(array(\n\t\t\t\t\t\t\t'user_two_id' => $replacement_user_id\n\t\t\t\t\t\t));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}", "public function setLineItems(?array $lineItems): void\n {\n $this->lineItems['value'] = $lineItems;\n }", "public function validateLineItems(ExecutionContextInterface $context)\n {\n if (count($this->items) == 0) {\n if ($this->totalCost < 0.01) {\n $context->buildViolation(\"No line items found.\")\n ->atPath('items')\n ->addViolation();\n }\n }\n }", "function solve_prepare()\n\t{\n\t\t// We can simplify one case where the array is usually supposed to be empty...\n\t\tif (count($this->orig) == 1 && trim($this->orig[0]) === '') $this->orig = array();\n\t\tif (count($this->final1) == 1 && trim($this->final1[0]) === '') $this->final1 = array();\n\t\tif (count($this->final2) == 1 && trim($this->final2[0]) === '') $this->final2 = array();\n\n\t\t// Now we only can have the case where the only difference between arrays are newlines, so compare all cases\n\n\t\t// First, some strings we can compare...\n\t\t$orig = $final1 = $final2 = '';\n\n\t\tforeach ($this->orig as $null => $line) $orig .= trim($line);\n\t\tforeach ($this->final1 as $null => $line) $final1 .= trim($line);\n\t\tforeach ($this->final2 as $null => $line) $final2 .= trim($line);\n\n\t\t// final1 === final2\n\t\tif ($final1 === $final2)\n\t\t{\n\t\t\t// We preserve the part which will be used in the merge later\n\t\t\t$this->final2 = $this->final1;\n\t\t}\n\t\t// final1 === orig\n\t\telse if ($final1 === $orig)\n\t\t{\n\t\t\t// Here it does not really matter what we choose, but we will use the new code\n\t\t\t$this->orig = $this->final1;\n\t\t}\n\t\t// final2 === orig\n\t\telse if ($final2 === $orig)\n\t\t{\n\t\t\t// Here it does not really matter too (final1 will be used), but we will use the new code\n\t\t\t$this->orig = $this->final2;\n\t\t}\n\t}", "protected function processItem()\n {\n if ($this->item['config']['element'] !== 'footnotes') {\n $this->extractFootnotes();\n $this->renumberReferences();\n } elseif (!$this->footnotes) {\n // avoid empty footnotes item appearing in the book\n $this->item['content'] = '';\n $this->item['toc'] = [];\n // instruct the publisher to remove this item\n $this->item['remove'] = true;\n $this->writeLn('No footnotes found in text.');\n }\n }", "public function deletewavelines($wave_id = null,$line_id = null)\n {\n\n $this->Wave->id = $wave_id;\n $wavelinestatus = $this->Wave->OrdersLine->find('first',array('conditions' => array(\"OrdersLine.id\" => $line_id)));\n if($wavelinestatus['OrdersLine']['status_id'] == 17)\n {\n $wavelineid = $this->Wave->OrderslinesWave->find('first',array('conditions' => array(\"wave_id\"=> $wave_id, \"ordersline_id\" => $line_id)));\n\n\n $this->Wave->OrderslinesWave->delete(array(\"id\" => $wavelineid['OrderslinesWave']['id']));\n $this->Wave->updateAll(\n array('Wave.numberoflines' => 'Wave.numberoflines - 1 '),\n array('Wave.id' => $wave_id));\n\n $this->Wave->OrdersLine->updateAll(\n array('OrdersLine.status_id' => 2),\n array('OrdersLine.id' => $line_id));\n $this->Session->setFlash(__('Line removed from wave number %d succefully',$wave_id), 'admin/success', array());\n return $this->redirect(array('action' => 'edit',$wave_id));\n } else {\n $this->Session->setFlash(__('Cannot remove line from wave because it is already packed.'), 'admin/danger', array());\n return $this->redirect(array('action' => 'edit',$wave_id));\n }\n }", "function trim_line_array(&$line_array)\n{\n\t$array_count = count($line_array);\n\t\n\tfor ($i = 0; $i < $array_count; $i++)\n\t{\n\t\t$line_array[$i] = trim($line_array[$i], \" \");\n\t}\n\t\n\treturn $line_array;\n}", "public function addEmptyLine() {\n $this->lines[] = '';\n }", "function PurchOrder(){\n\t\t$this->LineItems = array();\n\t\t$this->total=0;\n\t\t$this->LinesOnOrder=0;\n\t}", "private static function validize($item) {\n $collection = 'products';\n $fields = array('name','type','key');\n\n if(!$item) return false;\n if($item['valid']) return true;\n\n foreach($fields as $key) \n if($item[$key] === false) return false;\n\n // all clear!\n\n $update['valid'] = true;\n MongoLib::set($collection, $item['_id'], $update);\n\n return true;\n }", "function commerce_pos_transaction_line_item_remove_submit($form, &$form_state) {\n if (!empty($form_state['triggering_element']['#line_item_id'])) {\n $form_state['transaction']->doAction('deleteLineItem', $form_state['triggering_element']['#line_item_id'], TRUE);\n $form_state['transaction']->doAction('saveOrder');\n $form_state['order_updated'] = TRUE;\n $form_state['rebuild'] = TRUE;\n }\n}", "protected function normalizeItems()\n {\n if (!is_array($this->_items)) {\n if (is_string($this->_items)) {\n $fileName = Yii::getAlias($this->_items);\n if (file_exists($fileName)) {\n $this->_items = require($fileName);\n if (!is_array($this->_items)) {\n throw new InvalidConfigException('File \"' . $fileName . '\" should return an array.');\n }\n } else {\n throw new InvalidConfigException('File \"' . $this->_items . '\" does not exist.');\n }\n } else {\n $items = call_user_func($this->_items);\n if (!is_array($items)) {\n throw new InvalidConfigException('Callback for \"' . get_class($this) . '::$items\" should return an array.');\n }\n $this->_items = $items;\n }\n }\n }" ]
[ "0.6580282", "0.60321015", "0.5440953", "0.5389769", "0.522344", "0.5168959", "0.5109122", "0.50784034", "0.50721675", "0.5044062", "0.5030949", "0.5004979", "0.49982274", "0.49903348", "0.49573883", "0.49495265", "0.48732728", "0.48602006", "0.48486626", "0.4837617", "0.47921512", "0.4791057", "0.47811455", "0.47709516", "0.47663563", "0.47568414", "0.4737933", "0.4730819", "0.4722471", "0.47143155" ]
0.6792225
0
Ensures uniqueness of the line items.
public function ensure_unique_ids(array $line_items) { $unique_ids = array(); foreach ($line_items as $line_item) { $unique_id = $line_item->getUniqueId(); if (empty($unique_id)) { $unique_id = preg_replace("/[^a-z0-9]/", '', strtolower($line_item->getSku())); } if (empty($unique_id)) { throw new Exception("There is an invoice item without unique id."); } if (isset($unique_ids[$unique_id])) { $backup = $unique_id; $unique_id = $unique_id . '_' . $unique_ids[$unique_id]; $unique_ids[$backup] ++; } else { $unique_ids[$unique_id] = 1; } $line_item->setUniqueId($unique_id); } return $line_items; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "protected function __setUnique()\n {\n }", "protected function testGetLineItems() {\n $line_item_1 = $this->lineItemManager->createInstance('payment_basic');\n $line_item_1->setName($this->randomMachineName());\n $line_item_2 = $this->lineItemManager->createInstance('payment_basic');\n $line_item_2->setName($this->randomMachineName());\n $this->assertTrue(spl_object_hash($this->payment->setLineItems([$line_item_1, $line_item_2])), spl_object_hash($this->payment));\n $line_items = $this->payment->getLineItems();\n if ($this->assertTrue(is_array($line_items))) {\n $this->assertEqual(spl_object_hash($line_items[$line_item_1->getName()]), spl_object_hash($line_item_1));\n $this->assertEqual(spl_object_hash($line_items[$line_item_2->getName()]), spl_object_hash($line_item_2));\n }\n }", "public function unsetLineItems(): void\n {\n $this->lineItems = [];\n }", "public function isUnique()\r\n\t{\r\n\t\treturn true;\r\n\t\t\r\n\t}", "public function ensureUniqueness(): static;", "public function testAddDuplicatesWithInvalidEntry(): void\n {\n $id = '00000000-0000-0000-0000-000000000002';\n\n $manager = new Manager($this->table, $this->table->get('00000000-0000-0000-0000-000000000002'));\n $query = $this->table->find()->where(['id' => $id]);\n $manager->addDuplicates($query->all());\n\n $this->assertTrue($manager->process());\n }", "function itemDuplicateNoObs($itemUUID, $sourceIDs){\n\t\t \n\t\t $db = $this->startDB();\n\t\t $sql = \"SELECT * FROM space WHERE uuid = '$itemUUID' LIMIT 1;\";\n\t\t $resA = $db->fetchAll($sql);\n\t\t $originalSpace = $resA[0];\n\t\t \n\t\t $charID = 97; //code for ASCII \"a\"\n\t\t $i = 0;\n\t\t $UUIDsources = array();\n\t\t foreach($sourceIDs as $sourceItem){\n\t\t\t\t\n\t\t\t\tif($i>0){\n\t\t\t\t\t //don't make a new item for the first record, since we already have it. make it for the second record and after\n\t\t\t\t\t $increment = chr($charID);\n\t\t\t\t\t $newLabel = $originalSpace[\"space_label\"].\"-\".$increment;\n\t\t\t\t\t $newContext = $originalSpace[\"full_context\"].\"-\".$increment;\n\t\t\t\t\t $existingNew = $this->checkNewSpace($newLabel, $newContext);\n\t\t\t\t\t if(!$existingNew){\n\t\t\t\t\t\t $newSpace = $originalSpace;\n\t\t\t\t\t\t $newUUID = GenericFunctions::generateUUID();\n\t\t\t\t\t\t $newSpace[\"uuid\"] = $newUUID;\n\t\t\t\t\t\t $newSpace[\"space_label\"] = $newLabel;\n\t\t\t\t\t\t $newSpace[\"full_context\"] = $newContext;\n\t\t\t\t\t\t $newSpace[\"hash_fcntxt\"] = $newSpace[\"hash_fcntxt\"].\"-\".$increment;\n\t\t\t\t\t\t $newSpace[\"sample_des\"] = Zend_Json::encode(array(\"src\" => $sourceItem, \"srcID\" => $itemUUID));\n\t\t\t\t\t\t $itemOK = false;\n\t\t\t\t\t\t try{\n\t\t\t\t\t\t\t\t$db->insert(\"space\", $newSpace); //add the new space item, duplicating the old\n\t\t\t\t\t\t\t\t$itemOK = true;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t catch (Exception $e) {\n\t \n\t\t\t\t\t\t }\n\t\t\t\t\t\t if($itemOK){\n\t\t\t\t\t\t\t\t$UUIDsources[$newUUID] = $sourceItem;\n\t\t\t\t\t\t\t\t$this->duplicateItemLinks($itemUUID, $newUUID, $increment);\n\t\t\t\t\t\t\t\t$this->duplicateItemContext($itemUUID, $newUUID, $increment);\n\t\t\t\t\t\t }\n\t\t\t\t\t }\n\t\t\t\t\t else{\n\t\t\t\t\t\t $newUUID = $existingNew[\"uuid\"];\n\t\t\t\t\t\t $UUIDsources[$newUUID] = $sourceItem;\n\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t $UUIDsources[$itemUUID] = $sourceItem; \n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$i++;\n\t\t\t\t$charID++;\n\t\t }\n\t\t \n\t\t return $UUIDsources;\n\t }", "public function unique();", "public function test_add_existing_item_does_not_duplicate()\n\t{\n\t\t$basket = new Model_Basket;\n\n\t\t$item_1 = $this->get_item();\n\t\t$basket->add_item($item_1);\n\n\t\t$item_2 = $this->get_item();\n\t\t$basket->add_item($item_2);\n\n\t\t$this->assertSame($basket->item_count(), 1);\n\t}", "private function _trackDuplicates()\n {\n foreach( $this->csvParser->data as $index => $userData )\n {\n $userName = array_key_exists( 'username' , $userData )\n ? $userData[ 'username' ]\n : self::username( $userData[ 'prenom' ] , $userData[ 'nom' ] );\n \n if( $this->database->query( \"\n SELECT\n user_id\n FROM\n `{$this->userTbl}`\n WHERE\n nom = \" . $this->database->quote( $userData[ 'nom' ] ) . \"\n AND\n prenom = \" . $this->database->quote( $userData[ 'prenom' ] )\n )->numRows() )\n {\n $this->conflict[ $index ][ 'nom' ] = $userData[ 'nom' ];\n $this->conflict[ $index ][ 'prenom' ] = $userData[ 'prenom' ];\n }\n \n if( $this->database->query( \"\n SELECT\n user_id\n FROM\n `{$this->userTbl}`\n WHERE\n username = \" . $this->database->quote( $userName )\n )->numRows() )\n {\n $this->conflict[ $index ][ 'username' ] = $userName;\n }\n \n if( $this->database->query( \"\n SELECT\n user_id\n FROM\n `{$this->userTbl}`\n WHERE\n email = \" . $this->database->quote( $userData[ 'email' ] )\n )->numRows() )\n {\n $this->conflict[ $index ][ 'email' ] = $userData[ 'email' ];\n }\n \n if( ! empty( $this->conflict[ $index ] ) )\n {\n $reportLine = $userData[ 'prenom' ] . ' ' . $userData[ 'nom' ];\n $reportLine .= ' (' . implode( ', ' , array_keys( $this->conflict[ $index ] ) ) . ')';\n $this->output[ 'conflict_found' ][] = $reportLine;\n }\n }\n }", "public function cleanup_line_items(array $line_items, $expected_sum, $currency)\n {\n $effective_sum = $this->round_amount($this->get_total_amount_including_tax($line_items), $currency);\n $rounded_expected_sum = $this->round_amount($expected_sum, $currency);\n $inconsistent_amount = $rounded_expected_sum - $effective_sum;\n if ($inconsistent_amount != 0) {\n $enforce_consistency = get_option(WooCommerce_Wallee::CK_ENFORCE_CONSISTENCY);\n switch ($enforce_consistency){\n case 'no':\n $line_item = new \\Wallee\\Sdk\\Model\\LineItemCreate();\n $line_item->setAmountIncludingTax($this->round_amount($inconsistent_amount, $currency));\n $line_item->setName(__('Adjustment', 'woo-wallee'));\n $line_item->setQuantity(1);\n $line_item->setSku('adjustment');\n $line_item->setUniqueId('adjustment');\n $line_item->setShippingRequired(false);\n $line_item->setType($enforce_consistency > 0 ? \\Wallee\\Sdk\\Model\\LineItemType::FEE : \\Wallee\\Sdk\\Model\\LineItemType::DISCOUNT);\n $line_items[] = $line_item;\n break;\n default:\n throw new WC_Wallee_Exception_Invalid_Transaction_Amount($effective_sum, $rounded_expected_sum);\n }\n }\n $data = $this->ensure_unique_ids($line_items);\n return $data;\n }", "public function testGetDuplicateOrderLineById()\n {\n }", "function itemDuplicate($itemUUID, $sourceIDs){\n\t\t \n\t\t $db = $this->startDB();\n\t\t $sql = \"SELECT * FROM space WHERE uuid = '$itemUUID' LIMIT 1;\";\n\t\t $resA = $db->fetchAll($sql);\n\t\t $originalSpace = $resA[0];\n\t\t \n\t\t $charID = 97; //code for ASCII \"a\"\n\t\t $i = 0;\n\t\t $UUIDsources = array();\n\t\t foreach($sourceIDs as $sourceItem){\n\t\t\t\t\n\t\t\t\tif($i>0){\n\t\t\t\t\t //don't make a new item for the first record, since we already have it. make it for the second record and after\n\t\t\t\t\t $increment = chr($charID);\n\t\t\t\t\t $newLabel = $originalSpace[\"space_label\"].\"-\".$increment;\n\t\t\t\t\t $newContext = $originalSpace[\"full_context\"].\"-\".$increment;\n\t\t\t\t\t $existingNew = $this->checkNewSpace($newLabel, $newContext);\n\t\t\t\t\t if(!$existingNew){\n\t\t\t\t\t\t $newSpace = $originalSpace;\n\t\t\t\t\t\t $newUUID = GenericFunctions::generateUUID();\n\t\t\t\t\t\t $newSpace[\"uuid\"] = $newUUID;\n\t\t\t\t\t\t $newSpace[\"space_label\"] = $newLabel;\n\t\t\t\t\t\t $newSpace[\"full_context\"] = $newContext;\n\t\t\t\t\t\t $newSpace[\"hash_fcntxt\"] = $newSpace[\"hash_fcntxt\"].\"-\".$increment;\n\t\t\t\t\t\t $newSpace[\"sample_des\"] = Zend_Json::encode(array(\"src\" => $sourceItem, \"srcID\" => $itemUUID));\n\t\t\t\t\t\t $itemOK = false;\n\t\t\t\t\t\t try{\n\t\t\t\t\t\t\t\t$db->insert(\"space\", $newSpace); //add the new space item, duplicating the old\n\t\t\t\t\t\t\t\t$itemOK = true;\n\t\t\t\t\t\t }\n\t\t\t\t\t\t catch (Exception $e) {\n\t \n\t\t\t\t\t\t }\n\t\t\t\t\t\t if($itemOK){\n\t\t\t\t\t\t\t\t$UUIDsources[$newUUID] = $sourceItem;\n\t\t\t\t\t\t\t\t$this->duplicateItemObs($itemUUID, $newUUID, $increment);\n\t\t\t\t\t\t\t\t$this->duplicateItemLinks($itemUUID, $newUUID, $increment);\n\t\t\t\t\t\t\t\t$this->duplicateItemContext($itemUUID, $newUUID, $increment);\n\t\t\t\t\t\t }\n\t\t\t\t\t }\n\t\t\t\t\t else{\n\t\t\t\t\t\t $newUUID = $existingNew[\"uuid\"];\n\t\t\t\t\t\t $UUIDsources[$newUUID] = $sourceItem;\n\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t $UUIDsources[$itemUUID] = $sourceItem; \n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$i++;\n\t\t\t\t$charID++;\n\t\t }\n\t\t \n\t\t return $UUIDsources;\n\t }", "private function removeDuplicates(): void\n {\n if (is_array($this->value) && count(array_filter(array_keys($this->value), 'is_string')) == 0) {\n $this->value = array_values($this->value);\n }\n }", "protected function testGetLineItem() {\n $line_item = $this->lineItemManager->createInstance('payment_basic');\n $line_item->setName($this->randomMachineName());\n $this->assertTrue($this->payment->setLineItem($line_item) instanceof PaymentInterface);\n $this->assertIdentical(spl_object_hash($this->payment->getLineItem($line_item->getName())), spl_object_hash($line_item));\n }", "public function testUniq() {\n $uniqs = [];\n if (!$this->_runUniqTest) {\n $this->assertCount(0, $uniqs);\n return;\n }\n for ($i = 0; $i < $this->_countUniqModels; $i++) {\n $model = [];\n NestedModel::updateModelUnique($model);\n $uniqs[] = $model['unique_id'];\n $this->assertEquals(count($uniqs), count(array_unique($uniqs)));\n $this->assertInternalType('int', $uniqs[count($uniqs) - 1]);\n }\n }", "public function unique()\n {\n $items = [];\n\n foreach ($this->items as $item) {\n if (array_search($item, $items, true) === false) {\n $items[] = $item;\n }\n }\n\n return $this->createFrom($items);\n }", "abstract protected function addUniqueIngredient();", "function duplicateItemObs($oldUUID, $newUUID, $increment){\n\t\t \n\t\t $db = $this->startDB();\n\t\t $sql = \"SELECT * FROM observe WHERE subject_uuid = '$oldUUID' \";\n\t\t \n\t\t $result = $db->fetchAll($sql);\n\t\t foreach($result as $row){\n\t\t\t\t$data = $row;\n\t\t\t\t$data[\"hash_obs\"] = $data[\"hash_obs\"].\"-\".$increment; \n\t\t\t\t$data[\"subject_uuid\"] = $newUUID;\n\t\t\t\ttry{\n\t\t\t\t\t $db->insert(\"observe\", $data); //add list of subject items with multiple of the same var\n\t\t\t\t}\n\t\t\t\tcatch (Exception $e) {\n\t\t\t\t\n\t\t\t\t}\n\t\t }\n\t\t \n\t }", "public function testListUniqueness()\n {\n $obj = new RecentlyUsedList();\n $obj->add('First');\n $obj->add('Middle');\n $obj->add('Last');\n $unique_length = $obj->length();\n $obj->add('Middle');\n $this->assertEquals($unique_length, $obj->length(), 'Error: all list items should be unique!');\n $this->assertEquals(array('Middle', 'Last', 'First'), $obj->all(), 'Error: all list items should be unique!');\n }", "public function isOrderIdUnique() {\n\t\treturn false;\n\t}", "function isUnique() { return!$this->failed; }", "function isUnique() { return!$this->failed; }", "public function unique() {\n\t\treturn new static(\n\t\t\tarray_unique( $this->items )\n\t\t);\n\t}", "function duplicateItemLinks($oldUUID, $newUUID, $increment){\n\t\t \n\t\t $db = $this->startDB();\n\t\t $sql = \"SELECT * FROM links WHERE origin_uuid = '$oldUUID' OR targ_uuid = '$oldUUID' \";\n\t\t \n\t\t $result = $db->fetchAll($sql);\n\t\t foreach($result as $row){\n\t\t\t\t$data = $row;\n\t\t\t\t$data[\"hash_link\"] = $data[\"hash_link\"].\"-\".$increment;\n\t\t\t\t$data[\"link_uuid\"] = GenericFunctions::generateUUID();\n\t\t\t\tif($data[\"origin_uuid\"] == $oldUUID){\n\t\t\t\t\t $data[\"origin_uuid\"] = $newUUID;\n\t\t\t\t}\n\t\t\t\tif($data[\"targ_uuid\"] == $oldUUID){\n\t\t\t\t\t $data[\"targ_uuid\"] = $newUUID;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttry{\n\t\t\t\t\t $db->insert(\"links\", $data); //add list of subject items with multiple of the same var\n\t\t\t\t}\n\t\t\t\tcatch (Exception $e) {\n\t\t\t\t\n\t\t\t\t}\n\t\t }\n\t\t \n\t }", "function fixNotUniqueRecordInRebillLog()\n {\n if (version_compare($this->db_version, '4.2.15') < 0)\n {\n $db = $this->getDi()->db;\n try { //to handle situation when ?_cc_rebill table does not exists\n $db->query('CREATE TEMPORARY TABLE ?_cc_rebill_temp (\n cc_rebill_id int not null,\n tm_added datetime not null,\n paysys_id varchar(64),\n invoice_id int,\n rebill_date date,\n status smallint,\n status_tm datetime,\n status_msg varchar(255),\n UNIQUE INDEX(invoice_id, rebill_date))');\n\n $db->query('\n INSERT IGNORE INTO ?_cc_rebill_temp\n SELECT * FROM ?_cc_rebill\n ');\n\n $db->query(\"TRUNCATE ?_cc_rebill\");\n\n $db->query('\n INSERT INTO ?_cc_rebill\n SELECT * FROM ?_cc_rebill_temp\n ');\n\n $db->query(\"DROP TABLE ?_cc_rebill_temp\");\n } catch (Exception $e) {\n\n }\n }\n }", "public function testAddDuplicateWithInvalidEntry(): void\n {\n $id = '00000000-0000-0000-0000-000000000002';\n\n $manager = new Manager($this->table, $this->table->get('00000000-0000-0000-0000-000000000002'));\n $manager->addDuplicate($this->table->get($id));\n\n $this->assertTrue($manager->process());\n }", "public function unique(): ISeq;", "public function unique()\n {\n return new static(array_unique($this->items));\n }", "public function test_trackvalidation_preventsduplicates() {\n global $DB;\n\n $this->load_csv_data();\n\n // Need track and userset.\n $userset = new stdClass();\n $userset->id = 1;\n $userset->name = 'test';\n\n $track = new track(array('curid' => 4, 'name' => 'test', 'idnumber' => 'test'));\n $options = array();\n $options['targetcluster'] = $userset;\n $options['targetcurriculum'] = 4;\n $options['moodlecourses'] = 'copyalways';\n $options['tracks'] = 1;\n $options['classmap'] = array();\n\n $return = $track->duplicate($options);\n\n // Make sure that a we get a program returned.\n $this->assertTrue(is_array($return['tracks']));\n\n $id = $return['tracks'][''];\n $record = $DB->get_record('local_elisprogram_trk', array('id'=>$id));\n\n // We want to validate that the unique idnumber is \"test - test.3\".\n $expectedvalue = 'test - test.3';\n $this->assertEquals($expectedvalue, $record->idnumber);\n // The name is also to be unique.\n $this->assertEquals($expectedvalue, $record->name);\n }" ]
[ "0.6053164", "0.6052086", "0.60194916", "0.5800396", "0.5640351", "0.5600931", "0.55957156", "0.5564107", "0.554948", "0.55017704", "0.54472166", "0.5402047", "0.5397315", "0.5386926", "0.53755075", "0.5370209", "0.5365353", "0.53026193", "0.52636236", "0.52468896", "0.5227444", "0.5191055", "0.5191055", "0.5187206", "0.51602346", "0.51520354", "0.51147753", "0.5061517", "0.5054141", "0.5031783" ]
0.73324335
0
Returns the amount of the line item's reductions.
public function get_reduction_amount(array $line_items, array $reductions) { $line_item_map = array(); foreach ($line_items as $line_item) { $line_item_map[$line_item->getUniqueId()] = $line_item; } $amount = 0; foreach ($reductions as $reduction) { $line_item = $line_item_map[$reduction->getLineItemUniqueId()]; $amount += $line_item->getUnitPriceIncludingTax() * $reduction->getQuantityReduction(); $amount += $reduction->getUnitPriceReduction() * ($line_item->getQuantity() - $reduction->getQuantityReduction()); } return $amount; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getReduction() { return $this->reduction;}", "public function getTotal(): float\n {\n $value = $this->lineItems->reduce(static function (float $value, LineItem $item): float {\n return $value + $item->getTotal();\n }, -$this->discount);\n\n return round($value < 0 ? 0 : $value, 2);\n }", "public function getTotal() : float\n {\n return $this->items->pluck('amount')->sum();\n }", "public function getTotalItems() {\r\n $result = 0;\r\n foreach ($this->cartItems as $item) {\r\n $result += $item->getQuantity();\r\n }\r\n return $result;\r\n }", "public function get_item_count() {\n $total = 0;\n if (!empty($this->items)) {\n foreach ($this->items as $item) {\n $total += $item['quantity'];\n }\n }\n return $total;\n }", "public function ItemQty() {\n\t$rs = $this->LineRecords();\n\tif ($rs->HasRows()) {\n\t $qty = 0;\n\t while ($rs->NextRow()) {\n\t\t$qty += $rs->QtyInPackage();\n\t }\n\t} else {\n\t $qty = 0;\n\t}\n\treturn $qty;\n }", "function compute_number_of_items($value){\n global $number_of_items;\n $number_of_items += $value->amount;\n }", "public function getTotal()\n {\n\n $total = 0;\n\n foreach ($this->items as $item) {\n $total += $item->getTotal();\n }\n return $total;\n }", "public function totalReductionForfaits(FactureInterface $facture): float;", "public function totalStrokes()\n {\n return $this->scores->sum('strokes');\n }", "public function getTotal(){\n\t\t$total = 0;\n\n\t\tforeach ($this->items as $id) {\n\t\t\t\t\t\t$subtotal = $id['qty'] * ($id['item']->getPrice());\n\t\t\t\t\t\t$total += $subtotal;\n\t\t\t\t\t}\n\n\t\treturn $total;\t\t\t\n\t}", "public function getTotalAttribute(): int\n {\n return $this->charges->pluck('amount')->sum();\n }", "public function quantity()\r\n {\r\n $quantity = 0;\r\n \r\n if (empty($this->items)) {\r\n return $quantity;\r\n }\r\n \r\n foreach ($this->items as $item)\r\n {\r\n $quantity += (int) $item['quantity'];\r\n }\r\n \r\n return $quantity;\r\n }", "public function count(){\n\t\t\t\t$count = 0;\n\n\t\t\t\tforeach ($this->items as $item) {\n\t\t\t\t\t$count += $item['qty'];\n\t\t\t\t}\n\n\t\t\t\treturn $count;\n\t\t\t}", "public function sum()\n {\n return array_sum($this->items);\n }", "public static function total_items()\n {\n return static::$cart_contents['total_items'];\n }", "protected function getTotalItems()\n {\n return (int)$this->total_items;\n }", "public function getTotalWeight(): float {\n return $this->reps * $this->weight;\n }", "public function getTotalCount()\r\n {\r\n return $this->items_total;\r\n }", "public function getLineTotalAttribute()\n {\n return ($this->qty * $this->product->price);\n }", "public function get_total_amount_including_tax(array $line_items)\n {\n $sum = 0;\n foreach ($line_items as $line_item) {\n $sum += $line_item->getAmountIncludingTax();\n }\n return $sum;\n }", "public function getItemDiscountTotal()\n {\n return $this->itemDiscountTotal;\n }", "public function getUsageAttribute(){\n return $this->progress_details->sum('qty');\n }", "public static function get_total_items() {\n\t\treturn (int) self::db()->singleQuery('\n SELECT COUNT(1)\n FROM items');\n\t}", "function getTotal(){\n\t\t$items = $this->Items();\n\t\t$sum = 0;\n\t\tif ($items){\n\t\t\tforeach ($items as $item) {\n\t\t\t\t$sum+= $item->getSubTotal();\n\t\t\t}\n\t\t}\n\t\treturn $sum;\n\t}", "public function getItemsQty()\n {\n\t\treturn $this->getQuote()->getItemsSummaryQty()*1;\n }", "public function getTotalAttribute(): float\n {\n return $this->getTotal();\n }", "public function getTotal(): float\n {\n $total = 0;\n\n foreach ($this->getItems() as $item) {\n $total += $item->getTotal();\n }\n\n return $total;\n }", "public function getCalculatedItemAmounts()\n {\n return $this->calculatedItemAmounts;\n }", "public function getWeight()\r\n {\r\n $lineList = $this->getCart()->getLineList();\r\n $totalWeight = 0;\r\n foreach ($lineList as $line) {\r\n $cartable = $line->getCartable();\r\n if ($cartable instanceof ProductInterface) {\r\n $totalWeight += $cartable->getShopWeight() * $line->getQuantity();\r\n }\r\n }\r\n return $totalWeight;\r\n }" ]
[ "0.65854555", "0.64745253", "0.6471", "0.62112844", "0.6161584", "0.61184514", "0.6099023", "0.6082242", "0.6076313", "0.6075212", "0.60434043", "0.60256654", "0.601753", "0.5992936", "0.59786093", "0.59766185", "0.59758544", "0.59737855", "0.5970224", "0.5966221", "0.59555846", "0.5951608", "0.59419143", "0.5940325", "0.5908318", "0.58908856", "0.587814", "0.5875431", "0.5839643", "0.5826382" ]
0.71965635
0
Get the video identifier
public function videoId() { return $this->video_id; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getVideoId ()\n {\n return $this->video_id;\n }", "public function getVideoId()\n {\n return $this->videoId;\n }", "public function getIdVideo() {\n return $this->id_video; //retourne id_video\n }", "public function getVideoId()\n {\n return $this->videoId;\n }", "function getVideoId() {\n if ( is_null( $this->video_id ) ) {\n if ( false !== strpos( $this->web_link, 'youtube.com/watch?v=' ) ) {\n $video_parts = explode( 'youtube.com/watch?v=', $this->web_link );\n $video_id_parts = explode( '&', $video_parts[1] );\n $this->video_id = $video_id_parts[0];\n } else {\n $this->video_id = false;\n }\n }\n return $this->video_id;\n }", "function Get_video_id(){return $this->_video_id;}", "function ts_get_video_id($url)\n{\n $url = trim($url);\n\n if(preg_match(\"/^[a-z0-9\\-_]+$/i\", $url) || ctype_digit($url))\n return $url;\n\n $url_parts = parse_url($url);\n $url_part = (is_array($url_parts)) ? ts_array2object($url_parts) : $url_parts;\n\n if(is_object($url_part) && isset($url_part->host))\n {\n $host_names = explode(\".\", $url_part->host);\n $url_part->host = $host_names[count($host_names)-2] . \".\" . $host_names[count($host_names)-1];\n\n if(($url_part->host == 'youtube.com') || ($url_part->host == 'youtu.be'))\n {\n if($url_part->host == 'youtube.com')\n {\n if($url_part->query)\n {\n parse_str($url_part->query);\n }\n\n if(isset($v)) :\n $id = $v;\n elseif(strpos($url_part->path, '/v/') !== false) :\n $id_parts = explode('/v/', $url_part->path, 2);\n $id = end($id_parts);\n elseif(strpos($url_part->path, '/embed/') !== false) :\n $id_parts = explode('/embed/', $url_part->path, 2);\n $id = end($id_parts);\n else :\n $id = '';\n endif;\n }\n else\n {\n $id = substr($url_part->path, 1);\n }\n\n return $id;\n }\n elseif($url_part->host == 'vimeo.com')\n {\n if($url_part->path == '/channels/hd') :\n $id = $url_part->fragment;\n elseif(substr($url_part->path, 0, 7) == '/video/' || substr($url_part->path, 0, 8) == '/groups/' || substr($url_part->path, 0, 10) == '/channels/') :\n $id_parts = explode('/', $url_part->path);\n $id = end($id_parts);\n else :\n $id = substr($url_part->path, 1);\n endif;\n\n if(ctype_digit($id))\n return $id;\n }\n elseif($url_part->host == 'vine.co')\n {\n if(substr($url_part->path, 0, 3) == '/v/')\n return current(explode('/', substr($url_part->path, 3)));\n }\n }\n\n return null;\n}", "public function getMovieId() {\n\t\treturn($this->movieId);\n\t}", "function getVideoID($url) {\n \n if (str::contains($url, 'youtu')) {\n if (preg_match(\"/^((https?:\\/\\/)?(w{0,3}\\.)?youtu(\\.be|(be|be-nocookie)\\.\\w{2,3}\\/))((watch\\?v=|v|embed)?[\\/]?(?P<id>[a-zA-Z0-9-_]{11}))/si\", $url, $matches)) {\n return $matches['id'];\n }\n }\n \n elseif (str::contains($url, 'vimeo.com')) {\n return substr(parse_url($url, PHP_URL_PATH), 1);\n }\n \n else {\n return null;\n }\n \n}", "private function extractVideoId($video_url)\n {\n $start_position = stripos($video_url, \".com/\");\n return ltrim(substr($video_url, $start_position), \".com/\");\n }", "function getAttachedMovieID() {\n\t\treturn mofilmMovieMessageHistory::getMovieFromMessageID($this->getMessageID());\n\t}", "private function videoIDFromUrl(string $url): ?string {\n return preg_match(\"`^/?(medias|embed)/(?<videoID>[\\w-]+)`\", parse_url($url, PHP_URL_PATH) ?? \"\", $matches) ? $matches[\"videoID\"] : null;\n }", "function getMovieID() {\n\t\treturn $this->_MovieID;\n\t}", "private function videoIDFromUrl(string $url): ?string {\n $host = parse_url($url, PHP_URL_HOST);\n\n if ($host === self::SHORT_DOMAIN) {\n $path = parse_url($url, PHP_URL_PATH) ?? \"\";\n return preg_match(\"`^/?(?<videoID>[\\w-]{11})`\", $path, $matches) ? $matches[\"videoID\"] : null;\n } else {\n $parameters = [];\n parse_str(parse_url($url, PHP_URL_QUERY) ?? \"\", $parameters);\n return $parameters[\"v\"] ?? null;\n }\n\n return null;\n }", "public function getEmbedIdAttribute(): string\n {\n if ($this->type === LivestreamTypes::YOUTUBE_CHANNEL) {\n return $this->livestream_id;\n }\n\n // Only type === YouTube\n return static::extractYoutubeVideoId($this->livestream_id);\n }", "protected static function getVideoId($url)\n {\n\n $video_id = false;\n\n $regexp = array('/^https?:\\/\\/(www\\.youtube\\.com|youtube\\.com|youtu\\.be).*\\/(watch\\?v=)?(.*)/', 3);\n\n if(preg_match($regexp[0], $url, $matches, PREG_OFFSET_CAPTURE) > 0)\n {\n // regexp match key\n $match_key = $regexp[1];\n\n // define video id\n $video_id = $matches[$match_key][0];\n\n // Fixes the youtube &feature_gdata bug\n if(strpos($video_id, \"&\"))\n {\n $video_id = substr($video_id, 0, strpos($video_id, \"&\"));\n }\n }\n\n // here we should have a valid video_id or false if service not matching\n return $video_id;\n }", "function video() {\n\t\t\treturn $this->API->getVideo($this->VideoID);\n\t\t}", "public function getImdbId()\n {\n return $this->getId(self::IMDB_IDENTIFIER);\n }", "public static function getFacebookVideoIdFromPath($videoPath)\n {\n return pathinfo($videoPath, PATHINFO_FILENAME);\n }", "function video_embed_jwplayer_get_media_id($url) {\n //\n // the url is in the form: http(s)://content.jwplatform.com/[TYPE/]MEDIA_ID[-TEMP_ID].EXT[?parameters]\n //\n // get file name\n $splits = explode('/', $url);\n $media_id = array_pop($splits);\n\n //\n // remove extension and signing parameters\n if ($media_id && $pos = strpos($media_id, '.')) {\n $media_id = substr($media_id, 0, $pos);\n }\n\n //\n // remove template id. if any\n if ($media_id && $pos = strpos($media_id, '-')) {\n $media_id = substr($media_id, 0, $pos);\n }\n\n return $media_id ? $media_id : false;\n}", "function getMovieLinkID() {\n\t\treturn $this->_MovieLinkID;\n\t}", "function getdmid($url){\n\n$checkdm = explode(\".\", $url);\n\nif ($checkdm[1] == \"dailymotion\" ){\n\n\t//gets vid id\n$dm_start = explode(\"/video/\",$url,2);\n$dm_end = explode(\"&\",$dm_start[1],2);\n$gotid = $dm_end[0];\nreturn $gotid;\n}\n}", "public static function getIdentifier();", "public function getMp4FileID(): int\n {\n return $this->mp4fID ?? 0;\n }", "public function getAssetId();", "public function getVideo()\n {\n return $this->video;\n }", "public function getVideo()\n {\n return $this->video;\n }", "function getVideoEmbed() {\n $video_id = $this->getVideoId();\n return self::getVideoEmbedHTML( $video_id );\n }", "public function getIdentifier();", "public function getIdentifier();" ]
[ "0.8114377", "0.80092484", "0.7976643", "0.7936103", "0.77474207", "0.7499283", "0.69790363", "0.6947796", "0.68382967", "0.67223305", "0.66768473", "0.6618578", "0.6603153", "0.6562837", "0.65245354", "0.64901876", "0.64859194", "0.6480279", "0.6446378", "0.6423467", "0.63533163", "0.63198555", "0.6304507", "0.6296914", "0.62650627", "0.62260437", "0.62260437", "0.62052554", "0.62036836", "0.62036836" ]
0.81917083
0
Function for showing address book.
public function addressBook() { $user_id = Auth::user()->id; $userAddress = User_address::with('countries', 'states')->where('user_id', '=', $user_id)->orderBy('primary', 'desc')->get(); return view('address_book', array('conf' => $this->conf, 'userAddress' => $userAddress)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function addressbook_page() {\n\t\t$this->addressbook->plugin_page();\n\t}", "public function show(Address $address)\n {\n //\n }", "public function show(Address $address)\n {\n //\n }", "public function show(Address $address)\n {\n //\n }", "public function show(Address $address)\n {\n //\n }", "public function show(Address $address)\n {\n\n }", "public function show(address $address)\n {\n //\n }", "public function action_personnel_address_book() {\n $personnel = ORM::factory('Personnel')->find_all();\n $this->_template->set('personnel', $personnel);\n $this->_set_content('reports/personnel_address_book');\n }", "function readAddressBook()\n {\n }", "public function show(Address $address)\n {\n\n\n return view('admin.address.index')->with(['address'=>$address]);\n }", "public function getAddressBookUrl()\n {\n $params = array(\n 'id' => $this->getCustomer()->getId(),\n 'tab' => 'customer_info_tabs_addresses',\n );\n\n return Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit', $params);\n }", "public function browse()\n {\n $this->app->loadLang('user');\n $this->view->title = $this->lang->address->browse;\n $this->view->addresses = $this->address->getListByAccount($this->app->user->account);\n $this->view->mobileURL = helper::createLink('address', 'browse', '', '', 'mhtml');\n $this->view->desktopURL = helper::createLink('address', 'browse', '', '', 'html');\n $this->display();\n }", "public function index()\n\t{\n\t\t$addressList = $this->address->data->getAddressList($this->userId);\n\t\t$this->layout->content = View::make('address.list', compact('addressList'));\n\t}", "public function index()\n {\n return $this->showAll(Address::all());\n }", "public function index()\n {\n $addresses = auth()->user()->addresses;\n return view(\"address.index\", compact('addresses'));\n }", "public function show()\n {\n $book = Book::getInstance();\n $form_data = array(\n 'data' => ($book->error)?$book->form_data:null,\n 'error_msg' => $book->error_msg,\n 'error' => $book->error\n );\n\n $messages = $book->getMessages();\n $page_atts = array(\n 'form' => $this->getView('form', $form_data),\n 'messages' => $messages,\n 'pagination' => $this->pagination()\n );\n\n $view = $this->getView('page', $page_atts);\n echo $view;\n }", "public function showAddressAutocomplete()\n {\n if ($this->addressAutocompleteHelperData->getAddressAutocompleteStatus()) {\n return true;\n }\n return false;\n }", "function get_address_page()\n\t{\n\t\t$reffer = \"http://mail.google.com/mail/contacts/ui/ContactManager?js=RAW\";\n\t\t$addressUrl = \"https://mail.google.com/mail/contacts/data/contacts?thumb=true&groups=true&show=ALL&psort=Name&max=100000&out=js&rf=&jsx=true\";\n\t\t$str=$this->get_curl($addressUrl,\"\",$reffer);\n\t\treturn $str;\n\t}", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function show(Book $book)\n {\n //\n }", "public function getAddressbook()\r\n {\r\n $numArgs = func_num_args();\r\n if ($numArgs > 0) throw new Warecorp_Exception(\"ERROR USING METHOD getAddressbook. NO params.\");\r\n if ( $this->Addressbook === null ) {\r\n $this->Addressbook = new Warecorp_User_Addressbook_ContactList(false, 'owner_id', $this->id);\r\n }\r\n return $this->Addressbook;\r\n }", "public function index()\n {\n $address['address'] = Address::select('id','updated_at','family_id','address_country',\n 'address_city','address_like_bill','address_last')\n ->orderBy('id', 'DESC')\n ->get();\n return view('family.address.address_family')->with($address);\n }" ]
[ "0.7365258", "0.71552444", "0.71552444", "0.71552444", "0.71552444", "0.71406883", "0.7102418", "0.68128896", "0.64073396", "0.63166815", "0.6264516", "0.6249866", "0.62055004", "0.6126837", "0.60977864", "0.6082435", "0.606414", "0.6051024", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60428137", "0.60048056", "0.59704876" ]
0.7192567
1
/ Function for myaccount view
public function myAccount() { $user_id = Auth::user()->id; $user = User::where('id', '=', $user_id)->first(); return view('my_account', array('conf' => $this->conf, 'user' => $user)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function myAccount()\n {\n $viewChallenges = new ViewChallenges();\n $results = new ViewResults();\n $users = new TableUsers();\n\n $userId = auth()->user()->id;\n\n $finishedChallenges = $viewChallenges->getFinishedChallenges($userId);\n $openChallenges = $viewChallenges->getOpenChallenges($userId);\n $openChallengesSent = $viewChallenges->getOpenChallengesSent($userId);\n $allGames = $results->getAllGamesUser(intval($userId));\n $stats = $results->getStatsUser($userId);\n $userCoins = $users->getCoins($userId);\n\n return view('useraccount', [\n 'title' => \"My Account | ¥atzyBonanza\",\n 'finishedChallenges' => $finishedChallenges,\n 'openChallenges' => $openChallenges,\n 'openChallengesSent' => $openChallengesSent,\n 'allGames' => $allGames,\n 'stats' => $stats,\n 'userCoins' => $userCoins\n ]);\n }", "public function account()\n {\n return view(\"public.account\")->with(['active'=>'users', 'subactive'=>'user']);\n }", "public function getAccount(){\n $user = auth()->user();\n return view('user.account.myAccount',compact('user'));\n }", "function viewMyAccount()\n {\n $replace = array();\n\n $userInfo = $this->userInfo();\n // Encrypt data\n $encrypt_field = array('name_title','name_first','name_last','password','address', 'address2', 'country','city', 'state', 'zip', 'phone1', 'phone2','fax');\n //$userInfo = $this->decrypt_field($userInfo, $encrypt_field);\n if (!$userInfo)\n {\n header(\"location:index.php\");\n }\n else \n {\t\n $userId = $userInfo['user_id'];\n $replace['user_id'] = $userId;\n\n $userType = ($userInfo['usertype_id'] == 2) ? \"Therapist\" : \"\";\t\t\t\t\t\n\n // format subscriber details \n\n if(!empty($userInfo['name_title']))\n {\n $ret .= $userInfo['name_title'] . ' ';\n }\n\n $ret .= '<b style=\"font-size:14px;\"><font>'.$userInfo['name_first'] . ' ' .$userInfo['name_last'].'</font></b>';\n\n if(!empty($userInfo['name_suffix']))\n {\n $ret .= ', ' . $userInfo['name_suffix'];\n }\n\n $ret .= '<br /><br />';\t\n\n if(!empty($userInfo['address'])) $ret .= $userInfo['address'] . '<br><br />';\n if(!empty($userInfo['address2'])) $ret .= $userInfo['address2'] . '<br><br />';\n\n if (!empty($userInfo['city']) && !empty($userInfo['state']) && !empty($userInfo['zip']))\n {\n $key = $userInfo['state'];\n\n if($userInfo['country']=='US')\n {\n $state=$this->config['state'][$key];\n }\n else\n {\n $state=$this->config['canada_state'][$key];\n }\n\n $ret .= $userInfo['city'] . ', '. $state . ', ' .$userInfo['zip'].'<br><br />';\t\t\t\t\t\t\t\t\t\n\n }\n else if (!empty($userInfo['city']) && !empty($userInfo['state']))\n {\n $key = $userInfo['state'];\n\n if($userInfo['country']=='US')\n {\n $state=$this->config['state'][$key];\n }\n else\n {\n $state=$this->config['canada_state'][$key];\n }\n $ret .= $userInfo['city'] .' ' .$state.'<br><br />';\n }\n else if (!empty($userInfo['city']) && !empty($userInfo['zip']))\n {\n $ret .= $userInfo['city'] .' ' .$userInfo['zip'].'<br><br />';\n }\n else if (!empty($userInfo['state']) && !empty($userInfo['zip'])) \n {\n $key = $userInfo['state'];\n\n if($userInfo['country']=='US')\n {\n $state=$this->config['state'][$key];\n }\n else\n {\n $state=$this->config['canada_state'][$key];\n }\n $ret .= $state .' ' .$userInfo['zip'].'<br><br />';\t\n }\n else if (!empty($userInfo['city']))\n {\n $ret .= $userInfo['city'].'<br><br />';\n }\n else if (!empty($userInfo['state']))\n {\n $key = $userInfo['state'];\n\n if($userInfo['country']=='US')\n {\n $state=$this->config['state'][$key];\n }\n else\n {\n $state=$this->config['canada_state'][$key];\n }\n $ret .= $state.'<br><br />';\n }\n else if (!empty($userInfo['zip']))\n {\n $ret .= $userInfo['zip'].'<br><br />';\n }\n if (!empty($userInfo['country']))\n {\n $key=$userInfo['country'];\n $ret .= $this->config['country'][$key].'<br><br />';\n }\t\n\n //$ret .= '<br />';\n if(!empty($userInfo['username'])) $ret .= '<font><a href=\"mailto:' . $userInfo['username'] . '\" style=\"font-size:11px;\">' . $userInfo['username'] . '</a></font><br><br />';\n if(!empty($userInfo['phone1'])) $ret .= 'Phone 1: ' . $userInfo['phone1'] . '<br><br />';\n// if(!empty($userInfo['phone2'])) $ret .= 'Phone 2: ' .$userInfo['phone2'] . '<br><br />';\n $ret .= (!empty($userInfo['timezone'])) ? 'Time Zone: ' . $userInfo['timezone'] . '<br><br />' : 'Time Zone: ' . $this->config['timezone']['frontend']['region'] . '<br><br />';\n if(!empty($userInfo['fax'])) $ret .= 'Fax: ' .$userInfo['fax'] . '<br><br />';\n\n $replace['therapistInfo'] = $ret;\n\n }\t\n\n $replace['header'] = $this->build_template($this->get_template(\"header\"));\n $replace['footer'] = $this->build_template($this->get_template(\"footer\"));\t\n //$replace['sidebar'] = $this->build_template($this->get_template(\"sidebar\"));\t\t\t\t\t\n $replace['sidebar'] = $this->sidebar();\n\n $replace['body'] = $this->build_template($this->get_template(\"myAccountView\"),$replace);\n $replace['browser_title'] = \"Tx Xchange: My Account\";\n\n $dir = \"asset/images/profilepictures/\".$userId;\n\n $contents = $this->ReadFolderDirectory($dir);\n //print_r($contents);\n if($contents[1]!='')\n { \n $replace['propic'] = \"$dir/$contents[1]\";\n }\n else\n {\n $replace['propic'] = 'images/no-image.gif'; \n }\n\n $replace['get_satisfaction'] = $this->get_satisfaction();\n\n $this->output = $this->build_template($this->get_template(\"main\"),$replace);\t\n }", "public function account() {\n\t\tif ($this->params['loggedIn']) {\n\t $this->getURIData();\n\t\t\t$func = \"view\";\n\t\t\tif (isset($this->uriVars['id'])) {\n\t\t\t\t$func = $this->uriVars['id'];\n\t\t\t} else if (isset($this->uriVars['mode'])) {\n\t\t\t\t$func = $this->uriVars['mode'];\n\t\t\t} // END if\n\t\t\t$this->data['account'] = $this->auth->accountDetails();\n\t\t\t/*--------------------------------------\n\t\t\t/\tView the account details\n\t\t\t/-------------------------------------*/\n\t\t\tif ($func == \"view\") {\n\t\t\t\t$levelStr = '';\n\t\t\t\tif ($this->data['account']->levelId != -1 && $this->data['account']->levelId != 0) {\n\t\t\t\t\t$levelList = loadSimpleDataList('userLevel');\n\t\t\t\t\tforeach($levelList as $key => $value) {\n\t\t\t\t\t\tif ($this->data['account']->levelId == $key) {\n\t\t\t\t\t\t\t$levelStr = \"L\".$key.\" - \".$value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} // END if\n\t\t\t\t\t} // END foreach\n\t\t\t\t} // END if\n\t\t\t\t$this->data['account']->userLevel = $levelStr;\n\t\t\t\t\n\t\t\t\t$typeStr = '';\n\t\t\t\tif ($this->data['account']->typeId != -1 && $this->data['account']->typeId != 0) {\n\t\t\t\t\t$typeList = loadSimpleDataList('userType');\n\t\t\t\t\tforeach($typeList as $key => $value) {\n\t\t\t\t\t\tif ($this->data['account']->typeId == $key) {\n\t\t\t\t\t\t\t$typeStr = $value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} // END if\n\t\t\t\t\t} // END foreach\n\t\t\t\t} // END if\n\t\t\t\t$this->data['account']->userType = $typeStr;\n\t\t\t\t\n\t\t\t\t$accessStr = '';\n\t\t\t\tif ($this->data['account']->accessId != -1 && $this->data['account']->accessId != 0) {\n\t\t\t\t\t$accessList = loadSimpleDataList('accessLevel');\n\t\t\t\t\tforeach($accessList as $key => $value) {\n\t\t\t\t\t\tif ($this->data['account']->accessId == $key) {\n\t\t\t\t\t\t\t$accessStr = \"L\".$key.\" - \".$value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} // END if\n\t\t\t\t\t} // END foreach\n\t\t\t\t} // END if\n\t\t\t\t$this->data['account']->accessLevel = $accessStr;\n\t\t\t\t$this->params['subTitle'] = $this->data['subTitle'] = 'Account Details';\n\t\t\t\t$this->params['content'] = $this->load->view($this->views['ACCOUNT'], $this->data, true);\n\t\t\t\t$this->makeNav();\n\t\t\t\t$this->displayView();\n\t\t\t/*--------------------------------------\n\t\t\t/\tEdit the account details\n\t\t\t/-------------------------------------*/\n\t\t\t} else {\n\t\t\t\t$this->form_validation->set_rules('email', 'Email Address', 'required|trim|valid_email');\n\t\t\t\t$this->form_validation->set_error_delimiters('<p class=\"error\">', '</p>');\n\t\t\t\t\n\t\t\t\tif ($this->form_validation->run() == false) {\n\t\t\t\t\t$this->params['subTitle'] = $this->data['subTitle'] = 'Edit Account';\n\t\t\t\t\t$this->data['input'] = $this->input;\n\t\t\t\t\t$this->params['content'] = $this->load->view($this->views['ACCOUNT_EDIT'], $this->data, true);\n\t\t\t\t\t$this->params['pageType'] = PAGE_FORM;\n\t\t\t\t\t$this->makeNav();\n\t\t\t\t\t$this->displayView();\n\t\t\t\t} else {\n\t\t\t\t\tif ($this->input->post('email') != $this->data['account']->email) {\n\t\t\t\t\t\t$this->db->select('email')->from('users_core')->where('email',$this->input->post('email'));\n\t\t\t\t\t\t$query = $this->db->get();\n\t\t\t\t\t\tif ($query->num_rows() != 0) {\n\t\t\t\t\t\t\t$this->session->set_flashdata('message', '<p class=\"error\">Account Update Failed. The email address <b>'.$this->input->post('email').'</b> is already in use. Please choose a different e-mail address.</p>');\n\t\t\t\t\t\t\tredirect('user/account/edit');\n\t\t\t\t\t\t} // END if\n\t\t\t\t\t} // END if\n\t\t\t\t\t$session_auth = $this->session->userdata($this->config->item('session_auth'));\n\t\t\t\t\t$change = $this->auth->account_update($this->input,$session_auth);\n\t\t\t\t\tif ($change) {\n\t\t\t\t\t\t$this->session->set_flashdata('message', '<p class=\"success\">Your account details were successfully changed.</p>');\n\t\t\t\t\t\tredirect('user/account');\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$message = '<p class=\"error\">Account Update Failed.';\n\t\t\t\t\t\tif ($this->auth->get_status_code() != 0) {\n\t\t\t\t\t\t\t$message .= ' '.$this->auth->get_status_message().'</p>';\n\t\t\t\t\t\t} // END if\n\t\t\t\t\t\t$message .= '</p >';\n\t\t\t\t\t\t$this->session->set_flashdata('message', $message);\n\t\t\t\t\t\tredirect('user/account/edit');\n\t\t\t\t\t} // END if\n\t\t\t\t} // END if\n\t\t\t} // END if\n\t } else {\n\t $this->session->set_flashdata('loginRedirect',current_url());\t\n\t\t\tredirect('user/login');\n\t } // END if\n\t}", "public function index()\n { \n \n return view('user.account');\n }", "public function account()\n {\n return view('settings.account');\n }", "public function show_account()\n {\n return view('driver_dashboard.account');\n }", "public function index() {\n //\n return view( 'account.account' );\n }", "public function view($account_id){\n\tif(!empty($account_id) && $this->account_model->account_exists($account_id)) {\n\t $data['page_title'] = \"MyLIS Account ($account_id)\";\n\t $data['account_id'] = $account_id;\n\t $accountInfo = $this->account_model->get_account_info($account_id);\n\t \n\t $manager_id = $accountInfo['manager_id'];\n\t $userList = $this->load_users();\n\t $managerInfo = $userList[$manager_id];\n\t \n\t $data['accountInfo'] = $accountInfo;\n\t $data['accountUsers'] = $this->account_model->get_account_users($account_id);\n\t $data['managerInfo'] = $managerInfo;\n\t $data['accountProfile'] = $this->account_model->get_account_profile($account_id);\n\t $this->load_view('admin/accounts/account_info',$data);\n\t} else {\n\t redirect('admin/accounts');\n\t}\n }", "public function myaccountTask()\n\t{\n\t\tif (User::isGuest())\n\t\t{\n\t\t\tApp::redirect(\n\t\t\t\tRoute::url('index.php?option=com_users&view=login&return=' . base64_encode(Route::url('index.php?option=' . $this->_option . '&task=myaccount', false, true)), false),\n\t\t\t\tLang::txt('COM_MEMBERS_NOT_LOGGEDIN'),\n\t\t\t\t'warning'\n\t\t\t);\n\t\t}\n\n\t\tRequest::setVar('id', User::get('id'));\n\n\t\treturn $this->viewTask();\n\t}", "public function index()\n {\n $themename = get_theme_name();\n $user = UserProfile::find(Auth::user()->id);\n $address = CustomerAddress::where('customerid', Auth::user()->id)->first();\n return view($themename.'account',compact('user','address'));\n }", "public function index()\n {\n return view('frontend::setting.account', ['user' => user()]);\n }", "public function index()\n {\n return view('auth.account');\n }", "public function viewAccount()\n {\n $this->data['title'] = 'Chart of Account';\n\n $accountTypes = $this->getAccountTypeList('foriegnkeycolumn');\n $this->data['accountTypes'] = $accountTypes->content();\n\n $accounts = $this->getAccountList('foriegnkeycolumn');\n $this->data['accounts'] = $accounts->content();\n\n $userControler = new UserController;\n $this->data['users'] = $userControler->get('foriegnkeycolumn')->content();\n\n return view('pages.accounts.account', $this->data);\n }", "public function index()\n {\n return view('backend.pages.account.account');\n }", "public function actionAccount(){\n $app = Yii::$app;\n if($app->user->isGuest){\n return $this->goHome();\n }\n return $this->render('account', [\n 'commercial' => SpyCommercial::findOne($app->user->id),\n ]);\n }", "public function Account()\n\t{\n\t\t$logged_user = $this->auth->getLoggedUser();\n\t\t$skrill_accounts = Financial::where('user_id',$logged_user->id)->where('skrill_account','!=','')->get();\n\t\t$bank_accounts = Bank::with('financial')->where('user_id',$logged_user->id)->get();\n\t\t$credit_accounts = Credit::where('user_id',$logged_user->id)->get();\n\t\t$paypal_accounts = Financial::where('user_id',$logged_user->id)->where('paypal_account','!=','')->get();\n\t\t\n\t\treturn View::make('laravel-authentication-acl::admin.financial.account')->with([ 'skrill_accounts' => $skrill_accounts,'bank_accounts' => $bank_accounts,'credit_accounts' => $credit_accounts,'paypal_accounts'=>$paypal_accounts]);\n\t}", "public function useraccountstate() {\r\n $this->assign('page_title', __('My Account'));\r\n /**\r\n * Add 02/08/2010\r\n */\r\n include_once(P_LIB.'/pager.php');\r\n\r\n $curr_user_id = SessionHolder::get('user/id');\r\n\r\n $o_user_ext = new UserExtend();\r\n $curr_user_ext =& $o_user_ext->find(\"user_id=?\", array($curr_user_id));\r\n if (!$curr_user_ext) {\r\n $this->assign('json', Toolkit::jsonERR(__('Invalid ID!')));\r\n return '_error';\r\n }\r\n $this->assign('curr_user_ext', $curr_user_ext);\r\n\r\n $user_transactions =& Pager::pageByObject('Transaction', \"user_id=?\", array($curr_user_id),\r\n \"ORDER BY `action_time` DESC\");\r\n $this->assign('transactions', $user_transactions['data']);\r\n $this->assign('pager', $user_transactions['pager']);\r\n $this->assign('page_mod', $user_transactions['mod']);\r\n\t\t$this->assign('page_act', $user_transactions['act']);\r\n\t\t$this->assign('page_extUrl', $user_transactions['extUrl']);\r\n }", "public function index() {\n\n\t\t$user = Auth::user();\n\n\t\treturn view( 'member.account.index' )->with( [ 'user' => $user ] );\n\n\t}", "public function accntsttngs()\n {\n $data['title'] = 'Account settings - Shaadi Baraati';\n $admin = $this->session->userdata('admin_id');\n $data['setting'] = $this->m_account->account($admin);\n $this->load->view('account/profile.php', $data, false);\n }", "public function index()\n {\n return view('ecommerce.account', [\n 'user' => json_encode(UserAccountTransformer::transform(Auth::user()))\n ]);\n }", "public function getMakeaccount() {\n\n\t\treturn View::make('channel.account');\n\t}", "function bankAccounts() {\n $this->view->title = 'එක්සත් අවමංගල්‍යාධාර සමිතිය';\n // $this->view->bankAccounts = $this->model->bankAccounts();\n $this->view->render('awamangala/bankAccounts'); //sending paramiters to View() at lib/view.php\n }", "public function getAccount()\n {\n $user = \\Auth::user();\n $accdata = Data::where('user_id','=',$user->id)->get();\n \n return view('accountdata')->with(['accountdata'=>$accdata, 'user'=>$user]);\n }", "public function account()\n {\n return view('pegawai.akunpeg');\n }", "public function index()\n {\n $profile = User::where('phone', Auth::user()->phone)->first();\n $siteinfo = siteinfo::latest()->first();\n return view('admin.account', ['profile' => $profile, 'siteinfo' => $siteinfo]);\n }", "public function account()\n\t{\n\n\n\n\t\t\n$data['rs'] = $this->lib_model->Select('m_faculty', 'id,username,name,email,status', array('id' => $this->session->EmpId));\n\t\t\n\t\n\t\t\t# code...\n\t\t\n\t\t$this->load->view('admin/header', $data);\n\t\t$this->load->view('admin/account');\n\t\t$this->load->view('admin/footer');\n\t\n}", "public function index()\n {\n return view('collection::accounttitle')->with('base', $this->base);\n }", "public function index()\n\t{\n\t\t$user = Auth::user();\n\t\treturn view('account.general', compact('user'));\n\t}" ]
[ "0.73803383", "0.7340963", "0.72559625", "0.71973795", "0.71600586", "0.6989899", "0.69809073", "0.69659686", "0.6898726", "0.6874257", "0.68378913", "0.6804005", "0.67724586", "0.67699647", "0.6755564", "0.6727984", "0.67214006", "0.66174066", "0.6612291", "0.6605747", "0.6605238", "0.66033757", "0.65801114", "0.6567563", "0.6565626", "0.6533817", "0.6511444", "0.65100175", "0.6483432", "0.64827615" ]
0.7593972
0
Sets the global variable $projectID
public function setProjectID($id) { $this->projectID = $id; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function setProjectID($project_id) {\n $this->project_id = $project_id;\n }", "function setProjectId($value) {\n return $this->setFieldValue('project_id', $value);\n }", "function setProjectId($value) {\n return $this->setFieldValue('project_id', $value);\n }", "public function setProjectId($project_id)\n {\n $this->project_id = $project_id;\n }", "public function setProjectId($project_id)\n {\n $this->project_id = $project_id;\n }", "private function setProjectId($projectId) {\n $this->projectId = $projectId;\n }", "public static function initProject($str_project_id) {\n self::$str_project_id = $str_project_id;\n }", "function helper_set_current_project( $p_project_id ) {\n\t\t \n\t\t$t_project_cookie_name\t= config_get( 'project_cookie' );\n\t\t$t_filter_cookie_name\t= config_get( 'view_all_cookie' );\n\n\t\tgpc_set_cookie( $t_project_cookie_name, $p_project_id, true );\n\n\t\t# clear view filter when switching projects\n\t\tgpc_clear_cookie( $t_filter_cookie_name );\n\t\t\n\t\thelper_set_current_task(0);\n\n\t\treturn true;\n\t}", "public function setProjectId($value)\n {\n $this->validateNotNull('ProjectId', $value);\n $this->validateInt('ProjectId', $value);\n\n if ($this->data['project_id'] === $value) {\n return;\n }\n\n $this->data['project_id'] = $value;\n\n $this->setModified('project_id');\n }", "public function determineProjectNumber()\n {\n $project = $this->client()->getProject();\n $this->update(['project_number' => $project['projectNumber']]);\n }", "public function setProjectIdAttribute($input)\n {\n $this->attributes['project_id'] = $input ? $input : null;\n }", "public function setProjectIdAttribute($input)\n {\n $this->attributes['project_id'] = $input ? $input : null;\n }", "public function projectIdentifier($identifier) {\n\t\t$this->_id = $identifier;\n\t}", "protected function setProject($project)\n {\n $this->project = $project;\n }", "private function handleAgumentProjectId($project_id = null)\n {\n return ($project_id ? $project_id : $this->getService()->getConfig()['project_id']);\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function setProjectId($var)\n {\n GPBUtil::checkString($var, True);\n $this->project_id = $var;\n }", "public function setProject($project)\n {\n $this->project = $project;\n }", "public function setProjectId($projectId)\n {\n $this->projectId = $projectId;\n }", "private function getProjectId() {\n return $this->projectId;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "public function getProjectId()\n {\n return $this->project_id;\n }", "function getProjectId() {\n return $this->getFieldValue('project_id');\n }" ]
[ "0.76918155", "0.7395235", "0.7395235", "0.71310055", "0.71310055", "0.70773077", "0.701461", "0.6855343", "0.6810153", "0.6761024", "0.67142886", "0.67142886", "0.6653724", "0.6625466", "0.65485996", "0.65392274", "0.6537789", "0.6522752", "0.65042126", "0.6494403", "0.63395596", "0.63395596", "0.63395596", "0.63395596", "0.63395596", "0.63395596", "0.63395596", "0.63395596", "0.63395596", "0.6191898" ]
0.817969
0
Sets the global variable $employeeName
public function setEmployeeName($name) { $this->employeeName = $name; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function setEmployee($value)\n {\n $this->employee = $value;\n }", "public function getEmployeeName() { return $this->employeeName; }", "function set_person_name()\n\t\t\t\t{\n\t\t\t\t\t$this->first_name = 'Jaddian';\n\t\t\t\t\t$this->last_name = 'Forte';\n\t\t\t\t}", "private function setName() {\n\t\t$this->strName = $_SERVER[\"SERVER_NAME\"];\n\t}", "function set_name($new_name) { # called a setter function\n $this->name = $new_name;\n }", "public function setName($name) {\n // print_r( $name);\n\n $this->name = $name;\n\t}", "public function setName($name){\n\t\t$this->name = $name;\n\t}", "public function setName($name){\n\t\t$this->name = $name;\n\t}", "function set_name($name) {\n $this->name = $name;\n }", "public function setName($name){\r\n $this->name = $name;\r\n }", "public function setName($name) {\n\t\t\t$this->name = $name;\n\t\t}", "public function setName($value){\n\t\t$this->name=$value;\n\t}", "public function setName($name) {\r\n $this->name = $name;\r\n }", "function setName($value){\n\t\t$this->name = $value;\n\t}", "function setName($value) {\r\n $this->name = $value;\r\n }", "function setName( $name )\r\n {\r\n $this->Name = $name;\r\n }", "public function setName($name)\n\t {\n\t \t$this->name = $name;\n\t }", "static function setUserName( $user_name, $event ) {\n\t\tif ( owa_coreAPI::getSetting( 'base', 'log_visitor_pii' ) ) {\n\t\t\t\n\t\t\t// set user name if one does not already exist on event\n\t\t\tif ( ! $user_name && owa_coreAPI::getSetting( 'base', 'log_owa_user_names' ) ) {\n\t\t\t\n\t\t\t\t$cu = owa_coreAPI::getCurrentUser();\n\t\t\t\t\n\t\t\t\t$user_name = $cu->user->get( 'user_id' );\n\t\t\t}\n\t\t\t\n\t\t\treturn $user_name;\n\t\t}\n\t}", "public function setName($name) {\r\n $this->_name = $name;\r\n }", "protected function setChiefEmployee(Employee $employee) {\n\t\t\t$this->_ChiefEmployee = $employee;\n\t\t}", "public function setName( $p_value ) {\r\n\t\t$this->name = $p_value;\r\n\t}", "protected function set_name( $name ) {\n\t\t$this->name = sanitize_key( $name );\n\t}", "public function setName($name){\n $this->name = $name;\n }", "public function setName($name){\n $this->name = $name;\n }", "public function setName($name) {\n\t\t$this->name = $name;\n\t}", "public function setName($name) {\n\t\t$this->name = $name;\n\t}", "public function setName($name) {\n\t\t$this->name = $name;\n\t}", "public function setName($name) {\n\t\t$this->name = $name;\n\t}", "public function setName($name) {\n\t\t$this->name = $name;\n\t}", "public function setName($name) {\n\t\t$this->name = $name;\n\t}" ]
[ "0.6799418", "0.65262747", "0.6461376", "0.63071316", "0.623688", "0.6108344", "0.6011842", "0.6004558", "0.5994179", "0.5972003", "0.5962109", "0.59358233", "0.5928961", "0.59247315", "0.59232193", "0.59209085", "0.5920615", "0.59196734", "0.5915847", "0.59082985", "0.59047174", "0.59034556", "0.5900853", "0.5900853", "0.58968544", "0.58968544", "0.58968544", "0.58968544", "0.58968544", "0.58968544" ]
0.81751776
0
Sets the global variable $employeePhone
public function setEmployeePhone($phone) { $this->employeePhone = $phone; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function setPhone($new_phone)\n {\n $this->phone = $new_phone;\n }", "public function set_phone($phone){\n\t \t$this->phone = $phone;\t\n\t }", "public function setPhone(){\n\t\t$CPhone = ClientPhone::model() -> findByAttributes(array('mangoTalker' => $this -> mangoTalker), array('with' => 'phone'));\n\t\tif ($CPhone) {\n\t\t\t$this -> phone = $CPhone -> phone;\n\t\t\t$this -> i = $this -> phone -> i;\n\t\t}\n\t}", "function setPhone($value);", "function setPhone($phone){\r\n if(strlen($phone)<12) {\r\n $this->phone = $phone;\r\n }\r\n else {\r\n $this->phone='555-555-5555';\r\n }\r\n }", "public function setPhone($value)\n {\n Yii::trace('setPhone()', 'application.components.RinkfinderWebUser');\n\t$this->setState('__phone', $value);\n }", "public function getEmployeePhone() { return $this->employeePhone; }", "public function setPhone($phone)\n {\n $this->phone = $phone;\n $this->telephone = $phone;\n\n\n }", "public function setPhone($phone)\n {\n $this->phone = $this->cleanup($phone);\n }", "public function setPhone($phone) {\r\n $this->phone = $phone;\r\n }", "public function setPhone(string $phone) : void\n {\n $this->phone = $phone;\n }", "public function setPhone(string $phone): void\n {\n $this->_phone = $phone;\n }", "public function setPhone(string $phone)\n\t{\n\t\t$this->addKeyValue('phone', $phone); \n\n\t}", "public function setPhone($var)\n {\n GPBUtil::checkString($var, True);\n $this->phone = $var;\n }", "public function setPhone(?string $phone): void;", "public function setTelephone($telephone)\n {\n $this->telephone = $telephone;\n\n \n }", "function setPhoneNumberCustomer($arg) {\n\t\t$this->parameters['phone_customer'] = $arg;\n\t\treturn $this;\n\t}", "function setPhone($a_sPhone)\n {\n $this->_sPhone = (string) $a_sPhone;\n $this->setSearchParameter('phone', $this->_sPhone);\n }", "public function setPhone(?string $phone): self;", "public function setEmployee($value)\n {\n $this->employee = $value;\n }", "public function setPhone(?string $phone): self\n {\n $this->initialized['phone'] = true;\n $this->phone = $phone;\n\n return $this;\n }", "public function setTelephone($telephone) {\n $this->telephone = $telephone;\n }", "public function setTelephone($telephone) {\n $this->telephone = $telephone;\n }", "public function setTelephone($telephone)\n {\n $this->telephone = (string)$telephone;\n }", "public function setPhone($phone)\n {\n $this->contact_phone = $phone;\n return $this;\n }", "public function setPhoneNumber($phoneNumber)\n {\n $this->phoneNumber = isset($phoneNumber) ? $phoneNumber : '';\n }", "public function setPhoneNumber(?string $value): void {\n $this->getBackingStore()->set('phoneNumber', $value);\n }", "public function setOfficePhone($office_phone)\n {\n $this->office_phone = preg_replace('/\\D/', '', $office_phone);\n\n return $this;\n }", "public function setTelephone($var)\n {\n GPBUtil::checkString($var, True);\n $this->telephone = $var;\n }", "private function _setPhone($phone)\n {\n $this->phone = $phone;\n\n return $this;\n }" ]
[ "0.7414282", "0.7410093", "0.7401461", "0.7375621", "0.73031056", "0.7139005", "0.7059289", "0.70008945", "0.6963344", "0.6906919", "0.6878732", "0.68226206", "0.6717404", "0.663493", "0.658703", "0.6579881", "0.65561914", "0.6490457", "0.64837795", "0.6369448", "0.63664776", "0.63647956", "0.63647956", "0.63627845", "0.628504", "0.626627", "0.61879253", "0.6149756", "0.60994554", "0.6088157" ]
0.8186105
0
Sets the global variable $employeeEmail
public function setEmployeeEmail($email) { $this->employeeEmail = $email; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function setTestUserEmail()\n {\n if (Zend_Registry::get('testConfig')->email) {\n // set email of test user contact\n $testUserContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId());\n $testUserContact->email = Zend_Registry::get('testConfig')->email;\n Addressbook_Controller_Contact::getInstance()->update($testUserContact, FALSE);\n }\n }", "public function getEmployeeEmail() { return $this->employeeEmail; }", "function setEmail($email){\r\n $this->email=$email;\r\n }", "function setEmail($value);", "function setEmail($value)\t\r\n {\r\n\t \t$this->email = $value; //θέτω την τιμή του loggedIn\r\n\t }", "function setJobEmailAddress($email_address)\n {\n $this->__job_email_address = $email_address ;\n }", "public static function setEmail($address)\n {\n self::$emailAddress = $address;\n }", "public function setEmail($value)\n {\n Yii::trace('setEmail()', 'application.components.RinkfinderWebUser');\n\t$this->setState('__email', $value);\n }", "function setEmail($email)\r\n {\r\n $this->email = $email;\r\n }", "protected function setEmail($email) {\r\n $this->email = $email;\r\n }", "public function set_email($email){\n\t\t$this->email = $email;\t\n\t}", "public function setEmail($value)\n {\n $this->email = $value;\n }", "function setEmail($value){\r\n $this->setColumnValue('user_email', $value);\r\n }", "public function setEmail($newEmail){\n $this->email = $newEmail;\n }", "public function setEmail($email)\n {\n $this->email = $email;\n\n \n }", "public function set_email($email) {\n $this->email = $email;\n }", "function setEmail($email = \"\")\n\t\t{\n\t\t if(isset($email) && !empty($email))\n\t\t \t$this->_email = $email;\n\t\t}", "public function setEmail($email)\n {\n $this->_email = $email;\n }", "public function setEmail($email) {\r\n $this->email = $email;\r\n }", "public function setEmail($value)\n {\n $this->setProperty(\"Email\", $value, true);\n }", "public function setEmail($newEmail){\r\n\t\t\r\n\t\tif (filter_var($newEmail, FILTER_VALIDATE_EMAIL)) {\r\n\t\t\t$this->email = $newEmail;\r\n\t\t} else {\r\n\t\t\ttrigger_error(\"e-mail invalide\", E_USER_WARNING);\r\n\t\t}\r\n\t}", "public function setEmail(string $email)\n {\n $this->email = $email;\n\n \n }", "public function setEmail($sEmail) {\n $this->email = $sEmail;\n }", "public function setEmployee($value)\n {\n $this->employee = $value;\n }", "public function setEMail($value) {\n\t\tif (!filter_var($value, FILTER_VALIDATE_EMAIL))\n\t\t\tthrow new \\Exception(\"U dient een geldig e-mail adres op te geven.\");\n\n\t\t$this->_email = $value;\n\t}", "public function setEmail($email)\n {\n $this->email = $email;\n \n }", "public function identifyingEmail()\n\t{\n\t\t$user = $this->findUser();\n\t\tif ($user == null)\n\t\t\t$this->addError('email', 'Δεν ταυτοποιήθηκε χρήστης με τέτοιο όνομα ή email');\n\t}", "public function setEmail($email = '')\n\t{\n\t $this->email = $email;\n\t}", "public function set_email(string $email){\n\t\t$this->email = $email;\n\t}", "public function setEmail($email) {\r\n $this->email = $email;\r\n }" ]
[ "0.7430811", "0.7275118", "0.7121232", "0.70528287", "0.69803876", "0.6962943", "0.6957125", "0.6938441", "0.69271064", "0.69077975", "0.6898341", "0.68845797", "0.6808869", "0.67819583", "0.6779112", "0.67602545", "0.6702261", "0.6659492", "0.66494554", "0.6618353", "0.6582728", "0.6541897", "0.6536559", "0.6536205", "0.652949", "0.65013593", "0.64756817", "0.64644027", "0.64635664", "0.64629686" ]
0.82451415
0
Returns the global variable $employeeID
public function getEmployeeID() { return $this->employeeID; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function get_employee_id($employee_name)\n {\n global $connection;\n $query = \"SELECT employee_id FROM employee\n WHERE employee_name = \\\"{$employee_name}\\\" LIMIT 1\";\n $employee_id = mysql_query($query, $connection);\n confirm_query($employee_id);\n $array = mysql_fetch_array($employee_id);\n $id = $array[0];\n return $id;\t\t\n }", "public function getEmpid($empIdIdentity)\r\n {\r\n if ($this->_empid === false) {\r\n $this->_empid = Employe::find()->where(['EMP_ID' => $empIdIdentity])->one();\r\n }\r\n return $this->_empid;\r\n }", "public function get_employee_no($employee_id)\n\t{\n\t\t/* $user_data = $erp_employee->find()->where(['employee_id'=>$employee_id]); */\n\t\t\n\t\t$erp_employee = TableRegistry::get('erp_users'); \n\t\t$user_data = $erp_employee->find()->where(['user_id'=>$employee_id]);\n\t\t$status = 0;\n\t\t$employee_no = \"\";\n\t\tforeach($user_data as $retrive_data)\n\t\t{\n\t\t\t$employee_no = $retrive_data['employee_no'];\t\t\t\n\t\t}\n\t\treturn $employee_no;\t\t\n\t}", "function get_id() {\n\t\treturn '';\n\t}", "function get_logged_in_employee_current_register_id()\n\t{\n\t\tif($this->is_logged_in())\n\t\t{\n\t\t\t//If we have a register in the session\n\t\t\tif ($this->session->userdata('employee_current_register_id')!==NULL)\n\t\t\t{\n\t\t\t\treturn $this->session->userdata('employee_current_register_id');\n\t\t\t}\n\t\t\t\n\t\t\treturn NULL;\n\t\t}\n\t\t\n\t\treturn NULL;\n\t}", "public static function findIdentity($idEmployee){\n return static::findOne($idEmployee);\n }", "function getID();", "function virool_id() {\n\t\trequire '../config.php';\n\t\treturn $ViroolID;\n\t}", "public function get_user_esi_no($employee_id)\n\t{\n\t\t/* $user_data = $erp_employee->find()->where(['employee_id'=>$employee_id]); */\n\t\t\n\t\t$erp_employee = TableRegistry::get('erp_users'); \n\t\t$user_data = $erp_employee->find()->where(['user_id'=>$employee_id,'employee_no !='=>'']);\n\t\t$esi_no = \"\";\n\t\tforeach($user_data as $retrive_data)\n\t\t{\n\t\t\t$esi_no = $retrive_data['esi_no'];\t\t\t\n\t\t}\n\t\treturn $esi_no;\t\t\n\t}", "public function get_user_epf_no($employee_id)\n\t{\n\t\t/* $user_data = $erp_employee->find()->where(['employee_id'=>$employee_id]); */\n\t\t\n\t\t$erp_employee = TableRegistry::get('erp_users'); \n\t\t$user_data = $erp_employee->find()->where(['user_id'=>$employee_id,'employee_no !='=>'']);\n\t\t$epf_no = \"\";\n\t\tforeach($user_data as $retrive_data)\n\t\t{\n\t\t\t$epf_no = $retrive_data['epf_no'];\t\t\t\n\t\t}\n\t\treturn $epf_no;\t\t\n\t}", "public function get_ID();", "public function GetID ()\r\n\r\n\t{\r\n\t\treturn ($ID);\r\n\t}", "function getExternalID()\n {\n if(is_null($this->externalid)) {\n $this->execQuery();\n }\n return $this->externalid;\n }", "public function getID();", "public function getID();", "public function getID();", "public function getID();", "public function getID();", "public function getId(){\nreturn $this->employeeId;\n}", "function get_employee($employee_id) {\r\n global $db;\r\n $query = 'SELECT * \r\n FROM Employees \r\n WHERE EM_ID = :employee_id';\r\n $statement = $db->prepare($query);\r\n $statement-> bindValue(\":employee_id\", $employee_id);\r\n $statement->execute();\r\n $employee = $statement->fetch();\r\n $statement->closeCursor();\r\n return $employee; \r\n}", "public static function getUserGlobalID()\r\n\t{\r\n\t\tif(self::$_instance === NULL)\r\n\t\t\tthrow new SonicRuntimeException('Sonic instance not initialized');\r\n\t\t\r\n\t\treturn self::$_instance->userAuthData->getGlobalID();\r\n\t}", "public function GetAccountID ()\r\n\r\n\t{\r\n\t\treturn ($AccountID);\r\n\t}", "public function getExternalId();", "public function get_id();", "public function getID() {\n\t\treturn \\Anemo\\ID::getInstance();\n\t}", "public function getEid()\n\t{\n\t\treturn $this->getField('eid');\n\t}", "public function getEventID() {\n return($this->eventID);\n }", "public function getEmployeeDetails(){\n\t\t$uid;\n\t\tif(! empty($_SESSION['user_id'])) $uid = $_SESSION['user_id'];\n\t\telse $uid = \"\";\n\t\t$this->employeeDetails = $this->employeesDAO->getEmployeeDetails($uid);\n\t}", "public function get_global_id(){\n\t\treturn (int) $this->v_global_id;\n\t}", "public function getID () {\n\t\treturn $this->log_id;\n\t}" ]
[ "0.6870661", "0.67360693", "0.6392441", "0.6318392", "0.6266885", "0.62447846", "0.617724", "0.61743474", "0.6130702", "0.6120632", "0.61163986", "0.61139506", "0.6020297", "0.60128826", "0.60128826", "0.60128826", "0.60128826", "0.60128826", "0.60121685", "0.60036755", "0.60027826", "0.59976685", "0.59968245", "0.5986866", "0.59835637", "0.5976051", "0.5969496", "0.5969492", "0.5950113", "0.59461224" ]
0.75024295
0
Returns the global variable $employeeName
public function getEmployeeName() { return $this->employeeName; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getEmployeeName()\n {\n return $this->getEmployeeData('nome');\n }", "public function get_global_name(){\n\t\treturn $this->v_global_name;\n\t}", "public function getEmployeeInformation(){\n print(\"Employee\");\n }", "public function getEmployerName(): string\n {\n return $this->employerName;\n }", "function Summer(){\n\t\tglobal $Name; //That allows us acces the variable in which global.\n\t\techo $Name;\n\t\techo Name;\n\t}", "protected function _get_name() {\n\t\treturn $this->getData( 'name' );\n\t}", "function getempname($db, $empid) {\r\n\t$sql = \"SELECT first_name || ' ' || last_name AS emp_name \".\r\n\t \"FROM employees \".\r\n\t \"WHERE employee_id = :id\";\r\n\t$res = $db->execFetchAll($sql, \"Get EName\", array(array(\":id\", $empid, -1)));\r\n\t$empname = $res[0]['EMP_NAME'];\r\n\treturn($empname);\r\n }", "function printDepartment()\n{\n\tglobal $departmentName;\t//tells the function to use the global scope version of this variable\n\techo $departmentName;\t\n}", "function printDepartment()\n{\n\tglobal $departmentName;\t//tells the function to use the global scope version of this variable\n\techo $departmentName;\t\n}", "public function getNombre_empleado()\n {\n return $this->nombre_empleado;\n }", "public function getEmployee()\n {\n return $this->employee;\n }", "public function get_eventname() {\n return $this->eventname;\n }", "public function getCurrentName(): string;", "public function getEmployeeID() { return $this->employeeID; }", "function getTitle(){\n global $pageName;\n return isset($pageName) ? $pageName : 'No Name';\n }", "public function get_name();", "public function get_name();", "public function get_name();", "public function getEmployeeName($empid){\n\t\t\t$stmt = $this->con->prepare(\"SELECT name FROM employees WHERE id = ?\");\n\t\t\t$stmt->bind_param(\"s\", $empid);\n\t\t\t$stmt->execute();\n\t\t\treturn $stmt->get_result()->fetch_assoc();\n\t\t}", "function getName(){\n\t\tif($this->name==\"\") {\n\t\t\t$this->obtainName();\n\t\t}\n\t\treturn $this->name;\n\t}", "function get_name() { # called a getter function\n # the $this-> is a self-referencing variable and \n # points to the current object (class person)\n return $this->name;\n }", "public function setEmployeeName($name) { $this->employeeName = $name; }", "public function getCurrentName(){\n return $this->currentName;\n }", "private function getCurrentUserName()\n {\n try {\n $name = $this->getCurrentAdminSession()->getUser()->getFirstname();\n if (empty($name)) {\n $name = Mage::getStoreConfig(self::TRANS_EMAIL_IDENT_GENERAL_NAME, Mage::app()->getStore());\n }\n return $name;\n } catch (Exception $e) {\n return \"\";\n }\n }", "function get_name()\n {\n return $this->get_default_property(self::PROPERTY_NAME);\n }", "public function get_employement_name() {\n $this->db->select('emp_status,id as emp_status_id');\n $this->db->from('main_employment_status');\n $query = $this->db->get();\n return $query->result();\n }", "public function getNameUser()\n {\n //return '[email protected]';\n return $this['loginUser'];\n }", "public function getEmployeeEmail() { return $this->employeeEmail; }", "private function get_name() {\n\t\t\t$full_name = $this->firstname . \" \" . $this->lastname;\n\t\t\treturn $full_name;\n\t\t}", "public function getEmployee();" ]
[ "0.73346794", "0.65493584", "0.64722204", "0.64543056", "0.64255947", "0.6343948", "0.6325184", "0.6306624", "0.6306624", "0.6025673", "0.60165316", "0.5989103", "0.5986738", "0.59651834", "0.5961658", "0.59571534", "0.59571534", "0.59571534", "0.5955659", "0.59277505", "0.5904599", "0.5888643", "0.588286", "0.58817524", "0.5870624", "0.5863913", "0.5852474", "0.58503765", "0.58500004", "0.58422107" ]
0.72712904
1
Returns the global variable $employeePhone
public function getEmployeePhone() { return $this->employeePhone; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function getEvePhone()\n\t{\n\t\treturn $this->eve_phone;\n\t}", "public function getPhone()\n {\n return $this->contact_phone;\n }", "public function getPhone()\n {\n Yii::trace('getPhone()', 'application.components.RinkfinderWebUser');\n\treturn $this->getState('__phone');\n }", "public function getPhone();", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone()\n\t{\n\t\treturn $this->getKeyValue('phone'); \n\n\t}", "public function getPhone(): string\n {\n return $this->_phone;\n }", "public function getCustomerPhone()\n {\n return $this->customerPhone;\n }", "public function getPhone()\n {\n return $this->phone;\n }", "public function getPhone() {\n return $this->phone;\n }", "public function getPhone() {\n return $this->phone;\n }", "public function get_phone(){\n\t\tprint $this->phone . \"\\n\";\t\n\t}" ]
[ "0.72636503", "0.7144914", "0.71365887", "0.707301", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.7010493", "0.69892335", "0.69743985", "0.6968297", "0.6956427", "0.6943996", "0.69299877", "0.6924335" ]
0.80007124
0
Returns the global variable $employeeEmail
public function getEmployeeEmail() { return $this->employeeEmail; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function getEmail(){\n\t\treturn self::$email;\n\t}", "protected function _getEmail()\n\t{\n\t\treturn $this->helper('customer')->getCustomer()->getEmail();\n\t}", "function getJobEmailAddress()\n {\n return ($this->__job_email_address) ;\n }", "public function obtenerEmail(){\r\n return $this->email;\r\n }", "function getEmail()\n\t {\n\t \treturn $this->_email;\n\t }", "public function getEmail()\n\t\t{\n\t\t}", "public function getEmail()\n {\n Yii::trace('getEmail()', 'application.components.RinkfinderWebUser');\n\treturn $this->getState('__email');\n }", "public function email(){\r\n\t\treturn $this->_email;\r\n\t}", "function getEmail() {\n\t\treturn $this->email;\n\t}", "function getEmail() {\n $user = $this->loadUser(Yii::app()->user->id);\n return $user->staff_email;\n }", "public function getEmail() {\n\t\treturn ($this->email);\n\t}", "public function getUserEmail() {\n return($this->userEmail);\n }", "public function getEmail(){\r\n\t\treturn $this->email;\r\n\t}", "public function getUserEmail()\n\t{\n\t\treturn $this->user_email;\n\t}", "public function getEmail() {\n return $this->sEmail;\n }", "public function getUserEmail() {\n\t\treturn $this->userEmail;\n\t}", "public function getUserEmail() {\n\t\treturn $this->userEmail;\n\t}", "public function getEmail() {\n return $this->_personal_email;\n }", "public function getEmail(){\n\t\t\treturn $this->email;\n\t\t}", "public function getStrEmail()\n {\n return $this->strEmail;\n }", "public function getEmail(){\n return $this->info['email'];\n }", "public function getEmail();", "public function getEmail();", "public function getEmail();", "public function getEmail();", "public function getEmail();", "public function getEmail();", "public function getEmail();", "public function getEmail()\r\n\t{\r\n\t\treturn $this->email;\r\n\t}", "public function getEmail()\r\n\t{\r\n\t\treturn $this->email;\r\n\t}" ]
[ "0.77066773", "0.7324251", "0.7303077", "0.73020405", "0.7283108", "0.7276098", "0.72754693", "0.72736865", "0.7267038", "0.7221924", "0.72192377", "0.7205597", "0.71963304", "0.7192121", "0.7184966", "0.71821356", "0.71821356", "0.7176705", "0.71602345", "0.71491385", "0.71344316", "0.7128123", "0.7128123", "0.7128123", "0.7128123", "0.7128123", "0.7128123", "0.7128123", "0.7101019", "0.7101019" ]
0.81908166
0
Creates a new Employee object and inserts in the Employee table in the databae. Called in EmployeeController.php
public function create() { global $connection; $eName = $this->getEmployeeName(); $ePhone = $this->getEmployeePhone(); $eEmail = $this->getEmployeeEmail(); $query = "INSERT INTO employee (employee_name, phone_number, email) VALUES ('{$eName}','{$ePhone}','{$eEmail}')"; $result = mysql_query($query, $connection); confirm_query($result); redirect_to("EmployeeCreateView.php"); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public function createAction()\n {\n\n if (!$this->request->isPost()) {\n return $this->dispatcher->forward(array(\n \"controller\" => \"employees\",\n \"action\" => \"index\"\n ));\n }\n\n $employee = new Employees();\n\n $employee->id = $this->request->getPost(\"id\");\n $username = $this->request->getPost(\"username\");\n //Check if this username is already in use as client username\n $checkUsername = Clients::findFirst(array(\n 'username = ?0',\n 'bind' => $username\n ));\n if ($checkUsername != false) {\n $this->flash->error(\"This username is already taken\");\n return $this->dispatcher->forward(array(\n \"controller\" => \"employees\",\n \"action\" => \"new\"\n ));\n }\n $employee->password = $this->security->hash($this->request->getPost(\"password\"));\n $employee->roleId = $this->request->getPost(\"role_id\");\n $employee->fullname = $this->request->getPost(\"fullname\");\n $employee->job = $this->request->getPost(\"job\");\n $employee->contacts = $this->request->getPost(\"contacts\");\n $employee->moreInfo = $this->request->getPost(\"more_info\");\n $employee->worksSince = $this->request->getPost(\"works_since\");\n\n\n if (!$employee->save()) {\n foreach ($employee->getMessages() as $message) {\n $this->flash->error($message);\n }\n return $this->dispatcher->forward(array(\n \"controller\" => \"employees\",\n \"action\" => \"new\"\n ));\n }\n\n $this->flash->success(\"The Employee was created successfully\");\n return $this->dispatcher->forward(array(\n \"controller\" => \"employees\",\n \"action\" => \"index\"\n ));\n\n }", "public function insert()\n {\n $params = [\n\t\t\t'first_name'\t=> $this->input->post('first_name'),\n\t\t\t'last_name'\t\t=> $this->input->post('last_name'),\n\t\t\t'designation'\t=> $this->input->post('designation'),\n\t\t\t'based'\t\t => $this->input->post('based'),\n\t\t\t'gender'\t\t=> $this->input->post('gender'),\n\t\t\t'salary'\t => $this->input->post('salary')\n\t\t];\n // employee model -> add\n $msg = $this->employeeservice->addEmployee($params);\n echo json_encode($msg);\n }", "public function store(StoreEmployee $request)\n {\n $data = $request->all();\n Employee::create($data);\n session()->flash('success', 'Employee Successfully Inserted!');\n return redirect()->route('employee.index');\n }", "public function actionCreate()\n {\n $model = new EmployeeDetails();\n\n if ($model->load(Yii::$app->request->post()) && $model->save(false)) {\n return $this->redirect(['view', 'id' => $model->empId]);\n }\n\n return $this->render('create', [\n 'model' => $model,\n ]);\n }", "public function store(EmployeeRequest $request)\n {\n $input = $request->all();\n Employee::create($input);\n return Redirect::route($this->route)->with($this->success, trans($this->createmsg));\n }", "public function store(EmployeeRequest $request)\n {\n $data = $request->all();\n\n try {\n if ($data['phone'] == null) $data['phone_country'] = null;\n \n $employee = Employee::create($data);\n }\n catch (QueryException $e)\n {\n Session::flash('message', __('messages.error_save'));\n return redirect('/employees');\n }\n catch (Exception $e)\n {\n Session::flash('message', __('messages.error_save'));\n return redirect('/employees');\n }\n\n Session::flash('message', __('messages.added_successfully', ['name' => $employee->first_name . ' ' . $employee->last_name ]));\n return redirect('/employees');\n }", "public function store(EmployeeRequest $request)\n {\n /*$request->validate([\n 'first_name' => 'required',\n 'last_name' => 'required',\n 'company_id' => 'required'\n ]);*/\n\n Employee::create($request->all());\n return redirect()->route('employees.index')\n ->with('success', 'New Employee data created successfully');\n }", "public function createEmployeeAccount(){\n // needs disclaimer about password being saved as plaintext\n $name = $this->request->getParameter('reg-name');\n $username = $this->request->getParameter('reg-username');\n $password = $this->request->getParameter('reg-password');\n $sinno = $this->request->getParameter('reg-sin');\n $accType = $this->request->getParameter('reg-acc-type');\n\n if (is_null($name) || strlen($name) == 0 ||\n is_null($username) || strlen($username) == 0 ||\n is_null($password) || strlen($password) == 0) {\n\n throw new InvalidArgumentException(\"Required form input missing. Either name, username, or password.\");\n }\n $usernameQueryStr_e = \"SELECT * FROM Employees WHERE Employee_Login = '$username' \";\n\n $usernameQueryResult = $this->dbProvider->selectQuery($usernameQueryStr_e);\n\n\n if (empty($usernameQueryResult)) {\n throw new EntityExistsException(\"User exists with username $username\");\n }\n\n $registerQueryStr_e = \"INSERT INTO Employees \".\n \"(SIN, Employee_Login, Employee_Password, FirstName) \".\n \" VALUE \".\n \"('$sinno', '$username', '$password', '$name' ) \";\n\n $created = $this->dbProvider->insertQuery($registerQueryStr_e);\n\n if (!$created) {\n throw new SQLException(\"Failed to create User with $name, $username, $password\");\n }\n }", "public function store(EmployeeRequest $request)\n {\n // Basic validation done through EmployeeRequest\n\n $data = [\n 'role_id' => $request->role_id,\n 'team_id' => $request->team_id,\n 'first_name' => $request->first_name,\n 'last_name' => $request->last_name,\n 'email' => $request->email,\n 'hiring_date' => $request->hiring_date,\n ];\n\n $newEmployee = Employee::create($data);\n\n return response()->json(['data' => $newEmployee, 'success' => true], 200);\n }", "public function store(CreateEmployeeRequest $request)\n {\n $input = $request->all();\n\n $employee = $this->employeeRepository->create($input);\n\n Flash::success('Employee saved successfully.');\n\n return redirect(route('employees.index'));\n }", "public function created(Employee $employee)\n {\n //\n }", "public function store(EmployeeRequest $request)\n {\n $name = $request['name'];\n $network_account = $request['network_account'];\n $email = $request['email'];\n $manager = $request['manager'];\n $clone_account = $request['clone_account'];\n $location = $request['location'];\n $job_title = $request['job_title'];\n $did = $request['did'];\n $ext = $request['ext'];\n $start_date = $request['start_date'];\n\n $clogics_account = $request['clogics_account'];\n $logics = $request['logics'];\n $assign_logics_sms = $request['assign_logics_sms'];\n $tax_preparer_udfid = $request['tax_preparer_udfid'];\n $tax_preparers_eas = $request['tax_preparers_eas'];\n $ifax_account = $request['ifax_account'];\n $spark = $request['spark_account'];\n $docstar = $request['docstar'];\n $user_to_scanner = $request['user_to_scanner'];\n\n //We create an Employee instance and we set parameters\n $employee = new Employee;\n $employee->name = $name;\n $employee->network_account = $network_account;\n $employee->email = $email;\n $employee->manager = $manager;\n $employee->clone_account = $clone_account;\n $employee->location = $location;\n $employee->job_title = $job_title;\n $employee->did = $did;\n $employee->ext = $ext;\n $employee->start_date = $start_date;\n $employee->save();\n\n //Personal Account\n $personal_account = new Account();\n $personal_account->employee_id = $employee->id;\n $personal_account->type_account = Account::TYPE_PERSONAL_ACCOUNT;\n $personal_account->user_name = $network_account;\n $personal_account->password = Account::DEFAULT_PASSWORD;\n $personal_account->save();\n\n //Outlook Account\n $outlook_account = new Account();\n $outlook_account->employee_id = $employee->id;\n $outlook_account->type_account = Account::TYPE_OUTLOOK_ACCOUNT;\n $outlook_account->user_name = $email;\n $outlook_account->password = Account::DEFAULT_PASSWORD;\n $outlook_account->save();\n\n //PhoneSystem Account\n $phonesys_account = new Account();\n $phonesys_account->employee_id = $employee->id;\n $phonesys_account->type_account = Account::TYPE_PHONESYSTEM_ACCOUNT;\n $phonesys_account->user_name = $network_account;\n $phonesys_account->password = Account::DEFAULT_PASSWORD;\n $phonesys_account->save();\n\n //3C Logics Account\n if( !empty($clogics_account) ) {\n $employee->clogics_account = true;\n $logics3c_account = new Account();\n $logics3c_account->employee_id = $employee->id;\n $logics3c_account->type_account = Account::TYPE_3CLOGICS_ACCOUNT;\n $logics3c_account->user_name = str_replace(' ', '', $name);\n $logics3c_account->password = Account::DEFAULT_3CLOGICS_PASSWORD;\n $logics3c_account->save();\n } else {\n $employee->clogics_account = false;\n }\n \n //Logics Account\n if( !empty($logics) ) {\n $employee->logics_account = true;\n $logics_account = new Account();\n $logics_account->employee_id = $employee->id;\n $logics_account->type_account = Account::TYPE_LOGICS_ACCOUNT;\n $logics_account->user_name = $email;\n $logics_account->save();\n } else {\n $employee->logics_account = false;\n $logics_account = new Account();\n $logics_account->employee_id = $employee->id;\n $logics_account->type_account = Account::TYPE_LOGICS_ACCOUNT;\n $logics_account->save();\n }\n\n //Hylafax Account\n if( !empty($ifax_account) ) {\n $employee->ifax_account = true;\n $hylafax_account = new Account();\n $hylafax_account->employee_id = $employee->id;\n $hylafax_account->type_account = Account::TYPE_HYLAFAX_ACCOUNT;\n $hylafax_account->user_name = $network_account;\n $hylafax_account->password = Account::DEFAULT_PASSWORD;\n $hylafax_account->save();\n } else {\n $employee->ifax_account = false;\n $hylafax_account = new Account();\n $hylafax_account->employee_id = $employee->id;\n $hylafax_account->type_account = Account::TYPE_HYLAFAX_ACCOUNT;\n $hylafax_account->save();\n }\n\n //Spark Account\n if( !empty($spark) ) {\n $employee->spark_account = true;\n $sparkAccount = new Account();\n $sparkAccount->employee_id = $employee->id;\n $sparkAccount->type_account = Account::TYPE_SPARK_ACCOUNT;\n $sparkAccount->user_name = $ext;\n $sparkAccount->password = Account::DEFAULT_PASSWORD_SPARK;\n $sparkAccount->save();\n } else {\n $employee->spark_account = false;\n $sparkAccount = new Account();\n $sparkAccount->employee_id = $employee->id;\n $sparkAccount->type_account = Account::TYPE_SPARK_ACCOUNT;\n $sparkAccount->save();\n }\n\n //DocStar Account\n if( !empty($docstar) ) {\n $employee->ds_account = true;\n $docstar_account = new Account();\n $docstar_account->employee_id = $employee->id;\n $docstar_account->type_account = Account::TYPE_DOCSTAR_ACCOUNT;\n $docstar_account->user_name = $network_account;\n $docstar_account->password = Account::DEFAULT_PASSWORD;\n $docstar_account->save();\n } else {\n $employee->ds_account = false;\n $docstar_account = new Account();\n $docstar_account->employee_id = $employee->id;\n $docstar_account->type_account = Account::TYPE_DOCSTAR_ACCOUNT;\n $docstar_account->save();\n }\n\n if( !empty($assign_logics_sms) ) {\n $employee->assign_logics_sms = true;\n } else {\n $employee->assign_logics_sms = false;\n }\n\n if( !empty($tax_preparer_udfid) ) {\n $employee->tax_preparer_udfid = true;\n } else {\n $employee->tax_preparer_udfid = false;\n }\n\n if( !empty($tax_preparers_eas) ) {\n $employee->tax_preparers_eas = true;\n } else {\n $employee->tax_preparers_eas = false;\n }\n\n if( !empty($ifax_account) ) {\n $employee->ifax_account = true;\n } else {\n $employee->ifax_account = false;\n }\n\n if( !empty($user_to_scanner) ) {\n $employee->user_to_scanner = true;\n } else {\n $employee->user_to_scanner = true;\n }\n\n $employee->save();\n\n alert()->success('Employee', 'The record has been saved successfully.');\n return redirect()->route('employees.index')->with('message', 'item added');\n }", "public function addEmployee()\n {\n $employees = [\n ['name' => 'khan', 'email' => '[email protected]', 'phone' => '123456789', 'salary' => '400000', 'department' => 'Accounting'],\n\n ['name' => 'inam', 'email' => '[email protected]', 'phone' => '1234556789', 'salary' => '500000', 'department' => 'marketing'],\n\n ['name' => 'umar', 'email' => '[email protected]', 'phone' => '12345678916', 'salary' => '600000', 'department' => 'programming'],\n\n ['name' => 'waqas', 'email' => '[email protected]', 'phone' => '12347756789', 'salary' => '700000', 'department' => 'Mobile apps'],\n\n ['name' => 'latif', 'email' => '[email protected]', 'phone' => '1234567654689', 'salary' => '800000', 'department' => 'developer'],\n ];\n Employee::insert($employees);\n return 'record has been inserted successfully!';\n }", "public function store(StorePostRequest $request)\n {\n\n $employee =new employee;\n $employee->emp_id = $request->empid;\n $employee->fname = $request->fname;\n $employee->lname = $request->lname;\n $employee->phone = $request->phone;\n $employee->email = $request->email;\n $employee->gender = $request->gender;\n $employee->address = $request->address;\n $employee->salary = $request->salary;\n $employee->dep_id = $request->depid;\n $employee->team_id = $request->teamid;\n\n $dep=Department::where('dep_id','=',$request->depid)->first();\n $team=Team::where('id','=',$request->teamid)->first();\n $em=employee::where('emp_id','=',$request->empid)->first();\n if(empty($em)){\n\n if(!empty($dep)){\n\n if(!empty($team)){\n \n if($employee->save()){\n return $this->success($employee,201);\n }\n else{\n return $this->error(\"employee not saved\");\n }\n }\n else{\n return $this->error(\"Team not exist with this Id\");\n }\n }\n else{\n return $this->error(\"Department not exist with this Id\");\n }\n }\n else{\n return $this->error(\"Employee already exist with this Id\");\n }\n\n }", "public function store(StoreEmployees $request)\n {\n $data = $request->only('name', 'age', 'job_description', 'warehouse_id');\n\n Employee::create($data);\n\n return redirect('/employees')->with('success', 'Employee Successfully Created');\n }", "public function store(EmployeeRequest $request)\n {\n $employeeCreated = $this->repository->create($request->all());\n\n if($employeeCreated){\n return redirect()->route('employees.index')->with('success', 'employee has been created Successfully');\n }\n return redirect()->route('employees.index')->with('error', 'Error in creating employee.');\n\n }", "public function postCreate(Request $request)\n {\n\t\t$this->validate($request, [\n 'first_name' => 'required|min:2|max:30',\n\t\t\t'last_name' => 'required|min:2|max:30',\n ]);\n\t\t\n\t\t$employee = new \\App\\Employee();\n\t\t$employee->first_name = $request->first_name;\n\t\t$employee->last_name = $request->last_name;\n\t\t$employee->position = $request->position;\n\t\t$employee->month = $request->month;\n\t\t$employee->day = $request->day;\n\t\t$employee->year = $request->year;\n\t\t$employee->save();\n\t\t\n\t\t\\Session::flash('flash_message','The new employee has been added');\n\t\treturn redirect('/employees');\n }", "public function store(EmployeeRequest $request)\n {\n // if($request->has('id')){\n // Employee::where('id',$request->id)->update($request->except('_token','id'));\n // }else{\n // Employee::create($request->except('_token','id'));\n // }\n // return response()->json(['message'=>'Saved']);\n $request->merge(['employee_no'=>'EMP-'.Str::random(10)]);\n $employee = Employee::create($request->except('_token'));\n $data = Employee::where('id',$employee->id)->with(['branch','job_title','user'])->first();\n return response()->json(['message'=>'Saved','data'=>$data],200);\n }", "public function store(EmployeeRequest $request)\n {\n Employee::create($request->all());\n return redirect(route('employees.index'))->with('message', 'Empleado creado corectamente');\n }", "public function store(Request $request)\n {\n\n $employee = new Employee();\n $employee->first_name = $request->input('first_name');\n $employee->middle_name = ($request->has('middle_name'))?$request->input('middle_name'):\"\";\n $employee->last_name = $request->input('last_name');\n $employee->pension_fund_id = $request->input('pension_fund_id');\n $employee->pension_identification_number = ($request->has('pension_identification_number'))?$request->input('pension_identification_number'):\"\";\n $employee->gender = $request->input('gender');\n $employee->date_of_birth = $request->input('date_of_birth');\n $employee->salary = $request->input('salary');\n $employee->employee_type = $request->input('employee_type');\n $employee->date_of_retirement = $request->input('date_of_retirement');\n $employee->email = ($request->has('email'))?$request->input('email'):\"\";\n $employee->phone_number = ($request->has('phone_number'))?$request->input('phone_number'):\"\";\n $employee->institution_id = $request->input('institution_id');\n\n $employee->save();\n }", "public function store(StoreEmployee $request)\n {\n $validated = $request->validated();\n $company = Company::find($validated['company_id']);\n\n $employee = $company->employees()->create($validated); // Create employee as a child of the company\n\n Session::flash('message', 'Successfully added the employee.');\n return redirect('employees');\n }", "public function store()\n {\n $allInputs = Input::all();\n\n $validator = Validator::make($allInputs, $this->emolpoyeesModel->getRules('STORE'));\n\n if ($validator->fails()) {\n return Redirect::to('employees/create')->with('message_danger', $validator->errors());\n } else {\n if ($employee = $this->emolpoyeesModel->insertRow($allInputs)) {\n $this->systemLogs->insertSystemLogs('Employees has been add with id: '. $employee, 200);\n return Redirect::to('employees')->with('message_success', $this->language->getMessage('messages.SuccessEmployeesStore'));\n } else {\n return Redirect::back()->with('message_success', $this->language->getMessage('messages.ErrorEmployeesStore'));\n }\n }\n }", "public function actionCreate()\n {\n if(!app()->user->checkAccess('createUser')) {\n\n if(!app()->user->checkAccess('manageUser')){\n app()->user->setFlash('error', 'You are not authorized to create a new user !');\n app()->request->redirect(app()->createUrl('/'));\n }\n else {\n app()->user->setFlash('error', 'You are not authorized to create a new user !');\n app()->request->redirect(app()->createUrl('/User/Admin'));\n }\n\n }\n elseif(app()->user->checkAccess('createUser')) {\n\n $model=new User('create');\n $employeemodel=new Employee('create');\n $roles = $model->getRoleOptions();\n $pass = $model->autoGeneralPass();\n\n if(app()->user->checkAccess('admin') && app()->user->type == 0){\n unset($roles[USER::ADMIN]);\n }\n elseif(app()->user->checkAccess('manager') && app()->user->type == 0){\n unset($roles[USER::ADMIN]);\n unset($roles[USER::MANAGER]);\n }\n elseif(app()->user->checkAccess('leader') && app()->user->type == 0){\n unset($roles[USER::ADMIN]);\n unset($roles[USER::MANAGER]);\n unset($roles[USER::LEADER]);\n }\n\n // Uncomment the following line if AJAX validation is needed\n $this->performAjaxValidation(array($model,$employeemodel));\n\n if(isset($_POST['User']))\n {\n $model->attributes = Clean($_POST['User']);\n $model->email = textlower($_POST['User']['email']);\n $model->password = encrypt($pass);\n $model->activkey = encrypt(microtime().$model->password);\n $model->dob = $model->setUserDob($_POST['User']['dob']);\n $model->created_date = gettime();\n\n // validate BOTH $model and $employeemodel\n $model->validate();\n $employeemodel->validate();\n // End validate\n\n if($model->save()){\n $employeemodel->attributes = Clean($_POST['Employee']);\n $employeemodel->id = $model->id;\n /*if(isset($_POST['Employee']['personal_email'])) {\n $employeemodel->personal_email = textlower($employeemodel->personal_email);\n }*/\n if(isset($_POST['Employee']['department'])) {\n $employeemodel->setDepartment($_POST['Employee']['department']);\n }\n $employeemodel->created_date = $model->created_date;\n if($employeemodel->save()) {\n $this->associateUserToRole($_POST['User']['user_role'], $model->id);\n $activation_url = $this->createAbsoluteUrl('/activation/Index',array(\"activkey\" => $model->activkey, \"email\" => $model->email));\n MailTransport::sendMail(\n app()->params['noreplyEmail'],\n $model->email,\n 'Welcome to EMS',\n CController::renderPartial('emailwelcome',array('activation_url'=>$activation_url,'email'=>$model->email,'password'=>$pass),true,false)\n );\n app()->user->setFlash('success', 'You create a new user successful !');\n $this->redirect(array('view','id'=>$model->id));\n }\n }\n }\n }\n $this->render('create',array(\n 'model'=>$model,\n 'employeemodel'=>$employeemodel,\n 'roles'=>$roles,\n ));\n\n }", "public function create(){\n $getIdQuery = \"SELECT empId FROM \" . $this->table_name . \"\n ORDER BY empId DESC LIMIT 0,1\";\n // prepare the getIdQuery\n $stmt = $this->conn->prepare($getIdQuery);\n $stmt->execute();\n // get number of rows\n $num = $stmt->rowCount();\n\n if($num > 0 ){\n $result = $stmt->fetch(PDO::FETCH_ASSOC); \n $eId = $result['empId'];\n $num = trim($eId , \"EN\");\n $num = $num + 1;\n $this->empId = \"EN\" . sprintf(\"%04d\", $num);\n } else {\n $this->empId = \"EN0001\";\n }\n\n // insert query\n $query = \"INSERT INTO \" . $this->table_name . \"\n SET\n empId = :empId,\n firstName = :firstName,\n middleName = :middleName,\n lastName = :lastName,\n email = :email,\n contact = :contact,\n dateOfBirth = :dateOfBirth,\n dateOfJoin = :dateOfJoin,\n location = :location,\n empRole = :empRole,\n empType = :empType,\n empStatus = :empStatus,\n manager = :manager,\n departmentId = :departmentId\n \";\n\n // begin a transaction\n $this->conn->beginTransaction();\n // prepare the query\n $stmt = $this->conn->prepare($query);\n \n // sanitize\n $this->empId=htmlspecialchars(strip_tags($this->empId));\n $this->firstName=htmlspecialchars(strip_tags($this->firstName));\n $this->middleName=htmlspecialchars(strip_tags($this->middleName));\n $this->lastName=htmlspecialchars(strip_tags($this->lastName));\n $this->email=htmlspecialchars(strip_tags($this->email));\n $this->contact=htmlspecialchars(strip_tags($this->contact));\n $this->dateOfBirth=htmlspecialchars(strip_tags($this->dateOfBirth));\n $this->dateOfJoin=htmlspecialchars(strip_tags($this->dateOfJoin));\n $this->location=htmlspecialchars(strip_tags($this->location));\n $this->empRole=htmlspecialchars(strip_tags($this->empRole));\n $this->empType=htmlspecialchars(strip_tags($this->empType));\n $this->empStatus=htmlspecialchars(strip_tags($this->empStatus));\n $this->manager=htmlspecialchars(strip_tags($this->manager));\n $this->departmentId=htmlspecialchars(strip_tags($this->departmentId));\n\n // bind the values\n $stmt->bindParam(':empId', $this->empId);\n $stmt->bindParam(':firstName', $this->firstName);\n $stmt->bindParam(':middleName', $this->middleName);\n $stmt->bindParam(':lastName', $this->lastName);\n $stmt->bindParam(':contact', $this->contact);\n $stmt->bindParam(':email', $this->email);\n\n $stmt->bindParam(':dateOfBirth', date( \"Y-m-d\", strtotime($this->dateOfBirth)));\n $stmt->bindParam(':dateOfJoin', date( \"Y-m-d\", strtotime($this->dateOfJoin)));\n $stmt->bindParam(':location', $this->location);\n $stmt->bindParam(':empRole', $this->empRole);\n $stmt->bindParam(':empType', $this->empType);\n $stmt->bindParam(':empStatus', $this->empStatus);\n $stmt->bindParam(':manager', $this->manager);\n $stmt->bindParam(':departmentId', $this->departmentId);\n \n // execute the query, also check if query was successful\n\n\n // try the insert, if something goes wrong, rollback.\n if ($stmt->execute() === FALSE) {\n $this->conn->rollback();\n return false;\n } else { \n $this->conn->commit();\n return true;\n }\n\n return false;\n }", "public function store(EmployeeRequest $request)\n {\n $data = $request->validated();\n $employee= Employee::create($data);;\n $response = ['employee' => new EmployeeResource($employee),'message' =>'employee created successfully.'];\n return response($response, 200);\n }", "public function store(EmployeeCreateRequest $request)\n {\n Customer::create($request->all());\n return response()->json([\n 'status' => true,\n 'message' => [\n 'head' => 'Berhasil',\n 'body' => 'Berhasil menambahkan data pelanggan'\n ]\n ], 200);\n }", "public function store(EmployeeRequest $request)\n {\n $params = $request->validated();\n\n Employee::create($params);\n\n return redirect('/companies/' . $request->get('company_id'));\n }", "protected function createEmployee(Request $request)\n {\n $data = $request->all();\n //$myCheckboxes = $request->input('OnRouteDetails_tbl');\n\n $stringArray = self::getArrayString($data['OnRouteDetails_tbl']);\n $jsonObject = '{ \"OnRouteDetails_tbl\": ['.$stringArray.'], ';\n\n $stringArray = self::getArrayString($data['CustomerSurvey_tbl']);\n $jsonObject = $jsonObject.'\"CustomerSurvey_tbl\": ['.$stringArray.'], ';\n\n $stringArray = self::getArrayString($data['TraveledHistory_tbl']);\n $jsonObject = $jsonObject.'\"TraveledHistory_tbl\": ['.$stringArray.'], ';\n\n $stringArray = self::getArrayString($data['home_tbl']);\n $jsonObject = $jsonObject.'\"home_tbl\": ['.$stringArray.'] }';\n\n Employee::create([\n 'firstName' => $data['firstName'],\n 'lastName' => $data['lastName'],\n 'emailAddress' => $data['emailAddress'],\n 'password' => Hash::make($data['password']),\n 'phoneNumber' => $data['phoneNumber'],\n 'employeeAlias' => $data['employeeAlias'],\n ]);\n \n //add verification to send post request if permissions were selected\n self::sendPostRequest($data,$jsonObject);\n \n return view('home');\n }", "public function Insert_Employee($emp_data)\n\t{\n\t\t$this->db->insert('employee', $emp_data);\n\t}", "public function testAddEmployee()\n\t{\n\t\tinclude(\"databaseClass.inc\");\n\t\t$_SESSION['abn'] = '56497978719';\n\n\t\t// Test Valid Entry\n\t\t$this->assertEquals(\n\t\t\t1,\n\t\t\tprocesses::addEmployee('John', 'Job 2', '102', '56497978719', $db)\n\t\t);\n\n\t\t// Test Taken ID\n\t\t$this->assertEquals(\n\t\t\t0,\n\t\t\tprocesses::addEmployee('John', 'Job 2', '102', '56497978719', $db)\n\t\t);\n\n\t}" ]
[ "0.7440914", "0.722781", "0.71334606", "0.7129786", "0.71063566", "0.71062684", "0.7087633", "0.7053755", "0.7040397", "0.7029879", "0.7020511", "0.70186806", "0.69748425", "0.6968411", "0.69483167", "0.6911789", "0.690723", "0.6898501", "0.68977386", "0.6894267", "0.68804806", "0.68782264", "0.6875289", "0.684115", "0.68298405", "0.68200696", "0.680749", "0.67658037", "0.6759267", "0.6751827" ]
0.7643127
0
function to get event search count
function posts_search_count($search) { $this->db->select('*'); $this->db->from(DB_PREFIX.'events'); $this->db->like('ico_events.event_name',$search); $this->db->or_like('ico_events.event_link',$search); $query = $this->db->get(); return $query->num_rows(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countEvents($search = null)\n {\n if($search) {\n $lm = new Labels_model();\n $labels = $lm->searchLabel($search);\n $labelIDs = array();\n $i = 0;\n foreach ($labels as $label) {\n $labelIDs[$i] = $label['id'];\n $i++;\n }\n $this->db->where_in('title', $labelIDs);\n }\n\n $this->db->select('*');\n $this->db->from('Events');\n\n $query = $this->db->get();\n return $query->num_rows();\n }", "function allevent_count()\n { \n\t\t$this->db->select('*');\t\t\n\t\t$this->db->from(DB_PREFIX.'events');\n\t\t$query = $this->db->get();\n\t\treturn $query->num_rows();\n\t}", "public function countEntries($searchResult);", "public function count()\n\t{\n return count($this->_events);\n }", "public function count()\n {\n $endpoint = 'marketing_events/count.json';\n $response = $this->request($endpoint);\n return $response['count'];\n }", "public function count()\n {\n return count($this->events);\n }", "public function count()\n {\n return count($this->_events);\n }", "public function count(): int\n {\n return count($this->events);\n }", "public function getEventsCount()\n {\n return $this->count(self::EVENTS);\n }", "public static function counterEvents()\n {\n include ($_SERVER[\"DOCUMENT_ROOT\"] . \"/venue/venue-finder/config/db_config.php\");\n $query = \"SELECT COUNT(*) FROM events\";\n $result = mysqli_query($mysqli,$query);\n $rows = mysqli_fetch_row($result);\n\n // Debug increase value.\n $rows[0] = $rows[0] * 1;\n\n // Simplify the number if over 1000.\n if ($rows[0] > 1000) {\n // If over 1000.\n $rows[0] = number_format((float)$rows[0] / 1000, 2, '.', '') . \"K\";\n }\n\n return $rows[0];\n }", "function bbp_get_search_pagination_count()\n{\n}", "private static function _count($search) {\n return dbConnection()\n ->query(static::_generateQuery($search, \"COUNT(*) AS cnt\"))\n ->fetch_object()\n ->cnt;\n }", "public function getCount() {\n return $this->db->fetchColumn('SELECT COUNT(idevent_type) FROM wcwd_event_type');\n }", "public function getQueryCount();", "public function getQueryCount();", "public function getCount();", "public function getCount();", "public function getCount();", "public function getCount();", "public function getCount();", "public function getCount();", "public function count();", "public function count();", "public function count();", "public function count();", "public function count();", "public function count();", "public function count();", "public function count();", "public function count();" ]
[ "0.75438863", "0.69364035", "0.68442684", "0.6779472", "0.67525977", "0.67439634", "0.6742298", "0.671561", "0.66782844", "0.6630313", "0.66191816", "0.6547265", "0.6531101", "0.6496755", "0.6496755", "0.64693564", "0.64693564", "0.64693564", "0.64693564", "0.64693564", "0.64693564", "0.6445818", "0.6445818", "0.6445818", "0.6445818", "0.6445818", "0.6445818", "0.6445818", "0.6445818", "0.6445818" ]
0.73757786
1
Run all the jobs that are due now.
public function runJobs() { foreach ($this->jobs as $job) { if ($job->isDue()) { $job->run(); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "public static function cron_runner() {\n\n\t\t// Go through the various regular tasks. These functions should make no assumptions themselves how regularly they are called - i.e. be stateless, within a week (to allow use of transients).\n\t\tself::email_users_with_expiring_cards();\n\n\t\tself::charge_due_users();\n\n\t\tself::renew_due_domains();\n\n\t\tself::email_unpaid_users();\n\n\t}", "function checkPendingJobs() {\n\t\tglobal $sugar_config;\n\t\tglobal $timedate;\n\t\t\n\t\t$GLOBALS['log']->debug('');\n\t\t$GLOBALS['log']->debug('----->Scheduler checking for qualified jobs to run.');\n\t\tif(empty($this->db)) {\n\t\t\t$this->db = DBManagerFactory::getInstance();\n\t\t}\n\t\t\n\t\t$fireTimeMinus = $timedate->asDb($timedate->getNow()->get('-1 minute'));\n\t\t$fireTimePlus = $timedate->asDb($timedate->getNow()->get('+1 minute'));\n\n\t\t// collapse list of schedulers where \"catch_up\" is 0 and status is \"ready\" (not \"in progress, completed, etc.\");\n\t\t$q = 'UPDATE schedulers_times st\n\t\t\t\t\tSET st.status = \\'not run\\' \n\t\t\t\t\tWHERE st.execute_time < '.$this->db->convert($this->db->quoted($fireTimeMinus), 'datetime').'\n\t\t\t\t\tAND st.status = \\'ready\\' \n\t\t\t\t\tAND st.scheduler_id IN (SELECT s.id FROM schedulers s WHERE st.scheduler_id = s.id AND s.catch_up = 0)';\n\t\t$this->db->query($q);\n\t\t\n\t\t$q = 'SELECT DISTINCT st.id, st.scheduler_id, st.status, s.name, s.job FROM schedulers_times st\n\t\t LEFT JOIN schedulers s ON st.scheduler_id = s.id WHERE st.execute_time < '.$this->db->convert($this->db->quoted($fireTimeMinus), 'datetime').\n ' AND st.deleted=0 AND s.deleted=0 AND st.status=\\'ready\\' AND s.status=\\'Active\\' ORDER BY s.name';\n\t\t$r = $this->db->query($q);\n\t\t$count = 0;\n\n\t\twhile($a = $this->db->fetchByAssoc($r)) {\n\t\t\t\n\t\t\t$job = BeanFactory::newBean('SchedulersJobs');\n\t\t\t\n\t\t\t$paramJob = $a['scheduler_id'];\n\t\t\t$job->fire($sugar_config['site_url'].'/index.php?entryPoint=schedulers&type=job&job_id='.$paramJob.'&record='.$a['id']);\n\t\t\t$count++;\n\t\t}\n\n\n\t\tif($count < 1) {\n\t\t\t$GLOBALS['log']->debug('----->Scheduler has found 0 Jobs to fire');\n\t\t}\n\t}", "public function execute()\n {\n if (!$this->itemHelper->isCronEnabled()) {\n return;\n }\n\n try {\n $this->itemModel->cleanOldEntries();\n } catch (\\Exception $e) {\n $this->logger->critical($e);\n }\n }", "public function run_all()\n {\n $age = time() - 60*60*36; // 1.5 days\n try\n {\n $sql = \"SELECT `id` FROM `apps_formitive_index` WHERE (`status` = 'pending' AND `activity` < '$age' );\";\n $rows = Database::getResult($sql);\n unset ($sql);\n }\n catch (Exception $e)\n {\n //TODO - Log the failure\n }\n\n foreach ($rows as $row)\n {\n $this->entry_delete($row['id']);\n }\n\n $this->maintenance_reindex();\n $this->maintenance_reorder();\n $this->maintenance_auto_increment();\n $this->maintenance_optimize_tables();\n }", "protected function schedule(Schedule $schedule)\r\n {\r\n // Pending rengga: aktifin backup ketika live\r\n $schedule->command('backup:clean')->daily()->at('01:00');\r\n $schedule->command('backup:run')->daily()->at('02:00');\r\n /*$schedule->command('foo')\r\n ->cron('* * * * * *')\r\n ->appendOutputTo('reminder_log.txt');*/\r\n\r\n \r\n //CHECK PENDING INVESMENT PAYMENT\r\n /*$schedule->call(function () {\r\n $investments = Investment::pendingInstallment()->get();\r\n\r\n foreach ($investments as $investment) {\r\n DB::beginTransaction();\r\n\r\n try {\r\n $loan = Loan::find($investment->loan_id);\r\n if (!empty($loan)) {\r\n $loan->amount_funded -= $investment->amount_invested;\r\n $loan->save();\r\n }\r\n $investment->status_id = Status::select('id')->where('name', 'cancelled')->first()->id;\r\n //$investment->deleted_at = Carbon::now();\r\n $investment->save();\r\n } catch (Exception $e) { \r\n return $e->getMessage();\r\n DB::rollback();\r\n }\r\n\r\n DB::commit();\r\n }\r\n })\r\n ->everyMinute();*/\r\n\r\n // Check due installments\r\n $schedule->call(function () {\r\n $dateFormat = 'Y-m-d';\r\n $due_date_days = Carbon::now()->format('Y-m-d');\r\n\r\n //return $due_date_days;\r\n\r\n $unpaid_due_installments = DB::table('installments')\r\n ->join('loans as l', 'l.id', '=', 'installments.installmentable_id')\r\n ->where('installmentable_type','App\\\\Loan')\r\n ->where('paid', 0)\r\n ->where('l.status_id', '3');\r\n\r\n\r\n if($unpaid_due_installments->count() > 0) {\r\n $dueDateTemp = array();\r\n $userTemp = array();\r\n foreach ($unpaid_due_installments->get() as $installment) {\r\n $dueDateArray = array();\r\n $dueDate = Carbon::createFromFormat('Y-m-d', $installment->due_date);\r\n array_push($dueDateArray, $dueDate->format($dateFormat));\r\n array_push($dueDateArray, $dueDate->addDays(-3)->format($dateFormat));\r\n array_push($dueDateArray, $dueDate->addDays(-4)->format($dateFormat));\r\n\r\n array_push($dueDateTemp, $dueDateArray);\r\n\r\n $hasDueDate = in_array($due_date_days, $dueDateArray);\r\n\r\n if ($hasDueDate) {\r\n $loan = Loan::where('status_id', 3)->find($installment->installmentable_id);\r\n\r\n if (!empty($loan)) {\r\n $user = User::join('companies as c', 'c.id', '=', 'users.company_id')\r\n ->select('users.id', 'c.name', 'c.affiliate')\r\n ->find($loan->user_id);\r\n\r\n array_push($userTemp, [$loan->user_id, $due_date_days, $loan->id]);\r\n\r\n if (!empty($user)) {\r\n\r\n $hasReminder = HasUserReminder::where([\r\n 'user_id' => $user->id,\r\n 'loan_id' => $loan->id,\r\n 'created_at' => $due_date_days\r\n ])->count();\r\n\r\n if ($hasReminder < 1) {\r\n HasUserReminder::insert([\r\n 'user_id' => $user->id,\r\n 'loan_id' => $loan->id,\r\n 'created_at' => $due_date_days\r\n ]);\r\n\r\n if ($user->affiliate == 1) {\r\n $configEmail = explode(\";\", config('email_reminder'));\r\n Mail::to($loan->user)\r\n ->cc($configEmail)\r\n ->queue(new InstallmentReminderRekananEmail($loan, $installment));\r\n //return view('email.installment_reminder_rekanan', compact('loan', 'installment'));\r\n }else{\r\n //return $user->id;\r\n $midtrans = new Midtrans;\r\n $currentPendingInstallment['userName'] = $user->name;\r\n $currentPendingInstallment['userEmail'] = $user->email;\r\n $currentPendingInstallment['userPhone'] = $user->mobile_phone;\r\n $currentPendingInstallment['id'] = $installment->id;\r\n $currentPendingInstallment['amount'] = intval($installment->amount);\r\n $currentPendingInstallment['tenor'] = $installment->tenor;\r\n $currentPendingInstallment['due_date'] = $installment->due_date;\r\n //$checkHasPayment = $this->checkHasPayment($currentPendingInstallment);\r\n\r\n $userVa = \"\";\r\n /*$userId = $user->id;\r\n $userVa = UserVa::getByUserId($userId)->first();\r\n\r\n if (empty($userVa)) {\r\n $vaId = UserVa::insertGetId([\r\n 'user_id' => $userId,\r\n 'va_number' => $checkHasPayment->va_numbers{0}->va_number,\r\n 'created_at' => Carbon::now()->toDateTimeString()\r\n ]);\r\n $userVa = UserVa::getByUserId($userId)->first();\r\n }*/\r\n\r\n $configEmail = explode(\";\", config('email_reminder'));\r\n Mail::to($loan->user)\r\n ->cc($configEmail)\r\n ->queue(new InstallmentReminderNonRekananEmail($loan, $installment, $userVa, $midtrans));\r\n //return view('email.installment_reminder_nonrekanan', compact('loan', 'installment', 'userVa', 'midtrans'));\r\n }\r\n }\r\n\r\n } \r\n }\r\n }\r\n }\r\n }\r\n })\r\n ->everyMinute();\r\n\r\n }", "public function run()\n {\n $conditions = array(\"Open\", \"Delivered\", \"Refund\");\n $problems = array(\n 'Fix Glass',\n 'Fix WIFI',\n 'Fix Cover',\n 'Fix Battery Problem',\n 'Fix Software Problem'\n );\n\n for($i =0; $i < 30; $i++){\n $currentDate = rand(1619292276, 1619551476);\n DB::table('tasks')->insert([\n 'registered_devices_id' => rand(1, 5),\n 'name' => $problems[rand(0,4)],\n 'condition' => rand(0,1),\n ]);\n }\n }", "private function checkTaskDueDate()\n {\n $notificationService = new NotificationService();\n\n $tasks = Task::where( 'due_date', '>', Carbon::now()->subDays(3))->get();\n\n foreach($tasks as $task){\n\n $link = url('/tasks/'.$task->id);\n $notificationService->sendNotification(\n $task->assignee_id, \n $task->account_id , \n $task->title , \n $link ,\n NotificationType::TASK_DUE_DATE_NOTIFICATION,\n array()\n );\n }\n \n }", "public function waitAll() {\r\n\t\twhile (count($this->jobs) > 0) {\r\n\t\t\t$this->waitFirst();\r\n\t\t}\r\n\t}", "public static function execute_prerequest_cronjobs()\n {\n $nearest_event = Okapi::get_var(\"cron_nearest_event\");\n if ($nearest_event + 0 <= time())\n {\n require_once \"okapi/cronjobs.php\";\n try {\n $nearest_event = CronJobController::run_jobs('pre-request');\n Okapi::set_var(\"cron_nearest_event\", $nearest_event);\n } catch (\\okapi\\cronjobs\\JobsAlreadyInProgress $e) {\n // Ignore.\n }\n }\n }", "public function DDPQueueRecordsAllProjects() \r\n\t{\r\n\t\t// Perform the seeding\r\n\t\t$recordsSeeded = DynamicDataPull::seedMrIdsAllProjects();\r\n\t\t// Set records as queued for those ready to be fetched from the source system\r\n\t\t$recordsQueued = DynamicDataPull::setQueuedFetchStatusAllProjects();\r\n\t\t// Set cron job message\r\n\t\tif ($recordsSeeded + $recordsQueued > 0) {\r\n\t\t\t$GLOBALS['redcapCronJobReturnMsg'] = \"DDP - $recordsSeeded records were seeded and $recordsQueued records were queued\";\r\n\t\t}\r\n\t}", "public function intra_day()\n {\n // set to run every 5 min and continue until que empty\n while ($this->have_mail_in_mailque()) {\n $this->process_mail_que($quiet = true);\n }\n }", "public static function processNotifications(){\n\n\t\t$jobsByLanguage = self::getAllJobsByLanguage();\n\n\t\tforeach ($jobsByLanguage as $languageId=>$jobs) {\n\n\t\t\t$countJobs = count($jobs);\n\n\t\t\t/**\n\t\t\t * @type $allUsersForLanguage User[]\n\t\t\t */\n\t\t\t$allUsersForLanguage = PullRequest::getInstance()->getUsers($languageId);\n\n\t\t\tforeach ($allUsersForLanguage as $user) {\n\t\t\t\t$emailHandler = new EmailHandler('pull_request_deferred_notification');\n\n\t\t\t\tif ($emailHandler->getTemplateState()) {\n\t\t\t\t\t$subject = $emailHandler->prepeate_subject(array(\n\t\t\t\t\t\t'[[[CountJobs]]]' => $countJobs //Count jobs\n\t\t\t\t\t));\n\t\t\t\t\t$message = $emailHandler->prepare_body(array(\n\t\t\t\t\t\t'[[[FullName]]]' => $user->getFullName(), //Name\n\t\t\t\t\t\t'[[[CountJobs]]]' => $countJobs, //Count jobs\n\t\t\t\t\t));\n\n\t\t\t\t\tYii::app()->amazonSes->sendMessage($user->email, $subject, $message);\n\t\t\t\t\tsleep(1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//remove jobs from notification list\n\t\t\tself::removeJobs($jobs);\n\t\t}\n\t}", "public function run()\n {\n $tasks = array();\n $tasks[] = [\n \t\t\t'description' => 'Wash car',\n \t\t\t'day' => 'monday',\n \t\t\t'finished' => 0\n ];\n $tasks[] = [\n \t\t\t'description' => 'Pay bills',\n \t\t\t'day' => 'tuesday',\n \t\t\t'finished' => 0\n ];\n $tasks[] = [\n \t\t\t'description' => 'Do homework',\n \t\t\t'day' => 'wednesday',\n \t\t\t'finished' => 0\n ];\n $tasks[] = [\n \t\t\t'description' => 'Do laundry',\n \t\t\t'day' => 'thursday',\n \t\t\t'finished' => 0\n ];\n $tasks[] = [\n \t\t\t'description' => 'Take kids to the beach',\n \t\t\t'day' => 'saturday',\n \t\t\t'finished' => 0\n ];\n\n foreach ($tasks as $task) {\n\t DB::table('tasks')->insert($task);\t\n }\n }", "public function run() {\n $now = time();\n $stop_after = $now + $this->timeLimit;\n $expire_up_to = (new \\DateTime(\"@$now\"))\n ->modify($this->expireUpToStr)\n ->getTimestamp();\n $last_sid = 0;\n while (($still_time = time() < $stop_after) && ($last_sid = $this->expireSubmissionBatch($expire_up_to, $last_sid))) {\n watchdog('campaignion_expiry', 'Expired webform submissions up to sid=@last_sid', ['@last_sid' => $last_sid], WATCHDOG_DEBUG);\n }\n if ($still_time) {\n watchdog('campaignion_expiry', 'No more submissions to anonymize for now.', [], WATCHDOG_DEBUG);\n $args = ['@expire_up_to' => strftime('%d/%m/%Y %H:%M:%S', $expire_up_to)];\n watchdog('campaignion_expiry', 'Expired all submissions up to @expire_up_to', $args, WATCHDOG_INFO);\n }\n else {\n watchdog('campaignion_expiry', 'Out of time to anonymize submissions in this cron-run.', [], WATCHDOG_INFO);\n }\n }", "public function cron_jobs() {\n\n // Verify if the app is enabled\n if ( get_option('app_facebook_ads_enable') ) {\n\n foreach (glob(MIDRUB_BASE_USER_APPS_FACEBOOK_ADS . 'automatizations/*', GLOB_ONLYDIR) as $automatization_dir) {\n\n $automatization = trim(basename($automatization_dir) . PHP_EOL);\n \n // Create an array\n $array = array(\n 'MidrubBase',\n 'User',\n 'Apps',\n 'Collection',\n 'Facebook_ads',\n 'Automatizations',\n ucfirst($automatization),\n 'Main'\n );\n \n // Implode the array above\n $cl = implode('\\\\', $array);\n \n // Call cron jobs\n (new $cl())->cron_jobs();\n \n }\n\n }\n \n }", "public function work()\n {\n $this->queue->watch($this->queueName)->ignore('default');\n\n\n echo \"Working next job in the 'emails\" . ZEND_ENV . \"' queue\" . PHP_EOL;\n\n $job = $this->queue->reserve();\n echo \"Email job received! Job Id is \" . $job->getId() . PHP_EOL;\n\n $email = json_decode($job->getData(), true);\n\n if (!isset($email['message']) || !isset($email['templateName']) || !isset($email['templateContent'])) {\n // Email Incomplete\n echo \"Email incomplete!\" . PHP_EOL;\n\n $this->queue->delete($job);\n }\n\n if ($email['test'] === true) {\n $mandrill = new \\Mandrill(getenv('MANDRILL_TEST'));\n } else {\n $mandrill = new \\Mandrill(getenv('MANDRILL'));\n }\n\n try {\n $mandrill->messages->sendTemplate($email['templateName'], $email['templateContent'], $email['message']);\n echo \"Email sent!\" . PHP_EOL;\n $this->queue->delete($job);\n } catch (\\Mandrill_Error $e) {\n echo \"Error!\" . PHP_EOL;\n\n $jobsStats = $this->queue->statsJob($job);\n\n if ($jobsStats->releases > $this->tries) {\n echo \"Burrying job!\" . PHP_EOL;\n $this->buryJob($job, $this->queue);\n } else {\n echo \"retrying in 60 seconds!\" . PHP_EOL;\n $this->queue->release($job, PheanstalkInterface::DEFAULT_PRIORITY, 60);\n }\n\n }\n\n }", "public function runTimedChecks()\n {\n $this->checkAutomated();\n $this->checkDebt();\n }", "function run_jobs($jobs)\n{\n global $bb_cfg, $tr_cfg, $datastore;\n\n define('IN_CRON', true);\n\n $sql = \"SELECT cron_script FROM \" . BB_CRON . \" WHERE cron_id IN ($jobs)\";\n if (!$result = DB()->sql_query($sql)) {\n bb_die('Could not obtain cron script');\n }\n\n while ($row = DB()->sql_fetchrow($result)) {\n $job = $row['cron_script'];\n $job_script = INC_DIR . 'cron/jobs/' . $job;\n require($job_script);\n }\n DB()->query(\"\n\t\t\tUPDATE \" . BB_CRON . \" SET\n\t\t\t\tlast_run = NOW(),\n\t\t\t\trun_counter = run_counter + 1,\n\t\t\t\tnext_run =\n\t\t\tCASE\n\t\t\t\tWHEN schedule = 'hourly' THEN\n\t\t\t\t\tDATE_ADD(NOW(), INTERVAL 1 HOUR)\n\t\t\t\tWHEN schedule = 'daily' THEN\n\t\t\t\t\tDATE_ADD(DATE_ADD(CURDATE(), INTERVAL 1 DAY), INTERVAL TIME_TO_SEC(run_time) SECOND)\n\t\t\t\tWHEN schedule = 'weekly' THEN\n\t\t\t\t\tDATE_ADD(\n\t\t\t\t\t\tDATE_ADD(DATE_SUB(CURDATE(), INTERVAL WEEKDAY(NOW()) DAY), INTERVAL 7 DAY),\n\t\t\t\t\tINTERVAL CONCAT(ROUND(run_day-1), ' ', run_time) DAY_SECOND)\n\t\t\t\tWHEN schedule = 'monthly' THEN\n\t\t\t\t\tDATE_ADD(\n\t\t\t\t\t\tDATE_ADD(DATE_SUB(CURDATE(), INTERVAL DAYOFMONTH(NOW())-1 DAY), INTERVAL 1 MONTH),\n\t\t\t\t\tINTERVAL CONCAT(ROUND(run_day-1), ' ', run_time) DAY_SECOND)\n\t\t\t\tELSE\n\t\t\t\t\tDATE_ADD(NOW(), INTERVAL TIME_TO_SEC(run_interval) SECOND)\n\t\t\tEND\n\t\t\tWHERE cron_id IN ($jobs)\n\t\t\");\n sleep(3);\n return;\n}", "public function cron_functions() {\r\n do_action( 'pta_sus_hourly_cron' );\r\n\r\n // Run our reminders email check\r\n $this->emails->send_reminders();\r\n\r\n // If automatic clearing of expired signups is enabled, run the check\r\n if($this->main_options['clear_expired_signups']) {\r\n $this->data = new PTA_SUS_Data();\r\n $results = $this->data->delete_expired_signups();\r\n if($results && $this->main_options['enable_cron_notifications']) {\r\n $to = get_bloginfo( 'admin_email' );\r\n $subject = __(\"Volunteer Signup Housekeeping Completed!\", 'pta_volunteer_sus');\r\n $message = __(\"Volunteer signup sheet CRON job has been completed.\", 'pta_volunteer_sus').\"\\n\\n\" . \r\n sprintf(__(\"%d expired signups were deleted.\", 'pta_volunteer_sus'), (int)$results) . \"\\n\\n\";\r\n wp_mail($to, $subject, $message); \r\n }\r\n }\r\n }", "public function run()\n {\n $plans = \\App\\Plan::get();\n $goalCategories = \\App\\GoalCategory::get();\n $goalStatuses = \\App\\GoalStatus::get();\n\n $now = \\Carbon\\Carbon::now();\n\n for ($i=0; $i < $plans->count()*20; $i++) { \n $now = $now->subDays(3);\n\n factory(\\App\\Goal::class, 1)->create()->each(function ($f) use(&$plans, &$goalCategories, &$goalStatuses, &$now) {\n $f->plan()->associate($plans->random());\n $f->goalCategory()->associate($goalCategories->random());\n $f->goalStatus()->associate($goalStatuses->random());\n\n if ($f->goalStatus->name === 'Avklarat') {\n $f->finished_at = $now;\n }\n\n $f->save();\n });\n }\n }", "public function do_cron(){\n if( !static::SKIP_CRON ){\n foreach( $this->get_results() as $result ){\n $this->parse_row($result);\n }\n }\n }", "public function executeJobs()\n\t{\n\t\t//get jobs to execute\n\t\t$jobController = JobController::create();\n\t\t$jobs = $jobController->getAndRemoveJobs();\n\n\t\tforeach($jobs as $job)\n\t\t{\n\t\t\t$this->executeJob($job);\n\t\t}\n\t}", "public function getAfterJobs();", "public function run()\n {\n $dailyJobs = MigrationDailyJob::get();\n\n foreach ($dailyJobs as $dailyJob) {\n DailyJob::create([\n 'slug' => $dailyJob->slug,\n 'user_id' => $dailyJob->user_id,\n 'title' => $dailyJob->title,\n 'description' => $dailyJob->description,\n 'date' => $dailyJob->date,\n 'created_at' => $dailyJob->created_at,\n 'updated_at' => $dailyJob->updated_at,\n 'deleted_at' => $dailyJob->deleted_at,\n ]);\n }\n }", "private function checkExpiringTasks()\n {\n $expiringUserTasks = UserTask::where('status', UserTask::STATUS_ASSIGNED)\n ->where('deadline', Carbon::now()->format('Y-m-d'))\n ->get();\n\n $this->info('[' . Carbon::now()->format('Y-m-d H:i:s') . ']: Found ' . $expiringUserTasks->count() . ' expiring tasks.');\n\n foreach ($expiringUserTasks as $expiringUserTask) {\n $userNotification = $this->notificationService->addNotification(\n $expiringUserTask->assigned_user_id,\n TranslationCode::NOTIFICATION_TASK_EXPIRING,\n 'userTask',\n $expiringUserTask->id\n );\n\n $this->notificationService->sendNotification($userNotification);\n }\n }", "public function execute()\n {\n $db = $this->contanier->get('db');\n\n $sql = \"SELECT `employee_id` AS `id` FROM `employee_status` WHERE `finish` < NOW()\";\n $stmt = $db->query($sql);\n $result = $stmt->fetchAll();\n\n if (!$result) {\n return;\n }\n\n foreach ($result as $busyEmployee) {\n $db->delete('employee_status', ['employee_id' => $busyEmployee['id']]);\n }\n }", "public function execute() {\n $statuses = []; \n foreach ($this->jobs as $jobname => $jobconf) {\n $data = [];\n $data['Name'] = $jobname;\n $data['Next'] = $this->getNext($jobconf);\n $reports = ReportsManager::getAllExistingReportsFromRootDir($jobconf->rootDir.DS.$jobname);\n if (count($reports)) {\n $last = array_pop($reports);\n $data['Since'] = $this->getTimeSinceLastBackup($last);\n $data['Delta'] = $this->getSizeFilesTransfered($last);\n $data['Size'] = $this->getTotalSizeLastBackup($last);\n }\n else {\n $data['Since'] = '';\n $data['Delta'] = '';\n $data['Size'] = '';\n }\n $statuses[] = $data;\n }\n if (count($statuses)) {\n echo (new ArrayToTextTable($statuses))->render();\n }\n else {\n echo \"\\nNo configured backups found.\";\n }\n echo \"\\n\";\n }", "public function run()\n {\n $task = new Task();\n $task->description = 'To do';\n $task->status = true;\n $task->save();\n\n $task = new Task();\n $task->description = 'In process';\n $task->status = false;\n $task->save();\n\n $task = new Task();\n $task->description = 'Completed';\n $task->status = true;\n $task->save();\n }", "public function run()\n {\n //\n $date = date(\"Y-m-d H:i:s\");\n\n \\DB::table('jobs')->delete();\n\n for ($i = 1; $i < 26; $i++) {\n for ($j = 1; $j < 5; $j++) {\n \\DB::table('jobs')->insert(\n array(\n 'name' => \"Job_\" . $i . \"_\" . $j,\n 'album_id' => $i,\n 'file_location' => \"file_\" . $i . \"_\" . $j . \".zip\",\n 'created_at' => $date,\n 'updated_at' => NULL,\n 'deleted_at' => NULL,\n )\n );\n }\n }\n\n\n }", "public function trigger_all()\n\t{\n\t\tif ( !$this->is_enabled() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t$this->setup_locale();\n\n\t\t$items = $this->get_data();\n\t\tforeach ( $items as $item ) {\n\n\t\t\t$this->recipient = $item['recipient'];\n\n\t\t\t// DEV: Sends email to dev account\n\t\t\tif ( self::IS_TEST_MODE ) {\n\t\t\t\t$this->recipient = self::DEV_EMAIL;\n\t\t\t}\n\n\t\t\tif ( $this->get_recipient() ) {\n\t\t\t\t// Fill data\n\t\t\t\t$this->args = $item;\n\t\t\t\t$this->placeholders['{YEAR}'] = $this->args['year'];\n\t\t\t\t$this->placeholders['{MONEY_RAISED}'] = $this->args['money_raised'];\n\t\t\t\t$this->placeholders['{MONEY_GOAL}'] = $this->args['money_goal'];\n\n\t\t\t\t$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );\n\t\t\t}\n\n\t\t\t// DEV: Sends only one email for testing purposes\n\t\t\tif ( self::IS_TEST_MODE ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t$this->restore_locale();\n\t}" ]
[ "0.62653005", "0.62254333", "0.62248516", "0.61877435", "0.61342317", "0.60955364", "0.606937", "0.60398865", "0.6013766", "0.5994489", "0.59914", "0.5983933", "0.5981765", "0.5980087", "0.5951756", "0.59386224", "0.5925003", "0.58933043", "0.5874184", "0.5823198", "0.5821375", "0.5807984", "0.5775323", "0.5751332", "0.57489187", "0.5723842", "0.56987673", "0.56894976", "0.5670766", "0.56703466" ]
0.7970121
0
Register the product feature and add it to enabled producttype addons
function add_feature_support_to_product_types() { // Register the product feature $slug = 'membership-hierarchy'; $description = __( 'Allows you to set a Parent for a given membership, to enable membership hierarchy permissions.', 'LION' ); it_exchange_register_product_feature( $slug, $description ); it_exchange_add_feature_support_to_product_type( 'membership-hierarchy', 'membership-product-type' ); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function add_feature_support_to_product_types() {\n\t\t// Register the product feature\n\t\t$slug = 'featured-video';\n\t\t$description = __( \"This displays a custom pricing options for all Exchange product types\", 'LION' );\n\t\tit_exchange_register_product_feature( $slug, $description );\n\n\t\t// Add it to all enabled product-type addons\n\t\t$products = it_exchange_get_enabled_addons( array( 'category' => 'product-type' ) );\n\t\tforeach( $products as $key => $params ) {\n\t\t\tit_exchange_add_feature_support_to_product_type( 'featured-video', $params['slug'] );\n\t\t}\n\t}", "function add_feature_support_to_product_types() {\n\t\t// Register the product feature\n\t\t$slug = 'membership-welcome-message';\n\t\t$description = __( \"This displays a custom welcome message for each Membership type on the member's dashboard\", 'LION' );\n\t\tit_exchange_register_product_feature( $slug, $description );\n\n\t\tit_exchange_add_feature_support_to_product_type( 'membership-welcome-message', 'membership-product-type' );\n\t}", "public function register()\n {\n add_filter('woocommerce_product_data_tabs', array($this, 'show_attributes_data_panel'), 10, 1);\n // Loads the script for adding extra options to the product tabs\n add_action('admin_footer', array($this, 'default_tab_options_combo_product'));\n // Add extra field for the Number of Options for a variation\n add_action('woocommerce_variation_options_pricing', array($this, 'add_custom_field_to_variations'), 10, 3);\n // Saves the custom field value onto the variation post Meta\n add_action('woocommerce_save_product_variation', array($this, 'save_custom_field_variations'), 10, 2);\n // Loads script for the Combo Product tab on the product\n add_action('woocommerce_product_data_panels', array($this, 'combo_product_tab_options'));\n // Saves the tag used for the product onto the product meta\n add_action('woocommerce_process_product_meta', array($this, 'save_combo_product_options'));\n }", "function save_feature_on_product_save() {\n\t\t// Abort if we can't determine a product type\n\t\tif ( ! $product_type = it_exchange_get_product_type() )\n\t\t\treturn;\n\n\t\t// Abort if we don't have a product ID\n\t\t$product_id = empty( $_POST['ID'] ) ? false : $_POST['ID'];\n\t\tif ( ! $product_id )\n\t\t\treturn;\n\n\t\t// Abort if this product type doesn't support this feature\n\t\tif ( ! it_exchange_product_type_supports_feature( $product_type, 'membership-hierarchy' ) )\n\t\t\treturn;\n\n\t\t$child_ids = empty( $_POST['it-exchange-membership-child-ids'] ) ? array() : $_POST['it-exchange-membership-child-ids'];\n\t\t$parent_ids = empty( $_POST['it-exchange-membership-parent-ids'] ) ? array() : $_POST['it-exchange-membership-parent-ids'];\n\n\t\tit_exchange_update_product_feature( $product_id, 'membership-hierarchy', $child_ids, array( 'setting' => 'children' ) );\n\t\tit_exchange_update_product_feature( $product_id, 'membership-hierarchy', $parent_ids, array( 'setting' => 'parents' ) );\n\t}", "public function pc_register_product_type() {\n\t\trequire_once( pc_pcalculator_invoices_dir.'/Include/pc-product-type.php' );\t\n\t}", "function wp_custom_post_type_product() {\n\t$support = array(\n\t\t'title',\n\t\t'custom-fields',\n\t\t'editor',\n\t\t'thumbnail',\n\t);\n\t$labels = array(\n\t\t'name' => _x('Produk', 'plural'),\n\t\t'singular_name' => _x('Produk', 'singular'),\n\t\t'add_new' => _x('Tambah Produk', 'add new')\n\t);\n\t$args = array(\n\t\t'supports' => $support,\n\t\t'labels' => $labels,\n\t\t'description' => 'Add your product to be displayed on Product page',\n\t\t'public' => true,\n\t\t'query_var' => true,\n\t\t'rewrite' => array('slug' => 'product'),\n\t\t'has_archive' => true,\n\t\t'publicly_queryable' => true,\n\t);\n\tregister_post_type('Products', $args);\n}", "function register_webinarjam_product_type() {\n\n if ( class_exists('WC_Product') ) {\n\t require_once plugin_dir_path( __FILE__ ) . 'includes/wc-product-webinarjam.php';\n\n\t // functions to work with orders, extract data from webinars etc.\n\n\t require_once plugin_dir_path( __FILE__ ) . 'includes/utilities.php';\n\n\t // add metabox to Order's page.\n\t require_once plugin_dir_path( __FILE__ ) . 'includes/order-webinarjam-metabox.php';\n\n\t require_once plugin_dir_path( __FILE__ ) . 'includes/webinarjam-shortcodes.php';\n }\n}", "function shop_register_product() {\n // Register shop_product\n register_post_type( 'shop_product',\n array(\n 'label' => 'Produto',\n 'public' => true,\n 'has_archive' => true,\n 'show_in_rest' => true,\n )\n );\n}", "function save_feature_on_product_save() {\n\t\t// Abort if we can't determine a product type\n\t\tif ( ! $product_type = it_exchange_get_product_type() )\n\t\t\treturn;\n\n\t\t// Abort if we don't have a product ID\n\t\t$product_id = empty( $_POST['ID'] ) ? false : $_POST['ID'];\n\t\tif ( ! $product_id )\n\t\t\treturn;\n\n\t\t// Abort if this product type doesn't support this feature\n\t\tif ( ! it_exchange_product_type_supports_feature( $product_type, 'featured-video' ) )\n\t\t\treturn;\n\n\t\t// Abort if key for feature option isn't set in POST data\n\t\tif ( ! isset( $_POST['it-exchange-product-featured-video'] ) )\n\t\t\treturn;\n\n\t\t// Get new value from post\n\t\t$new_value = $_POST['it-exchange-product-featured-video'];\n\n\t\t// Save new value\n\t\tit_exchange_update_product_feature( $product_id, 'featured-video', $new_value );\n\t}", "function kia_save_custom_addons_fields( $product ) {\n\n\t// Layout.\n\tif ( ! empty( $_POST[ 'global_addons' ] ) ) {\n\n\t\t$meta = array_map( 'intval', (array) $_POST[ 'global_addons' ] );\n\n\t\t$product->add_meta_data( '_global_addons', $meta, true );\n\t}\n\n}", "public function enable_feature($id)\n {\n $item = array(\n 'p_feature' => 'YES'\n );\n $this->db->WHERE('id',$id)->update('products',$item);\n }", "function register_tour_product_type() {\n\n\t/**\n\t * This should be in its own separate file.\n\t */\n\tclass WC_Product_Tour extends WC_Product {\n\n\t\tpublic function __construct( $product ) {\n\n\t\t\t$this->product_type = 'tour';\n\t\t\t$this->supports[] = 'ajax_add_to_cart';\n\t\t\t\n\t\t\tparent::__construct( $product );\n\n\t\t}\n\n\t\t/**\n\t\t* Get the add to url used mainly in loops.\n\t\t*\n\t\t* @return string\n\t\t*/\n\t\tpublic function add_to_cart_url() {\n\t\t\t$url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg( 'added-to-cart', add_query_arg( 'add-to-cart', $this->id ) ) : get_permalink( $this->id );\n\n\t\t\treturn apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this );\n\t\t}\n\n\t\t/**\n\t\t* Get the add to cart button text.\n\t\t*\n\t\t* @return string\n\t\t*/\n\t\tpublic function add_to_cart_text() {\n\t\t\t$text = $this->is_purchasable() && $this->is_in_stock() ? __( 'Add to cart', 'woocommerce' ) : __( 'Read more', 'woocommerce' );\n\n\t\t\treturn apply_filters( 'woocommerce_product_add_to_cart_text', $text, $this );\n\t\t}\n\n\t}\n\n}", "public function install(){\n // del admin panel que vayan al modulo preciso\n return parent::install() && \n $this->registerHook(\"displayTop\") && \n $this->registerHook('displayProductTabContent') && \n $this->registerHook('displayProductTab') &&\n $this->registerHook('displayNav') &&\n $this->registerHook('displayAdminProductExtra') && \n $this->registerHook('actionProductUpdate') &&\n $this->registerHook('leftColumn') && \n $this->registerHook('rightColumn');\n $this->installTab('AdminCatalog', 'AdminListproducts', 'listproducts');\n Configuration::updateValue('LISTPRODUCTS', \"listproducts\");\n return true; \n }", "public function add_product() {\n \n }", "function add_product_fields()\n {\n $meta_box = new TTC_Product_Fields();\n $meta_box->register();\n }", "private function product_type_register(){\n\t\t\n\t\t$fly_by_class = '\n\t\t\n\t\tclass WC_Product_' . ucwords($this->product_type) . ' extends \\WC_Product {\n\t\t\t\n\t\t\tpublic function __construct( $product ) {\n\t\t\t\t\n\t\t\t\t$this->product_type = \"' . $this->product_type . '\";\n\t\t\t\tparent::__construct( $product );\n\t\t\t\t\n\t\t\t}\t\n\t\t}\n\t\t';\n\t\t\n\t\teval($fly_by_class);\n\n\t}", "function save_feature( $product_id, $new_value, $options=array() ) {\n\t\tif ( ! it_exchange_get_product( $product_id ) )\n\t\t\treturn false;\n\t\tupdate_post_meta( $product_id, '_it-exchange-product-featured-video', $new_value );\n\t}", "function kia_add_global_product_addons( $product_addons, $post_id ) {\n\n\tglobal $product;\n\n\tif( ! is_admin() && $product instanceof WC_Product && $post_id === $product->get_id() ) {\n\n\t\t$meta = $product->get_meta( '_global_addons', true );\n\n\t\tif( ! empty( $meta ) ) {\n\n\t\t\t$args = array(\n\t\t\t\t'posts_per_page' => -1,\n\t\t\t\t'post_type' => 'global_product_addon',\n\t\t\t\t'post_status' => 'publish',\n\t\t\t\t'suppress_filters' => true,\n\t\t\t\t'include' => $meta\n\t\t\t);\n\n\t\t\t$global_addons = get_posts( $args );\n\n\t\t\tif ( $global_addons ) {\n\t\t\t\t$new_addons = array();\n\t\t\t\tforeach ( $global_addons as $global_addon ) {\n\t\t\t\t\t \n\t\t\t\t\t$new_addon = apply_filters( 'get_product_addons_fields', array_filter( (array) get_post_meta( $global_addon->ID, '_product_addons', true ) ), $global_addon->ID );\n\t\t\t\t\t$new_addons = $new_addons + $new_addon;\n\t\t\t\t}\n\n\t\t\t\t$product_addons = array_merge( $new_addons, $product_addons );\n\n\t\t\t}\n\n\t\t}\n\t}\n\n\treturn $product_addons;\n}", "function tx_register_fp_2x3_feature()\n{\n register_widget('TX_FP_2x3_Feature');\n}", "public function addProduct()\r\n {\r\n }", "function add_webinarjam_product( $types = array() ) {\n\t$types['webinarjam'] = __( 'WebinarJam' );\n\n\treturn $types;\n\n}", "public function install()\n {\n include_once($this->local_path.'sql/install.php');\n if (!parent::install()) {\n return false;\n }\n if (!$this->registerHook('displayProductExtraContent')) {\n return false;\n }\n if (!$this->registerHook('displayHeader')) {\n return false;\n }\n if (!$this->registerHook('displayProductListReviews')) {\n return false;\n }\n if (!$this->registerHook('displayAdminProductsExtra')) {\n return false;\n }\n if (!$this->registerHook('actionProductSave')) {\n return false;\n }\n // After register all the hook, 3 value will be add to the database\n // to enable the review form.\n Configuration::updateValue('SIMPLECOMMENTS_GRADES', '1');\n Configuration::updateValue('SIMPLECOMMENTS_COMMENTS', '1');\n Configuration::updateValue('SIMPLECOMMENTS_REVIEWS', '1');\n return true;\n }", "function product_has_feature( $result, $product_id, $options=array() ) {\n\t\t$defaults['setting'] = 'enabled';\n\t\t$options = ITUtility::merge_defaults( $options, $defaults );\n\n\t\t// Does this product type support this feature?\n\t\tif ( false === $this->product_supports_feature( false, $product_id, $options ) )\n\t\t\treturn false;\n\n\t\t// If it does support, does it have it?\n\t\treturn (boolean) $this->get_feature( false, $product_id, $options );\n\t}", "function product_supports_feature( $result, $product_id, $options=array() ) {\n\t\t// Does this product type support this feature?\n\t\t$product_type = it_exchange_get_product_type( $product_id );\n\t\tif ( ! it_exchange_product_type_supports_feature( $product_type, 'membership-hierarchy' ) )\n\t\t\treturn false;\n\n\t\treturn true;\n\t}", "function cw_post_type_product() {\n $supports = array(\n 'title', // post title\n 'editor', // post content\n 'author', // post author\n 'thumbnail', // featured images\n 'excerpt', // post excerpt\n 'custom-fields', // custom fields\n 'comments', // post comments\n 'revisions', // post revisions\n 'post-formats', // post formats\n );\n $labels = array(\n 'name' => _x('product', 'plural'),\n 'singular_name' => _x('product', 'singular'),\n 'menu_name' => _x('product', 'admin menu'),\n 'name_admin_bar' => _x('product', 'admin bar'),\n 'add_new' => _x('Add New', 'add new'),\n 'add_new_item' => __('Add New product'),\n 'new_item' => __('New product'),\n 'edit_item' => __('Edit product'),\n 'view_item' => __('View product'),\n 'all_items' => __('All product'),\n 'search_items' => __('Search product'),\n 'not_found' => __('No product found.'),\n );\n $args = array(\n 'supports' => $supports,\n 'labels' => $labels,\n 'public' => true,\n 'query_var' => true,\n 'rewrite' => array('slug' => 'product'),\n 'has_archive' => true,\n 'taxonomies' => array('product_category'),\n 'hierarchical' => false,\n 'menu_icon' => 'dashicons-admin-home',\n );\n\n register_post_type('product', $args);\n }", "public function register() {\n\t\tadd_action( 'wp_ajax_wpmdb_plugin_compatibility', array( $this, 'ajax_plugin_compatibility' ) );\n\t\tadd_action( 'admin_init', array( $this, 'muplugin_version_check' ), 1 );\n\t\tadd_action( 'wpmdb_notices', array( $this, 'template_muplugin_update_fail' ) );\n\t\t//Fired in the register_deactivation_hook() call in both the pro and non-pro plugins\n\t\tadd_action( 'wp_migrate_db_remove_compatibility_plugin', array( $this, 'remove_muplugin_on_deactivation' ) );\n\t}", "public function install()\n {\n Configuration::updateValue('INFORMACIOPRODUCTO_LIVE_MODE', false);\n\n return parent::install() &&\n $this->registerHook('header') &&\n $this->registerHook('backOfficeHeader')&&\n $this->registerHook('displayAdminProductsMainStepLeftColumnMiddle') &&\n $this->registerHook('displayProductAdditionalInfo');\n }", "public function install() {\n if (Shop::isFeatureActive())\n Shop::setContext(Shop::CONTEXT_ALL);\n\n return parent::install()\n && $this->registerHook('displayHeader') // base script\n && $this->registerHook('displayLeftColumnProduct') // product script\n // && $this->registerHook('cart') // addtocart script\n && $this->registerHook('displayShoppingCart') // bag script\n // && $this->registerHook('orderConfirmation') // buy script\n && $this->registerHook('displayOrderConfirmation') // buy script\n && Configuration::updateValue('MYMODULE_NAME', 'minewhat');\n }", "public function enableProduct($id)\r\n {\r\n }", "function register_capability() {\n\n\t$labels = array(\n\t\t'name' => 'Capabilities',\n\t\t'singular_name' => 'Capability',\n\t\t'menu_name' => 'Capabilities',\n\t\t'name_admin_bar' => 'Capability',\n\t\t'archives' => 'Capability Archives',\n\t\t'attributes' => 'Item Attributes',\n\t\t'parent_item_colon' => 'Parent Item:',\n\t\t'all_items' => 'All Items',\n\t\t'add_new_item' => 'Add New Item',\n\t\t'add_new' => 'Add New',\n\t\t'new_item' => 'New Item',\n\t\t'edit_item' => 'Edit Item',\n\t\t'update_item' => 'Update Item',\n\t\t'view_item' => 'View Item',\n\t\t'view_items' => 'View Items',\n\t\t'search_items' => 'Search Item',\n\t\t'not_found' => 'Not found',\n\t\t'not_found_in_trash' => 'Not found in Trash',\n\t\t'featured_image' => 'Featured Image',\n\t\t'set_featured_image' => 'Set featured image',\n\t\t'remove_featured_image' => 'Remove featured image',\n\t\t'use_featured_image' => 'Use as featured image',\n\t\t'insert_into_item' => 'Insert into item',\n\t\t'uploaded_to_this_item' => 'Uploaded to this item',\n\t\t'items_list' => 'Items list',\n\t\t'items_list_navigation' => 'Items list navigation',\n\t\t'filter_items_list' => 'Filter items list',\n\t);\n\t$args = array(\n\t\t'label' => 'Capability',\n\t\t'description' => 'Post Type Description',\n\t\t'labels' => $labels,\n\t\t'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),\n\t\t'taxonomies' => array( 'capability_category' ),\n\t\t'hierarchical' => false,\n\t\t'public' => true,\n\t\t'show_ui' => true,\n\t\t'show_in_menu' => true,\n\t\t'menu_position' => 5,\n\t\t'show_in_admin_bar' => true,\n\t\t'show_in_nav_menus' => true,\n\t\t'can_export' => true,\n\t\t'has_archive' => true,\n\t\t'exclude_from_search' => false,\n\t\t'publicly_queryable' => true,\n\t\t'capability_type' => 'post',\n\t);\n\tregister_post_type( 'capabilities', $args );\n}" ]
[ "0.79884714", "0.7250908", "0.72440386", "0.66008955", "0.64226687", "0.6384139", "0.63414013", "0.6288835", "0.6282158", "0.62569237", "0.6241092", "0.6215454", "0.61828715", "0.6147372", "0.6102705", "0.60993904", "0.60198665", "0.6016605", "0.6001956", "0.5979254", "0.5920621", "0.5904646", "0.59010774", "0.58983946", "0.58964205", "0.5896172", "0.5857337", "0.5847156", "0.5806973", "0.57877904" ]
0.73767966
1