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,400
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.render
public function render($template, $variables, $default = false) { if ($default) { $template = $this->homeService->defaultTemplate($template); } return new Response($this->templating->render($template, $variables)); }
php
public function render($template, $variables, $default = false) { if ($default) { $template = $this->homeService->defaultTemplate($template); } return new Response($this->templating->render($template, $variables)); }
[ "public", "function", "render", "(", "$", "template", ",", "$", "variables", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "default", ")", "{", "$", "template", "=", "$", "this", "->", "homeService", "->", "defaultTemplate", "(", "$", ...
Extends templating render. @param string $template @param array $variables @param bool $default @return Response
[ "Extends", "templating", "render", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L819-L826
40,401
claroline/Distribution
plugin/exo/Serializer/Attempt/PaperSerializer.php
PaperSerializer.serialize
public function serialize(Paper $paper, array $options = []) { $serialized = [ 'id' => $paper->getUuid(), 'number' => $paper->getNumber(), 'finished' => !$paper->isInterrupted(), 'user' => $paper->getUser() && !$paper->isAnonymized() ? $this->userSerializer->serialize($paper->getUser(), $options) : null, 'startDate' => $paper->getStart() ? DateNormalizer::normalize($paper->getStart()) : null, 'endDate' => $paper->getEnd() ? DateNormalizer::normalize($paper->getEnd()) : null, 'structure' => json_decode($paper->getStructure(), true), ]; // Adds detail information if (!in_array(Transfer::MINIMAL, $options)) { $serialized['answers'] = $this->serializeAnswers($paper, $options); } // Adds user score if (!in_array(Transfer::INCLUDE_USER_SCORE, $options)) { $serialized['score'] = $paper->getScore(); } return $serialized; }
php
public function serialize(Paper $paper, array $options = []) { $serialized = [ 'id' => $paper->getUuid(), 'number' => $paper->getNumber(), 'finished' => !$paper->isInterrupted(), 'user' => $paper->getUser() && !$paper->isAnonymized() ? $this->userSerializer->serialize($paper->getUser(), $options) : null, 'startDate' => $paper->getStart() ? DateNormalizer::normalize($paper->getStart()) : null, 'endDate' => $paper->getEnd() ? DateNormalizer::normalize($paper->getEnd()) : null, 'structure' => json_decode($paper->getStructure(), true), ]; // Adds detail information if (!in_array(Transfer::MINIMAL, $options)) { $serialized['answers'] = $this->serializeAnswers($paper, $options); } // Adds user score if (!in_array(Transfer::INCLUDE_USER_SCORE, $options)) { $serialized['score'] = $paper->getScore(); } return $serialized; }
[ "public", "function", "serialize", "(", "Paper", "$", "paper", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "paper", "->", "getUuid", "(", ")", ",", "'number'", "=>", "$", "paper", "->", "ge...
Converts a Paper into a JSON-encodable structure. @param Paper $paper @param array $options @return array
[ "Converts", "a", "Paper", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/PaperSerializer.php#L58-L81
40,402
claroline/Distribution
plugin/exo/Serializer/Attempt/PaperSerializer.php
PaperSerializer.deserialize
public function deserialize($data, Paper $paper = null, array $options = []) { $paper = $paper ?: new Paper(); $this->sipe('id', 'setUuid', $data, $paper); $this->sipe('number', 'setNumber', $data, $paper); $this->sipe('score', 'setScore', $data, $paper); if (isset($data['startDate'])) { $startDate = DateNormalizer::denormalize($data['startDate']); $paper->setStart($startDate); } if (isset($data['endDate'])) { $endDate = DateNormalizer::denormalize($data['endDate']); $paper->setEnd($endDate); } if (isset($data['structure'])) { $paper->setStructure(json_encode($data['structure'])); } if (isset($data['finished'])) { $paper->setInterrupted(!$data['finished']); } if (isset($data['answers'])) { $this->deserializeAnswers($paper, $data['answers'], $options); } return $paper; }
php
public function deserialize($data, Paper $paper = null, array $options = []) { $paper = $paper ?: new Paper(); $this->sipe('id', 'setUuid', $data, $paper); $this->sipe('number', 'setNumber', $data, $paper); $this->sipe('score', 'setScore', $data, $paper); if (isset($data['startDate'])) { $startDate = DateNormalizer::denormalize($data['startDate']); $paper->setStart($startDate); } if (isset($data['endDate'])) { $endDate = DateNormalizer::denormalize($data['endDate']); $paper->setEnd($endDate); } if (isset($data['structure'])) { $paper->setStructure(json_encode($data['structure'])); } if (isset($data['finished'])) { $paper->setInterrupted(!$data['finished']); } if (isset($data['answers'])) { $this->deserializeAnswers($paper, $data['answers'], $options); } return $paper; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "Paper", "$", "paper", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "paper", "=", "$", "paper", "?", ":", "new", "Paper", "(", ")", ";", "$", "this", "->", ...
Converts raw data into a Paper entity. @param array $data @param Paper $paper @param array $options @return Paper
[ "Converts", "raw", "data", "into", "a", "Paper", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/PaperSerializer.php#L92-L119
40,403
claroline/Distribution
plugin/exo/Serializer/Attempt/PaperSerializer.php
PaperSerializer.serializeAnswers
private function serializeAnswers(Paper $paper, array $options = []) { // We need to inject the hints available in the structure $options['hints'] = []; $decoded = json_decode($paper->getStructure(), true); foreach ($decoded['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { foreach ($item['hints'] as $hint) { $options['hints'][$hint['id']] = $hint; } } } } return array_map(function (Answer $answer) use ($options) { return $this->answerSerializer->serialize($answer, $options); }, $paper->getAnswers()->toArray()); }
php
private function serializeAnswers(Paper $paper, array $options = []) { // We need to inject the hints available in the structure $options['hints'] = []; $decoded = json_decode($paper->getStructure(), true); foreach ($decoded['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { foreach ($item['hints'] as $hint) { $options['hints'][$hint['id']] = $hint; } } } } return array_map(function (Answer $answer) use ($options) { return $this->answerSerializer->serialize($answer, $options); }, $paper->getAnswers()->toArray()); }
[ "private", "function", "serializeAnswers", "(", "Paper", "$", "paper", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// We need to inject the hints available in the structure", "$", "options", "[", "'hints'", "]", "=", "[", "]", ";", "$", "decoded", ...
Serializes paper answers. @param Paper $paper @param array $options @return array
[ "Serializes", "paper", "answers", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/PaperSerializer.php#L129-L148
40,404
claroline/Distribution
main/core/Entity/Content.php
Content.setModified
public function setModified($modified = null) { if ($modified) { $this->modified = $modified; } else { $this->modified = new \Datetime(); } return $this; }
php
public function setModified($modified = null) { if ($modified) { $this->modified = $modified; } else { $this->modified = new \Datetime(); } return $this; }
[ "public", "function", "setModified", "(", "$", "modified", "=", "null", ")", "{", "if", "(", "$", "modified", ")", "{", "$", "this", "->", "modified", "=", "$", "modified", ";", "}", "else", "{", "$", "this", "->", "modified", "=", "new", "\\", "Da...
Set modified. @param \DateTime $modified @return Content
[ "Set", "modified", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Content.php#L209-L218
40,405
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.getDesktopToolsConfigurationArray
public function getDesktopToolsConfigurationArray(User $user, $type = 0) { $orderedToolList = []; $desktopTools = $this->orderedToolRepo->findDisplayableDesktopOrderedToolsByUser( $user, $type ); foreach ($desktopTools as $desktopTool) { //this field isn't mapped $desktopTool->getTool()->setVisible($desktopTool->isVisibleInDesktop()); $orderedToolList[$desktopTool->getOrder()] = $desktopTool->getTool(); } $undisplayedTools = $this->toolRepo->findDesktopUndisplayedToolsByUser($user, $type); foreach ($undisplayedTools as $tool) { //this field isn't mapped $tool->setVisible(false); } $this->addMissingDesktopTools( $user, $undisplayedTools, count($desktopTools) + 1, $type ); return $this->utilities->arrayFill($orderedToolList, $undisplayedTools); }
php
public function getDesktopToolsConfigurationArray(User $user, $type = 0) { $orderedToolList = []; $desktopTools = $this->orderedToolRepo->findDisplayableDesktopOrderedToolsByUser( $user, $type ); foreach ($desktopTools as $desktopTool) { //this field isn't mapped $desktopTool->getTool()->setVisible($desktopTool->isVisibleInDesktop()); $orderedToolList[$desktopTool->getOrder()] = $desktopTool->getTool(); } $undisplayedTools = $this->toolRepo->findDesktopUndisplayedToolsByUser($user, $type); foreach ($undisplayedTools as $tool) { //this field isn't mapped $tool->setVisible(false); } $this->addMissingDesktopTools( $user, $undisplayedTools, count($desktopTools) + 1, $type ); return $this->utilities->arrayFill($orderedToolList, $undisplayedTools); }
[ "public", "function", "getDesktopToolsConfigurationArray", "(", "User", "$", "user", ",", "$", "type", "=", "0", ")", "{", "$", "orderedToolList", "=", "[", "]", ";", "$", "desktopTools", "=", "$", "this", "->", "orderedToolRepo", "->", "findDisplayableDesktop...
Returns the sorted list of OrderedTools for a user. @param \Claroline\CoreBundle\Entity\User $user @return \Claroline\CoreBundle\Entity\Tool\OrderedTool
[ "Returns", "the", "sorted", "list", "of", "OrderedTools", "for", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L235-L264
40,406
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.setToolPosition
public function setToolPosition( Tool $tool, $position, User $user = null, Workspace $workspace = null, $type = 0 ) { $movingTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'workspace' => $workspace, 'type' => $type] ); $movingTool->setOrder($position); $this->om->persist($movingTool); $this->om->flush(); }
php
public function setToolPosition( Tool $tool, $position, User $user = null, Workspace $workspace = null, $type = 0 ) { $movingTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'workspace' => $workspace, 'type' => $type] ); $movingTool->setOrder($position); $this->om->persist($movingTool); $this->om->flush(); }
[ "public", "function", "setToolPosition", "(", "Tool", "$", "tool", ",", "$", "position", ",", "User", "$", "user", "=", "null", ",", "Workspace", "$", "workspace", "=", "null", ",", "$", "type", "=", "0", ")", "{", "$", "movingTool", "=", "$", "this"...
Sets a tool position. @param Tool $tool @param $position @param User $user @param Workspace $workspace
[ "Sets", "a", "tool", "position", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L550-L563
40,407
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.resetToolsVisiblity
public function resetToolsVisiblity( User $user = null, Workspace $workspace = null, $type = 0 ) { $orderedTools = $this->orderedToolRepo->findBy( ['user' => $user, 'workspace' => $workspace, 'type' => $type] ); foreach ($orderedTools as $orderedTool) { if ($user) { $orderedTool->setVisibleInDesktop(false); } $this->om->persist($orderedTool); } $this->om->flush(); }
php
public function resetToolsVisiblity( User $user = null, Workspace $workspace = null, $type = 0 ) { $orderedTools = $this->orderedToolRepo->findBy( ['user' => $user, 'workspace' => $workspace, 'type' => $type] ); foreach ($orderedTools as $orderedTool) { if ($user) { $orderedTool->setVisibleInDesktop(false); } $this->om->persist($orderedTool); } $this->om->flush(); }
[ "public", "function", "resetToolsVisiblity", "(", "User", "$", "user", "=", "null", ",", "Workspace", "$", "workspace", "=", "null", ",", "$", "type", "=", "0", ")", "{", "$", "orderedTools", "=", "$", "this", "->", "orderedToolRepo", "->", "findBy", "("...
Resets the tool visibility. @param User $user @param Workspace $workspace
[ "Resets", "the", "tool", "visibility", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L571-L589
40,408
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.setDesktopToolVisible
public function setDesktopToolVisible(Tool $tool, User $user, $type = 0) { $orderedTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'type' => $type] ); $orderedTool->setVisibleInDesktop(true); $this->om->persist($orderedTool); $this->om->flush(); }
php
public function setDesktopToolVisible(Tool $tool, User $user, $type = 0) { $orderedTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'type' => $type] ); $orderedTool->setVisibleInDesktop(true); $this->om->persist($orderedTool); $this->om->flush(); }
[ "public", "function", "setDesktopToolVisible", "(", "Tool", "$", "tool", ",", "User", "$", "user", ",", "$", "type", "=", "0", ")", "{", "$", "orderedTool", "=", "$", "this", "->", "orderedToolRepo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "u...
Sets a tool visible for a user in the desktop. @param Tool $tool @param User $user
[ "Sets", "a", "tool", "visible", "for", "a", "user", "in", "the", "desktop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L636-L644
40,409
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.addRequiredToolsToUser
public function addRequiredToolsToUser(User $user, $type = 0) { $requiredTools = []; $adminOrderedTools = $this->getConfigurableDesktopOrderedToolsByTypeForAdmin($type); foreach ($adminOrderedTools as $orderedTool) { if ($orderedTool->isVisibleInDesktop()) { $requiredTools[] = $orderedTool->getTool(); } } $position = 1; $this->om->startFlushSuite(); foreach ($requiredTools as $requiredTool) { $this->addDesktopTool( $requiredTool, $user, $position, $requiredTool->getName(), $type ); ++$position; } $this->om->persist($user); $this->om->endFlushSuite($user); }
php
public function addRequiredToolsToUser(User $user, $type = 0) { $requiredTools = []; $adminOrderedTools = $this->getConfigurableDesktopOrderedToolsByTypeForAdmin($type); foreach ($adminOrderedTools as $orderedTool) { if ($orderedTool->isVisibleInDesktop()) { $requiredTools[] = $orderedTool->getTool(); } } $position = 1; $this->om->startFlushSuite(); foreach ($requiredTools as $requiredTool) { $this->addDesktopTool( $requiredTool, $user, $position, $requiredTool->getName(), $type ); ++$position; } $this->om->persist($user); $this->om->endFlushSuite($user); }
[ "public", "function", "addRequiredToolsToUser", "(", "User", "$", "user", ",", "$", "type", "=", "0", ")", "{", "$", "requiredTools", "=", "[", "]", ";", "$", "adminOrderedTools", "=", "$", "this", "->", "getConfigurableDesktopOrderedToolsByTypeForAdmin", "(", ...
Adds the mandatory tools at the user creation. @param \Claroline\CoreBundle\Entity\User $user
[ "Adds", "the", "mandatory", "tools", "at", "the", "user", "creation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L651-L678
40,410
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.contentLayout
public function contentLayout($type, $father = null, $region = null, $admin = null) { $type = $this->getType($type); $content = $this->getContentByType($type->getName(), $father, $region); $array = null; if ($content && ($type->isPublish() || $admin)) { $array = []; $array['content'] = $content; $array['type'] = $type->getName(); $array['publish'] = $type->isPublish(); $array = $this->homeService->isDefinedPush($array, 'father', $father); $array = $this->homeService->isDefinedPush($array, 'region', $region); } return $array; }
php
public function contentLayout($type, $father = null, $region = null, $admin = null) { $type = $this->getType($type); $content = $this->getContentByType($type->getName(), $father, $region); $array = null; if ($content && ($type->isPublish() || $admin)) { $array = []; $array['content'] = $content; $array['type'] = $type->getName(); $array['publish'] = $type->isPublish(); $array = $this->homeService->isDefinedPush($array, 'father', $father); $array = $this->homeService->isDefinedPush($array, 'region', $region); } return $array; }
[ "public", "function", "contentLayout", "(", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ",", "$", "admin", "=", "null", ")", "{", "$", "type", "=", "$", "this", "->", "getType", "(", "$", "type", ")", ";", "$", ...
Return the layout of contents by his type. @return array
[ "Return", "the", "layout", "of", "contents", "by", "his", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L104-L120
40,411
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getContentByType
public function getContentByType($type, $father = null, $region = null) { $array = []; $type = $this->type->findOneBy(['name' => $type]); if ($type) { if ($father) { $father = $this->content->find($father); $first = $this->subContent->findOneBy( ['back' => null, 'father' => $father] ); } else { $first = $this->contentType->findOneBy( ['back' => null, 'type' => $type] ); } if ($first) { for ($i = 0; $i < $type->getMaxContentPage() && null !== $first; ++$i) { $variables = []; $variables['content'] = $first->getContent(); $variables['size'] = $first->getSize(); $variables['type'] = $type->getName(); if (!$father) { $variables['collapse'] = $first->isCollapse(); } $variables = $this->homeService->isDefinedPush($variables, 'father', $father, 'getId'); $variables = $this->homeService->isDefinedPush($variables, 'region', $region); $array[] = $variables; $first = $first->getNext(); } } else { $array[] = ['content' => '', 'type' => $type->getName()]; // in case of not yet content } } return $array; }
php
public function getContentByType($type, $father = null, $region = null) { $array = []; $type = $this->type->findOneBy(['name' => $type]); if ($type) { if ($father) { $father = $this->content->find($father); $first = $this->subContent->findOneBy( ['back' => null, 'father' => $father] ); } else { $first = $this->contentType->findOneBy( ['back' => null, 'type' => $type] ); } if ($first) { for ($i = 0; $i < $type->getMaxContentPage() && null !== $first; ++$i) { $variables = []; $variables['content'] = $first->getContent(); $variables['size'] = $first->getSize(); $variables['type'] = $type->getName(); if (!$father) { $variables['collapse'] = $first->isCollapse(); } $variables = $this->homeService->isDefinedPush($variables, 'father', $father, 'getId'); $variables = $this->homeService->isDefinedPush($variables, 'region', $region); $array[] = $variables; $first = $first->getNext(); } } else { $array[] = ['content' => '', 'type' => $type->getName()]; // in case of not yet content } } return $array; }
[ "public", "function", "getContentByType", "(", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ")", "{", "$", "array", "=", "[", "]", ";", "$", "type", "=", "$", "this", "->", "type", "->", "findOneBy", "(", "[", "'...
Get Content by type. This method return a string with the content on success or null if the type does not exist. @return array
[ "Get", "Content", "by", "type", ".", "This", "method", "return", "a", "string", "with", "the", "content", "on", "success", "or", "null", "if", "the", "type", "does", "not", "exist", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L138-L175
40,412
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.reorderContent
public function reorderContent($type, $a, $b = null, $father = null) { $a = $this->getNode($type, $a, $father); $a->detach(); if ($b) { $b = $this->getNode($type, $b, $father); $a->setBack($b->getBack()); $a->setNext($b); if ($b->getBack()) { $b->getBack()->setNext($a); } $b->setBack($a); } else { $b = $this->getnode($type, null, $father); $a->setNext($b->getNext()); $a->setBack($b); $b->setNext($a); } $this->manager->persist($a); $this->manager->persist($b); $this->manager->flush(); }
php
public function reorderContent($type, $a, $b = null, $father = null) { $a = $this->getNode($type, $a, $father); $a->detach(); if ($b) { $b = $this->getNode($type, $b, $father); $a->setBack($b->getBack()); $a->setNext($b); if ($b->getBack()) { $b->getBack()->setNext($a); } $b->setBack($a); } else { $b = $this->getnode($type, null, $father); $a->setNext($b->getNext()); $a->setBack($b); $b->setNext($a); } $this->manager->persist($a); $this->manager->persist($b); $this->manager->flush(); }
[ "public", "function", "reorderContent", "(", "$", "type", ",", "$", "a", ",", "$", "b", "=", "null", ",", "$", "father", "=", "null", ")", "{", "$", "a", "=", "$", "this", "->", "getNode", "(", "$", "type", ",", "$", "a", ",", "$", "father", ...
Reorder Contents.
[ "Reorder", "Contents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L306-L331
40,413
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.createType
public function createType($name) { $type = new Type($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
php
public function createType($name) { $type = new Type($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
[ "public", "function", "createType", "(", "$", "name", ")", "{", "$", "type", "=", "new", "Type", "(", "$", "name", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "type", ")", ";", "$", "this", "->", "manager", "->", "flush", "...
Create a type. @param string $name @return Type
[ "Create", "a", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L399-L406
40,414
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.renameType
public function renameType($type, $name) { $type->setName($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
php
public function renameType($type, $name) { $type->setName($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
[ "public", "function", "renameType", "(", "$", "type", ",", "$", "name", ")", "{", "$", "type", "->", "setName", "(", "$", "name", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "type", ")", ";", "$", "this", "->", "manager", "...
Rename a type. @param Type $type @param string $name @return Type
[ "Rename", "a", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L416-L423
40,415
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.typeExist
public function typeExist($name) { $type = $this->type->findOneBy(['name' => $name]); if (is_object($type)) { return true; } return false; }
php
public function typeExist($name) { $type = $this->type->findOneBy(['name' => $name]); if (is_object($type)) { return true; } return false; }
[ "public", "function", "typeExist", "(", "$", "name", ")", "{", "$", "type", "=", "$", "this", "->", "type", "->", "findOneBy", "(", "[", "'name'", "=>", "$", "name", "]", ")", ";", "if", "(", "is_object", "(", "$", "type", ")", ")", "{", "return"...
Verify if a type exist. @param string $name @return bool
[ "Verify", "if", "a", "type", "exist", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L441-L450
40,416
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.deleNodeEntity
public function deleNodeEntity($entity, $search, $function = null) { $entities = $entity->findBy($search); foreach ($entities as $entity) { $entity->detach(); if ($function) { $function($entity); } $this->manager->remove($entity); $this->manager->flush(); } }
php
public function deleNodeEntity($entity, $search, $function = null) { $entities = $entity->findBy($search); foreach ($entities as $entity) { $entity->detach(); if ($function) { $function($entity); } $this->manager->remove($entity); $this->manager->flush(); } }
[ "public", "function", "deleNodeEntity", "(", "$", "entity", ",", "$", "search", ",", "$", "function", "=", "null", ")", "{", "$", "entities", "=", "$", "entity", "->", "findBy", "(", "$", "search", ")", ";", "foreach", "(", "$", "entities", "as", "$"...
Delete a node entity and link together the next and back entities. @return string The word "true" useful in ajax
[ "Delete", "a", "node", "entity", "and", "link", "together", "the", "next", "and", "back", "entities", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L498-L512
40,417
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.deleteRegions
public function deleteRegions($content, $regions) { foreach ($regions as $region) { $region->detach(); $this->manager->remove($region); $this->manager->flush(); } }
php
public function deleteRegions($content, $regions) { foreach ($regions as $region) { $region->detach(); $this->manager->remove($region); $this->manager->flush(); } }
[ "public", "function", "deleteRegions", "(", "$", "content", ",", "$", "regions", ")", "{", "foreach", "(", "$", "regions", "as", "$", "region", ")", "{", "$", "region", "->", "detach", "(", ")", ";", "$", "this", "->", "manager", "->", "remove", "(",...
Delete a content from every region.
[ "Delete", "a", "content", "from", "every", "region", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L540-L547
40,418
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getCreator
public function getCreator($type, $id = null, $content = null, $father = null) { $variables = ['type' => $type]; if ($id && !$content) { $content = $this->content->find($id); $variables['content'] = $content; } $variables['form'] = $this->formFactory->create( HomeContentType::class, $content, ['id' => $id, 'type' => $type, 'father' => $father] )->createView(); return $this->homeService->isDefinedPush($variables, 'father', $father); }
php
public function getCreator($type, $id = null, $content = null, $father = null) { $variables = ['type' => $type]; if ($id && !$content) { $content = $this->content->find($id); $variables['content'] = $content; } $variables['form'] = $this->formFactory->create( HomeContentType::class, $content, ['id' => $id, 'type' => $type, 'father' => $father] )->createView(); return $this->homeService->isDefinedPush($variables, 'father', $father); }
[ "public", "function", "getCreator", "(", "$", "type", ",", "$", "id", "=", "null", ",", "$", "content", "=", "null", ",", "$", "father", "=", "null", ")", "{", "$", "variables", "=", "[", "'type'", "=>", "$", "type", "]", ";", "if", "(", "$", "...
Get the creator of contents. @return array
[ "Get", "the", "creator", "of", "contents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L554-L570
40,419
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getMenu
public function getMenu($id, $size, $type, $father = null, $region = null, $collapse = false) { $variables = ['id' => $id, 'size' => $size, 'type' => $type, 'region' => $region, 'collapse' => $collapse]; return $this->homeService->isDefinedPush($variables, 'father', $father); }
php
public function getMenu($id, $size, $type, $father = null, $region = null, $collapse = false) { $variables = ['id' => $id, 'size' => $size, 'type' => $type, 'region' => $region, 'collapse' => $collapse]; return $this->homeService->isDefinedPush($variables, 'father', $father); }
[ "public", "function", "getMenu", "(", "$", "id", ",", "$", "size", ",", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ",", "$", "collapse", "=", "false", ")", "{", "$", "variables", "=", "[", "'id'", "=>", "$", ...
Get the variables of the menu. @param string $id The id of the content @param string $size The size (content-8) of the content @param string $type The type of the content @return array
[ "Get", "the", "variables", "of", "the", "menu", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L581-L586
40,420
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getHomeParameters
public function getHomeParameters() { return [ 'homeMenu' => $this->configHandler->getParameter('home_menu'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), ]; }
php
public function getHomeParameters() { return [ 'homeMenu' => $this->configHandler->getParameter('home_menu'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), ]; }
[ "public", "function", "getHomeParameters", "(", ")", "{", "return", "[", "'homeMenu'", "=>", "$", "this", "->", "configHandler", "->", "getParameter", "(", "'home_menu'", ")", ",", "'footerLogin'", "=>", "$", "this", "->", "configHandler", "->", "getParameter", ...
Get the home parameters.
[ "Get", "the", "home", "parameters", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L603-L611
40,421
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.saveHomeParameters
public function saveHomeParameters($homeMenu, $footerLogin, $footerWorkspaces, $headerLocale) { $this->configHandler->setParameters( [ 'home_menu' => is_numeric($homeMenu) ? intval($homeMenu) : null, 'footer_login' => ('true' === $footerLogin), 'footer_workspaces' => ('true' === $footerWorkspaces), 'header_locale' => ('true' === $headerLocale), ] ); }
php
public function saveHomeParameters($homeMenu, $footerLogin, $footerWorkspaces, $headerLocale) { $this->configHandler->setParameters( [ 'home_menu' => is_numeric($homeMenu) ? intval($homeMenu) : null, 'footer_login' => ('true' === $footerLogin), 'footer_workspaces' => ('true' === $footerWorkspaces), 'header_locale' => ('true' === $headerLocale), ] ); }
[ "public", "function", "saveHomeParameters", "(", "$", "homeMenu", ",", "$", "footerLogin", ",", "$", "footerWorkspaces", ",", "$", "headerLocale", ")", "{", "$", "this", "->", "configHandler", "->", "setParameters", "(", "[", "'home_menu'", "=>", "is_numeric", ...
Save the home parameters.
[ "Save", "the", "home", "parameters", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L616-L626
40,422
claroline/Distribution
main/core/Controller/WorkspaceController.php
WorkspaceController.renderToolbarAction
public function renderToolbarAction(Workspace $workspace, Request $request) { $orderedTools = []; $hasManagerAccess = $this->workspaceManager->isManager($workspace, $this->tokenStorage->getToken()); $hideToolsMenu = $this->workspaceManager->isToolsMenuHidden($workspace); $this->toolManager->addMissingWorkspaceTools($workspace); if ($hasManagerAccess || !$hideToolsMenu) { // load tool list if ($hasManagerAccess) { // gets all available tools $orderedTools = $this->toolManager->getOrderedToolsByWorkspace($workspace); // always display tools to managers $hideToolsMenu = false; } else { // gets accessible tools by user $currentRoles = $this->utils->getRoles($this->tokenStorage->getToken()); $orderedTools = $this->toolManager->getOrderedToolsByWorkspaceAndRoles($workspace, $currentRoles); } } $current = null; if ('claro_workspace_open_tool' === $request->get('_route')) { $params = $request->get('_route_params'); if (!empty($params['toolName'])) { $current = $params['toolName']; } } // mega hack to make the resource manager active when inside a resource if (in_array($request->get('_route'), ['claro_resource_show', 'claro_resource_show_short'])) { $current = 'resource_manager'; } return [ 'current' => $current, 'tools' => array_values(array_map(function (OrderedTool $orderedTool) use ($workspace) { // todo : create a serializer return [ 'icon' => $orderedTool->getTool()->getClass(), 'name' => $orderedTool->getTool()->getName(), 'open' => ['claro_workspace_open_tool', ['workspaceId' => $workspace->getId(), 'toolName' => $orderedTool->getTool()->getName()]], ]; }, $orderedTools)), 'workspace' => $workspace, 'hideToolsMenu' => $hideToolsMenu, ]; }
php
public function renderToolbarAction(Workspace $workspace, Request $request) { $orderedTools = []; $hasManagerAccess = $this->workspaceManager->isManager($workspace, $this->tokenStorage->getToken()); $hideToolsMenu = $this->workspaceManager->isToolsMenuHidden($workspace); $this->toolManager->addMissingWorkspaceTools($workspace); if ($hasManagerAccess || !$hideToolsMenu) { // load tool list if ($hasManagerAccess) { // gets all available tools $orderedTools = $this->toolManager->getOrderedToolsByWorkspace($workspace); // always display tools to managers $hideToolsMenu = false; } else { // gets accessible tools by user $currentRoles = $this->utils->getRoles($this->tokenStorage->getToken()); $orderedTools = $this->toolManager->getOrderedToolsByWorkspaceAndRoles($workspace, $currentRoles); } } $current = null; if ('claro_workspace_open_tool' === $request->get('_route')) { $params = $request->get('_route_params'); if (!empty($params['toolName'])) { $current = $params['toolName']; } } // mega hack to make the resource manager active when inside a resource if (in_array($request->get('_route'), ['claro_resource_show', 'claro_resource_show_short'])) { $current = 'resource_manager'; } return [ 'current' => $current, 'tools' => array_values(array_map(function (OrderedTool $orderedTool) use ($workspace) { // todo : create a serializer return [ 'icon' => $orderedTool->getTool()->getClass(), 'name' => $orderedTool->getTool()->getName(), 'open' => ['claro_workspace_open_tool', ['workspaceId' => $workspace->getId(), 'toolName' => $orderedTool->getTool()->getName()]], ]; }, $orderedTools)), 'workspace' => $workspace, 'hideToolsMenu' => $hideToolsMenu, ]; }
[ "public", "function", "renderToolbarAction", "(", "Workspace", "$", "workspace", ",", "Request", "$", "request", ")", "{", "$", "orderedTools", "=", "[", "]", ";", "$", "hasManagerAccess", "=", "$", "this", "->", "workspaceManager", "->", "isManager", "(", "...
Renders the left tool bar. Not routed. @EXT\Template("ClarolineCoreBundle:workspace:toolbar.html.twig") @param Workspace $workspace @param Request $request @return array
[ "Renders", "the", "left", "tool", "bar", ".", "Not", "routed", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/WorkspaceController.php#L170-L217
40,423
claroline/Distribution
main/core/API/Serializer/ParametersSerializer.php
ParametersSerializer.deserialize
public function deserialize(array $data) { $original = $data; $this->deserializeTos($data); $data = $this->getJavascriptsData($data); $data = $this->getLogoData($data); unset($data['tos']['text']); //maybe move this somewhere else unset($data['archives']); $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data); ksort($data); $data = json_encode($data, JSON_PRETTY_PRINT); file_put_contents($this->filePath, $data); return $original; }
php
public function deserialize(array $data) { $original = $data; $this->deserializeTos($data); $data = $this->getJavascriptsData($data); $data = $this->getLogoData($data); unset($data['tos']['text']); //maybe move this somewhere else unset($data['archives']); $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data); ksort($data); $data = json_encode($data, JSON_PRETTY_PRINT); file_put_contents($this->filePath, $data); return $original; }
[ "public", "function", "deserialize", "(", "array", "$", "data", ")", "{", "$", "original", "=", "$", "data", ";", "$", "this", "->", "deserializeTos", "(", "$", "data", ")", ";", "$", "data", "=", "$", "this", "->", "getJavascriptsData", "(", "$", "d...
Deserializes the parameters list. @param array $data - the data to deserialize @return array
[ "Deserializes", "the", "parameters", "list", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/ParametersSerializer.php#L97-L114
40,424
claroline/Distribution
main/app/API/ValidatorProvider.php
ValidatorProvider.validate
public function validate($class, $data, $mode, $throwException = false, array $options = []) { $schema = $this->serializer->getSchema($class); //schema isn't always there yet if ($schema) { $validator = Validator::buildDefault(); $errors = $validator->validate($this->toObject($data), $schema, '', [$mode]); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } if (count($errors) > 0) { return $errors; } } //validate uniques try { $validator = $this->get($class); } catch (\Exception $e) { //no custom validator $uniqueFields = []; $identifiers = $this->serializer->getIdentifiers($class); foreach ($identifiers as $identifier) { $uniqueFields[$identifier] = $identifier; } return $this->validateUnique($uniqueFields, $data, $mode, $class); } //can be deduced from the mapping, but we won't know //wich field is related to wich data prop in that case $uniqueFields = $validator->getUniqueFields(); $errors = $this->validateUnique($uniqueFields, $data, $mode, $class); //custom validation $errors = array_merge($errors, $validator->validate($data, $mode, $options)); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } return $errors; }
php
public function validate($class, $data, $mode, $throwException = false, array $options = []) { $schema = $this->serializer->getSchema($class); //schema isn't always there yet if ($schema) { $validator = Validator::buildDefault(); $errors = $validator->validate($this->toObject($data), $schema, '', [$mode]); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } if (count($errors) > 0) { return $errors; } } //validate uniques try { $validator = $this->get($class); } catch (\Exception $e) { //no custom validator $uniqueFields = []; $identifiers = $this->serializer->getIdentifiers($class); foreach ($identifiers as $identifier) { $uniqueFields[$identifier] = $identifier; } return $this->validateUnique($uniqueFields, $data, $mode, $class); } //can be deduced from the mapping, but we won't know //wich field is related to wich data prop in that case $uniqueFields = $validator->getUniqueFields(); $errors = $this->validateUnique($uniqueFields, $data, $mode, $class); //custom validation $errors = array_merge($errors, $validator->validate($data, $mode, $options)); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } return $errors; }
[ "public", "function", "validate", "(", "$", "class", ",", "$", "data", ",", "$", "mode", ",", "$", "throwException", "=", "false", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "schema", "=", "$", "this", "->", "serializer", "->", "ge...
Validates `data` using the `class` validator. @param string $class - the class of the validator to use @param mixed $data - the data to validate @param string $mode - 'create', 'update' @param bool $throwException - if true an InvalidDataException is thrown instead of returning the errors @return array - the list of validation errors @throws InvalidDataException
[ "Validates", "data", "using", "the", "class", "validator", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/ValidatorProvider.php#L102-L154
40,425
claroline/Distribution
main/app/API/ValidatorProvider.php
ValidatorProvider.validateUnique
private function validateUnique(array $uniqueFields, array $data, $mode, $class) { $errors = []; foreach ($uniqueFields as $dataProp => $entityProp) { if (isset($data[$dataProp])) { $qb = $this->om->createQueryBuilder(); $qb->select('DISTINCT o') ->from($class, 'o') ->where("o.{$entityProp} LIKE :{$entityProp}") ->setParameter($entityProp, $data[$dataProp]); if (self::UPDATE === $mode && isset($data['id'])) { $parameter = is_numeric($data['id']) ? 'id' : 'uuid'; $value = is_numeric($data['id']) ? (int) $data['id'] : $data['id']; $qb->setParameter($parameter, $value)->andWhere("o.{$parameter} != :{$parameter}"); } $objects = $qb->getQuery()->getResult(); if ((self::UPDATE === $mode && isset($data['id'])) || self::CREATE === $mode) { if (count($objects) > 0) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } else { if (count($objects) > 1) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } } } return $errors; }
php
private function validateUnique(array $uniqueFields, array $data, $mode, $class) { $errors = []; foreach ($uniqueFields as $dataProp => $entityProp) { if (isset($data[$dataProp])) { $qb = $this->om->createQueryBuilder(); $qb->select('DISTINCT o') ->from($class, 'o') ->where("o.{$entityProp} LIKE :{$entityProp}") ->setParameter($entityProp, $data[$dataProp]); if (self::UPDATE === $mode && isset($data['id'])) { $parameter = is_numeric($data['id']) ? 'id' : 'uuid'; $value = is_numeric($data['id']) ? (int) $data['id'] : $data['id']; $qb->setParameter($parameter, $value)->andWhere("o.{$parameter} != :{$parameter}"); } $objects = $qb->getQuery()->getResult(); if ((self::UPDATE === $mode && isset($data['id'])) || self::CREATE === $mode) { if (count($objects) > 0) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } else { if (count($objects) > 1) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } } } return $errors; }
[ "private", "function", "validateUnique", "(", "array", "$", "uniqueFields", ",", "array", "$", "data", ",", "$", "mode", ",", "$", "class", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "uniqueFields", "as", "$", "dataProp", "=>", ...
only if uniqueFields in data
[ "only", "if", "uniqueFields", "in", "data" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/ValidatorProvider.php#L173-L207
40,426
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.export
public function export(ResourceNode $node, $locale = 'en', $scormVersion = '2004') { if ('2004' !== $scormVersion && '1.2' !== $scormVersion) { // Invalid Scorm version throw new \Exception('SCORM export : Invalid SCORM version.'); } $resource = $this->resourceManager->getResourceFromNode($node); if (!$resource) { throw new ResourceNotFoundException('SCORM export : The resource '.$node->getName().' was not found'); } // Export the Resource and all it's sub-resources $exportedResources = $this->exportResource($resource, $locale); // Create the manifest for the Scorm package if ('1.2' === $scormVersion) { $manifest = new Scorm12Manifest($node, $exportedResources); } else { $manifest = new Scorm2004Manifest($node, $exportedResources); } $package = $this->createPackage($node, $locale, $manifest, $exportedResources); return $package; }
php
public function export(ResourceNode $node, $locale = 'en', $scormVersion = '2004') { if ('2004' !== $scormVersion && '1.2' !== $scormVersion) { // Invalid Scorm version throw new \Exception('SCORM export : Invalid SCORM version.'); } $resource = $this->resourceManager->getResourceFromNode($node); if (!$resource) { throw new ResourceNotFoundException('SCORM export : The resource '.$node->getName().' was not found'); } // Export the Resource and all it's sub-resources $exportedResources = $this->exportResource($resource, $locale); // Create the manifest for the Scorm package if ('1.2' === $scormVersion) { $manifest = new Scorm12Manifest($node, $exportedResources); } else { $manifest = new Scorm2004Manifest($node, $exportedResources); } $package = $this->createPackage($node, $locale, $manifest, $exportedResources); return $package; }
[ "public", "function", "export", "(", "ResourceNode", "$", "node", ",", "$", "locale", "=", "'en'", ",", "$", "scormVersion", "=", "'2004'", ")", "{", "if", "(", "'2004'", "!==", "$", "scormVersion", "&&", "'1.2'", "!==", "$", "scormVersion", ")", "{", ...
Create a Scorm archive for a ResourceNode. @param ResourceNode $node @param string $locale @param string $scormVersion @return \ZipArchive @throws ResourceNotFoundException @throws \Exception
[ "Create", "a", "Scorm", "archive", "for", "a", "ResourceNode", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L117-L142
40,427
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.exportResource
private function exportResource(AbstractResource $resource, $locale) { $resources = []; $event = $this->dispatchEvent($resource, $locale); $embedResources = $event->getEmbedResources(); // Grab data from event $resources[$resource->getResourceNode()->getId()] = [ 'node' => $resource->getResourceNode(), 'template' => $event->getTemplate(), 'assets' => $event->getAssets(), 'files' => $event->getFiles(), 'translation_domains' => $event->getTranslationDomains(), 'resources' => array_keys($embedResources), // We only need IDs ]; if (!empty($embedResources)) { foreach ($embedResources as $embedResource) { if (empty($resources[$embedResource->getResourceNode()->getId()])) { // Current resource has not been exported yet $exported = $this->exportResource($embedResource, $locale); $resources = array_merge($resources, $exported); } } } return $resources; }
php
private function exportResource(AbstractResource $resource, $locale) { $resources = []; $event = $this->dispatchEvent($resource, $locale); $embedResources = $event->getEmbedResources(); // Grab data from event $resources[$resource->getResourceNode()->getId()] = [ 'node' => $resource->getResourceNode(), 'template' => $event->getTemplate(), 'assets' => $event->getAssets(), 'files' => $event->getFiles(), 'translation_domains' => $event->getTranslationDomains(), 'resources' => array_keys($embedResources), // We only need IDs ]; if (!empty($embedResources)) { foreach ($embedResources as $embedResource) { if (empty($resources[$embedResource->getResourceNode()->getId()])) { // Current resource has not been exported yet $exported = $this->exportResource($embedResource, $locale); $resources = array_merge($resources, $exported); } } } return $resources; }
[ "private", "function", "exportResource", "(", "AbstractResource", "$", "resource", ",", "$", "locale", ")", "{", "$", "resources", "=", "[", "]", ";", "$", "event", "=", "$", "this", "->", "dispatchEvent", "(", "$", "resource", ",", "$", "locale", ")", ...
Export a Claroline Resource and all it's embed Resources. @param AbstractResource $resource @param string $locale @return array - The list of exported resource
[ "Export", "a", "Claroline", "Resource", "and", "all", "it", "s", "embed", "Resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L152-L180
40,428
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.dispatchEvent
private function dispatchEvent(AbstractResource $resource, $locale) { return $this->dispatcher->dispatch( 'export_scorm_'.$resource->getResourceNode()->getResourceType()->getName(), 'Claroline\\ScormBundle\\Event\\ExportScormResourceEvent', [$resource, $locale] ); }
php
private function dispatchEvent(AbstractResource $resource, $locale) { return $this->dispatcher->dispatch( 'export_scorm_'.$resource->getResourceNode()->getResourceType()->getName(), 'Claroline\\ScormBundle\\Event\\ExportScormResourceEvent', [$resource, $locale] ); }
[ "private", "function", "dispatchEvent", "(", "AbstractResource", "$", "resource", ",", "$", "locale", ")", "{", "return", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'export_scorm_'", ".", "$", "resource", "->", "getResourceNode", "(", ")", "->", ...
Dispatch export event for the Resource. @param AbstractResource $resource @param string $locale @return ExportScormResourceEvent
[ "Dispatch", "export", "event", "for", "the", "Resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L190-L197
40,429
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.createPackage
public function createPackage(ResourceNode $node, $locale, AbstractScormManifest $manifest, array $scos = []) { $scormId = 'scorm-'.$node->getId().'-'.date('YmdHis'); // Create and open scorm archive if (!is_dir($this->tmpPath)) { mkdir($this->tmpPath); } $archive = new \ZipArchive(); $archive->open($this->tmpPath.DIRECTORY_SEPARATOR.$scormId.'.zip', \ZipArchive::CREATE); // Add manifest $this->saveToPackage($archive, 'imsmanifest.xml', $manifest->dump()); // Add common files $this->addCommons($archive, $locale); // Add resources files foreach ($scos as $sco) { // Dump template into file $this->saveToPackage($archive, 'scos/resource_'.$sco['node']->getId().'.html', $sco['template']); // Dump additional resource assets if (!empty($sco['assets'])) { foreach ($sco['assets'] as $filename => $originalFile) { $this->copyToPackage($archive, 'assets/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } } // Add uploaded files if (!empty($sco['files'])) { // $this->container->getParameter('claroline.param.files_directory') foreach ($sco['files'] as $filename => $originalFile) { $filePath = $originalFile['absolute'] ? $originalFile['path'] : $this->getFilePath($this->uploadPath, $originalFile['path']); $this->copyToPackage($archive, 'files/'.$filename, $filePath); } } // Add translations if (!empty($sco['translation_domains'])) { foreach ($sco['translation_domains'] as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } } } $archive->close(); return $archive; }
php
public function createPackage(ResourceNode $node, $locale, AbstractScormManifest $manifest, array $scos = []) { $scormId = 'scorm-'.$node->getId().'-'.date('YmdHis'); // Create and open scorm archive if (!is_dir($this->tmpPath)) { mkdir($this->tmpPath); } $archive = new \ZipArchive(); $archive->open($this->tmpPath.DIRECTORY_SEPARATOR.$scormId.'.zip', \ZipArchive::CREATE); // Add manifest $this->saveToPackage($archive, 'imsmanifest.xml', $manifest->dump()); // Add common files $this->addCommons($archive, $locale); // Add resources files foreach ($scos as $sco) { // Dump template into file $this->saveToPackage($archive, 'scos/resource_'.$sco['node']->getId().'.html', $sco['template']); // Dump additional resource assets if (!empty($sco['assets'])) { foreach ($sco['assets'] as $filename => $originalFile) { $this->copyToPackage($archive, 'assets/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } } // Add uploaded files if (!empty($sco['files'])) { // $this->container->getParameter('claroline.param.files_directory') foreach ($sco['files'] as $filename => $originalFile) { $filePath = $originalFile['absolute'] ? $originalFile['path'] : $this->getFilePath($this->uploadPath, $originalFile['path']); $this->copyToPackage($archive, 'files/'.$filename, $filePath); } } // Add translations if (!empty($sco['translation_domains'])) { foreach ($sco['translation_domains'] as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } } } $archive->close(); return $archive; }
[ "public", "function", "createPackage", "(", "ResourceNode", "$", "node", ",", "$", "locale", ",", "AbstractScormManifest", "$", "manifest", ",", "array", "$", "scos", "=", "[", "]", ")", "{", "$", "scormId", "=", "'scorm-'", ".", "$", "node", "->", "getI...
Create SCORM package. @param ResourceNode $node - The exported ResourceNode @param string $locale - THe locale to use for export @param AbstractScormManifest $manifest - The manifest of the SCORM package @param array $scos - The list of resources to include into the package @return \ZipArchive
[ "Create", "SCORM", "package", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L209-L260
40,430
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.addCommons
private function addCommons(\ZipArchive $archive, $locale) { $assets = [ 'bootstrap.css' => 'themes/claroline/bootstrap.css', 'fontawesome' => 'packages/@fortawesome/fontawesome-free/css/fontawesome.css', 'v4-shims' => 'packages/@fortawesome/fontawesome-free/css/v4-shims.css', 'solid' => 'packages/@fortawesome/fontawesome-free/css/solid.css', 'regular' => 'packages/@fortawesome/fontawesome-free/css/regular.css', 'brands' => 'packages/@fortawesome/fontawesome-free/css/brands.css', 'claroline-reset.css' => 'vendor/clarolinescorm/claroline-reset.css', 'jquery.min.js' => 'packages/jquery/dist/jquery.min.js', 'jquery-ui.min.js' => 'packages/jquery-ui-dist/jquery-ui.min.js', 'bootstrap.min.js' => 'packages/bootstrap/dist/js/bootstrap.min.js', 'translator.js' => 'bundles/bazingajstranslation/js/translator.min.js', 'router.js' => 'bundles/fosjsrouting/js/router.js', 'video.min.js' => 'packages/video.js/dist/video.min.js', 'video-js.min.css' => 'packages/video.js/dist/video-js.min.css', 'video-js.swf' => 'packages/video.js/dist/video-js.swf', ]; $webpackAssets = [ 'commons.js' => 'dist/commons.js', 'claroline-distribution-plugin-video-player-watcher.js' => 'dist/claroline-distribution-plugin-video-player-watcher.js', ]; $translationDomains = [ 'resource', 'home', 'platform', 'error', 'validators', ]; foreach ($assets as $filename => $originalFile) { $this->copyToPackage($archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } // Add webpack assets foreach ($webpackAssets as $filename => $originalFile) { $this->copyToPackage( $archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $this->webpack->hotAsset($originalFile, true)) ); } // Add FontAwesome font files $fontDir = $this->webPath.DIRECTORY_SEPARATOR.'packages/@fortawesome/fontawesome-free/webfonts'; $files = scandir($fontDir); foreach ($files as $file) { $filePath = $fontDir.DIRECTORY_SEPARATOR.$file; if (is_file($filePath)) { $this->copyToPackage($archive, 'fonts/'.$file, $this->getFilePath($fontDir, $file)); } } // Generate JS routes with FOSJSRoutingBundle $request = new Request([ 'callback' => 'fos.Router.setData', ]); $jsRoutes = $this->jsRouterCtrl->indexAction($request, 'js'); $this->saveToPackage($archive, 'commons/routes.js', $jsRoutes->getContent()); // Add common translations foreach ($translationDomains as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } }
php
private function addCommons(\ZipArchive $archive, $locale) { $assets = [ 'bootstrap.css' => 'themes/claroline/bootstrap.css', 'fontawesome' => 'packages/@fortawesome/fontawesome-free/css/fontawesome.css', 'v4-shims' => 'packages/@fortawesome/fontawesome-free/css/v4-shims.css', 'solid' => 'packages/@fortawesome/fontawesome-free/css/solid.css', 'regular' => 'packages/@fortawesome/fontawesome-free/css/regular.css', 'brands' => 'packages/@fortawesome/fontawesome-free/css/brands.css', 'claroline-reset.css' => 'vendor/clarolinescorm/claroline-reset.css', 'jquery.min.js' => 'packages/jquery/dist/jquery.min.js', 'jquery-ui.min.js' => 'packages/jquery-ui-dist/jquery-ui.min.js', 'bootstrap.min.js' => 'packages/bootstrap/dist/js/bootstrap.min.js', 'translator.js' => 'bundles/bazingajstranslation/js/translator.min.js', 'router.js' => 'bundles/fosjsrouting/js/router.js', 'video.min.js' => 'packages/video.js/dist/video.min.js', 'video-js.min.css' => 'packages/video.js/dist/video-js.min.css', 'video-js.swf' => 'packages/video.js/dist/video-js.swf', ]; $webpackAssets = [ 'commons.js' => 'dist/commons.js', 'claroline-distribution-plugin-video-player-watcher.js' => 'dist/claroline-distribution-plugin-video-player-watcher.js', ]; $translationDomains = [ 'resource', 'home', 'platform', 'error', 'validators', ]; foreach ($assets as $filename => $originalFile) { $this->copyToPackage($archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } // Add webpack assets foreach ($webpackAssets as $filename => $originalFile) { $this->copyToPackage( $archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $this->webpack->hotAsset($originalFile, true)) ); } // Add FontAwesome font files $fontDir = $this->webPath.DIRECTORY_SEPARATOR.'packages/@fortawesome/fontawesome-free/webfonts'; $files = scandir($fontDir); foreach ($files as $file) { $filePath = $fontDir.DIRECTORY_SEPARATOR.$file; if (is_file($filePath)) { $this->copyToPackage($archive, 'fonts/'.$file, $this->getFilePath($fontDir, $file)); } } // Generate JS routes with FOSJSRoutingBundle $request = new Request([ 'callback' => 'fos.Router.setData', ]); $jsRoutes = $this->jsRouterCtrl->indexAction($request, 'js'); $this->saveToPackage($archive, 'commons/routes.js', $jsRoutes->getContent()); // Add common translations foreach ($translationDomains as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } }
[ "private", "function", "addCommons", "(", "\\", "ZipArchive", "$", "archive", ",", "$", "locale", ")", "{", "$", "assets", "=", "[", "'bootstrap.css'", "=>", "'themes/claroline/bootstrap.css'", ",", "'fontawesome'", "=>", "'packages/@fortawesome/fontawesome-free/css/fon...
Adds the claroline common assets and translations into the package. @param \ZipArchive $archive @param string $locale
[ "Adds", "the", "claroline", "common", "assets", "and", "translations", "into", "the", "package", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L268-L336
40,431
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.copyToPackage
private function copyToPackage(\ZipArchive $archive, $pathInArchive, $path) { if (file_exists($path)) { if (is_dir($path)) { /** @var \SplFileInfo[] $files */ $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $file) { // Skip directories if (!$file->isDir()) { // Get real and relative path for current file // Add current file to archive $archive->addFile( $path.DIRECTORY_SEPARATOR.$file->getFilename(), $pathInArchive.DIRECTORY_SEPARATOR.$file->getFilename()); } } } else { $archive->addFile($path, $pathInArchive); } } else { throw new FileNotFoundException(sprintf('File "%s" could not be found.', $path)); } }
php
private function copyToPackage(\ZipArchive $archive, $pathInArchive, $path) { if (file_exists($path)) { if (is_dir($path)) { /** @var \SplFileInfo[] $files */ $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $file) { // Skip directories if (!$file->isDir()) { // Get real and relative path for current file // Add current file to archive $archive->addFile( $path.DIRECTORY_SEPARATOR.$file->getFilename(), $pathInArchive.DIRECTORY_SEPARATOR.$file->getFilename()); } } } else { $archive->addFile($path, $pathInArchive); } } else { throw new FileNotFoundException(sprintf('File "%s" could not be found.', $path)); } }
[ "private", "function", "copyToPackage", "(", "\\", "ZipArchive", "$", "archive", ",", "$", "pathInArchive", ",", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", ...
Copy file into the SCORM package. @param \ZipArchive $archive @param string $pathInArchive @param string $path
[ "Copy", "file", "into", "the", "SCORM", "package", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L345-L370
40,432
claroline/Distribution
main/core/Repository/ResourceTypeRepository.php
ResourceTypeRepository.findAll
public function findAll($filterEnabled = true) { if (!$filterEnabled) { return parent::findAll(); } $dql = ' SELECT rt FROM Claroline\CoreBundle\Entity\Resource\ResourceType rt LEFT JOIN rt.plugin p WHERE (CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR rt.plugin is NULL) AND rt.isEnabled = true'; $query = $this->_em->createQuery($dql); $query->setParameter('bundles', $this->bundles); return $query->getResult(); }
php
public function findAll($filterEnabled = true) { if (!$filterEnabled) { return parent::findAll(); } $dql = ' SELECT rt FROM Claroline\CoreBundle\Entity\Resource\ResourceType rt LEFT JOIN rt.plugin p WHERE (CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR rt.plugin is NULL) AND rt.isEnabled = true'; $query = $this->_em->createQuery($dql); $query->setParameter('bundles', $this->bundles); return $query->getResult(); }
[ "public", "function", "findAll", "(", "$", "filterEnabled", "=", "true", ")", "{", "if", "(", "!", "$", "filterEnabled", ")", "{", "return", "parent", "::", "findAll", "(", ")", ";", "}", "$", "dql", "=", "'\n SELECT rt FROM Claroline\\CoreBundle\\Ent...
Returns all the resource types introduced by plugins. @param bool $filterEnabled - when true, it will only return resource types for enabled plugins @return ResourceType[]
[ "Returns", "all", "the", "resource", "types", "introduced", "by", "plugins", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceTypeRepository.php#L92-L109
40,433
claroline/Distribution
main/core/Repository/ResourceTypeRepository.php
ResourceTypeRepository.findEnabledResourceTypesByNames
public function findEnabledResourceTypesByNames(array $names) { if (count($names) > 0) { $dql = ' SELECT r FROM Claroline\CoreBundle\Entity\Resource\ResourceType r WHERE r.isEnabled = true AND r.name IN (:names) '; $query = $this->_em->createQuery($dql); $query->setParameter('names', $names); $result = $query->getResult(); } else { $result = []; } return $result; }
php
public function findEnabledResourceTypesByNames(array $names) { if (count($names) > 0) { $dql = ' SELECT r FROM Claroline\CoreBundle\Entity\Resource\ResourceType r WHERE r.isEnabled = true AND r.name IN (:names) '; $query = $this->_em->createQuery($dql); $query->setParameter('names', $names); $result = $query->getResult(); } else { $result = []; } return $result; }
[ "public", "function", "findEnabledResourceTypesByNames", "(", "array", "$", "names", ")", "{", "if", "(", "count", "(", "$", "names", ")", ">", "0", ")", "{", "$", "dql", "=", "'\n SELECT r\n FROM Claroline\\CoreBundle\\Entity\\Resource\\Re...
Returns enabled resource types by their names. @param array $names @return ResourceType[]
[ "Returns", "enabled", "resource", "types", "by", "their", "names", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceTypeRepository.php#L144-L162
40,434
claroline/Distribution
main/core/Manager/Theme/ThemeBuilderManager.php
ThemeBuilderManager.rebuild
public function rebuild(array $themes, $cache = true) { $logs = []; foreach ($themes as $theme) { $logs[$theme->getNormalizedName()] = $this->rebuildTheme($theme, $cache); } return $logs; }
php
public function rebuild(array $themes, $cache = true) { $logs = []; foreach ($themes as $theme) { $logs[$theme->getNormalizedName()] = $this->rebuildTheme($theme, $cache); } return $logs; }
[ "public", "function", "rebuild", "(", "array", "$", "themes", ",", "$", "cache", "=", "true", ")", "{", "$", "logs", "=", "[", "]", ";", "foreach", "(", "$", "themes", "as", "$", "theme", ")", "{", "$", "logs", "[", "$", "theme", "->", "getNormal...
Rebuilds the list of themes passed as argument. @param Theme[] $themes @param bool $cache @return array
[ "Rebuilds", "the", "list", "of", "themes", "passed", "as", "argument", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Theme/ThemeBuilderManager.php#L86-L95
40,435
claroline/Distribution
main/core/Library/Utilities/ClaroUtilities.php
ClaroUtilities.getRealFileSize
public function getRealFileSize($fileSize) { //B goes at the end because it's always matched otherwise $validUnits = ['KB', 'MB', 'GB', 'TB']; $value = str_replace(' ', '', $fileSize); $pattern = '/\d+/'; preg_match($pattern, $value, $match); foreach ($validUnits as $unit) { if (strpos($fileSize, $unit)) { switch ($unit) { case 'B': return $match[0] * pow(1024, 0); case 'KB': return $match[0] * pow(1024, 1); case 'MB': return $match[0] * pow(1024, 2); case 'GB': return $match[0] * pow(1024, 3); case 'TB': return $match[0] * pow(1024, 4); } } } return $fileSize; }
php
public function getRealFileSize($fileSize) { //B goes at the end because it's always matched otherwise $validUnits = ['KB', 'MB', 'GB', 'TB']; $value = str_replace(' ', '', $fileSize); $pattern = '/\d+/'; preg_match($pattern, $value, $match); foreach ($validUnits as $unit) { if (strpos($fileSize, $unit)) { switch ($unit) { case 'B': return $match[0] * pow(1024, 0); case 'KB': return $match[0] * pow(1024, 1); case 'MB': return $match[0] * pow(1024, 2); case 'GB': return $match[0] * pow(1024, 3); case 'TB': return $match[0] * pow(1024, 4); } } } return $fileSize; }
[ "public", "function", "getRealFileSize", "(", "$", "fileSize", ")", "{", "//B goes at the end because it's always matched otherwise", "$", "validUnits", "=", "[", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", "]", ";", "$", "value", "=", "str_replace", "(", "' ...
Take a formatted file size and returns the number of bytes. @deprecated. just let the client do it for you
[ "Take", "a", "formatted", "file", "size", "and", "returns", "the", "number", "of", "bytes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Utilities/ClaroUtilities.php#L181-L208
40,436
claroline/Distribution
plugin/reservation/Controller/API/ResourceController.php
ResourceController.listOrganizationsAction
public function listOrganizationsAction($id, Request $request) { $resource = $this->resourceRepo->findOneBy(['uuid' => $id]); $organizations = !empty($resource) ? $resource->getOrganizations() : []; $organizationsUuids = array_map(function (Organization $organization) { return $organization->getUuid(); }, $organizations); return new JsonResponse( $this->finder->search('Claroline\CoreBundle\Entity\Organization\Organization', array_merge( $request->query->all(), ['hiddenFilters' => ['whitelist' => $organizationsUuids]] )) ); }
php
public function listOrganizationsAction($id, Request $request) { $resource = $this->resourceRepo->findOneBy(['uuid' => $id]); $organizations = !empty($resource) ? $resource->getOrganizations() : []; $organizationsUuids = array_map(function (Organization $organization) { return $organization->getUuid(); }, $organizations); return new JsonResponse( $this->finder->search('Claroline\CoreBundle\Entity\Organization\Organization', array_merge( $request->query->all(), ['hiddenFilters' => ['whitelist' => $organizationsUuids]] )) ); }
[ "public", "function", "listOrganizationsAction", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "resource", "=", "$", "this", "->", "resourceRepo", "->", "findOneBy", "(", "[", "'uuid'", "=>", "$", "id", "]", ")", ";", "$", "organizations...
List organizations of the collection. @Route("/{id}/organization") @Method("GET") @param string $id @param Request $request @return JsonResponse
[ "List", "organizations", "of", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Controller/API/ResourceController.php#L72-L86
40,437
claroline/Distribution
plugin/reservation/Controller/API/ResourceController.php
ResourceController.exportResourcesAction
public function exportResourcesAction(Request $request) { $resources = $this->decodeIdsString($request, 'FormaLibre\ReservationBundle\Entity\Resource'); $response = new StreamedResponse(function () use ($resources) { $file = fopen('php://output', 'w'); fputcsv($file, [ 'resourceType.name', 'id', 'name', 'maxTimeReservation', 'description', 'localization', 'quantity', 'color', ], ';', '"'); foreach ($resources as $resource) { if (!empty($resource)) { $resourceType = $resource->getResourceType(); $data = [ $resourceType->getName(), $resource->getUuid(), $resource->getName(), $resource->getMaxTimeReservation(), $resource->getDescription(), $resource->getLocalisation(), $resource->getQuantity(), $resource->getColor(), ]; fputcsv($file, $data, ';', '"'); } } fclose($file); }); $response->headers->set('Content-Transfer-Encoding', 'octet-stream'); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-Disposition', 'attachment; filename="resources.csv"'); $response->headers->set('Content-Type', 'application/csv; charset=utf-8'); $response->headers->set('Connection', 'close'); $response->send(); return $response; }
php
public function exportResourcesAction(Request $request) { $resources = $this->decodeIdsString($request, 'FormaLibre\ReservationBundle\Entity\Resource'); $response = new StreamedResponse(function () use ($resources) { $file = fopen('php://output', 'w'); fputcsv($file, [ 'resourceType.name', 'id', 'name', 'maxTimeReservation', 'description', 'localization', 'quantity', 'color', ], ';', '"'); foreach ($resources as $resource) { if (!empty($resource)) { $resourceType = $resource->getResourceType(); $data = [ $resourceType->getName(), $resource->getUuid(), $resource->getName(), $resource->getMaxTimeReservation(), $resource->getDescription(), $resource->getLocalisation(), $resource->getQuantity(), $resource->getColor(), ]; fputcsv($file, $data, ';', '"'); } } fclose($file); }); $response->headers->set('Content-Transfer-Encoding', 'octet-stream'); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-Disposition', 'attachment; filename="resources.csv"'); $response->headers->set('Content-Type', 'application/csv; charset=utf-8'); $response->headers->set('Connection', 'close'); $response->send(); return $response; }
[ "public", "function", "exportResourcesAction", "(", "Request", "$", "request", ")", "{", "$", "resources", "=", "$", "this", "->", "decodeIdsString", "(", "$", "request", ",", "'FormaLibre\\ReservationBundle\\Entity\\Resource'", ")", ";", "$", "response", "=", "ne...
Exports resources. @Route( "/resources/export", name="apiv2_reservationresource_export" ) @Method("GET") @return StreamedResponse
[ "Exports", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Controller/API/ResourceController.php#L99-L142
40,438
claroline/Distribution
plugin/exo/Library/Item/Definition/AbstractDefinition.php
AbstractDefinition.validateAnswer
public function validateAnswer($answer, AbstractItem $question, array $options = []) { $options[Validation::QUESTION] = $question; return $this->getAnswerValidator()->validate($answer, $options); }
php
public function validateAnswer($answer, AbstractItem $question, array $options = []) { $options[Validation::QUESTION] = $question; return $this->getAnswerValidator()->validate($answer, $options); }
[ "public", "function", "validateAnswer", "(", "$", "answer", ",", "AbstractItem", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "Validation", "::", "QUESTION", "]", "=", "$", "question", ";", "return", "$", ...
Validates the answer data for a question. @param mixed $answer @param AbstractItem $question @param array $options @return array
[ "Validates", "the", "answer", "data", "for", "a", "question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/AbstractDefinition.php#L57-L62
40,439
claroline/Distribution
plugin/exo/Library/Item/Definition/AbstractDefinition.php
AbstractDefinition.deserializeQuestion
public function deserializeQuestion(array $questionData, AbstractItem $question = null, array $options = []) { return $this->getQuestionSerializer()->deserialize($questionData, $question, $options); }
php
public function deserializeQuestion(array $questionData, AbstractItem $question = null, array $options = []) { return $this->getQuestionSerializer()->deserialize($questionData, $question, $options); }
[ "public", "function", "deserializeQuestion", "(", "array", "$", "questionData", ",", "AbstractItem", "$", "question", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getQuestionSerializer", "(", ")", "->", ...
Deserializes question data. @param array $questionData @param AbstractItem $question @param array $options @return AbstractItem
[ "Deserializes", "question", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/AbstractDefinition.php#L86-L89
40,440
claroline/Distribution
plugin/blog/Controller/Resource/BlogController.php
BlogController.openAction
public function openAction(Blog $blog) { return $this->redirectToRoute('claro_resource_open', [ 'node' => $blog->getResourceNode()->getId(), 'resourceType' => $blog->getResourceNode()->getResourceType()->getName(), ], 301); }
php
public function openAction(Blog $blog) { return $this->redirectToRoute('claro_resource_open', [ 'node' => $blog->getResourceNode()->getId(), 'resourceType' => $blog->getResourceNode()->getResourceType()->getName(), ], 301); }
[ "public", "function", "openAction", "(", "Blog", "$", "blog", ")", "{", "return", "$", "this", "->", "redirectToRoute", "(", "'claro_resource_open'", ",", "[", "'node'", "=>", "$", "blog", "->", "getResourceNode", "(", ")", "->", "getId", "(", ")", ",", ...
Route parameter is for backwards compatibility and redirects old URLS to the new react ones. @EXT\Route("/{blogId}", name="icap_blog_open") @EXT\ParamConverter("blog", class="IcapBlogBundle:Blog", options={"id" = "blogId"})
[ "Route", "parameter", "is", "for", "backwards", "compatibility", "and", "redirects", "old", "URLS", "to", "the", "new", "react", "ones", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/Resource/BlogController.php#L80-L86
40,441
claroline/Distribution
plugin/notification/Manager/NotificationManager.php
NotificationManager.createNotification
public function createNotification($actionKey, $iconKey, $resourceId = null, $details = [], $doer = null) { $notification = new Notification(); $notification->setActionKey($actionKey); $notification->setIconKey($iconKey); $notification->setResourceId($resourceId); $doerId = null; if (null === $doer) { $doer = $this->getLoggedUser(); } if (is_a($doer, 'Claroline\CoreBundle\Entity\User')) { $doerId = $doer->getId(); } if (!isset($details['doer']) && !empty($doerId)) { $details['doer'] = [ 'id' => $doerId, 'firstName' => $doer->getFirstName(), 'lastName' => $doer->getLastName(), 'avatar' => $doer->getPicture(), 'publicUrl' => $doer->getPublicUrl(), ]; } $notification->setDetails($details); $notification->setUserId($doerId); $this->getEntityManager()->persist($notification); $this->getEntityManager()->flush(); return $notification; }
php
public function createNotification($actionKey, $iconKey, $resourceId = null, $details = [], $doer = null) { $notification = new Notification(); $notification->setActionKey($actionKey); $notification->setIconKey($iconKey); $notification->setResourceId($resourceId); $doerId = null; if (null === $doer) { $doer = $this->getLoggedUser(); } if (is_a($doer, 'Claroline\CoreBundle\Entity\User')) { $doerId = $doer->getId(); } if (!isset($details['doer']) && !empty($doerId)) { $details['doer'] = [ 'id' => $doerId, 'firstName' => $doer->getFirstName(), 'lastName' => $doer->getLastName(), 'avatar' => $doer->getPicture(), 'publicUrl' => $doer->getPublicUrl(), ]; } $notification->setDetails($details); $notification->setUserId($doerId); $this->getEntityManager()->persist($notification); $this->getEntityManager()->flush(); return $notification; }
[ "public", "function", "createNotification", "(", "$", "actionKey", ",", "$", "iconKey", ",", "$", "resourceId", "=", "null", ",", "$", "details", "=", "[", "]", ",", "$", "doer", "=", "null", ")", "{", "$", "notification", "=", "new", "Notification", "...
Create new Tag given its name. @param string $actionKey @param string $iconKey @param int|null $resourceId @param array $details @param object|null $doer @internal param \Icap\NotificationBundle\Entity\NotifiableInterface $notifiable @return Notification
[ "Create", "new", "Tag", "given", "its", "name", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/notification/Manager/NotificationManager.php#L290-L323
40,442
claroline/Distribution
plugin/notification/Manager/NotificationManager.php
NotificationManager.notifyUsers
public function notifyUsers(Notification $notification, $userIds) { if (count($userIds) > 0) { foreach ($userIds as $userId) { if (null !== $userId && $notification->getUserId() !== $userId) { $notificationViewer = new NotificationViewer(); $notificationViewer->setNotification($notification); $notificationViewer->setViewerId($userId); $notificationViewer->setStatus(false); $this->getEntityManager()->persist($notificationViewer); } } } $this->getEntityManager()->flush(); return $notification; }
php
public function notifyUsers(Notification $notification, $userIds) { if (count($userIds) > 0) { foreach ($userIds as $userId) { if (null !== $userId && $notification->getUserId() !== $userId) { $notificationViewer = new NotificationViewer(); $notificationViewer->setNotification($notification); $notificationViewer->setViewerId($userId); $notificationViewer->setStatus(false); $this->getEntityManager()->persist($notificationViewer); } } } $this->getEntityManager()->flush(); return $notification; }
[ "public", "function", "notifyUsers", "(", "Notification", "$", "notification", ",", "$", "userIds", ")", "{", "if", "(", "count", "(", "$", "userIds", ")", ">", "0", ")", "{", "foreach", "(", "$", "userIds", "as", "$", "userId", ")", "{", "if", "(", ...
Creates a notification viewer for every user in the list of people to be notified. @param Notification $notification @param $userIds @internal param \Icap\NotificationBundle\Entity\NotifiableInterface $notifiable @return \Icap\NotificationBundle\Entity\Notification
[ "Creates", "a", "notification", "viewer", "for", "every", "user", "in", "the", "list", "of", "people", "to", "be", "notified", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/notification/Manager/NotificationManager.php#L335-L351
40,443
claroline/Distribution
plugin/notification/Manager/NotificationManager.php
NotificationManager.createNotificationAndNotify
public function createNotificationAndNotify(NotifiableInterface $notifiable) { $userIds = $this->getUsersToNotifyForNotifiable($notifiable); $notification = null; if (count($userIds) > 0) { $resourceId = null; if (null !== $notifiable->getResource()) { $resourceId = $notifiable->getResource()->getId(); } $notification = $this->createNotification( $notifiable->getActionKey(), $notifiable->getIconKey(), $resourceId, $notifiable->getNotificationDetails(), $notifiable->getDoer() ); $this->notifyUsers($notification, $userIds); } return $notification; }
php
public function createNotificationAndNotify(NotifiableInterface $notifiable) { $userIds = $this->getUsersToNotifyForNotifiable($notifiable); $notification = null; if (count($userIds) > 0) { $resourceId = null; if (null !== $notifiable->getResource()) { $resourceId = $notifiable->getResource()->getId(); } $notification = $this->createNotification( $notifiable->getActionKey(), $notifiable->getIconKey(), $resourceId, $notifiable->getNotificationDetails(), $notifiable->getDoer() ); $this->notifyUsers($notification, $userIds); } return $notification; }
[ "public", "function", "createNotificationAndNotify", "(", "NotifiableInterface", "$", "notifiable", ")", "{", "$", "userIds", "=", "$", "this", "->", "getUsersToNotifyForNotifiable", "(", "$", "notifiable", ")", ";", "$", "notification", "=", "null", ";", "if", ...
Creates a notification and notifies the concerned users. @param NotifiableInterface $notifiable @return Notification
[ "Creates", "a", "notification", "and", "notifies", "the", "concerned", "users", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/notification/Manager/NotificationManager.php#L360-L382
40,444
claroline/Distribution
plugin/notification/Manager/NotificationManager.php
NotificationManager.getUserNotificationsList
public function getUserNotificationsList(User $user, $page = 1, $maxResult = -1, $isRss = false, $notificationParameters = null, $category = null) { $query = $this->getUserNotifications($user, $page, $maxResult, $isRss, $notificationParameters, false, $category); $adapter = new DoctrineORMAdapter($query, false); $pager = new Pagerfanta($adapter); $pager->setMaxPerPage($maxResult); try { $pager->setCurrentPage($page); } catch (NotValidCurrentPageException $e) { throw new NotFoundHttpException(); } $notifications = $this->renderNotifications($pager->getCurrentPageResults()); return [ 'pager' => $pager, 'notificationViews' => $notifications['views'], 'colors' => $notifications['colors'], ]; }
php
public function getUserNotificationsList(User $user, $page = 1, $maxResult = -1, $isRss = false, $notificationParameters = null, $category = null) { $query = $this->getUserNotifications($user, $page, $maxResult, $isRss, $notificationParameters, false, $category); $adapter = new DoctrineORMAdapter($query, false); $pager = new Pagerfanta($adapter); $pager->setMaxPerPage($maxResult); try { $pager->setCurrentPage($page); } catch (NotValidCurrentPageException $e) { throw new NotFoundHttpException(); } $notifications = $this->renderNotifications($pager->getCurrentPageResults()); return [ 'pager' => $pager, 'notificationViews' => $notifications['views'], 'colors' => $notifications['colors'], ]; }
[ "public", "function", "getUserNotificationsList", "(", "User", "$", "user", ",", "$", "page", "=", "1", ",", "$", "maxResult", "=", "-", "1", ",", "$", "isRss", "=", "false", ",", "$", "notificationParameters", "=", "null", ",", "$", "category", "=", "...
Retrieves the notifications list. @param int $userId @param int $page @param int $maxResult @param bool $isRss @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException @return mixed
[ "Retrieves", "the", "notifications", "list", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/notification/Manager/NotificationManager.php#L415-L434
40,445
claroline/Distribution
plugin/message/Serializer/MessageSerializer.php
MessageSerializer.getUserMessages
private function getUserMessages(Message $message) { $currentUser = $this->tokenStorage->getToken()->getUser(); return $this->om->getRepository(UserMessage::class)->findBy(['message' => $message, 'user' => $currentUser]); }
php
private function getUserMessages(Message $message) { $currentUser = $this->tokenStorage->getToken()->getUser(); return $this->om->getRepository(UserMessage::class)->findBy(['message' => $message, 'user' => $currentUser]); }
[ "private", "function", "getUserMessages", "(", "Message", "$", "message", ")", "{", "$", "currentUser", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "return", "$", "this", "->", "om", "->", "getRepos...
we return an array for backward compatibity. It used to create many messages for a single user.
[ "we", "return", "an", "array", "for", "backward", "compatibity", ".", "It", "used", "to", "create", "many", "messages", "for", "a", "single", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/message/Serializer/MessageSerializer.php#L166-L171
40,446
claroline/Distribution
plugin/reservation/Serializer/ResourceTypeSerializer.php
ResourceTypeSerializer.deserialize
public function deserialize($data, ResourceType $resourceType = null) { if (empty($resourceType)) { $resourceType = new ResourceType(); } $resourceType->setName($data['name']); return $resourceType; }
php
public function deserialize($data, ResourceType $resourceType = null) { if (empty($resourceType)) { $resourceType = new ResourceType(); } $resourceType->setName($data['name']); return $resourceType; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ResourceType", "$", "resourceType", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "resourceType", ")", ")", "{", "$", "resourceType", "=", "new", "ResourceType", "(", ")", ";", "}", "$...
Deserializes data into a ResourceType entity. @param \stdClass $data @param ResourceType $resourceType @return ResourceType
[ "Deserializes", "data", "into", "a", "ResourceType", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Serializer/ResourceTypeSerializer.php#L35-L43
40,447
claroline/Distribution
plugin/exo/Manager/CorrectionManager.php
CorrectionManager.save
public function save(array $correctedAnswers = []) { $updatedPapers = []; foreach ($correctedAnswers as $index => $correctedAnswer) { /** @var Answer $answer */ $answer = $this->om->getRepository('UJMExoBundle:Attempt\Answer')->findOneBy([ 'uuid' => $correctedAnswer['id'], ]); if (empty($answer)) { throw new InvalidDataException('Submitted answers are invalid', [[ 'path' => "/{$index}", 'message' => 'answer does not exists', ]]); } $question = $answer->getPaper()->getQuestion($answer->getQuestionId()); $decodedQuestion = $this->itemSerializer->deserialize($question, new Item()); // Update answer and apply hint penalties $this->answerManager->update($decodedQuestion, $answer, $correctedAnswer, true); if (!empty($answer->getUsedHints())) { $this->applyPenalties($answer); } $updatedPapers[$answer->getPaper()->getId()] = $answer->getPaper(); } // A first flush is needed because score calculation for the whole paper retrieve scores from DB $this->om->flush(); // Recalculate scores for updated papers foreach ($updatedPapers as $paper) { $newScore = $this->paperManager->calculateScore($paper); $paper->setScore($newScore); $this->om->persist($paper); $this->paperManager->checkPaperEvaluated($paper); } $this->om->flush(); }
php
public function save(array $correctedAnswers = []) { $updatedPapers = []; foreach ($correctedAnswers as $index => $correctedAnswer) { /** @var Answer $answer */ $answer = $this->om->getRepository('UJMExoBundle:Attempt\Answer')->findOneBy([ 'uuid' => $correctedAnswer['id'], ]); if (empty($answer)) { throw new InvalidDataException('Submitted answers are invalid', [[ 'path' => "/{$index}", 'message' => 'answer does not exists', ]]); } $question = $answer->getPaper()->getQuestion($answer->getQuestionId()); $decodedQuestion = $this->itemSerializer->deserialize($question, new Item()); // Update answer and apply hint penalties $this->answerManager->update($decodedQuestion, $answer, $correctedAnswer, true); if (!empty($answer->getUsedHints())) { $this->applyPenalties($answer); } $updatedPapers[$answer->getPaper()->getId()] = $answer->getPaper(); } // A first flush is needed because score calculation for the whole paper retrieve scores from DB $this->om->flush(); // Recalculate scores for updated papers foreach ($updatedPapers as $paper) { $newScore = $this->paperManager->calculateScore($paper); $paper->setScore($newScore); $this->om->persist($paper); $this->paperManager->checkPaperEvaluated($paper); } $this->om->flush(); }
[ "public", "function", "save", "(", "array", "$", "correctedAnswers", "=", "[", "]", ")", "{", "$", "updatedPapers", "=", "[", "]", ";", "foreach", "(", "$", "correctedAnswers", "as", "$", "index", "=>", "$", "correctedAnswer", ")", "{", "/** @var Answer $a...
Save scores and feedback for questions. @param array $correctedAnswers @throws InvalidDataException
[ "Save", "scores", "and", "feedback", "for", "questions", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/CorrectionManager.php#L108-L150
40,448
claroline/Distribution
main/core/Validator/Constraints/UserAdministrativeCodeValidator.php
UserAdministrativeCodeValidator.validate
public function validate($user, Constraint $constraint) { $code = $user->getAdministrativeCode(); if (!empty($code) && $this->platformConfigHandler->getParameter('is_user_admin_code_unique')) { $tmpUser = $this->om->getRepository('ClarolineCoreBundle:User')->findOneByAdministrativeCode($code); if ($tmpUser && $tmpUser->getUsername() !== $user->getUsername()) { $this->context->addViolationAt( 'administrativeCode', $this->translator->trans($constraint->error, ['%code%' => $code], 'platform') ); } } }
php
public function validate($user, Constraint $constraint) { $code = $user->getAdministrativeCode(); if (!empty($code) && $this->platformConfigHandler->getParameter('is_user_admin_code_unique')) { $tmpUser = $this->om->getRepository('ClarolineCoreBundle:User')->findOneByAdministrativeCode($code); if ($tmpUser && $tmpUser->getUsername() !== $user->getUsername()) { $this->context->addViolationAt( 'administrativeCode', $this->translator->trans($constraint->error, ['%code%' => $code], 'platform') ); } } }
[ "public", "function", "validate", "(", "$", "user", ",", "Constraint", "$", "constraint", ")", "{", "$", "code", "=", "$", "user", "->", "getAdministrativeCode", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "code", ")", "&&", "$", "this", "->", ...
Checks if administration code is unique. @param User $user @param Constraint $constraint
[ "Checks", "if", "administration", "code", "is", "unique", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Validator/Constraints/UserAdministrativeCodeValidator.php#L67-L79
40,449
claroline/Distribution
plugin/agenda/Manager/AgendaManager.php
AgendaManager.import
public function import($fileData, $workspace = null) { $ical = new ICal($fileData); $events = $ical->events(); $entities = []; foreach ($events as $event) { $e = new Event(); $e->setTitle($event->summary); $e->setStart($ical->iCalDateToUnixTimestamp($event->dtstart)); $e->setEnd($ical->iCalDateToUnixTimestamp($event->dtend)); $e->setDescription($event->description); if ($workspace) { $e->setWorkspace($workspace); } $e->setUser($this->tokenStorage->getToken()->getUser()); $e->setPriority('#01A9DB'); $this->om->persist($e); //the flush is required to generate an id $this->om->flush(); $entities[] = $e; } return $entities; }
php
public function import($fileData, $workspace = null) { $ical = new ICal($fileData); $events = $ical->events(); $entities = []; foreach ($events as $event) { $e = new Event(); $e->setTitle($event->summary); $e->setStart($ical->iCalDateToUnixTimestamp($event->dtstart)); $e->setEnd($ical->iCalDateToUnixTimestamp($event->dtend)); $e->setDescription($event->description); if ($workspace) { $e->setWorkspace($workspace); } $e->setUser($this->tokenStorage->getToken()->getUser()); $e->setPriority('#01A9DB'); $this->om->persist($e); //the flush is required to generate an id $this->om->flush(); $entities[] = $e; } return $entities; }
[ "public", "function", "import", "(", "$", "fileData", ",", "$", "workspace", "=", "null", ")", "{", "$", "ical", "=", "new", "ICal", "(", "$", "fileData", ")", ";", "$", "events", "=", "$", "ical", "->", "events", "(", ")", ";", "$", "entities", ...
Imports ical files. @param UploadedFile $file @param Workspace $workspace @return int number of events saved
[ "Imports", "ical", "files", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/agenda/Manager/AgendaManager.php#L193-L217
40,450
claroline/Distribution
plugin/agenda/Manager/AgendaManager.php
AgendaManager.replaceEventUser
public function replaceEventUser(User $from, User $to) { $events = $this->om->getRepository('ClarolineAgendaBundle:Event')->findBy(['user' => $from]); if (count($events) > 0) { foreach ($events as $event) { $event->setUser($to); } $this->om->flush(); } return count($events); }
php
public function replaceEventUser(User $from, User $to) { $events = $this->om->getRepository('ClarolineAgendaBundle:Event')->findBy(['user' => $from]); if (count($events) > 0) { foreach ($events as $event) { $event->setUser($to); } $this->om->flush(); } return count($events); }
[ "public", "function", "replaceEventUser", "(", "User", "$", "from", ",", "User", "$", "to", ")", "{", "$", "events", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineAgendaBundle:Event'", ")", "->", "findBy", "(", "[", "'user'", "=>", ...
Find every Event for a given user and the replace him by another. @param User $from @param User $to @return int
[ "Find", "every", "Event", "for", "a", "given", "user", "and", "the", "replace", "him", "by", "another", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/agenda/Manager/AgendaManager.php#L271-L284
40,451
claroline/Distribution
plugin/agenda/Manager/AgendaManager.php
AgendaManager.replaceEventInvitationUser
public function replaceEventInvitationUser(User $from, User $to) { $eventInvitations = $this->om->getRepository('ClarolineAgendaBundle:EventInvitation')->findByUser($from); if (count($eventInvitations) > 0) { foreach ($eventInvitations as $eventInvitation) { $eventInvitation->setUser($to); } $this->om->flush(); } return count($eventInvitations); }
php
public function replaceEventInvitationUser(User $from, User $to) { $eventInvitations = $this->om->getRepository('ClarolineAgendaBundle:EventInvitation')->findByUser($from); if (count($eventInvitations) > 0) { foreach ($eventInvitations as $eventInvitation) { $eventInvitation->setUser($to); } $this->om->flush(); } return count($eventInvitations); }
[ "public", "function", "replaceEventInvitationUser", "(", "User", "$", "from", ",", "User", "$", "to", ")", "{", "$", "eventInvitations", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineAgendaBundle:EventInvitation'", ")", "->", "findByUser", ...
Find every EventInvitation for a given user and the replace him by another. @param User $from @param User $to @return int
[ "Find", "every", "EventInvitation", "for", "a", "given", "user", "and", "the", "replace", "him", "by", "another", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/agenda/Manager/AgendaManager.php#L294-L307
40,452
claroline/Distribution
main/core/Listener/Administration/UserListener.php
UserListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:users.html.twig', [ // todo : put it in the async load of form 'parameters' => $this->parametersSerializer->serialize(), 'profile' => $this->profileSerializer->serialize(), 'platformRoles' => $this->finder->search('Claroline\CoreBundle\Entity\Role', [ 'filters' => ['type' => Role::PLATFORM_ROLE], ]), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:users.html.twig', [ // todo : put it in the async load of form 'parameters' => $this->parametersSerializer->serialize(), 'profile' => $this->profileSerializer->serialize(), 'platformRoles' => $this->finder->search('Claroline\CoreBundle\Entity\Role', [ 'filters' => ['type' => Role::PLATFORM_ROLE], ]), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:administration:users.html.twig'", ",", "[", "// todo : put it in the async l...
Displays user administration tool. @DI\Observe("administration_tool_user_management") @param OpenAdministrationToolEvent $event
[ "Displays", "user", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/UserListener.php#L85-L100
40,453
claroline/Distribution
plugin/exo/Validator/JsonSchema/Item/Type/WordsQuestionValidator.php
WordsQuestionValidator.validateSolutions
protected function validateSolutions(array $question) { return $this->keywordValidator->validateCollection($question['solutions'], [Validation::NO_SCHEMA, Validation::VALIDATE_SCORE]); }
php
protected function validateSolutions(array $question) { return $this->keywordValidator->validateCollection($question['solutions'], [Validation::NO_SCHEMA, Validation::VALIDATE_SCORE]); }
[ "protected", "function", "validateSolutions", "(", "array", "$", "question", ")", "{", "return", "$", "this", "->", "keywordValidator", "->", "validateCollection", "(", "$", "question", "[", "'solutions'", "]", ",", "[", "Validation", "::", "NO_SCHEMA", ",", "...
Validates the solution of the question. Sends the keywords collection to the keyword validator. @param array $question @return array
[ "Validates", "the", "solution", "of", "the", "question", ".", "Sends", "the", "keywords", "collection", "to", "the", "keyword", "validator", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Validator/JsonSchema/Item/Type/WordsQuestionValidator.php#L58-L61
40,454
claroline/Distribution
main/core/Repository/Facet/FacetRepository.php
FacetRepository.findVisibleFacets
public function findVisibleFacets(TokenInterface $token, $isRegistration = false) { // retrieves current user roles $roleNames = array_map(function (Role $role) { return $role->getRole(); }, $token->getRoles()); $qb = $this->createQueryBuilder('f'); if ($isRegistration) { $qb->andWhere('f.forceCreationForm = true'); } else { if (!in_array('ROLE_ADMIN', $roleNames)) { // filter query to only get accessible facets for the current roles $qb ->leftJoin('f.roles', 'r') ->where('(r.id IS NULL OR r.name IN (:roles))') ->setParameter('roles', $roleNames); } } $qb->orderBy('f.main DESC, f.position'); return $qb->getQuery()->getResult(); }
php
public function findVisibleFacets(TokenInterface $token, $isRegistration = false) { // retrieves current user roles $roleNames = array_map(function (Role $role) { return $role->getRole(); }, $token->getRoles()); $qb = $this->createQueryBuilder('f'); if ($isRegistration) { $qb->andWhere('f.forceCreationForm = true'); } else { if (!in_array('ROLE_ADMIN', $roleNames)) { // filter query to only get accessible facets for the current roles $qb ->leftJoin('f.roles', 'r') ->where('(r.id IS NULL OR r.name IN (:roles))') ->setParameter('roles', $roleNames); } } $qb->orderBy('f.main DESC, f.position'); return $qb->getQuery()->getResult(); }
[ "public", "function", "findVisibleFacets", "(", "TokenInterface", "$", "token", ",", "$", "isRegistration", "=", "false", ")", "{", "// retrieves current user roles", "$", "roleNames", "=", "array_map", "(", "function", "(", "Role", "$", "role", ")", "{", "retur...
Find facets visible by the current User. @param TokenInterface $token @param bool $isRegistration @return Facet[]
[ "Find", "facets", "visible", "by", "the", "current", "User", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/Facet/FacetRepository.php#L30-L54
40,455
claroline/Distribution
main/core/Manager/EventManager.php
EventManager.getEventsForApiFilter
public function getEventsForApiFilter($restriction = null) { $resourceOption = 'resource'; $allOption = 'all'; $eventNames = $this->getEvents($restriction); sort($eventNames); $sortedEvents = ['all' => 'all']; $genericResourceEvents = ['all' => 'all']; $tempResourceEvents = ['all' => []]; foreach ($eventNames as $eventName) { $eventNameChunks = explode('-', $eventName); $eventKey = "log_${eventName}_filter"; if ($eventNameChunks[0] !== 'clacoformbundle' && !isset($sortedEvents[$eventNameChunks[0]])) { $sortedEvents[$eventNameChunks[0]] = ['all' => "${eventNameChunks[0]}::all"]; } if ($resourceOption === $eventNameChunks[0]) { if (isset($eventNameChunks[2])) { $tempResourceEvents[$eventNameChunks[1]][$eventKey] = $eventName; } else { $genericResourceEvents[$eventKey] = $eventName; } } elseif ($eventNameChunks[0] === 'clacoformbundle') { $tempResourceEvents[$eventNameChunks[0]][$eventKey] = $eventName; } else { $sortedEvents[$eventNameChunks[0]][$eventKey] = $eventName; } } // adding resource types that don't define specific event classes $sortedEvents[$resourceOption][$allOption] = []; $remainingTypes = $this->om ->getRepository('ClarolineCoreBundle:Resource\ResourceType') ->findTypeNamesNotIn(array_keys($tempResourceEvents)); foreach ($remainingTypes as $type) { $tempResourceEvents[$type['name']] = []; } foreach (array_keys($tempResourceEvents) as $resourceType) { if ($resourceType === 'resource_shortcut') { continue; } foreach ($genericResourceEvents as $genericEventKey => $genericEventName) { $eventPrefix = ''; if ($allOption !== $resourceType) { $eventPrefix = "${resourceOption}::${resourceType}::"; } if ($allOption === $resourceType && $genericEventName === $allOption) { $eventPrefix = "${resourceOption}::"; } $sortedEvents[$resourceOption][$resourceType][$genericEventKey] = $eventPrefix.$genericEventName; } if ($allOption !== $resourceType) { foreach ($tempResourceEvents[$resourceType] as $resourceEventKey => $resourceEventName) { $sortedEvents[$resourceOption][$resourceType][$resourceEventKey] = $resourceEventName; } } } return $this->formatEventsTableForApi($sortedEvents); }
php
public function getEventsForApiFilter($restriction = null) { $resourceOption = 'resource'; $allOption = 'all'; $eventNames = $this->getEvents($restriction); sort($eventNames); $sortedEvents = ['all' => 'all']; $genericResourceEvents = ['all' => 'all']; $tempResourceEvents = ['all' => []]; foreach ($eventNames as $eventName) { $eventNameChunks = explode('-', $eventName); $eventKey = "log_${eventName}_filter"; if ($eventNameChunks[0] !== 'clacoformbundle' && !isset($sortedEvents[$eventNameChunks[0]])) { $sortedEvents[$eventNameChunks[0]] = ['all' => "${eventNameChunks[0]}::all"]; } if ($resourceOption === $eventNameChunks[0]) { if (isset($eventNameChunks[2])) { $tempResourceEvents[$eventNameChunks[1]][$eventKey] = $eventName; } else { $genericResourceEvents[$eventKey] = $eventName; } } elseif ($eventNameChunks[0] === 'clacoformbundle') { $tempResourceEvents[$eventNameChunks[0]][$eventKey] = $eventName; } else { $sortedEvents[$eventNameChunks[0]][$eventKey] = $eventName; } } // adding resource types that don't define specific event classes $sortedEvents[$resourceOption][$allOption] = []; $remainingTypes = $this->om ->getRepository('ClarolineCoreBundle:Resource\ResourceType') ->findTypeNamesNotIn(array_keys($tempResourceEvents)); foreach ($remainingTypes as $type) { $tempResourceEvents[$type['name']] = []; } foreach (array_keys($tempResourceEvents) as $resourceType) { if ($resourceType === 'resource_shortcut') { continue; } foreach ($genericResourceEvents as $genericEventKey => $genericEventName) { $eventPrefix = ''; if ($allOption !== $resourceType) { $eventPrefix = "${resourceOption}::${resourceType}::"; } if ($allOption === $resourceType && $genericEventName === $allOption) { $eventPrefix = "${resourceOption}::"; } $sortedEvents[$resourceOption][$resourceType][$genericEventKey] = $eventPrefix.$genericEventName; } if ($allOption !== $resourceType) { foreach ($tempResourceEvents[$resourceType] as $resourceEventKey => $resourceEventName) { $sortedEvents[$resourceOption][$resourceType][$resourceEventKey] = $resourceEventName; } } } return $this->formatEventsTableForApi($sortedEvents); }
[ "public", "function", "getEventsForApiFilter", "(", "$", "restriction", "=", "null", ")", "{", "$", "resourceOption", "=", "'resource'", ";", "$", "allOption", "=", "'all'", ";", "$", "eventNames", "=", "$", "this", "->", "getEvents", "(", "$", "restriction"...
Gets formated events for API filter. @param null|string $restriction @return array
[ "Gets", "formated", "events", "for", "API", "filter", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/EventManager.php#L265-L330
40,456
claroline/Distribution
main/core/Twig/WebpackExtension.php
WebpackExtension.hotAsset
public function hotAsset($path, $hot = true) { $assets = $this->getWebpackAssets(); $assetName = pathinfo($path, PATHINFO_FILENAME); if (!isset($assets[$assetName])) { $assetNames = implode("\n", array_keys($assets)); throw new \Exception( "Cannot find asset '{$assetName}' in webpack stats. Found:\n{$assetNames})" ); } if ('dev' === $this->environment && $hot) { // for dev serve fill from webpack-dev-server return 'http://localhost:8080/dist/'.$assets[$assetName]['js']; } // otherwise serve static generated files return $this->assetExtension->getAssetUrl( 'dist/'.$assets[$assetName]['js'] ); }
php
public function hotAsset($path, $hot = true) { $assets = $this->getWebpackAssets(); $assetName = pathinfo($path, PATHINFO_FILENAME); if (!isset($assets[$assetName])) { $assetNames = implode("\n", array_keys($assets)); throw new \Exception( "Cannot find asset '{$assetName}' in webpack stats. Found:\n{$assetNames})" ); } if ('dev' === $this->environment && $hot) { // for dev serve fill from webpack-dev-server return 'http://localhost:8080/dist/'.$assets[$assetName]['js']; } // otherwise serve static generated files return $this->assetExtension->getAssetUrl( 'dist/'.$assets[$assetName]['js'] ); }
[ "public", "function", "hotAsset", "(", "$", "path", ",", "$", "hot", "=", "true", ")", "{", "$", "assets", "=", "$", "this", "->", "getWebpackAssets", "(", ")", ";", "$", "assetName", "=", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ...
Returns the URL of an asset managed by webpack. The final URL will depend on the environment and the version hash generated by webpack. @param string $path @param bool $hot @return string @throws \Exception
[ "Returns", "the", "URL", "of", "an", "asset", "managed", "by", "webpack", ".", "The", "final", "URL", "will", "depend", "on", "the", "environment", "and", "the", "version", "hash", "generated", "by", "webpack", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Twig/WebpackExtension.php#L71-L93
40,457
claroline/Distribution
plugin/claco-form/Serializer/CommentSerializer.php
CommentSerializer.serialize
public function serialize(Comment $comment, array $options = []) { $user = $comment->getUser(); $serialized = [ 'id' => $comment->getUuid(), 'content' => $comment->getContent(), 'status' => $comment->getStatus(), 'creationDate' => $comment->getCreationDate() ? $comment->getCreationDate()->format('Y-m-d H:i:s') : null, 'editionDate' => $comment->getEditionDate() ? $comment->getEditionDate()->format('Y-m-d H:i:s') : null, 'user' => $user ? $this->userSerializer->serialize($user, [Options::SERIALIZE_MINIMAL]) : null, ]; return $serialized; }
php
public function serialize(Comment $comment, array $options = []) { $user = $comment->getUser(); $serialized = [ 'id' => $comment->getUuid(), 'content' => $comment->getContent(), 'status' => $comment->getStatus(), 'creationDate' => $comment->getCreationDate() ? $comment->getCreationDate()->format('Y-m-d H:i:s') : null, 'editionDate' => $comment->getEditionDate() ? $comment->getEditionDate()->format('Y-m-d H:i:s') : null, 'user' => $user ? $this->userSerializer->serialize($user, [Options::SERIALIZE_MINIMAL]) : null, ]; return $serialized; }
[ "public", "function", "serialize", "(", "Comment", "$", "comment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "user", "=", "$", "comment", "->", "getUser", "(", ")", ";", "$", "serialized", "=", "[", "'id'", "=>", "$", "comment", "...
Serializes a Comment entity for the JSON api. @param Comment $comment - the comment to serialize @param array $options - a list of serialization options @return array - the serialized representation of the comment
[ "Serializes", "a", "Comment", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/CommentSerializer.php#L41-L55
40,458
claroline/Distribution
plugin/path/Entity/Step.php
Step.addChild
public function addChild(Step $step) { if (!$this->children->contains($step)) { $this->children->add($step); $step->setParent($this); } return $this; }
php
public function addChild(Step $step) { if (!$this->children->contains($step)) { $this->children->add($step); $step->setParent($this); } return $this; }
[ "public", "function", "addChild", "(", "Step", "$", "step", ")", "{", "if", "(", "!", "$", "this", "->", "children", "->", "contains", "(", "$", "step", ")", ")", "{", "$", "this", "->", "children", "->", "add", "(", "$", "step", ")", ";", "$", ...
Add new child to the step. @param Step $step @return Step
[ "Add", "new", "child", "to", "the", "step", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Entity/Step.php#L327-L335
40,459
claroline/Distribution
plugin/path/Entity/Step.php
Step.removeChild
public function removeChild(Step $step) { if ($this->children->contains($step)) { $this->children->removeElement($step); $step->setParent(null); } return $this; }
php
public function removeChild(Step $step) { if ($this->children->contains($step)) { $this->children->removeElement($step); $step->setParent(null); } return $this; }
[ "public", "function", "removeChild", "(", "Step", "$", "step", ")", "{", "if", "(", "$", "this", "->", "children", "->", "contains", "(", "$", "step", ")", ")", "{", "$", "this", "->", "children", "->", "removeElement", "(", "$", "step", ")", ";", ...
Remove a step from children. @param Step $step @return Step
[ "Remove", "a", "step", "from", "children", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Entity/Step.php#L344-L352
40,460
claroline/Distribution
main/core/Controller/APINew/Model/HasWorkspacesTrait.php
HasWorkspacesTrait.addWorkspacesAction
public function addWorkspacesAction($id, $class, Request $request) { $object = $this->find($class, $id); $workspaces = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Workspace\Workspace'); $this->crud->patch($object, 'workspace', Crud::COLLECTION_ADD, $workspaces); return new JsonResponse( $this->serializer->serialize($object) ); }
php
public function addWorkspacesAction($id, $class, Request $request) { $object = $this->find($class, $id); $workspaces = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Workspace\Workspace'); $this->crud->patch($object, 'workspace', Crud::COLLECTION_ADD, $workspaces); return new JsonResponse( $this->serializer->serialize($object) ); }
[ "public", "function", "addWorkspacesAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "workspaces", "=", "$", "this...
Adds workspaces to the collection. @EXT\Route("/{id}/workspace") @EXT\Method("PATCH") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Adds", "workspaces", "to", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasWorkspacesTrait.php#L49-L58
40,461
claroline/Distribution
main/core/Controller/APINew/Model/HasWorkspacesTrait.php
HasWorkspacesTrait.removeWorkspacesAction
public function removeWorkspacesAction($id, $class, Request $request) { $object = $this->find($class, $id); $workspaces = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Workspace\Workspace'); $this->crud->patch($object, 'workspace', Crud::COLLECTION_REMOVE, $workspaces); return new JsonResponse( $this->serializer->serialize($object) ); }
php
public function removeWorkspacesAction($id, $class, Request $request) { $object = $this->find($class, $id); $workspaces = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\Workspace\Workspace'); $this->crud->patch($object, 'workspace', Crud::COLLECTION_REMOVE, $workspaces); return new JsonResponse( $this->serializer->serialize($object) ); }
[ "public", "function", "removeWorkspacesAction", "(", "$", "id", ",", "$", "class", ",", "Request", "$", "request", ")", "{", "$", "object", "=", "$", "this", "->", "find", "(", "$", "class", ",", "$", "id", ")", ";", "$", "workspaces", "=", "$", "t...
Removes workspaces from the collection. @EXT\Route("/{id}/workspace") @EXT\Method("DELETE") @param string $id @param string $class @param Request $request @return JsonResponse
[ "Removes", "workspaces", "from", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Model/HasWorkspacesTrait.php#L72-L81
40,462
claroline/Distribution
main/core/Listener/Administration/TechnicalListener.php
TechnicalListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:technical.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'adminTools' => array_map(function (AdminTool $tool) { return $tool->getName(); }, $this->om->getRepository(AdminTool::class)->findAll()), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:technical.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'adminTools' => array_map(function (AdminTool $tool) { return $tool->getName(); }, $this->om->getRepository(AdminTool::class)->findAll()), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:administration:technical.html.twig'", ",", "[", "'context'", "=>", "[", ...
Displays technical administration tool. @DI\Observe("administration_tool_technical_settings") @param OpenAdministrationToolEvent $event
[ "Displays", "technical", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/TechnicalListener.php#L54-L70
40,463
claroline/Distribution
main/core/Manager/Resource/ResourceActionManager.php
ResourceActionManager.support
public function support(ResourceNode $resourceNode, string $actionName, string $method): bool { $action = $this->get($resourceNode, $actionName); if (empty($action) || !in_array($method, $action->getApi())) { return false; } return true; }
php
public function support(ResourceNode $resourceNode, string $actionName, string $method): bool { $action = $this->get($resourceNode, $actionName); if (empty($action) || !in_array($method, $action->getApi())) { return false; } return true; }
[ "public", "function", "support", "(", "ResourceNode", "$", "resourceNode", ",", "string", "$", "actionName", ",", "string", "$", "method", ")", ":", "bool", "{", "$", "action", "=", "$", "this", "->", "get", "(", "$", "resourceNode", ",", "$", "actionNam...
Checks if the resource node supports an action. @param ResourceNode $resourceNode @param string $actionName @param string $method @return bool
[ "Checks", "if", "the", "resource", "node", "supports", "an", "action", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceActionManager.php#L95-L104
40,464
claroline/Distribution
main/core/Manager/Resource/ResourceActionManager.php
ResourceActionManager.execute
public function execute(ResourceNode $resourceNode, string $actionName, array $options = [], array $content = null, array $files = null): Response { $resourceAction = $this->get($resourceNode, $actionName); $resource = $this->resourceManager->getResourceFromNode($resourceNode); /** @var ResourceActionEvent $event */ $event = $this->dispatcher->dispatch( static::eventName($actionName, $resourceAction->getResourceType()), ResourceActionEvent::class, [$resource, $options, $content, $files, $resourceNode] ); return $event->getResponse(); }
php
public function execute(ResourceNode $resourceNode, string $actionName, array $options = [], array $content = null, array $files = null): Response { $resourceAction = $this->get($resourceNode, $actionName); $resource = $this->resourceManager->getResourceFromNode($resourceNode); /** @var ResourceActionEvent $event */ $event = $this->dispatcher->dispatch( static::eventName($actionName, $resourceAction->getResourceType()), ResourceActionEvent::class, [$resource, $options, $content, $files, $resourceNode] ); return $event->getResponse(); }
[ "public", "function", "execute", "(", "ResourceNode", "$", "resourceNode", ",", "string", "$", "actionName", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "content", "=", "null", ",", "array", "$", "files", "=", "null", ")", ":", "Res...
Executes an action on a resource. @param ResourceNode $resourceNode @param string $actionName @param array $options @param array $content @param array $files @return Response
[ "Executes", "an", "action", "on", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceActionManager.php#L117-L130
40,465
claroline/Distribution
main/core/Manager/Resource/ResourceActionManager.php
ResourceActionManager.get
public function get(ResourceNode $resourceNode, string $actionName) { $nodeActions = $this->all($resourceNode->getResourceType()); foreach ($nodeActions as $current) { if ($actionName === $current->getName()) { return $current; } } return null; }
php
public function get(ResourceNode $resourceNode, string $actionName) { $nodeActions = $this->all($resourceNode->getResourceType()); foreach ($nodeActions as $current) { if ($actionName === $current->getName()) { return $current; } } return null; }
[ "public", "function", "get", "(", "ResourceNode", "$", "resourceNode", ",", "string", "$", "actionName", ")", "{", "$", "nodeActions", "=", "$", "this", "->", "all", "(", "$", "resourceNode", "->", "getResourceType", "(", ")", ")", ";", "foreach", "(", "...
Retrieves the correct action instance for resource. @param ResourceNode $resourceNode @param string $actionName @return MenuAction
[ "Retrieves", "the", "correct", "action", "instance", "for", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceActionManager.php#L140-L150
40,466
claroline/Distribution
main/core/Manager/Resource/ResourceActionManager.php
ResourceActionManager.all
public function all(ResourceType $resourceType): array { if (empty($this->actions)) { $this->load(); } // get all actions implemented for the resource $actions = array_filter($this->actions, function (MenuAction $action) use ($resourceType) { return empty($action->getResourceType()) || $resourceType->getId() === $action->getResourceType()->getId(); }); return array_values($actions); }
php
public function all(ResourceType $resourceType): array { if (empty($this->actions)) { $this->load(); } // get all actions implemented for the resource $actions = array_filter($this->actions, function (MenuAction $action) use ($resourceType) { return empty($action->getResourceType()) || $resourceType->getId() === $action->getResourceType()->getId(); }); return array_values($actions); }
[ "public", "function", "all", "(", "ResourceType", "$", "resourceType", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "this", "->", "actions", ")", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "// get all actions implemented for the reso...
Gets all actions available for a resource type. @param ResourceType $resourceType @return MenuAction[]
[ "Gets", "all", "actions", "available", "for", "a", "resource", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceActionManager.php#L159-L171
40,467
claroline/Distribution
main/core/Manager/Resource/ResourceActionManager.php
ResourceActionManager.hasPermission
public function hasPermission(MenuAction $action, ResourceCollection $resourceNodes): bool { return $this->authorization->isGranted($action->getDecoder(), $resourceNodes); }
php
public function hasPermission(MenuAction $action, ResourceCollection $resourceNodes): bool { return $this->authorization->isGranted($action->getDecoder(), $resourceNodes); }
[ "public", "function", "hasPermission", "(", "MenuAction", "$", "action", ",", "ResourceCollection", "$", "resourceNodes", ")", ":", "bool", "{", "return", "$", "this", "->", "authorization", "->", "isGranted", "(", "$", "action", "->", "getDecoder", "(", ")", ...
Checks if the current user can execute an action on a resource. @param MenuAction $action @param ResourceCollection $resourceNodes @return bool
[ "Checks", "if", "the", "current", "user", "can", "execute", "an", "action", "on", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceActionManager.php#L181-L184
40,468
claroline/Distribution
main/core/Manager/Resource/ResourceActionManager.php
ResourceActionManager.eventName
private static function eventName($actionName, ResourceType $resourceType = null): string { if (!empty($resourceType)) { // This is an action only available for the current type return 'resource.'.$resourceType->getName().'.'.$actionName; } // This is an action available for all resource types return 'resource.'.$actionName; }
php
private static function eventName($actionName, ResourceType $resourceType = null): string { if (!empty($resourceType)) { // This is an action only available for the current type return 'resource.'.$resourceType->getName().'.'.$actionName; } // This is an action available for all resource types return 'resource.'.$actionName; }
[ "private", "static", "function", "eventName", "(", "$", "actionName", ",", "ResourceType", "$", "resourceType", "=", "null", ")", ":", "string", "{", "if", "(", "!", "empty", "(", "$", "resourceType", ")", ")", "{", "// This is an action only available for the c...
Generates the names for resource actions events. @param string $actionName @param ResourceType $resourceType @return string
[ "Generates", "the", "names", "for", "resource", "actions", "events", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceActionManager.php#L194-L203
40,469
claroline/Distribution
main/core/Controller/User/ProfileController.php
ProfileController.indexAction
public function indexAction($user) { try { $profileUser = $this->repository->findOneByIdOrPublicUrl($user); $serializedUser = $this->userSerializer->serialize($profileUser, [Options::SERIALIZE_FACET]); return [ 'user' => $serializedUser, 'facets' => $this->profileSerializer->serialize(), 'parameters' => $this->parametersSerializer->serialize()['profile'], ]; } catch (NoResultException $e) { throw new NotFoundHttpException('Page not found'); } }
php
public function indexAction($user) { try { $profileUser = $this->repository->findOneByIdOrPublicUrl($user); $serializedUser = $this->userSerializer->serialize($profileUser, [Options::SERIALIZE_FACET]); return [ 'user' => $serializedUser, 'facets' => $this->profileSerializer->serialize(), 'parameters' => $this->parametersSerializer->serialize()['profile'], ]; } catch (NoResultException $e) { throw new NotFoundHttpException('Page not found'); } }
[ "public", "function", "indexAction", "(", "$", "user", ")", "{", "try", "{", "$", "profileUser", "=", "$", "this", "->", "repository", "->", "findOneByIdOrPublicUrl", "(", "$", "user", ")", ";", "$", "serializedUser", "=", "$", "this", "->", "userSerialize...
Displays a user profile from its public URL or ID. @EXT\Route("/{user}", name="claro_user_profile") @EXT\Template("ClarolineCoreBundle:user:profile.html.twig") @param string|int $user @return array
[ "Displays", "a", "user", "profile", "from", "its", "public", "URL", "or", "ID", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/User/ProfileController.php#L78-L92
40,470
claroline/Distribution
plugin/competency/Controller/MyObjectiveController.php
MyObjectiveController.objectivesAction
public function objectivesAction(User $user) { $objectives = $this->objectiveManager->loadSubjectObjectives($user); $objectivesCompetencies = []; $competencies = []; foreach ($objectives as $objectiveData) { $objective = $this->objectiveManager->getObjectiveById($objectiveData['id']); $objectiveComps = $this->objectiveManager->loadUserObjectiveCompetencies($objective, $user); $objectivesCompetencies[$objectiveData['id']] = $objectiveComps; $competencies[$objectiveData['id']] = []; foreach ($objectiveComps as $comp) { if (isset($comp['__children']) && count($comp['__children']) > 0) { $this->objectiveManager->getCompetencyFinalChildren( $comp, $competencies[$objectiveData['id']], $comp['levelValue'], $comp['nbLevels'] ); } else { $comp['id'] = $comp['originalId']; $comp['requiredLevel'] = $comp['levelValue']; $competencies[$objectiveData['id']][$comp['id']] = $comp; } } } return [ 'user' => $user, 'objectives' => $objectives, 'objectivesCompetencies' => $objectivesCompetencies, 'competencies' => $competencies, ]; }
php
public function objectivesAction(User $user) { $objectives = $this->objectiveManager->loadSubjectObjectives($user); $objectivesCompetencies = []; $competencies = []; foreach ($objectives as $objectiveData) { $objective = $this->objectiveManager->getObjectiveById($objectiveData['id']); $objectiveComps = $this->objectiveManager->loadUserObjectiveCompetencies($objective, $user); $objectivesCompetencies[$objectiveData['id']] = $objectiveComps; $competencies[$objectiveData['id']] = []; foreach ($objectiveComps as $comp) { if (isset($comp['__children']) && count($comp['__children']) > 0) { $this->objectiveManager->getCompetencyFinalChildren( $comp, $competencies[$objectiveData['id']], $comp['levelValue'], $comp['nbLevels'] ); } else { $comp['id'] = $comp['originalId']; $comp['requiredLevel'] = $comp['levelValue']; $competencies[$objectiveData['id']][$comp['id']] = $comp; } } } return [ 'user' => $user, 'objectives' => $objectives, 'objectivesCompetencies' => $objectivesCompetencies, 'competencies' => $competencies, ]; }
[ "public", "function", "objectivesAction", "(", "User", "$", "user", ")", "{", "$", "objectives", "=", "$", "this", "->", "objectiveManager", "->", "loadSubjectObjectives", "(", "$", "user", ")", ";", "$", "objectivesCompetencies", "=", "[", "]", ";", "$", ...
Displays the index of the learner version of the learning objectives tool, i.e the list of his learning objectives. @EXT\Route( "/", name="hevinci_my_objectives_index" ) @EXT\ParamConverter("user", options={"authenticatedUser"=true}) @EXT\Template @param User $user @return array
[ "Displays", "the", "index", "of", "the", "learner", "version", "of", "the", "learning", "objectives", "tool", "i", ".", "e", "the", "list", "of", "his", "learning", "objectives", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Controller/MyObjectiveController.php#L64-L98
40,471
claroline/Distribution
plugin/competency/Controller/MyObjectiveController.php
MyObjectiveController.objectiveCompetencyResourceFetchAction
public function objectiveCompetencyResourceFetchAction(Competency $competency, $level, User $user) { $rootComptency = empty($competency->getParent()) ? $competency : $this->competencyManager->getCompetencyById($competency->getRoot()); $scale = $rootComptency->getScale(); $levelEntity = $this->competencyManager->getLevelByScaleAndValue($scale, $level); $resource = $this->objectiveManager->getRelevantResourceForUserByLevel($user, $competency, $levelEntity); $data = is_null($resource) ? null : ['resourceId' => $resource->getId()]; return new JsonResponse($data); }
php
public function objectiveCompetencyResourceFetchAction(Competency $competency, $level, User $user) { $rootComptency = empty($competency->getParent()) ? $competency : $this->competencyManager->getCompetencyById($competency->getRoot()); $scale = $rootComptency->getScale(); $levelEntity = $this->competencyManager->getLevelByScaleAndValue($scale, $level); $resource = $this->objectiveManager->getRelevantResourceForUserByLevel($user, $competency, $levelEntity); $data = is_null($resource) ? null : ['resourceId' => $resource->getId()]; return new JsonResponse($data); }
[ "public", "function", "objectiveCompetencyResourceFetchAction", "(", "Competency", "$", "competency", ",", "$", "level", ",", "User", "$", "user", ")", "{", "$", "rootComptency", "=", "empty", "(", "$", "competency", "->", "getParent", "(", ")", ")", "?", "$...
Fetches a resource for a competency at the given level for My Objectives tool. @EXT\Route( "/objective/competency/{competency}/level/{level}/resource/fetch", name="hevinci_my_objectives_competency_resource_fetch" ) @EXT\ParamConverter("user", options={"authenticatedUser"=true}) @param Competency $competency @param int $level @param User $user @return JsonResponse
[ "Fetches", "a", "resource", "for", "a", "competency", "at", "the", "given", "level", "for", "My", "Objectives", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Controller/MyObjectiveController.php#L199-L210
40,472
claroline/Distribution
plugin/competency/Controller/MyObjectiveController.php
MyObjectiveController.userObjectiveCompetenciesAction
public function userObjectiveCompetenciesAction(Objective $objective, User $user) { return new JsonResponse($this->objectiveManager->loadUserObjectiveCompetencies($objective, $user)); }
php
public function userObjectiveCompetenciesAction(Objective $objective, User $user) { return new JsonResponse($this->objectiveManager->loadUserObjectiveCompetencies($objective, $user)); }
[ "public", "function", "userObjectiveCompetenciesAction", "(", "Objective", "$", "objective", ",", "User", "$", "user", ")", "{", "return", "new", "JsonResponse", "(", "$", "this", "->", "objectiveManager", "->", "loadUserObjectiveCompetencies", "(", "$", "objective"...
Returns the competencies associated with an objective assigned to a user, with progress data. @EXT\Route("/{id}/competencies", name="hevinci_load_my_objective_competencies") @EXT\ParamConverter("user", options={"authenticatedUser"=true}) @param Objective $objective @param User $user @return JsonResponse
[ "Returns", "the", "competencies", "associated", "with", "an", "objective", "assigned", "to", "a", "user", "with", "progress", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Controller/MyObjectiveController.php#L223-L226
40,473
claroline/Distribution
plugin/competency/Controller/MyObjectiveController.php
MyObjectiveController.competencyUserHistoryAction
public function competencyUserHistoryAction(Competency $competency, User $user) { return [ 'competency' => $competency, 'user' => $user, 'logs' => $this->progressManager->listLeafCompetencyLogs($competency, $user), ]; }
php
public function competencyUserHistoryAction(Competency $competency, User $user) { return [ 'competency' => $competency, 'user' => $user, 'logs' => $this->progressManager->listLeafCompetencyLogs($competency, $user), ]; }
[ "public", "function", "competencyUserHistoryAction", "(", "Competency", "$", "competency", ",", "User", "$", "user", ")", "{", "return", "[", "'competency'", "=>", "$", "competency", ",", "'user'", "=>", "$", "user", ",", "'logs'", "=>", "$", "this", "->", ...
Displays the progress history of a user for a given competency. @EXT\Route("/competencies/{id}/history", name="hevinci_competency_my_history") @EXT\ParamConverter("user", options={"authenticatedUser"=true}) @EXT\Template("HeVinciCompetencyBundle::competencyHistory.html.twig") @param Competency $competency @param User $user @return array
[ "Displays", "the", "progress", "history", "of", "a", "user", "for", "a", "given", "competency", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Controller/MyObjectiveController.php#L240-L247
40,474
claroline/Distribution
plugin/blog/Manager/TagManager.php
TagManager.loadOrCreateTags
public function loadOrCreateTags($tagNames) { $tagNames = (is_array($tagNames)) ? $tagNames : $this->parseTagString($tagNames); $tags = []; foreach ($tagNames as $name) { if ($name) { $tags[] = $this->loadOrCreateTag($name); } } return $tags; }
php
public function loadOrCreateTags($tagNames) { $tagNames = (is_array($tagNames)) ? $tagNames : $this->parseTagString($tagNames); $tags = []; foreach ($tagNames as $name) { if ($name) { $tags[] = $this->loadOrCreateTag($name); } } return $tags; }
[ "public", "function", "loadOrCreateTags", "(", "$", "tagNames", ")", "{", "$", "tagNames", "=", "(", "is_array", "(", "$", "tagNames", ")", ")", "?", "$", "tagNames", ":", "$", "this", "->", "parseTagString", "(", "$", "tagNames", ")", ";", "$", "tags"...
Load or Create tag following to a given string or list of names. @param string or array $tagNames @return array tags
[ "Load", "or", "Create", "tag", "following", "to", "a", "given", "string", "or", "list", "of", "names", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/TagManager.php#L52-L64
40,475
claroline/Distribution
plugin/blog/Manager/TagManager.php
TagManager.loadOrCreateTag
public function loadOrCreateTag($name) { $tag = $this->loadTag($name); if (null === $tag) { $tag = $this->createTag($name); } return $tag; }
php
public function loadOrCreateTag($name) { $tag = $this->loadTag($name); if (null === $tag) { $tag = $this->createTag($name); } return $tag; }
[ "public", "function", "loadOrCreateTag", "(", "$", "name", ")", "{", "$", "tag", "=", "$", "this", "->", "loadTag", "(", "$", "name", ")", ";", "if", "(", "null", "===", "$", "tag", ")", "{", "$", "tag", "=", "$", "this", "->", "createTag", "(", ...
Load or Create tag following to a given name. @param string $name @return \Icap\BlogBundle\Entity\Tag
[ "Load", "or", "Create", "tag", "following", "to", "a", "given", "name", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/TagManager.php#L73-L81
40,476
claroline/Distribution
plugin/blog/Manager/TagManager.php
TagManager.loadByBlog
public function loadByBlog(Blog $blog, $max = null) { $results = $this->getTagRepository()->findByBlog($blog, true, $max); $tags = []; if (0 < count($results)) { $maxWeight = intval($results[0]['frequency']); $resultsValues = array_values($results); $endResult = end($resultsValues); $minWeight = intval($endResult['frequency']); $diff = $maxWeight - $minWeight; foreach ($results as $result) { /** @var \Icap\BlogBundle\Entity\Tag $tag */ $tag = $result[0]; if ($diff > 10) { $weight = round(((intval($result['frequency']) - $minWeight) / $diff) * 9 + 1); } else { $weight = intval($result['frequency']) - $minWeight + 1; } $tagArray = [ 'name' => $tag->getName(), 'slug' => $tag->getSlug(), 'weight' => $weight, 'countPosts' => intval($result['countPosts']), 'text' => $tag->getName(), 'id' => $tag->getId(), ]; array_push($tags, $tagArray); } } return $tags; }
php
public function loadByBlog(Blog $blog, $max = null) { $results = $this->getTagRepository()->findByBlog($blog, true, $max); $tags = []; if (0 < count($results)) { $maxWeight = intval($results[0]['frequency']); $resultsValues = array_values($results); $endResult = end($resultsValues); $minWeight = intval($endResult['frequency']); $diff = $maxWeight - $minWeight; foreach ($results as $result) { /** @var \Icap\BlogBundle\Entity\Tag $tag */ $tag = $result[0]; if ($diff > 10) { $weight = round(((intval($result['frequency']) - $minWeight) / $diff) * 9 + 1); } else { $weight = intval($result['frequency']) - $minWeight + 1; } $tagArray = [ 'name' => $tag->getName(), 'slug' => $tag->getSlug(), 'weight' => $weight, 'countPosts' => intval($result['countPosts']), 'text' => $tag->getName(), 'id' => $tag->getId(), ]; array_push($tags, $tagArray); } } return $tags; }
[ "public", "function", "loadByBlog", "(", "Blog", "$", "blog", ",", "$", "max", "=", "null", ")", "{", "$", "results", "=", "$", "this", "->", "getTagRepository", "(", ")", "->", "findByBlog", "(", "$", "blog", ",", "true", ",", "$", "max", ")", ";"...
Load a blog tags, calculating their weights. @param \Icap\BlogBundle\Entity\Blog $blog @param int max @return array tags
[ "Load", "a", "blog", "tags", "calculating", "their", "weights", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/TagManager.php#L103-L138
40,477
claroline/Distribution
plugin/exo/Serializer/Item/Type/GridQuestionSerializer.php
GridQuestionSerializer.serialize
public function serialize(GridQuestion $gridQuestion, array $options = []) { $serialized = [ 'penalty' => $gridQuestion->getPenalty(), 'rows' => $gridQuestion->getRows(), 'cols' => $gridQuestion->getColumns(), 'sumMode' => $gridQuestion->getSumMode(), 'border' => $gridQuestion->getGridStyle(), 'cells' => $this->serializeCells($gridQuestion, $options), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($gridQuestion, $options); } return $serialized; }
php
public function serialize(GridQuestion $gridQuestion, array $options = []) { $serialized = [ 'penalty' => $gridQuestion->getPenalty(), 'rows' => $gridQuestion->getRows(), 'cols' => $gridQuestion->getColumns(), 'sumMode' => $gridQuestion->getSumMode(), 'border' => $gridQuestion->getGridStyle(), 'cells' => $this->serializeCells($gridQuestion, $options), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($gridQuestion, $options); } return $serialized; }
[ "public", "function", "serialize", "(", "GridQuestion", "$", "gridQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'penalty'", "=>", "$", "gridQuestion", "->", "getPenalty", "(", ")", ",", "'rows'", "=>", "$...
Converts a Grid question into a JSON-encodable structure. @param GridQuestion $gridQuestion @param array $options @return array
[ "Converts", "a", "Grid", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/GridQuestionSerializer.php#L48-L64
40,478
claroline/Distribution
plugin/exo/Serializer/Item/Type/GridQuestionSerializer.php
GridQuestionSerializer.deserialize
public function deserialize($data, GridQuestion $gridQuestion = null, array $options = []) { if (empty($gridQuestion)) { $gridQuestion = new GridQuestion(); } if (!empty($data['penalty']) || 0 === $data['penalty']) { $gridQuestion->setPenalty($data['penalty']); } $this->sipe('data', 'setData', $data, $gridQuestion); $this->sipe('rows', 'setRows', $data, $gridQuestion); $this->sipe('cols', 'setColumns', $data, $gridQuestion); $this->sipe('sumMode', 'setSumMode', $data, $gridQuestion); $this->sipe('border.width', 'setBorderWidth', $data, $gridQuestion); $this->sipe('border.color', 'setBorderColor', $data, $gridQuestion); // Deserialize cells and solutions $this->deserializeCells($gridQuestion, $data['cells'], $data['solutions'], $options); return $gridQuestion; }
php
public function deserialize($data, GridQuestion $gridQuestion = null, array $options = []) { if (empty($gridQuestion)) { $gridQuestion = new GridQuestion(); } if (!empty($data['penalty']) || 0 === $data['penalty']) { $gridQuestion->setPenalty($data['penalty']); } $this->sipe('data', 'setData', $data, $gridQuestion); $this->sipe('rows', 'setRows', $data, $gridQuestion); $this->sipe('cols', 'setColumns', $data, $gridQuestion); $this->sipe('sumMode', 'setSumMode', $data, $gridQuestion); $this->sipe('border.width', 'setBorderWidth', $data, $gridQuestion); $this->sipe('border.color', 'setBorderColor', $data, $gridQuestion); // Deserialize cells and solutions $this->deserializeCells($gridQuestion, $data['cells'], $data['solutions'], $options); return $gridQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "GridQuestion", "$", "gridQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "gridQuestion", ")", ")", "{", "$", "gridQuestion", "=", ...
Converts raw data into a Grid question entity. @param array $data @param GridQuestion $gridQuestion @param array $options @return GridQuestion
[ "Converts", "raw", "data", "into", "a", "Grid", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/GridQuestionSerializer.php#L137-L156
40,479
claroline/Distribution
plugin/exo/Serializer/Item/Type/GridQuestionSerializer.php
GridQuestionSerializer.deserializeCells
private function deserializeCells(GridQuestion $gridQuestion, array $cells, array $solutions, array $options = []) { $cellEntities = $gridQuestion->getCells()->toArray(); foreach ($cells as $cellData) { $cell = null; // Searches for an existing cell entity. foreach ($cellEntities as $entityIndex => $entityCell) { /* @var Cell $entityCell */ if ($entityCell->getUuid() === $cellData['id']) { $cell = $entityCell; unset($cellEntities[$entityIndex]); break; } } $cell = $cell ?: new Cell(); $cell->setUuid($cellData['id']); $cell->setCoordsX($cellData['coordinates'][0]); $cell->setCoordsY($cellData['coordinates'][1]); $cell->setColor($cellData['color']); $cell->setBackground($cellData['background']); if (!empty($cellData['data'])) { $cell->setData($cellData['data']); } if (!empty($cellData['choices'])) { $cell->setSelector(true); } else { $cell->setSelector(false); } $hasSolution = false; foreach ($solutions as $solution) { if ($solution['cellId'] === $cellData['id']) { $this->deserializeCellChoices($cell, $solution['answers'], $options); $hasSolution = true; break; } } if (!$hasSolution) { $this->deserializeCellChoices($cell, [], $options); } $cell->setInput($hasSolution); $gridQuestion->addCell($cell); } // Remaining cells are no longer in the Question foreach ($cellEntities as $cellToRemove) { $gridQuestion->removeCell($cellToRemove); } }
php
private function deserializeCells(GridQuestion $gridQuestion, array $cells, array $solutions, array $options = []) { $cellEntities = $gridQuestion->getCells()->toArray(); foreach ($cells as $cellData) { $cell = null; // Searches for an existing cell entity. foreach ($cellEntities as $entityIndex => $entityCell) { /* @var Cell $entityCell */ if ($entityCell->getUuid() === $cellData['id']) { $cell = $entityCell; unset($cellEntities[$entityIndex]); break; } } $cell = $cell ?: new Cell(); $cell->setUuid($cellData['id']); $cell->setCoordsX($cellData['coordinates'][0]); $cell->setCoordsY($cellData['coordinates'][1]); $cell->setColor($cellData['color']); $cell->setBackground($cellData['background']); if (!empty($cellData['data'])) { $cell->setData($cellData['data']); } if (!empty($cellData['choices'])) { $cell->setSelector(true); } else { $cell->setSelector(false); } $hasSolution = false; foreach ($solutions as $solution) { if ($solution['cellId'] === $cellData['id']) { $this->deserializeCellChoices($cell, $solution['answers'], $options); $hasSolution = true; break; } } if (!$hasSolution) { $this->deserializeCellChoices($cell, [], $options); } $cell->setInput($hasSolution); $gridQuestion->addCell($cell); } // Remaining cells are no longer in the Question foreach ($cellEntities as $cellToRemove) { $gridQuestion->removeCell($cellToRemove); } }
[ "private", "function", "deserializeCells", "(", "GridQuestion", "$", "gridQuestion", ",", "array", "$", "cells", ",", "array", "$", "solutions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "cellEntities", "=", "$", "gridQuestion", "->", "ge...
Deserializes Question cells. @param GridQuestion $gridQuestion @param array $cells @param array $solutions @param array $options
[ "Deserializes", "Question", "cells", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/GridQuestionSerializer.php#L166-L219
40,480
claroline/Distribution
plugin/exo/Library/Item/Definition/MatchDefinition.php
MatchDefinition.refreshIdentifiers
public function refreshIdentifiers(AbstractItem $item) { /** @var Label $label */ foreach ($item->getLabels() as $label) { $label->refreshUuid(); } /** @var Proposal $proposal */ foreach ($item->getProposals() as $proposal) { $proposal->refreshUuid(); } }
php
public function refreshIdentifiers(AbstractItem $item) { /** @var Label $label */ foreach ($item->getLabels() as $label) { $label->refreshUuid(); } /** @var Proposal $proposal */ foreach ($item->getProposals() as $proposal) { $proposal->refreshUuid(); } }
[ "public", "function", "refreshIdentifiers", "(", "AbstractItem", "$", "item", ")", "{", "/** @var Label $label */", "foreach", "(", "$", "item", "->", "getLabels", "(", ")", "as", "$", "label", ")", "{", "$", "label", "->", "refreshUuid", "(", ")", ";", "}...
Refreshes items UUIDs. @param MatchQuestion $item
[ "Refreshes", "items", "UUIDs", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/MatchDefinition.php#L207-L218
40,481
claroline/Distribution
plugin/exo/Library/Attempt/PaperGenerator.php
PaperGenerator.create
public function create(Exercise $exercise, User $user = null, Paper $previousPaper = null) { // Create the new Paper entity $paper = new Paper(); $paper->setExercise($exercise); $paper->setUser($user); $paper->setAnonymized($exercise->getAnonymizeAttempts()); // Get the number of the new Paper $paperNum = (null === $previousPaper) ? 1 : $previousPaper->getNumber() + 1; $paper->setNumber($paperNum); // Generate the structure for the new paper // Reuse a previous paper if exists and has not been invalidated $structure = $this->generateStructure( $exercise, ($previousPaper && !$previousPaper->isInvalidated()) ? $previousPaper : null ); $paper->setStructure(json_encode($structure)); return $paper; }
php
public function create(Exercise $exercise, User $user = null, Paper $previousPaper = null) { // Create the new Paper entity $paper = new Paper(); $paper->setExercise($exercise); $paper->setUser($user); $paper->setAnonymized($exercise->getAnonymizeAttempts()); // Get the number of the new Paper $paperNum = (null === $previousPaper) ? 1 : $previousPaper->getNumber() + 1; $paper->setNumber($paperNum); // Generate the structure for the new paper // Reuse a previous paper if exists and has not been invalidated $structure = $this->generateStructure( $exercise, ($previousPaper && !$previousPaper->isInvalidated()) ? $previousPaper : null ); $paper->setStructure(json_encode($structure)); return $paper; }
[ "public", "function", "create", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", "=", "null", ",", "Paper", "$", "previousPaper", "=", "null", ")", "{", "// Create the new Paper entity", "$", "paper", "=", "new", "Paper", "(", ")", ";", "$", "...
Creates a paper for a new attempt. @param Exercise $exercise - the exercise tried @param User $user - the user who wants to pass the exercise @param Paper $previousPaper - the previous paper if one exists @return Paper
[ "Creates", "a", "paper", "for", "a", "new", "attempt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Attempt/PaperGenerator.php#L67-L88
40,482
claroline/Distribution
plugin/exo/Library/Attempt/PaperGenerator.php
PaperGenerator.generateStructure
private function generateStructure(Exercise $exercise, Paper $previousPaper = null) { // The structure of the previous paper if any $previousStructure = !empty($previousPaper) ? json_decode($previousPaper->getStructure(), true) : null; // Get JSON representation of the full exercise $structure = $this->exerciseSerializer->serialize($exercise); // Pick questions for each steps and generate structure $structure['steps'] = $this->pickSteps($exercise, $previousStructure); return $structure; }
php
private function generateStructure(Exercise $exercise, Paper $previousPaper = null) { // The structure of the previous paper if any $previousStructure = !empty($previousPaper) ? json_decode($previousPaper->getStructure(), true) : null; // Get JSON representation of the full exercise $structure = $this->exerciseSerializer->serialize($exercise); // Pick questions for each steps and generate structure $structure['steps'] = $this->pickSteps($exercise, $previousStructure); return $structure; }
[ "private", "function", "generateStructure", "(", "Exercise", "$", "exercise", ",", "Paper", "$", "previousPaper", "=", "null", ")", "{", "// The structure of the previous paper if any", "$", "previousStructure", "=", "!", "empty", "(", "$", "previousPaper", ")", "?"...
Generates the structure of the attempt based on Exercise and Steps parameters. @param Exercise $exercise @param Paper $previousPaper @return \stdClass
[ "Generates", "the", "structure", "of", "the", "attempt", "based", "on", "Exercise", "and", "Steps", "parameters", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Attempt/PaperGenerator.php#L98-L109
40,483
claroline/Distribution
plugin/exo/Library/Attempt/PaperGenerator.php
PaperGenerator.pickStepsByTags
private function pickStepsByTags(Exercise $exercise, array $previousExercise = null) { $pickConfig = $exercise->getPick(); // Retrieve the list of items to use $items = []; if (!empty($previousExercise) && Recurrence::ALWAYS !== $exercise->getRandomPick()) { // Just get the list of items from the previous paper foreach ($previousExercise['steps'] as $pickedStep) { foreach ($pickedStep['items'] as $pickedItem) { $items[] = $exercise->getQuestion($pickedItem['id']); } } } else { // Get the list of items from exercise foreach ($exercise->getSteps() as $step) { $items = array_merge($items, $step->getQuestions()); } } // Serialize items (we will automatically get items tags for filtering) $serializedItems = array_map(function (Item $pickedItem) { return $this->itemSerializer->serialize($pickedItem, [ Transfer::SHUFFLE_ANSWERS, Transfer::INCLUDE_SOLUTIONS, ]); }, $items); $pickedItems = []; if (!empty($previousExercise) && Recurrence::ALWAYS !== $exercise->getRandomPick()) { // items are already filtered $pickedItems = $serializedItems; } else { // Only pick wanted tags (format : ['tagName', itemCount]) foreach ($pickConfig['tags'] as $pickedTag) { $taggedItems = array_filter($serializedItems, function ($serializedItem) use ($pickedTag) { return !empty($serializedItem['tags']) && in_array($pickedTag[0], $serializedItem['tags']); }); // Get the correct number of items with the current tag // There is no error if we want more items than there are in the quiz, // we just stop to pick when there are no more available items $pickedItems = array_merge($pickedItems, static::pick($taggedItems, $pickedTag[1], true)); } } // Shuffle items according to config if ((empty($previousExercise) && Recurrence::ONCE === $exercise->getRandomOrder()) || Recurrence::ALWAYS === $exercise->getRandomOrder()) { shuffle($pickedItems); } // Create steps and fill it with the correct number of questions $pickedSteps = []; while (!empty($pickedItems)) { $pickedStep = $this->stepSerializer->serialize(new Step()); $pickedStep['items'] = array_splice($pickedItems, 0, $pickConfig['pageSize']); $pickedSteps[] = $pickedStep; } return $pickedSteps; }
php
private function pickStepsByTags(Exercise $exercise, array $previousExercise = null) { $pickConfig = $exercise->getPick(); // Retrieve the list of items to use $items = []; if (!empty($previousExercise) && Recurrence::ALWAYS !== $exercise->getRandomPick()) { // Just get the list of items from the previous paper foreach ($previousExercise['steps'] as $pickedStep) { foreach ($pickedStep['items'] as $pickedItem) { $items[] = $exercise->getQuestion($pickedItem['id']); } } } else { // Get the list of items from exercise foreach ($exercise->getSteps() as $step) { $items = array_merge($items, $step->getQuestions()); } } // Serialize items (we will automatically get items tags for filtering) $serializedItems = array_map(function (Item $pickedItem) { return $this->itemSerializer->serialize($pickedItem, [ Transfer::SHUFFLE_ANSWERS, Transfer::INCLUDE_SOLUTIONS, ]); }, $items); $pickedItems = []; if (!empty($previousExercise) && Recurrence::ALWAYS !== $exercise->getRandomPick()) { // items are already filtered $pickedItems = $serializedItems; } else { // Only pick wanted tags (format : ['tagName', itemCount]) foreach ($pickConfig['tags'] as $pickedTag) { $taggedItems = array_filter($serializedItems, function ($serializedItem) use ($pickedTag) { return !empty($serializedItem['tags']) && in_array($pickedTag[0], $serializedItem['tags']); }); // Get the correct number of items with the current tag // There is no error if we want more items than there are in the quiz, // we just stop to pick when there are no more available items $pickedItems = array_merge($pickedItems, static::pick($taggedItems, $pickedTag[1], true)); } } // Shuffle items according to config if ((empty($previousExercise) && Recurrence::ONCE === $exercise->getRandomOrder()) || Recurrence::ALWAYS === $exercise->getRandomOrder()) { shuffle($pickedItems); } // Create steps and fill it with the correct number of questions $pickedSteps = []; while (!empty($pickedItems)) { $pickedStep = $this->stepSerializer->serialize(new Step()); $pickedStep['items'] = array_splice($pickedItems, 0, $pickConfig['pageSize']); $pickedSteps[] = $pickedStep; } return $pickedSteps; }
[ "private", "function", "pickStepsByTags", "(", "Exercise", "$", "exercise", ",", "array", "$", "previousExercise", "=", "null", ")", "{", "$", "pickConfig", "=", "$", "exercise", "->", "getPick", "(", ")", ";", "// Retrieve the list of items to use", "$", "items...
Generates steps based on the quiz configuration and a list of items. In this kind of quiz all items are stored in a single step. @param Exercise $exercise @param array $previousExercise @return array
[ "Generates", "steps", "based", "on", "the", "quiz", "configuration", "and", "a", "list", "of", "items", ".", "In", "this", "kind", "of", "quiz", "all", "items", "are", "stored", "in", "a", "single", "step", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Attempt/PaperGenerator.php#L170-L233
40,484
claroline/Distribution
plugin/exo/Library/Attempt/PaperGenerator.php
PaperGenerator.pickItems
private function pickItems(Step $step, array $previousStep = null) { if (!empty($previousStep) && Recurrence::ALWAYS !== $step->getRandomPick()) { // Just get the list of question from previous step // We get the entities to reapply shuffle (= redo serialization with shuffle option) $items = array_map(function (array $pickedItem) use ($step) { return $step->getQuestion($pickedItem['id']); }, $previousStep['items']); } else { // Pick a new set of questions $items = static::pick( $step->getQuestions(), $step->getPick() ); } // Serialize items $pickedItems = array_map(function (Item $pickedItem) { return $this->itemSerializer->serialize($pickedItem, [ Transfer::SHUFFLE_ANSWERS, Transfer::INCLUDE_SOLUTIONS, ]); }, $items); // Recalculate order of the items based on the configuration // if we don't want to keep the one from the previous paper if ((empty($previousStep) && Recurrence::ONCE === $step->getRandomOrder()) || Recurrence::ALWAYS === $step->getRandomOrder()) { shuffle($pickedItems); } return $pickedItems; }
php
private function pickItems(Step $step, array $previousStep = null) { if (!empty($previousStep) && Recurrence::ALWAYS !== $step->getRandomPick()) { // Just get the list of question from previous step // We get the entities to reapply shuffle (= redo serialization with shuffle option) $items = array_map(function (array $pickedItem) use ($step) { return $step->getQuestion($pickedItem['id']); }, $previousStep['items']); } else { // Pick a new set of questions $items = static::pick( $step->getQuestions(), $step->getPick() ); } // Serialize items $pickedItems = array_map(function (Item $pickedItem) { return $this->itemSerializer->serialize($pickedItem, [ Transfer::SHUFFLE_ANSWERS, Transfer::INCLUDE_SOLUTIONS, ]); }, $items); // Recalculate order of the items based on the configuration // if we don't want to keep the one from the previous paper if ((empty($previousStep) && Recurrence::ONCE === $step->getRandomOrder()) || Recurrence::ALWAYS === $step->getRandomOrder()) { shuffle($pickedItems); } return $pickedItems; }
[ "private", "function", "pickItems", "(", "Step", "$", "step", ",", "array", "$", "previousStep", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "previousStep", ")", "&&", "Recurrence", "::", "ALWAYS", "!==", "$", "step", "->", "getRandomPick",...
Pick items for a step according to the step configuration. @param Step $step @param array|null $previousStep @return Item[]
[ "Pick", "items", "for", "a", "step", "according", "to", "the", "step", "configuration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Attempt/PaperGenerator.php#L243-L275
40,485
claroline/Distribution
plugin/exo/Library/Attempt/PaperGenerator.php
PaperGenerator.pick
private static function pick(array $collection, $count = 0, $force = false) { if (count($collection) < $count) { if ($force) { return $collection; } throw new \LogicException("Cannot pick more elements ({$count}) than there are in the collection."); } $picked = []; if (0 !== $count) { $randomSelect = array_rand($collection, $count); if (is_int($randomSelect)) { // only one element has been picked $randomSelect = [$randomSelect]; } // put back original collection order sort($randomSelect, SORT_NUMERIC); foreach ($randomSelect as $randomIndex) { $picked[] = $collection[$randomIndex]; } } else { $picked = $collection; } return $picked; }
php
private static function pick(array $collection, $count = 0, $force = false) { if (count($collection) < $count) { if ($force) { return $collection; } throw new \LogicException("Cannot pick more elements ({$count}) than there are in the collection."); } $picked = []; if (0 !== $count) { $randomSelect = array_rand($collection, $count); if (is_int($randomSelect)) { // only one element has been picked $randomSelect = [$randomSelect]; } // put back original collection order sort($randomSelect, SORT_NUMERIC); foreach ($randomSelect as $randomIndex) { $picked[] = $collection[$randomIndex]; } } else { $picked = $collection; } return $picked; }
[ "private", "static", "function", "pick", "(", "array", "$", "collection", ",", "$", "count", "=", "0", ",", "$", "force", "=", "false", ")", "{", "if", "(", "count", "(", "$", "collection", ")", "<", "$", "count", ")", "{", "if", "(", "$", "force...
Picks a subset of items in an array. @param array $collection - the original collection @param int $count - the number of items to pick in the collection (if 0, the whole collection is returned) @param bool $force @return array - the truncated collection
[ "Picks", "a", "subset", "of", "items", "in", "an", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Attempt/PaperGenerator.php#L286-L314
40,486
claroline/Distribution
main/core/Listener/Tool/LogsListener.php
LogsListener.onDisplayWorkspace
public function onDisplayWorkspace(DisplayToolEvent $event) { $workspace = $event->getWorkspace(); $content = $this->templating->render( 'ClarolineCoreBundle:workspace:logs.html.twig', [ 'workspace' => $workspace, 'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_WORKSPACE), ] ); $event->setContent($content); $event->stopPropagation(); }
php
public function onDisplayWorkspace(DisplayToolEvent $event) { $workspace = $event->getWorkspace(); $content = $this->templating->render( 'ClarolineCoreBundle:workspace:logs.html.twig', [ 'workspace' => $workspace, 'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_WORKSPACE), ] ); $event->setContent($content); $event->stopPropagation(); }
[ "public", "function", "onDisplayWorkspace", "(", "DisplayToolEvent", "$", "event", ")", "{", "$", "workspace", "=", "$", "event", "->", "getWorkspace", "(", ")", ";", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreB...
Displays logs on Workspace. @DI\Observe("open_tool_workspace_logs") @param DisplayToolEvent $event
[ "Displays", "logs", "on", "Workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/LogsListener.php#L56-L69
40,487
claroline/Distribution
plugin/exo/Entity/ItemType/BooleanQuestion.php
BooleanQuestion.getChoice
public function getChoice($uuid) { $found = null; foreach ($this->choices as $choice) { if ($choice->getUuid() === $uuid) { $found = $choice; break; } } return $found; }
php
public function getChoice($uuid) { $found = null; foreach ($this->choices as $choice) { if ($choice->getUuid() === $uuid) { $found = $choice; break; } } return $found; }
[ "public", "function", "getChoice", "(", "$", "uuid", ")", "{", "$", "found", "=", "null", ";", "foreach", "(", "$", "this", "->", "choices", "as", "$", "choice", ")", "{", "if", "(", "$", "choice", "->", "getUuid", "(", ")", "===", "$", "uuid", "...
Get a choice by its uuid. @param $uuid @return BooleanChoice|null
[ "Get", "a", "choice", "by", "its", "uuid", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/BooleanQuestion.php#L42-L53
40,488
claroline/Distribution
plugin/blog/Manager/BlogTrackingManager.php
BlogTrackingManager.updateResourceTracking
public function updateResourceTracking(ResourceNode $node, User $user, \DateTime $date) { $this->evalutionManager->updateResourceUserEvaluationData( $node, $user, $date, ['status' => AbstractResourceEvaluation::STATUS_PARTICIPATED] ); }
php
public function updateResourceTracking(ResourceNode $node, User $user, \DateTime $date) { $this->evalutionManager->updateResourceUserEvaluationData( $node, $user, $date, ['status' => AbstractResourceEvaluation::STATUS_PARTICIPATED] ); }
[ "public", "function", "updateResourceTracking", "(", "ResourceNode", "$", "node", ",", "User", "$", "user", ",", "\\", "DateTime", "$", "date", ")", "{", "$", "this", "->", "evalutionManager", "->", "updateResourceUserEvaluationData", "(", "$", "node", ",", "$...
Logs participation in resource tracking. @param ResourceNode $node @param User $user @param \DateTime $date
[ "Logs", "participation", "in", "resource", "tracking", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogTrackingManager.php#L230-L238
40,489
claroline/Distribution
main/core/Manager/Workspace/TransferManager.php
TransferManager.serialize
public function serialize(Workspace $workspace) { $serialized = $this->serializer->serialize($workspace, [Options::REFRESH_UUID]); //if roles duplicatas, remove them $roles = $serialized['roles']; foreach ($roles as $role) { $uniques[$role['translationKey']] = ['type' => $role['type']]; } $roles = []; foreach ($uniques as $key => $val) { $val['translationKey'] = $key; $roles[] = $val; } $serialized['roles'] = $roles; //we want to load the ressources first $ot = $workspace->getOrderedTools()->toArray(); $idx = 0; foreach ($ot as $key => $tool) { if ('resource_manager' === $tool->getName()) { $idx = $key; } } $first = $ot[$idx]; unset($ot[$idx]); array_unshift($ot, $first); $serialized['orderedTools'] = array_map(function (OrderedTool $tool) { $data = $this->ots->serialize($tool, [Options::SERIALIZE_TOOL, Options::REFRESH_UUID]); return $data; }, $ot); return $serialized; }
php
public function serialize(Workspace $workspace) { $serialized = $this->serializer->serialize($workspace, [Options::REFRESH_UUID]); //if roles duplicatas, remove them $roles = $serialized['roles']; foreach ($roles as $role) { $uniques[$role['translationKey']] = ['type' => $role['type']]; } $roles = []; foreach ($uniques as $key => $val) { $val['translationKey'] = $key; $roles[] = $val; } $serialized['roles'] = $roles; //we want to load the ressources first $ot = $workspace->getOrderedTools()->toArray(); $idx = 0; foreach ($ot as $key => $tool) { if ('resource_manager' === $tool->getName()) { $idx = $key; } } $first = $ot[$idx]; unset($ot[$idx]); array_unshift($ot, $first); $serialized['orderedTools'] = array_map(function (OrderedTool $tool) { $data = $this->ots->serialize($tool, [Options::SERIALIZE_TOOL, Options::REFRESH_UUID]); return $data; }, $ot); return $serialized; }
[ "public", "function", "serialize", "(", "Workspace", "$", "workspace", ")", "{", "$", "serialized", "=", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "workspace", ",", "[", "Options", "::", "REFRESH_UUID", "]", ")", ";", "//if roles duplicat...
Returns a json description of the entire workspace. @param Workspace $workspace - the workspace to serialize @return array - the serialized representation of the workspace
[ "Returns", "a", "json", "description", "of", "the", "entire", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Workspace/TransferManager.php#L149-L190
40,490
claroline/Distribution
main/core/Manager/Workspace/TransferManager.php
TransferManager.exportFiles
public function exportFiles($data, FileBag $fileBag, Workspace $workspace) { foreach ($data['orderedTools'] as $key => $orderedToolData) { //copied from crud $name = 'export_tool_'.$orderedToolData['name']; //use an other even. StdClass is not pretty if (isset($orderedToolData['data'])) { /** @var ExportObjectEvent $event */ $event = $this->dispatcher->dispatch($name, ExportObjectEvent::class, [ new \StdClass(), $fileBag, $orderedToolData['data'], $workspace, ]); $data['orderedTools'][$key]['data'] = $event->getData(); } } return $data; }
php
public function exportFiles($data, FileBag $fileBag, Workspace $workspace) { foreach ($data['orderedTools'] as $key => $orderedToolData) { //copied from crud $name = 'export_tool_'.$orderedToolData['name']; //use an other even. StdClass is not pretty if (isset($orderedToolData['data'])) { /** @var ExportObjectEvent $event */ $event = $this->dispatcher->dispatch($name, ExportObjectEvent::class, [ new \StdClass(), $fileBag, $orderedToolData['data'], $workspace, ]); $data['orderedTools'][$key]['data'] = $event->getData(); } } return $data; }
[ "public", "function", "exportFiles", "(", "$", "data", ",", "FileBag", "$", "fileBag", ",", "Workspace", "$", "workspace", ")", "{", "foreach", "(", "$", "data", "[", "'orderedTools'", "]", "as", "$", "key", "=>", "$", "orderedToolData", ")", "{", "//cop...
once everything is serialized, we add files to the archive.
[ "once", "everything", "is", "serialized", "we", "add", "files", "to", "the", "archive", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Workspace/TransferManager.php#L255-L271
40,491
claroline/Distribution
plugin/dropzone/Controller/CorrectionController.php
CorrectionController.checkUserGradeAvailable
private function checkUserGradeAvailable(Dropzone $dropzone, Drop $drop, $user) { // notification only in the PeerReview mode. $em = $this->getDoctrine()->getManager(); $event = new LogDropGradeAvailableEvent($dropzone, $drop); if (1 === $dropzone->getPeerReview()) { // copy corrected by user // corrections on the user's copy $nbCorrectionByOthersOnUsersCopy = $em->getRepository('IcapDropzoneBundle:Correction')->getCorrectionsIds($dropzone, $drop); //Expected corrections $expectedCorrections = $dropzone->getExpectedTotalCorrection(); /** * $nbCorrectionByUser = $em->getRepository('IcapDropzoneBundle:Correction')->getAlreadyCorrectedDropIds($dropzone, $user); * if(count($nbCorrectionByUser) >= $expectedCorrections && count($nbCorrectionByOthersOnUsersCopy) >= $expectedCorrections ). **/ // corrected copy only instead of corrected copy AND given corrections. if (count($nbCorrectionByOthersOnUsersCopy) >= $expectedCorrections) { //dispatchEvent. $this->get('event_dispatcher')->dispatch('log', $event); } } else { $nbCorrectionByOthersOnUsersCopy = $em->getRepository('IcapDropzoneBundle:Correction') ->getCorrectionsIds($dropzone, $drop); if ($nbCorrectionByOthersOnUsersCopy > 0) { $this->get('event_dispatcher')->dispatch('log', $event); } } }
php
private function checkUserGradeAvailable(Dropzone $dropzone, Drop $drop, $user) { // notification only in the PeerReview mode. $em = $this->getDoctrine()->getManager(); $event = new LogDropGradeAvailableEvent($dropzone, $drop); if (1 === $dropzone->getPeerReview()) { // copy corrected by user // corrections on the user's copy $nbCorrectionByOthersOnUsersCopy = $em->getRepository('IcapDropzoneBundle:Correction')->getCorrectionsIds($dropzone, $drop); //Expected corrections $expectedCorrections = $dropzone->getExpectedTotalCorrection(); /** * $nbCorrectionByUser = $em->getRepository('IcapDropzoneBundle:Correction')->getAlreadyCorrectedDropIds($dropzone, $user); * if(count($nbCorrectionByUser) >= $expectedCorrections && count($nbCorrectionByOthersOnUsersCopy) >= $expectedCorrections ). **/ // corrected copy only instead of corrected copy AND given corrections. if (count($nbCorrectionByOthersOnUsersCopy) >= $expectedCorrections) { //dispatchEvent. $this->get('event_dispatcher')->dispatch('log', $event); } } else { $nbCorrectionByOthersOnUsersCopy = $em->getRepository('IcapDropzoneBundle:Correction') ->getCorrectionsIds($dropzone, $drop); if ($nbCorrectionByOthersOnUsersCopy > 0) { $this->get('event_dispatcher')->dispatch('log', $event); } } }
[ "private", "function", "checkUserGradeAvailable", "(", "Dropzone", "$", "dropzone", ",", "Drop", "$", "drop", ",", "$", "user", ")", "{", "// notification only in the PeerReview mode.", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManage...
Check the user's drop to see if he has corrected enought copy and if his copy is fully corrected in order to notify him that his grade is available.
[ "Check", "the", "user", "s", "drop", "to", "see", "if", "he", "has", "corrected", "enought", "copy", "and", "if", "his", "copy", "is", "fully", "corrected", "in", "order", "to", "notify", "him", "that", "his", "grade", "is", "available", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Controller/CorrectionController.php#L245-L276
40,492
claroline/Distribution
plugin/exo/Installation/Updater/Updater060000.php
Updater060000.migrateDateData
private function migrateDateData() { if (!$this->connection->getSchemaManager()->listTableDetails('ujm_exercise')->hasColumn('start_date')) { return; // migration has already been executed } $this->log('Moving date data from ujm_exercise to claro_resource_node...'); $startQuery = ' UPDATE claro_resource_node AS node JOIN ujm_exercise AS exo ON node.id = exo.resourceNode_id SET node.accessible_from = exo.start_date WHERE node.accessible_from IS NULL AND exo.start_date IS NOT NULL '; $endQuery = ' UPDATE claro_resource_node AS node JOIN ujm_exercise AS exo ON node.id = exo.resourceNode_id SET node.accessible_until = exo.end_date WHERE node.accessible_until IS NULL AND exo.start_date IS NOT NULL AND exo.use_date_end = 1 '; $this->connection->exec($startQuery); $this->connection->exec($endQuery); }
php
private function migrateDateData() { if (!$this->connection->getSchemaManager()->listTableDetails('ujm_exercise')->hasColumn('start_date')) { return; // migration has already been executed } $this->log('Moving date data from ujm_exercise to claro_resource_node...'); $startQuery = ' UPDATE claro_resource_node AS node JOIN ujm_exercise AS exo ON node.id = exo.resourceNode_id SET node.accessible_from = exo.start_date WHERE node.accessible_from IS NULL AND exo.start_date IS NOT NULL '; $endQuery = ' UPDATE claro_resource_node AS node JOIN ujm_exercise AS exo ON node.id = exo.resourceNode_id SET node.accessible_until = exo.end_date WHERE node.accessible_until IS NULL AND exo.start_date IS NOT NULL AND exo.use_date_end = 1 '; $this->connection->exec($startQuery); $this->connection->exec($endQuery); }
[ "private", "function", "migrateDateData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connection", "->", "getSchemaManager", "(", ")", "->", "listTableDetails", "(", "'ujm_exercise'", ")", "->", "hasColumn", "(", "'start_date'", ")", ")", "{", "return...
Date control access, as well as creation dates, move from the exercises to the resource nodes themselves.
[ "Date", "control", "access", "as", "well", "as", "creation", "dates", "move", "from", "the", "exercises", "to", "the", "resource", "nodes", "themselves", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060000.php#L36-L64
40,493
claroline/Distribution
plugin/exo/Installation/Updater/Updater060000.php
Updater060000.checkQuestionReferences
private function checkQuestionReferences() { if (!in_array('ujm_interaction', $this->connection->getSchemaManager()->listTableNames())) { return; // migration has already been executed } $this->log('Checking question references...'); $checkQuery = ' SELECT id AS interaction_id, question_id FROM ujm_interaction WHERE id <> question_id '; $divergentIds = $this->connection->query($checkQuery)->fetchAll(); if (count($divergentIds) > 0) { $this->log('Found diverging identifiers, looking for references to update...'); // key = table, value = name of the foreign key on "interaction_id" $candidateTables = [ 'ujm_hint' => 'FK_B5FFCBE7886DEE8F', 'ujm_interaction_graphic' => 'FK_9EBD442F886DEE8F', 'ujm_interaction_hole' => 'FK_7343FAC1886DEE8F', 'ujm_interaction_matching' => 'FK_AC9801C7886DEE8F', 'ujm_interaction_open' => 'FK_BFFE44F4886DEE8F', 'ujm_interaction_qcm' => 'FK_58C3D5A1886DEE8F', 'ujm_response' => 'FK_A7EC2BC2886DEE8F', ]; // if values need to be changed in those tables, unique indexes must be dropped/restored $uniqueIndexes = [ 'ujm_interaction_graphic' => 'UNIQ_9EBD442F886DEE8F', 'ujm_interaction_hole' => 'UNIQ_7343FAC1886DEE8F', 'ujm_interaction_matching' => 'UNIQ_AC9801C7886DEE8F', 'ujm_interaction_qcm' => 'UNIQ_58C3D5A1886DEE8F', 'ujm_interaction_open' => 'UNIQ_BFFE44F4886DEE8F', ]; // makes the result set more usable (key = interaction_id, value = question _id) $divergentByInteraction = []; foreach ($divergentIds as $divergentPair) { $divergentByInteraction[$divergentPair['interaction_id']] = $divergentPair['question_id']; } $idChain = implode(',', array_keys($divergentByInteraction)); foreach ($candidateTables as $table => $foreignKey) { $referenceQuery = " SELECT id, interaction_id FROM {$table} WHERE interaction_id IN ({$idChain}) "; $foundIds = $this->connection->query($referenceQuery)->fetchAll(); if (count($foundIds) > 0) { $this->log("Found reference(s) in {$table}, updating..."); // foreign key must be dropped to update value $this->connection->exec(" ALTER TABLE {$table} DROP FOREIGN KEY {$foreignKey}; "); if (in_array($table, array_keys($uniqueIndexes))) { // unique index must be dropped too $this->connection->exec(" DROP INDEX {$uniqueIndexes[$table]} ON {$table}; "); } foreach ($foundIds as $idRow) { $this->connection->exec(" UPDATE {$table} SET interaction_id = {$divergentByInteraction[$idRow['interaction_id']]} WHERE id = {$idRow['id']} "); } // restore foreign key (so that it can be dropped by the migration file) // BUT make it already point to question (to avoid references issues) $restoreQuery = " ALTER TABLE {$table} ADD CONSTRAINT {$foreignKey} FOREIGN KEY (interaction_id) REFERENCES ujm_question (id) "; if (in_array($table, array_keys($uniqueIndexes))) { // restore unique index too $this->connection->exec(" CREATE INDEX {$uniqueIndexes[$table]} ON {$table} (interaction_id); "); } $this->connection->exec($restoreQuery); } } } }
php
private function checkQuestionReferences() { if (!in_array('ujm_interaction', $this->connection->getSchemaManager()->listTableNames())) { return; // migration has already been executed } $this->log('Checking question references...'); $checkQuery = ' SELECT id AS interaction_id, question_id FROM ujm_interaction WHERE id <> question_id '; $divergentIds = $this->connection->query($checkQuery)->fetchAll(); if (count($divergentIds) > 0) { $this->log('Found diverging identifiers, looking for references to update...'); // key = table, value = name of the foreign key on "interaction_id" $candidateTables = [ 'ujm_hint' => 'FK_B5FFCBE7886DEE8F', 'ujm_interaction_graphic' => 'FK_9EBD442F886DEE8F', 'ujm_interaction_hole' => 'FK_7343FAC1886DEE8F', 'ujm_interaction_matching' => 'FK_AC9801C7886DEE8F', 'ujm_interaction_open' => 'FK_BFFE44F4886DEE8F', 'ujm_interaction_qcm' => 'FK_58C3D5A1886DEE8F', 'ujm_response' => 'FK_A7EC2BC2886DEE8F', ]; // if values need to be changed in those tables, unique indexes must be dropped/restored $uniqueIndexes = [ 'ujm_interaction_graphic' => 'UNIQ_9EBD442F886DEE8F', 'ujm_interaction_hole' => 'UNIQ_7343FAC1886DEE8F', 'ujm_interaction_matching' => 'UNIQ_AC9801C7886DEE8F', 'ujm_interaction_qcm' => 'UNIQ_58C3D5A1886DEE8F', 'ujm_interaction_open' => 'UNIQ_BFFE44F4886DEE8F', ]; // makes the result set more usable (key = interaction_id, value = question _id) $divergentByInteraction = []; foreach ($divergentIds as $divergentPair) { $divergentByInteraction[$divergentPair['interaction_id']] = $divergentPair['question_id']; } $idChain = implode(',', array_keys($divergentByInteraction)); foreach ($candidateTables as $table => $foreignKey) { $referenceQuery = " SELECT id, interaction_id FROM {$table} WHERE interaction_id IN ({$idChain}) "; $foundIds = $this->connection->query($referenceQuery)->fetchAll(); if (count($foundIds) > 0) { $this->log("Found reference(s) in {$table}, updating..."); // foreign key must be dropped to update value $this->connection->exec(" ALTER TABLE {$table} DROP FOREIGN KEY {$foreignKey}; "); if (in_array($table, array_keys($uniqueIndexes))) { // unique index must be dropped too $this->connection->exec(" DROP INDEX {$uniqueIndexes[$table]} ON {$table}; "); } foreach ($foundIds as $idRow) { $this->connection->exec(" UPDATE {$table} SET interaction_id = {$divergentByInteraction[$idRow['interaction_id']]} WHERE id = {$idRow['id']} "); } // restore foreign key (so that it can be dropped by the migration file) // BUT make it already point to question (to avoid references issues) $restoreQuery = " ALTER TABLE {$table} ADD CONSTRAINT {$foreignKey} FOREIGN KEY (interaction_id) REFERENCES ujm_question (id) "; if (in_array($table, array_keys($uniqueIndexes))) { // restore unique index too $this->connection->exec(" CREATE INDEX {$uniqueIndexes[$table]} ON {$table} (interaction_id); "); } $this->connection->exec($restoreQuery); } } } }
[ "private", "function", "checkQuestionReferences", "(", ")", "{", "if", "(", "!", "in_array", "(", "'ujm_interaction'", ",", "$", "this", "->", "connection", "->", "getSchemaManager", "(", ")", "->", "listTableNames", "(", ")", ")", ")", "{", "return", ";", ...
One part of the migration consists in merging the Interaction entity into the Question entity. For the merge to be successful, we must ensure that previous references to the interaction table point to the question table. In most installations, this won't require any effort, because despite their one-to-many relationship, these two entities have always been used in a one-to-one fashion. Having always been created and deleted altogether, their generated id is expected to be identical. Thus, simply renaming an "interaction_id" to a "question_id" and make it point to the question table should be sufficient. However, in the unlikely event that identifiers are different, all foreign keys must be updated properly.
[ "One", "part", "of", "the", "migration", "consists", "in", "merging", "the", "Interaction", "entity", "into", "the", "Question", "entity", ".", "For", "the", "merge", "to", "be", "successful", "we", "must", "ensure", "that", "previous", "references", "to", "...
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Installation/Updater/Updater060000.php#L81-L179
40,494
claroline/Distribution
plugin/collecticiel/Entity/Correction.php
Correction.addGrade
public function addGrade(\Innova\CollecticielBundle\Entity\Grade $grades) { $this->grades[] = $grades; return $this; }
php
public function addGrade(\Innova\CollecticielBundle\Entity\Grade $grades) { $this->grades[] = $grades; return $this; }
[ "public", "function", "addGrade", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Grade", "$", "grades", ")", "{", "$", "this", "->", "grades", "[", "]", "=", "$", "grades", ";", "return", "$", "this", ";", "}" ]
Add grades. @param \Innova\CollecticielBundle\Entity\Grade $grades @return Correction
[ "Add", "grades", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Correction.php#L463-L468
40,495
claroline/Distribution
plugin/collecticiel/Entity/Correction.php
Correction.removeGrade
public function removeGrade(\Innova\CollecticielBundle\Entity\Grade $grades) { $this->grades->removeElement($grades); }
php
public function removeGrade(\Innova\CollecticielBundle\Entity\Grade $grades) { $this->grades->removeElement($grades); }
[ "public", "function", "removeGrade", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "Grade", "$", "grades", ")", "{", "$", "this", "->", "grades", "->", "removeElement", "(", "$", "grades", ")", ";", "}" ]
Remove grades. @param \Innova\CollecticielBundle\Entity\Grade $grades
[ "Remove", "grades", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/Correction.php#L475-L478
40,496
claroline/Distribution
main/core/Entity/Resource/Text.php
Text.getContent
public function getContent() { $content = null; if (0 < $this->revisions->count()) { $content = $this->revisions->get(0)->getContent(); } return $content; }
php
public function getContent() { $content = null; if (0 < $this->revisions->count()) { $content = $this->revisions->get(0)->getContent(); } return $content; }
[ "public", "function", "getContent", "(", ")", "{", "$", "content", "=", "null", ";", "if", "(", "0", "<", "$", "this", "->", "revisions", "->", "count", "(", ")", ")", "{", "$", "content", "=", "$", "this", "->", "revisions", "->", "get", "(", "0...
Get the current content of the Resource. @return string
[ "Get", "the", "current", "content", "of", "the", "Resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Resource/Text.php#L97-L105
40,497
claroline/Distribution
main/app/API/Utils/ArrayUtils.php
ArrayUtils.set
public static function set(array &$object, $keys, $value) { $keys = explode('.', $keys); $depth = count($keys); $key = array_shift($keys); if (1 === $depth) { $object[$key] = $value; } else { if (!isset($object[$key])) { $object[$key] = []; } elseif (!is_array($object[$key])) { throw new \Exception('Cannot set property because it already exists as a non \stdClass'); } static::set($object[$key], implode('.', $keys), $value); } }
php
public static function set(array &$object, $keys, $value) { $keys = explode('.', $keys); $depth = count($keys); $key = array_shift($keys); if (1 === $depth) { $object[$key] = $value; } else { if (!isset($object[$key])) { $object[$key] = []; } elseif (!is_array($object[$key])) { throw new \Exception('Cannot set property because it already exists as a non \stdClass'); } static::set($object[$key], implode('.', $keys), $value); } }
[ "public", "static", "function", "set", "(", "array", "&", "$", "object", ",", "$", "keys", ",", "$", "value", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "keys", ")", ";", "$", "depth", "=", "count", "(", "$", "keys", ")", ";",...
This is more or less the equivalent of lodash set for array. @param array $object @param string $keys - the property path @param $value @throws \Exception
[ "This", "is", "more", "or", "less", "the", "equivalent", "of", "lodash", "set", "for", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Utils/ArrayUtils.php#L16-L33
40,498
claroline/Distribution
main/app/API/Utils/ArrayUtils.php
ArrayUtils.get
public static function get(array $object, $keys) { $parts = explode('.', $keys); $key = array_shift($parts); if (isset($object[$key])) { if (!empty($parts) && is_array($object[$key])) { return static::get($object[$key], implode('.', $parts)); } return $object[$key]; } if (array_key_exists($key, $object)) { return null; } throw new \Exception("Key `{$keys}` doesn't exist for array keys [".implode(',', array_keys($object)).']'); }
php
public static function get(array $object, $keys) { $parts = explode('.', $keys); $key = array_shift($parts); if (isset($object[$key])) { if (!empty($parts) && is_array($object[$key])) { return static::get($object[$key], implode('.', $parts)); } return $object[$key]; } if (array_key_exists($key, $object)) { return null; } throw new \Exception("Key `{$keys}` doesn't exist for array keys [".implode(',', array_keys($object)).']'); }
[ "public", "static", "function", "get", "(", "array", "$", "object", ",", "$", "keys", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "keys", ")", ";", "$", "key", "=", "array_shift", "(", "$", "parts", ")", ";", "if", "(", "isset",...
This is more or less the equivalent of lodash get for array. @param array $object - the array @param string $keys - the property path @return mixed @throws \Exception
[ "This", "is", "more", "or", "less", "the", "equivalent", "of", "lodash", "get", "for", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Utils/ArrayUtils.php#L45-L62
40,499
claroline/Distribution
main/core/Manager/Resource/ResourceRestrictionsManager.php
ResourceRestrictionsManager.isGranted
public function isGranted(ResourceNode $resourceNode, array $userRoles): bool { return $this->hasRights($resourceNode, $userRoles) && $resourceNode->isActive() && $resourceNode->isPublished() && ($this->isStarted($resourceNode) && !$this->isEnded($resourceNode)) && $this->isUnlocked($resourceNode) && $this->isIpAuthorized($resourceNode); }
php
public function isGranted(ResourceNode $resourceNode, array $userRoles): bool { return $this->hasRights($resourceNode, $userRoles) && $resourceNode->isActive() && $resourceNode->isPublished() && ($this->isStarted($resourceNode) && !$this->isEnded($resourceNode)) && $this->isUnlocked($resourceNode) && $this->isIpAuthorized($resourceNode); }
[ "public", "function", "isGranted", "(", "ResourceNode", "$", "resourceNode", ",", "array", "$", "userRoles", ")", ":", "bool", "{", "return", "$", "this", "->", "hasRights", "(", "$", "resourceNode", ",", "$", "userRoles", ")", "&&", "$", "resourceNode", "...
Checks access restrictions of a ResourceNodes. @param ResourceNode $resourceNode @param Role[] $userRoles @return bool
[ "Checks", "access", "restrictions", "of", "a", "ResourceNodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/ResourceRestrictionsManager.php#L61-L69