id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
40,500
claroline/Distribution
main/core/Manager/Resource/ResourceRestrictionsManager.php
ResourceRestrictionsManager.getErrors
public function getErrors(ResourceNode $resourceNode, array $userRoles): array { if (!$this->isGranted($resourceNode, $userRoles)) { // return restrictions details $errors = [ 'noRights' => !$this->hasRights($resourceNode, $userRoles), 'deleted' => !$resourceNode->isActive(), 'notPublished' => !$resourceNode->isPublished(), ]; // optional restrictions // we return them only if they are enabled if (!empty($resourceNode->getAccessCode())) { $errors['locked'] = !$this->isUnlocked($resourceNode); } if (!empty($resourceNode->getAccessibleFrom()) || !empty($resourceNode->getAccessibleUntil())) { $errors['notStarted'] = !$this->isStarted($resourceNode); $errors['startDate'] = $resourceNode->getAccessibleFrom() ? $resourceNode->getAccessibleFrom()->format('d/m/Y') : null; $errors['ended'] = $this->isEnded($resourceNode); } if (!empty($resourceNode->getAllowedIps())) { $errors['invalidLocation'] = !$this->isIpAuthorized($resourceNode); } return $errors; } return []; }
php
public function getErrors(ResourceNode $resourceNode, array $userRoles): array { if (!$this->isGranted($resourceNode, $userRoles)) { // return restrictions details $errors = [ 'noRights' => !$this->hasRights($resourceNode, $userRoles), 'deleted' => !$resourceNode->isActive(), 'notPublished' => !$resourceNode->isPublished(), ]; // optional restrictions // we return them only if they are enabled if (!empty($resourceNode->getAccessCode())) { $errors['locked'] = !$this->isUnlocked($resourceNode); } if (!empty($resourceNode->getAccessibleFrom()) || !empty($resourceNode->getAccessibleUntil())) { $errors['notStarted'] = !$this->isStarted($resourceNode); $errors['startDate'] = $resourceNode->getAccessibleFrom() ? $resourceNode->getAccessibleFrom()->format('d/m/Y') : null; $errors['ended'] = $this->isEnded($resourceNode); } if (!empty($resourceNode->getAllowedIps())) { $errors['invalidLocation'] = !$this->isIpAuthorized($resourceNode); } return $errors; } return []; }
[ "public", "function", "getErrors", "(", "ResourceNode", "$", "resourceNode", ",", "array", "$", "userRoles", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isGranted", "(", "$", "resourceNode", ",", "$", "userRoles", ")", ")", "{", "// retur...
Gets the list of access error for a resource and a user roles. @param ResourceNode $resourceNode @param array $userRoles @return array
[ "Gets", "the", "list", "of", "access", "error", "for", "a", "resource", "and", "a", "user", "roles", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceRestrictionsManager.php#L79-L111
40,501
claroline/Distribution
main/core/Manager/Resource/ResourceRestrictionsManager.php
ResourceRestrictionsManager.hasRights
public function hasRights(ResourceNode $resourceNode, array $userRoles): bool { $isAdmin = false; if ($workspace = $resourceNode->getWorkspace()) { $isAdmin = $this->security->isGranted('administrate', $workspace); } return 0 !== $this->rightsManager->getMaximumRights($userRoles, $resourceNode) || $isAdmin; }
php
public function hasRights(ResourceNode $resourceNode, array $userRoles): bool { $isAdmin = false; if ($workspace = $resourceNode->getWorkspace()) { $isAdmin = $this->security->isGranted('administrate', $workspace); } return 0 !== $this->rightsManager->getMaximumRights($userRoles, $resourceNode) || $isAdmin; }
[ "public", "function", "hasRights", "(", "ResourceNode", "$", "resourceNode", ",", "array", "$", "userRoles", ")", ":", "bool", "{", "$", "isAdmin", "=", "false", ";", "if", "(", "$", "workspace", "=", "$", "resourceNode", "->", "getWorkspace", "(", ")", ...
Checks if a user has at least the right to access to one of the resource action. @param ResourceNode $resourceNode @param Role[] $userRoles @return bool
[ "Checks", "if", "a", "user", "has", "at", "least", "the", "right", "to", "access", "to", "one", "of", "the", "resource", "action", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceRestrictionsManager.php#L121-L130
40,502
claroline/Distribution
main/core/Manager/Resource/ResourceRestrictionsManager.php
ResourceRestrictionsManager.isStarted
public function isStarted(ResourceNode $resourceNode): bool { return empty($resourceNode->getAccessibleFrom()) || $resourceNode->getAccessibleFrom() <= new \DateTime(); }
php
public function isStarted(ResourceNode $resourceNode): bool { return empty($resourceNode->getAccessibleFrom()) || $resourceNode->getAccessibleFrom() <= new \DateTime(); }
[ "public", "function", "isStarted", "(", "ResourceNode", "$", "resourceNode", ")", ":", "bool", "{", "return", "empty", "(", "$", "resourceNode", "->", "getAccessibleFrom", "(", ")", ")", "||", "$", "resourceNode", "->", "getAccessibleFrom", "(", ")", "<=", "...
Checks if the access period of the resource is started. @param ResourceNode $resourceNode @return bool
[ "Checks", "if", "the", "access", "period", "of", "the", "resource", "is", "started", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceRestrictionsManager.php#L139-L142
40,503
claroline/Distribution
main/core/Manager/Resource/ResourceRestrictionsManager.php
ResourceRestrictionsManager.isEnded
public function isEnded(ResourceNode $resourceNode): bool { return !empty($resourceNode->getAccessibleUntil()) && $resourceNode->getAccessibleUntil() <= new \DateTime(); }
php
public function isEnded(ResourceNode $resourceNode): bool { return !empty($resourceNode->getAccessibleUntil()) && $resourceNode->getAccessibleUntil() <= new \DateTime(); }
[ "public", "function", "isEnded", "(", "ResourceNode", "$", "resourceNode", ")", ":", "bool", "{", "return", "!", "empty", "(", "$", "resourceNode", "->", "getAccessibleUntil", "(", ")", ")", "&&", "$", "resourceNode", "->", "getAccessibleUntil", "(", ")", "<...
Checks if the access period of the resource is over. @param ResourceNode $resourceNode @return bool
[ "Checks", "if", "the", "access", "period", "of", "the", "resource", "is", "over", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceRestrictionsManager.php#L151-L154
40,504
claroline/Distribution
main/core/Manager/Resource/ResourceRestrictionsManager.php
ResourceRestrictionsManager.unlock
public function unlock(ResourceNode $resourceNode, $code = null) { //if a code is defined if ($accessCode = $resourceNode->getAccessCode()) { if (empty($code) || $accessCode !== $code) { $this->session->set($resourceNode->getUuid(), false); throw new InvalidDataException('Invalid code sent'); } $this->session->set($resourceNode->getUuid(), true); } }
php
public function unlock(ResourceNode $resourceNode, $code = null) { //if a code is defined if ($accessCode = $resourceNode->getAccessCode()) { if (empty($code) || $accessCode !== $code) { $this->session->set($resourceNode->getUuid(), false); throw new InvalidDataException('Invalid code sent'); } $this->session->set($resourceNode->getUuid(), true); } }
[ "public", "function", "unlock", "(", "ResourceNode", "$", "resourceNode", ",", "$", "code", "=", "null", ")", "{", "//if a code is defined", "if", "(", "$", "accessCode", "=", "$", "resourceNode", "->", "getAccessCode", "(", ")", ")", "{", "if", "(", "empt...
Submits a code to unlock a resource. NB. The resource will stay unlocked as long as the user session stay alive. @param ResourceNode $resourceNode - The resource to unlock @param string $code - The code sent by the user @throws InvalidDataException - If the submitted code is incorrect
[ "Submits", "a", "code", "to", "unlock", "a", "resource", ".", "NB", ".", "The", "resource", "will", "stay", "unlocked", "as", "long", "as", "the", "user", "session", "stay", "alive", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceRestrictionsManager.php#L223-L235
40,505
claroline/Distribution
plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php
SelectionQuestionSerializer.serialize
public function serialize(SelectionQuestion $selectionQuestion, array $options = []) { $serialized = [ 'text' => $selectionQuestion->getText(), 'mode' => $selectionQuestion->getMode(), ]; if ($selectionQuestion->getPenalty()) { $serialized['penalty'] = $selectionQuestion->getPenalty(); } if ($selectionQuestion->getTries()) { $serialized['tries'] = $selectionQuestion->getTries(); } switch ($selectionQuestion->getMode()) { case SelectionQuestion::MODE_FIND: $serialized['tries'] = $selectionQuestion->getTries(); break; case SelectionQuestion::MODE_SELECT: $serialized['selections'] = $this->serializeSelections($selectionQuestion); break; case SelectionQuestion::MODE_HIGHLIGHT: $serialized['selections'] = $this->serializeSelections($selectionQuestion); $serialized['colors'] = $this->serializeColors($selectionQuestion); break; } if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($selectionQuestion); } return $serialized; }
php
public function serialize(SelectionQuestion $selectionQuestion, array $options = []) { $serialized = [ 'text' => $selectionQuestion->getText(), 'mode' => $selectionQuestion->getMode(), ]; if ($selectionQuestion->getPenalty()) { $serialized['penalty'] = $selectionQuestion->getPenalty(); } if ($selectionQuestion->getTries()) { $serialized['tries'] = $selectionQuestion->getTries(); } switch ($selectionQuestion->getMode()) { case SelectionQuestion::MODE_FIND: $serialized['tries'] = $selectionQuestion->getTries(); break; case SelectionQuestion::MODE_SELECT: $serialized['selections'] = $this->serializeSelections($selectionQuestion); break; case SelectionQuestion::MODE_HIGHLIGHT: $serialized['selections'] = $this->serializeSelections($selectionQuestion); $serialized['colors'] = $this->serializeColors($selectionQuestion); break; } if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($selectionQuestion); } return $serialized; }
[ "public", "function", "serialize", "(", "SelectionQuestion", "$", "selectionQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'text'", "=>", "$", "selectionQuestion", "->", "getText", "(", ")", ",", "'mode'", "...
Converts a Selection question into a JSON-encodable structure. @param SelectionQuestion $selectionQuestion @param array $options @return array
[ "Converts", "a", "Selection", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php#L29-L62
40,506
claroline/Distribution
plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php
SelectionQuestionSerializer.deserialize
public function deserialize($data, SelectionQuestion $selectionQuestion = null, array $options = []) { if (empty($selectionQuestion)) { $selectionQuestion = new SelectionQuestion(); } $this->sipe('text', 'setText', $data, $selectionQuestion); $this->sipe('mode', 'setMode', $data, $selectionQuestion); $this->sipe('tries', 'setTries', $data, $selectionQuestion); $this->sipe('penalty', 'setPenalty', $data, $selectionQuestion); // colors must be deserialized first because they might be useful for selections if (isset($data['colors'])) { $this->deserializeColors($selectionQuestion, $data['colors']); } $options['selection_mode'] = $data['mode']; if (isset($data['selections']) && 'find' !== $data['mode']) { $this->deserializeSelections($selectionQuestion, $data['selections'], $data['solutions'], $options); } if (isset($data['solutions']) && 'find' === $data['mode']) { $this->deserializeSolutions($selectionQuestion, $data['solutions'], $options); } return $selectionQuestion; }
php
public function deserialize($data, SelectionQuestion $selectionQuestion = null, array $options = []) { if (empty($selectionQuestion)) { $selectionQuestion = new SelectionQuestion(); } $this->sipe('text', 'setText', $data, $selectionQuestion); $this->sipe('mode', 'setMode', $data, $selectionQuestion); $this->sipe('tries', 'setTries', $data, $selectionQuestion); $this->sipe('penalty', 'setPenalty', $data, $selectionQuestion); // colors must be deserialized first because they might be useful for selections if (isset($data['colors'])) { $this->deserializeColors($selectionQuestion, $data['colors']); } $options['selection_mode'] = $data['mode']; if (isset($data['selections']) && 'find' !== $data['mode']) { $this->deserializeSelections($selectionQuestion, $data['selections'], $data['solutions'], $options); } if (isset($data['solutions']) && 'find' === $data['mode']) { $this->deserializeSolutions($selectionQuestion, $data['solutions'], $options); } return $selectionQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "SelectionQuestion", "$", "selectionQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "selectionQuestion", ")", ")", "{", "$", "selecti...
Converts raw data into a Selection question entity. @param array $data @param SelectionQuestion $selectionQuestion @param array $options @return SelectionQuestion
[ "Converts", "raw", "data", "into", "a", "Selection", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php#L73-L99
40,507
claroline/Distribution
plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php
SelectionQuestionSerializer.deserializeSelections
private function deserializeSelections(SelectionQuestion $selectionQuestion, array $selections, array $solutions, array $options = []) { $selectionEntities = $selectionQuestion->getSelections()->toArray(); foreach ($selections as $selectionData) { $selection = null; foreach ($selectionEntities as $entityIndex => $selectionEntity) { /** @var Selection $selectionEntity */ if ($selectionEntity->getUuid() === $selectionData['id']) { $selection = $selectionEntity; unset($selectionEntities[$entityIndex]); break; } } $selection = $selection ?: new Selection(); $selection->setUuid($selectionData['id']); $solutionsD = array_values(array_filter($solutions, function ($solution) use ($selectionData) { return $solution['selectionId'] === $selectionData['id']; })); if (isset($solutionsD[0]) && isset($solutionsD[0]['feedback'])) { $selection->setFeedback($solutionsD[0]['feedback']); } $selection->setBegin($selectionData['begin']); $selection->setEnd($selectionData['end']); foreach ($solutions as $solutionData) { if ($solutionData['selectionId'] === $selectionData['id']) { switch ($options['selection_mode']) { case SelectionQuestion::MODE_SELECT: $selection->setScore($solutionData['score']); break; case SelectionQuestion::MODE_HIGHLIGHT: $selection->setScore(0); $this->deserializeColorSelection($selection, $solutionData['answers'], $selectionQuestion->getColors()->toArray()); break; } } } $selectionQuestion->addSelection($selection); } // Remaining color are no longer in the Question foreach ($selectionEntities as $selectionToRemove) { $selectionQuestion->removeSelection($selectionToRemove); } }
php
private function deserializeSelections(SelectionQuestion $selectionQuestion, array $selections, array $solutions, array $options = []) { $selectionEntities = $selectionQuestion->getSelections()->toArray(); foreach ($selections as $selectionData) { $selection = null; foreach ($selectionEntities as $entityIndex => $selectionEntity) { /** @var Selection $selectionEntity */ if ($selectionEntity->getUuid() === $selectionData['id']) { $selection = $selectionEntity; unset($selectionEntities[$entityIndex]); break; } } $selection = $selection ?: new Selection(); $selection->setUuid($selectionData['id']); $solutionsD = array_values(array_filter($solutions, function ($solution) use ($selectionData) { return $solution['selectionId'] === $selectionData['id']; })); if (isset($solutionsD[0]) && isset($solutionsD[0]['feedback'])) { $selection->setFeedback($solutionsD[0]['feedback']); } $selection->setBegin($selectionData['begin']); $selection->setEnd($selectionData['end']); foreach ($solutions as $solutionData) { if ($solutionData['selectionId'] === $selectionData['id']) { switch ($options['selection_mode']) { case SelectionQuestion::MODE_SELECT: $selection->setScore($solutionData['score']); break; case SelectionQuestion::MODE_HIGHLIGHT: $selection->setScore(0); $this->deserializeColorSelection($selection, $solutionData['answers'], $selectionQuestion->getColors()->toArray()); break; } } } $selectionQuestion->addSelection($selection); } // Remaining color are no longer in the Question foreach ($selectionEntities as $selectionToRemove) { $selectionQuestion->removeSelection($selectionToRemove); } }
[ "private", "function", "deserializeSelections", "(", "SelectionQuestion", "$", "selectionQuestion", ",", "array", "$", "selections", ",", "array", "$", "solutions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "selectionEntities", "=", "$", "sel...
Deserializes Question selection. @param SelectionQuestion $selectionQuestion @param array $selections @param array $solutions @param array $options
[ "Deserializes", "Question", "selection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php#L167-L218
40,508
claroline/Distribution
main/core/Listener/AnonymousAuthenticationListener.php
AnonymousAuthenticationListener.handle
public function handle(GetResponseEvent $event) { if (null !== $this->tokenStorage->getToken()) { // user is already authenticated, there is nothing to do. return; } // creates an anonymous token with a dedicated role. $this->tokenStorage->setToken( new AnonymousToken($this->secret, 'anon.', ['ROLE_ANONYMOUS']) ); if (null !== $this->logger) { $this->logger->info(sprintf('Populated SecurityContext with an anonymous Token')); } }
php
public function handle(GetResponseEvent $event) { if (null !== $this->tokenStorage->getToken()) { // user is already authenticated, there is nothing to do. return; } // creates an anonymous token with a dedicated role. $this->tokenStorage->setToken( new AnonymousToken($this->secret, 'anon.', ['ROLE_ANONYMOUS']) ); if (null !== $this->logger) { $this->logger->info(sprintf('Populated SecurityContext with an anonymous Token')); } }
[ "public", "function", "handle", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ")", "{", "// user is already authenticated, there is nothing to do.", "return", ";", "}", "...
Authenticates anonymous with correct roles. @param GetResponseEvent $event
[ "Authenticates", "anonymous", "with", "correct", "roles", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/AnonymousAuthenticationListener.php#L52-L67
40,509
claroline/Distribution
plugin/lti/Listener/LtiListener.php
LtiListener.onLoad
public function onLoad(LoadResourceEvent $event) { $ltiResource = $event->getResource(); $collection = new ResourceCollection([$ltiResource->getResourceNode()]); $ltiApps = $this->authorization->isGranted('EDIT', $collection) ? $this->ltiAppRepo->findBy([], ['title' => 'ASC']) : []; $event->setData([ 'ltiResource' => $this->serializer->serialize($ltiResource), 'ltiApps' => array_map(function (LtiApp $app) { return $this->serializer->serialize($app, [Options::SERIALIZE_MINIMAL]); }, $ltiApps), ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { $ltiResource = $event->getResource(); $collection = new ResourceCollection([$ltiResource->getResourceNode()]); $ltiApps = $this->authorization->isGranted('EDIT', $collection) ? $this->ltiAppRepo->findBy([], ['title' => 'ASC']) : []; $event->setData([ 'ltiResource' => $this->serializer->serialize($ltiResource), 'ltiApps' => array_map(function (LtiApp $app) { return $this->serializer->serialize($app, [Options::SERIALIZE_MINIMAL]); }, $ltiApps), ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "$", "ltiResource", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "collection", "=", "new", "ResourceCollection", "(", "[", "$", "ltiResource", "->", "getResource...
Loads a LTI resource. @DI\Observe("resource.ujm_lti_resource.load") @param LoadResourceEvent $event
[ "Loads", "a", "LTI", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/lti/Listener/LtiListener.php#L96-L112
40,510
claroline/Distribution
main/core/Controller/APINew/User/ProfileController.php
ProfileController.updateAction
public function updateAction(Request $request) { $formData = $this->decodeRequest($request); // dump current profile configuration (to know what to remove later) /** @var Facet[] $facets */ $facets = $this->om->getRepository('ClarolineCoreBundle:Facet\Facet')->findAll(); $this->om->startFlushSuite(); // updates facets data $updatedFacets = []; foreach ($formData as $facetData) { $updated = $this->crud->update( 'Claroline\CoreBundle\Entity\Facet\Facet', $facetData, [Options::DEEP_DESERIALIZE] ); $updatedFacets[$updated->getId()] = $updated; } // removes deleted facets foreach ($facets as $facet) { if (empty($updatedFacets[$facet->getId()])) { $this->crud->delete($facet); } } $this->om->endFlushSuite(); return new JsonResponse( $this->serializer->serialize() ); }
php
public function updateAction(Request $request) { $formData = $this->decodeRequest($request); // dump current profile configuration (to know what to remove later) /** @var Facet[] $facets */ $facets = $this->om->getRepository('ClarolineCoreBundle:Facet\Facet')->findAll(); $this->om->startFlushSuite(); // updates facets data $updatedFacets = []; foreach ($formData as $facetData) { $updated = $this->crud->update( 'Claroline\CoreBundle\Entity\Facet\Facet', $facetData, [Options::DEEP_DESERIALIZE] ); $updatedFacets[$updated->getId()] = $updated; } // removes deleted facets foreach ($facets as $facet) { if (empty($updatedFacets[$facet->getId()])) { $this->crud->delete($facet); } } $this->om->endFlushSuite(); return new JsonResponse( $this->serializer->serialize() ); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ")", "{", "$", "formData", "=", "$", "this", "->", "decodeRequest", "(", "$", "request", ")", ";", "// dump current profile configuration (to know what to remove later)", "/** @var Facet[] $facets */", ...
Updates the profile configuration for the current platform. @EXT\Route("", name="apiv2_profile_update") @EXT\Method("PUT") @param Request $request @return JsonResponse
[ "Updates", "the", "profile", "configuration", "for", "the", "current", "platform", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/User/ProfileController.php#L78-L111
40,511
claroline/Distribution
plugin/scorm/Event/ExportScormResourceEvent.php
ExportScormResourceEvent.addFile
public function addFile($packageName, $filePath, $absolutePath = false) { $this->files[$packageName] = [ 'path' => $filePath, 'absolute' => $absolutePath, ]; }
php
public function addFile($packageName, $filePath, $absolutePath = false) { $this->files[$packageName] = [ 'path' => $filePath, 'absolute' => $absolutePath, ]; }
[ "public", "function", "addFile", "(", "$", "packageName", ",", "$", "filePath", ",", "$", "absolutePath", "=", "false", ")", "{", "$", "this", "->", "files", "[", "$", "packageName", "]", "=", "[", "'path'", "=>", "$", "filePath", ",", "'absolute'", "=...
Add a new uploaded file to include. @param string $packageName - Name of the asset in the SCORM package (with extension) @param string $filePath - Path to the file @param bool $absolutePath - if false $filePath will be searched in `files` directory
[ "Add", "a", "new", "uploaded", "file", "to", "include", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Event/ExportScormResourceEvent.php#L156-L162
40,512
claroline/Distribution
plugin/scorm/Event/ExportScormResourceEvent.php
ExportScormResourceEvent.addEmbedResource
public function addEmbedResource(AbstractResource $resource) { if (!in_array($resource, $this->embedResources)) { // Uses node ID as array key in order to avoid duplicates $this->embedResources[$resource->getResourceNode()->getId()] = $resource; } }
php
public function addEmbedResource(AbstractResource $resource) { if (!in_array($resource, $this->embedResources)) { // Uses node ID as array key in order to avoid duplicates $this->embedResources[$resource->getResourceNode()->getId()] = $resource; } }
[ "public", "function", "addEmbedResource", "(", "AbstractResource", "$", "resource", ")", "{", "if", "(", "!", "in_array", "(", "$", "resource", ",", "$", "this", "->", "embedResources", ")", ")", "{", "// Uses node ID as array key in order to avoid duplicates", "$",...
Add an embed Resource. @param AbstractResource $resource
[ "Add", "an", "embed", "Resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Event/ExportScormResourceEvent.php#L206-L212
40,513
claroline/Distribution
main/core/Repository/WorkspaceRepository.php
WorkspaceRepository.countNonPersonalWorkspaces
public function countNonPersonalWorkspaces($organizations = null) { $qb = $this ->createQueryBuilder('w') ->select('COUNT(w.id)') ->andWhere('w.personal = :personal') ->setParameter('personal', false); if (null !== $organizations) { $qb->join('w.organizations', 'orgas') ->andWhere('orgas IN (:organizations)') ->setParameter('organizations', $organizations); } return $qb->getQuery()->getSingleScalarResult(); }
php
public function countNonPersonalWorkspaces($organizations = null) { $qb = $this ->createQueryBuilder('w') ->select('COUNT(w.id)') ->andWhere('w.personal = :personal') ->setParameter('personal', false); if (null !== $organizations) { $qb->join('w.organizations', 'orgas') ->andWhere('orgas IN (:organizations)') ->setParameter('organizations', $organizations); } return $qb->getQuery()->getSingleScalarResult(); }
[ "public", "function", "countNonPersonalWorkspaces", "(", "$", "organizations", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'w'", ")", "->", "select", "(", "'COUNT(w.id)'", ")", "->", "andWhere", "(", "'w.personal = :pe...
Counts the non personal workspaces. @return int
[ "Counts", "the", "non", "personal", "workspaces", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/WorkspaceRepository.php#L78-L92
40,514
claroline/Distribution
main/core/Repository/WorkspaceRepository.php
WorkspaceRepository.findWorkspaceByWorkspaceAndRoles
public function findWorkspaceByWorkspaceAndRoles( Workspace $workspace, array $roles, $orderedToolType = 0 ) { if (count($roles) > 0) { $dql = ' SELECT DISTINCT w FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w JOIN w.orderedTools ot JOIN ot.rights otr JOIN otr.role r WHERE w = :workspace AND ot.type = :type AND r.name IN (:roles) AND BIT_AND(otr.mask, :openValue) = :openValue '; $query = $this->_em->createQuery($dql); $query->setParameter('workspace', $workspace); $query->setParameter('roles', $roles); $query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']); $query->setParameter('type', $orderedToolType); return $query->getOneOrNullResult(); } return null; }
php
public function findWorkspaceByWorkspaceAndRoles( Workspace $workspace, array $roles, $orderedToolType = 0 ) { if (count($roles) > 0) { $dql = ' SELECT DISTINCT w FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w JOIN w.orderedTools ot JOIN ot.rights otr JOIN otr.role r WHERE w = :workspace AND ot.type = :type AND r.name IN (:roles) AND BIT_AND(otr.mask, :openValue) = :openValue '; $query = $this->_em->createQuery($dql); $query->setParameter('workspace', $workspace); $query->setParameter('roles', $roles); $query->setParameter('openValue', ToolMaskDecoder::$defaultValues['open']); $query->setParameter('type', $orderedToolType); return $query->getOneOrNullResult(); } return null; }
[ "public", "function", "findWorkspaceByWorkspaceAndRoles", "(", "Workspace", "$", "workspace", ",", "array", "$", "roles", ",", "$", "orderedToolType", "=", "0", ")", "{", "if", "(", "count", "(", "$", "roles", ")", ">", "0", ")", "{", "$", "dql", "=", ...
Used By claro_workspace_update_favourite.
[ "Used", "By", "claro_workspace_update_favourite", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/WorkspaceRepository.php#L375-L403
40,515
claroline/Distribution
main/core/Repository/WorkspaceRepository.php
WorkspaceRepository.findWorkspacesByManager
public function findWorkspacesByManager(User $user, $executeQuery = true) { $roles = $user->getRoles(); $managerRoles = []; foreach ($roles as $role) { if (strpos('_'.$role, 'ROLE_WS_MANAGER')) { $managerRoles[] = $role; } } $dql = ' SELECT w FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w JOIN w.roles r WHERE r.name IN (:roleNames) '; $query = $this->_em->createQuery($dql); $query->setParameter('roleNames', $managerRoles); return $executeQuery ? $query->getResult() : $query; }
php
public function findWorkspacesByManager(User $user, $executeQuery = true) { $roles = $user->getRoles(); $managerRoles = []; foreach ($roles as $role) { if (strpos('_'.$role, 'ROLE_WS_MANAGER')) { $managerRoles[] = $role; } } $dql = ' SELECT w FROM Claroline\\CoreBundle\\Entity\\Workspace\\Workspace w JOIN w.roles r WHERE r.name IN (:roleNames) '; $query = $this->_em->createQuery($dql); $query->setParameter('roleNames', $managerRoles); return $executeQuery ? $query->getResult() : $query; }
[ "public", "function", "findWorkspacesByManager", "(", "User", "$", "user", ",", "$", "executeQuery", "=", "true", ")", "{", "$", "roles", "=", "$", "user", "->", "getRoles", "(", ")", ";", "$", "managerRoles", "=", "[", "]", ";", "foreach", "(", "$", ...
Eventually used by the message bundle.
[ "Eventually", "used", "by", "the", "message", "bundle", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/WorkspaceRepository.php#L431-L454
40,516
claroline/Distribution
main/core/Repository/WorkspaceRepository.php
WorkspaceRepository.findAllNonPersonalWorkspaces
public function findAllNonPersonalWorkspaces( $orderedBy = 'name', $order = 'ASC', User $user = null ) { $isAdmin = $user ? $user->hasRole('ROLE_ADMIN') : false; $qb = $this->createQueryBuilder('w') ->select('w') ->join('w.organizations', 'o') ->leftJoin('o.administrators', 'a') ->where('NOT EXISTS ( SELECT u FROM Claroline\CoreBundle\Entity\User u JOIN u.personalWorkspace pw WHERE pw = w )'); if (!$isAdmin) { $qb->andWhere('a.id = ?1')->setParameter(1, $user->getId()); } $qb->orderBy("w.{$orderedBy}", $order); return $qb->getQuery()->getResult(); }
php
public function findAllNonPersonalWorkspaces( $orderedBy = 'name', $order = 'ASC', User $user = null ) { $isAdmin = $user ? $user->hasRole('ROLE_ADMIN') : false; $qb = $this->createQueryBuilder('w') ->select('w') ->join('w.organizations', 'o') ->leftJoin('o.administrators', 'a') ->where('NOT EXISTS ( SELECT u FROM Claroline\CoreBundle\Entity\User u JOIN u.personalWorkspace pw WHERE pw = w )'); if (!$isAdmin) { $qb->andWhere('a.id = ?1')->setParameter(1, $user->getId()); } $qb->orderBy("w.{$orderedBy}", $order); return $qb->getQuery()->getResult(); }
[ "public", "function", "findAllNonPersonalWorkspaces", "(", "$", "orderedBy", "=", "'name'", ",", "$", "order", "=", "'ASC'", ",", "User", "$", "user", "=", "null", ")", "{", "$", "isAdmin", "=", "$", "user", "?", "$", "user", "->", "hasRole", "(", "'RO...
Returns all non-personal workspaces. @param string $orderedBy @param string $order @param User $user @return Workspace[]
[ "Returns", "all", "non", "-", "personal", "workspaces", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/WorkspaceRepository.php#L479-L504
40,517
claroline/Distribution
main/core/API/Finder/User/UserFinder.php
UserFinder.sortBy
private function sortBy($qb, array $sortBy = null) { // manages custom sort properties if ($sortBy && 0 !== $sortBy['direction']) { switch ($sortBy['property']) { case 'name': $qb->orderBy('obj.lastName', 1 === $sortBy['direction'] ? 'ASC' : 'DESC'); break; case 'isDisabled': $qb->orderBy('obj.isEnabled', 1 === $sortBy['direction'] ? 'ASC' : 'DESC'); break; } } return $qb; }
php
private function sortBy($qb, array $sortBy = null) { // manages custom sort properties if ($sortBy && 0 !== $sortBy['direction']) { switch ($sortBy['property']) { case 'name': $qb->orderBy('obj.lastName', 1 === $sortBy['direction'] ? 'ASC' : 'DESC'); break; case 'isDisabled': $qb->orderBy('obj.isEnabled', 1 === $sortBy['direction'] ? 'ASC' : 'DESC'); break; } } return $qb; }
[ "private", "function", "sortBy", "(", "$", "qb", ",", "array", "$", "sortBy", "=", "null", ")", "{", "// manages custom sort properties", "if", "(", "$", "sortBy", "&&", "0", "!==", "$", "sortBy", "[", "'direction'", "]", ")", "{", "switch", "(", "$", ...
probably deprecated since we try hard to optimize everything and is a duplicata of getExtraFieldMapping
[ "probably", "deprecated", "since", "we", "try", "hard", "to", "optimize", "everything", "and", "is", "a", "duplicata", "of", "getExtraFieldMapping" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Finder/User/UserFinder.php#L238-L253
40,518
claroline/Distribution
plugin/exo/Entity/Misc/Hole.php
Hole.getKeyword
public function getKeyword($text) { $found = null; $text = trim($text); $iText = strtoupper(TextNormalizer::stripDiacritics($text)); foreach ($this->keywords as $keyword) { /** @var Keyword $keyword */ $tmpText = trim($keyword->getText()); if ($tmpText === $text || ( empty($keyword->isCaseSensitive()) && strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText) ) { $found = $keyword; break; } } return $found; }
php
public function getKeyword($text) { $found = null; $text = trim($text); $iText = strtoupper(TextNormalizer::stripDiacritics($text)); foreach ($this->keywords as $keyword) { /** @var Keyword $keyword */ $tmpText = trim($keyword->getText()); if ($tmpText === $text || ( empty($keyword->isCaseSensitive()) && strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText) ) { $found = $keyword; break; } } return $found; }
[ "public", "function", "getKeyword", "(", "$", "text", ")", "{", "$", "found", "=", "null", ";", "$", "text", "=", "trim", "(", "$", "text", ")", ";", "$", "iText", "=", "strtoupper", "(", "TextNormalizer", "::", "stripDiacritics", "(", "$", "text", "...
Get a keyword by text. @param string $text @return Keyword
[ "Get", "a", "keyword", "by", "text", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/Hole.php#L181-L200
40,519
claroline/Distribution
plugin/exo/Entity/Misc/Hole.php
Hole.setKeywords
public function setKeywords(array $keywords) { // Removes old keywords $oldKeywords = array_filter($this->keywords->toArray(), function (Keyword $keyword) use ($keywords) { return !in_array($keyword, $keywords); }); array_walk($oldKeywords, function (Keyword $keyword) { $this->removeKeyword($keyword); }); // Adds new ones array_walk($keywords, function (Keyword $keyword) { $this->addKeyword($keyword); }); }
php
public function setKeywords(array $keywords) { // Removes old keywords $oldKeywords = array_filter($this->keywords->toArray(), function (Keyword $keyword) use ($keywords) { return !in_array($keyword, $keywords); }); array_walk($oldKeywords, function (Keyword $keyword) { $this->removeKeyword($keyword); }); // Adds new ones array_walk($keywords, function (Keyword $keyword) { $this->addKeyword($keyword); }); }
[ "public", "function", "setKeywords", "(", "array", "$", "keywords", ")", "{", "// Removes old keywords", "$", "oldKeywords", "=", "array_filter", "(", "$", "this", "->", "keywords", "->", "toArray", "(", ")", ",", "function", "(", "Keyword", "$", "keyword", ...
Sets keywords collection. @param array $keywords
[ "Sets", "keywords", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/Hole.php#L207-L221
40,520
claroline/Distribution
plugin/exo/Serializer/ExerciseSerializer.php
ExerciseSerializer.serialize
public function serialize(Exercise $exercise, array $options = []) { $serialized = [ 'id' => $exercise->getUuid(), 'title' => $exercise->getResourceNode()->getName(), // TODO : remove me. it's required by the json schema ]; if (!in_array(Transfer::MINIMAL, $options)) { if (!empty($exercise->getDescription())) { $serialized['description'] = $exercise->getDescription(); } $serialized['parameters'] = $this->serializeParameters($exercise); $serialized['picking'] = $this->serializePicking($exercise); $serialized['steps'] = $this->serializeSteps($exercise, $options); } return $serialized; }
php
public function serialize(Exercise $exercise, array $options = []) { $serialized = [ 'id' => $exercise->getUuid(), 'title' => $exercise->getResourceNode()->getName(), // TODO : remove me. it's required by the json schema ]; if (!in_array(Transfer::MINIMAL, $options)) { if (!empty($exercise->getDescription())) { $serialized['description'] = $exercise->getDescription(); } $serialized['parameters'] = $this->serializeParameters($exercise); $serialized['picking'] = $this->serializePicking($exercise); $serialized['steps'] = $this->serializeSteps($exercise, $options); } return $serialized; }
[ "public", "function", "serialize", "(", "Exercise", "$", "exercise", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "exercise", "->", "getUuid", "(", ")", ",", "'title'", "=>", "$", "exercise", ...
Converts an Exercise into a JSON-encodable structure. @param Exercise $exercise @param array $options @return array
[ "Converts", "an", "Exercise", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/ExerciseSerializer.php#L67-L84
40,521
claroline/Distribution
plugin/exo/Serializer/ExerciseSerializer.php
ExerciseSerializer.deserialize
public function deserialize($data, Exercise $exercise = null, array $options = []) { $exercise = $exercise ?: new Exercise(); $this->sipe('id', 'setUuid', $data, $exercise); $this->sipe('description', 'setDescription', $data, $exercise); if (in_array(Transfer::REFRESH_UUID, $options)) { $exercise->refreshUuid(); } if (!empty($data['parameters'])) { $this->deserializeParameters($exercise, $data['parameters']); } if (!empty($data['picking'])) { $this->deserializePicking($exercise, $data['picking']); } if (!empty($data['steps'])) { $this->deserializeSteps($exercise, $data['steps'], $options); } return $exercise; }
php
public function deserialize($data, Exercise $exercise = null, array $options = []) { $exercise = $exercise ?: new Exercise(); $this->sipe('id', 'setUuid', $data, $exercise); $this->sipe('description', 'setDescription', $data, $exercise); if (in_array(Transfer::REFRESH_UUID, $options)) { $exercise->refreshUuid(); } if (!empty($data['parameters'])) { $this->deserializeParameters($exercise, $data['parameters']); } if (!empty($data['picking'])) { $this->deserializePicking($exercise, $data['picking']); } if (!empty($data['steps'])) { $this->deserializeSteps($exercise, $data['steps'], $options); } return $exercise; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "Exercise", "$", "exercise", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "exercise", "=", "$", "exercise", "?", ":", "new", "Exercise", "(", ")", ";", "$", "th...
Converts raw data into an Exercise entity. @param array $data @param Exercise $exercise @param array $options @return Exercise
[ "Converts", "raw", "data", "into", "an", "Exercise", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/ExerciseSerializer.php#L95-L119
40,522
claroline/Distribution
plugin/exo/Serializer/ExerciseSerializer.php
ExerciseSerializer.serializeParameters
private function serializeParameters(Exercise $exercise) { $parameters = [ 'type' => $exercise->getType(), 'maxAttempts' => $exercise->getMaxAttempts(), 'maxAttemptsPerDay' => $exercise->getMaxAttemptsPerDay(), 'maxPapers' => $exercise->getMaxPapers(), 'showFeedback' => $exercise->getShowFeedback(), 'progressionDisplayed' => $exercise->isProgressionDisplayed(), 'timeLimited' => $exercise->isTimeLimited(), // todo : remove me 'duration' => $exercise->getDuration(), 'anonymizeAttempts' => $exercise->getAnonymizeAttempts(), 'interruptible' => $exercise->isInterruptible(), 'numbering' => $exercise->getNumbering(), 'mandatoryQuestions' => $exercise->getMandatoryQuestions(), 'answersEditable' => $exercise->isAnswersEditable(), 'showOverview' => $exercise->getShowOverview(), 'showEndConfirm' => $exercise->getShowEndConfirm(), 'showEndPage' => $exercise->getShowEndPage(), 'endNavigation' => $exercise->hasEndNavigation(), 'showMetadata' => $exercise->isMetadataVisible(), 'showStatistics' => $exercise->hasStatistics(), 'allPapersStatistics' => $exercise->isAllPapersStatistics(), 'showFullCorrection' => !$exercise->isMinimalCorrection(), 'showScoreAt' => $exercise->getMarkMode(), 'showCorrectionAt' => $exercise->getCorrectionMode(), 'successMessage' => $exercise->getSuccessMessage(), 'failureMessage' => $exercise->getFailureMessage(), 'totalScoreOn' => $exercise->getTotalScoreOn(), 'successScore' => $exercise->getSuccessScore(), 'correctionDate' => $exercise->getDateCorrection() ? DateNormalizer::normalize($exercise->getDateCorrection()) : null, ]; if (!empty($exercise->getEndMessage())) { $parameters['endMessage'] = $exercise->getEndMessage(); } return $parameters; }
php
private function serializeParameters(Exercise $exercise) { $parameters = [ 'type' => $exercise->getType(), 'maxAttempts' => $exercise->getMaxAttempts(), 'maxAttemptsPerDay' => $exercise->getMaxAttemptsPerDay(), 'maxPapers' => $exercise->getMaxPapers(), 'showFeedback' => $exercise->getShowFeedback(), 'progressionDisplayed' => $exercise->isProgressionDisplayed(), 'timeLimited' => $exercise->isTimeLimited(), // todo : remove me 'duration' => $exercise->getDuration(), 'anonymizeAttempts' => $exercise->getAnonymizeAttempts(), 'interruptible' => $exercise->isInterruptible(), 'numbering' => $exercise->getNumbering(), 'mandatoryQuestions' => $exercise->getMandatoryQuestions(), 'answersEditable' => $exercise->isAnswersEditable(), 'showOverview' => $exercise->getShowOverview(), 'showEndConfirm' => $exercise->getShowEndConfirm(), 'showEndPage' => $exercise->getShowEndPage(), 'endNavigation' => $exercise->hasEndNavigation(), 'showMetadata' => $exercise->isMetadataVisible(), 'showStatistics' => $exercise->hasStatistics(), 'allPapersStatistics' => $exercise->isAllPapersStatistics(), 'showFullCorrection' => !$exercise->isMinimalCorrection(), 'showScoreAt' => $exercise->getMarkMode(), 'showCorrectionAt' => $exercise->getCorrectionMode(), 'successMessage' => $exercise->getSuccessMessage(), 'failureMessage' => $exercise->getFailureMessage(), 'totalScoreOn' => $exercise->getTotalScoreOn(), 'successScore' => $exercise->getSuccessScore(), 'correctionDate' => $exercise->getDateCorrection() ? DateNormalizer::normalize($exercise->getDateCorrection()) : null, ]; if (!empty($exercise->getEndMessage())) { $parameters['endMessage'] = $exercise->getEndMessage(); } return $parameters; }
[ "private", "function", "serializeParameters", "(", "Exercise", "$", "exercise", ")", "{", "$", "parameters", "=", "[", "'type'", "=>", "$", "exercise", "->", "getType", "(", ")", ",", "'maxAttempts'", "=>", "$", "exercise", "->", "getMaxAttempts", "(", ")", ...
Serializes Exercise parameters. @param Exercise $exercise @return array
[ "Serializes", "Exercise", "parameters", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/ExerciseSerializer.php#L128-L166
40,523
claroline/Distribution
plugin/exo/Serializer/ExerciseSerializer.php
ExerciseSerializer.serializeSteps
private function serializeSteps(Exercise $exercise, array $options = []) { return array_map(function (Step $step) use ($options) { return $this->stepSerializer->serialize($step, $options); }, $exercise->getSteps()->toArray()); }
php
private function serializeSteps(Exercise $exercise, array $options = []) { return array_map(function (Step $step) use ($options) { return $this->stepSerializer->serialize($step, $options); }, $exercise->getSteps()->toArray()); }
[ "private", "function", "serializeSteps", "(", "Exercise", "$", "exercise", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_map", "(", "function", "(", "Step", "$", "step", ")", "use", "(", "$", "options", ")", "{", "return", "$"...
Serializes Exercise steps. Forwards the step serialization to StepSerializer. @param Exercise $exercise @param array $options @return array
[ "Serializes", "Exercise", "steps", ".", "Forwards", "the", "step", "serialization", "to", "StepSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/ExerciseSerializer.php#L289-L294
40,524
claroline/Distribution
plugin/exo/Serializer/ExerciseSerializer.php
ExerciseSerializer.deserializeSteps
private function deserializeSteps(Exercise $exercise, array $steps = [], array $options = []) { $stepEntities = $exercise->getSteps()->toArray(); foreach ($steps as $index => $stepData) { $existingStep = null; // Searches for an existing step entity. foreach ($stepEntities as $entityIndex => $entityStep) { /** @var Step $entityStep */ if ($entityStep->getUuid() === $stepData['id']) { $existingStep = $entityStep; unset($stepEntities[$entityIndex]); break; } } $step = $this->stepSerializer->deserialize($stepData, $existingStep, $options); // Set order in Exercise $step->setOrder($index); if (empty($existingStep)) { // Creation of a new step (we need to link it to the Exercise) $exercise->addStep($step); } } // Remaining steps are no longer in the Exercise if (0 < count($stepEntities)) { /** @var Step $stepToRemove */ foreach ($stepEntities as $stepToRemove) { $exercise->removeStep($stepToRemove); $stepQuestions = $stepToRemove->getStepQuestions()->toArray(); foreach ($stepQuestions as $stepQuestionToRemove) { $stepToRemove->removeStepQuestion($stepQuestionToRemove); } } } }
php
private function deserializeSteps(Exercise $exercise, array $steps = [], array $options = []) { $stepEntities = $exercise->getSteps()->toArray(); foreach ($steps as $index => $stepData) { $existingStep = null; // Searches for an existing step entity. foreach ($stepEntities as $entityIndex => $entityStep) { /** @var Step $entityStep */ if ($entityStep->getUuid() === $stepData['id']) { $existingStep = $entityStep; unset($stepEntities[$entityIndex]); break; } } $step = $this->stepSerializer->deserialize($stepData, $existingStep, $options); // Set order in Exercise $step->setOrder($index); if (empty($existingStep)) { // Creation of a new step (we need to link it to the Exercise) $exercise->addStep($step); } } // Remaining steps are no longer in the Exercise if (0 < count($stepEntities)) { /** @var Step $stepToRemove */ foreach ($stepEntities as $stepToRemove) { $exercise->removeStep($stepToRemove); $stepQuestions = $stepToRemove->getStepQuestions()->toArray(); foreach ($stepQuestions as $stepQuestionToRemove) { $stepToRemove->removeStepQuestion($stepQuestionToRemove); } } } }
[ "private", "function", "deserializeSteps", "(", "Exercise", "$", "exercise", ",", "array", "$", "steps", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "stepEntities", "=", "$", "exercise", "->", "getSteps", "(", ")", "->", ...
Deserializes Exercise steps. Forwards the step deserialization to StepSerializer. @param Exercise $exercise @param array $steps @param array $options
[ "Deserializes", "Exercise", "steps", ".", "Forwards", "the", "step", "deserialization", "to", "StepSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/ExerciseSerializer.php#L304-L343
40,525
claroline/Distribution
plugin/dropzone/Manager/DropzoneManager.php
DropzoneManager.getDropzoneUsersIds
public function getDropzoneUsersIds(Dropzone $dropzone) { $this->container->get('icap.manager.dropzone_voter')->isAllowToEdit($dropzone); //getting the ressource node $ressourceNode = $dropzone->getResourceNode(); // getting the rights of the ressource node $rights = $ressourceNode->getRights(); // will contain the 'authorized to open' user's ids. $userIds = []; $test = []; // searching for roles with the 'open' right foreach ($rights as $ressourceRight) { $role = $ressourceRight->getRole(); // current role $mask = $ressourceRight->getMask(); // current mask // getting decoded rights. $decodedRights = $this->maskManager->decodeMask($mask, $ressourceNode->getResourceType()); // if this role is allowed to open and this role is not an Admin role if (array_key_exists('open', $decodedRights) && true === $decodedRights['open'] && 'ROLE_ADMIN' !== $role->getName() ) { // the role has the 'open' right array_push($test, $role->getName()); $users = $role->getUsers(); foreach ($users as $user) { array_push($userIds, $user->getId()); } } } $userIds = array_unique($userIds); return $userIds; }
php
public function getDropzoneUsersIds(Dropzone $dropzone) { $this->container->get('icap.manager.dropzone_voter')->isAllowToEdit($dropzone); //getting the ressource node $ressourceNode = $dropzone->getResourceNode(); // getting the rights of the ressource node $rights = $ressourceNode->getRights(); // will contain the 'authorized to open' user's ids. $userIds = []; $test = []; // searching for roles with the 'open' right foreach ($rights as $ressourceRight) { $role = $ressourceRight->getRole(); // current role $mask = $ressourceRight->getMask(); // current mask // getting decoded rights. $decodedRights = $this->maskManager->decodeMask($mask, $ressourceNode->getResourceType()); // if this role is allowed to open and this role is not an Admin role if (array_key_exists('open', $decodedRights) && true === $decodedRights['open'] && 'ROLE_ADMIN' !== $role->getName() ) { // the role has the 'open' right array_push($test, $role->getName()); $users = $role->getUsers(); foreach ($users as $user) { array_push($userIds, $user->getId()); } } } $userIds = array_unique($userIds); return $userIds; }
[ "public", "function", "getDropzoneUsersIds", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "this", "->", "container", "->", "get", "(", "'icap.manager.dropzone_voter'", ")", "->", "isAllowToEdit", "(", "$", "dropzone", ")", ";", "//getting the ressource node", ...
Getting the user that have the 'open' rights. Excluded the admin profil. @param \Icap\DropzoneBundle\Entity\Dropzone $dropzone @return array UserIds
[ "Getting", "the", "user", "that", "have", "the", "open", "rights", ".", "Excluded", "the", "admin", "profil", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Manager/DropzoneManager.php#L43-L77
40,526
claroline/Distribution
plugin/dropzone/Manager/DropzoneManager.php
DropzoneManager.getDropzoneProgressByUser
public function getDropzoneProgressByUser($dropzone, $user) { $drop = $this->em ->getRepository('IcapDropzoneBundle:Drop') ->findOneBy(['dropzone' => $dropzone, 'user' => $user]); $nbCorrections = $this->em ->getRepository('IcapDropzoneBundle:Correction') ->countFinished($dropzone, $user); return $this->getDrozponeProgress($dropzone, $drop, $nbCorrections); }
php
public function getDropzoneProgressByUser($dropzone, $user) { $drop = $this->em ->getRepository('IcapDropzoneBundle:Drop') ->findOneBy(['dropzone' => $dropzone, 'user' => $user]); $nbCorrections = $this->em ->getRepository('IcapDropzoneBundle:Correction') ->countFinished($dropzone, $user); return $this->getDrozponeProgress($dropzone, $drop, $nbCorrections); }
[ "public", "function", "getDropzoneProgressByUser", "(", "$", "dropzone", ",", "$", "user", ")", "{", "$", "drop", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'IcapDropzoneBundle:Drop'", ")", "->", "findOneBy", "(", "[", "'dropzone'", "=>", "$"...
ShortCut to getDropzoneProgress allow to get progress without drop and nbCorrection parameter. only need user and dropzone. STATES FOR NORMAL ARE : 0 : not started 1 : Waiting for drop 2 : Drop received, waiting for correction 3 : Copy corrected , Evaluation end. STATES FOR PEERREVIEW (for X correction ): 0 : notStarted 1 : Waiting for drop 2 : Drop received 3 : Correction 1/x 4 : Correction 2/X 5 : Correction X/X 6 : Waiting for correction 7 : copy corrected, Evaluation End. * WARNING : if a drop has the 'unlockedDrop' property, it will make the drop being at the last state. currentstate : index of the current state in the stateArray percent : rounded progress in percent nbCorrection : corrections made by the user in this evaluation. * @param Dropzone dropzone @param Drop drop @return array (states, currentState,percent,nbCorrection)
[ "ShortCut", "to", "getDropzoneProgress", "allow", "to", "get", "progress", "without", "drop", "and", "nbCorrection", "parameter", ".", "only", "need", "user", "and", "dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Manager/DropzoneManager.php#L112-L122
40,527
claroline/Distribution
plugin/dropzone/Manager/DropzoneManager.php
DropzoneManager.isPeerReviewEndedOrManualStateFinished
public function isPeerReviewEndedOrManualStateFinished(Dropzone $dropzone, $nbCorrection) { $specialCase = false; if (($dropzone->getManualPlanning() && Dropzone::MANUAL_STATE_FINISHED === $dropzone->getManualState()) || (!$dropzone->getManualPlanning() && $dropzone->getTimeRemaining($dropzone->getEndReview()) <= 0) ) { if ($dropzone->getExpectedTotalCorrection() > $nbCorrection) { $specialCase = true; } } return $specialCase; }
php
public function isPeerReviewEndedOrManualStateFinished(Dropzone $dropzone, $nbCorrection) { $specialCase = false; if (($dropzone->getManualPlanning() && Dropzone::MANUAL_STATE_FINISHED === $dropzone->getManualState()) || (!$dropzone->getManualPlanning() && $dropzone->getTimeRemaining($dropzone->getEndReview()) <= 0) ) { if ($dropzone->getExpectedTotalCorrection() > $nbCorrection) { $specialCase = true; } } return $specialCase; }
[ "public", "function", "isPeerReviewEndedOrManualStateFinished", "(", "Dropzone", "$", "dropzone", ",", "$", "nbCorrection", ")", "{", "$", "specialCase", "=", "false", ";", "if", "(", "(", "$", "dropzone", "->", "getManualPlanning", "(", ")", "&&", "Dropzone", ...
Test to detect the special case where the peerReview end whereas user didnt had time to make the expected number of correction. @param Dropzone $dropzone @param $nbCorrection @return bool
[ "Test", "to", "detect", "the", "special", "case", "where", "the", "peerReview", "end", "whereas", "user", "didnt", "had", "time", "to", "make", "the", "expected", "number", "of", "correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Manager/DropzoneManager.php#L253-L265
40,528
claroline/Distribution
plugin/dropzone/Manager/DropzoneManager.php
DropzoneManager.closeDropzoneOpenedDrops
public function closeDropzoneOpenedDrops(Dropzone $dropzone, $force = false) { if ($force || $this->isDropzoneDropTimeIsUp($dropzone)) { $dropRepo = $this->em->getRepository('IcapDropzoneBundle:Drop'); $dropRepo->closeUnTerminatedDropsByDropzone($dropzone->getId()); $dropzone->setAutoCloseState(Dropzone::AUTO_CLOSED_STATE_CLOSED); } }
php
public function closeDropzoneOpenedDrops(Dropzone $dropzone, $force = false) { if ($force || $this->isDropzoneDropTimeIsUp($dropzone)) { $dropRepo = $this->em->getRepository('IcapDropzoneBundle:Drop'); $dropRepo->closeUnTerminatedDropsByDropzone($dropzone->getId()); $dropzone->setAutoCloseState(Dropzone::AUTO_CLOSED_STATE_CLOSED); } }
[ "public", "function", "closeDropzoneOpenedDrops", "(", "Dropzone", "$", "dropzone", ",", "$", "force", "=", "false", ")", "{", "if", "(", "$", "force", "||", "$", "this", "->", "isDropzoneDropTimeIsUp", "(", "$", "dropzone", ")", ")", "{", "$", "dropRepo",...
if the dropzone option 'autocloseOpenDropsWhenTimeIsUp' is activated, and evalution allowToDrop time is over, this will close all drop not closed yet. @param Dropzone $dropzone @param bool $force
[ "if", "the", "dropzone", "option", "autocloseOpenDropsWhenTimeIsUp", "is", "activated", "and", "evalution", "allowToDrop", "time", "is", "over", "this", "will", "close", "all", "drop", "not", "closed", "yet", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Manager/DropzoneManager.php#L274-L281
40,529
claroline/Distribution
plugin/dropzone/Manager/DropzoneManager.php
DropzoneManager.isDropzoneDropTimeIsUp
private function isDropzoneDropTimeIsUp(Dropzone $dropzone) { $dropDatePassed = false; if ($dropzone->getAutoCloseOpenedDropsWhenTimeIsUp() && false === $dropzone->getManualPlanning()) { $now = new \DateTime(); $dropDatePassed = $now->getTimestamp() > $dropzone->getEndAllowDrop()->getTimeStamp(); } return $dropDatePassed; }
php
private function isDropzoneDropTimeIsUp(Dropzone $dropzone) { $dropDatePassed = false; if ($dropzone->getAutoCloseOpenedDropsWhenTimeIsUp() && false === $dropzone->getManualPlanning()) { $now = new \DateTime(); $dropDatePassed = $now->getTimestamp() > $dropzone->getEndAllowDrop()->getTimeStamp(); } return $dropDatePassed; }
[ "private", "function", "isDropzoneDropTimeIsUp", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "dropDatePassed", "=", "false", ";", "if", "(", "$", "dropzone", "->", "getAutoCloseOpenedDropsWhenTimeIsUp", "(", ")", "&&", "false", "===", "$", "dropzone", "->",...
Check if dropzone options are ok in order to autoclose Drops. @param Dropzone $dropzone @return bool
[ "Check", "if", "dropzone", "options", "are", "ok", "in", "order", "to", "autoclose", "Drops", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Manager/DropzoneManager.php#L290-L299
40,530
claroline/Distribution
plugin/exo/Installation/Updater/Updater060200.php
Updater060200.createTemporaryPicture
private function createTemporaryPicture() { $schema = $this->connection->getSchemaManager(); if (!$schema->tablesExist('ujm_picture_temp')) { $this->log('Create ujm_picture_temp ...'); $this->connection->exec(' CREATE TABLE ujm_picture_temp ( id INT NOT NULL, user_id INT DEFAULT NULL, `label` VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, width INT NOT NULL, height INT NOT NULL, INDEX IDX_88AACC8AA76ED395 (user_id), PRIMARY KEY(id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB '); } $this->checkDocument(); }
php
private function createTemporaryPicture() { $schema = $this->connection->getSchemaManager(); if (!$schema->tablesExist('ujm_picture_temp')) { $this->log('Create ujm_picture_temp ...'); $this->connection->exec(' CREATE TABLE ujm_picture_temp ( id INT NOT NULL, user_id INT DEFAULT NULL, `label` VARCHAR(255) NOT NULL, url VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, width INT NOT NULL, height INT NOT NULL, INDEX IDX_88AACC8AA76ED395 (user_id), PRIMARY KEY(id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB '); } $this->checkDocument(); }
[ "private", "function", "createTemporaryPicture", "(", ")", "{", "$", "schema", "=", "$", "this", "->", "connection", "->", "getSchemaManager", "(", ")", ";", "if", "(", "!", "$", "schema", "->", "tablesExist", "(", "'ujm_picture_temp'", ")", ")", "{", "$",...
create temporary table for picture in order to recover data.
[ "create", "temporary", "table", "for", "picture", "in", "order", "to", "recover", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060200.php#L37-L58
40,531
claroline/Distribution
plugin/exo/Installation/Updater/Updater060200.php
Updater060200.createTemporaryInterGraph
private function createTemporaryInterGraph() { $schema = $this->connection->getSchemaManager(); if (!$schema->tablesExist('ujm_interaction_graphic_temp')) { $this->log('Create ujm_interaction_graphic_temp ...'); $this->connection->exec(' CREATE TABLE ujm_interaction_graphic_temp ( id INT NOT NULL, document_id INT NOT NULL, PRIMARY KEY(id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB '); } $this->connection->exec(' INSERT INTO ujm_interaction_graphic_temp (id, document_id) SELECT id, document_id FROM ujm_interaction_graphic '); }
php
private function createTemporaryInterGraph() { $schema = $this->connection->getSchemaManager(); if (!$schema->tablesExist('ujm_interaction_graphic_temp')) { $this->log('Create ujm_interaction_graphic_temp ...'); $this->connection->exec(' CREATE TABLE ujm_interaction_graphic_temp ( id INT NOT NULL, document_id INT NOT NULL, PRIMARY KEY(id) ) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB '); } $this->connection->exec(' INSERT INTO ujm_interaction_graphic_temp (id, document_id) SELECT id, document_id FROM ujm_interaction_graphic '); }
[ "private", "function", "createTemporaryInterGraph", "(", ")", "{", "$", "schema", "=", "$", "this", "->", "connection", "->", "getSchemaManager", "(", ")", ";", "if", "(", "!", "$", "schema", "->", "tablesExist", "(", "'ujm_interaction_graphic_temp'", ")", ")"...
create temporary table for interaction_graphic in order to recover picture_id.
[ "create", "temporary", "table", "for", "interaction_graphic", "in", "order", "to", "recover", "picture_id", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060200.php#L63-L82
40,532
claroline/Distribution
plugin/exo/Installation/Updater/Updater060200.php
Updater060200.checkDocument
private function checkDocument() { $this->log('Checking document ...'); $checkQuery = ' SELECT * FROM ujm_document '; $results = $this->connection->query($checkQuery)->fetchAll(); foreach ($results as $res) { try { $this->connection->exec(" INSERT INTO ujm_picture_temp VALUES ({$res['id']}, {$res['user_id']}, '" .addslashes($res['label'])."', '" .addslashes($res['url'])."', '" .addslashes($res['type'])."', 0, 0 ) "); } catch (\Exception $e) { $this->log("Picture {$res['id']} already inserted"); } } $this->checkInteractionGraphic(); }
php
private function checkDocument() { $this->log('Checking document ...'); $checkQuery = ' SELECT * FROM ujm_document '; $results = $this->connection->query($checkQuery)->fetchAll(); foreach ($results as $res) { try { $this->connection->exec(" INSERT INTO ujm_picture_temp VALUES ({$res['id']}, {$res['user_id']}, '" .addslashes($res['label'])."', '" .addslashes($res['url'])."', '" .addslashes($res['type'])."', 0, 0 ) "); } catch (\Exception $e) { $this->log("Picture {$res['id']} already inserted"); } } $this->checkInteractionGraphic(); }
[ "private", "function", "checkDocument", "(", ")", "{", "$", "this", "->", "log", "(", "'Checking document ...'", ")", ";", "$", "checkQuery", "=", "'\n SELECT *\n FROM ujm_document\n '", ";", "$", "results", "=", "$", "this", "->", "conn...
recover the questions of an exercise in order to inject in step_question.
[ "recover", "the", "questions", "of", "an", "exercise", "in", "order", "to", "inject", "in", "step_question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060200.php#L87-L114
40,533
claroline/Distribution
plugin/exo/Installation/Updater/Updater060200.php
Updater060200.checkInteractionGraphic
private function checkInteractionGraphic() { $this->log('Checking InteractionGraphic ...'); $checkQuery = ' SELECT id, document_id, width, height FROM ujm_interaction_graphic '; $results = $this->connection->query($checkQuery)->fetchAll(); foreach ($results as $res) { $this->connection->exec(" UPDATE ujm_picture_temp SET width = {$res['width']}, height = {$res['height']} WHERE id = {$res['id']} "); } $this->connection->exec(' UPDATE ujm_interaction_graphic SET document_id = NULL '); }
php
private function checkInteractionGraphic() { $this->log('Checking InteractionGraphic ...'); $checkQuery = ' SELECT id, document_id, width, height FROM ujm_interaction_graphic '; $results = $this->connection->query($checkQuery)->fetchAll(); foreach ($results as $res) { $this->connection->exec(" UPDATE ujm_picture_temp SET width = {$res['width']}, height = {$res['height']} WHERE id = {$res['id']} "); } $this->connection->exec(' UPDATE ujm_interaction_graphic SET document_id = NULL '); }
[ "private", "function", "checkInteractionGraphic", "(", ")", "{", "$", "this", "->", "log", "(", "'Checking InteractionGraphic ...'", ")", ";", "$", "checkQuery", "=", "'\n SELECT id, document_id, width, height\n FROM ujm_interaction_graphic\n '", ";",...
recover the width and height move interaction_graphic -> picture.
[ "recover", "the", "width", "and", "height", "move", "interaction_graphic", "-", ">", "picture", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060200.php#L135-L157
40,534
claroline/Distribution
plugin/exo/Installation/Updater/Updater060200.php
Updater060200.migrateExerciseQuestionData
private function migrateExerciseQuestionData() { $exoId = -1; $orderStep = 1; $exoQuestion = $this->checkExoQuestion(); $stepStmt = $this->connection->prepare(" INSERT INTO ujm_step (exercise_id, value, nbQuestion, keepSameQuestion, shuffle, duration, max_attempts, ordre) VALUES (:exoId, '', 0, FALSE, FALSE, 0, 0, :orderStep) "); foreach ($exoQuestion as $eq) { if ($eq['exercise_id'] !== $exoId) { $exoId = $eq['exercise_id']; } $this->log('Create step ...'); $stepStmt->bindValue('exoId', $exoId); $stepStmt->bindValue('orderStep', $orderStep); $stepStmt->execute(); $stepId = $this->connection->lastInsertId(); $this->addQuestionStep($stepId, $eq['question_id'], 1); ++$orderStep; } }
php
private function migrateExerciseQuestionData() { $exoId = -1; $orderStep = 1; $exoQuestion = $this->checkExoQuestion(); $stepStmt = $this->connection->prepare(" INSERT INTO ujm_step (exercise_id, value, nbQuestion, keepSameQuestion, shuffle, duration, max_attempts, ordre) VALUES (:exoId, '', 0, FALSE, FALSE, 0, 0, :orderStep) "); foreach ($exoQuestion as $eq) { if ($eq['exercise_id'] !== $exoId) { $exoId = $eq['exercise_id']; } $this->log('Create step ...'); $stepStmt->bindValue('exoId', $exoId); $stepStmt->bindValue('orderStep', $orderStep); $stepStmt->execute(); $stepId = $this->connection->lastInsertId(); $this->addQuestionStep($stepId, $eq['question_id'], 1); ++$orderStep; } }
[ "private", "function", "migrateExerciseQuestionData", "(", ")", "{", "$", "exoId", "=", "-", "1", ";", "$", "orderStep", "=", "1", ";", "$", "exoQuestion", "=", "$", "this", "->", "checkExoQuestion", "(", ")", ";", "$", "stepStmt", "=", "$", "this", "-...
Move data exercise_question in step_question.
[ "Move", "data", "exercise_question", "in", "step_question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060200.php#L193-L220
40,535
claroline/Distribution
plugin/exo/Installation/Updater/Updater060200.php
Updater060200.migratePicture
private function migratePicture() { $this->log('UPDATE Picture ...'); $this->connection->exec(' INSERT INTO ujm_picture (id, user_id, `label`, url, type, width, height) SELECT id, user_id, `label`, url, type, width, height FROM ujm_picture_temp '); $this->log('UPDATE interaction_graphic -> picture_id ...'); $query = 'SELECT * FROM ujm_interaction_graphic_temp'; $results = $this->connection->query($query)->fetchAll(); $stmt = $this->connection->prepare(' UPDATE ujm_interaction_graphic SET picture_id = :docId WHERE id = :resId '); foreach ($results as $res) { $stmt->bindValue('docId', $res['document_id']); $stmt->bindValue('resId', $res['id']); $stmt->execute(); } }
php
private function migratePicture() { $this->log('UPDATE Picture ...'); $this->connection->exec(' INSERT INTO ujm_picture (id, user_id, `label`, url, type, width, height) SELECT id, user_id, `label`, url, type, width, height FROM ujm_picture_temp '); $this->log('UPDATE interaction_graphic -> picture_id ...'); $query = 'SELECT * FROM ujm_interaction_graphic_temp'; $results = $this->connection->query($query)->fetchAll(); $stmt = $this->connection->prepare(' UPDATE ujm_interaction_graphic SET picture_id = :docId WHERE id = :resId '); foreach ($results as $res) { $stmt->bindValue('docId', $res['document_id']); $stmt->bindValue('resId', $res['id']); $stmt->execute(); } }
[ "private", "function", "migratePicture", "(", ")", "{", "$", "this", "->", "log", "(", "'UPDATE Picture ...'", ")", ";", "$", "this", "->", "connection", "->", "exec", "(", "'\n INSERT INTO ujm_picture (id, user_id, `label`, url, type, width, height)\n ...
Move data picture_temp in picture.
[ "Move", "data", "picture_temp", "in", "picture", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060200.php#L225-L249
40,536
claroline/Distribution
main/core/Listener/Administration/ParametersListener.php
ParametersListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:parameters.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'availableLocales' => array_keys($this->localeManager->getImplementedLocales()), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:parameters.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'availableLocales' => array_keys($this->localeManager->getImplementedLocales()), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:administration:parameters.html.twig'", ",", "[", "'context'", "=>", "[",...
Displays parameters administration tool. @DI\Observe("administration_tool_main_settings") @param OpenAdministrationToolEvent $event
[ "Displays", "parameters", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/ParametersListener.php#L65-L79
40,537
claroline/Distribution
main/core/Manager/ExporterManager.php
ExporterManager.exportUsers
private function exportUsers($exporter, array $extra) { $dontExport = ['password', 'description', 'salt', 'plainPassword']; if (isset($extra['workspace'])) { $users = $this->om->getRepository('ClarolineCoreBundle:User') ->findAllWithFacetsByWorkspace($extra['workspace']); } else { $users = $this->om->getRepository('ClarolineCoreBundle:User') ->findAllWithFacets(); } $fieldsFacets = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacet')->findAll(); $fields = $this->getExportableFields('Claroline\CoreBundle\Entity\User'); foreach ($fields as $field) { if (in_array($field, $dontExport)) { unset($fields[array_search($field, $fields)]); } } $data = []; $fieldFacetsName = []; foreach ($fieldsFacets as $fieldsFacet) { $fieldFacetsName[] = $fieldsFacet->getName(); } foreach ($users as $user) { $data[$user->getId()] = []; foreach ($fields as $field) { $data[$user->getId()][$field] = $this->formatValue($this->getValueFromObject($user, $field)); } foreach ($fieldFacetsName as $fieldFacetName) { $found = false; foreach ($user->getFieldsFacetValue() as $fieldFacetValue) { if ($fieldFacetValue->getFieldFacet()->getName() === $fieldFacetName) { $found = true; $data[$user->getId()][$fieldFacetName] = $this->formatValue($fieldFacetValue->getValue()); } } if (!$found) { $data[$user->getId()][$fieldFacetName] = null; } } } foreach ($fieldFacetsName as $fieldFacetName) { $fields[] = $fieldFacetName; } return $exporter->export($fields, $data); }
php
private function exportUsers($exporter, array $extra) { $dontExport = ['password', 'description', 'salt', 'plainPassword']; if (isset($extra['workspace'])) { $users = $this->om->getRepository('ClarolineCoreBundle:User') ->findAllWithFacetsByWorkspace($extra['workspace']); } else { $users = $this->om->getRepository('ClarolineCoreBundle:User') ->findAllWithFacets(); } $fieldsFacets = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacet')->findAll(); $fields = $this->getExportableFields('Claroline\CoreBundle\Entity\User'); foreach ($fields as $field) { if (in_array($field, $dontExport)) { unset($fields[array_search($field, $fields)]); } } $data = []; $fieldFacetsName = []; foreach ($fieldsFacets as $fieldsFacet) { $fieldFacetsName[] = $fieldsFacet->getName(); } foreach ($users as $user) { $data[$user->getId()] = []; foreach ($fields as $field) { $data[$user->getId()][$field] = $this->formatValue($this->getValueFromObject($user, $field)); } foreach ($fieldFacetsName as $fieldFacetName) { $found = false; foreach ($user->getFieldsFacetValue() as $fieldFacetValue) { if ($fieldFacetValue->getFieldFacet()->getName() === $fieldFacetName) { $found = true; $data[$user->getId()][$fieldFacetName] = $this->formatValue($fieldFacetValue->getValue()); } } if (!$found) { $data[$user->getId()][$fieldFacetName] = null; } } } foreach ($fieldFacetsName as $fieldFacetName) { $fields[] = $fieldFacetName; } return $exporter->export($fields, $data); }
[ "private", "function", "exportUsers", "(", "$", "exporter", ",", "array", "$", "extra", ")", "{", "$", "dontExport", "=", "[", "'password'", ",", "'description'", ",", "'salt'", ",", "'plainPassword'", "]", ";", "if", "(", "isset", "(", "$", "extra", "["...
We add the facets to the user export.
[ "We", "add", "the", "facets", "to", "the", "user", "export", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ExporterManager.php#L60-L114
40,538
claroline/Distribution
main/core/Library/Installation/OperationExecutor.php
OperationExecutor.buildOperation
private function buildOperation($type, $package) { $vendorDir = $this->kernel->getRootDir().'/../vendor'; $targetDir = $package->getTargetDir() ?: ''; $packageDir = empty($targetDir) ? $package->getPrettyName() : "{$package->getName()}/{$targetDir}"; $fqcn = $this->detector->detectBundle("{$vendorDir}/{$packageDir}"); return new Operation($type, $package, $fqcn); }
php
private function buildOperation($type, $package) { $vendorDir = $this->kernel->getRootDir().'/../vendor'; $targetDir = $package->getTargetDir() ?: ''; $packageDir = empty($targetDir) ? $package->getPrettyName() : "{$package->getName()}/{$targetDir}"; $fqcn = $this->detector->detectBundle("{$vendorDir}/{$packageDir}"); return new Operation($type, $package, $fqcn); }
[ "private", "function", "buildOperation", "(", "$", "type", ",", "$", "package", ")", "{", "$", "vendorDir", "=", "$", "this", "->", "kernel", "->", "getRootDir", "(", ")", ".", "'/../vendor'", ";", "$", "targetDir", "=", "$", "package", "->", "getTargetD...
Composer\Package\PackageInterface but the use causes some issue
[ "Composer", "\\", "Package", "\\", "PackageInterface", "but", "the", "use", "causes", "some", "issue" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Installation/OperationExecutor.php#L356-L366
40,539
claroline/Distribution
plugin/exo/Installation/Updater/Updater090000.php
Updater090000.updatePapers
private function updatePapers() { $this->log('Update Papers structures and hints...'); $oldHints = $this->fetchHints(); $questions = $this->om->getRepository('UJMExoBundle:Item\Item')->findAll(); $decodedQuestions = []; $papers = $this->om->getRepository('UJMExoBundle:Attempt\Paper')->findAll(); $this->om->startFlushSuite(); $this->log(count($papers).' papers to process.'); /** @var Paper $paper */ foreach ($papers as $i => $paper) { // Checks the format of the structure to know if it has already been transformed $structure = $paper->getStructure(); if ('{' !== substr($structure, 0, 1)) { // The structure is not a JSON (this is a little bit hacky) // Update structure $this->updatePaperStructure($paper, $questions, $decodedQuestions); // Update hints $this->updatePaperHints($paper, $oldHints); $this->om->persist($paper); } if (0 === $i % 200) { $this->om->forceFlush(); $this->log('200 papers processed.'); } } $this->om->endFlushSuite(); $this->log('done !'); }
php
private function updatePapers() { $this->log('Update Papers structures and hints...'); $oldHints = $this->fetchHints(); $questions = $this->om->getRepository('UJMExoBundle:Item\Item')->findAll(); $decodedQuestions = []; $papers = $this->om->getRepository('UJMExoBundle:Attempt\Paper')->findAll(); $this->om->startFlushSuite(); $this->log(count($papers).' papers to process.'); /** @var Paper $paper */ foreach ($papers as $i => $paper) { // Checks the format of the structure to know if it has already been transformed $structure = $paper->getStructure(); if ('{' !== substr($structure, 0, 1)) { // The structure is not a JSON (this is a little bit hacky) // Update structure $this->updatePaperStructure($paper, $questions, $decodedQuestions); // Update hints $this->updatePaperHints($paper, $oldHints); $this->om->persist($paper); } if (0 === $i % 200) { $this->om->forceFlush(); $this->log('200 papers processed.'); } } $this->om->endFlushSuite(); $this->log('done !'); }
[ "private", "function", "updatePapers", "(", ")", "{", "$", "this", "->", "log", "(", "'Update Papers structures and hints...'", ")", ";", "$", "oldHints", "=", "$", "this", "->", "fetchHints", "(", ")", ";", "$", "questions", "=", "$", "this", "->", "om", ...
Updates papers data. - Dump the full exercise definition in `structure` - Move hints to answers
[ "Updates", "papers", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater090000.php#L429-L468
40,540
claroline/Distribution
plugin/link/Serializer/ShortcutSerializer.php
ShortcutSerializer.serialize
public function serialize(Shortcut $shortcut, array $options = []) { return [ 'target' => $this->resourceNodeSerializer->serialize($shortcut->getTarget(), array_merge($options, [Options::SERIALIZE_MINIMAL])), ]; }
php
public function serialize(Shortcut $shortcut, array $options = []) { return [ 'target' => $this->resourceNodeSerializer->serialize($shortcut->getTarget(), array_merge($options, [Options::SERIALIZE_MINIMAL])), ]; }
[ "public", "function", "serialize", "(", "Shortcut", "$", "shortcut", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "[", "'target'", "=>", "$", "this", "->", "resourceNodeSerializer", "->", "serialize", "(", "$", "shortcut", "->", "getTar...
Serializes a Shortcut resource entity for the JSON api. @param Shortcut $shortcut @param array $options @return array
[ "Serializes", "a", "Shortcut", "resource", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Serializer/ShortcutSerializer.php#L59-L64
40,541
claroline/Distribution
plugin/link/Serializer/ShortcutSerializer.php
ShortcutSerializer.deserialize
public function deserialize(array $data, Shortcut $shortcut) { if (!empty($data['target']) && !empty($data['target']['id']) && (!$shortcut->getTarget() || $data['target']['id'] !== $shortcut->getTarget()->getUuid()) ) { // the target is specified and as changed /** @var ResourceNode $target */ $target = $this->om ->getRepository('ClarolineCoreBundle:Resource\ResourceNode') ->findOneBy(['uuid' => $data['target']['id']]); $shortcut->setTarget($target); } }
php
public function deserialize(array $data, Shortcut $shortcut) { if (!empty($data['target']) && !empty($data['target']['id']) && (!$shortcut->getTarget() || $data['target']['id'] !== $shortcut->getTarget()->getUuid()) ) { // the target is specified and as changed /** @var ResourceNode $target */ $target = $this->om ->getRepository('ClarolineCoreBundle:Resource\ResourceNode') ->findOneBy(['uuid' => $data['target']['id']]); $shortcut->setTarget($target); } }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Shortcut", "$", "shortcut", ")", "{", "if", "(", "!", "empty", "(", "$", "data", "[", "'target'", "]", ")", "&&", "!", "empty", "(", "$", "data", "[", "'target'", "]", "[", "'id'...
Deserializes shortcut data into an Entity. @param array $data @param Shortcut $shortcut @return Shortcut
[ "Deserializes", "shortcut", "data", "into", "an", "Entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Serializer/ShortcutSerializer.php#L74-L88
40,542
claroline/Distribution
plugin/exo/Validator/JsonSchema/Item/ItemValidator.php
ItemValidator.validateAfterSchema
public function validateAfterSchema($question, array $options = []) { $errors = []; if (empty($question['content'])) { // No blank content $errors[] = [ 'path' => '/content', 'message' => 'Question content can not be empty', ]; } if (!isset($question['score'])) { // No question with no score // this is not in the schema because this will become optional when exercise without scores will be implemented $errors[] = [ 'path' => '/score', 'message' => 'Question score is required', ]; } if (in_array(Validation::REQUIRE_SOLUTIONS, $options) && !isset($question['solutions'])) { // No question without solutions $errors[] = [ 'path' => '/solutions', 'message' => 'Question requires a "solutions" property', ]; } if (!$this->itemDefinitions->has($question['type'])) { $errors[] = [ 'path' => '/type', 'message' => 'Unknown question type "'.$question['type'].'"', ]; } // Validate hints if (isset($question['hints'])) { array_map(function ($hint) use (&$errors, $options) { $errors = array_merge($errors, $this->hintValidator->validateAfterSchema($hint, $options)); }, $question['hints']); } // Validate objects if (isset($question['objects'])) { array_map(function ($object) use (&$errors, $options) { $errors = array_merge($errors, $this->contentValidator->validateAfterSchema($object, $options)); }, $question['objects']); } // Validates specific data of the question type if (empty($errors)) { // Forward to the correct definition $definition = $this->itemDefinitions->get($question['type']); $errors = array_merge( $errors, $definition->validateQuestion($question, array_merge($options, [Validation::NO_SCHEMA])) ); } return $errors; }
php
public function validateAfterSchema($question, array $options = []) { $errors = []; if (empty($question['content'])) { // No blank content $errors[] = [ 'path' => '/content', 'message' => 'Question content can not be empty', ]; } if (!isset($question['score'])) { // No question with no score // this is not in the schema because this will become optional when exercise without scores will be implemented $errors[] = [ 'path' => '/score', 'message' => 'Question score is required', ]; } if (in_array(Validation::REQUIRE_SOLUTIONS, $options) && !isset($question['solutions'])) { // No question without solutions $errors[] = [ 'path' => '/solutions', 'message' => 'Question requires a "solutions" property', ]; } if (!$this->itemDefinitions->has($question['type'])) { $errors[] = [ 'path' => '/type', 'message' => 'Unknown question type "'.$question['type'].'"', ]; } // Validate hints if (isset($question['hints'])) { array_map(function ($hint) use (&$errors, $options) { $errors = array_merge($errors, $this->hintValidator->validateAfterSchema($hint, $options)); }, $question['hints']); } // Validate objects if (isset($question['objects'])) { array_map(function ($object) use (&$errors, $options) { $errors = array_merge($errors, $this->contentValidator->validateAfterSchema($object, $options)); }, $question['objects']); } // Validates specific data of the question type if (empty($errors)) { // Forward to the correct definition $definition = $this->itemDefinitions->get($question['type']); $errors = array_merge( $errors, $definition->validateQuestion($question, array_merge($options, [Validation::NO_SCHEMA])) ); } return $errors; }
[ "public", "function", "validateAfterSchema", "(", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "errors", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "question", "[", "'content'", "]", ")", ")", "{", "// No blank ...
Delegates the validation to the correct question type handler. @param array $question @param array $options @return array
[ "Delegates", "the", "validation", "to", "the", "correct", "question", "type", "handler", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Validator/JsonSchema/Item/ItemValidator.php#L67-L129
40,543
claroline/Distribution
main/core/Listener/CliListener.php
CliListener.setDefaultUser
public function setDefaultUser(ConsoleCommandEvent $event) { $command = $event->getCommand(); if ($command instanceof AdminCliCommand) { $user = $this->userManager->getDefaultClarolineAdmin(); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->tokenStorage->setToken($token); } }
php
public function setDefaultUser(ConsoleCommandEvent $event) { $command = $event->getCommand(); if ($command instanceof AdminCliCommand) { $user = $this->userManager->getDefaultClarolineAdmin(); $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $this->tokenStorage->setToken($token); } }
[ "public", "function", "setDefaultUser", "(", "ConsoleCommandEvent", "$", "event", ")", "{", "$", "command", "=", "$", "event", "->", "getCommand", "(", ")", ";", "if", "(", "$", "command", "instanceof", "AdminCliCommand", ")", "{", "$", "user", "=", "$", ...
Sets claroline default admin for cli because it's very annoying otherwise to do it manually everytime. @DI\Observe("console.command", priority = 17) @param GetResponseEvent $event
[ "Sets", "claroline", "default", "admin", "for", "cli", "because", "it", "s", "very", "annoying", "otherwise", "to", "do", "it", "manually", "everytime", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/CliListener.php#L55-L64
40,544
claroline/Distribution
plugin/collecticiel/Entity/ReturnReceiptType.php
ReturnReceiptType.addReturnreceipt
public function addReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts[] = $returnreceipt; return $this; }
php
public function addReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts[] = $returnreceipt; return $this; }
[ "public", "function", "addReturnreceipt", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ReturnReceipt", "$", "returnreceipt", ")", "{", "$", "this", "->", "returnreceipts", "[", "]", "=", "$", "returnreceipt", ";", "return", "$", "thi...
Add returnreceipt. @param \Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt @return ReturnReceiptType
[ "Add", "returnreceipt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/ReturnReceiptType.php#L90-L95
40,545
claroline/Distribution
plugin/collecticiel/Entity/ReturnReceiptType.php
ReturnReceiptType.removeReturnreceipt
public function removeReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts->removeElement($returnreceipt); }
php
public function removeReturnreceipt(\Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt) { $this->returnreceipts->removeElement($returnreceipt); }
[ "public", "function", "removeReturnreceipt", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ReturnReceipt", "$", "returnreceipt", ")", "{", "$", "this", "->", "returnreceipts", "->", "removeElement", "(", "$", "returnreceipt", ")", ";", ...
Remove returnreceipt. @param \Innova\CollecticielBundle\Entity\ReturnReceipt $returnreceipt
[ "Remove", "returnreceipt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/ReturnReceiptType.php#L102-L105
40,546
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.getTranslatedContent
public function getTranslatedContent(array $filter) { $content = $this->getContent($filter); if ($content instanceof Content) { return $this->translations->findTranslations($content); } }
php
public function getTranslatedContent(array $filter) { $content = $this->getContent($filter); if ($content instanceof Content) { return $this->translations->findTranslations($content); } }
[ "public", "function", "getTranslatedContent", "(", "array", "$", "filter", ")", "{", "$", "content", "=", "$", "this", "->", "getContent", "(", "$", "filter", ")", ";", "if", "(", "$", "content", "instanceof", "Content", ")", "{", "return", "$", "this", ...
Get translated Content. Example: $contentManager->getTranslatedContent(array('id' => $id)); @param array $filter @return array
[ "Get", "translated", "Content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L93-L100
40,547
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.deleteTranslation
public function deleteTranslation($locale, $id) { if ('en' === $locale) { $content = $this->content->findOneBy(['id' => $id]); } else { $content = $this->translations->findOneBy(['foreignKey' => $id, 'locale' => $locale]); } if ($content instanceof ContentTranslation || $content instanceof Content) { $this->manager->remove($content); $this->manager->flush(); } }
php
public function deleteTranslation($locale, $id) { if ('en' === $locale) { $content = $this->content->findOneBy(['id' => $id]); } else { $content = $this->translations->findOneBy(['foreignKey' => $id, 'locale' => $locale]); } if ($content instanceof ContentTranslation || $content instanceof Content) { $this->manager->remove($content); $this->manager->flush(); } }
[ "public", "function", "deleteTranslation", "(", "$", "locale", ",", "$", "id", ")", "{", "if", "(", "'en'", "===", "$", "locale", ")", "{", "$", "content", "=", "$", "this", "->", "content", "->", "findOneBy", "(", "[", "'id'", "=>", "$", "id", "]"...
Delete a translation of content. @param string $locale @param $id
[ "Delete", "a", "translation", "of", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L148-L160
40,548
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.resetContent
private function resetContent(Content $content, array $translatedContents) { foreach ($translatedContents as $lang => $translatedContent) { $this->updateTranslation($content, $translatedContent, $lang, true); } $this->updateTranslation($content, $translatedContents['en']); return $content; }
php
private function resetContent(Content $content, array $translatedContents) { foreach ($translatedContents as $lang => $translatedContent) { $this->updateTranslation($content, $translatedContent, $lang, true); } $this->updateTranslation($content, $translatedContents['en']); return $content; }
[ "private", "function", "resetContent", "(", "Content", "$", "content", ",", "array", "$", "translatedContents", ")", "{", "foreach", "(", "$", "translatedContents", "as", "$", "lang", "=>", "$", "translatedContent", ")", "{", "$", "this", "->", "updateTranslat...
Reset translated values of a content. @param Content $content A content entity @param array $translatedContents array('en' => array('content' => 'foo', 'title' => 'foo')) @return \Claroline\CoreBundle\Entity\Content
[ "Reset", "translated", "values", "of", "a", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L170-L179
40,549
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.updateTranslation
private function updateTranslation(Content $content, $translation, $locale = 'en', $reset = false) { if (isset($translation['title'])) { $content->setTitle(($reset ? null : $translation['title'])); } if (isset($translation['content'])) { $content->setContent(($reset ? null : $translation['content'])); } $content->setTranslatableLocale($locale); $content->setModified(); $this->manager->persist($content); $this->manager->flush(); }
php
private function updateTranslation(Content $content, $translation, $locale = 'en', $reset = false) { if (isset($translation['title'])) { $content->setTitle(($reset ? null : $translation['title'])); } if (isset($translation['content'])) { $content->setContent(($reset ? null : $translation['content'])); } $content->setTranslatableLocale($locale); $content->setModified(); $this->manager->persist($content); $this->manager->flush(); }
[ "private", "function", "updateTranslation", "(", "Content", "$", "content", ",", "$", "translation", ",", "$", "locale", "=", "'en'", ",", "$", "reset", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "translation", "[", "'title'", "]", ")", ")",...
Update a content translation. @param Content $content A content entity @param array $translation array('content' => 'foo', 'title' => 'foo') @param string $locale A string with a locale value as 'en' or 'fr' @param bool $reset A boolean in case of you whant to reset the values of the translation
[ "Update", "a", "content", "translation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L189-L202
40,550
claroline/Distribution
main/core/Manager/ContentManager.php
ContentManager.setDefault
private function setDefault(array $translatedContent, $field, $locale) { if ('en' !== $locale) { if (isset($translatedContent['en'][$field]) && !strlen($translatedContent['en'][$field]) && isset($translatedContent[$locale][$field]) && strlen($translatedContent[$locale][$field])) { $translatedContent['en'][$field] = $translatedContent[$locale][$field]; } } return $translatedContent; }
php
private function setDefault(array $translatedContent, $field, $locale) { if ('en' !== $locale) { if (isset($translatedContent['en'][$field]) && !strlen($translatedContent['en'][$field]) && isset($translatedContent[$locale][$field]) && strlen($translatedContent[$locale][$field])) { $translatedContent['en'][$field] = $translatedContent[$locale][$field]; } } return $translatedContent; }
[ "private", "function", "setDefault", "(", "array", "$", "translatedContent", ",", "$", "field", ",", "$", "locale", ")", "{", "if", "(", "'en'", "!==", "$", "locale", ")", "{", "if", "(", "isset", "(", "$", "translatedContent", "[", "'en'", "]", "[", ...
create_content in another language not longer create this content in the default language, so this function is used for this purpose. @param array $translatedContent array('en' => array('content' => 'foo', 'title' => 'foo')) @param string $field The name of a field as 'title' or 'content' @param string $locale A string with a locale value as 'en' or 'fr' @return array('en' => array('content' => 'foo', 'title' => 'foo'))
[ "create_content", "in", "another", "language", "not", "longer", "create", "this", "content", "in", "the", "default", "language", "so", "this", "function", "is", "used", "for", "this", "purpose", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContentManager.php#L214-L224
40,551
claroline/Distribution
main/core/Controller/AdministrationController.php
AdministrationController.openToolAction
public function openToolAction($toolName) { $tool = $this->toolManager->getAdminToolByName($toolName); if (!$this->authorization->isGranted('OPEN', $tool)) { throw new AccessDeniedException(); } /** @var OpenAdministrationToolEvent $event */ $event = $this->eventDispatcher->dispatch( 'administration_tool_'.$toolName, 'OpenAdministrationTool', ['toolName' => $toolName] ); $this->eventDispatcher->dispatch( 'log', 'Log\LogAdminToolRead', ['toolName' => $toolName] ); return $event->getResponse(); }
php
public function openToolAction($toolName) { $tool = $this->toolManager->getAdminToolByName($toolName); if (!$this->authorization->isGranted('OPEN', $tool)) { throw new AccessDeniedException(); } /** @var OpenAdministrationToolEvent $event */ $event = $this->eventDispatcher->dispatch( 'administration_tool_'.$toolName, 'OpenAdministrationTool', ['toolName' => $toolName] ); $this->eventDispatcher->dispatch( 'log', 'Log\LogAdminToolRead', ['toolName' => $toolName] ); return $event->getResponse(); }
[ "public", "function", "openToolAction", "(", "$", "toolName", ")", "{", "$", "tool", "=", "$", "this", "->", "toolManager", "->", "getAdminToolByName", "(", "$", "toolName", ")", ";", "if", "(", "!", "$", "this", "->", "authorization", "->", "isGranted", ...
Opens an administration tool. @EXT\Route("/open/{toolName}", name="claro_admin_open_tool") @param $toolName @throws AccessDeniedException @return Response
[ "Opens", "an", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/AdministrationController.php#L103-L124
40,552
claroline/Distribution
plugin/favourite/Manager/FavouriteManager.php
FavouriteManager.createFavourite
public function createFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (empty($favourite)) { $favourite = new Favourite(); $favourite->setUser($user); $favourite->setResourceNode($resourceNode); $this->om->persist($favourite); $this->om->flush(); } }
php
public function createFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (empty($favourite)) { $favourite = new Favourite(); $favourite->setUser($user); $favourite->setResourceNode($resourceNode); $this->om->persist($favourite); $this->om->flush(); } }
[ "public", "function", "createFavourite", "(", "User", "$", "user", ",", "ResourceNode", "$", "resourceNode", ")", "{", "$", "favourite", "=", "$", "this", "->", "repo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "user", ",", "'resourceNode'", "=>", ...
Creates a favourite for given user and resource. @param User $user @param ResourceNode $resourceNode
[ "Creates", "a", "favourite", "for", "given", "user", "and", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/favourite/Manager/FavouriteManager.php#L95-L106
40,553
claroline/Distribution
plugin/favourite/Manager/FavouriteManager.php
FavouriteManager.deleteFavourite
public function deleteFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (!empty($favourite)) { $this->om->remove($favourite); $this->om->flush(); } }
php
public function deleteFavourite(User $user, ResourceNode $resourceNode) { $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]); if (!empty($favourite)) { $this->om->remove($favourite); $this->om->flush(); } }
[ "public", "function", "deleteFavourite", "(", "User", "$", "user", ",", "ResourceNode", "$", "resourceNode", ")", "{", "$", "favourite", "=", "$", "this", "->", "repo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "user", ",", "'resourceNode'", "=>", ...
Deletes favourite for given user and resource. @param User $user @param ResourceNode $resourceNode
[ "Deletes", "favourite", "for", "given", "user", "and", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/favourite/Manager/FavouriteManager.php#L114-L122
40,554
claroline/Distribution
plugin/announcement/Manager/AnnouncementManager.php
AnnouncementManager.sendMessage
public function sendMessage(Announcement $announcement, array $users = []) { $message = $this->getMessage($announcement, $users); $announcementSend = new AnnouncementSend(); $data = $message; $data['receivers'] = array_map(function (User $receiver) { return $receiver->getUsername(); }, $message['receivers']); $data['sender'] = $message['sender']->getUsername(); $announcementSend->setAnnouncement($announcement); $announcementSend->setData($data); $this->om->persist($announcementSend); $this->om->flush(); $this->eventDispatcher->dispatch( 'claroline_message_sending_to_users', 'SendMessage', [ $message['sender'], $message['content'], $message['object'], null, $message['receivers'], ] ); }
php
public function sendMessage(Announcement $announcement, array $users = []) { $message = $this->getMessage($announcement, $users); $announcementSend = new AnnouncementSend(); $data = $message; $data['receivers'] = array_map(function (User $receiver) { return $receiver->getUsername(); }, $message['receivers']); $data['sender'] = $message['sender']->getUsername(); $announcementSend->setAnnouncement($announcement); $announcementSend->setData($data); $this->om->persist($announcementSend); $this->om->flush(); $this->eventDispatcher->dispatch( 'claroline_message_sending_to_users', 'SendMessage', [ $message['sender'], $message['content'], $message['object'], null, $message['receivers'], ] ); }
[ "public", "function", "sendMessage", "(", "Announcement", "$", "announcement", ",", "array", "$", "users", "=", "[", "]", ")", "{", "$", "message", "=", "$", "this", "->", "getMessage", "(", "$", "announcement", ",", "$", "users", ")", ";", "$", "annou...
Sends an Announcement by message to Users that can access it. @param Announcement $announcement @param array $users
[ "Sends", "an", "Announcement", "by", "message", "to", "Users", "that", "can", "access", "it", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/announcement/Manager/AnnouncementManager.php#L145-L171
40,555
claroline/Distribution
plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php
AbstractScormManifest.dump
public function dump() { // Create a new XML document $document = new \DOMDocument('1.0', 'utf-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $document->loadXML($this->xml->asXML()); return $document->saveXML(); }
php
public function dump() { // Create a new XML document $document = new \DOMDocument('1.0', 'utf-8'); $document->preserveWhiteSpace = false; $document->formatOutput = true; $document->loadXML($this->xml->asXML()); return $document->saveXML(); }
[ "public", "function", "dump", "(", ")", "{", "// Create a new XML document", "$", "document", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "document", "->", "preserveWhiteSpace", "=", "false", ";", "$", "document", "->", "for...
Dump manifest structure into a XML string. @return string
[ "Dump", "manifest", "structure", "into", "a", "XML", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php#L56-L65
40,556
claroline/Distribution
plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php
AbstractScormManifest.addMetadata
protected function addMetadata() { $metadata = $this->xml->addChild('metadata'); $metadata->addChild('schema', 'ADL SCORM'); $metadata->addChild('schemaversion', $this->getSchemaVersion()); return $metadata; }
php
protected function addMetadata() { $metadata = $this->xml->addChild('metadata'); $metadata->addChild('schema', 'ADL SCORM'); $metadata->addChild('schemaversion', $this->getSchemaVersion()); return $metadata; }
[ "protected", "function", "addMetadata", "(", ")", "{", "$", "metadata", "=", "$", "this", "->", "xml", "->", "addChild", "(", "'metadata'", ")", ";", "$", "metadata", "->", "addChild", "(", "'schema'", ",", "'ADL SCORM'", ")", ";", "$", "metadata", "->",...
Add metadata node to the manifest. @return \SimpleXMLElement
[ "Add", "metadata", "node", "to", "the", "manifest", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Library/Export/Manifest/AbstractScormManifest.php#L72-L79
40,557
claroline/Distribution
plugin/video-player/Serializer/TrackSerializer.php
TrackSerializer.deserialize
public function deserialize($data, Track $track) { if (empty($track)) { $track = new Track(); } $track->setUuid($data['id']); $video = $this->fileRepo->findOneBy(['id' => $data['video']['id']]); $track->setVideo($video); $this->sipe('meta.label', 'setLabel', $data, $track); $this->sipe('meta.lang', 'setLang', $data, $track); $this->sipe('meta.kind', 'setKind', $data, $track); $this->sipe('meta.default', 'setIsDefault', $data, $track); if (isset($data['file'])) { $trackFile = $this->fileManager->create( new File(), $data['file'], $data['file']->getClientOriginalName(), $data['file']->getMimeType(), $video->getResourceNode()->getWorkspace() ); $this->om->persist($trackFile); $track->setTrackFile($trackFile); } return $track; }
php
public function deserialize($data, Track $track) { if (empty($track)) { $track = new Track(); } $track->setUuid($data['id']); $video = $this->fileRepo->findOneBy(['id' => $data['video']['id']]); $track->setVideo($video); $this->sipe('meta.label', 'setLabel', $data, $track); $this->sipe('meta.lang', 'setLang', $data, $track); $this->sipe('meta.kind', 'setKind', $data, $track); $this->sipe('meta.default', 'setIsDefault', $data, $track); if (isset($data['file'])) { $trackFile = $this->fileManager->create( new File(), $data['file'], $data['file']->getClientOriginalName(), $data['file']->getMimeType(), $video->getResourceNode()->getWorkspace() ); $this->om->persist($trackFile); $track->setTrackFile($trackFile); } return $track; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "Track", "$", "track", ")", "{", "if", "(", "empty", "(", "$", "track", ")", ")", "{", "$", "track", "=", "new", "Track", "(", ")", ";", "}", "$", "track", "->", "setUuid", "(", "$", "...
Deserializes data into a Track entity. @param \stdClass $data @param Track $track @return Track
[ "Deserializes", "data", "into", "a", "Track", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/video-player/Serializer/TrackSerializer.php#L95-L121
40,558
claroline/Distribution
main/core/Twig/HomeExtension.php
HomeExtension.autoLink
public function autoLink($text) { $rexProtocol = '(https?://)?'; $rexDomain = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})'; $rexPort = '(:[0-9]{1,5})?'; $rexPath = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?'; $rexQuery = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $text = preg_replace_callback( "&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&", function ($match) { // Prepend http:// if no protocol specified $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}"; return '<a href="'.$completeUrl.'" target="_blank">' .$match[2].$match[3].$match[4].'</a>'; }, htmlspecialchars($text) ); return $text; }
php
public function autoLink($text) { $rexProtocol = '(https?://)?'; $rexDomain = '((?:[-a-zA-Z0-9]{1,63}\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\.){3}[0-9]{1,3})'; $rexPort = '(:[0-9]{1,5})?'; $rexPath = '(/[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]*?)?'; $rexQuery = '(\?[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $rexFragment = '(#[!$-/0-9:;=@_\':;!a-zA-Z\x7f-\xff]+?)?'; $text = preg_replace_callback( "&\\b$rexProtocol$rexDomain$rexPort$rexPath$rexQuery$rexFragment(?=[?.!,;:\"]?(\s|$))&", function ($match) { // Prepend http:// if no protocol specified $completeUrl = $match[1] ? $match[0] : "http://{$match[0]}"; return '<a href="'.$completeUrl.'" target="_blank">' .$match[2].$match[3].$match[4].'</a>'; }, htmlspecialchars($text) ); return $text; }
[ "public", "function", "autoLink", "(", "$", "text", ")", "{", "$", "rexProtocol", "=", "'(https?://)?'", ";", "$", "rexDomain", "=", "'((?:[-a-zA-Z0-9]{1,63}\\.)+[-a-zA-Z0-9]{2,63}|(?:[0-9]{1,3}\\.){3}[0-9]{1,3})'", ";", "$", "rexPort", "=", "'(:[0-9]{1,5})?'", ";", "$"...
Find links in a text and made it clickable.
[ "Find", "links", "in", "a", "text", "and", "made", "it", "clickable", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Twig/HomeExtension.php#L201-L223
40,559
claroline/Distribution
main/app/JVal/Context.php
Context.getCurrentPath
public function getCurrentPath() { $this->pathSegments = array_slice($this->pathSegments, 0, $this->pathLength); return $this->pathLength ? '/'.implode('/', $this->pathSegments) : ''; }
php
public function getCurrentPath() { $this->pathSegments = array_slice($this->pathSegments, 0, $this->pathLength); return $this->pathLength ? '/'.implode('/', $this->pathSegments) : ''; }
[ "public", "function", "getCurrentPath", "(", ")", "{", "$", "this", "->", "pathSegments", "=", "array_slice", "(", "$", "this", "->", "pathSegments", ",", "0", ",", "$", "this", "->", "pathLength", ")", ";", "return", "$", "this", "->", "pathLength", "?"...
Returns the path of the current node. @return string
[ "Returns", "the", "path", "of", "the", "current", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/JVal/Context.php#L75-L80
40,560
claroline/Distribution
plugin/dropzone/Repository/DropRepository.php
DropRepository.isUnlockedDrop
public function isUnlockedDrop($dropzoneId, $userId) { $qb = $this->createQueryBuilder('drop') ->select('drop.unlockedUser') ->andWhere('drop.dropzone = :dropzone') ->andWhere('drop.user = :user') ->setParameter('dropzone', $dropzoneId) ->setParameter('user', $userId); $isUnlockedDrop = $qb->getQuery()->getOneOrNullResult(); return $isUnlockedDrop; }
php
public function isUnlockedDrop($dropzoneId, $userId) { $qb = $this->createQueryBuilder('drop') ->select('drop.unlockedUser') ->andWhere('drop.dropzone = :dropzone') ->andWhere('drop.user = :user') ->setParameter('dropzone', $dropzoneId) ->setParameter('user', $userId); $isUnlockedDrop = $qb->getQuery()->getOneOrNullResult(); return $isUnlockedDrop; }
[ "public", "function", "isUnlockedDrop", "(", "$", "dropzoneId", ",", "$", "userId", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'drop'", ")", "->", "select", "(", "'drop.unlockedUser'", ")", "->", "andWhere", "(", "'drop.dropzone...
Return if user was unlocked ( no need to make the required corrections todo Why not in a user super class ? @param $dropzoneId @param $userId @return array
[ "Return", "if", "user", "was", "unlocked", "(", "no", "need", "to", "make", "the", "required", "corrections", "todo", "Why", "not", "in", "a", "user", "super", "class", "?" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Repository/DropRepository.php#L82-L93
40,561
claroline/Distribution
plugin/dropzone/Repository/DropRepository.php
DropRepository.closeUnTerminatedDropsByDropzone
public function closeUnTerminatedDropsByDropzone($dropzoneId) { $qb = $this->createQueryBuilder('drop') ->update('Icap\\DropzoneBundle\\Entity\\Drop', 'd') ->set('d.autoClosedDrop', 1) ->set('d.finished', 1) ->andWhere('d.dropzone = :dropzoneId') ->andWhere('d.finished = 0') ->setParameter('dropzoneId', $dropzoneId); $qb->getQuery()->execute(); }
php
public function closeUnTerminatedDropsByDropzone($dropzoneId) { $qb = $this->createQueryBuilder('drop') ->update('Icap\\DropzoneBundle\\Entity\\Drop', 'd') ->set('d.autoClosedDrop', 1) ->set('d.finished', 1) ->andWhere('d.dropzone = :dropzoneId') ->andWhere('d.finished = 0') ->setParameter('dropzoneId', $dropzoneId); $qb->getQuery()->execute(); }
[ "public", "function", "closeUnTerminatedDropsByDropzone", "(", "$", "dropzoneId", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'drop'", ")", "->", "update", "(", "'Icap\\\\DropzoneBundle\\\\Entity\\\\Drop'", ",", "'d'", ")", "->", "set"...
Close unclosed drops in a dropzone. @param $dropzoneId
[ "Close", "unclosed", "drops", "in", "a", "dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Repository/DropRepository.php#L417-L427
40,562
claroline/Distribution
plugin/exo/Controller/Api/Item/ShareController.php
ShareController.shareAction
public function shareAction(Request $request, User $user) { $errors = []; $data = $this->decodeRequestData($request); if (empty($data)) { $errors[] = [ 'path' => '', 'message' => 'Invalid JSON data.', ]; } else { try { $this->shareManager->share($data, $user); } catch (InvalidDataException $e) { $errors = $e->getErrors(); } } if (!empty($errors)) { return new JsonResponse($errors, 422); } else { return new JsonResponse(null, 201); } }
php
public function shareAction(Request $request, User $user) { $errors = []; $data = $this->decodeRequestData($request); if (empty($data)) { $errors[] = [ 'path' => '', 'message' => 'Invalid JSON data.', ]; } else { try { $this->shareManager->share($data, $user); } catch (InvalidDataException $e) { $errors = $e->getErrors(); } } if (!empty($errors)) { return new JsonResponse($errors, 422); } else { return new JsonResponse(null, 201); } }
[ "public", "function", "shareAction", "(", "Request", "$", "request", ",", "User", "$", "user", ")", "{", "$", "errors", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "decodeRequestData", "(", "$", "request", ")", ";", "if", "(", "empty", ...
Shares a list of questions to users. @EXT\Route("", name="questions_share") @EXT\Method("POST") @EXT\ParamConverter("user", converter="current_user") @param Request $request @param User $user @return JsonResponse
[ "Shares", "a", "list", "of", "questions", "to", "users", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ShareController.php#L74-L97
40,563
claroline/Distribution
plugin/exo/Controller/Api/Item/ShareController.php
ShareController.searchUsers
public function searchUsers($search) { $users = $this->userRepository->findByName($search); return new JsonResponse(array_map(function (User $user) { return $this->userSerializer->serialize($user); }, $users)); }
php
public function searchUsers($search) { $users = $this->userRepository->findByName($search); return new JsonResponse(array_map(function (User $user) { return $this->userSerializer->serialize($user); }, $users)); }
[ "public", "function", "searchUsers", "(", "$", "search", ")", "{", "$", "users", "=", "$", "this", "->", "userRepository", "->", "findByName", "(", "$", "search", ")", ";", "return", "new", "JsonResponse", "(", "array_map", "(", "function", "(", "User", ...
Searches users by username, first or last name. @EXT\Route("/{search}", name="questions_share_users") @EXT\Method("GET") @param string $search @return JsonResponse
[ "Searches", "users", "by", "username", "first", "or", "last", "name", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Controller/Api/Item/ShareController.php#L133-L140
40,564
claroline/Distribution
plugin/web-resource/Installation/Updater/Updater120000.php
Updater120000.updateWebResourceFilePath
private function updateWebResourceFilePath() { $this->log('Update resourceWeb file path ...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $resourceType = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceType')->findOneBy(['name' => 'claroline_web_resource']); $resourceNodes = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceNode')->findBy(['resourceType' => $resourceType]); $resourceManager = $this->container->get('claroline.manager.resource_manager'); $fs = $this->container->get('filesystem'); foreach ($resourceNodes as $resourceNode) { $file = $resourceManager->getResourceFromNode($resourceNode); $workspace = $resourceNode->getWorkspace(); if (!empty($file)) { $hash = $file->getHashName(); $uploadDir = $this->container->getParameter('claroline.param.uploads_directory'); $filesDir = $this->container->getParameter('claroline.param.files_directory'); if ($fs->exists($filesDir.DIRECTORY_SEPARATOR.$hash)) { $fs->copy($filesDir.DIRECTORY_SEPARATOR.$hash, $filesDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($filesDir.DIRECTORY_SEPARATOR.$hash); } if ($fs->exists($uploadDir.DIRECTORY_SEPARATOR.$hash)) { $fs->mirror($uploadDir.DIRECTORY_SEPARATOR.$hash, $uploadDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($uploadDir.DIRECTORY_SEPARATOR.$hash); } } } }
php
private function updateWebResourceFilePath() { $this->log('Update resourceWeb file path ...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $resourceType = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceType')->findOneBy(['name' => 'claroline_web_resource']); $resourceNodes = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceNode')->findBy(['resourceType' => $resourceType]); $resourceManager = $this->container->get('claroline.manager.resource_manager'); $fs = $this->container->get('filesystem'); foreach ($resourceNodes as $resourceNode) { $file = $resourceManager->getResourceFromNode($resourceNode); $workspace = $resourceNode->getWorkspace(); if (!empty($file)) { $hash = $file->getHashName(); $uploadDir = $this->container->getParameter('claroline.param.uploads_directory'); $filesDir = $this->container->getParameter('claroline.param.files_directory'); if ($fs->exists($filesDir.DIRECTORY_SEPARATOR.$hash)) { $fs->copy($filesDir.DIRECTORY_SEPARATOR.$hash, $filesDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($filesDir.DIRECTORY_SEPARATOR.$hash); } if ($fs->exists($uploadDir.DIRECTORY_SEPARATOR.$hash)) { $fs->mirror($uploadDir.DIRECTORY_SEPARATOR.$hash, $uploadDir.DIRECTORY_SEPARATOR.'webresource'.DIRECTORY_SEPARATOR.$workspace->getUuid().DIRECTORY_SEPARATOR.$hash); $fs->remove($uploadDir.DIRECTORY_SEPARATOR.$hash); } } } }
[ "private", "function", "updateWebResourceFilePath", "(", ")", "{", "$", "this", "->", "log", "(", "'Update resourceWeb file path ...'", ")", ";", "/** @var ObjectManager $om */", "$", "om", "=", "$", "this", "->", "container", "->", "get", "(", "'claroline.persisten...
Update file path.
[ "Update", "file", "path", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/web-resource/Installation/Updater/Updater120000.php#L27-L58
40,565
claroline/Distribution
main/core/Controller/APINew/Tool/Workspace/LogController.php
LogController.getWorkspaceFilteredQuery
private function getWorkspaceFilteredQuery(Request $request, Workspace $workspace) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['workspace' => $workspace]); return $query; }
php
private function getWorkspaceFilteredQuery(Request $request, Workspace $workspace) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['workspace' => $workspace]); return $query; }
[ "private", "function", "getWorkspaceFilteredQuery", "(", "Request", "$", "request", ",", "Workspace", "$", "workspace", ")", "{", "$", "query", "=", "$", "request", "->", "query", "->", "all", "(", ")", ";", "$", "hiddenFilters", "=", "isset", "(", "$", ...
Add workspace filter to request. @param Request $request @param Workspace $workspace @return array
[ "Add", "workspace", "filter", "to", "request", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Tool/Workspace/LogController.php#L237-L244
40,566
claroline/Distribution
plugin/exo/Entity/ItemType/GraphicQuestion.php
GraphicQuestion.addArea
public function addArea(Area $area) { if (!$this->areas->contains($area)) { $this->areas->add($area); $area->setInteractionGraphic($this); } }
php
public function addArea(Area $area) { if (!$this->areas->contains($area)) { $this->areas->add($area); $area->setInteractionGraphic($this); } }
[ "public", "function", "addArea", "(", "Area", "$", "area", ")", "{", "if", "(", "!", "$", "this", "->", "areas", "->", "contains", "(", "$", "area", ")", ")", "{", "$", "this", "->", "areas", "->", "add", "(", "$", "area", ")", ";", "$", "area"...
Adds an area. @param Area $area
[ "Adds", "an", "area", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/GraphicQuestion.php#L88-L94
40,567
claroline/Distribution
plugin/exo/Entity/ItemType/GraphicQuestion.php
GraphicQuestion.removeArea
public function removeArea(Area $area) { if ($this->areas->contains($area)) { $this->areas->removeElement($area); } }
php
public function removeArea(Area $area) { if ($this->areas->contains($area)) { $this->areas->removeElement($area); } }
[ "public", "function", "removeArea", "(", "Area", "$", "area", ")", "{", "if", "(", "$", "this", "->", "areas", "->", "contains", "(", "$", "area", ")", ")", "{", "$", "this", "->", "areas", "->", "removeElement", "(", "$", "area", ")", ";", "}", ...
Removes an area. @param Area $area
[ "Removes", "an", "area", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/GraphicQuestion.php#L101-L106
40,568
claroline/Distribution
plugin/claco-form/Serializer/FieldValueSerializer.php
FieldValueSerializer.serialize
public function serialize(FieldValue $fieldValue, array $options = []) { $serialized = [ 'id' => $fieldValue->getUuid(), ]; if (in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'field' => [ 'id' => $fieldValue->getField()->getUuid(), ], 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } else { $serialized = array_merge($serialized, [ 'field' => $this->fieldSerializer->serialize($fieldValue->getField(), [Options::SERIALIZE_MINIMAL]), 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } return $serialized; }
php
public function serialize(FieldValue $fieldValue, array $options = []) { $serialized = [ 'id' => $fieldValue->getUuid(), ]; if (in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'field' => [ 'id' => $fieldValue->getField()->getUuid(), ], 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } else { $serialized = array_merge($serialized, [ 'field' => $this->fieldSerializer->serialize($fieldValue->getField(), [Options::SERIALIZE_MINIMAL]), 'fieldFacetValue' => $this->fieldFacetValueSerializer->serialize($fieldValue->getFieldFacetValue(), ['minimal']), ]); } return $serialized; }
[ "public", "function", "serialize", "(", "FieldValue", "$", "fieldValue", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "fieldValue", "->", "getUuid", "(", ")", ",", "]", ";", "if", "(", "in_arr...
Serializes a FieldValue entity for the JSON api. @param FieldValue $fieldValue - the field value to serialize @param array $options - a list of serialization options @return array - the serialized representation of the field value
[ "Serializes", "a", "FieldValue", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/FieldValueSerializer.php#L49-L70
40,569
claroline/Distribution
main/core/Controller/APINew/Model/HasGroupsTrait.php
HasGroupsTrait.addGroupsAction
public function addGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_ADD, $groups); return new JsonResponse( $this->serializer->serialize($object) ); }
php
public function addGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_ADD, $groups); return new JsonResponse( $this->serializer->serialize($object) ); }
[ "public", "function", "addGroupsAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "groups", "=", "$", "this", "->...
Adds groups to the collection. @EXT\Route("/{id}/group") @EXT\Method("PATCH") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Adds", "groups", "to", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasGroupsTrait.php#L49-L58
40,570
claroline/Distribution
main/core/Controller/APINew/Model/HasGroupsTrait.php
HasGroupsTrait.removeGroupsAction
public function removeGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_REMOVE, $groups); return new JsonResponse($this->serializer->serialize($object)); }
php
public function removeGroupsAction($id, $class, Request $request) { $object = $this->find($class, $id); $groups = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Group'); $this->crud->patch($object, 'group', Crud::COLLECTION_REMOVE, $groups); return new JsonResponse($this->serializer->serialize($object)); }
[ "public", "function", "removeGroupsAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "groups", "=", "$", "this", ...
Removes groups from the collection. @EXT\Route("/{id}/group") @EXT\Method("DELETE") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Removes", "groups", "from", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasGroupsTrait.php#L72-L79
40,571
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.addDocument
public function addDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents[] = $documents; return $this; }
php
public function addDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents[] = $documents; return $this; }
[ "public", "function", "addDocument", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Document", "$", "documents", ")", "{", "$", "this", "->", "documents", "[", "]", "=", "$", "documents", ";", "return", "$", "this", ";", "}" ]
Add documents. @param \Innova\CollecticielBundle\Entity\Document $documents @return Drop
[ "Add", "documents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L434-L439
40,572
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.removeDocument
public function removeDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents->removeElement($documents); }
php
public function removeDocument(\Innova\CollecticielBundle\Entity\Document $documents) { $this->documents->removeElement($documents); }
[ "public", "function", "removeDocument", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Document", "$", "documents", ")", "{", "$", "this", "->", "documents", "->", "removeElement", "(", "$", "documents", ")", ";", "}" ]
Remove documents. @param \Innova\CollecticielBundle\Entity\Document $documents
[ "Remove", "documents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L446-L449
40,573
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.addCorrection
public function addCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections[] = $corrections; return $this; }
php
public function addCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections[] = $corrections; return $this; }
[ "public", "function", "addCorrection", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Correction", "$", "corrections", ")", "{", "$", "this", "->", "corrections", "[", "]", "=", "$", "corrections", ";", "return", "$", "this", ";", ...
Add corrections. @param \Innova\CollecticielBundle\Entity\Correction $corrections @return Drop
[ "Add", "corrections", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L458-L463
40,574
claroline/Distribution
plugin/collecticiel/Entity/Drop.php
Drop.removeCorrection
public function removeCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections->removeElement($corrections); }
php
public function removeCorrection(\Innova\CollecticielBundle\Entity\Correction $corrections) { $this->corrections->removeElement($corrections); }
[ "public", "function", "removeCorrection", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Correction", "$", "corrections", ")", "{", "$", "this", "->", "corrections", "->", "removeElement", "(", "$", "corrections", ")", ";", "}" ]
Remove corrections. @param \Innova\CollecticielBundle\Entity\Correction $corrections
[ "Remove", "corrections", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Drop.php#L470-L473
40,575
claroline/Distribution
plugin/path/Installation/Updater/Updater120000.php
Updater120000.initializeResourceEvaluationProgression
private function initializeResourceEvaluationProgression() { $this->log('Initializing progression of path evaluations...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $paths = $om->getRepository('Innova\PathBundle\Entity\Path\Path')->findAll(); $om->startFlushSuite(); $i = 0; foreach ($paths as $path) { $node = $path->getResourceNode(); $userEvals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceUserEvaluation') ->findBy(['resourceNode' => $node]); foreach ($userEvals as $userEval) { $userEvalScore = $userEval->getScore(); $userEvalScoreMax = $userEval->getScoreMax(); if (is_null($userEval->getProgression()) && !is_null($userEvalScore) && !empty($userEvalScoreMax)) { $progression = intval(($userEvalScore / $userEvalScoreMax) * 100); $userEval->setProgression($progression); $om->persist($userEval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } $evals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceEvaluation') ->findBy(['resourceUserEvaluation' => $userEval]); foreach ($evals as $eval) { $evalScore = $eval->getScore(); $evalScoreMax = $eval->getScoreMax(); if (is_null($eval->getProgression()) && !is_null($evalScore) && !empty($evalScoreMax)) { $progression = intval(($evalScore / $evalScoreMax) * 100); $eval->setProgression($progression); $om->persist($eval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } } } } $om->endFlushSuite(); }
php
private function initializeResourceEvaluationProgression() { $this->log('Initializing progression of path evaluations...'); /** @var ObjectManager $om */ $om = $this->container->get('claroline.persistence.object_manager'); $paths = $om->getRepository('Innova\PathBundle\Entity\Path\Path')->findAll(); $om->startFlushSuite(); $i = 0; foreach ($paths as $path) { $node = $path->getResourceNode(); $userEvals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceUserEvaluation') ->findBy(['resourceNode' => $node]); foreach ($userEvals as $userEval) { $userEvalScore = $userEval->getScore(); $userEvalScoreMax = $userEval->getScoreMax(); if (is_null($userEval->getProgression()) && !is_null($userEvalScore) && !empty($userEvalScoreMax)) { $progression = intval(($userEvalScore / $userEvalScoreMax) * 100); $userEval->setProgression($progression); $om->persist($userEval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } $evals = $om->getRepository('Claroline\CoreBundle\Entity\Resource\ResourceEvaluation') ->findBy(['resourceUserEvaluation' => $userEval]); foreach ($evals as $eval) { $evalScore = $eval->getScore(); $evalScoreMax = $eval->getScoreMax(); if (is_null($eval->getProgression()) && !is_null($evalScore) && !empty($evalScoreMax)) { $progression = intval(($evalScore / $evalScoreMax) * 100); $eval->setProgression($progression); $om->persist($eval); ++$i; if (0 === $i % 250) { $om->forceFlush(); } } } } } $om->endFlushSuite(); }
[ "private", "function", "initializeResourceEvaluationProgression", "(", ")", "{", "$", "this", "->", "log", "(", "'Initializing progression of path evaluations...'", ")", ";", "/** @var ObjectManager $om */", "$", "om", "=", "$", "this", "->", "container", "->", "get", ...
Initializes progression of path evaluation.
[ "Initializes", "progression", "of", "path", "evaluation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Installation/Updater/Updater120000.php#L33-L85
40,576
claroline/Distribution
main/core/Form/Handler/FormHandler.php
FormHandler.isValid
public function isValid($formReference, Request $request, $data = null, array $options = []) { $form = $this->getForm($formReference, $data, $options); $form->handleRequest($request); return $form->isValid(); }
php
public function isValid($formReference, Request $request, $data = null, array $options = []) { $form = $this->getForm($formReference, $data, $options); $form->handleRequest($request); return $form->isValid(); }
[ "public", "function", "isValid", "(", "$", "formReference", ",", "Request", "$", "request", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "form", "=", "$", "this", "->", "getForm", "(", "$", "formReference...
Returns whether a form is valid and stores it internally for future use. @param string $formReference The form type name @param Request $request The request to be bound @param mixed $data An entity or array to be bound @param array $options The options to be passed to the form builder @return bool
[ "Returns", "whether", "a", "form", "is", "valid", "and", "stores", "it", "internally", "for", "future", "use", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Form/Handler/FormHandler.php#L42-L48
40,577
claroline/Distribution
main/core/Form/Handler/FormHandler.php
FormHandler.getView
public function getView($formReference = null, $data = null, array $options = []) { if ($formReference) { $this->getForm($formReference, $data, $options); } return $this->getCurrentForm()->createView(); }
php
public function getView($formReference = null, $data = null, array $options = []) { if ($formReference) { $this->getForm($formReference, $data, $options); } return $this->getCurrentForm()->createView(); }
[ "public", "function", "getView", "(", "$", "formReference", "=", "null", ",", "$", "data", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "formReference", ")", "{", "$", "this", "->", "getForm", "(", "$", "formR...
Creates and returns a form view either from the current form or from a new form type reference passed as argument. @param string $formReference The form type name @param mixed $data An entity or array to be bound @param array $options The options to be passed to the form builder @return mixed @throws \LogicException if no reference is passed and no form has been handled yet
[ "Creates", "and", "returns", "a", "form", "view", "either", "from", "the", "current", "form", "or", "from", "a", "new", "form", "type", "reference", "passed", "as", "argument", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Form/Handler/FormHandler.php#L75-L82
40,578
claroline/Distribution
plugin/forum/Listener/Resource/ForumListener.php
ForumListener.onOpen
public function onOpen(LoadResourceEvent $event) { $forum = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isValidatedUser = false; if ('anon.' !== $user) { $validationUser = $this->manager->getValidationUser($user, $forum); $isValidatedUser = $validationUser->getAccess(); } $event->setData([ 'forum' => $this->serializer->serialize($forum), 'isValidatedUser' => $isValidatedUser, ]); $event->stopPropagation(); }
php
public function onOpen(LoadResourceEvent $event) { $forum = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isValidatedUser = false; if ('anon.' !== $user) { $validationUser = $this->manager->getValidationUser($user, $forum); $isValidatedUser = $validationUser->getAccess(); } $event->setData([ 'forum' => $this->serializer->serialize($forum), 'isValidatedUser' => $isValidatedUser, ]); $event->stopPropagation(); }
[ "public", "function", "onOpen", "(", "LoadResourceEvent", "$", "event", ")", "{", "$", "forum", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "("...
Loads a Forum resource. @DI\Observe("resource.claroline_forum.load") @param LoadResourceEvent $event
[ "Loads", "a", "Forum", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/forum/Listener/Resource/ForumListener.php#L95-L112
40,579
claroline/Distribution
main/authentication/Listener/Cas/ApiListener.php
ApiListener.onSerialize
public function onSerialize(DecorateUserEvent $event) { $casUserId = $this->casManager->getCasUserIdByUserId($event->getUser()->getId()); $event->add('cas_data', [ 'id' => $casUserId, ]); }
php
public function onSerialize(DecorateUserEvent $event) { $casUserId = $this->casManager->getCasUserIdByUserId($event->getUser()->getId()); $event->add('cas_data', [ 'id' => $casUserId, ]); }
[ "public", "function", "onSerialize", "(", "DecorateUserEvent", "$", "event", ")", "{", "$", "casUserId", "=", "$", "this", "->", "casManager", "->", "getCasUserIdByUserId", "(", "$", "event", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", ";", ...
Add CAS ID to serialized user. @param DecorateUserEvent $event @DI\Observe("serialize_user")
[ "Add", "CAS", "ID", "to", "serialized", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/authentication/Listener/Cas/ApiListener.php#L39-L46
40,580
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.showAction
public function showAction($id, User $currentUser = null) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // TODO : not pretty, but might want on some case to download files instead ? // TODO : find a way to do it in the link plugin if ('shortcut' === $resourceNode->getResourceType()->getName()) { $shortcut = $this->manager->getResourceFromNode($resourceNode); $resourceNode = $shortcut->getTarget(); } // do a minimal security check to redirect user which are not authenticated if needed. if (empty($currentUser) && 0 >= $this->rightsRepo->findMaximumRights([], $resourceNode)) { // user is not authenticated and the current node is not opened to anonymous throw new AccessDeniedException(); } return [ 'resourceNode' => $resourceNode, ]; }
php
public function showAction($id, User $currentUser = null) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // TODO : not pretty, but might want on some case to download files instead ? // TODO : find a way to do it in the link plugin if ('shortcut' === $resourceNode->getResourceType()->getName()) { $shortcut = $this->manager->getResourceFromNode($resourceNode); $resourceNode = $shortcut->getTarget(); } // do a minimal security check to redirect user which are not authenticated if needed. if (empty($currentUser) && 0 >= $this->rightsRepo->findMaximumRights([], $resourceNode)) { // user is not authenticated and the current node is not opened to anonymous throw new AccessDeniedException(); } return [ 'resourceNode' => $resourceNode, ]; }
[ "public", "function", "showAction", "(", "$", "id", ",", "User", "$", "currentUser", "=", "null", ")", "{", "/** @var ResourceNode $resourceNode */", "$", "resourceNode", "=", "$", "this", "->", "om", "->", "find", "(", "ResourceNode", "::", "class", ",", "$...
Renders a resource application. @EXT\Route("/show/{id}", name="claro_resource_show_short") @EXT\Route("/show/{type}/{id}", name="claro_resource_show") @EXT\Method("GET") @EXT\ParamConverter("currentUser", converter="current_user", options={"allowAnonymous"=true}) @EXT\Template() @param int|string $id - the id of the target node (we don't use ParamConverter to support ID and UUID) @param User $currentUser @return array @throws ResourceNotFoundException
[ "Renders", "a", "resource", "application", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L142-L166
40,581
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.embedAction
public function embedAction(ResourceNode $resourceNode) { $mimeType = explode('/', $resourceNode->getMimeType()); $view = 'default'; if ($mimeType[0] && in_array($mimeType[0], ['video', 'audio', 'image'])) { $view = $mimeType[0]; } return new Response( $this->templating->render("ClarolineCoreBundle:resource:embed/{$view}.html.twig", [ 'resource' => $this->manager->getResourceFromNode($resourceNode), ]) ); }
php
public function embedAction(ResourceNode $resourceNode) { $mimeType = explode('/', $resourceNode->getMimeType()); $view = 'default'; if ($mimeType[0] && in_array($mimeType[0], ['video', 'audio', 'image'])) { $view = $mimeType[0]; } return new Response( $this->templating->render("ClarolineCoreBundle:resource:embed/{$view}.html.twig", [ 'resource' => $this->manager->getResourceFromNode($resourceNode), ]) ); }
[ "public", "function", "embedAction", "(", "ResourceNode", "$", "resourceNode", ")", "{", "$", "mimeType", "=", "explode", "(", "'/'", ",", "$", "resourceNode", "->", "getMimeType", "(", ")", ")", ";", "$", "view", "=", "'default'", ";", "if", "(", "$", ...
Embeds a resource inside a rich text content. @EXT\Route("/embed/{id}", name="claro_resource_embed_short") @EXT\Route("/embed/{type}/{id}", name="claro_resource_embed") @param ResourceNode $resourceNode @return Response
[ "Embeds", "a", "resource", "inside", "a", "rich", "text", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L178-L192
40,582
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.downloadAction
public function downloadAction($forceArchive = false, Request $request) { $ids = $request->query->get('ids'); $nodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $collection = new ResourceCollection($nodes); if (!$this->authorization->isGranted('EXPORT', $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } $data = $this->manager->download($nodes, $forceArchive); $file = $data['file'] ?: tempnam('tmp', 'tmp'); $fileName = $data['name']; if (!file_exists($file)) { return new JsonResponse(['file_not_found'], 500); } $fileName = null === $fileName ? $response->getFile()->getFilename() : $fileName; $fileName = str_replace('/', '_', $fileName); $fileName = str_replace('\\', '_', $fileName); $response = new BinaryFileResponse($file, 200, ['Content-Disposition' => "attachment; filename={$fileName}"]); return $response; }
php
public function downloadAction($forceArchive = false, Request $request) { $ids = $request->query->get('ids'); $nodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $collection = new ResourceCollection($nodes); if (!$this->authorization->isGranted('EXPORT', $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } $data = $this->manager->download($nodes, $forceArchive); $file = $data['file'] ?: tempnam('tmp', 'tmp'); $fileName = $data['name']; if (!file_exists($file)) { return new JsonResponse(['file_not_found'], 500); } $fileName = null === $fileName ? $response->getFile()->getFilename() : $fileName; $fileName = str_replace('/', '_', $fileName); $fileName = str_replace('\\', '_', $fileName); $response = new BinaryFileResponse($file, 200, ['Content-Disposition' => "attachment; filename={$fileName}"]); return $response; }
[ "public", "function", "downloadAction", "(", "$", "forceArchive", "=", "false", ",", "Request", "$", "request", ")", "{", "$", "ids", "=", "$", "request", "->", "query", "->", "get", "(", "'ids'", ")", ";", "$", "nodes", "=", "$", "this", "->", "om",...
Downloads a list of Resources. @EXT\Route( "/download", name="claro_resource_download", defaults ={"forceArchive"=false} ) @EXT\Route( "/download/{forceArchive}", name="claro_resource_download", requirements={"forceArchive" = "^(true|false|0|1)$"}, ) @param bool $forceArchive @param Request $request @return Response
[ "Downloads", "a", "list", "of", "Resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L213-L240
40,583
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.unlockAction
public function unlockAction(ResourceNode $resourceNode, Request $request) { $this->restrictionsManager->unlock($resourceNode, json_decode($request->getContent(), true)['code']); return new JsonResponse(null, 204); }
php
public function unlockAction(ResourceNode $resourceNode, Request $request) { $this->restrictionsManager->unlock($resourceNode, json_decode($request->getContent(), true)['code']); return new JsonResponse(null, 204); }
[ "public", "function", "unlockAction", "(", "ResourceNode", "$", "resourceNode", ",", "Request", "$", "request", ")", "{", "$", "this", "->", "restrictionsManager", "->", "unlock", "(", "$", "resourceNode", ",", "json_decode", "(", "$", "request", "->", "getCon...
Submit access code. @EXT\Route("/unlock/{id}", name="claro_resource_unlock") @EXT\Method("POST") @EXT\ParamConverter("resourceNode", class="ClarolineCoreBundle:Resource\ResourceNode", options={"mapping": {"id": "uuid"}}) @param ResourceNode $resourceNode @param Request $request @return JsonResponse
[ "Submit", "access", "code", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L254-L259
40,584
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.executeCollectionAction
public function executeCollectionAction($action, Request $request) { $ids = $request->query->get('ids'); /** @var ResourceNode[] $resourceNodes */ $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $responses = []; // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); $this->om->startFlushSuite(); foreach ($resourceNodes as $resourceNode) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // dispatch action event $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); } $this->om->endFlushSuite(); return new JsonResponse(array_map(function (Response $response) { return json_decode($response->getContent(), true); }, $responses)); }
php
public function executeCollectionAction($action, Request $request) { $ids = $request->query->get('ids'); /** @var ResourceNode[] $resourceNodes */ $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids); $responses = []; // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); $this->om->startFlushSuite(); foreach ($resourceNodes as $resourceNode) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // dispatch action event $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); } $this->om->endFlushSuite(); return new JsonResponse(array_map(function (Response $response) { return json_decode($response->getContent(), true); }, $responses)); }
[ "public", "function", "executeCollectionAction", "(", "$", "action", ",", "Request", "$", "request", ")", "{", "$", "ids", "=", "$", "request", "->", "query", "->", "get", "(", "'ids'", ")", ";", "/** @var ResourceNode[] $resourceNodes */", "$", "resourceNodes",...
Executes an action on a collection of resources. @EXT\Route("/collection/{action}", name="claro_resource_collection_action") @param string $action @param Request $request @return JsonResponse @throws NotFoundHttpException
[ "Executes", "an", "action", "on", "a", "collection", "of", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L273-L313
40,585
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.getAction
public function getAction($id, $embedded = 0) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // gets the current user roles to check access restrictions $userRoles = $this->security->getRoles($this->tokenStorage->getToken()); $accessErrors = $this->restrictionsManager->getErrors($resourceNode, $userRoles); if (empty($accessErrors) || $this->manager->isManager($resourceNode)) { try { $loaded = $this->manager->load($resourceNode, intval($embedded) ? true : false); } catch (ResourceNotFoundException $e) { return new JsonResponse(['resource_not_found'], 500); } return new JsonResponse( array_merge([ // append access restrictions to the loaded node // if any to let know the manager that other user can not enter the resource 'accessErrors' => $accessErrors, ], $loaded) ); } return new JsonResponse($accessErrors, 403); }
php
public function getAction($id, $embedded = 0) { /** @var ResourceNode $resourceNode */ $resourceNode = $this->om->find(ResourceNode::class, $id); if (!$resourceNode) { throw new ResourceNotFoundException(); } // gets the current user roles to check access restrictions $userRoles = $this->security->getRoles($this->tokenStorage->getToken()); $accessErrors = $this->restrictionsManager->getErrors($resourceNode, $userRoles); if (empty($accessErrors) || $this->manager->isManager($resourceNode)) { try { $loaded = $this->manager->load($resourceNode, intval($embedded) ? true : false); } catch (ResourceNotFoundException $e) { return new JsonResponse(['resource_not_found'], 500); } return new JsonResponse( array_merge([ // append access restrictions to the loaded node // if any to let know the manager that other user can not enter the resource 'accessErrors' => $accessErrors, ], $loaded) ); } return new JsonResponse($accessErrors, 403); }
[ "public", "function", "getAction", "(", "$", "id", ",", "$", "embedded", "=", "0", ")", "{", "/** @var ResourceNode $resourceNode */", "$", "resourceNode", "=", "$", "this", "->", "om", "->", "find", "(", "ResourceNode", "::", "class", ",", "$", "id", ")",...
Gets a resource. @EXT\Route("/{id}", name="claro_resource_load_short") @EXT\Route("/{type}/{id}", name="claro_resource_load") @EXT\Route("/{type}/{id}/embedded/{embedded}", name="claro_resource_load_embedded") @EXT\Method("GET") @param int|string $id - the id of the target node (we don't use ParamConverter to support ID and UUID) @param int $embedded @return JsonResponse @throws ResourceNotFoundException
[ "Gets", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L330-L359
40,586
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.executeAction
public function executeAction($action, ResourceNode $resourceNode, Request $request) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); // dispatch action event return $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); }
php
public function executeAction($action, ResourceNode $resourceNode, Request $request) { // check the requested action exists if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) { // undefined action throw new NotFoundHttpException( sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName()) ); } // check current user rights $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]); // read request and get user query $parameters = $request->query->all(); $content = null; if (!empty($request->getContent())) { $content = json_decode($request->getContent(), true); } $files = $request->files->all(); // dispatch action event return $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files); }
[ "public", "function", "executeAction", "(", "$", "action", ",", "ResourceNode", "$", "resourceNode", ",", "Request", "$", "request", ")", "{", "// check the requested action exists", "if", "(", "!", "$", "this", "->", "actionManager", "->", "support", "(", "$", ...
Executes an action on one resource. @EXT\Route("/{action}/{id}", name="claro_resource_action_short") @EXT\Route("/{type}/{action}/{id}", name="claro_resource_action") @param string $action @param ResourceNode $resourceNode @param Request $request @return Response @throws NotFoundHttpException
[ "Executes", "an", "action", "on", "one", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L375-L400
40,587
claroline/Distribution
main/core/Controller/ResourceController.php
ResourceController.checkAccess
private function checkAccess(MenuAction $action, array $resourceNodes, array $attributes = []) { $collection = new ResourceCollection($resourceNodes); $collection->setAttributes($attributes); if (!$this->actionManager->hasPermission($action, $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } }
php
private function checkAccess(MenuAction $action, array $resourceNodes, array $attributes = []) { $collection = new ResourceCollection($resourceNodes); $collection->setAttributes($attributes); if (!$this->actionManager->hasPermission($action, $collection)) { throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources()); } }
[ "private", "function", "checkAccess", "(", "MenuAction", "$", "action", ",", "array", "$", "resourceNodes", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "collection", "=", "new", "ResourceCollection", "(", "$", "resourceNodes", ")", ";", ...
Checks the current user can execute the action on the requested nodes. @param MenuAction $action @param array $resourceNodes @param array $attributes
[ "Checks", "the", "current", "user", "can", "execute", "the", "action", "on", "the", "requested", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/ResourceController.php#L409-L417
40,588
claroline/Distribution
plugin/link/Listener/Resource/Types/ShortcutListener.php
ShortcutListener.load
public function load(LoadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->load($shortcut->getTarget()); }
php
public function load(LoadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->load($shortcut->getTarget()); }
[ "public", "function", "load", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var Shortcut $shortcut */", "$", "shortcut", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "this", "->", "resourceLifecycle", "->", "load", "(", "$", "shortcut"...
Loads a shortcut. It forwards the event to the target of the shortcut. @DI\Observe("resource.shortcut.load") @param LoadResourceEvent $event
[ "Loads", "a", "shortcut", ".", "It", "forwards", "the", "event", "to", "the", "target", "of", "the", "shortcut", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Listener/Resource/Types/ShortcutListener.php#L55-L61
40,589
claroline/Distribution
plugin/link/Listener/Resource/Types/ShortcutListener.php
ShortcutListener.open
public function open(OpenResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->open($shortcut->getTarget()); }
php
public function open(OpenResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->open($shortcut->getTarget()); }
[ "public", "function", "open", "(", "OpenResourceEvent", "$", "event", ")", "{", "/** @var Shortcut $shortcut */", "$", "shortcut", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "this", "->", "resourceLifecycle", "->", "open", "(", "$", "shortcut"...
Opens a shortcut. It forwards the event to the target of the shortcut. @DI\Observe("resource.shortcut.open") @param OpenResourceEvent $event
[ "Opens", "a", "shortcut", ".", "It", "forwards", "the", "event", "to", "the", "target", "of", "the", "shortcut", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Listener/Resource/Types/ShortcutListener.php#L71-L77
40,590
claroline/Distribution
plugin/link/Listener/Resource/Types/ShortcutListener.php
ShortcutListener.export
public function export(DownloadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->export($shortcut->getTarget()); }
php
public function export(DownloadResourceEvent $event) { /** @var Shortcut $shortcut */ $shortcut = $event->getResource(); $this->resourceLifecycle->export($shortcut->getTarget()); }
[ "public", "function", "export", "(", "DownloadResourceEvent", "$", "event", ")", "{", "/** @var Shortcut $shortcut */", "$", "shortcut", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "this", "->", "resourceLifecycle", "->", "export", "(", "$", "s...
Exports a shortcut. It forwards the event to the target of the shortcut. @DI\Observe("resource.shortcut.export") @param DownloadResourceEvent $event
[ "Exports", "a", "shortcut", ".", "It", "forwards", "the", "event", "to", "the", "target", "of", "the", "shortcut", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/link/Listener/Resource/Types/ShortcutListener.php#L87-L93
40,591
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.addAssociation
public function addAssociation(Association $association) { if (!$this->associations->contains($association)) { $this->associations->add($association); $association->setQuestion($this); } }
php
public function addAssociation(Association $association) { if (!$this->associations->contains($association)) { $this->associations->add($association); $association->setQuestion($this); } }
[ "public", "function", "addAssociation", "(", "Association", "$", "association", ")", "{", "if", "(", "!", "$", "this", "->", "associations", "->", "contains", "(", "$", "association", ")", ")", "{", "$", "this", "->", "associations", "->", "add", "(", "$...
Adds an association. @param Association $association
[ "Adds", "an", "association", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L91-L97
40,592
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.removeAssociation
public function removeAssociation(Association $association) { if ($this->associations->contains($association)) { $this->associations->removeElement($association); } }
php
public function removeAssociation(Association $association) { if ($this->associations->contains($association)) { $this->associations->removeElement($association); } }
[ "public", "function", "removeAssociation", "(", "Association", "$", "association", ")", "{", "if", "(", "$", "this", "->", "associations", "->", "contains", "(", "$", "association", ")", ")", "{", "$", "this", "->", "associations", "->", "removeElement", "("...
Removes an association. @param Association $association
[ "Removes", "an", "association", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L104-L109
40,593
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.addLabel
public function addLabel(Label $label) { if (!$this->labels->contains($label)) { $this->labels->add($label); $label->setInteractionMatching($this); } }
php
public function addLabel(Label $label) { if (!$this->labels->contains($label)) { $this->labels->add($label); $label->setInteractionMatching($this); } }
[ "public", "function", "addLabel", "(", "Label", "$", "label", ")", "{", "if", "(", "!", "$", "this", "->", "labels", "->", "contains", "(", "$", "label", ")", ")", "{", "$", "this", "->", "labels", "->", "add", "(", "$", "label", ")", ";", "$", ...
Adds a label. @param Label $label
[ "Adds", "a", "label", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L126-L132
40,594
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.removeLabel
public function removeLabel(Label $label) { if ($this->labels->contains($label)) { $this->labels->removeElement($label); } }
php
public function removeLabel(Label $label) { if ($this->labels->contains($label)) { $this->labels->removeElement($label); } }
[ "public", "function", "removeLabel", "(", "Label", "$", "label", ")", "{", "if", "(", "$", "this", "->", "labels", "->", "contains", "(", "$", "label", ")", ")", "{", "$", "this", "->", "labels", "->", "removeElement", "(", "$", "label", ")", ";", ...
Removes a label. @param Label $label
[ "Removes", "a", "label", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L139-L144
40,595
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.addProposal
public function addProposal(Proposal $proposal) { if (!$this->proposals->contains($proposal)) { $this->proposals->add($proposal); $proposal->setInteractionMatching($this); } }
php
public function addProposal(Proposal $proposal) { if (!$this->proposals->contains($proposal)) { $this->proposals->add($proposal); $proposal->setInteractionMatching($this); } }
[ "public", "function", "addProposal", "(", "Proposal", "$", "proposal", ")", "{", "if", "(", "!", "$", "this", "->", "proposals", "->", "contains", "(", "$", "proposal", ")", ")", "{", "$", "this", "->", "proposals", "->", "add", "(", "$", "proposal", ...
Adds a proposal. @param Proposal $proposal
[ "Adds", "a", "proposal", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L161-L167
40,596
claroline/Distribution
plugin/exo/Entity/ItemType/MatchQuestion.php
MatchQuestion.removeProposal
public function removeProposal(Proposal $proposal) { if ($this->proposals->contains($proposal)) { $this->proposals->removeElement($proposal); } }
php
public function removeProposal(Proposal $proposal) { if ($this->proposals->contains($proposal)) { $this->proposals->removeElement($proposal); } }
[ "public", "function", "removeProposal", "(", "Proposal", "$", "proposal", ")", "{", "if", "(", "$", "this", "->", "proposals", "->", "contains", "(", "$", "proposal", ")", ")", "{", "$", "this", "->", "proposals", "->", "removeElement", "(", "$", "propos...
Removes a proposal. @param Proposal $proposal
[ "Removes", "a", "proposal", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/MatchQuestion.php#L174-L179
40,597
claroline/Distribution
main/core/Library/Normalizer/DateRangeNormalizer.php
DateRangeNormalizer.normalize
public static function normalize(\DateTime $startDate = null, \DateTime $endDate = null) { if (!empty($startDate) || !empty($endDate)) { return [ DateNormalizer::normalize($startDate), DateNormalizer::normalize($endDate), ]; } return []; }
php
public static function normalize(\DateTime $startDate = null, \DateTime $endDate = null) { if (!empty($startDate) || !empty($endDate)) { return [ DateNormalizer::normalize($startDate), DateNormalizer::normalize($endDate), ]; } return []; }
[ "public", "static", "function", "normalize", "(", "\\", "DateTime", "$", "startDate", "=", "null", ",", "\\", "DateTime", "$", "endDate", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "startDate", ")", "||", "!", "empty", "(", "$", "endDa...
Normalizes two DateTimes to an array of date strings. @param \DateTime|null $startDate @param \DateTime|null $endDate @return array
[ "Normalizes", "two", "DateTimes", "to", "an", "array", "of", "date", "strings", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Normalizer/DateRangeNormalizer.php#L23-L33
40,598
claroline/Distribution
main/core/Library/Normalizer/DateRangeNormalizer.php
DateRangeNormalizer.denormalize
public static function denormalize($dateRange = []) { if (!empty($dateRange)) { return [ DateNormalizer::denormalize($dateRange[0]), DateNormalizer::denormalize($dateRange[1]), ]; } return [null, null]; }
php
public static function denormalize($dateRange = []) { if (!empty($dateRange)) { return [ DateNormalizer::denormalize($dateRange[0]), DateNormalizer::denormalize($dateRange[1]), ]; } return [null, null]; }
[ "public", "static", "function", "denormalize", "(", "$", "dateRange", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "dateRange", ")", ")", "{", "return", "[", "DateNormalizer", "::", "denormalize", "(", "$", "dateRange", "[", "0", "]", ...
Denormalizes an array of date strings into DateTime objects. @param array $dateRange @return array
[ "Denormalizes", "an", "array", "of", "date", "strings", "into", "DateTime", "objects", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Normalizer/DateRangeNormalizer.php#L42-L52
40,599
claroline/Distribution
plugin/collecticiel/Entity/CommentRead.php
CommentRead.setComment
public function setComment(\Innova\CollecticielBundle\Entity\Comment $comment) { $this->comment = $comment; return $this; }
php
public function setComment(\Innova\CollecticielBundle\Entity\Comment $comment) { $this->comment = $comment; return $this; }
[ "public", "function", "setComment", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Comment", "$", "comment", ")", "{", "$", "this", "->", "comment", "=", "$", "comment", ";", "return", "$", "this", ";", "}" ]
Set comment. @param \Innova\CollecticielBundle\Entity\Comment $comment @return CommentRead
[ "Set", "comment", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/CommentRead.php#L168-L173